QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#251358 | #7738. Equivalent Rewriting | remain11 | WA | 2ms | 7856kb | C++14 | 1.8kb | 2023-11-14 16:31:40 | 2023-11-14 16:31:40 |
Judging History
answer
#include<iostream>
#include<cstring>
#include<vector>
#include<string>
#include<queue>
#include<map>
#include<unordered_map>
#include<algorithm>
#include<bitset>
using namespace std;
//#define int long long
#define x first
#define y second
const int N = 1e5 + 10;
int n, m,p[N],st[N],p1[N],p2[N];
vector<int> v[N];
void solve()
{
scanf("%d%d", &n, &m);
int tmp, move;
for (int i = 1; i <= n; i++)
{
v[i].clear();
scanf("%d", &tmp);
while (tmp--)
{
scanf("%d", &move);
v[i].push_back(move);
}
}
memset(st, -1, sizeof st);
memset(p1, -1, sizeof p1);
for (int i = n; i >= 2; i--)
{
memcpy(p2, st, sizeof st);
for (int j = 0; j < v[i].size(); j++)
{
if(st[v[i][j]]==-1) st[v[i][j]] = i;
if(p1[v[i][j]]==-1) p1[v[i][j]] = i;
}
for (int j = 0; j < v[i - 1].size(); j++)
{
if(p1[v[i-1][j]]==-1) p1[v[i - 1][j]] = i - 1;
if(p2[v[i-1][j]]==-1) p2[v[i - 1][j]] = i - 1;
}
for (int j = 0; j < v[i].size(); j++)
{
if(p2[v[i][j]]==-1) p2[v[i][j]] = i;
}
for (int i = 1; i <= m; i++)
{
if (p1[i] != p2[i])
{
printf("No\n");
return;
}
}
swap(p[i], p[i - 1]);
printf("Yes\n");
for (int i = 1; i <= n; i++)
{
printf("%d ", p[i]);
}
printf("\n");
swap(p[i], p[i - 1]);
return;
}
}
signed main()
{
int T;
scanf("%d", &T);
for (int i = 1; i < N; i++) p[i] = i;
while (T--)
{
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 7856kb
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
result:
wrong output format Unexpected end of file - token expected (test case 3)