QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#271741 | #7738. Equivalent Rewriting | ucup-team1196# | WA | 0ms | 3844kb | C++23 | 1.7kb | 2023-12-02 14:22:31 | 2023-12-02 14:22:31 |
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>> q(n + 1);
for (int i = 1; i <= n; i++) {
int x;
cin >> x;
q[i].push_back(x);
for (int j = 1; j <= q[i][0]; j++) {
cin >> x;
q[i].push_back(x);
}
}
vector<int> is(m + 1, 0);
for (int i = n; i >= 2; i--) {
map<int, int> a, b;
for (int j = 1; j <= q[i - 1][0]; j++) {
if (!is[q[i - 1][j]]) a[q[i - 1][j]] = j;
}
for (int j = 1; j <= q[i][0]; j++) {
if (!is[q[i][j]]) a[q[i][j]] = j;
}
for (int j = 1; j <= q[i][0]; j++) {
if (!is[q[i][j]]) b[q[i][j]] = j;
}
for (int j = 1; j <= q[i - 1][0]; j++) {
if (!is[q[i - 1][j]]) b[q[i - 1][j]] = j;
}
for (auto [x, y] : a) {
if (b[x] != y && b[x] != 0) goto G;
}
if (1) {
cout << "Yes\n";
for (int j = 1; j <= n; j++) {
if (j == i) {
cout << i - 1 << " \n"[j == n];
} else if (j == i - 1) {
cout << i << " \n"[j == n];
} else {
cout << j << " \n"[j == n];
}
}
return;
}
G:;
for (int j = 1; j <= q[i][0]; j++) {
is[q[i][j]] = 1;
}
}
cout << "No\n";
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while (t--) {
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3844kb
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:
ok OK. (3 test cases)
Test #2:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
1 10 5 2 2 4 4 1 3 4 2 1 2 3 2 1 4 4 5 2 4 3 3 2 5 4 3 5 4 2 3 1 3 2 5 1 4 2 3 5 1 4
output:
Yes 1 2 3 4 5 6 8 7 9 10
result:
ok OK. (1 test case)
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3612kb
input:
1 20 5 5 4 1 2 5 3 2 5 3 3 5 1 2 5 4 5 1 3 2 3 4 2 5 5 3 1 5 4 2 5 5 1 2 3 4 1 3 4 5 1 2 3 4 4 1 3 5 2 5 2 4 2 3 5 1 3 2 4 5 5 2 3 4 1 5 4 5 2 4 3 1 2 2 4 3 4 4 5 3 1 5 4 1 5 3 2 3 5 1 3
output:
Yes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 19 18 20
result:
wrong answer two transactions are not equivalent. (test case 1)