제출 #1320219

#제출 시각아이디문제언어결과실행 시간메모리
1320219yessimkhan동굴 (IOI13_cave)C++20
64 / 100
80 ms516 KiB
#include "cave.h" #include <bits/stdc++.h> // solved by bekagg #define ll long long #define ent '\n' #define pb push_back #define all(x) x.begin(),x.end() #define PRaim_bek_abi ios_base::sync_with_stdio(0);cin.tie(0); using namespace std; const int N = 5e5+5; const int MOD = 1e9+7; int d[N] , cnt , us[N] , s[N] , p , nn; void build(int tl , int tr){ for (int i = tl; i <= tr; i++){ if (us[i]) continue; s[i] = 1 - s[i]; } int pos = tryCombination(s); if (pos == -1) pos = nn; int tm = (tl + tr) / 2; if (pos >= p){ return; } else { for (int i = tl; i <= tr; i++){ if (us[i]) continue; s[i] = 1 - s[i]; } if (tl == tr){ if (us[tl] == 0){ us[tl] = 1; cnt++; } } else { build(tl , tm) , build(tm + 1 , tr); } } } void exploreCave(int n){ /*if (n > 2000){ int pp = tryCombination(s); if (pp == -1){ for (int i = 0; i < n; i++){ s[i] = 1 - s[i]; int pos = tryCombination(s); d[i] = pos; s[i] = 1 - s[i]; } answer(s , d); return; } for (int i = 0; i < n; i++){ s[i] = 0; int p1 = tryCombination(s); s[i] = 1; int p2 = tryCombination(s); if (p1 == 0) s[i] = 0; else if (p2 == 0) s[i] = 1; } for (int i = 0; i < n; i++){ s[i] = 1 - s[i]; d[i] = i; int pos = tryCombination(s); if (pos == -1) pos = n; if (pos == i + 1) continue; s[i + 1] = 1 - s[i + 1]; pos = tryCombination(s); } answer(s , d); return; }*/ nn = n; while(cnt < n){ p = tryCombination(s); if (p == -1) p = n; build(0 , n - 1); } for (int i = 0; i < n; i++){ s[i] = 1 - s[i]; int pos = tryCombination(s); d[i] = pos; s[i] = 1 - s[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...