제출 #131958

#제출 시각아이디문제언어결과실행 시간메모리
131958junodeveloper동굴 (IOI13_cave)C++14
컴파일 에러
0 ms0 KiB
#include "cave.h"
#include <bits/stdc++.h>
using namespace std;
int S[5010], D[5010], rev[5010];
int Try() {
	return tryCombination(S);
}
void exploreCave(int N) {
	memset(D, -1, sizeof(D));
	srand(123);
	for(int i=0; i<N; i++) S[i] = rand() % 2;
	int s = 0, x, B, idx, nxt = Try(), tmp;
	while(1) {
		idx = nxt;
		if(idx != -1) x = idx - s + 1;
		else x = N - s;
		B = sqrt((N - s) / x);
		vector<int> a;
		int f = -1;
		for(int i=0; i<N; i++) {
			if(D[i] == -1) {
				a.push_back(i);
				if(a.size() == B) {
					for(auto& j : a) S[j] ^= 1;
					tmp = Try();
					if(idx != tmp) {
						for(auto& j : a) S[j] ^= 1;
						for(auto& j : a) {
							S[j] ^= 1;
							int t = Try();
							if((t != -1 && t < idx) || idx == -1) {
								while(t == -1);
								rev[t] = j;
								D[j] = t;
							} else if(t == -1 || idx < t) {
								rev[idx] = j;
								D[j] = idx;
								f = j;
								nxt = t;
							}
							S[j] ^= 1;
						}
						for(auto& j : a) S[j] ^= 1;
					}
					for(auto& j : a) S[j] ^= 1;
					a.clear();
				}
			}
		}
		if(a.size() > 0) {
			for(auto& j : a) S[j] ^= 1;
			tmp = Try();
			if(idx != tmp) {
				for(auto& j : a) S[j] ^= 1;
				for(auto& j : a) {
					S[j] ^= 1;
					int t = Try();
					if((t != -1 && t < idx) || idx == -1) {
						while(t == -1);
						rev[t] = j;
						D[j] = t;
					} else if(t == -1 || idx < t) {
						rev[idx] = j;
						D[j] = idx;
						f = j;
						nxt = t;
					}
					S[j] ^= 1;
				}
				for(auto& j : a) S[j] ^= 1;
			}
			for(auto& j : a) S[j] ^= 1;
			a.clear();
		}
		if(f != -1) S[f] ^= 1;
		if(idx == -1) break;
		s = idx + 1;
	}
	answer(S, D);
}

int main() {

}

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

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:23:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(a.size() == B) {
        ~~~~~~~~~^~~~
/tmp/ccR4BIsN.o: In function `main':
cave.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccrOnrb6.o:grader.c:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status