QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#643424#7738. Equivalent RewritingPepinotWA 1ms3792kbC++201.4kb2024-10-15 21:08:382024-10-15 21:08:40

Judging History

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

  • [2024-10-15 21:08:40]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3792kb
  • [2024-10-15 21:08:38]
  • 提交

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);
    map<int,int> mp;
    map<int,int> end;
    map<int,int> pre;
    for(int i=0; i<n; i++) {
        int p; cin>>p;
        for(int j=0; j<p; j++) {
            int x; cin>>x;
            v[i].insert(x);
            mp[x]++;
            pre[x]=end[x],end[x]=i;
        }
    }
    if(n==1) {
        cout<<"No\n";
        return;
    }
    int idx=n;
    bool is=false;
    for(int i=1; i<n-1; i++) {
        for(auto j:v[i]) {
            //等于1or后面还有
            if(!(mp[j]==1||end[j]>i||(end[j]==i&&end[j]-pre[j]>1)))
                goto B;
        }
        is=true,idx=i+1;
        B:;
    }
    //最后就得全等于1
    for(auto i:v[n-1])
        if(mp[i]!=1) {
            goto A;
        }
    is=true;
    A:;
    if(is) {
        cout<<"Yes\n";
        cout<<idx;
        for(int i=1; i<=n; i++)
            if(i!=idx) cout<<" "<<i;
        cout<<endl;
    }
    else {
        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: 100
Accepted
time: 0ms
memory: 3792kb

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

result:

ok OK. (3 test cases)

Test #2:

score: 0
Accepted
time: 0ms
memory: 3564kb

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:

Yes
8 1 2 3 4 5 6 7 9 10

result:

ok OK. (1 test case)

Test #3:

score: 0
Accepted
time: 1ms
memory: 3600kb

input:

1
20 5
5 4 1 2 5 3
2 5 3
3 5 1 2
5 4 5 1 3 2
3 4 2 5
5 3 1 5 4 2
5 5 1 2 3 4
1 3
4 5 1 2 3
4 4 1 3 5
2 5 2
4 2 3 5 1
3 2 4 5
5 2 3 4 1 5
4 5 2 4 3
1 2
2 4 3
4 4 5 3 1
5 4 1 5 3 2
3 5 1 3

output:

Yes
18 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 19 20

result:

ok OK. (1 test case)

Test #4:

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

input:

1
40 10
2 4 1
10 5 8 2 3 6 7 4 1 10 9
3 10 9 7
1 9
10 10 5 6 9 2 8 3 1 4 7
7 8 4 7 5 2 3 6
5 2 6 5 1 10
6 6 5 4 8 7 1
3 4 9 8
9 9 10 4 2 1 8 7 5 3
2 5 7
9 8 6 1 2 9 7 5 10 3
2 8 1
8 8 3 10 9 1 4 5 6
2 3 4
5 5 3 6 2 7
10 3 2 8 9 10 1 7 4 6 5
2 1 9
1 1
3 3 7 4
5 2 6 5 7 1
7 3 2 4 9 10 6 1
1 4
5 6 4 5 ...

output:

Yes
39 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 40

result:

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