QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#187930 | #7510. Independent Set | bulijiojiodibuliduo# | WA | 1ms | 4108kb | C++17 | 3.1kb | 2023-09-25 06:37:56 | 2023-09-25 06:37:56 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef basic_string<int> BI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(1);
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
const int N=4010;
int n,ind[N],sl[N];
vector<PII> nd[N],E;
VI xs[N];
int wt;
//#define LOCAL
#ifdef LOCAL
int m;
VI e[N];
bool mark[N];
vector<PII> es;
#endif
VI query(VI x) {
wt+=SZ(x);
printf("? %d",SZ(x));
for (auto u:x) printf(" %d",u); puts("");
fflush(stdout);
VI cnt(SZ(x),0);
#ifdef LOCAL
rep(i,0,SZ(x)) {
int u=x[i];
for (auto v:e[u]) if (mark[v]) cnt[i]++;
if (cnt[i]==0) mark[u]=1;
}
rep(i,0,SZ(x)) mark[x[i]]=0;
printf("answer: ");
rep(i,0,SZ(x)) printf("%d ",cnt[i]); puts("");
#else
rep(i,0,SZ(x)) {
scanf("%d",&cnt[i]);
}
#endif
return cnt;
}
int tmpd[N];
vector<int> eg[N];
int main() {
scanf("%d",&n);
#ifdef LOCAL
scanf("%d",&m);
rep(i,0,m) {
int u=rnd(n)+1,v=rnd(n)+1;
printf("E %d %d\n",u,v);
es.pb(mp(u,v));
if (u!=v) e[u].pb(v),e[v].pb(u);
else e[u].pb(u);
}
#endif
rep(i,1,n+1) {
auto d=query(VI{i,i});
sl[i]=d[1];
rep(j,0,sl[i]) E.pb(mp(i,i));
}
VI ord;
rep(i,1,n+1) ord.pb(i);
auto adde=[&](int u,int v) {
eg[u].pb(v);
eg[v].pb(u);
E.pb(mp(u,v));
};
function<void(VI,vector<PII>)> solvebip=[&](VI l,vector<PII> r) {
if (r.empty()) return;
if (SZ(l)==1) {
for (auto [v,deg]:r) {
rep(j,0,deg) adde(l[0],v);
}
} else {
int md=SZ(l)/2;
VI l0(l.begin(),l.begin()+md),l1(l.begin()+md,l.end());
vector<PII> r0,r1;
VI qr=l0;
for (auto [x,deg]:r) qr.pb(x);
auto d=query(qr);
set<int> mk;
for (auto [v,deg]:r) tmpd[v]=deg;
rep(i,SZ(l0),SZ(qr)) {
int u=qr[i];
int v=d[i];
if (v==0) mk.insert(u);
for (auto w:eg[u]) if (mk.count(w)) --v;
if (v>0) r0.pb(mp(u,v));
if (tmpd[u]-v>0) r1.pb(mp(u,tmpd[u]-v));
}
solvebip(l0,r0);
solvebip(l1,r1);
}
};
function<void(VI)> solve=[&](VI ord) {
shuffle(all(ord),mrand);
if (SZ(ord)<=1) return;
auto d=query(ord);
VI s,ns;
rep(i,0,SZ(ord)) {
if (d[i]==0) s.pb(ord[i]); else ns.pb(ord[i]);
}
solve(ns);
VI qr=s; qr.insert(qr.end(),all(ns));
d=query(qr);
vector<PII> r;
rep(i,SZ(s),SZ(qr)) {
assert(d[i]>0);
r.pb(mp(qr[i],d[i]));
}
solvebip(s,r);
};
solve(ord);
printf("!");
for (auto [x,y]:E) printf(" %d %d",x,y);
puts("");
#ifdef LOCAL
for (auto &[x,y]:E) if (x>y) swap(x,y); sort(all(E));
for (auto &[x,y]:es) if (x>y) swap(x,y); sort(all(es));
assert(E==es);
printf("total : %d\n",wt);
#endif
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 4108kb
input:
4 0 0 0 0 0 0 0 1 0 2 0 0 0 0 0 3 0 2 0 1
output:
? 2 1 1 ? 2 2 2 ? 2 3 3 ? 2 4 4 ? 4 2 1 3 4 ? 4 2 3 4 1 ? 2 2 1 ? 2 3 1 ! 4 4 2 1 2 1 3 1
result:
wrong answer format Unexpected end of file - int32 expected