제출 #161609

#제출 시각아이디문제언어결과실행 시간메모리
161609kostia244Cave (IOI13_cave)C++14
100 / 100
1977 ms504 KiB
#include "cave.h"
#include<bits/stdc++.h>
const int maxn = 5051;
int n;
int S[maxn], D[maxn];
void fill(int v, int q) {
	int c = 0;
	for(int i = 0;i < n&&c<q; i++) {
		if(D[i]==-1)c++,S[i]=v;
	}
}
int get(int x) {
	int i = 0, c = 0;
	while(c < x) {
		if(D[i]==-1)c++;
		if(c!=x)i++;
	}
	return i;
}
void exploreCave(int N) {
	n = N;
	memset(S, 0, sizeof S);
	memset(D, -1, sizeof D);
	int c = 0;
	int x = 0;
	for(int i = 0; i < n; i++) {
		fill(1, n);
		x = tryCombination(S);
		if(x>i||x==-1) {
			x=1;
		} else {
			x=0;
		}
		int a = 0;
		for(int j = 1<<12; j; j>>=1) {
			if(a+j>n)continue;
			fill(x^1, n);
			fill(x, a+j);
			int t = tryCombination(S);
			if(t<=i&&t!=-1) {
				a+=j;
			}
		}
		a = get(a+1);
		D[a] = i;
		S[a] = x;
	}
	answer(S, D);
}

컴파일 시 표준 에러 (stderr) 메시지

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:24:6: warning: unused variable 'c' [-Wunused-variable]
  int c = 0;
      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...