# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
61961 |
2018-07-27T06:42:59 Z |
ainta(#1792) |
popa (BOI18_popa) |
C++11 |
|
157 ms |
636 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;
}
int pv = 0;
while (1) {
int ck = 0;
for (i = pv; 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;
pv = max(0,i - 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:38:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (i = pv; i < V.size() - 1; i++) {
~~^~~~~~~~~~~~~~
popa.cpp:50: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;
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
252 KB |
Output is correct |
2 |
Correct |
9 ms |
308 KB |
Output is correct |
3 |
Correct |
13 ms |
384 KB |
Output is correct |
4 |
Correct |
13 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
144 ms |
596 KB |
Output is correct |
2 |
Correct |
106 ms |
600 KB |
Output is correct |
3 |
Correct |
47 ms |
600 KB |
Output is correct |
4 |
Correct |
157 ms |
600 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
148 ms |
620 KB |
Output is correct |
2 |
Correct |
73 ms |
620 KB |
Output is correct |
3 |
Correct |
135 ms |
636 KB |
Output is correct |
4 |
Correct |
137 ms |
636 KB |
Output is correct |