QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#799273 | #4218. Hidden Graph | qwqUwU_ | WA | 1ms | 3920kb | C++14 | 2.0kb | 2024-12-05 09:55:21 | 2024-12-05 09:55:54 |
Judging History
answer
#include<bits/stdc++.h>
#define pb push_back
#define P make_pair
#define fi first
#define se second
#define bit(s,x) (((s)>>(x))&1)
#define pnp(s) __builtin_popcountll(s)
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
inline ll read(){
ll x=0,f=1,c=getchar();
while(c<'0'||c>'9')f=(c=='-'?-1:1),c=getchar();
while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();
return x*f;
}
const int N=2e3+3;
int n,col[N];
int debug=0;
inline int ask(vector<int>vec,int i){
++debug;
if(n==2000)assert(debug<=6000);
vec.pb(i);
printf("? %d ",vec.size());
for(int x:vec)printf("%d ",x);
printf("\n");fflush(stdout);
int x=read(),y=read();
if(x!=-1)assert(x==i||y==i);
if(x==i)return y;
return x;
}
vector<int>G[N],vec[N];
int d[N];
inline void solve(vector<int>&A){
if(!A.size())return ;
int p=0;
rep(i,0,A.size()-1)if(d[A[i]]<d[A[p]])p=i;
int i=A[p];
swap(A[p],A.back());A.pop_back();
for(int j:G[i])--d[j];
solve(A);
static bool a[N];
for(int j:G[i])a[col[j]]=1;
for(col[i]=1;a[col[i]];++col[i]);
for(int j:G[i])a[col[j]]=0;
vec[col[i]].pb(i);
}
int main() {
//freopen("data.in", "r", stdin);
//freopen("myans.out","w",stdout);
n=read();
rep(i,2,n){
vector<int>ve;
rep(j,1,i-1){
ve.pb(j),col[j]=0;
d[j]=vec[j].size();
}
solve(ve);
rep(j,1,n){
if(!vec[j].size())break;
vector<int>tmp=vec[j];vec[j].clear();
while(tmp.size()){
int p=ask(tmp,i);
if(p==-1)break;
G[i].pb(p),G[p].pb(i);
rep(k,0,tmp.size()-1)if(tmp[k]==p){
swap(tmp[k],tmp.back());tmp.pop_back();
break;
}
}
}
static bool a[N];
rep(j,1,n)a[j]=0;
for(int p:G[i])a[col[p]]=1;
for(col[i]=1;a[col[i]];++col[i]);
vec[col[i]].pb(i);
}
int m=0;rep(i,1,n)m+=G[i].size();
printf("! %d\n",m/2);
rep(i,1,n)for(int j:G[i])if(i<j)printf("%d %d\n",i,j);
fflush(stdout);
cerr<<debug;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3920kb
input:
3 1 2 2 3 1 3 2 3
output:
? 2 1 2 ? 2 2 3 ? 3 2 1 3 ? 2 2 3 ! 4 1 2 1 3 2 3 2 3
result:
wrong answer read 4 edges but expected 3 edges