QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#770562 | #7738. Equivalent Rewriting | s1amese | WA | 0ms | 3756kb | C++20 | 926b | 2024-11-21 22:22:28 | 2024-11-21 22:22:28 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n, m;
cin >> n >> m;
vector<vector<int>> a(n);
for (int i = 0; i < n; i++) {
int p;
cin >> p;
a[i].resize(p);
for (int j = 0; j < p; j++)
cin >> a[i][j], a[i][j]--;
}
vector<int> col(n);
for (int i = n - 1; i >= 0; i--) {
bool ok = true;
for (int j = 0; j < a[i].size(); j++)
if (!col[a[i][j]]) {
col[a[i][j]] = i + 1;
} else if (col[a[i][j]] == i + 2) {
ok = false;
}
if (ok && i != n - 1) {
cout << "Yes\n";
for (int j = 0; j < i; j++)
cout << j + 1 << " ";
cout << i + 2 << " " << i + 1;
if (i < m - 2) {
cout << " ";
for (int j = i + 2; j < n; j++) {
cout << j + 1;
if (j < n - 1)
cout << " ";
}
}
cout << '\n';
return;
}
}
cout << "No\n";
}
int main() {
int t;
cin >> t;
while (t--)
solve();
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3756kb
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: 3500kb
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
result:
wrong output format Unexpected end of file - int32 expected (test case 1)