이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "cave.h"
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP MP make_pair
#define EB emplace_back
#define V vector
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << "LINE(" << __LINE__ << ") -> " << #x << " is " << (x) << endl
#define ask tryCombination
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;
const int INF = 1e9 + 7, N = 5005;
int s[N], d[N], done[N], n;
pi go(int i) { // find the switch that controls door i
vi can;
for(int i = 0; i < n; i++)
if(!done[i])
can.PB(i);
auto inv = [&] (vi& v) {
for(int i:v)
s[i] ^= 1;
};
int x = ask(s);
assert(x >= i);
while(can.size() > 1) {
int sz = can.size();
vi l, r;
for(int i = 0; i < sz / 2; i++) l.PB(can[i]);
for(int i = sz / 2; i < sz; i++) r.PB(can[i]);
inv(l);
int y = ask(s);
inv(l);
if((x == i) == (y == i)) { // in r
can = r;
} else { // in l
can = l;
}
}
assert(can.size() == 1);
int id = can[0], state = s[id];
if(x == i) state ^= 1;
return {id, state};
}
void exploreCave(int _n) {
n = _n;
// for(int i = 0; i < n; i++) {
// pi p = go(i); // {which switch, which state}
// s[p.F] = p.S;
// d[p.F] = i;
// done[p.F] = 1;
// }
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... |