QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#192921#7510. Independent Setyfq3WA 88ms66624kbC++142.8kb2023-09-30 15:54:152023-09-30 15:54:15

Judging History

你现在查看的是最新测评结果

  • [2023-09-30 15:54:15]
  • 评测
  • 测评结果:WA
  • 用时:88ms
  • 内存:66624kb
  • [2023-09-30 15:54:15]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

#define rep(i,l,r) for(auto i(l),i##_end(r);i<=i##_end;++i)
#define per(i,r,l) for(auto i(r),i##_end(l);i>=i##_end;--i)
#define fi first
#define se second
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define SZ(a) ((int)(a).size())

using cint=const int;
using ll=long long;
using cll=const long long;
using ull=unsigned long long;
#if __SIZEOF_POINTER__==8
using lll=__int128;
#endif
using db=double;
using ld=long double;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vl=vector<ll>;
using vii=vector<pii>;
using vll=vector<pll>;
mt19937 rnd(random_device{}());
mt19937_64 rnd64(random_device{}());

// #define LOCAL
const int N=4005;
#ifdef LOCAL
int G[N][N];
#endif
int n;
int slf[N],d[N],g[N][N];
vi query(vi a)
{
    printf("? %d ",SZ(a));
    for(int i:a) printf("%d ",i);
    puts("");
    #ifdef LOCAL
    vi res,S;
    rep(i,0,SZ(a)-1)
    {
        int d=0;
        for(int j:S) d+=G[a[i]][j];
        res.pb(d);
        if(!d) S.pb(a[i]);
        printf("%d ",d);
    }
    puts("");
    system("pause");
    return res;
    #endif
    fflush(stdout);
    vi b(SZ(a));
    for(int &i:b) scanf("%d",&i);
    return b;
}
void solve(vi a)
{
    if (SZ(a)<=1) return;
    vi cnt(query(a));
    vi L,R; vii TR;
    rep(i,0,SZ(a)-1)
        if(!cnt[i]) L.pb(a[i]);
        else R.pb(a[i]),TR.pb({a[i],cnt[i]});
    if (!SZ(R)) return;
    solve(R);
    
    function<void(vi,vii)> seek=[&](vi L,vii R)->void
    {
        if (!SZ(L)) return;
        if (SZ(L)==1)
        {
            for(int i:L) 
                for(auto [j,d]:R)
                    g[i][j]+=d,g[j][i]+=d;
            return;
        }
        int mid=(SZ(L)-1)/2;
        vi l1,l2;
        rep(i,0,mid) l1.pb(L[i]);
        rep(i,mid+1,SZ(L)-1) l2.pb(L[i]);

        vi T(l1);
        for(auto i:R) T.pb(i.fi);
        T=query(T);
        vii r1,r2;
        rep(i,0,SZ(R)-1)
        {
            int x=R[i].fi,num=T[i+SZ(l1)];
            rep(j,0,i-1) if(!T[j+SZ(l1)]) num-=g[x][R[j].fi];
            if (num) r1.pb({x,num});
            if (R[i].se-num) r2.pb({x,R[i].se-num});
        }
        seek(l1,r1),seek(l2,r2);
    };
    seek(L,TR);
}
int main()
{
    scanf("%d",&n);
    #ifdef LOCAL
    int m;
    scanf("%d",&m);
    rep(i,1,m) 
    {
        int u,v;
        scanf("%d%d",&u,&v);
        if (u==v) G[u][u]++;
        else G[u][v]++,G[v][u]++;
    }
    #endif
    rep(i,1,n) g[i][i]=query({i,i})[1];
    vi a;
    rep(i,1,n) a.pb(i);
    solve(a);
    vii ans;
    rep(i,1,n)
        rep(j,i,n)
            rep(k,1,g[i][j]) ans.pb({i,j});
    printf("! %d ",SZ(ans));
    for(pii i:ans) printf("%d %d ",i.fi,i.se);
}
/* 
4
4 1 2 1 2 1 3 4 4
 */

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 4092kb

input:

4
0 0
0 0
0 0
0 1
0 2 1 0
0 0
0 2 1

output:

? 2 1 1 
? 2 2 2 
? 2 3 3 
? 2 4 4 
? 4 1 2 3 4 
? 2 2 3 
? 3 1 2 3 
! 4 1 2 1 2 1 3 4 4 

result:

ok Ok, Accepted!

Test #2:

score: -100
Wrong Answer
time: 88ms
memory: 66624kb

input:

4000
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0...

output:

? 2 1 1 
? 2 2 2 
? 2 3 3 
? 2 4 4 
? 2 5 5 
? 2 6 6 
? 2 7 7 
? 2 8 8 
? 2 9 9 
? 2 10 10 
? 2 11 11 
? 2 12 12 
? 2 13 13 
? 2 14 14 
? 2 15 15 
? 2 16 16 
? 2 17 17 
? 2 18 18 
? 2 19 19 
? 2 20 20 
? 2 21 21 
? 2 22 22 
? 2 23 23 
? 2 24 24 
? 2 25 25 
? 2 26 26 
? 2 27 27 
? 2 28 28 
? 2 29 29 ...

result:

wrong answer Integer 13635 violates the range [0, 10000]