QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#660742 | #7738. Equivalent Rewriting | yld | WA | 0ms | 3868kb | C++20 | 1.1kb | 2024-10-20 13:08:14 | 2024-10-20 13:08:16 |
Judging History
answer
#include<bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;
void solve()
{
int n,m;
cin>>n>>m;
vector<int> a[n+1];
vector<int> num(n+1);
for(int i=1;i<=n;i++)
{
cin>>num[i];
a[i].resize(num[i]+1);
for(int j=1;j<=num[i];j++) cin>>a[i][j];
}
if(n==1) {cout<<"No\n";return;}
vector<int> vis(m+1);
for(int i=1;i<=num[1];i++) vis[a[1][i]]++;
int ok=0;
for(int i=2;i<=n;i++)
{
int flag=1;
for(int j=1;j<=num[i];j++)
{
vis[a[i][j]]++;
if(vis[a[i][j]]==2) flag=0;
}
if(flag) ok=i;
for(int j=1;j<=num[i-1];j++) vis[a[i-1][j]]--;
}
if(ok)
{
vector<int> ans(n+1);
for(int i=1;i<=n;i++) ans[i]=i;
cout<<"Yes\n";
swap(ans[ok],ans[ok-1]);
for(int i=1;i<=n;i++) cout<<ans[i]<<(i!=n?' ':'\n');
}
else cout<<"No\n";
}
signed main()
{
cin.tie(0)->sync_with_stdio(0);
int t=1;
cin>>t;
while(t--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3868kb
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: 3852kb
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)