QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#643666#7738. Equivalent RewritingPepinotWA 0ms3820kbC++201.1kb2024-10-15 22:46:042024-10-15 22:46:05

Judging History

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

  • [2024-10-15 22:46:05]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3820kb
  • [2024-10-15 22:46:04]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>

void solve() {
    int n,m; cin>>n>>m;
    vector<set<int>> v(n+1);
    map<int,int> mp,end,pre;
    for(int i=1; i<=n; i++) {
        int p; cin>>p;
        while(p--) {
            int x; cin>>x;
            v[i].insert(x);
            mp[x]++;
            pre[x]=end[x],end[x]=i;
        }
    }

    int idx;
    for(int i=2; i<=n; i++) {
       //i,i-1
        bool is=true;
        map<int,bool> mm;
        for(auto j:v[i-1]) mm[j]=true;
        for(auto j:v[i]) 
            if(mm[j]&&end[j]==i)
                is=false;

        if(is) {
            cout<<"Yes\n";
            cout<<i;
            idx=i;
            for(int i=1; i<=n; i++)
                if(i!=idx) cout<<" "<<i;
            cout<<endl;
        }
        
    }

    cout<<"No\n";

}
signed main()
{
    ios::sync_with_stdio(false),cin.tie(nullptr);

    int t; cin>>t;
    while(t--)
        solve();
    return 0;
}
/*
3 5
3 1 2 3
3 1 2 3
3 1 2 3
3 5
4 1 2 3 5
3 1 2 3
3 1 2 3
4 5
3 3 1 5
3 2 4 6
3 3 2 4
3 1 5 2

all yes
*/

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3820kb

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

result:

wrong output format Extra information in the output file (test case 3)