제출 #204744

#제출 시각아이디문제언어결과실행 시간메모리
204744bogdan_ogorodniy동굴 (IOI13_cave)C++14
100 / 100
1127 ms640 KiB
#include <bits/stdc++.h> #include "cave.h" using namespace std; const int inf = 1e9 + 7; int N; int _S[5001], _P[5001]; // int tryCombination(int a[]) { // int ans = 0; // vector <int> op(N + 1, 0); // for (int i = 0; i < N; i++) { // if (_S[i] == a[i]) op[_P[i]] = true; // } // while (op[ans++]); // return ans - 1; // } // void answer(int a[], int b[]) { // cout << tryCombination(a) << '\t' << tryCombination(_S) << '\n'; // for (int i = 0; i < N; i++) cout << a[i] << ' '; cout << '\t'; for (int i = 0; i < N; i++) cout << _S[i] << ' '; cout << '\n'; // for (int i = 0; i < N; i++) cout << b[i] << ' '; cout << '\t'; for (int i = 0; i < N; i++) cout << _P[i] << ' '; cout << '\n'; // } int temp[5001]; int s[5001], p[5001]; bool fnd[5001]; void sett(int pos, int f) { memset(temp, 0, sizeof temp); for (int i = 0; i < pos; i++) { if (!fnd[i]) { temp[i] = f; } else { temp[i] = s[i]; } } for (int i = pos; i < N; i++) { if (!fnd[i]) { temp[i] = !f; } else { temp[i] = s[i]; } } } void exploreCave(int n) { N = n; for (int i = 0; i < n; i++) { sett(n, 1); int k = tryCombination(temp); if (k == -1) k = n + 1; bool f = 0; if (k > i) { f = 1; } else { f = 0; } int l = 0, r = n - 1; while (r - l > 0) { int m = (l + r) / 2; sett(m + 1, f); int k = tryCombination(temp); if (k == -1) k = n + 1; if (k > i) { r = m; } else { l = m + 1; } } p[l] = i; s[l] = f; fnd[l] = 1; } answer(s, p); } // signed main() { // N = 4; // _P[0] = 3; _P[1] = 1; _P[2] = 0; _P[3] = 2; // _S[0] = 1; _S[1] = 1; _S[2] = 1; // mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); // // N = 5; // // for (int i = 0; i < N; i++) _P[i] = i; // // random_shuffle(_P, _P + N); // // for (int i = 0; i < N; i++) _S[i] = rng() % 2; // cout << tryCombination(vector<int>{1, 1, 1, 0}.data()) << '\n'; // exploreCave(N); // return 0; // }
#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...