Submission #464746

#TimeUsernameProblemLanguageResultExecution timeMemory
464746AdamGSCave (IOI13_cave)C++14
100 / 100
261 ms456 KiB
#include "cave.h"
#include<bits/stdc++.h>
using namespace std;
#define rep(a, b) for(int a = 0; a < (b); ++a)
void exploreCave(int N) {
	int S[N], D[N];
	rep(i, N) {
		S[i]=0;
		D[i]=-1;
	}
	int lst=tryCombination(S);
	rep(i, N) {
		int p=0, k=N-1;
		while(p<k) {
			int sr=(p+k)/2;
			for(int j=p; j<=sr; ++j) if(D[j]==-1) S[j]^=1;
			int nowe=tryCombination(S);
			if(nowe!=i && lst!=i || nowe==i && lst==i) p=sr+1; else k=sr;
			lst=nowe;
		}
		D[p]=i;
		if(lst==i) S[p]^=1;
		lst=tryCombination(S);
	}
	answer(S, D);
}

Compilation message (stderr)

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:18:15: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   18 |    if(nowe!=i && lst!=i || nowe==i && lst==i) p=sr+1; else k=sr;
      |       ~~~~~~~~^~~~~~~~~
#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...