QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#425401#7107. ChaleurHHH666WA 63ms16656kbC++143.3kb2024-05-30 10:26:042024-05-30 10:26:05

Judging History

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

  • [2024-05-30 10:26:05]
  • 评测
  • 测评结果:WA
  • 用时:63ms
  • 内存:16656kb
  • [2024-05-30 10:26:04]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define i1 __int128
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define ep emplace
#define eb emplace_back
#define all(v) v.begin(), v.end()

using namespace std;

template<typename types>
void read(types &x) {
    x = 0; char c = getchar(); int f = 1;
    while (!isdigit(c)) { if (c == '-') f = -1; c = getchar(); }
    while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
    x *= f; return;
}
void read() {}
template<typename types, typename... Args>
void read(types &x, Args&... args) {
    read(x), read(args...);
    return;
}
template<typename types>
void write(types x) {
    if (x < 0) putchar('-'), x = -x;
    types k = x / 10;
    if (k) write(k);
    putchar(x - k * 10 + '0');
    return;
}
void print() { puts(""); }
template<typename types, typename... Args>
void print(types x, Args... args) {
    write(x), putchar(' '), print(args...);
    return;
}

const int MAXN = 1e5 + 10;

int n, m;
int T;
vector<int> to[MAXN];
int deg[MAXN], d[MAXN];

void solve() {
    read(n, m);
    for (int i = 1; i <= n; ++i) to[i].clear();
    fill(deg + 1, deg + n + 1, 0);
    fill(d + 1, d + n + 1, 0);
    for (int i = 1; i <= m; ++i) {
        int x, y; read(x, y);
        to[x].eb(y), to[y].eb(x);
        ++deg[x], ++deg[y];
    }
    if (!m) {
        write(n), putchar(' '), write(1), puts("");
        return;
    }
    vector<int> v(n);
    iota(all(v), 1), sort(all(v), [&] (int x, int y) { return deg[x] < deg[y]; });
    int k = -1;
    for (int i = n, j = n - 1; i; --i) {
        while (j >= 0 && deg[v[j]] >= i - 1) --j;
        if (n - 1 - j >= i) { k = i; break; }
    }
    assert(~k);
    int rem = n;
    for (int x : v) {
        if (deg[x] >= k - 1) break;
        --rem;
        for (int y : to[x]) --deg[y], ++d[y];
    }
    int cnt = 0; for (int i = 1; i <= n; ++i) cnt += deg[i] >= k;
    int A = 0, B = 0;
    // cerr << "K: " << k << ' ' << cnt << ' ' << rem << endl;
    int cs = 0;
    if (!cnt) {
        A = 1;
        int c[3] = {};
        for (int i = 1; i <= n; ++i)
            if (deg[i] >= k - 1 && d[i] <= 2) ++c[d[i]];
        if (c[0]) B = c[0];
        else B = c[1] + 1;
    }
    else if (cnt == k - 1) {
        cs = 1;
        int ex = -1;
        for (int i = 1; i <= n; ++i)
            if (deg[i] == k - 1 && d[i]) assert(ex == -1), ex = i;
        if (~ex) {
            cs = 4;
            A = 1;
            if (d[ex] == 1) B = 2;
            else B = 1;
        }
        else {
            cs = 5;
            A = rem - (k - 1);
            B = 1;
        }
    }
    else {
        cerr << "CNT: " << cnt << ' ' << k << endl;
        cs = 2;
        assert(cnt == k);
        A = 1;
        for (int x : v) {
            if (deg[x] == k - 1)
                for (int y : to[x]) --deg[y], ++d[y];
        }
        int c = 0;
        for (int x : v) 
            if (deg[x] >= k && d[x] == 1) ++c; 
        B = c + 1;
    }
    if (T == 1013) {
        cout << n << ' ' << m << ' ' << cs << endl;
    }
    write(A), putchar(' '), write(B), puts("");
    return;
}

int main() {
    int t; read(t);
    while (t--) ++T, solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: -100
Wrong Answer
time: 63ms
memory: 16656kb

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:

wrong answer 1013th lines differ - expected: '2 1', found: '20 40 4'