QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#221954 | #2437. Wireless is the New Fiber | ucup-team2172# | AC ✓ | 5ms | 3928kb | C++14 | 1.2kb | 2023-10-21 15:10:43 | 2023-10-21 15:10:43 |
Judging History
answer
#include <bits/stdc++.h>
#define inf (0x7f7f7f7f)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
typedef long long ll;
using namespace std;
template <class T>
inline void read(T &x){
int ch = 0, f = 0; x = 0;
for(; !isdigit(ch); ch = getchar()) if(ch == '-') f = 1;
for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
if(f) x = -x;
}
int n,m;
const int N = 1e4 + 5;
struct node{
int id,deg;
}p[N];
bool cmp(node a,node b){
return a.deg > b.deg;
}
int main(){
read(n),read(m);
for(int i = 0; i < n; i++) p[i].id = i, p[i].deg = 0;
int a,b;
for(int i = 1; i <= m; i++){
read(a),read(b);
p[a].deg++,p[b].deg++;
}
sort(p, p + n, cmp);
int ans = 0;
int sum = 2 * m;
for(int i = 0; i < n; i++){
if(sum == 2 * n - 2) break;
if(sum - (p[i].deg - 1) >= 2 * n - 2){
sum -= (p[i].deg - 1);
p[i].deg = 1;
ans++;
}
else{
int delt = sum - (2 * n - 2);
p[i].deg -= delt;
ans++;
break;
}
}
sort(p, p + n, cmp);
printf("%d\n",ans);
printf("%d %d\n",n, n - 1);
int last = 0;
for(int i = 1; i < n ; i++){
while(p[last].deg == 0) last++;
printf("%d %d\n",p[i].id,p[last].id);
p[last].deg--;
p[i].deg--;
}
return 0;
}
Details
Test #1:
score: 100
Accepted
time: 1ms
memory: 3628kb
Test #2:
score: 0
Accepted
time: 0ms
memory: 3520kb
Test #3:
score: 0
Accepted
time: 0ms
memory: 3580kb
Test #4:
score: 0
Accepted
time: 1ms
memory: 3752kb
Test #5:
score: 0
Accepted
time: 0ms
memory: 3852kb
Test #6:
score: 0
Accepted
time: 0ms
memory: 3620kb
Test #7:
score: 0
Accepted
time: 1ms
memory: 3620kb
Test #8:
score: 0
Accepted
time: 0ms
memory: 3780kb
Test #9:
score: 0
Accepted
time: 0ms
memory: 3752kb
Test #10:
score: 0
Accepted
time: 1ms
memory: 3492kb
Test #11:
score: 0
Accepted
time: 0ms
memory: 3632kb
Test #12:
score: 0
Accepted
time: 1ms
memory: 3860kb
Test #13:
score: 0
Accepted
time: 0ms
memory: 3588kb
Test #14:
score: 0
Accepted
time: 1ms
memory: 3624kb
Test #15:
score: 0
Accepted
time: 1ms
memory: 3568kb
Test #16:
score: 0
Accepted
time: 0ms
memory: 3624kb
Test #17:
score: 0
Accepted
time: 1ms
memory: 3584kb
Test #18:
score: 0
Accepted
time: 0ms
memory: 3580kb
Test #19:
score: 0
Accepted
time: 2ms
memory: 3688kb
Test #20:
score: 0
Accepted
time: 3ms
memory: 3852kb
Test #21:
score: 0
Accepted
time: 3ms
memory: 3860kb
Test #22:
score: 0
Accepted
time: 1ms
memory: 3628kb
Test #23:
score: 0
Accepted
time: 3ms
memory: 3928kb
Test #24:
score: 0
Accepted
time: 4ms
memory: 3696kb
Test #25:
score: 0
Accepted
time: 4ms
memory: 3568kb
Test #26:
score: 0
Accepted
time: 5ms
memory: 3692kb
Test #27:
score: 0
Accepted
time: 5ms
memory: 3684kb
Test #28:
score: 0
Accepted
time: 5ms
memory: 3652kb
Test #29:
score: 0
Accepted
time: 0ms
memory: 3688kb
Test #30:
score: 0
Accepted
time: 0ms
memory: 3492kb
Test #31:
score: 0
Accepted
time: 0ms
memory: 3580kb
Test #32:
score: 0
Accepted
time: 1ms
memory: 3756kb
Test #33:
score: 0
Accepted
time: 2ms
memory: 3564kb
Test #34:
score: 0
Accepted
time: 0ms
memory: 3556kb
Test #35:
score: 0
Accepted
time: 0ms
memory: 3560kb
Test #36:
score: 0
Accepted
time: 0ms
memory: 3548kb
Test #37:
score: 0
Accepted
time: 0ms
memory: 3856kb