QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#617792#7738. Equivalent Rewritingxjt05WA 2ms7680kbC++232.4kb2024-10-06 17:07:342024-10-06 17:07:37

Judging History

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

  • [2024-10-06 17:07:37]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:7680kb
  • [2024-10-06 17:07:34]
  • 提交

answer

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    ll a[200005];
    ll b[200005];
    ll c[200005];
    vector<ll>g[250000];
    int main()
    {
        ll t;
        cin>>t;
        while(t--)
        {    ll gp=0;
            ll n,m;
            cin>>m>>n;
            ll temp=0;
            for(ll i=1;i<=n;i++)a[i]=0,c[i]=0;
            for(ll i=1;i<=m;i++)b[i]=i,g[i].clear();
            for(ll i=1;i<=m;i++)
            {
                ll k;
                cin>>k;
                while(k--)
                {
                    ll x;
                    cin>>x;
                    g[i].push_back(x);
                    a[i]++;
                }
            }
            ll u=0,c=0;
            for(ll i=1;i<=m;i++)
            {
                if(c==0)
                {
                for(auto j:g[i])
                {
                    a[j]--;
                    if(a[j]==0)
                    {
                        u=i;
                    }
                    else if(a[j]==1)
                    {
                        u=0;
                        break;
                    }
                    else
                    {
                        u=i;
                    }
                }
                c=u;
                }
                else
                {
                 for(auto j:g[i])
                {
                    a[j]--;
                    if(a[j]==0)
                    {
                        u=i;
                    }
                    else if(a[j]==1)
                    {
                        u=0;
                        break;
                    }
                    else
                    {
                        u=i;
                    }
                }
                if(i!=m)
                {
                    if(u>0)
                    {
                        swap(b[c],b[u]);
                        gp=1;
                        break;
                    }
                }
                }
             }
             if(gp)
             {
                cout<<"Yes"<<endl;
             for(ll i=1;i<=m;i++)
             {
                cout<<b[i];
                if(i!=m)
                cout<<" ";
             }
             cout<<endl;
             }
             else
             cout<<"No"<<endl;
        }
    }

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 7680kb

input:

3
3 6
3 3 1 5
2 5 3
2 2 6
2 3
3 1 3 2
2 3 1
1 3
2 2 1

output:

No
No
No

result:

wrong answer jury found an answer but participant did not (test case 1)