Submission #832649

#TimeUsernameProblemLanguageResultExecution timeMemory
832649matthewhutamaCave (IOI13_cave)C++14
100 / 100
628 ms568 KiB
#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)

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:88:25: warning: 'simpan' may be used uninitialized in this function [-Wmaybe-uninitialized]
   88 |             vis[simpan] = 1;
      |             ~~~~~~~~~~~~^~~
cave.cpp:55:25: warning: 'simpan' may be used uninitialized in this function [-Wmaybe-uninitialized]
   55 |             vis[simpan] = 1;
      |             ~~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...