QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#242947 | #7738. Equivalent Rewriting | 1528344561 | WA | 0ms | 3576kb | C++14 | 1.2kb | 2023-11-07 19:00:30 | 2023-11-07 19:00:31 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
void solve()
{
int n,m;
cin>>n>>m;
vector<vector<int> > b(n+1);
vector<int > c(n+1);
for(int i=1;i<=n;i++)
{
int k;
cin>>k;
for(int j =1;j<=k;j++)
{
int x;
cin>>x;
b[i].push_back(j);
c[j] = i;
}
}
int pos= -1;
for(int i=1;i<n;i+=2)
{
vector<int> vis(n+1);
for(int j :b[i])
{
vis[j] = 1;
}
int flag = 0;
for(int j:b[i+1])
{
if(vis[j]&&c[j]==i+1)
{
flag = 1;
break;
}
}
if(!flag)
{
pos = i;
}
}
if(pos==-1)
{
cout<<"No\n";
return ;
}
cout<<"Yes\n";
for(int i=1;i<=n;i++)
{
if(i==pos)
{
cout<<i+1<<' '<<i;
i++;
if(i!=n)cout<<" ";
}
else
{
cout<<i;
if(i!=n)cout<<" ";
}
}
cout<<endl;
}
int main()
{
int T;
cin>>T;
while(T--)
{
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3576kb
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 2 1 3 No No
result:
wrong answer two transactions are not equivalent. (test case 1)