QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#356900#7107. ChaleurkarunaAC ✓116ms4256kbC++201.1kb2024-03-18 15:32:352024-03-18 15:32:35

Judging History

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

  • [2024-03-18 15:32:35]
  • 评测
  • 测评结果:AC
  • 用时:116ms
  • 内存:4256kb
  • [2024-03-18 15:32:35]
  • 提交

answer

#include <bits/stdc++.h>
#define ff first
#define ss second
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
	cin.tie(0); ios_base::sync_with_stdio(0);
	int T;
	cin >> T;
	while (T--) {
		int n, m;
		cin >> n >> m;

		vector<int> a(n);
		for (int i = 0; i < m; i++) {
			int u, v;
			cin >> u >> v;
			a[u - 1]++;
			a[v - 1]++;
		}
		sort(a.rbegin(), a.rend());
		
		if (n == 1) {
			cout << 1 << ' ' << 1 << '\n';
			continue;
		}
		for (int t = 0; t < 2; t++) {
			for (int k = 1; k < n; k++) {
				if (a[k - 1] >= k - 1 && a[k] <= k) {
					int x = a[k - 1];
					int y = a[k];
					int z = (k == n - 1) ? 0 : a[k + 1];

					if (y <= k - 1) {
						int p = k;
						while (p < n && a[p] == k - 1) ++p;

						cout << p - k + 1 << ' ';
					}
					else {
						int p = k;
						while (p < n && a[p] == k) ++p;

						cout << p - k << ' ';
					}
					break;
				}
			}
			for (int i = 0; i < n; i++) a[i] = n - 1 - a[i];
			reverse(a.begin(), a.end());
		}
		cout << '\n';
	}
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3564kb

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: 116ms
memory: 4256kb

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...

result:

ok 2231 lines

Extra Test:

score: 0
Extra Test Passed