| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|
| 1305900 | | Johan | 동굴 (IOI13_cave) | C++20 | | 2096 ms | 980 KiB |
#pragma GCC optimize("Ofast")
#include "cave.h"
#include "bits/stdc++.h"
using namespace std;
int f(vector < int > a){
int n = (int)a.size();
int s[n];
for(int i = 0; i < n; i++)
s[i] = a[i];
return tryCombination(s);
}
int ok(vector < int > s, bool turn, set < int > st, int l, int r){
for(int i = l; i <= r; i++){
if(st.count(i) == 0)
s[i] = turn ^ 1;
}
int cur = f(s);
return (cur == -1 ? 1e9 : cur);
}
void exploreCave(int n){
vector < int > s(n, 1);
int x = f(s);
bool turn = (x >= 1);
set < int > st;
vector < pair < int , int > > y;
while(y.size() != n){
for(int i = 0; i < n; i++){
if(st.count(i) == 0){
s[i] = turn;
}
}
x = f(s);
if(x == -1)x = n;
int p = 0;
while(p < n){
int l = p, r = n - 1;
int best = -1;
while(r >= l){
int mid = (l + r) >> 1;
if(ok(s, turn, st, p, mid) < x){
r = mid - 1;
best = mid;
}
else l = mid + 1;
}
if(best == -1)break;
s[best] = turn ^ 1;
y.push_back({best, f(s)});
st.insert(best);
s[best] = turn;
p = best + 1;
}
turn ^= 1;
}
sort(y.begin(), y.end());
int e[n], o[n], id1 = 0, id2 = 0;
for(auto [idx, va] : y)e[id1++] = va;
for(auto i : s)o[id2++] = i;
answer(o, e);
}
// C:\Users\Kazim\Downloads\Desktop\cavee
// g++ cave.cpp grader.c -o main
| # | 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... |