QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#658708 | #7738. Equivalent Rewriting | Detach# | WA | 1ms | 3848kb | C++20 | 2.8kb | 2024-10-19 17:26:30 | 2024-10-19 17:26:35 |
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;
for(int j = 0; j < len; j ++) {
int b;
cin >> b;
las[b] = i;
g[i].push_back(b);
}
sort(g[i].begin(), g[i].end());
}
for(int i = 2; i <= n; i ++) {
int ok2 = true;
for(auto j : g[i]) {
int ok3 = (*lower_bound(g[i - 1].begin(), g[i - 1].end(), j) == j);
if(las[j] == i and ok3) ok2 = false;
}
if(ok2) {
ok = i;
break;
}
}
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;
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3848kb
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)