QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#344441#5575. Knight's Tour ReduxFAKUMARERWA 0ms3672kbC++142.2kb2024-03-04 16:08:542024-03-04 16:08:54

Judging History

This is the latest submission verdict.

  • [2024-03-04 16:08:54]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3672kb
  • [2024-03-04 16:08:54]
  • Submitted

answer

#include <iostream>
#define A 10
#define B 11

using namespace std;

inline void Print (const int x, const int y) {
	cout << x << ' ' << y << '\n';
}

inline void Work_5 (const int x) {
	Print (x + 2, x + 4);
	Print (x + 3, x + 1);
	Print (x + 0, x + 0);
	Print (x + 1, x + 3);
	Print (x + 4, x + 2);
}

inline void Work_6 (const int x) {
	Print (x + 0, x + 0);
	Print (x + 1, x + 3);
	Print (x + 4, x + 4);
	Print (x + 5, x + 1);
	Print (x + 2, x + 2);
	Print (x + 3, x + 5);
}

inline void Work_7 (const int x) {
	Print (x + 0, x + 0);
	Print (x + 1, x + 3);
	Print (x + 4, x + 4);
	Print (x + 5, x + 1);
	Print (x + 2, x + 2);
	Print (x + 3, x + 5);
	Print (x + 1, x + 1);
}

inline void Work_8 (const int x) {
	Print (x + 0, x + 0);
	Print (x + 1, x + 3);
	Print (x + 2, x + 6);
	Print (x + 5, x + 7);
	Print (x + 4, x + 4);
	Print (x + 3, x + 1);
	Print (x + 6, x + 2);
	Print (x + 7, x + 5);
}

inline void Work_9 (const int x) {
	Print (x + 0, x + 0);
	Print (x + 1, x + 3);
	Print (x + 2, x + 6);
	Print (x + 5, x + 7);
	Print (x + 4, x + 4);
	Print (x + 3, x + 1);
	Print (x + 6, x + 2);
	Print (x + 7, x + 5);
	Print (x + 8, x + 8);
} 

inline void Work_A (const int x) {
	Print (x + 0, x + 0);
	Print (x + 1, x + 3);
	Print (x + 2, x + 6);
	Print (x + 3, x + 9);
	Print (x + 6, x + 8);
	Print (x + 5, x + 5);
	Print (x + 4, x + 2);
	Print (x + 7, x + 1);
	Print (x + 8, x + 4);
	Print (x + 9, x + 7);
}

inline void Work_B (const int x) {
	Print (x + 0, x + 0);
	Print (x + 1, x + 3);
	Print (x + 2, x + 6);
	Print (x + 3, x + 9);
	Print (x + 6, x + 8);
	Print (x + 5, x + 5);
	Print (x + 4, x + 2);
	Print (x + 7, x + 1);
	Print (x + 8, x + 4);
	Print (x + 9, x + 7);
	Print (x + A, x + A);
}

int N, P = 1;

int main () {
	
	cin >> N;
	
	if (N == 1) return cout << "POSSIBLE" << endl << 1 << ' ' << 1 << endl, 0;
	if (N <= 4) return cout << "IMPOSSIBLE" << endl, 0;
	
	cout << "POSSIBLE" << endl;
	
	if (N == 5) return Work_5 (P), 0;
	
	while (N >= 12) Work_6 (P), P += 6, N -= 6;
	
	if (N == 6) Work_6 (P);
	if (N == 7) Work_7 (P);
	if (N == 8) Work_8 (P);
	if (N == 9) Work_9 (P);
	if (N == A) Work_A (P);
	if (N == B) Work_B (P);
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1

output:

POSSIBLE
1 1

result:

ok answer = 1

Test #2:

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

input:

2

output:

IMPOSSIBLE

result:

ok answer = 0

Test #3:

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

input:

3

output:

IMPOSSIBLE

result:

ok answer = 0

Test #4:

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

input:

4

output:

IMPOSSIBLE

result:

ok answer = 0

Test #5:

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

input:

5

output:

POSSIBLE
3 5
4 2
1 1
2 4
5 3

result:

ok answer = 1

Test #6:

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

input:

6

output:

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

result:

ok answer = 1

Test #7:

score: -100
Wrong Answer
time: 0ms
memory: 3612kb

input:

7

output:

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

result:

wrong answer Invalid Jump from (4, 6) to (2, 2)