QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#243314#7738. Equivalent Rewritingucup-team1769WA 1ms5824kbC++201.6kb2023-11-08 02:24:222023-11-08 02:24:22

Judging History

你现在查看的是最新测评结果

  • [2023-11-08 02:24:22]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5824kb
  • [2023-11-08 02:24:22]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define INF 0x3f3f3f3f
#define endl '\n'
const int mod = 998244353;
const int N = 1e5 + 10;
const int M = 1e5 + 10;

vector<int> g[N];
int in[N];

void solve()
{

    int n, m;
    cin >> n >> m;
    for (int i = 0; i <= m; i++)
    {
        g[i].clear();
    }
    vector<int> v(m + 10);
    for (int i = 1; i <= n; i++)
    {
        int a;
        cin >> a;
        for (int j = 0; j < a; j++)
        {
            int x;
            cin >> x;
            g[i].push_back(v[x]);
            in[v[x]]++;
            v[x] = i;
        }
    }

    bool flag = 1;
    for (int i = n; i > 0; i--)
    {
        if (g[i].back() != i - 1)
            flag = 0;
    }

    if (flag)
        cout << "No" << endl;
    else
    {
        cout << "Yes" << endl;
        vector<int> t;
        vector<bool> bl(n + 1);
        for (int i = n; i > 0; i--)
        {
            if (g[i].back() != i - 1)
            {
                t.push_back(i - 1);
                bl[i - 1] = 1;
            }
        }
        for (int i = 0; i < t.size(); i++)
        {
            if (i)
                cout << ' ';
            cout << t[i];
        }
        for (int i = 1; i <= n; i++)
        {
            if (!bl[i])
                cout << ' ' << i;
        }
        cout << endl;
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t;
    cin >> t;
    while (t--)
        solve();

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5824kb

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)