QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#658680 | #7738. Equivalent Rewriting | Detach# | WA | 0ms | 3608kb | C++20 | 2.6kb | 2024-10-19 17:20:31 | 2024-10-19 17:20:31 |
Judging History
answer
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #include <algorithm>
// #include <queue>
// #include <map>
// #include <iostream>
// #include <string>
// #include <set>
#define endl '\n'
#define int long long
using namespace std;
using namespace __gnu_pbds;
using LL = long long;
using PII = pair<int, int>;
using i128 = __int128_t;
using ULL = unsigned long long;
using Tree = tree<PII, null_type, less<PII>, rb_tree_tag, tree_order_statistics_node_update>;
constexpr int INF = 0x3f3f3f3f, MOD = 1e9 + 7, N = 1e6 + 5, M = 1e6 + 5;
constexpr LL LINF = 0x3f3f3f3f3f3f3f3f;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve()
{
int n, m;
cin >> n >> m;
vector<int> las(m + 1);
int ok = -1;
vector<vector<int>> g(n + 1);
for(int i = 1; i <= n; i ++) {
int len;
cin >> len;
int ok2 = true;
for(int j = 0; j < len; j ++) {
int b;
cin >> b;
if(las[b] == i - 1) ok2 = false;
las[b] = i;
g[i].push_back(b);
}
if(ok2 and ok == -1) {
ok = i;
}
}
if(ok != -1) {
cout << "YES" << endl;
for(int i = 1; i <= n; i ++) {
if(i == ok - 1) {
cout << ok << ' ' << ok - 1;
if(ok != n) cout << ' ';
i ++ ;
continue;
}
cout << i;
if(i != n) cout << ' ';
}
cout << endl;
return;
}
for(int i = 2; i <= n; i ++) {
int ok2 = true;
for(auto j : g[i]) {
if(las[j] == i) ok2 = false;
}
if(ok2) {
cout << "YES" << endl;
cout << i << ' ';
for(int k = 1; k <= n; k ++) {
if(k == i) continue;
cout << k;
if(k < n - 1) cout << ' ';
else {
if(i != n and k == n - 1) cout << ' ';
}
}
cout << endl;
return;
}
}
cout << "NO" << endl;
}
signed main()
{
// (.*) "$1"
// freopen("park.in", "r", stdin);
// freopen("park.out", "w", stdout);
// cout << fixed << setprecision(2);
// srand(NULL);
ios::sync_with_stdio(false), cin.tie(nullptr);
int T = 1;
cin >> T;
while(T -- )
solve();
// fclose(stdin);
// fclose(stdout);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3608kb
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 1 3 2 NO NO
result:
wrong answer Token parameter [name=yesno] equals to "YES", doesn't correspond to pattern "Yes|No" (test case 1)