QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#142136#5575. Knight's Tour Reduxammardab3an#WA 1ms3552kbC++171.8kb2023-08-18 15:32:202023-08-18 15:32:22

Judging History

This is the latest submission verdict.

  • [2023-08-18 15:32:22]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3552kb
  • [2023-08-18 15:32:20]
  • Submitted

answer

#include <bits/stdc++.h>


using namespace std;

int main() {
	int n;
	cin >> n;
	vector<pair<int, int>>v10 = { {1,1},{4,2},{3,5},{2,8},{5,9},{6,6},{7,3},{10,4},{9,7},{8,10} };
	vector<pair<int, int>>v8 = { {1,1},{2,4},{3,7},{6,8},{5,5},{4,2},{7,3},{8,6} };
	vector<pair<int, int>>v7 = { {1,1},{2,4},{5,5},{6,2},{3,3},{4,6},{7,7} };
	vector<pair<int, int>>v6 = { {1,1},{2,4},{5,5},{6,2},{3,3},{4,6} };
	vector<pair<int, int>>v5 = { {1,3},{4,2},{5,5},{2,4},{3,1} };

	if (n == 12 || n == 13) {
		int cur = 0;
		for (auto x : v6) {
			cout << x.first + cur << " " << x.second + cur << '\n';
		}
		cur = 6;
		for (auto x : v6) {
			cout << x.first + cur << " " << x.second + cur << '\n';
		}
		cur = 12;
		if (n == 13) {
			cout << 13 << " " << 13 << '\n';
		}
		return 0;
	}

	for (int i = 0; i < 4; i++) {
		if (n < i * 10)break;
		int m = (n - i * 10) % 8;
		if (!m || m == 1 || m == 7 || m == 6||m==5) {
			cout << "POSSIBLE\n";
			int cur = 0;
			for (int j = 0; j < i; j++) {
				for (auto x : v10)cout << x.first + cur << " " << x.second + cur << '\n';
				cur += 10;
			}
			n -= 10 * i;
			int mm = n / 8;
			while (mm--) {
				for (auto x : v8) {
					cout << x.first + cur << " " << x.second + cur << '\n';
				}
				n -= 8;
				cur += 8;
			}
			if (m == 1) {
				cout << cur + 1 << " " << cur + 1 << '\n';
			}
			else if (m == 7) {
				for (auto x : v7) {
					cout << x.first + cur << " " << x.second + cur << '\n';
				}
			}
			else if (m == 6) {
				for (auto x : v6) {
					cout << x.first + cur << " " << x.second + cur << '\n';
				}
			}
			else if (n == 5) {
				for (auto x : v5) {
					cout << x.first + cur << " " << x.second + cur << '\n';
				}
			}
			return 0;
		}
	}
	cout << "IMPOSSIBLE\n";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1

output:

POSSIBLE
1 1

result:

ok answer = 1

Test #2:

score: 0
Accepted
time: 1ms
memory: 3508kb

input:

2

output:

IMPOSSIBLE

result:

ok answer = 0

Test #3:

score: 0
Accepted
time: 0ms
memory: 3524kb

input:

3

output:

IMPOSSIBLE

result:

ok answer = 0

Test #4:

score: 0
Accepted
time: 1ms
memory: 3552kb

input:

4

output:

IMPOSSIBLE

result:

ok answer = 0

Test #5:

score: 0
Accepted
time: 1ms
memory: 3452kb

input:

5

output:

POSSIBLE
1 3
4 2
5 5
2 4
3 1

result:

ok answer = 1

Test #6:

score: 0
Accepted
time: 0ms
memory: 3504kb

input:

6

output:

POSSIBLE
1 1
2 4
5 5
6 2
3 3
4 6

result:

ok answer = 1

Test #7:

score: 0
Accepted
time: 0ms
memory: 3508kb

input:

7

output:

POSSIBLE
1 1
2 4
5 5
6 2
3 3
4 6
7 7

result:

ok answer = 1

Test #8:

score: 0
Accepted
time: 1ms
memory: 3500kb

input:

8

output:

POSSIBLE
1 1
2 4
3 7
6 8
5 5
4 2
7 3
8 6

result:

ok answer = 1

Test #9:

score: 0
Accepted
time: 1ms
memory: 3524kb

input:

9

output:

POSSIBLE
1 1
2 4
3 7
6 8
5 5
4 2
7 3
8 6
9 9

result:

ok answer = 1

Test #10:

score: 0
Accepted
time: 0ms
memory: 3440kb

input:

10

output:

POSSIBLE
1 1
4 2
3 5
2 8
5 9
6 6
7 3
10 4
9 7
8 10

result:

ok answer = 1

Test #11:

score: 0
Accepted
time: 1ms
memory: 3508kb

input:

11

output:

POSSIBLE
1 1
4 2
3 5
2 8
5 9
6 6
7 3
10 4
9 7
8 10
11 11

result:

ok answer = 1

Test #12:

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

input:

12

output:

1 1
2 4
5 5
6 2
3 3
4 6
7 7
8 10
11 11
12 8
9 9
10 12

result:

wrong answer Line [name=Possibility] equals to "1 1", doesn't correspond to pattern "[a-zA-Z]+"