# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
538088 |
2022-03-16T05:12:36 Z |
huangqr |
Library (JOI18_library) |
C++14 |
|
49 ms |
336 KB |
#include <cstdio>
#include <vector>
#include "library.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void Solve(int N)
{
vector<int>M(N,1);
vector<int>ans;
unordered_set<int>unknown;
for(int i=1;i<=N;i++)unknown.insert(i);
for(int i=0;i<N;i++){//Locating an edge, letting it be L
M[i]=0;
if(Query(M)==1){
ans.push_back(i+1);
unknown.erase(i+1);
break;
}
M[i]=1;
}
if(ans.empty())Answer(ans);
while((int)ans.size()<N){
/*cout<<"ans: ";
for(auto x:ans)cout<<x<<" ";
cout<<"\n";*/
unordered_set<int>space=unknown,a,b;
while(space.size()>1){
/*cout<<"space: ";
for(auto x:space)cout<<x<<" ";
cout<<"\n";*/
int halfsize=space.size()/2;
auto it=space.begin();
for(int i=0;i<halfsize;i++){
a.insert(*it);
it++;
}
for(int i=halfsize;i<(int)space.size();i++){
b.insert(*it);
it++;
}
/*cout<<"a: ";
for(auto x:a)cout<<x<<" ";
cout<<"\n";
cout<<"b: ";
for(auto x:b)cout<<x<<" ";
cout<<"\n";*/
M=vector<int>(N,0);
for(auto x:a)M[x-1]=1;
int pre = Query(M);
M[ans.back()-1]=1;
int aft = Query(M);
if(pre==aft)space=a;
else space=b;
a.clear();
b.clear();
}
ans.push_back(*(space.begin()));
unknown.erase(*(space.begin()));
}
Answer(ans);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
316 KB |
# of queries: 2381 |
2 |
Correct |
49 ms |
208 KB |
# of queries: 2443 |
3 |
Correct |
33 ms |
208 KB |
# of queries: 2660 |
4 |
Correct |
37 ms |
208 KB |
# of queries: 2583 |
5 |
Correct |
39 ms |
208 KB |
# of queries: 2516 |
6 |
Correct |
43 ms |
308 KB |
# of queries: 2555 |
7 |
Correct |
47 ms |
336 KB |
# of queries: 2558 |
8 |
Correct |
37 ms |
208 KB |
# of queries: 2418 |
9 |
Correct |
39 ms |
312 KB |
# of queries: 2534 |
10 |
Correct |
24 ms |
208 KB |
# of queries: 1484 |
11 |
Runtime error |
0 ms |
296 KB |
Execution killed with signal 13 |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
316 KB |
# of queries: 2381 |
2 |
Correct |
49 ms |
208 KB |
# of queries: 2443 |
3 |
Correct |
33 ms |
208 KB |
# of queries: 2660 |
4 |
Correct |
37 ms |
208 KB |
# of queries: 2583 |
5 |
Correct |
39 ms |
208 KB |
# of queries: 2516 |
6 |
Correct |
43 ms |
308 KB |
# of queries: 2555 |
7 |
Correct |
47 ms |
336 KB |
# of queries: 2558 |
8 |
Correct |
37 ms |
208 KB |
# of queries: 2418 |
9 |
Correct |
39 ms |
312 KB |
# of queries: 2534 |
10 |
Correct |
24 ms |
208 KB |
# of queries: 1484 |
11 |
Runtime error |
0 ms |
296 KB |
Execution killed with signal 13 |
12 |
Halted |
0 ms |
0 KB |
- |