QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#209633 | #7107. Chaleur | fyz216 | WA | 119ms | 4228kb | C++14 | 642b | 2023-10-10 16:19:05 | 2023-10-10 16:19:06 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int T,n,m,d[N],sz;
bool cmp(int x,int y) {return x>y;}
int main() {
scanf("%d",&T);
while(T--) {
scanf("%d%d",&n,&m);
if(m==0) {
printf("%d 1\n",n);
continue;
}
for(int i=1;i<=n;i++) d[i]=0;
for(int i=1,x,y;i<=m;d[x]++,d[y]++,i++) scanf("%d%d",&x,&y);
sort(d+1,d+n+1,cmp);
for(int i=1;i<=n;i++)
if(d[i]<i-1) {sz=i-1;break;}
int ans=1,ans1=0,ans2=1;
for(int i=sz+1;i<=n;i++)
if(d[i]==sz-1) ans++;
for(int i=1;i<=sz;i++)
if(d[i]==sz) ans2++;
else if(d[i]==sz-1) ans1++;
printf("%d %d\n",ans,ans1?ans1:ans2);
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3856kb
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
Wrong Answer
time: 119ms
memory: 4228kb
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 1 1 1 2 1 4 1 2 1 4 1 2 1 2 1 3 1 4 1 4 1 1 1 2 1 4 1 1 1 1 1 1 1 3 1 4 1 4 1 4 1 3 1 3 1 4 1 4 1 2 1 4 1 4 1 1 1 1 1 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 1 4 1 4 1 1 1 2 1 4 1 2 1 2 1 1 5 4 1 1 1 3 1 4 1 1 1 2 1 1 5 3 1 3 1 1 1 3 1 3 1 2 1 1 5 4 1 3 1 1 1 2 1 3 1 2 1 2 1 ...
result:
wrong answer 4th lines differ - expected: '1 5', found: '1 1'