제출 #962893

#제출 시각아이디문제언어결과실행 시간메모리
962893raspy동굴 (IOI13_cave)C++14
51 / 100
400 ms776 KiB
#include "cave.h" #include <iostream> using namespace std; int s[5005]; int rs[5005]; int cn[5005]; void exploreCave(int n) { int lg = 0; while ((1<<lg) < n) lg++; // cout << n << " " << lg << "\n"; for (int i = 0; i < n; i++) rs[i] = -1; for (int tr = 0; tr < n; tr++) { // cout << "-> " << tr << "\n"; int ixn = 0; for (int j = 0; j < lg; j++) { // cout << " "; for (int i = 0; i < n; i++) { s[i] = (i&(1<<j) ? 1 : 0); if (rs[i] != -1) s[i] = rs[i]; // cout << s[i] << " "; } // cout << "\n"; int odg = tryCombination(s)-1; if (odg == -2) odg = n-1; // cout << "\t" << odg << "\n"; if (odg >= tr) { // cout << "\ttest" << "\n"; ixn |= (1<<j); } } int ix = 0; for (int j = 0; j < lg; j++) if (!(ixn & (1<<j))) ix |= (1<<j); for (int i = 0; i < n; i++) { s[i] = 0; if (rs[i] != -1) s[i] = rs[i]; } s[ixn] = 1; if (rs[ix] == -1) s[ix] = 1; int odg = tryCombination(s)-1; if (odg == -2) odg = n-1; // cout << "-> " << tr << " <> " << odg << ", " << ixn << "\n"; if (odg >= tr) { // cout << ixn << " " << tr << "\n"; cn[ixn] = tr; rs[ixn] = 1; } else { cn[ix] = tr; rs[ix] = 0; } } answer(rs, cn); }
#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...