QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#670954 | #7738. Equivalent Rewriting | xxk2006 | WA | 0ms | 3744kb | C++23 | 1.7kb | 2024-10-24 09:04:59 | 2024-10-24 09:04:59 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define Enter putchar('\n')
#define spc putchar(' ')
#define pb push_back
#define fi first
#define se second
inline void read(int &num){num=0;int f=1;char ch=getchar();while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){num=(num<<1)+(num<<3)+(ch^48);ch=getchar();}num*=f;}
inline void lread(long long &num){num=0;int f=1;char ch=getchar();while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){num=(num<<1)+(num<<3)+(ch^48);ch=getchar();}num*=f;}
void print(long long num){if(num<0){putchar('-');num=-num;}if(num>9){print(num/10);}putchar((num%10)^48);}
vector<int> f;
set<int> g;
int id[100009];
int main(){
int T,k,x,n,m;
read(T);
while(T--){
read(n),read(m);
read(k);
g.clear();
for(int i=1;i<=k;i++){
read(x);
g.insert(x);
}
int ans=0;
id[1]=1;
for(int i=2;i<=n;i++){
id[i]=i;
read(k);
bool flag=0;
for(int j=0;j<k;j++){
read(x);
f.pb(x);
if(g.find(x)!=g.end())flag=1;
}
g.clear();
for(int j=0;j<k;j++){
g.insert(f[j]);
}
f.clear();
if(!flag)ans=i;
}
if(ans){
puts("Yes");
swap(id[ans],id[ans-1]);
for(int i=1;i<n;i++)print(id[i]),spc;
print(id[n]);
}
else{
printf("No");
}
if(T>=1)Enter;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3604kb
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: 3744kb
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)