QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#701621 | #7738. Equivalent Rewriting | retired_midlights# | WA | 1ms | 6196kb | C++14 | 1.3kb | 2024-11-02 14:27:07 | 2024-11-02 14:27:09 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = (int)a; i <= (int)b; i ++)
#define per(i, a, b) for(int i = (int)a; i >= (int)b; i --)
#define ll long long
#define no { puts("No"); return; }
#define yes { puts("Yes"); return; }
using namespace std;
const int maxn = 100010;
int n, m, p[maxn];
vector < int > a[maxn];
void solve() {
cin >> n >> m;
rep(i, 1, n) {
cin >> p[i];
a[i].clear();
rep(j, 0, p[i] - 1) {
int x;
cin >> x;
a[i].emplace_back(x);
}
sort(a[i].begin(), a[i].end());
}
rep(i, 1, n - 1) {
set < int > s;
rep(j, 0, p[i] - 1) s.insert(a[i][j]);
bool flag = 1;
rep(j, 0, p[i + 1] - 1) if(s.count(a[i + 1][j])) {
flag = 0;
break;
}
if(flag) {
cout << "Yes\n";
rep(k, 1, i - 1) cout << k << " ";
cout << i + 1 << " " << i << " ";
rep(k, i + 2, n) cout << k << " ";
cout << '\n';
return;
}
}
cout << "No\n";
}
int main() {
#ifdef LOCAL
freopen("data.in", "r", stdin);
#endif
ios :: sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
int T = 1;
cin >> T;
while(T --) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 6004kb
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: 6196kb
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)