QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#251351 | #7738. Equivalent Rewriting | remain11 | WA | 1ms | 7636kb | C++11 | 1.8kb | 2023-11-14 16:19:26 | 2023-11-14 16:19:26 |
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);
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;
}
bool flag = true;
for (int i = 1; i <= m; i++)
{
if (p1[i]!= p2[i]) flag = false;
}
if (flag)
{
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;
}
}
printf("No\n");
}
signed main()
{
int T;
scanf("%d", &T);
for (int i = 1; i < N; i++) p[i] = i;
while (T--)
{
solve();
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 7636kb
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:
No No No
result:
wrong answer jury found an answer but participant did not (test case 1)