제출 #52127

#제출 시각아이디문제언어결과실행 시간메모리
52127rondojim동굴 (IOI13_cave)C++17
0 / 100
39 ms512 KiB
#include <bits/stdc++.h>
#include "cave.h"
using namespace std;

const int MAXN = 5e3 + 5;

int st[MAXN], con[MAXN], cnt, n, SS[MAXN], DD[MAXN];

/*
int tryCombination(int S[]){
	int mn = MAXN;
	for(int i=0; i<n; ++i) if(S[i] != SS[i]) mn = min(mn, DD[i]);
	return mn == MAXN ? -1 : mn;
}
*/
/*
void answer(int S[], int D[]){
	bool ok = true;
	for(int i=0; i<n; ++i) if(S[i] != SS[i]) ok = false;
	for(int i=0; i<n; ++i) if(D[i] != DD[i]) ok = false;
	puts(ok ? "YES" : "NO");
}
*/

void solve(int ret){
	int lo = 0, hi = n - 1, mid, res, r;
	while(lo <= hi){
		mid = (lo + hi)>>1;
		for(int i=0; i<=mid; ++i) st[i] ^= 1;
		r = tryCombination(st);
		for(int i=0; i<=mid; ++i) st[i] ^= 1;
		if(r != ret) hi = mid - 1, res = mid;
		else lo = mid + 1;
	}
	st[res] ^= 1;
}

void exploreCave(int N){
	n = N;
	for(int i=0; i<N; ++i) st[i] = rand() & 1;
	while(true){
		int ret = tryCombination(st);
		if(ret == -1){
			for(int i=0; i<n; ++i){ st[i] ^= 1; con[i] = tryCombination(st); st[i] ^= 1; }
			break;
		}
		solve(ret);
	}
	answer(st, con);
}
/*
int main(){
	scanf("%d", &n);
	for(int i=0; i<n; ++i) scanf("%d", &SS[i]);
	for(int i=0; i<n; ++i) scanf("%d", &DD[i]);
	exploreCave(n);
	return 0;
}
*/

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

cave.cpp: In function 'void solve(int)':
cave.cpp:35:10: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
  st[res] ^= 1;
  ~~~~~~~~^~~~
#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...