QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#176482#7107. ChaleursupepapupuAC ✓46ms4192kbC++171.3kb2023-09-11 18:16:352023-09-11 18:16:35

Judging History

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

  • [2023-09-11 18:16:35]
  • 评测
  • 测评结果:AC
  • 用时:46ms
  • 内存:4192kb
  • [2023-09-11 18:16:35]
  • 提交

answer

#include <bits/stdc++.h>

#define x first
#define y second
#define el '\n'
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int N = 3e5 + 10, INF = 0x3f3f3f3f, mod = 998244353;

inline int read() {
    int f = 1, k = 0;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-') f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        k = k * 10 + c - '0';
        c = getchar();
    }
    return f * k;
}

void solve() {
    int n = read(), m = read();
    vector<int> deg(n + 1);
    while (m--) {
        int a = read(), b = read();
        ++deg[a], ++deg[b];
    }
    sort(deg.begin() + 1, deg.end(), greater<int>());
    int p = n;
    for (int i = 1; i <= n; ++i) {
        if (deg[i] < i - 1) {
            p = i - 1;
            break;
        }
    }
    // cout << p << el;
    int ans1 = 1, ans2 = 0;
    for (int i = p + 1; i <= n; ++i) ans1 += deg[i] == p - 1;
    for (int i = 1; i <= p; ++i) ans2 += deg[i] == p - 1;
    if (!ans2) {
        ans2 = 1;
        for (int i = 1; i <= p; ++i) ans2 += deg[i] == p;
    }
    printf("%d %d\n", ans1, ans2);
}

int main() {
    // ios::sync_with_stdio(0); cin.tie(0);
    int tcase = 1;
    cin >> tcase;
    while (tcase--) solve();
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 46ms
memory: 4192kb

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