QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#643666 | #7738. Equivalent Rewriting | Pepinot | WA | 0ms | 3820kb | C++20 | 1.1kb | 2024-10-15 22:46:04 | 2024-10-15 22:46:05 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
void solve() {
int n,m; cin>>n>>m;
vector<set<int>> v(n+1);
map<int,int> mp,end,pre;
for(int i=1; i<=n; i++) {
int p; cin>>p;
while(p--) {
int x; cin>>x;
v[i].insert(x);
mp[x]++;
pre[x]=end[x],end[x]=i;
}
}
int idx;
for(int i=2; i<=n; i++) {
//i,i-1
bool is=true;
map<int,bool> mm;
for(auto j:v[i-1]) mm[j]=true;
for(auto j:v[i])
if(mm[j]&&end[j]==i)
is=false;
if(is) {
cout<<"Yes\n";
cout<<i;
idx=i;
for(int i=1; i<=n; i++)
if(i!=idx) cout<<" "<<i;
cout<<endl;
}
}
cout<<"No\n";
}
signed main()
{
ios::sync_with_stdio(false),cin.tie(nullptr);
int t; cin>>t;
while(t--)
solve();
return 0;
}
/*
3 5
3 1 2 3
3 1 2 3
3 1 2 3
3 5
4 1 2 3 5
3 1 2 3
3 1 2 3
4 5
3 3 1 5
3 2 4 6
3 3 2 4
3 1 5 2
all yes
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3820kb
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 No
result:
wrong output format Extra information in the output file (test case 3)