QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#159221#7107. Chaleurucup-team045#AC ✓162ms7668kbC++201.4kb2023-09-02 17:38:572023-09-02 17:38:58

Judging History

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

  • [2023-09-02 17:38:58]
  • 评测
  • 测评结果:AC
  • 用时:162ms
  • 内存:7668kb
  • [2023-09-02 17:38:57]
  • 提交

answer

#include<iostream>
#include<cstring>
#include<vector>
#include<cmath>
using namespace std;
using LL = long long;

int main(){

#ifdef LOCAL
    freopen("data.in", "r", stdin);
    freopen("data.out", "w", stdout);
#endif

    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);

    int T;
    cin >> T;
    while(T--){
        int n, m;
        cin >> n >> m;
        vector<vector<int> > g(n + 1);
        for(int i = 0; i < m; i++){
            int a, b;
            cin >> a >> b;
            g[a].push_back(b), g[b].push_back(a);
        }
        vector<int> id(n);
        for(int i = 0; i < n; i++) id[i] = i + 1;
        sort(id.begin(), id.end(), [&](int a, int b){
            return g[a].size() > g[b].size();
        });
        int mx = n;
        for(int i = 0; i < n; i++){
            if (g[id[i]].size() < i){
                mx = i;
                break;
            }
        }
        int cnt1 = 1;
        for(int i = mx; i < n; i++){
            if (g[id[i]].size() == mx - 1){
                cnt1 += 1;
            }
        }
        cout << cnt1 << ' ';
        int cnt2 = 0, cnt3 = 0;
        for(int i = 0; i < mx; i++){
            if (g[id[i]].size() == mx - 1) cnt2 += 1;
            if (g[id[i]].size() == mx) cnt3 += 1;
        }
        if (cnt2 != 0){
            cout << cnt2 << '\n';
        }
        else{
            cout << cnt3 + 1 << '\n';
        }
    }

}

这程序好像有点Bug,我给组数据试试?

詳細信息

Test #1:

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

input:

3
3 2
1 2
2 3
6 6
1 2
2 3
1 3
1 4
2 5
3 6
4 1
1 2

output:

2 1
1 4
1 2

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 162ms
memory: 7668kb

input:

2231
1 0
5 7
4 1
3 4
3 1
3 5
4 2
3 2
4 5
5 4
2 1
2 5
2 4
2 3
5 10
3 2
2 5
1 4
4 2
4 5
1 2
1 3
3 5
3 4
1 5
5 10
1 3
2 4
1 4
5 2
2 3
1 5
5 4
1 2
3 4
5 3
5 9
2 5
3 5
2 3
2 1
4 3
3 1
4 1
4 5
2 4
5 4
4 2
4 1
4 5
4 3
5 9
4 1
4 5
3 4
2 4
2 1
3 1
2 5
3 5
3 2
5 4
2 5
2 3
2 1
2 4
5 9
5 2
1 3
4 3
1 2
5 4
4 2
5...

output:

1 1
3 1
4 1
1 5
1 5
2 1
4 1
2 1
4 1
2 1
2 1
3 1
4 1
4 1
1 5
2 1
4 1
1 5
1 5
1 5
3 1
4 1
4 1
4 1
3 1
3 1
4 1
4 1
2 1
4 1
4 1
1 5
1 5
2 1
4 1
4 1
4 1
3 1
2 1
4 1
2 1
4 1
4 1
4 1
3 1
1 5
4 1
4 1
1 5
2 1
4 1
2 1
2 1
1 5
4 1
1 5
3 1
4 1
1 5
2 1
1 5
3 1
3 1
1 5
3 1
3 1
2 1
1 5
4 1
3 1
1 5
2 1
3 1
2 1
2 1
...

result:

ok 2231 lines

Extra Test:

score: 0
Extra Test Passed