# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
97313 | ahgus89 | Magic Dowsing (FXCUP3_magic) | C++14 | 4 ms | 376 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 "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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |