QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#546548 | #7738. Equivalent Rewriting | yulishen | WA | 0ms | 3828kb | C++20 | 1.1kb | 2024-09-04 09:07:21 | 2024-09-04 09:07:23 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 1e5 + 5;
int a[maxn];
int ans[maxn];
void solve()
{
int n, m;
cin >> n >> m;
map<int, int> mp;
for (int i = 1; i <= m; i++)
{
a[i] = 0;
}
for (int i = 1; i <= n; i++)
{
ans[i] = 0;
}
for (int i = 1; i <= n; i++)
{
int k;
cin >> k;
for (int j = 1; j <= k; j++)
{
int x;
cin >> x;
ans[i] = max(ans[i], a[x]);
a[x] = i;
}
}
// for (int i = 1; i <= n; i++)
// {
// cout << ans[i] << " ";
// }
// cout << endl;
int flag = 0;
for (int i = 2; i <= n; i++)
{
if (ans[i] != i - 1)
{
flag = i;
break;
}
}
if (flag == 0)
{
cout << "No" << endl;
return ;
}
cout << "Yes" << endl;
for (int i = 1; i <= n; i++)
{
if (i != 1) cout << " ";
if (i == flag - 1)
{
cout << i + 1;
}
else if (i == flag)
{
cout << i - 1;
}
else
{
cout << i;
}
}
cout << endl;
return ;
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
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: 3568kb
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: 3828kb
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)