QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#590275 | #7738. Equivalent Rewriting | bruteforce_ | WA | 0ms | 3664kb | C++20 | 957b | 2024-09-25 23:02:07 | 2024-09-25 23:02:09 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e6+7,inf=1e18;
void O_o()
{
int n,m;
cin>>m>>n;
vector<int> a(n+1,m+1),d(m+2,0);
vector e(m+2,vector<int>());
for(int i=1; i<=m; i++)
{
int t;
cin>>t;
while(t--)
{
int x;
cin>>x;
e[a[x]].push_back(i);
a[x]=i;
d[i]++;
}
}
priority_queue<int> q;
q.push(m+1);
bool bz=0;
vector<int> ans;
while(!q.empty())
{
int u=q.top(); q.pop();
if(u<=m) ans.push_back(u);
for(auto v:e[u])
{
d[v]--;
if(!d[v])
{
q.push(v);
}
}
if(q.size()>=2) bz=1;
}
if(!bz)
{
cout<<"No\n";
return;
}
cout<<"Yes\n";
for(int i=0; i<ans.size(); i++)
{
cout<<ans[i];
if(i==m-1) cout<<"\n";
else cout<<" ";
}
}
signed main()
{
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cout<<fixed<<setprecision(12);
int T=1;
cin>>T;
while(T--)
{
O_o();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3568kb
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 3 1 2 No No
result:
ok OK. (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3664kb
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)