QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#266446#7738. Equivalent Rewritingcaolima#WA 0ms3816kbC++141.9kb2023-11-26 14:17:532023-11-26 14:17:54

Judging History

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

  • [2023-11-26 14:17:54]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3816kb
  • [2023-11-26 14:17:53]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

const int N=1e5+5;

int cnt[N];


void solve(){
    map<int,int>m;
    vector<vector<int>>v;
    vector<int>num;
    int n,k;
    cin>>n>>k;
    int a;
    for(int i=0;i<n;++i){
        cin>>cnt[i];
        num.clear();
        for(int j=0;j<cnt[i];++j){
            cin>>a;
            num.push_back(a);
        }
        v.push_back(num);
    }
    int op=-1;
    int cx1=-1,cx2=-1,no1=-1,no2=-1;
    for(int i=n-1;i>=0;--i){
        int c=0;
        for(int j=0;j<cnt[i];++j){
            if(m[v[i][j]]){
                c++;
            }
            m[v[i][j]]++;
        }
        if(c==cnt[i]){
            if(cx1==-1){
                cx1=i;
            }else{
                cx2=i;
                op=1;
                break;
            }
        }
        if(c==0){
            if(no1==-1){
                no1=i;
            }
            else{
                no2=i;
                op=0;
                break;
            }
        }
    }
    if(op==1){
        cout<<"Yes"<<endl;
        for(int i=0;i<n;++i){
            if(i==cx1){
                cout<<cx2+1<<' ';
            }
            else if(i==cx2){
                cout<<cx1+1<<' ';
            }
            else {
                cout<<i+1<<' ';
            }
        }
        cout<<endl;
    }
    else if(op==0){
        cout<<"Yes"<<endl;
        for(int i=0;i<n;++i){
            if(i==no1){
                cout<<no2+1<<' ';
            }
            else if(i==no2){
                cout<<no1+1<<' ';
            }
            else {
                cout<<i+1<<' ';
            }
        }
        cout<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;cin>>t;while(t--)
    solve();

}


详细

Test #1:

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

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: 0
Accepted
time: 0ms
memory: 3624kb

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
1 2 3 4 5 6 8 7 9 10 

result:

ok OK. (1 test case)

Test #3:

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

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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 18 17 19 20 

result:

ok OK. (1 test case)

Test #4:

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

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
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 40 38 39 37 

result:

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