#include<bits/stdc++.h>
using namespace std;
// uncomment before submiting
#include "icc.h"
// Comment or delete this before submitting
// ---------------------------------------------------------------
/*int grader_N;
int grader_Q_num ;
int grader_currEdge;
int grader_A[110], grader_B[110];
int grader_Adj[110][110];
int query(int size_a, int size_b, int a[], int b[]) {
grader_Q_num++;
for (int i = 0; i < size_a; i++) {
for (int j = 0; j < size_b; j++) {
if (a[i] == b[j]) {
cout << "Query arrays are not disjoint:" << endl;
for (int k = 0; k < size_a; k++) cout << a[k] << " ";
cout << endl;
for (int k = 0; k < size_b; k++) cout << b[k] << " ";
cout << endl;
exit(0);
}
if (grader_Adj[a[i]][b[j]] == 1) {
return 1;
}
}
}
return 0;
}
void setRoad(int a, int b) {
if ((a == grader_A[grader_currEdge] && b == grader_B[grader_currEdge])
|| (a == grader_B[grader_currEdge] && b == grader_A[grader_currEdge]))
{
grader_currEdge++;
int a1 = grader_A[grader_currEdge];
int b1 = grader_B[grader_currEdge];
grader_Adj[a1][b1] = 1;
grader_Adj[b1][a1] = 1;
if (grader_currEdge == grader_N) {
cout << "OK " << "queries: " << grader_Q_num << endl;
exit(0);
}
} else {
cout << "Wrong answer for edge number " << grader_currEdge << endl;
cout << "Correct edge: " << grader_A[grader_currEdge] << " " << grader_B[grader_currEdge] << ", ";
cout << "Reported edge: " << a << " " << b << endl;
exit(0);
}
}
void run(int);
int main() {
cin >> grader_N;
for (int i = 1; i < grader_N; i++) {
cin >> grader_A[i] >> grader_B[i];
}
grader_Q_num = 0;
grader_currEdge = 1;
grader_Adj[grader_A[1]][grader_B[1]] = 1;
grader_Adj[grader_B[1]][grader_A[1]] = 1;
run(grader_N);
if (grader_currEdge < grader_N) {
cout << "Not all edges found" << endl;
}
return 0;
}*/
// ---------------------------------------------------------------
// Implement
void run(int N) {
bool ok[N][N] = {};
for(int z = 0; z < N-1; z++) {
for(int i = 1; i <= N; i++) {
bool check = true;
int a[1], b[1];
a[0] = i;
for(int j = i+1; j <= N; j++) {
if(ok[i][j] == 1) continue;
b[0] = j;
int cur = query(1, 1, a, b);
if(cur == 1) {
setRoad(i,j);
ok[i][j] = 1;
ok[j][i] = 1;
check = false;
break;
}
}
if(!check) break;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
52 ms |
604 KB |
Not all edges were guessed! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
91 ms |
864 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
201 ms |
600 KB |
Number of queries more than 4500 out of 2250 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
197 ms |
600 KB |
Number of queries more than 4000 out of 2000 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
160 ms |
600 KB |
Number of queries more than 3550 out of 1775 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
160 ms |
604 KB |
Number of queries more than 3250 out of 1625 |
2 |
Halted |
0 ms |
0 KB |
- |