QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#86859 | #4218. Hidden Graph | AFewSuns | TL | 0ms | 0kb | C++14 | 2.2kb | 2023-03-11 11:17:53 | 2023-03-11 11:17:55 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
namespace my_std{
#define ll long long
#define bl bool
ll my_pow(ll a,ll b,ll mod){
ll res=1;
if(!b) return 1;
while(b){
if(b&1) res=(res*a)%mod;
a=(a*a)%mod;
b>>=1;
}
return res;
}
ll qpow(ll a,ll b){
ll res=1;
if(!b) return 1;
while(b){
if(b&1) res*=a;
a*=a;
b>>=1;
}
return res;
}
#define db double
#define pf printf
#define pc putchar
#define fr(i,x,y) for(register ll i=(x);i<=(y);i++)
#define pfr(i,x,y) for(register ll i=(x);i>=(y);i--)
#define go(u) for(ll i=head[u];i;i=e[i].nxt)
#define enter pc('\n')
#define space pc(' ')
#define fir first
#define sec second
#define MP make_pair
#define il inline
#define inf 8e18
#define random(x) rand()*rand()%(x)
#define inv(a,mod) my_pow((a),(mod-2),(mod))
il ll read(){
ll sum=0,f=1;
char ch=0;
while(!isdigit(ch)){
if(ch=='-') f=-1;
ch=getchar();
}
while(isdigit(ch)){
sum=sum*10+(ch^48);
ch=getchar();
}
return sum*f;
}
il void write(ll x){
if(x<0){
x=-x;
pc('-');
}
if(x>9) write(x/10);
pc(x%10+'0');
}
il void writeln(ll x){
write(x);
enter;
}
il void writesp(ll x){
write(x);
space;
}
}
using namespace my_std;
#define fl fflush(stdout)
vector<ll> vec[2020],qry;
vector<pair<ll,ll> > ans;
ll n,k=0,all=0;
bl ck[2020],pd[2020];
void query(){
all++;
if(n==2000&&all>6000) assert(0);
pf("? %lld ",qry.size());
fr(i,0,(ll)qry.size()-1) writesp(qry[i]);
enter;
fl;
}
int main(){
n=read();
fr(i,1,n){
fr(j,1,k) ck[j]=0;
fr(j,1,k){
fr(l,0,(ll)vec[j].size()-1) pd[vec[j][l]]=0;
while(1){
qry.clear();
fr(l,0,(ll)vec[j].size()-1) if(!pd[vec[j][l]]) qry.push_back(vec[j][l]);
if(qry.empty()) break;
qry.push_back(i);
query();
ll u=read(),v=read();
if(u==-1) break;
ck[j]=1;
if(v==i) pd[u]=1;
else pd[v]=1;
ans.push_back(MP(u,v));
}
}
bl ckk=0;
fr(j,1,k){
if(!ck[j]){
vec[j].push_back(i);
ckk=1;
break;
}
}
if(!ckk){
k++;
vec[k].push_back(i);
}
if(k>2) while(1);
}
pf("! %lld\n",(ll)ans.size());
fr(i,0,(ll)ans.size()-1) pf("%lld %lld\n",ans[i].fir,ans[i].sec);
fl;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Time Limit Exceeded
input:
3 1 2 1 3 2 3
output:
? 2 1 2 ? 2 1 3 ? 2 2 3