QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#209643 | #7107. Chaleur | fyz216 | WA | 126ms | 4232kb | C++14 | 655b | 2023-10-10 16:22:31 | 2023-10-10 16:22:32 |
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;d[n+1]=1e9;
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+1;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);
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3628kb
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: 126ms
memory: 4232kb
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'