QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#640445 | #7738. Equivalent Rewriting | ucup-team1769 | WA | 0ms | 3788kb | C++20 | 1.2kb | 2024-10-14 12:35:54 | 2024-10-14 12:35:55 |
Judging History
answer
#include <bits/stdc++.h>
using u32 = unsigned;
using i64 = long long;
using u64 = unsigned long long;
constexpr i64 inf = 1e18;
void solve() {
int n, m;
std::cin >> n >> m;
std::vector adj(n, std::vector<int>());
std::vector<int> v(m, -1), flag(n, 0);
int ans = -1;
for (int i = 0; i < n; i++) {
int p;
std::cin >> p;
adj[i].resize(p);
for (int j = 0; j < p; j++) {
std::cin >> adj[i][j];
if (v[adj[i][j] - 1] + 1 == i) {
flag[i] = 1;
}
v[adj[i][j] - 1] = i;
}
if (!flag[i]) ans = i;
}
if (ans != -1) {
std::cout << "Yes\n";
for (int i = 0; i < n; i++) {
if (i == ans) std::cout << ans << " ";
else if (i == ans - 1) std::cout << ans + 1 << " ";
else std::cout << i + 1 << " ";
}
std::cout << "\n";
} else {
std::cout << "No\n";
}
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int t;
std::cin >> t;
while (t--) {
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3564kb
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: 3788kb
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)