QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#347620#7738. Equivalent RewritingOobugoOWA 1ms3828kbC++201.3kb2024-03-09 14:34:112024-03-09 14:34:12

Judging History

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

  • [2024-03-09 14:34:12]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3828kb
  • [2024-03-09 14:34:11]
  • 提交

answer

#include <bits/stdc++.h>

#define OobugoO_IOS std::ios::sync_with_stdio(false), std::cin.tie(nullptr);
#define x first
#define y second

typedef long long ll;

void solve() {
    int n, m;
    std::cin >> n >> m;
    std::vector<std::set<int>> a(n + 1, std::set<int>());
    std::vector<int> ans(n + 1);
    for (int i = 1; i <= n; i++) ans[i] = i;
    for (int i = 1; i <= n; i++) {
        int j; std::cin >> j;
        while (j--) {
            int x;  std::cin >> x;
            a[i].insert(x);
        }
    }
    bool f = false;
    for (int i = 2; i <= n; i++) {
        bool ok = true;
        for (auto x : a[i]) {
            if (a[i - 1].find(x) != a[i - 1].end()) {
                ok = false;
                break;
            }
        }
        if (ok) {
            f = true;
            std::swap(ans[i], ans[i - 1]);
        }
    }
    if (f) {
        std::cout << "Yes\n";
        for (int i = 1; i <= n; i++)
            std::cout << ans[i] << " \n"[i == n];
    } else {
        std::cout << "No\n";
    }
}
int main() {
    OobugoO_IOS;

#ifdef Onlion_Judge
    freopen("IO/input.in", "r", stdin);
    freopen("IO/output.out", "w", stdout);
#endif
    
    int t = 1;  std::cin >> t;
    while (t--)
        solve();
}

詳細信息

Test #1:

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

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

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)