QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#246647 | #7738. Equivalent Rewriting | qwq7 | WA | 0ms | 3528kb | C++20 | 2.0kb | 2023-11-10 23:43:36 | 2023-11-10 23:43:37 |
Judging History
answer
// 哎 签到低手
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define PII pair<int,int>
#define PDI pair<double,int>
#define db double
#define all(x) (x).begin(),(x).end()
#define YES cout<<"Yes"<<endl;
#define NO cout<<"No"<<endl;
const int mod = 1e9+7;
void solve(){
int n,m;cin>>n>>m;
vector<int>v[n+1],pre(m+1),last(m+1);
vector<int>g[n+1],deg(n+1);
for(int i=1;i<=n;i++){
int x;cin>>x;
while(x--){
int now;cin>>now;
v[i].push_back(now);
last[now]=i;
}
}
for(int i=1;i<=n;i++){
for(auto j:v[i]){
g[i].push_back(last[j]);
deg[last[j]]++;
}
}
vector<int>q;
for(int i=1;i<=n;i++){
if(!deg[i])q.push_back(i);
}
vector<int>ans(n+1);
for(int i=1;i<=n;i++)ans[i]=i;
while(q.size()){
if(q.size()>=2){
cout<<"Yes"<<endl;
int mx=max(q[0],q[1]),mn=min(q[0],q[1]);
for(int j=1;j<=n;j++){
if(mx==j)continue;
if(j==1){
if(j==mn){
cout<<mx<<' '<<mn;
}else{
cout<<j;
}
}
else {
if(j==mn){
cout<<' '<<mx<<' '<<mn;
}else{
cout<<' '<<j;
}
}
}cout<<endl;
return;
}
vector<int>nq;
while(q.size()){
auto u=q.back();q.pop_back();
for(auto v:g[u]){
deg[v]--;
if(deg[v]==0){
nq.push_back(0);
}
}
}
q=nq;
}
cout<<"No"<<endl;
}
signed main(){
ios::sync_with_stdio(false);cin.tie(0);
int t=1;cin>>t;
while(t--)solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3528kb
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)