This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "cave.h"
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
const int NMAX = (int)1e3 * 6;
int S[NMAX],D[NMAX];
bool fixat[NMAX];
void exploreCave(int N) {
vector<pair<int,int>>buton;
buton.push_back({0,0});
for (int i = 0; i < N;++i)
buton.push_back({0,i});
for (int i = 0; i < N;++i) {
//for (auto j : buton)
// cout << j.second << ' ';
//cout << '\n';
//for (int j = 0; j < N;++j)
// cout << S[j] << ' ';
//cout << '\n';
int a = tryCombination(S);
//cout << a << '\n';
if (a == i) {
for (int j = 0; j < (int)buton.size();++j)
S[buton[j].second] ^= 1;
}
int l = 1,r = (int)buton.size() - 1;
int ans = 1;
//cout << l << ' ' << r << '\n';
if ((int)buton.size() == 2) {
D[buton[1].second] = i;
int v = tryCombination(S);
if (v == -1) answer(S,D);
S[buton[1].second] ^= 1;
answer(S,D);
}
while (l <= r) {
int mid = (l + r) / 2;
for (int g = l; g <= mid;++g)
S[buton[g].second] ^= 1;
a = tryCombination(S);
//cout << l << ' ' << mid << ' ' << r << ' ' << a << '\n';
//for (int j = 0; j < N;++j)
// cout << S[j] << ' ';
//cout << "!\n";
if (a == i) {
ans = mid;
r = mid - 1;
for (int g = l; g <= mid;++g)
S[buton[g].second] ^= 1;
}
else {
ans = l;
}
}
//cout << buton[ans].second << ' ' << ans << '\n';
int t = buton[ans].second;
buton.erase(buton.begin() + ans);
D[t] = i;
}
answer(S,D);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |