QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#264618#7738. Equivalent Rewritingucup-team1303#WA 2ms8632kbC++141.3kb2023-11-25 14:37:112023-11-25 14:37:12

Judging History

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

  • [2023-11-25 14:37:12]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:8632kb
  • [2023-11-25 14:37:11]
  • 提交

answer

//私は猫です
#include <bits/stdc++.h>
using namespace std;
#define int long long
int read(){
    int xx = 0, f = 1; char ch = getchar();
    for (;!isdigit(ch); ch = getchar())
        f = (ch == '-' ? -1 : 1);
    for (; isdigit(ch); ch = getchar())
        xx = (xx << 3) + (xx << 1) + ch - '0';
    return xx * f;
}
int n, m, ans[214514];
vector <int> e[214514];
void solve(){
    n = read(), m = read();
    for (int i = 1, k, a; i <= n; ++i){
        e[i].clear();
        k = read(); ans[i] = i;
        while(k--)e[i].push_back(read());
        sort(e[i].begin(), e[i].end());
    }
    // for (int i = 1; i <= n; ++i){
    //     for (int v : e[i])cout<<v<<" ";cout<<endl;
    // }
    bool fl, fll = false;
    for (int i = 2; i <= n; ++i){
        fl = true;
        for (int j = 0, k = 0; j < e[i].size(); ++j){
            while(k < e[i - 1].size() && e[i - 1][k] < e[i][j])++k;
            if (e[i - 1][k] == e[i][j]){
                fl = false; break;
            }
        }
        if (fl){
            fll = true;
            swap(ans[i - 1], ans[i]); break;
        }
    }
    if (fll){
        printf("Yes\n");
        for (int i = 1; i <= n; ++i)printf("%lld ", ans[i]); printf("\n");
    }
    else printf("No\n");
}
signed main(){
    int _ = read();
    while(_--)solve();
    return 0;
}


详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 8632kb

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: 2ms
memory: 8532kb

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)