QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#657425 | #7738. Equivalent Rewriting | WilliamHu | WA | 1ms | 6156kb | C++20 | 1.3kb | 2024-10-19 14:44:22 | 2024-10-19 14:44:31 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N =2000006;
int q[N];
int final[N];
int main() {
int T;
scanf("%d",&T);
while(T--) {
int n,m;scanf("%d%d",&m,&n);
vector<vector<int> > b(m+1);
for(int i=1;i<=n;++i)
final[i]=0;
for(int i=1;i<=m;++i) {
scanf("%d",&q[i]);
b[i].resize(q[i]+1);
for(int j=1;j<=q[i];++j){
scanf("%d",&b[i][j]);
final[b[i][j]]=i;
}
sort(b[i].begin()+1,b[i].begin()+1+q[i]);
}
if(m==1) printf("No\n");
bool f;
int i;
for(i=2;i<=m;++i) {
f=0;
for(int j=1,k=1;j<=q[i],k<=q[i-1];++j){
int x=b[i][j];
while(k<=q[i-1] && b[i-1][k]<x)
++k;
if(k<=q[i-1] && final[x]==i && b[i-1][k]==x) {
f=1;break;
}
}
if(!f) break;
}
if(!f&&i<=m) {
printf("Yes\n");
for(int l=1;l<i-1;++l) printf("%d ",l);
printf("%d %d ",i,i-1);
for(int l=i+1;l<=m;++l) printf("%d ",l);
printf("\n");
} else {
printf("No\n");
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 6156kb
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 No
result:
wrong output format Extra information in the output file (test case 3)