QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#594525#7738. Equivalent RewritingllgWA 1ms3780kbC++141.8kb2024-09-28 02:07:262024-09-28 02:07:26

Judging History

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

  • [2024-09-28 02:07:26]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3780kb
  • [2024-09-28 02:07:26]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define mod 1000000007
int main()
{
#ifndef ONLINE_JUDGE
    freopen("a.in", "r", stdin);
    freopen("a.out", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--)
    {
        int m, n;
        cin >> m >> n;
        vector<set<int>> last(n + 1);
        for (int i = 1; i <= m; i++)
        {
            int p;
            cin >> p;
            for (int j = 1; j <= p; j++)
            {
                int b;
                cin >> b;
                last[b].insert(i);
            }
        }

        vector<bool> possible(m + 1, true);
        for (int i = 1; i <= n; i++)
        {
            for (auto x : last[i])
            {
                if (last[i].count(x + 1))
                {
                    possible[x] = false;
                }
            }
        }
        vector<int> p_(m + 1, 0);
        for (int i = 1; i <= m; i++)
        {
            p_[i] = i;
        }
        bool dude = false;
        for (int i = 1; i < m; i++)
        {
            if (possible[i])
            {
                dude = true;
                swap(p_[i], p_[i + 1]);
                break;
            }
        }
        if (dude)
        {
            cout << "Yes" << endl;
            for (int i = 1; i <= m; i++)
            {
                cout << p_[i] << " ";
            }
            cout << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3780kb

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: 3556kb

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)