#include <cstdio>
#include <vector>
#include "library.h"
using namespace std;
namespace {
int N;
const int MAXN = 1000;
vector<int> G[MAXN + 10];
vector<int> init(int l, int r) {
vector<int> v(N, 0);
fill(v.begin() + l, v.begin() + r + 1, 1);
return v;
}
vector<int> upd(vector<int> m, int i) {
m[i] = 1;
return m;
}
void work(int i, int l, int r) {
if(l == r) {
G[i].push_back(l);
G[l].push_back(i);
return;
}
int m = (l + r) / 2;
if(Query(init(l, m)) >= Query(upd(init(l, m), i))) {
work(i, l, m);
}
if(Query(init(m+1, r)) >= Query(upd(init(m+1, r), i))) {
work(i, m+1, r);
}
}
};
void Solve(int N_) {
N = N_;
for(int i = 1; i < N; i++) {
if(Query(init(0, i-1)) >= Query(init(0, i))) work(i, 0, i-1);
}
vector<int> res;
res.reserve(N);
int u = 0, p = -1;
while(G[u].size() > 1) u++;
while((int)res.size() < N) {
res.push_back(u+1);
for(int v : G[u]) {
if(v != p) {
p = u;
u = v;
break;
}
}
}
Answer(res);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
77 ms |
248 KB |
Output is correct |
2 |
Correct |
74 ms |
308 KB |
Output is correct |
3 |
Correct |
74 ms |
436 KB |
Output is correct |
4 |
Correct |
82 ms |
548 KB |
Output is correct |
5 |
Correct |
67 ms |
548 KB |
Output is correct |
6 |
Correct |
80 ms |
548 KB |
Output is correct |
7 |
Correct |
84 ms |
548 KB |
Output is correct |
8 |
Correct |
84 ms |
652 KB |
Output is correct |
9 |
Correct |
83 ms |
652 KB |
Output is correct |
10 |
Correct |
44 ms |
652 KB |
Output is correct |
11 |
Correct |
2 ms |
700 KB |
Output is correct |
12 |
Correct |
2 ms |
700 KB |
Output is correct |
13 |
Correct |
2 ms |
700 KB |
Output is correct |
14 |
Correct |
2 ms |
700 KB |
Output is correct |
15 |
Correct |
3 ms |
700 KB |
Output is correct |
16 |
Correct |
6 ms |
700 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
77 ms |
248 KB |
Output is correct |
2 |
Correct |
74 ms |
308 KB |
Output is correct |
3 |
Correct |
74 ms |
436 KB |
Output is correct |
4 |
Correct |
82 ms |
548 KB |
Output is correct |
5 |
Correct |
67 ms |
548 KB |
Output is correct |
6 |
Correct |
80 ms |
548 KB |
Output is correct |
7 |
Correct |
84 ms |
548 KB |
Output is correct |
8 |
Correct |
84 ms |
652 KB |
Output is correct |
9 |
Correct |
83 ms |
652 KB |
Output is correct |
10 |
Correct |
44 ms |
652 KB |
Output is correct |
11 |
Correct |
2 ms |
700 KB |
Output is correct |
12 |
Correct |
2 ms |
700 KB |
Output is correct |
13 |
Correct |
2 ms |
700 KB |
Output is correct |
14 |
Correct |
2 ms |
700 KB |
Output is correct |
15 |
Correct |
3 ms |
700 KB |
Output is correct |
16 |
Correct |
6 ms |
700 KB |
Output is correct |
17 |
Execution timed out |
2027 ms |
1144 KB |
Time limit exceeded |
18 |
Halted |
0 ms |
0 KB |
- |