QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#251324 | #7738. Equivalent Rewriting | remain11 | WA | 2ms | 6388kb | C++14 | 1.7kb | 2023-11-14 15:56:10 | 2023-11-14 15:56:10 |
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];
vector<int> v[N];
void solve()
{
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; i++) v[i].clear();
int tmp, move;
for (int i = 1; i <= n; i++)
{
scanf("%d", &tmp);
while (tmp--)
{
scanf("%d", &move);
v[i].push_back(move);
}
}
vector<int> st(m + 1, -1);
for (int i = n; i >= 2; i--)
{
vector<int> p1 = st, p2 = st;
for (int j = 0; j < v[i].size(); j++)
{
st[v[i][j]] = i;
p1[v[i][j]] = i;
}
for (int j = 0; j < v[i - 1].size(); j++)
{
// st[v[i-1][j]] = i-1;
p1[v[i-1][j]] = i-1;
p2[v[i-1][j]] = i-1;
}
for (int j = 0; j < v[i].size(); j++)
{
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: 100
Accepted
time: 2ms
memory: 6388kb
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: 6356kb
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)