QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#617792 | #7738. Equivalent Rewriting | xjt05 | WA | 2ms | 7680kb | C++23 | 2.4kb | 2024-10-06 17:07:34 | 2024-10-06 17:07:37 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[200005];
ll b[200005];
ll c[200005];
vector<ll>g[250000];
int main()
{
ll t;
cin>>t;
while(t--)
{ ll gp=0;
ll n,m;
cin>>m>>n;
ll temp=0;
for(ll i=1;i<=n;i++)a[i]=0,c[i]=0;
for(ll i=1;i<=m;i++)b[i]=i,g[i].clear();
for(ll i=1;i<=m;i++)
{
ll k;
cin>>k;
while(k--)
{
ll x;
cin>>x;
g[i].push_back(x);
a[i]++;
}
}
ll u=0,c=0;
for(ll i=1;i<=m;i++)
{
if(c==0)
{
for(auto j:g[i])
{
a[j]--;
if(a[j]==0)
{
u=i;
}
else if(a[j]==1)
{
u=0;
break;
}
else
{
u=i;
}
}
c=u;
}
else
{
for(auto j:g[i])
{
a[j]--;
if(a[j]==0)
{
u=i;
}
else if(a[j]==1)
{
u=0;
break;
}
else
{
u=i;
}
}
if(i!=m)
{
if(u>0)
{
swap(b[c],b[u]);
gp=1;
break;
}
}
}
}
if(gp)
{
cout<<"Yes"<<endl;
for(ll i=1;i<=m;i++)
{
cout<<b[i];
if(i!=m)
cout<<" ";
}
cout<<endl;
}
else
cout<<"No"<<endl;
}
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 7680kb
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:
No No No
result:
wrong answer jury found an answer but participant did not (test case 1)