QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#242794 | #7738. Equivalent Rewriting | 568915433 | WA | 1ms | 5964kb | C++14 | 1.3kb | 2023-11-07 17:16:42 | 2023-11-07 17:16:43 |
Judging History
answer
#include "bits/stdc++.h"
#define endl "\n"
using namespace std;
vector<int> v[100005];
int u[100005]={0};
int n,m;
bool check(int e){
fill(u,u+(m+2),0);
for (int i = 0; i < v[e].size(); ++i) {
int x = v[e][i];
u[x]=1;
}
for (int i = 0; i < v[e-1].size(); ++i) {
int x = v[e-1][i];
if(u[x]==1)return false;
}
return true;
}
void so(){
int ac=-1;
cin>>n>>m;
for (int i = 0; i < n; ++i) {
v[i].clear();
}
for (int i = 0; i < n; ++i) {
int k;
cin>>k;
for (int j = 0; j < k; ++j) {
int a;
cin>>a;
v[i].push_back(a);
}
}
for (int i = 1; i < n; ++i) {
if(check(i)){
ac=i;
break;
}
}
if(ac==-1){
cout<<"No\n";
}else{
cout<<"Yes\n";
for (int i = 1; i <= n; ++i) {
if(i==ac){
cout<<ac+1<<" "<<ac;
i++;
}else{
cout<<i;
}
if(i!=n){
cout<<" ";
}
}
cout<<endl;
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin>>t;
while (t--)so();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5964kb
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: 5924kb
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)