QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#660742#7738. Equivalent RewritingyldWA 0ms3868kbC++201.1kb2024-10-20 13:08:142024-10-20 13:08:16

Judging History

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

  • [2024-10-20 13:08:16]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3868kb
  • [2024-10-20 13:08:14]
  • 提交

answer

#include<bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;
void solve()
{
    int n,m;
    cin>>n>>m;
    vector<int> a[n+1];
    vector<int> num(n+1);
    for(int i=1;i<=n;i++)
    {
        cin>>num[i];
        a[i].resize(num[i]+1);
        for(int j=1;j<=num[i];j++) cin>>a[i][j];
    }
    if(n==1) {cout<<"No\n";return;}
    vector<int> vis(m+1);
    for(int i=1;i<=num[1];i++) vis[a[1][i]]++;
    int ok=0;
    for(int i=2;i<=n;i++)
    {
        int flag=1;
        for(int j=1;j<=num[i];j++)
        {
            vis[a[i][j]]++;
            if(vis[a[i][j]]==2) flag=0;
        }
        if(flag) ok=i;
        for(int j=1;j<=num[i-1];j++) vis[a[i-1][j]]--; 
    }
    if(ok)
    {
        vector<int> ans(n+1);
        for(int i=1;i<=n;i++) ans[i]=i;
        cout<<"Yes\n";
        swap(ans[ok],ans[ok-1]);
        for(int i=1;i<=n;i++) cout<<ans[i]<<(i!=n?' ':'\n');
    }
    else cout<<"No\n";
}
signed main()
{
    cin.tie(0)->sync_with_stdio(0);
    int t=1;
    cin>>t;
    while(t--) solve();
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3868kb

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
1 3 2
No
No

result:

ok OK. (3 test cases)

Test #2:

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

input:

1
10 5
2 2 4
4 1 3 4 2
1 2
3 2 1 4
4 5 2 4 3
3 2 5 4
3 5 4 2
3 1 3 2
5 1 4 2 3 5
1 4

output:

No

result:

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