QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#701151 | #7738. Equivalent Rewriting | yumingsk# | WA | 1ms | 3748kb | C++20 | 1.8kb | 2024-11-02 13:50:22 | 2024-11-02 13:50:23 |
Judging History
answer
#pragma GCC optimize(3, "Ofast", "inline")
#include <iostream>
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define INF 0x3f3f3f3f
#define L_INF 0x7f3f3f3f3f3f3f3f
#define db cout << "debug\n";
using namespace std;
const int Mod = 998244353;
using ll = long long;
int a[2][100010];
int p[100010];
void solve()
{
int n, m;
cin >> n >> m;
for (int i = 0; i <= m; i++)
a[0][i] = 0, a[1][i] = 0;
int cnt[2];
cin >> cnt[1];
for (int i = 1; i <= cnt[1]; i++)
{
int x;
cin >> x;
a[1][i] = x;
p[x]++;
}
int ans = 0;
for (int i = 2; i <= n; i++)
{
int flag = 0;
int e = i % 2;
cin >> cnt[e];
for (int i = 1; i <= cnt[e]; i++)
{
int x;
cin >> x;
a[e][i] = x;
p[x]++;
if (p[x] > 1)
flag = 1;
}
if (flag == 0)
{
ans = i;
break;
}
for (int i = 1; i <= cnt[1 - e]; i++)
{
p[a[1 - e][i]]--;
}
}
if (ans)
{
cout << "Yes\n";
for (int i = 1; i < ans - 1; i++)
cout << i << " ";
cout << ans << " " << ans - 1 << " ";
for (int i = ans + 1; i <= n; i++)
cout << i << " ";
cout << "\n";
}
else
{
cout << "No\n";
}
}
int main()
{
IOS;
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
#ifndef ONLINE_JUDGE
clock_t start_time = clock();
#endif
int t = 1;
cin >> t;
while (t--)
{
solve();
}
#ifndef ONLINE_JUDGE
cout << "Used " << (double)(clock() - start_time) << " ms" << endl;
#endif
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3748kb
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: 3676kb
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)