QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#163490 | #7107. Chaleur | TsReaper | AC ✓ | 119ms | 4768kb | C++20 | 1.2kb | 2023-09-04 09:13:34 | 2023-09-04 09:13:34 |
Judging History
answer
#include <bits/stdc++.h>
#define MAXN ((int) 1e5)
using namespace std;
typedef pair<int, int> pii;
int n, m;
int deg[MAXN + 10];
bool flag[MAXN + 10];
void solve() {
scanf("%d%d", &n, &m);
if (m == 0) { printf("%d 1\n", n); return; }
memset(deg, 0, sizeof(int) * (n + 3));
for (int i = 1; i <= m; i++) {
int x, y; scanf("%d%d", &x, &y);
deg[x]++; deg[y]++;
}
vector<int> vec;
for (int i = 1; i <= n; i++) vec.push_back(i);
sort(vec.begin(), vec.end(), [&](int a, int b) {
return deg[a] > deg[b];
});
memset(flag, 0, sizeof(bool) * (n + 3));
int sz = 0;
for (int x : vec) {
if (deg[x] >= sz) sz++, flag[x] = true;
else break;
}
int ans = 1;
for (int i = 1; i <= n; i++) if (!flag[i] && deg[i] == sz - 1) ans++;
printf("%d ", ans);
int larger = 0, equal = 1;
for (int i = 1; i <= n; i++) if (flag[i]) {
if (deg[i] == sz - 1) larger++;
else if (deg[i] == sz) equal++;
}
printf("%d\n", larger ? larger : equal);
}
int main() {
int tcase; scanf("%d", &tcase);
while (tcase--) solve();
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 4100kb
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: 119ms
memory: 4768kb
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