QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#799244 | #4218. Hidden Graph | qwqUwU_ | RE | 1ms | 3928kb | C++14 | 1.5kb | 2024-12-05 09:27:08 | 2024-12-05 09:27:09 |
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;
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 main() {
//freopen("data.in", "r", stdin);
//freopen("myans.out","w",stdout);
n=read();
col[1]=1;
vec[1].pb(1);
rep(i,2,n){
rep(j,1,n){
if(!vec[j].size())break;
vector<int>tmp=vec[j];
while(tmp.size()){
int p=ask(tmp,i);
if(p==-1)break;
G[i].pb(p);
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);
rep(i,1,n)for(int j:G[i])printf("%d %d\n",i,j);
fflush(stdout);
cerr<<debug;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3928kb
input:
3 1 2 1 3 2 3
output:
? 2 1 2 ? 2 1 3 ? 2 2 3 ! 3 2 1 3 1 3 2
result:
ok correct
Test #2:
score: -100
Runtime Error
input:
10 1 2 1 3 -1 -1
output:
? 2 1 2 ? 2 1 3 ? 2 2 3