QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#246479 | #7738. Equivalent Rewriting | secretsky | WA | 1ms | 3472kb | C++23 | 1.3kb | 2023-11-10 20:55:15 | 2023-11-10 20:55:16 |
Judging History
answer
#include"bits/stdc++.h"
using namespace std;
void solve() {
int n, m;
cin >> n >> m;
vector<vector<int>> ve(n + 10);
vector<int> p(n + 10), a(n + 10, 0), c(m + 10, 0);
vector<int> ans(n + 10);
for(int i = 1; i <= n; i++) {
cin >> p[i];
ans[i] = i;
for(int j = 1; j <= p[i]; j++) {
int x;
cin >> x;
ve[i].push_back(x);
c[x] = j;
}
}
// for(int k = 1; k <= n; k++) {
// cout << ans[k] << " ";
// }
// cout << "\n";
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= p[i]; j++) {
//cout << c[ve[i][j - 1]] << " " << j << "\n";
if(c[ve[i][j - 1]] != j) a[ve[i][j - 1]] = i;
//cout << c[ve[i][j - 1]] << " " << j << " " << a[ve[i][j]]"\n";
}
}
// for(int k = 1; k <= m; k++) {
// cout << a[k] << " ";
// }
// cout << "\n";
int f = 0;
for(int i = 1; i <= n; i++) {
int res = 0;
for(int j = 1; j <= p[i]; j++) {
res = max(a[ve[i][j - 1]], res);
}
if(res + 1 < i) {
//cout << res << " " << i << "\n";
cout << "Yes" << "\n";
for(int k = 1; k <= res; k++) {
cout << k << " ";
}
cout << i << " ";
for(int k = res + 1; k <= n; k++) {
if(k == i) continue;
cout << k << " ";
}
cout << "\n";
return ;
}
}
cout << "No" << "\n";
}
int main() {
int t;
cin >> t;
while(t--) solve();
return 0;
}
/*
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
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3440kb
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 3 1 2 No No
result:
ok OK. (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3472kb
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)