#include <bits/stdc++.h>
using namespace std;
int Query(const std::vector<int> &p);
void Answer(int a, int b);
void Solve1(int N) {
int n = N;
vector<bool> visited(2*n+1);
for(int i=1;i<=2*n;i++){
if(visited[i])continue;
visited[i]=true;
int ans = 1;
for(int jump=512;jump;jump/=2){
if(ans+jump>2*n)continue;
vector<int> q;
for(int j=1;j<ans+jump;j++)if(!visited[j])q.emplace_back(j);
auto base = Query(q);
q.emplace_back(i);
if(Query(q)!=base)ans+=jump;
}
visited[ans]=true;
Answer(i,ans);
}
}
void Solve(int N) {
int n = N;
if(n>50){
Solve1(n);
return;
}
vector<vector<int>> adj(2*n+1);
set<pair<int,int>> edges;
for(int i=1;i<=n;i++){
for(int j=n+1;j<=2*n;j++){
if(Query({i,j})==1){
edges.insert({i,j});
adj[i].emplace_back(j);
adj[j].emplace_back(i);
}
}
}
for(int i=1;i<=2*n;i++){
if(adj[i].size()==1)continue;
assert(adj[i].size()==3);
if(Query({i,adj[i][0],adj[i][1]})==1)edges.erase({min(i,adj[i][2]),max(i,adj[i][2])});
else if(Query({i,adj[i][0],adj[i][2]})==1)edges.erase({min(i,adj[i][1]),max(i,adj[i][1])});
else edges.erase({min(i,adj[i][0]),max(i,adj[i][0])});
}
for(auto[a,b]:edges)Answer(a,b);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
19 ms |
456 KB |
Output is correct |
4 |
Correct |
19 ms |
344 KB |
Output is correct |
5 |
Correct |
20 ms |
344 KB |
Output is correct |
6 |
Correct |
19 ms |
344 KB |
Output is correct |
7 |
Correct |
19 ms |
344 KB |
Output is correct |
8 |
Correct |
24 ms |
344 KB |
Output is correct |
9 |
Correct |
21 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Incorrect |
1 ms |
344 KB |
Wrong Answer [6] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
19 ms |
456 KB |
Output is correct |
4 |
Correct |
19 ms |
344 KB |
Output is correct |
5 |
Correct |
20 ms |
344 KB |
Output is correct |
6 |
Correct |
19 ms |
344 KB |
Output is correct |
7 |
Correct |
19 ms |
344 KB |
Output is correct |
8 |
Correct |
24 ms |
344 KB |
Output is correct |
9 |
Correct |
21 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 6 |
12 |
Halted |
0 ms |
0 KB |
- |