QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#86841 | #4218. Hidden Graph | CharlieVinnie | RE | 0ms | 0kb | C++14 | 1.0kb | 2023-03-11 10:54:55 | 2023-03-11 10:54:59 |
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);
while(true){
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: 0
Dangerous Syscalls
input:
3 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2
output:
? 2 1 2 ? 2 1 2 ? 2 1 2 ? 2 1 2 ? 2 1 2 ? 2 1 2 ? 2 1 2 ? 2 1 2 ? 2 1 2 ? 2 1 2 ? 2 1 2 ? 2 1 2 ? 2 1 2 ? 2 1 2 ? 2 1 2 ? 2 1 2 ? 2 1 2