Submission #97313

# Submission time Handle Problem Language Result Execution time Memory
97313 2019-02-15T03:46:27 Z ahgus89 Magic Dowsing (FXCUP3_magic) C++14
60 / 100
4 ms 376 KB
#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

dowsing.cpp: In function 'void FindTreasure(int)':
dowsing.cpp:26:9: warning: unused variable 'cnt' [-Wunused-variable]
     int cnt=0;
         ^~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Correct : C = 5
2 Correct 2 ms 376 KB Correct : C = 4
3 Partially correct 4 ms 376 KB Partially correct : C = 197
4 Partially correct 4 ms 376 KB Partially correct : C = 197
5 Partially correct 4 ms 376 KB Partially correct : C = 199
6 Partially correct 4 ms 376 KB Partially correct : C = 199
7 Partially correct 4 ms 376 KB Partially correct : C = 195
8 Partially correct 4 ms 376 KB Partially correct : C = 199
9 Partially correct 4 ms 376 KB Partially correct : C = 199
10 Partially correct 4 ms 376 KB Partially correct : C = 165
11 Correct 3 ms 376 KB Correct : C = 132
12 Partially correct 3 ms 376 KB Partially correct : C = 177