QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#267403 | #7738. Equivalent Rewriting | tonylin1026 | WA | 0ms | 3464kb | C++23 | 1.1kb | 2023-11-27 11:11:02 | 2023-11-27 11:11:03 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n, m;
cin >> n >> m;
vector<int> now(m + 1), ind(n + 1);
vector<set<int, greater<int>>> to(n + 1);
for (int i = 1; i <= n; i++) {
int p;
cin >> p;
for (int j = 1; j <= p; j++) {
int x;
cin >> x;
if (now[x] && to[now[x]].find(i) == to[now[x]].end()) {
to[now[x]].insert(i);
ind[i]++;
}
now[x] = i;
}
}
for (int i = 1; i < n; i++) {
if (to[i].find(i + 1) != to[i].end()) {
cout << "Yes\n";
for (int j = 1; j <= n; j++) {
if (j == i + 1) {
cout << i << " \n"[j == n];
} else if (j == i) {
cout << i + 1 << " ";
} else
cout << j << " \n"[j == n];
}
return;
}
}
cout << "No\n";
return;
}
int main() {
int t;
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: 3464kb
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 Yes 2 1 No
result:
wrong answer two transactions are not equivalent. (test case 1)