QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#226444#7107. Chaleurreal_sigma_teamWA 244ms7864kbC++202.5kb2023-10-25 23:10:252023-10-25 23:10:25

Judging History

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

  • [2023-10-25 23:10:25]
  • 评测
  • 测评结果:WA
  • 用时:244ms
  • 内存:7864kb
  • [2023-10-25 23:10:25]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

using ll = long long;

const int N = 1e5 + 5;

mt19937 rnd(536465456);

void solve() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v; u--; v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    int l = 1, r = n + 1;
    while (r - l > 1) {
        int mid = (r + l) / 2;
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            if (g[i].size() >= mid - 1) {
                cnt++;
            }
        }
        if (cnt >= mid) {
            l = mid;
        } else {
            r = mid;
        }
    }
    vector<int> clica, neclica;
    set<int> clset;
    for (int i = 0; i < n; i++) {
        if (g[i].size() >= l) {
            clica.push_back(i);
            clset.insert(i);
        }
    }
    for (int i = 0; i < n; i++) {
        int ok = 0;
        for (int j : g[i]) {
            if (clset.find(j) == clset.end() && g[i].size() == l - 1) {
                ok = true;
            }
        }
        if (clica.size() == l - 1) {
            ok = true;
        }
        if (clica.size() < l && ok && g[i].size() == l - 1) {
            clset.insert(i);
            clica.push_back(i);
        } else if (g[i].size() <= l - 1) {
            neclica.push_back(i);
        }
    }
    int ans2 = 0, ind = -1, ans1 = 0;
    for (int i : clica) {
        if (g[i].size() == l - 1) {
            ans2++;
            ind = i;
        }
    }
    //cout << l << '\n';
    if (ans2 == 0) {
        ans1 = 1, ans2 = 1;
        for (int i : clica) {
//            cout << i << ' ';
            if (g[i].size() <= l) {
                ans2++;
            }
        }
//        cout << '\n';
        for (int i : neclica) {
            //cout << i << ' ';
            if (g[i].size() >= l) {
                ans1++;
            }
        }
//        cout << '\n';
        cout << ans1 << ' ' << ans2 << '\n';
        return;
    }
    neclica.push_back(ind);
    for (int i : neclica) {
        if (g[i].size() == l - 1) {
            ans1++;
        }
    }
    cout << ans1 << ' ' << ans2 << '\n';
}

int main() {
#ifndef LOCAL
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#else
    freopen("input.txt", "r", stdin);
#endif
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 244ms
memory: 7864kb

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: '1 1'