Submission #72016

# Submission time Handle Problem Language Result Execution time Memory
72016 2018-08-26T04:43:42 Z ㅋ(#2245, dohyun0324) Magic Dowsing (FXCUP3_magic) C
100 / 100
3 ms 380 KB
#include "dowsing.h"
void FindTreasure(int N)
{
    int i,arr[210],sw=0,sum=0,sw2,p1=0,p2=0,p3=0;
    for(i=1;i<N;i++)
    {
        arr[i]=Detect(i,i);
        sum+=arr[i];
    }
    if(sum==0)
    {
        for(i=1;i<=N;i++)
        {
            if(N%2==1 && i>=N/2+1){Report(N/2+1,N/2+1); return;}
            sw=Detect(i,N-i+1);
            if(sw==1) break;
        }
        p1=i; p2=N-i+1;
        for(i=1;i<=N;i++)
        {
            if(p1!=i && p2!=i) p3=i;
        }
        sw=Detect(p1,p3);
        if(sw==1) Report(p1,p1);
        else Report(p2,p2);
    }
    else
    {
        arr[N]=Detect(N,N);
        for(i=1;i<=N;i++)
        {
            if(arr[i]==1) p1=i;
        }
        for(i=1;i<=N;i++)
        {
            if(arr[i]==1 && i!=p1) p2=i;
        }
        for(i=1;i<=N;i++)
        {
            if(p1!=i && p2!=i) p3=i;
        }
        if(Detect(p1,p3)==0) Report(p2,p1);
        else Report(p1,p2);
    }
}

Compilation message

dowsing.c: In function 'FindTreasure':
dowsing.c:4:31: warning: unused variable 'sw2' [-Wunused-variable]
     int i,arr[210],sw=0,sum=0,sw2,p1=0,p2=0,p3=0;
                               ^~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Correct : C = 4
2 Correct 2 ms 380 KB Correct : C = 4
3 Correct 3 ms 376 KB Correct : C = 148
4 Correct 3 ms 376 KB Correct : C = 100
5 Correct 3 ms 376 KB Correct : C = 150
6 Correct 3 ms 376 KB Correct : C = 101
7 Correct 3 ms 376 KB Correct : C = 147
8 Correct 3 ms 376 KB Correct : C = 150
9 Correct 3 ms 380 KB Correct : C = 150
10 Correct 3 ms 376 KB Correct : C = 101
11 Correct 3 ms 376 KB Correct : C = 104
12 Correct 3 ms 380 KB Correct : C = 101