QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#137796#4218. Hidden GraphXY_ElevenWA 1ms3840kbC++235.1kb2023-08-10 17:44:152023-08-10 17:44:18

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-10 17:44:18]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3840kb
  • [2023-08-10 17:44:15]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define DB double
#define LL long long
#define ULL unsigned long long
#define pii pair<int,int>
#define pil pair<int,LL>
#define mii map<int,int>
#define miig map<int,int,greater<int> >
#define mil map<int,LL>
#define in128 __int128
#define cint const int
#define cLL const LL
#define cDB const DB
#define cchar const char
#define invoid inline void
#define inLL inline LL
#define inlint inline int
#define inbool inline bool
#define inl128 inline __int128
#define inDB inline double
#define For(z,e1,e2) for(int z=(e1);z<=(e2);z++)
#define Rof(z,e1,e2) for(int z=(e2);z>=(e1);z--)
#define For_(z,e1,e2) for(int z=(e1);z<(e2);z++)
#define Rof_(z,e1,e2) for(int z=(e2);z>(e1);z--)
#define inint(e) scanf("%d",&e)
#define inll(e) scanf("%lld",&e)
#define inpr(e1,e2) scanf("%d%d",&e1,&e2)
#define in3(e1,e2,e3) scanf("%d%d%d",&e1,&e2,&e3)
#define outint(e) printf("%d\n",e)
#define outint_(e) printf("%d%c",e," \n"[i==n])
#define outll(e) printf("%lld\n",e)
#define outll_(e) printf("%lld%c",e," \n"[i==n])
#define exc(e) if(e) continue
#define stop(e) if(e) break
#define ret(e) if(e) return
#define ll(e) ((LL)(e))
#define pb push_back
#define ft first
#define sc second
#define clean(e) while(!e.empty()) e.pop()
#define all(ev) ev.begin(),ev.end()
#define x0 x00
#define y1 y11
#define debug(x) cerr<<#x<<'='<<x<<'\n'
#define fout fflush(stdout)
invoid input(int &N_,int A_[],bool F_)
{
    if(F_) inint(N_);
    For(i,1,N_) inint(A_[i]);
}
template <typename Type>
inline Type md(Type w1,const Type w2)
{
    w1%=w2; if(w1<0) w1+=w2;
    return w1;
}
template <typename Type>
invoid add(Type &w1,const Type w2,const Type M_)
{ w1=md(w1+w2,M_); }
invoid mul(LL &w1,cLL w2,cLL M_)
{ w1=md(w1*w2,M_); }
inLL gcd(LL X_,LL Y_)
{
    LL R_=X_%Y_;
    while(R_)
    { X_=Y_; Y_=R_; R_=X_%Y_; }
    return Y_;
}
invoid ex_gcd(LL &X_,LL &Y_,LL A_,LL B_)
{
    if(!B_)
    {
        X_=1ll; Y_=0ll;
        return ;
    }
    ex_gcd(Y_,X_,B_,A_%B_);
    X_=md(X_,B_); Y_=(1ll-X_*A_)/B_;
}
inLL inv(LL A_,LL B_)
{
    LL X_=0ll,Y_=0ll;
    ex_gcd(X_,Y_,A_,B_);
    return X_;
}
inLL pw(LL X_,LL Y_,LL M_)
{
    LL S_=1ll;
    while(Y_)
    {
        if(Y_&1) mul(S_,X_,M_);
        Y_>>=1;
        mul(X_,X_,M_);
    }
    return S_;
}
template <typename Type>
invoid get_min(Type &w1,const Type w2)
{ if(w2<w1) w1=w2; }
template <typename Type>
invoid get_max(Type &w1,const Type w2)
{ if(w2>w1) w1=w2; }
//inLL A(cint N_,cint M_)
//{ return (N_>=M_?md(d1[N_]*d2[N_-M_],mod):0ll); }
//inLL C(cint N_,cint M_)
//{ return (N_>=M_?md(d1[N_]*md(d2[M_]*d2[N_-M_],mod),mod):0ll); }
//mt19937 gen(time(NULL));
//mt19937_64 gen(time(NULL));
//cLL base[]={166686661,188868881},mod[]={1686688681,1666868881};
//cLL mod[]={1e9+7,1e9+9,1e9+21,1e9+33};
cint N=2100;
int n;
vector <pii> edge;
vector <vector <int> > v;
vector <int> t,g[N];
int cnt=0;
bool vis[N][N];
inbool work(int x)
{
    if(t.empty()) return false;
    cnt++;
    printf("? %d ",(int)t.size()+1);
    for(auto i:t)
        printf("%d ",i);
    outint(x);
    fout;
    int a,b;
    inpr(a,b);
    if(a==-1) return false;
    edge.pb({a,b});
    g[a].pb(b),g[b].pb(a);
    vis[a][b]=vis[b][a]=true;
    if(a==x) swap(a,b);
    if(find(all(t),a)==t.end()&&
       find(all(t),b)==t.end())
    {
        while(true) ;
        return false;
    }
    t.erase(find(all(t),a));
    return true;
}
int d[N];
struct Node
{
    int x,k;
    inbool operator < (const Node &A) const
    {
        return (k==A.k?x<A.x:k<A.k);
    }
};
set <Node> st;
invoid solve(int m)
{
    For(i,1,m) d[i]=0;
    for(auto [x,y]:edge)
        d[x]++,d[y]++;
    st.clear(); v.clear();
    For(i,1,m) st.insert({i,d[i]});
    while(!st.empty())
    {
        int p=st.begin()->x;
        st.erase(st.begin());
        d[p]=0;
        bool f=false;
        for(auto &S:v)
        {
            bool ok=true;
            for(auto i:S)
                if(vis[i][p])
                {
                    ok=false;
                    break;
                }
            if(ok)
            {
                f=true;
                S.pb(p);
                break;
            }
        }
        if(!f) v.pb({p});
        for(auto i:g[p])
            if(st.find({i,d[i]})!=st.end())
            {
                st.erase({i,d[i]});
                st.insert({i,--d[i]});
            }
    }
}
int main()
{
    inint(n);
    For(x,1,n)
    {
        bool f=false;
        for(auto &S:v)
        {
            bool ok=true;
            t.clear();
            for(auto i:S) t.pb(i);
            while(work(x)) ok=false;
            if(ok&&(!f))
            {
                f=true;
                S.pb(x);
            }
        }
        if(!f) v.pb({x});
        int t=v.size();
        solve(x);
        if(v.size()>t)
        {
            puts("?!");
            return 0;
        }
    }
    printf("! %d\n",(int)edge.size());
    for(auto [x,y]:edge)
        printf("%d %d\n",x,y);
    fout;
    //debug(cnt);
    return 0;
}
/*
1 3
2 4
5 1
6 4
5 6
*/

詳細信息

Test #1:

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

input:

3
1 2
1 3
2 3

output:

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

result:

ok correct

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3840kb

input:

10
1 2
1 3
-1 -1
-1 -1
1 4
4 5
2 5
-1 -1
-1 -1
2 6
-1 -1
-1 -1

output:

? 2 1 2
? 2 1 3
? 2 2 3
? 3 2 3 4
? 2 1 4
? 4 2 3 4 5
? 3 2 3 5
? 2 3 5
? 2 1 5
? 4 3 2 4 6
? 3 3 4 6
? 3 1 5 6
?!

result:

wrong answer unknown token ?!