이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//#define NDEBUG
#include "cave.h"
#include <bits/stdc++.h>
#include <bits/extc++.h>
#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define mt make_tuple
#define gt(t, i) get<i>(t)
#define iceil(a, b) ((a + b - 1) / b)
#define tomax(a, b) (a = max(a, b))
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
if(pvaspace) b << " "; pvaspace=true;\
b << pva;\
}\
b << "\n";}
//#define TEST
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;
using tiii = tuple<int, int, int>;
const ll MOD = 1000000007;
const ll MAX = 2147483647;
template<typename A, typename B>
ostream& operator<<(ostream& o, pair<A, B> p){
return o << '(' << p.F << ',' << p.S << ')';
}
bool check(vector<int>& pos, int l, int r, int* q, int t, int n){
for(int i = l; i <= r; i++) q[pos[i]] = !q[pos[i]];
int qr = tryCombination(q);
bool ans = qr > t || qr == -1;
// cerr << l << " " << r << " " << t << " " << qr << "\n";
// printv(vector<int>(q, q + n), cerr);
for(int i = l; i <= r; i++) q[pos[i]] = !q[pos[i]];
// cerr << ans << "\n";
return ans;
}
void exploreCave(int n){
int q[n];
fill(q, q + n, 0);
int s[n], d[n];
fill(s, s + n, -1);
fill(d, d + n, -1);
for(int i = 0; i < n; i++){
vector<int> pos;
int qr = tryCombination(q);
// cerr << "test " << i << " " << qr << "\n";
if(qr != i){
for(int j = 0; j < n; j++){
if(s[j] == -1){
q[j] = !q[j];
}
}
}
for(int j = 0; j < n; j++){
if(s[j] == -1) pos.eb(j);
}
int l = 0, r = pos.size() - 1;
while(l < r){
int m = (l + r) / 2;
if(check(pos, l, m, q, i, n)) r = m;
else l = m + 1;
}
s[pos[l]] = q[pos[l]] = !q[pos[l]];
d[pos[l]] = 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... |