Submission #97313

#TimeUsernameProblemLanguageResultExecution timeMemory
97313ahgus89Magic Dowsing (FXCUP3_magic)C++14
60 / 100
4 ms376 KiB
#include "dowsing.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; mt19937 rd((unsigned)chrono::steady_clock::now().time_since_epoch().count()); inline int ask(int x, int y) { return Detect(x, y); } void FindTreasure(int n) { int i, j, k, arr[101]; bool chk[101]; memset(chk, 0, sizeof(chk)); uniform_int_distribution<int> ran(1, n); k=ran(rd); for(i=1; i<=n; i++) arr[i]=i; for(i=1; i<=n; i++) { uniform_int_distribution<int> ra(i, n); j=ra(rd); swap(arr[i], arr[j]); } int cnt=0; vector<int> v, nv; for(i=1; i<=3; i++) { if(ask(k, arr[i])==1) v.push_back(arr[i]); else nv.push_back(arr[i]); } if(v.size()==3) { for(; i<=n; i++) { if(ask(k, arr[i])==0) { Report(k, arr[i]); return; } } } else if(v.size()==2) { Report(k, nv[0]); return; } else if(v.size()==1) k=v[0]; else { for(; i<=n; i++) if(ask(k, arr[i])==1) break; k=arr[i]; } for(i=1;i<=n;i++) { uniform_int_distribution<int> ra(i, n); j=ra(rd); swap(arr[i], arr[j]); } for(i=1;i<=n;i++) if(ask(arr[i], k)==0) { Report(arr[i], k); return; } }

Compilation message (stderr)

dowsing.cpp: In function 'void FindTreasure(int)':
dowsing.cpp:26:9: warning: unused variable 'cnt' [-Wunused-variable]
     int cnt=0;
         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...