QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#647385 | #7738. Equivalent Rewriting | yell | WA | 0ms | 3620kb | C++20 | 1.2kb | 2024-10-17 13:47:17 | 2024-10-17 13:47:17 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
void solve() {
int n, m;
cin >> n >> m;
vector<vector<int>> op(n + 1);
vector<int> ans(n + 1), last(m + 1), flag(n + 1);
iota(ans.begin(), ans.end(), 0);
for (int i = 1; i <= n; i++) {
int sz;
cin >> sz;
for (int j = 0; j < sz; j++) {
int x;
cin >> x;
op[i].push_back(x);
last[x] = i;
}
}
for (int i = 1; i <= n; i++) {
for (auto x : op[i]) {
if (x == i + 1) {
flag[i] = 1;
}
if (i == x + 1) {
flag[x] = 1;
}
}
}
bool ok = false;
for (int i = 1; i + 1 <= n; i++) {
if (!flag[i]) {
swap(ans[i], ans[i + 1]);
ok = true;
break;
}
}
if (ok) {
cout << "Yes\n";
for (int i = 1; i <= n; i++) {
cout << ans[i] << " \n"[i == n];
}
} else {
cout << "No\n";
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
cin >> t;
while (t--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3620kb
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 2 1 3 No No
result:
wrong answer two transactions are not equivalent. (test case 1)