QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#170827 | #7107. Chaleur | kjhhjki# | AC ✓ | 121ms | 4780kb | C++20 | 1.0kb | 2023-09-09 16:03:13 | 2023-09-09 16:03:37 |
Judging History
answer
#include <bits/stdc++.h>
#define MAXN 100005
#define For(I,A,B) for(int I = A, endi = B; I <= endi; ++I)
#define foR(I,A,B) for(int I = A, endi = B; I >= endi; --I)
using namespace std;
typedef long long _ll;
int T,n,m,u,v,ans1,res,ans2,cnt,d[MAXN],f[MAXN],pos[MAXN];
inline bool cmp(int a,int b){return d[a] > d[b];}
void solve()
{
cin >> n >> m; ans1 = 1; res = 0; ans2 = 1; cnt = 0;
if(!m) { cout << n << " 1\n"; return; }
For(i,1,n) d[i] = f[i] = 0, pos[i] = i;
For(i,1,m) cin >> u >> v, ++d[u], ++d[v];
sort(pos+1,pos+n+1,cmp);
For(i,1,n)
{
u = pos[i];
if(d[u] >= cnt) ++cnt, f[u] = 1;
else break;
}
For(i,1,n) if(!f[i] && d[i] == cnt-1) ++ans1;
For(i,1,n) if(f[i])
{
if(d[i] == cnt-1) ++res;
else if(d[i] == cnt) ++ans2;
}
if(res) ans2 = res;
cout << ans1 << " " << ans2 << "\n";
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> T;
while(T--) solve();
return 0;
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3608kb
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: 121ms
memory: 4780kb
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