QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#250226 | #7738. Equivalent Rewriting | XHYMathematics | WA | 1ms | 6752kb | C++23 | 999b | 2023-11-12 23:19:30 | 2023-11-12 23:19:31 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll N=1e5;
vector<ll>a[N];
ll last[N];
ll ans[N];
ll n;
inline ll solve()
{
ll i,xmax;
for(i=1;i<n;i++)
{
xmax=0;
for(auto&&j:a[i])
{
xmax=max(xmax,last[j]+1);
last[j]=i;
}
if(xmax<i)return i;
}
return 0;
}
int main()
{
ll t,m,k,i,j,di;
ios::sync_with_stdio(0),cin.tie(0);
cin>>t;
while(t--)
{
cin>>n>>m;
for(i=0;i<n;i++)
{
cin>>k,a[i].resize(k);
for(j=0;j<k;j++)cin>>a[i][j];
}
di=solve();
if(di)
{
cout<<"Yes\n";
iota(ans,ans+n,1);
swap(ans[di-1],ans[di]);
for(i=0;i<n;i++)cout<<ans[i]<<" \n"[i==n-1];
}
else cout<<"No\n";
for(i=0;i<n;i++)a[i].clear();
memset(last+1,0,n*sizeof(ll));
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 6752kb
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: 1ms
memory: 5820kb
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)