#include <bits/stdc++.h>
#include "library.h"
using namespace std;
vector<int> ans,ans1,ans2,adjList[10009];
vector<bool> vis;
int dfs2(int u,int a){
if(a==0)
ans1.push_back(u);
for(int x=0;x<(int)adjList[u].size();x++){
int v=adjList[u][x];
if(!vis[v]){
vis[v]=true;
dfs2(v,a);
}
}
if(a==1)
ans2.push_back(u);
}
int dfs1(int u){
for(int x=0;x<(int)adjList[u].size();x++){
int v=adjList[u][x];
vis[v]=true;
dfs2(v,x);
}
ans2.push_back(u);
}
void Solve(int N)
{
vector<int> M(N);
for(int i = 0; i < N; i++) {
M[i] = 1;
for(int j=i+1;j<N;j++){
M[j] = 1;
int A = Query(M);
M[j]=0;
if(A==1){
adjList[i].push_back(j);
adjList[j].push_back(i);
}
}
M[i]=0;
}
vis.assign(N,false);
vis[0]=true;
dfs1(0);
for(int x:ans2){
ans.push_back(x+1);
//printf("%d ",x);
}
for(int x:ans1){
ans.push_back(x+1);
//printf("%d ",x);
}
//printf("\n");
Answer(ans);
}
Compilation message
library.cpp: In function 'int dfs2(int, int)':
library.cpp:20:1: warning: no return statement in function returning non-void [-Wreturn-type]
}
^
library.cpp: In function 'int dfs1(int)':
library.cpp:29:1: warning: no return statement in function returning non-void [-Wreturn-type]
}
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
276 ms |
632 KB |
Output is correct |
2 |
Correct |
252 ms |
692 KB |
Output is correct |
3 |
Correct |
256 ms |
768 KB |
Output is correct |
4 |
Correct |
244 ms |
804 KB |
Output is correct |
5 |
Correct |
321 ms |
804 KB |
Output is correct |
6 |
Correct |
305 ms |
804 KB |
Output is correct |
7 |
Correct |
318 ms |
804 KB |
Output is correct |
8 |
Correct |
297 ms |
804 KB |
Output is correct |
9 |
Correct |
308 ms |
804 KB |
Output is correct |
10 |
Correct |
124 ms |
804 KB |
Output is correct |
11 |
Correct |
2 ms |
804 KB |
Output is correct |
12 |
Correct |
2 ms |
804 KB |
Output is correct |
13 |
Correct |
2 ms |
804 KB |
Output is correct |
14 |
Correct |
2 ms |
804 KB |
Output is correct |
15 |
Correct |
3 ms |
804 KB |
Output is correct |
16 |
Correct |
5 ms |
804 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
276 ms |
632 KB |
Output is correct |
2 |
Correct |
252 ms |
692 KB |
Output is correct |
3 |
Correct |
256 ms |
768 KB |
Output is correct |
4 |
Correct |
244 ms |
804 KB |
Output is correct |
5 |
Correct |
321 ms |
804 KB |
Output is correct |
6 |
Correct |
305 ms |
804 KB |
Output is correct |
7 |
Correct |
318 ms |
804 KB |
Output is correct |
8 |
Correct |
297 ms |
804 KB |
Output is correct |
9 |
Correct |
308 ms |
804 KB |
Output is correct |
10 |
Correct |
124 ms |
804 KB |
Output is correct |
11 |
Correct |
2 ms |
804 KB |
Output is correct |
12 |
Correct |
2 ms |
804 KB |
Output is correct |
13 |
Correct |
2 ms |
804 KB |
Output is correct |
14 |
Correct |
2 ms |
804 KB |
Output is correct |
15 |
Correct |
3 ms |
804 KB |
Output is correct |
16 |
Correct |
5 ms |
804 KB |
Output is correct |
17 |
Execution timed out |
2052 ms |
804 KB |
Time limit exceeded |
18 |
Halted |
0 ms |
0 KB |
- |