QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#269784 | #7738. Equivalent Rewriting | khoray# | WA | 1ms | 3484kb | C++17 | 1.2kb | 2023-11-29 23:25:44 | 2023-11-29 23:25:44 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
void solve() {
int m, n; cin >> m >> n;
vector<int> cnt(n + 1);
vector<vector<int>> op(m + 1);
for(int i = 1; i <= m; i++) {
int k; cin >> k;
op[i].resize(k + 1);
for(int j = 1; j <= k; j++) {
cin >> op[i][j];
}
}
for(int i = m; i >= 1; i--) {
int mx = 0;
for(int j = 1; j < op[i].size(); j++) {
int x = op[i][j];
cnt[x]++;
mx = max(cnt[x], mx);
// cerr << "i = " << i << " mx = " << mx << '\n';
}
if(mx == 1 && i < m) {
cout << "Yes\n";
for(int j = 1; j <= m; j++) {
if(j == i) cout << j + 1 << " ";
else if(j == i + 1) cout << i << " ";
else cout << j << " ";
}
cout << '\n';
return;
}
if(i < m) {
for(int j = 1; j < op[i + 1].size(); j++) {
int x = op[i + 1][j];
cnt[x]--;
}
}
}
cout << "No\n";
}
int main() {
cin.tie(0)->sync_with_stdio(false);
int t; cin >> t;
while(t--) solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3484kb
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: 3452kb
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)