QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#640445#7738. Equivalent Rewritingucup-team1769WA 0ms3788kbC++201.2kb2024-10-14 12:35:542024-10-14 12:35:55

Judging History

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

  • [2024-10-14 12:35:55]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3788kb
  • [2024-10-14 12:35:54]
  • 提交

answer

#include <bits/stdc++.h>

using u32 = unsigned;
using i64 = long long;
using u64 = unsigned long long;

constexpr i64 inf = 1e18;

void solve() {
    int n, m;
    std::cin >> n >> m;

    std::vector adj(n, std::vector<int>());
    std::vector<int> v(m, -1), flag(n, 0);
    int ans = -1;
    for (int i = 0; i < n; i++) {
        int p;
        std::cin >> p;
        adj[i].resize(p);
        for (int j = 0; j < p; j++) {
            std::cin >> adj[i][j];
            if (v[adj[i][j] - 1] + 1 == i) {
                flag[i] = 1;
            }
            v[adj[i][j] - 1] = i;
        }
        if (!flag[i]) ans = i;
    }

    if (ans != -1) {
        std::cout << "Yes\n";
        for (int i = 0; i < n; i++) {
            if (i == ans) std::cout << ans << " ";
            else if (i == ans - 1) std::cout << ans + 1 << " ";
            else std::cout << i + 1 << " ";
        }
        std::cout << "\n";
    } else {
        std::cout << "No\n";
    }
}

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

    int t;
    std::cin >> t;

    while (t--) {
        solve();
    }

    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3564kb

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: 0ms
memory: 3788kb

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)