제출 #101358

#제출 시각아이디문제언어결과실행 시간메모리
101358naoai동굴 (IOI13_cave)C++14
100 / 100
403 ms640 KiB
#include "cave.h" #include <bits/stdc++.h> using namespace std; const int nmax = 5000; bool viz[nmax + 1]; int v[nmax + 1]; int s[nmax + 1], d[nmax + 1]; void divide (int x, int y, int ind, int lst) { if (lst == -1) lst = nmax + 1; if (x == y) { s[x] = (lst > ind ? v[x] : 1 - v[x]); d[x] = ind; viz[x] = 1; return ; } int mij = (x + y) / 2; for (int i = x; i <= mij; ++ i) if (viz[i] == 0) v[i] ^= 1; int val = tryCombination(v); if (val == -1) val = nmax + 1; if ((val > ind && lst <= ind) || (val <= ind && lst > ind)) { divide(x, mij, ind, val); } else { for (int i = x; i <= mij; ++ i) if (viz[i] == 0) v[i] ^= 1; divide(mij + 1, y, ind, lst); } } void exploreCave(int N) { for (int i = 0; i < N; ++ i) { for (int j = 0; j < N; ++ j) v[j] = s[j]; divide(0, N - 1, i, tryCombination(v)); } 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...