QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#242948#7738. Equivalent Rewriting1528344561WA 1ms3388kbC++141.2kb2023-11-07 19:02:152023-11-07 19:02:15

Judging History

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

  • [2023-11-07 19:02:15]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3388kb
  • [2023-11-07 19:02:15]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;
void solve()
{
    int n,m;
    cin>>n>>m;
    vector<vector<int> > b(n+1);
    vector<int > c(n+1);
    for(int i=1;i<=n;i++)
    {
        int k;
        cin>>k;
        for(int j =1;j<=k;j++)
        {
            int x;
            cin>>x;
            b[i].push_back(j);
            c[j] = i;
        }
    }
    int pos=  -1;
    for(int i=1;i<n;i++)
    {
        vector<int> vis(n+1);
        for(int j :b[i])
        {
            vis[j] = 1;
        }
        int flag = 0;
        for(int j:b[i+1])
        {
            if(vis[j]&&c[j]==i+1)
            {
                flag = 1;
                break;
            }
        }
        if(!flag)
        {
            pos = i;
        }
    }
    if(pos==-1)
    {
        cout<<"No\n";
        return ;
    }
    cout<<"Yes\n";
    for(int i=1;i<=n;i++)
    {
        if(i==pos)
        {
            cout<<i+1<<' '<<i;
            i++;
            if(i!=n)cout<<" ";
        }
        else
        {
            cout<<i;
            if(i!=n)cout<<" ";
        }
    }
    cout<<endl;

    

}
int main()
{
    int T;
    cin>>T;
    while(T--)
    {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3388kb

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:

Yes
2 1 3
No
No

result:

wrong answer two transactions are not equivalent. (test case 1)