QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#269784#7738. Equivalent Rewritingkhoray#WA 1ms3484kbC++171.2kb2023-11-29 23:25:442023-11-29 23:25:44

Judging History

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

  • [2023-11-29 23:25:44]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3484kb
  • [2023-11-29 23:25:44]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using LL = long long;

void solve() {
    int m, n; cin >> m >> n;
    vector<int> cnt(n + 1);
    vector<vector<int>> op(m + 1);
    for(int i = 1; i <= m; i++) {
        int k; cin >> k;
        op[i].resize(k + 1);
        for(int j = 1; j <= k; j++) {
            cin >> op[i][j];
        }
    }
    for(int i = m; i >= 1; i--) {
        int mx = 0;
        for(int j = 1; j < op[i].size(); j++) {
            int x = op[i][j];
            cnt[x]++;
            mx = max(cnt[x], mx);
            // cerr << "i = " << i << " mx = " << mx << '\n';
        }
        if(mx == 1 && i < m) {
            cout << "Yes\n";
            for(int j = 1; j <= m; j++) {
                if(j == i) cout << j + 1 << " ";
                else if(j == i + 1) cout << i << " ";
                else cout << j << " ";
            }
            cout << '\n';
            return;
        }
        if(i < m) {
            for(int j = 1; j < op[i + 1].size(); j++) {
                int x = op[i + 1][j];
                cnt[x]--;
            }
        }
    }
    cout << "No\n";
}

int main() {
    cin.tie(0)->sync_with_stdio(false);
    int t; cin >> t;
    while(t--) solve();
    return 0;
}

详细

Test #1:

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

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

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)