QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#162745#7107. ChaleurGenshinImpactsFault#AC ✓29ms4552kbC++171.3kb2023-09-03 16:14:572023-09-03 16:14:57

Judging History

你现在查看的是最新测评结果

  • [2023-09-03 16:14:57]
  • 评测
  • 测评结果:AC
  • 用时:29ms
  • 内存:4552kb
  • [2023-09-03 16:14:57]
  • 提交

answer

#include<bits/stdc++.h>
#define inf 1e9
#define eps 1e-6
#define FOR(i, a, b) for(int i = a; i <= b; i ++)
#define REP(i, a, b) for(int i = a; i >= b; i --)
#define pb push_back
#define fr first
#define sd second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
	char ch = getchar();
	ll s = 0, w = 1;
	while(ch < '0' || ch > '9'){if(ch == '-')w = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9'){s = s * 10 + ch - '0'; ch = getchar();}
	return s * w;
}
#define N 100010
int n, m;
int deg[N], num[N], s[N];
int calc()
{
	REP(i, n, 0)s[i] = s[i + 1] + num[i];
	REP(M, n, 1)
	{
		if(s[M] <= M && s[M - 1] >= M)
		{
			return s[M - 1] - M + 1;
		}
	}
	exit(-1);
}
void sol()
{
	n = read(), m = read();
	FOR(i, 1, m)
	{
		int x = read(), y = read();
		deg[x] ++, deg[y] ++;
	}
	FOR(i, 0, n)num[i] = 0;
	FOR(i, 1, n)num[deg[i]] ++;
	cout << calc() << ' ';
	FOR(i, 1, n)deg[i] = n - 1 - deg[i];
	FOR(i, 0, n)num[i] = 0;
	FOR(i, 1, n)num[deg[i]] ++;
	cout << calc() << '\n';
	FOR(i, 0, n + 1)deg[i] = s[i] = num[i] = 0;
}
int main()
{
	int T = read();
	while(T --)sol();
	return 0;
}
/*
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
*/
/*
1
6 6
1 2
2 3
1 3
1 4
2 5
3 6
*/

这程序好像有点Bug,我给组数据试试?

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3388kb

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: 29ms
memory: 4552kb

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