#include <cstdio>
#include <vector>
#include "library.h"
#define pb(x) push_back(x)
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
using namespace std;
#define N 1003
int val[N];
vector<int>adj[N],res;
void add(int x,int y){
adj[x].pb(y);
adj[y].pb(x);
}
void dfs(int nd,int pr){
res.pb(nd);
tr(it,adj[nd])
if(*it!=pr)
dfs(*it,nd);
}
void Solve(int n){
if(n==1){
res.pb(1);
Answer(res);
return;
}
vector<int> M(n);
for(int i=1;i<n;i++){
for(int j=0;j<n;j++)M[j]=0;
int last=1,cur=0;M[i]=1;
for(int j=i-1;j>=0;j--){cur+=val[j];
M[j]=1;int tmp=Query(M)+cur;
if(tmp<=last)
add(j+1,i+1),val[j]++;
last=tmp;
}
}
for(int i=1;i<=n;i++)
if(adj[i].size()==1){
dfs(i,-1);
break;
}
Answer(res);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
285 ms |
408 KB |
# of queries: 18336 |
2 |
Correct |
294 ms |
364 KB |
# of queries: 18145 |
3 |
Correct |
334 ms |
408 KB |
# of queries: 19900 |
4 |
Correct |
273 ms |
364 KB |
# of queries: 19900 |
5 |
Correct |
286 ms |
408 KB |
# of queries: 19900 |
6 |
Correct |
283 ms |
364 KB |
# of queries: 19900 |
7 |
Correct |
299 ms |
364 KB |
# of queries: 19900 |
8 |
Correct |
268 ms |
364 KB |
# of queries: 18528 |
9 |
Correct |
301 ms |
412 KB |
# of queries: 19701 |
10 |
Correct |
137 ms |
364 KB |
# of queries: 8256 |
11 |
Correct |
1 ms |
364 KB |
# of queries: 0 |
12 |
Correct |
1 ms |
364 KB |
# of queries: 1 |
13 |
Correct |
1 ms |
364 KB |
# of queries: 3 |
14 |
Correct |
1 ms |
364 KB |
# of queries: 6 |
15 |
Correct |
2 ms |
364 KB |
# of queries: 105 |
16 |
Correct |
5 ms |
384 KB |
# of queries: 351 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
285 ms |
408 KB |
# of queries: 18336 |
2 |
Correct |
294 ms |
364 KB |
# of queries: 18145 |
3 |
Correct |
334 ms |
408 KB |
# of queries: 19900 |
4 |
Correct |
273 ms |
364 KB |
# of queries: 19900 |
5 |
Correct |
286 ms |
408 KB |
# of queries: 19900 |
6 |
Correct |
283 ms |
364 KB |
# of queries: 19900 |
7 |
Correct |
299 ms |
364 KB |
# of queries: 19900 |
8 |
Correct |
268 ms |
364 KB |
# of queries: 18528 |
9 |
Correct |
301 ms |
412 KB |
# of queries: 19701 |
10 |
Correct |
137 ms |
364 KB |
# of queries: 8256 |
11 |
Correct |
1 ms |
364 KB |
# of queries: 0 |
12 |
Correct |
1 ms |
364 KB |
# of queries: 1 |
13 |
Correct |
1 ms |
364 KB |
# of queries: 3 |
14 |
Correct |
1 ms |
364 KB |
# of queries: 6 |
15 |
Correct |
2 ms |
364 KB |
# of queries: 105 |
16 |
Correct |
5 ms |
384 KB |
# of queries: 351 |
17 |
Runtime error |
372 ms |
408 KB |
Execution killed with signal 13 (could be triggered by violating memory limits) |
18 |
Halted |
0 ms |
0 KB |
- |