QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#375512#6643. Graphs and Colorsneko_nyaaWA 1ms3640kbC++231.6kb2024-04-03 11:41:542024-04-03 11:41:54

Judging History

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

  • [2024-04-03 11:41:54]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3640kb
  • [2024-04-03 11:41:54]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template <typename T> using min_heap = priority_queue<T, vector<T>, greater<T>>;

void solve() {
	int n, k; cin >> n >> k;
	if (k > n/2) {
		cout << "NO\n";
		return;
	}

	cout << "YES\n";
	vector<int> p;
	for (int i = 1; i <= n - n%2; i++) {
		p.push_back(i-1);
	}

	int ans[n][n];
	memset(ans, 0, sizeof(ans));
	for (int i = 0; i < n/2; i++) {
		int col = min(i+1, k);
		for (int j = 0; j+1 < n/2; j++) {
			ans[p[j]][p[j+1]] = ans[p[j+1]][p[j]] = col;
			ans[p[j+n/2]][p[j+n/2+1]] = ans[p[j+n/2+1]][p[j+n/2]] = col;

			//cout << "EDGE " << p[j] << ' ' << p[j+1] << ' ' << col << '\n';
			//cout << "EDGE " << p[j+n/2] << ' ' << p[j+n/2+1] << ' ' << col << '\n';
		}
		ans[p[0]][p[n/2]] = ans[p[n/2]][p[0]] = col;
		//cout << "EDGE " << p[0] << ' ' << p[n/2] << ' ' << col << '\n';

		if (n % 2) {
			ans[p[0]][n-1] = ans[n-1][p[0]] = col;
			ans[p[n/2]][n-1] = ans[n-1][p[n/2]] = col;

			//cout << "EDGE " << p[0] << ' ' << n-1 << ' ' << col << '\n';
			//cout << "EDGE " << p[n/2] << ' ' << n-1 << ' ' << col << '\n';
		}
		rotate(p.begin(), p.begin()+1, p.begin()+(n - n%2));
	}

	for (int i = 1; i < n; i++) {
		for (int j = 0; j < i; j++) {
			cout << ans[i][j] << ' ';
		}
		cout << '\n';
	}
}

signed main() {
	ios::sync_with_stdio(0); cin.tie(0);
	
	int t; cin >> t;
	while (t--) {
		solve();
	}
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3640kb

input:

768
8 24
7 20
17 61
17 76
16 100
16 16
15 59
9 17
14 31
14 61
10 32
17 55
5 7
10 29
14 82
13 47
17 32
5 10
16 76
14 59
8 28
13 19
12 41
13 41
11 32
11 53
3 2
16 52
16 87
7 12
9 15
15 65
15 53
17 47
6 15
12 1
14 35
16 60
12 31
14 70
15 88
12 2
8 23
12 38
16 111
16 117
5 4
14 90
12 55
15 41
15 48
15 4...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
1 
0 1 
0 0 1 
0 0 0 1 
0 0 0 0 1 
1 0 0 0 0 1 
0 1 0 0 0 0 1 
0 0 1 0 0 0 0 1 
0 0 0 1 0 0 0 0 1 
0 0 0 0 1 0 0 0 0 1 
1 0 0 0 0 1 0 0 0 0 1 
NO
NO
NO
NO
NO
YES
2 
0 2 
0 0 2 
0 0 0 2 
0 0 0...

result:

wrong answer Integer parameter [name=col] equals to 0, violates the range [1, 1] (test case 36)