QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#663618 | #7738. Equivalent Rewriting | wsy_jim | RE | 0ms | 0kb | C++14 | 1.5kb | 2024-10-21 16:26:21 | 2024-10-21 16:26: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);
vector<int> lst(n+1,0);
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);
lst[op]=i;
}
}
int idea=0,tmp=-1;
//vector<bool> vis(m+1);
for(int i=1;i<n;i++){
int id=1;
for(int j=1;j<=num[i][0];j++){
if(lst[num[i][j]]==i+1) id=0;
}
if(id) idea=1,tmp=i;
}
if(!idea){
printf("No\n");
continue;
}
printf("Yes\n");
for(int i=1;i<=n;i++){
if(i==(tmp-1+n)%n) printf("%d ",tmp);
else if(i==tmp) printf("%d ",tmp-1);
else printf("%d ",i);
}
printf("\n");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Runtime Error
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