QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#372100#2437. Wireless is the New FiberWe_Are_Chenough#AC ✓11ms4044kbC++171.4kb2024-03-30 21:35:562024-03-30 21:35:58

Judging History

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

  • [2024-03-30 21:35:58]
  • 评测
  • 测评结果:AC
  • 用时:11ms
  • 内存:4044kb
  • [2024-03-30 21:35:56]
  • 提交

answer

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;

signed main(){
    ios_base::sync_with_stdio(false), cin.tie(nullptr);

    int n, m;
    cin >> n >> m;

    vector<pair<int,int>> deg(n, {0,0});

    for(int i = 0; i < n; i++) deg[i].second = i;

    for(int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        deg[u].first++;
        deg[v].first++;
    }

    sort(deg.begin(), deg.end());

    queue<int> qw;

    vector<pair<int,int>> ans(0);
    int resp = 0;

    int p2 = n-1; 

    for(int i = 0; i < p2; i++){
        int x = deg[i].first, ind = deg[i].second;
        x--;

        // cout << x << ' ' << ind << endl;

        while(x > qw.size() && i < p2){
            int h = deg[p2--].second;

            qw.push(h);
        }

        if(i >= p2) break;

        for(int j = 0; j < x; j++){
            int h = qw.front(); qw.pop();
            ans.push_back({ind, h});
        }
        qw.push(ind);
        resp++;
    }

    int x = deg[p2].first, ind = deg[p2].second;

    if(x == qw.size()){
        resp++;
    }

    while(!qw.empty()){
        int h = qw.front(); qw.pop();
        ans.push_back({ind, h});
    }

    cout << n-resp << endl;
    cout << n << ' ' << n-1 << endl;

    for(auto[a,b]: ans) cout << a << ' ' << b << endl;

    return 0;
}

详细

Test #1:

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

Test #2:

score: 0
Accepted
time: 0ms
memory: 3616kb

Test #3:

score: 0
Accepted
time: 0ms
memory: 3576kb

Test #4:

score: 0
Accepted
time: 0ms
memory: 3632kb

Test #5:

score: 0
Accepted
time: 1ms
memory: 3544kb

Test #6:

score: 0
Accepted
time: 0ms
memory: 3548kb

Test #7:

score: 0
Accepted
time: 0ms
memory: 3584kb

Test #8:

score: 0
Accepted
time: 1ms
memory: 3788kb

Test #9:

score: 0
Accepted
time: 1ms
memory: 3492kb

Test #10:

score: 0
Accepted
time: 1ms
memory: 3568kb

Test #11:

score: 0
Accepted
time: 0ms
memory: 3548kb

Test #12:

score: 0
Accepted
time: 1ms
memory: 3788kb

Test #13:

score: 0
Accepted
time: 2ms
memory: 3620kb

Test #14:

score: 0
Accepted
time: 2ms
memory: 3632kb

Test #15:

score: 0
Accepted
time: 2ms
memory: 3612kb

Test #16:

score: 0
Accepted
time: 2ms
memory: 3592kb

Test #17:

score: 0
Accepted
time: 0ms
memory: 3520kb

Test #18:

score: 0
Accepted
time: 9ms
memory: 3596kb

Test #19:

score: 0
Accepted
time: 11ms
memory: 3792kb

Test #20:

score: 0
Accepted
time: 3ms
memory: 3816kb

Test #21:

score: 0
Accepted
time: 4ms
memory: 3752kb

Test #22:

score: 0
Accepted
time: 8ms
memory: 3824kb

Test #23:

score: 0
Accepted
time: 3ms
memory: 4044kb

Test #24:

score: 0
Accepted
time: 7ms
memory: 4040kb

Test #25:

score: 0
Accepted
time: 8ms
memory: 3756kb

Test #26:

score: 0
Accepted
time: 8ms
memory: 3792kb

Test #27:

score: 0
Accepted
time: 7ms
memory: 3752kb

Test #28:

score: 0
Accepted
time: 8ms
memory: 3800kb

Test #29:

score: 0
Accepted
time: 7ms
memory: 3816kb

Test #30:

score: 0
Accepted
time: 0ms
memory: 3492kb

Test #31:

score: 0
Accepted
time: 0ms
memory: 3548kb

Test #32:

score: 0
Accepted
time: 0ms
memory: 3576kb

Test #33:

score: 0
Accepted
time: 6ms
memory: 3548kb

Test #34:

score: 0
Accepted
time: 0ms
memory: 3544kb

Test #35:

score: 0
Accepted
time: 1ms
memory: 3596kb

Test #36:

score: 0
Accepted
time: 0ms
memory: 3548kb

Test #37:

score: 0
Accepted
time: 1ms
memory: 3836kb