QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#658295#7738. Equivalent RewritingDetach#WA 0ms3668kbC++202.4kb2024-10-19 16:34:532024-10-19 16:34:53

Judging History

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

  • [2024-10-19 16:34:53]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3668kb
  • [2024-10-19 16:34:53]
  • 提交

answer

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #include <algorithm>
// #include <queue>
// #include <map>
// #include <iostream>
// #include <string>
// #include <set>
#define endl '\n'
#define int long long

using namespace std;    
using namespace __gnu_pbds;

using LL = long long; 
using PII = pair<int, int>;
using i128 = __int128_t;
using ULL = unsigned long long;
using Tree = tree<PII, null_type, less<PII>, rb_tree_tag, tree_order_statistics_node_update>;

constexpr int INF = 0x3f3f3f3f, MOD = 1e9 + 7, N = 1e6 + 5, M = 1e6 + 5;
constexpr LL LINF = 0x3f3f3f3f3f3f3f3f;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve()    
{       
    int n, m;
    cin >> n >> m;
    vector<int> las(m + 1);
    
    int ok = -1;
    vector<vector<int>> g(n + 1);
    for(int i = 1; i <= n; i ++) {
        int len;
        cin >> len;
        int ok2 = true;
        for(int j = 0; j < len; j ++) {
            int b;
            cin >> b;

            if(las[b] == i - 1) ok2 = false;
            las[b] = i;
            g[i].push_back(b);
        }

        if(i != 1 and ok2 and ok == -1) {
            ok = i;
        }
    }

    if(ok != -1) {
        cout << "YES" << endl;
        for(int i = 1; i <= n; i ++) {
            if(i == ok - 1) {
                cout << ok << ' ' << ok - 1 << ' ';
                i ++ ;
                continue;
            }

            cout << i << ' ';
        }

        cout << endl;
        return;
    }

    for(int i = 2; i <= n; i ++) {
        int ok2 = true;
        for(auto j : g[i]) {
            if(las[j] == i) ok2 = false;
        }

        if(ok2) {
            cout << "YES" << endl;
            cout << i << ' ';
            for(int k = 1; k <= n; k ++) {
                if(k == i) continue;
                cout << k << ' ';
            }
            cout << endl;
            return;
        }
    }

    cout << "NO" << endl;
}   

signed main()
{
    // (.*)   "$1"
    // freopen("park.in", "r", stdin);
    // freopen("park.out", "w", stdout);
	// cout << fixed << setprecision(2);
    // srand(NULL);
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int T = 1;
	cin >> T;

    while(T -- )
        solve();

    // fclose(stdin);
    // fclose(stdout);
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3668kb

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:

wrong answer Token parameter [name=yesno] equals to "YES", doesn't correspond to pattern "Yes|No" (test case 1)