QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#209816 | #7107. Chaleur | Eznibuil | AC ✓ | 19ms | 4072kb | C++17 | 2.7kb | 2023-10-10 17:51:07 | 2023-10-10 17:51:08 |
Judging History
answer
#pragma GCC optimize("Ofast,inline,no-stack-protector,unroll-loops")
#include<stdio.h>
#include<algorithm>
#include<execution>
#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 deg[1000001];
int main()
{
int t;
fin>>t;
while(t--)
{
int n,m;
fin>>n>>m,std::fill_n(std::execution::par_unseq,deg,n,0);
while(m--)
{
int a,b;
fin>>a>>b,deg[a-1]++,deg[b-1]++;
}
std::sort(std::execution::par_unseq,deg,deg+n,[](int x,int y){return x>y;});
int x{};
for(;x<n&°[x]>=x;x++);
int ans{std::count(std::execution::par_unseq,deg,deg+x,x-1)};
printf("%d %d\n",1+std::count(std::execution::par_unseq,deg+x,deg+n,x-1),ans?ans:1+std::count(std::execution::par_unseq,deg,deg+x,x));
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 1480kb
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: 19ms
memory: 4072kb
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