QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#627140 | #7738. Equivalent Rewriting | heige# | WA | 1ms | 6324kb | C++14 | 1.4kb | 2024-10-10 14:55:13 | 2024-10-10 14:55:14 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int T, n, m;
vector<int> a[maxn];
bool p[maxn];
int x[maxn];
int s[maxn];
void work() {
cin >> m >> n;
for (int i = 1; i <= n; i++) s[i] = 0;
for (int i = 1; i <= m; i++) {
int k; cin >> k; a[i].clear();
for (int j = 1; j <= k; j++) {
int x; cin >> x;
a[i].push_back(x);
}
}
for (int i = 1; i < m; i++) {
for (auto x : a[i]) p[x] = 1, s[x] = i;
bool fl = 1;
for (auto x : a[i + 1]) fl &= !p[x];
for (auto x : a[i]) p[x] = 0;
if (fl) {
cout << "Yes" << '\n';
for (int i = 1; i <= m; i++) x[i] = i;
swap(x[i], x[i + 1]);
for (int i = 1; i <= m; i++) cout << x[i] << " \n"[i == m];
return;
}
}
for (auto x : a[m]) s[x] = m;
int minx = 1e9;
for (int i = 1; i <= n; i++)
if (s[i] != 0) minx = min(minx, s[i]);
if (minx >= 3) {
cout << "YES" << '\n';
for (int i = 1; i <= m; i++) x[i] = i;
swap(x[1], x[2]);
for (int i = 1; i <= m; i++) cout << x[i] << " \n"[i == m];
return;
}
cout << "No" << '\n';
}
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> T;
while (T--) work();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 6000kb
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: 1ms
memory: 6324kb
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 2 1 3 4 5 6 7 8 9 10
result:
wrong answer Token parameter [name=yesno] equals to "YES", doesn't correspond to pattern "Yes|No" (test case 1)