제출 #545667

#제출 시각아이디문제언어결과실행 시간메모리
545667AJ00동굴 (IOI13_cave)C++14
46 / 100
26 ms444 KiB
#include <bits/stdc++.h> #include "cave.h" using namespace std; int n; void exploreCave(int N){ n = N; int S[n],D[n],temp[n]; vector<bool> found(n,false); for (int i = 0; i < n; i++){ S[i] = 0; D[i] = -1; } int ans = tryCombination(S),i=0,runs =0; while (ans!=-1){ int prevans = ans; while(prevans == ans){ //cout << ans << "\n"; //cout << runs << " "; while (found[i]){ // cout << i << " "; i = (i+1)%n; } // cout << "\n"; // cout << i << " "; S[i] ^= 1; runs++; ans = tryCombination(S); i = (i+1)%n; } //cout << prevans << " " << ans << " " << ((i-1)+n)%n << "\n"; if (ans == -1){ break; } found[((i-1)+n)%n] = true; if (ans < prevans){ //D[((i-1)+n)%n] = ans; S[((i-1)+n)%n] ^= 1; ans = prevans; //S1[i-1] = S[i-1]; } //cout << "f " << ((i-1)+n)%n << " " << S[((i-1)+n)%n] << "\n"; } // cout << runs << "\n"; for (int i = 0; i < n; i++){ temp[i] = S[i]; } for (int i = 0; i < n; i++){ temp[i] ^= 1; D[i] = tryCombination(temp); temp[i] ^= 1; //cout << D[i] << " "; } answer(S,D); }
#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...