QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#617814 | #7738. Equivalent Rewriting | xjt05 | WA | 1ms | 7632kb | C++23 | 2.4kb | 2024-10-06 17:14:12 | 2024-10-06 17:14:13 |
Judging History
answer
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
ll a[200005];
ll b[200005];
ll c[200005];
vector<ll>g[250000];
int main()
{
ll t;
cin >> t;
while (t--)
{
ll gp = 0;
ll n, m;
cin >> m >> n;
ll temp = 0;
for (ll i = 1; i <= n; i++)a[i] = 0, c[i] = 0;
for (ll i = 1; i <= m; i++)b[i] = i, g[i].clear();
for (ll i = 1; i <= m; i++)
{
ll k;
cin >> k;
while (k--)
{
ll x;
cin >> x;
g[i].push_back(x);
a[i]++;
}
}
ll u = 0, c = 0;
for (ll i = 1; i <= m; i++)
{
ll z = 0;
if (c == 0)
{
for (auto j : g[i])
{
a[j]--;
if (a[j] == 0)
{
u = i;
}
else if (a[j] == 1)
{
u = 0;
z = 1;
}
else
{
u = i;
}
}
if (z)
c = 0;
c = u;
}
else
{
for (auto j : g[i])
{
a[j]--;
if (a[j] == 0)
{
u = i;
}
else if (a[j] == 1)
{
u = 0;
z = 1;
}
else
{
u = i;
}
}
if (z)
u = 0;
if (u > 0)
{
swap(b[c], b[u]);
gp = 1;
break;
}
}
}
if (gp)
{
cout << "Yes" << endl;
for (ll i = 1; i <= m; i++)
{
cout << b[i];
if (i != m)
cout << " ";
}
cout << endl;
}
else
cout << "No" << endl;
}
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 7632kb
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 2 1 3 No No
result:
wrong answer two transactions are not equivalent. (test case 1)