QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#266435#7738. Equivalent Rewritingtonylin1026#WA 0ms3748kbC++201.1kb2023-11-26 14:13:252023-11-26 14:13:26

Judging History

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

  • [2023-11-26 14:13:26]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3748kb
  • [2023-11-26 14:13:25]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> vec(n + 1);
    for (int i = 1; i <= n; i++) {
        int p;
        cin >> p;
        for (int j = 0; j < p; j++) {
            int x;
            cin >> x;
            vec[i].push_back(x);
        }
    }

    for (int i = n; i >= 2; i--) {
        set<int> st;
        for (auto x : vec[i]) {
            st.insert(x);
        }
        bool bl = true;
        for (auto x : vec[i - 1]) {
            if (st.find(x) != st.end()) {
                bl = false;
            }
        }
        if (bl) {
            cout << "Yes\n";
            vector<int> ans(n + 1);
            iota(ans.begin(), ans.end(), 0);
            swap(ans[i], ans[i - 1]);
            for (int i = 1; i <= n; i++) {
                cout << ans[i] << " ";
            }
            cout << "\n";
            return;
        }
    }
    
    cout << "No\n";

}

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

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

    return 0;
}

詳細信息

Test #1:

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

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

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)