QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#86840 | #4218. Hidden Graph | CharlieVinnie | WA | 3ms | 3452kb | C++14 | 1.0kb | 2023-03-11 10:53:57 | 2023-03-11 10:54:00 |
Judging History
answer
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Rev(i,a,b) for(int i=a;i>=b;i--)
#define Fin(file) freopen(file,"r",stdin)
#define Fout(file) freopen(file,"w",stdout)
using namespace std; using ll = long long;
const int N=2e3+5; using pii = pair<int,int>;
int n,col[N],vis[N]; vector<pii> ans; vector<int> lis[N];
pii query(const vector<int>& vec){
cout<<"? "<<vec.size()<<' '; for(int x:vec) cout<<x<<' ';; cout<<'\n';
int x,y; cin>>x>>y; return pii(x,y);
}
int main(){
cin>>n; col[1]=1;
For(u,2,n){
For(i,1,n) lis[i].clear(),vis[i]=0;
For(v,1,u-1) lis[col[v]].push_back(v);
For(i,1,n) if(lis[i].size()){
vector<int> tmp=lis[i]; tmp.push_back(u);
auto pr=query(tmp);
if(pr.first==-1) break;
assert(pr.first==u||pr.second==u);
int v=pr.first^pr.second^u;
vis[col[v]]=1; ans.push_back(minmax(u,v));
}
For(i,1,n) if(!vis[i]) { col[u]=i; break; }
}
cout<<"! "<<ans.size()<<'\n';
for(auto pr:ans) cout<<pr.first<<' '<<pr.second<<'\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3412kb
input:
3 1 2 1 3 2 3
output:
? 2 1 2 ? 2 1 3 ? 2 2 3 ! 3 1 2 1 3 2 3
result:
ok correct
Test #2:
score: -100
Wrong Answer
time: 3ms
memory: 3452kb
input:
10 1 2 1 3 -1 -1 1 4 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
output:
? 2 1 2 ? 2 1 3 ? 2 2 3 ? 2 1 4 ? 3 2 3 4 ? 2 1 5 ? 3 1 5 6 ? 4 1 5 6 7 ? 5 1 5 6 7 8 ? 6 1 5 6 7 8 9 ? 7 1 5 6 7 8 9 10 ! 3 1 2 1 3 1 4
result:
wrong answer read 3 edges but expected 12 edges