QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#209803 | #7107. Chaleur | Eznibuil | RE | 1ms | 5740kb | C++14 | 792b | 2023-10-10 17:39:08 | 2023-10-10 17:39:09 |
Judging History
answer
#pragma GCC optimize("Ofast,inline,no-stack-protector,unroll-loops")
#include<algorithm>
#include<iostream>
#include<numeric>
#include<vector>
int e[1000001],deg[1000001];
int main()
{
std::cin.tie(nullptr)->sync_with_stdio(0);
int t;
std::cin>>t;
while(t--)
{
int n,m;
std::cin>>n>>m,std::fill_n(deg,n,0),std::iota(e,e+n,0);
while(m--)
{
int a,b;
std::cin>>a>>b,deg[a-1]++,deg[b-1]++;
}
std::sort(e,e+n,[](int x,int y){return deg[x]>deg[y];});
int x{};
for(;deg[e[x]]>=x;x++);
int ans[2]{1+std::count_if(e+x,e+n,[=](int y){return deg[y]==x-1;}),std::count_if(e,e+x,[=](int y){return deg[y]==x-1;})};
if(!ans[1])
ans[1]=1+std::count_if(e,e+x,[=](int y){return deg[y]==x;});
std::cout<<ans[0]<<' '<<ans[1]<<'\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5740kb
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: -100
Runtime Error
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 ...