QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#266543 | #7107. Chaleur | UtopianZ# | AC ✓ | 57ms | 4184kb | C++14 | 1.7kb | 2023-11-26 15:17:09 | 2023-11-26 15:17:09 |
Judging History
answer
#include <set>
#include <cmath>
#include <queue>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#define ll long long
#define ull unsigned long long
#define pii std :: pair<int, int>
#define pb push_back
#define fi first
#define se second
#define lep(i, l, r) for(int i = l; i <= r; i++)
#define rep(i, r, l) for(int i = r; i >= l; i--)
#define mset(s, t) memset(s, t, sizeof(s))
#define mcpy(s, t) memcpy(s, t, sizeof(t))
template <typename T1, typename T2> void Min(T1 &x, T2 y) {
if (x > y) x = y;
}
template <typename T1, typename T2> void Max(T1 &x, T2 y) {
if (x < y) x = y;
}
int read() {
int x = 0, f = 0;
char ch = getchar();
while (!isdigit(ch)) f |= ch == '-', ch = getchar();
while (isdigit(ch)) x = 10 * x + ch - '0', ch = getchar();
return f ? -x : x;
}
template <typename T> void print(T x) {
if (x < 0) putchar('-'), x = -x;
if (x >= 10) print(x / 10);
putchar(x % 10 + '0');
}
template <typename T> void Print(T x, char let) {
print(x), putchar(let);
}
const int N = 1e5 + 5;
int T, n, m;
int deg[N];
int main() {
T = read();
while (T--) {
mset(deg, 0);
n = read(), m = read();
for(int i = 1, u, v; i <= m; i++) deg[u = read()]++, deg[v = read()]++;
std :: sort(deg + 1, deg + n + 1);
int cnt = 0, ans1 = 1, ans2 = 1;
for (int i = n; i; i--) if(deg[i] >= cnt) cnt++;
int C = 0, res = 0;
for (int i = n; i; i--) {
if (deg[i] >= C) {
C++;
if(deg[i] == cnt - 1) res++;
else if(deg[i] == cnt) ans2++;
}
else if(deg[i] == cnt - 1) ans1++;
}
if(res) ans2 = res;
printf("%d %d\n", ans1 ,ans2);
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 4180kb
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: 57ms
memory: 4184kb
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