QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#689568 | #7738. Equivalent Rewriting | i_love_qingyu# | WA | 0ms | 3540kb | C++20 | 1.0kb | 2024-10-30 17:46:06 | 2024-10-30 17:46:10 |
Judging History
answer
#include <iostream>
#include <cstdio>
using namespace std;
int book[100005],last[100005],ans[100005];
int find(int x){
return x==book[x]?x:(book[x]=find(book[x]));
}
int main()
{
int t;
cin>>t;
while(t--){
int n,m,p=0;
cin>>m>>n;
for(int i=1;i<=n;i++)last[i]=0;
for(int i=1;i<=m;i++)book[i]=i,ans[i]=i;
for(int i=1;i<=m;i++){
int k,a;
cin>>k;
for(int j=1;j<=k;j++){
cin>>a;
if(last[a]){
int x=find(book[last[a]]);
book[i]=book[x];
}else
last[a]=i;
}
}
for(int i=2;i<=m;i++)
if(book[i]!=book[i-1]){
swap(ans[i],ans[i-1]);
p=1;
}
if(p){
cout<<"YES"<<endl;
for(int i=1;i<=m;i++)
cout<<ans[i]<<" ";
cout<<endl;
}
else cout<<"NO"<<endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3540kb
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:
wrong answer Token parameter [name=yesno] equals to "YES", doesn't correspond to pattern "Yes|No" (test case 1)