QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#190242#6131. TournamentwoshiluoWA 1ms3488kbC++20869b2023-09-28 15:51:052023-09-28 15:51:06

Judging History

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

  • [2023-09-28 15:51:06]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3488kb
  • [2023-09-28 15:51:05]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

void solve() {
	int n, k;
	cin >> n >> k;
	if (n % 2 == 1 || n <= k) {
		cout << "Impossible\n";
		return;
	}
	vector<vector<int>> b;
	vector<int> a;
	for (int i = 0; i < n; i++) {
		int bat = i ^ 1;
		a.push_back(bat);
	}
	b.emplace_back(a);
	for (int c = 2; b.size() < k; c += 2) {
		a.resize(n);
		for (int i = 0; i < n; i++) a[i] = -1;
		for (int i = 0; i < n; i++) {
			int bat = (i + c) % n;
			a[i] = bat;
			if (a[bat] == -1)
				a[bat] = i;
		}
		b.push_back(a);
		for (int i = 0; i < n; i += 2)
			swap(a[i], a[i + 1]);
		b.emplace_back(a);
	}
	for (int i = 0; i < k; i++)
		for (int j = 0; j < n; j++)
			cout << b[i][j] + 1 << " \n"[j + 1 == n];
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int t;
	cin >> t;
	while (t--) {
		solve();
	
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
3 1
4 3

output:

Impossible
2 1 4 3
3 4 1 2
4 3 2 1

result:

ok 4 lines

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3488kb

input:

100
1 4
2 1
2 2
2 3
3 6
4 2
4 3
4 4
4 5
5 4
6 1
6 2
6 4
7 1
8 3
8 7
8 8
8 14
9 4
10 1
10 2
10 3
12 2
12 3
12 4
12 8
13 2
14 1
14 2
14 4
15 4
16 9
16 15
16 16
16 28
17 6
18 1
18 2
18 4
19 5
20 1
20 3
20 4
20 6
21 1
22 1
22 2
22 3
23 4
24 5
24 7
24 8
24 15
25 3
26 1
26 2
26 3
27 5
28 1
28 3
28 4
28 6
...

output:

Impossible
2 1
Impossible
Impossible
Impossible
2 1 4 3
3 4 1 2
2 1 4 3
3 4 1 2
4 3 2 1
Impossible
Impossible
Impossible
2 1 4 3 6 5
2 1 4 3 6 5
3 4 5 6 1 2
2 1 4 3 6 5
3 4 5 6 1 2
4 3 6 5 2 1
5 6 1 2 3 4
Impossible
2 1 4 3 6 5 8 7
3 4 5 6 7 8 1 2
4 3 6 5 8 7 2 1
2 1 4 3 6 5 8 7
3 4 5 6 7 8 1 2
4 3 ...

result:

wrong answer 15th lines differ - expected: 'Impossible', found: '2 1 4 3 6 5'