QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#660992 | #7738. Equivalent Rewriting | wxiaobaivv | WA | 0ms | 3664kb | C++14 | 921b | 2024-10-20 14:13:43 | 2024-10-20 14:13:43 |
Judging History
answer
#include<iostream>
#include<cstring>
#include<vector>
#define int long long
using namespace std;
const int N=2e5;
int last[N];
void slove()
{
int m,n; cin>>m>>n;
for(int i=1;i<=n;i++) last[i]=0;
int ans=-1,ps=-1;
for(int i=1;i<=m;i++)
{
int k; cin>>k;
int pos=1;
while(k--)
{
int t; cin>>t;
pos=max(pos,last[t]);
last[t]=i;
}
if(pos+1<i) ans=i,ps=pos;
}
if(ans==-1) cout<<"No\n";
else
{
cout<<"Yes\n";
for(int i=1;i<=m;i++)
{
if(i==ps+1) cout<<ans;
else if(i==ans) cout<<ps+1;
else cout<<i;
if(i<m) cout<<" ";
}
cout<<"\n";
}
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int ts=1; cin>>ts;
while(ts--) slove();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3664kb
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: 3624kb
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)