#include "dowsing.h"
#include <bits/stdc++.h>
using namespace std;
int A[111], B[111], P[111];
void FindTreasure(int N)
{
int i, x, y, a, b, k;
if(N < 75){
for(i=1; i<=N; i++){
A[i] = Detect(i, 1);
if(A[i] != A[1]) x = i;
}
for(i=1; i<=N; i++){
B[i] = Detect(1, i);
if(B[i] != A[1]) y = i;
}
if(A[1] != A[2] && A[1] != A[3]) x = 1;
if(B[1] != B[2] && B[1] != B[3]) y = 1;
Report(x, y);
return;
}
srand(time(0));
for(i=0; i<N; i++){
P[i] = i + 1;
}
for(i=1; i<=10000; i++){
a = rand() % N;
b = rand() % N;
swap(P[a], P[b]);
}
k = rand() % N + 1;
for(i=0; i<N; i++){
if(Detect(P[i], k)) break;
}
x = P[i];
for(i=0; i<N; i++){
P[i] = i + 1;
}
for(i=1; i<=10000; i++){
a = rand() % N;
b = rand() % N;
swap(P[a], P[b]);
}
for(i=0; i<N; i++){
if(!Detect(x, P[i])) break;
}
y = P[i];
Report(x, y);
}
Compilation message
dowsing.cpp: In function 'void FindTreasure(int)':
dowsing.cpp:26:9: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
Report(x, y);
~~~~~~^~~~~~
dowsing.cpp:26:9: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized]
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Correct : C = 6 |
2 |
Correct |
2 ms |
256 KB |
Correct : C = 6 |
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 = 198 |
6 |
Partially correct |
4 ms |
376 KB |
Partially correct : C = 198 |
7 |
Partially correct |
4 ms |
376 KB |
Partially correct : C = 197 |
8 |
Partially correct |
5 ms |
376 KB |
Partially correct : C = 197 |
9 |
Partially correct |
4 ms |
376 KB |
Partially correct : C = 193 |
10 |
Partially correct |
4 ms |
380 KB |
Partially correct : C = 181 |
11 |
Correct |
3 ms |
376 KB |
Correct : C = 89 |
12 |
Correct |
4 ms |
504 KB |
Correct : C = 135 |