# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
61960 |
2018-07-27T06:41:32 Z |
ainta(#1792) |
popa (BOI18_popa) |
C++11 |
|
368 ms |
508 KB |
#include<cstdio>
#include<algorithm>
#include<vector>
#define N_ 1010
#include "popa.h"
using namespace std;
int L[N_], R[N_], C[N_], vis[N_];
void Put(int nd, int x, int *Left, int *Right) {
if (nd < x) {
if (Right[nd] == -1) {
Right[nd] = x;
return;
}
else {
Put(Right[nd], x, Left, Right);
}
}
else {
if (Left[nd] == -1) {
Left[nd] = x;
return;
}
else {
Put(Left[nd], x, Left, Right);
}
}
}
int solve(int N, int* Left, int* Right) {
int i, j;
vector<int>V, T;
for (i = 0; i < N; i++) {
V.push_back(i),vis[i] = 0;
Left[i] = -1, Right[i] = -1;
}
while (1) {
int ck = 0;
for (i = 0; i < V.size() - 1; i++) {
if (!query(V[i], V[i], V[i], V[i + 1])) {
T.push_back(V[i]);
V.erase(V.begin() + i);
ck = 1;
break;
}
}
if (!ck)break;
}
int root = V[0];
for (i = 0; i < V.size() - 1; i++) {
Right[V[i]] = V[i + 1];
}
for (int i = T.size() - 1; i >= 0; i--) {
Put(root, T[i], Left, Right);
}
return root;
}
Compilation message
popa.cpp: In function 'int solve(int, int*, int*)':
popa.cpp:37:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (i = 0; i < V.size() - 1; i++) {
~~^~~~~~~~~~~~~~
popa.cpp:48:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (i = 0; i < V.size() - 1; i++) {
~~^~~~~~~~~~~~~~
popa.cpp:29:9: warning: unused variable 'j' [-Wunused-variable]
int i, j;
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
380 KB |
Output is correct |
2 |
Correct |
66 ms |
440 KB |
Output is correct |
3 |
Correct |
28 ms |
496 KB |
Output is correct |
4 |
Correct |
91 ms |
496 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
368 ms |
508 KB |
too many queries |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
23 ms |
508 KB |
too many queries |
2 |
Halted |
0 ms |
0 KB |
- |