# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
832649 | matthewhutama | Cave (IOI13_cave) | C++14 | 628 ms | 568 KiB |
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;
typedef int ll;
ll vis[5005];
void exploreCave(int N) {
ll ans[5005], koneksi[5005];
for (int i = 0; i < N; i++){
ll ask[5005];
for (int j = 0; j < N; j++){
if (vis[j] == 0){
ask[j] = 0;
}
else{
ask[j] = ans[j];
}
}
// for (int p = 0;p<N;p++) cout<<ask[p];
ll t = tryCombination(ask);
// cout << i <<" "<< t<<endl;
if (t == i){
ll lo = 0, hi = N - 1, mid, simpan;
while (lo <= hi){
mid = (lo + hi) / 2;
for (int k = 0; k <= mid; k++){
if (vis[k] == 0){
ask[k] = 1;
}
else{
ask[k] = ans[k];
}
}
for (int k = mid + 1; k < N; k++){
if (vis[k] == 0){
ask[k] = 0;
}
else{
ask[k] = ans[k];
}
}
// for (int p = 0;p<N;p++) cout<<ask[p];
// cout<<endl;
ll u = tryCombination(ask);
// cout<<u<<endl<<"________"<<endl;
if (u == i){
lo = mid + 1;
}
else{
hi = mid - 1;
simpan = mid;
}
}
koneksi[simpan] = i;
ans[simpan] = 1;
vis[simpan] = 1;
}
else{
ll lo = 0, hi = N - 1, mid, simpan;
while (lo <= hi){
mid = (lo + hi) / 2;
for (int j = 0; j <= mid; j++){
if (vis[j] == 0){
ask[j] = 1;
}
else{
ask[j] = ans[j];
}
}
for (int j = mid + 1; j < N; j++){
if (vis[j] == 0){
ask[j] = 0;
}
else{
ask[j] = ans[j];
}
}
ll u = tryCombination(ask);
if (u == i){
hi = mid - 1;
simpan = mid;
}
else{
lo = mid + 1;
}
}
koneksi[simpan] = i;
ans[simpan] = 0;
vis[simpan] = 1;
}
}
answer (ans, koneksi);
}
// #include "graderlib.c"
// int main() {
// int N;
// N = init();
// exploreCave(N);
// printf("INCORRECT\nYour solution did not call answer().\n");
// return 0;
// }
Compilation message (stderr)
# | 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... |