QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#209800 | #7107. Chaleur | Eznibuil | RE | 1ms | 5584kb | C++14 | 2.6kb | 2023-10-10 17:36:01 | 2023-10-10 17:36:02 |
Judging History
answer
#include<stdio.h>
#include<algorithm>
#include<numeric>
#include<vector>
#define FIOBUFSIZ (1<<20|1)
struct freader
{
FILE*f;
# ifdef ONLINE_JUDGE
char buf[FIOBUFSIZ],*p1,*p2;
# define fgetc(f) (p1==p2&&(p2=(p1=buf)+fread(buf,1,FIOBUFSIZ,f),p1==p2)?EOF:*p1++)
# endif
# ifdef BOOLTRANS
bool neof;
# define NEOF(c) ((c)!=EOF||(neof=0))
# else
# define NEOF(c) ((c)!=EOF)
# endif
# ifdef NOTONLYDIGIT
# define isdigit(c) ((c)>='0'&&(c)<='9')
# define isnotdigit(c) ((c)<'0'||(c)>'9')
# else
# define isdigit(c) ((c)>='0')
# define isnotdigit(c) ((c)<'0')
# endif
freader(FILE*_f=stdin):f(_f)
{
# ifdef BOOLTRANS
neof=1;
# endif
# ifdef ONLINE_JUDGE
setvbuf(f,NULL,_IONBF,0);
p1=p2=buf;
# endif
}
# ifdef NOTONLYDIGIT
void read(char&x)
{
for(x=fgetc(f);NEOF(x)&&x<=' ';x=fgetc(f));
return;
}
void read(char*s)
{
for(*s=fgetc(f);NEOF(*s)&&*s<=' ';*s=fgetc(f));
for(s++;NEOF(*s=fgetc(f))&&*s>' ';s++);
*s='\0';
return;
}
freader&operator>>(char*x)
{
# ifdef BOOLTRANS
return *this?read(x),*this:*this;
# else
return read(x),*this;
# endif
}
# endif
template<typename T>void read(T&x)
{
char c(fgetc(f));
# ifdef NEGATIVE
for(;NEOF(c)&&isnotdigit(c)&&c!='-';c=fgetc(f));
if(c=='-')
for(c=fgetc(f),x=0;NEOF(c)&&isdigit(c);c=fgetc(f))
x=(x<<3)+(x<<1)-(c^'0');
else
for(x=0;NEOF(c)&&isdigit(c);c=fgetc(f))
x=(x<<3)+(x<<1)+(c^'0');
# else
for(;NEOF(c)&&isnotdigit(c);c=fgetc(f));
for(x=0;NEOF(c)&&isdigit(c);c=fgetc(f))
x=(x<<3)+(x<<1)+(c^'0');
# endif
return;
}
# if __cplusplus>=201103
template<typename T,typename...Args>void read(T&x,Args&...args){return read(x),read(args...);}
# endif
template<typename T>freader&operator>>(T&x)
{
# ifdef BOOLTRANS
return *this?read(x),*this:*this;
# else
return read(x),*this;
# endif
}
# ifdef BOOLTRANS
operator bool(){return neof;}
# endif
# ifdef ONLINE_JUDGE
# undef fgetc
# endif
# undef NEOF
# undef isdigit
# undef isnotdigit
}fin;
#undef FIOBUFSIZ
int e[1000001],deg[1000001];
int main()
{
int t;
fin>>t;
while(t--)
{
int n,m;
fin>>n>>m,std::fill_n(deg,n,0),std::iota(e,e+n,0);
while(m--)
{
int a,b;
fin>>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;});
printf("%d %d\n",ans[0],ans[1]);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5584kb
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 ...