QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#209890 | #7107. Chaleur | Myrrh | AC ✓ | 22ms | 5732kb | C++14 | 1.8kb | 2023-10-10 18:59:45 | 2023-10-10 18:59:46 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
static char buf[1000000],*p1=buf,*p2=buf;
#define getchar() p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++
template<typename item>
inline void read(register item &x)
{
bool flag=false;
x=0;register char c=getchar();
while(c<'0'||c>'9')
{
if(c=='-')
flag=true;
c=getchar();
}
while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^48),c=getchar();
if(flag)
x=-x;
}
const int MAXN=1e5+50;
int N,M;
int Deg[MAXN],Cnt[MAXN];
int a[MAXN],tot;
void Solve()
{
read(N);
read(M);
if(M==0)
{
printf("%d %d\n",N,1);
return;
}
for(int i=1;i<=N;i++)
Deg[i]=0;
for(int i=1;i<=M;i++)
{
int x,y;
read(x);
read(y);
Deg[x]++;
Deg[y]++;
}
for(int i=1;i<=N;i++)
{
Cnt[Deg[i]]++;
}
tot=0;
for(int i=N;i>=0;i--)
{
while(Cnt[i])
{
a[++tot]=i;
Cnt[i]--;
}
}
int Size=0;
for(int i=1;i<=N;i++)
{
if(a[i]>=Size)
{
Size++;
}
else
break;
}
int ans1=1,ans2=0;
for(int i=Size+1;i<=N;i++)
{
if(a[i]==Size-1)
ans1++;
else
break;
}
if(a[Size]<=Size)
{
ans2=(a[Size]==Size);
for(int i=Size;i>=1;i--)
{
if(a[i]==a[Size])
ans2++;
else
break;
}
}
else
ans2=1;
printf("%d %d\n",ans1,ans2);
}
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
Solve();
}
}
/*
stuff you should look for
* int overflow, array bounds
* special cases (n=1?)
* i and j are misplaced
* variable misuse
* do smth instead of nothing and stay organized
* vector cause MLE or TLE
* wrong file name
* DON'T SLEEP IN THE EXAM
* WRITE STUFF DOWN
* DON'T GET STUCK ON ONE APPROACH
* DON'T GET A SWELLED HEAD
* YOU MUSTN'T HAVE EMOTION
->be based on Benq's code
*/
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3992kb
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: 22ms
memory: 5732kb
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