QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#347620 | #7738. Equivalent Rewriting | OobugoO | WA | 1ms | 3828kb | C++20 | 1.3kb | 2024-03-09 14:34:11 | 2024-03-09 14:34:12 |
Judging History
answer
#include <bits/stdc++.h>
#define OobugoO_IOS std::ios::sync_with_stdio(false), std::cin.tie(nullptr);
#define x first
#define y second
typedef long long ll;
void solve() {
int n, m;
std::cin >> n >> m;
std::vector<std::set<int>> a(n + 1, std::set<int>());
std::vector<int> ans(n + 1);
for (int i = 1; i <= n; i++) ans[i] = i;
for (int i = 1; i <= n; i++) {
int j; std::cin >> j;
while (j--) {
int x; std::cin >> x;
a[i].insert(x);
}
}
bool f = false;
for (int i = 2; i <= n; i++) {
bool ok = true;
for (auto x : a[i]) {
if (a[i - 1].find(x) != a[i - 1].end()) {
ok = false;
break;
}
}
if (ok) {
f = true;
std::swap(ans[i], ans[i - 1]);
}
}
if (f) {
std::cout << "Yes\n";
for (int i = 1; i <= n; i++)
std::cout << ans[i] << " \n"[i == n];
} else {
std::cout << "No\n";
}
}
int main() {
OobugoO_IOS;
#ifdef Onlion_Judge
freopen("IO/input.in", "r", stdin);
freopen("IO/output.out", "w", stdout);
#endif
int t = 1; std::cin >> t;
while (t--)
solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3828kb
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: -100
Wrong Answer
time: 0ms
memory: 3492kb
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:
No
result:
wrong answer jury found an answer but participant did not (test case 1)