QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#159221 | #7107. Chaleur | ucup-team045# | AC ✓ | 162ms | 7668kb | C++20 | 1.4kb | 2023-09-02 17:38:57 | 2023-09-02 17:38:58 |
Judging History
answer
#include<iostream>
#include<cstring>
#include<vector>
#include<cmath>
using namespace std;
using LL = long long;
int main(){
#ifdef LOCAL
freopen("data.in", "r", stdin);
freopen("data.out", "w", stdout);
#endif
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(0);
int T;
cin >> T;
while(T--){
int n, m;
cin >> n >> m;
vector<vector<int> > g(n + 1);
for(int i = 0; i < m; i++){
int a, b;
cin >> a >> b;
g[a].push_back(b), g[b].push_back(a);
}
vector<int> id(n);
for(int i = 0; i < n; i++) id[i] = i + 1;
sort(id.begin(), id.end(), [&](int a, int b){
return g[a].size() > g[b].size();
});
int mx = n;
for(int i = 0; i < n; i++){
if (g[id[i]].size() < i){
mx = i;
break;
}
}
int cnt1 = 1;
for(int i = mx; i < n; i++){
if (g[id[i]].size() == mx - 1){
cnt1 += 1;
}
}
cout << cnt1 << ' ';
int cnt2 = 0, cnt3 = 0;
for(int i = 0; i < mx; i++){
if (g[id[i]].size() == mx - 1) cnt2 += 1;
if (g[id[i]].size() == mx) cnt3 += 1;
}
if (cnt2 != 0){
cout << cnt2 << '\n';
}
else{
cout << cnt3 + 1 << '\n';
}
}
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3580kb
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: 162ms
memory: 7668kb
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