QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#209793 | #7107. Chaleur | QZJ123456 | AC ✓ | 28ms | 5080kb | C++14 | 4.1kb | 2023-10-10 17:28:40 | 2023-10-10 17:28:41 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define NEGATIVE
struct freader {
FILE *f;
# ifdef ONLINE_JUDGE
char buf[1048577], *p1, *p2;
# define fgetc(f) (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1048576, f), p1 == p2) ? EOF : *p1++)
# endif
# ifdef BOOLTRANS
bool neof;
# define NEOF(c) ((c) != EOF || (neof = 0))
# else
# define NEOF(c) ((c) != EOF)
# endif
freader(FILE *_f = stdin) : f(_f) {
# ifdef BOOLTRANS
neof = 1;
# endif
# ifdef ONLINE_JUDGE
setvbuf(f, NULL, _IONBF, 0);
p1 = p2 = buf;
# endif
}
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;
}
void read(float x) {return fputs("Error: Unable to read float.", stderr), void();}
void read(double x) {return fputs("Error: Unable to read double.", stderr), void();}
void read(long double x) {return fputs("Error: Unable to read long double.", stderr), void();}
template<typename T> void read(T &x) {
char c(fgetc(f));
# ifdef NEGATIVE
for (; NEOF(c) && (c < '0' || c > '9') && c != '-'; c = fgetc(f));
if (c == '-')
for (c = fgetc(f), x = 0; NEOF(c) && c >= '0' && c <= '9'; c = fgetc(f)) x = (x << 3) + (x << 1) - (c ^ '0');
else
for (x = 0; NEOF(c) && c >= '0' && c <= '9'; c = fgetc(f)) x = (x << 3) + (x << 1) + (c ^ '0');
# else
for (; NEOF(c) && (c < '0' || c > '9'); c = fgetc(f));
for (x = 0; NEOF(c) && c >= '0' && c <= '9'; 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
} fin;
#undef NEGATIVE
struct fwriter {
FILE *f;
# ifdef ONLINE_JUDGE
char buf[1048577], *p1;
# define fputc(c, f) (p1 == buf + 1048576 ? fwrite(buf, 1, 1048576, f), *(p1 = buf)++ = (c) : *p1++ = (c))
# endif
fwriter(FILE *_f = stdout): f(_f) {
# ifdef ONLINE_JUDGE
setvbuf(f, NULL, _IONBF, 0);
p1 = buf;
# endif
}
~fwriter() {flush();}
void flush() {
# ifdef ONLINE_JUDGE
fwrite(buf, 1, p1 - buf, f), p1 = buf;
# else
fflush(f);
# endif
return;
}
void write(char c) {return fputc(c, f), void();}
void write(char *s) {
for (; *s; s++) fputc(*s, f);
return;
}
void write(const char *s) {
for (; *s; s++) fputc(*s, f);
return;
}
void write(float x) {return fputs("Error: Unable to write float.", stderr), void();}
void write(double x) {return fputs("Error: Unable to write double.", stderr), void();}
void write(long double x) {return fputs("Error: Unable to write long double.", stderr), void();}
template<typename T> void write(T x) {
if (!x) return fputc('0', f), void();
if (x < 0) fputc('-', f), x = -x;
char s[41];
int l(0);
while (x) s[l++] = x % 10 ^ '0', x /= 10;
while (l--) fputc(s[l], f);
return;
}
# if __cplusplus >= 201103
template<typename T, typename...Args> void write(T x, Args...args) {return write(x), write(args...);}
# endif
template<typename T> fwriter &operator << (T x) {return write(x), *this;}
# ifdef ONLINE_JUDGE
# undef fputc
# endif
} fout;
int T,n,m,d[100005];
int main(){
fin>>T;
while(T--){
fin>>n>>m;
for(int i=1;i<=n;i++)d[i]=0;
for(int i=1;i<=m;i++){
int x,y;fin>>x>>y;d[x]++,d[y]++;
}
sort(d+1,d+1+n);reverse(d+1,d+1+n);int pos=0;
for(int i=1;i<=n;i++){
if(d[i]>=i-1)continue;
pos=i;break;
}
if(!pos)pos=n;
int ans=1;
for(int i=pos;i<=n;i++)if(d[i]==pos-2)ans++;
fout<<ans<<" ";
int ans1=0,ans2=1;
for(int i=1;i<pos;i++){
if(d[i]==pos-2)ans1++;
else if(d[i]==pos-1)ans2++;
}
if(!ans1)fout<<ans2<<'\n';
else fout<<ans1<<'\n';
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3608kb
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: 28ms
memory: 5080kb
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