QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#663570#7738. Equivalent Rewritingwsy_jimWA 0ms4020kbC++141.7kb2024-10-21 16:14:262024-10-21 16:14:27

Judging History

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

  • [2024-10-21 16:14:27]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4020kb
  • [2024-10-21 16:14:26]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdlib>
#include<ctime>
#include<bitset>
#include<vector>
#include<climits>
#include<iomanip>
using namespace std;
#define N 500010
template<typename T>
inline void read(T &x){
    x=0;bool flg=0;char c=getchar();
    for(;!isdigit(c);c=getchar()) if(c=='-') flg=1;
    for(;isdigit(c);c=getchar()) x=x*10+(c^48);
    if(flg) x=-x;
}

int n;
int t;
int m;

int main(){

    read(t);
    while(t--){
        read(n),read(m);
        vector<vector<int>> num(n+1);
        for(int i=1;i<=n;i++){
            int opt,op;
            read(opt);
            num[i].push_back(opt);
            for(int j=1;j<=opt;j++){
                read(op);
                num[i].push_back(op);
            }
        }

        int idea=0,tmp=-1;
        vector<bool> vis(m+1);
        for(int i=2;i<=n;i++){
            for(int j=1;j<=num[i-1][0];j++){
                vis[num[i-1][j]]=1;
            }
            int id=1;
            for(int j=1;j<=num[i][0];j++){
                if(vis[num[i][j]]) id=0;
            }
            if(id) idea=1,tmp=i;
            for(int j=1;j<=num[i-1][0];j++){
                vis[num[i-1][j]]=0;
            }
        }

        if(!idea){
            printf("No\n");
            continue;
        }
        printf("Yes\n");
        for(int i=1;i<=n;i++){
            if(i==tmp-1) printf("%d ",tmp);
            else if(i==tmp) printf("%d ",tmp-1);
            else printf("%d ",i);
        }
        printf("\n");
    }

    return 0;
}

详细

Test #1:

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

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: 3632kb

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)