CSES - Datatähti 2019 loppu - Results
Submission details
Task:Robotti
Sender:antti röyskö
Submission time:2019-01-17 12:49:14 +0200
Language:C++
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED12
#2ACCEPTED32
#3ACCEPTED56
Test results
testverdicttimegroup
#1ACCEPTED0.04 s1details
#2ACCEPTED0.01 s1details
#3ACCEPTED0.03 s1details
#4ACCEPTED0.02 s1details
#5ACCEPTED0.01 s1details
#6ACCEPTED0.02 s1details
#7ACCEPTED0.02 s1details
#8ACCEPTED0.02 s1details
#9ACCEPTED0.01 s2details
#10ACCEPTED0.01 s2details
#11ACCEPTED0.01 s2details
#12ACCEPTED0.03 s2details
#13ACCEPTED0.02 s2details
#14ACCEPTED0.01 s2details
#15ACCEPTED0.01 s2details
#16ACCEPTED0.02 s2details
#17ACCEPTED0.01 s2details
#18ACCEPTED0.02 s3details
#19ACCEPTED0.01 s3details
#20ACCEPTED0.01 s3details
#21ACCEPTED0.01 s3details
#22ACCEPTED0.02 s3details
#23ACCEPTED0.02 s3details
#24ACCEPTED0.02 s3details
#25ACCEPTED0.02 s3details
#26ACCEPTED0.01 s3details
#27ACCEPTED0.01 s3details
#28ACCEPTED0.02 s3details
#29ACCEPTED0.02 s3details
#30ACCEPTED0.02 s3details
#31ACCEPTED0.02 s3details
#32ACCEPTED0.01 s3details
#33ACCEPTED0.02 s3details
#34ACCEPTED0.03 s3details
#35ACCEPTED0.02 s3details
#36ACCEPTED0.03 s3details
#37ACCEPTED0.03 s3details
#38ACCEPTED0.03 s3details
#39ACCEPTED0.02 s3details

Code

#include <iostream>
using namespace std;

const int N = 100;
int res[N][N];
int c = 0;
int x = 0;
int y = 0;
int dx = 1;
int dy = 0;

int sgn(int v) {
	return v ? (v < 0 ? -1 : 1) : 0;
}

void move(int dist, int add) {
	for (; dist > 0; --dist) {
		if (res[x][y] == -1) res[x][y] = c;
		x += dx;
		y += dy;
	}

	if (add) {
		int ndy = dx;
		dx = -dy;
		dy = ndy;
	}
	c = (c + add) % 3;
}

void spin(int w, int a, int b, int c) {
	move(b, 2);
	move(a, 1);
	move(1, 1);
	move(w-1, 2);
	move(1, 1);
	move(w-2-a, 1);
	move(c, 1);
}
bool build(int w, int h) {
	if (w == 4 && h == 4) return false;
	for (int x = 0; x < w; ++x) {
		for (int y = 0; y < h; ++y) res[x][y] = -1;
	}

	// Top side
	move(w-1, 1);

	// Right side
	if (w % 6 == 4 || w % 6 == 0) {
		move(2, 1);
		spin(h-2, 1, 2, 2);
		move(h-4, 1);
		move(2, 0);
		w -= 2;
	} else {
		move(h-1, 1);
	}

	// take width mod 6
	while(w > 6) {
		move(3, 1);
		move(2, 1);
		spin(h-4, 1, 2, 2);
		spin(6, 2, h-5, 3);
		spin(h-4, 1, 2, 2);
		move(h-6, 1);
		move(2, 0);
		w -= 6;
	}

	// w can't be 0 (mod 6), due to right side
	if (w % 6 == 4) {
		move(3, 1);
		move(2, 1);
		spin(h-2, 1, 2, 2);
		if (c == 0) ++c;
		move(h-4, 1);
	} else {
		move(1, 1);
		if (c == 0) ++c;
		move(h-1, 1);
	}
	return true;
}

int main() {
	int h, w;
	cin >> h >> w;	
	if (h >= w) {
		bool fail = ! build(w, h);
		if (fail) {
			cout << "IMPOSSIBLE\n";
		} else {
			for (int y = 0; y < h; ++y) {
				for (int x = 0; x < w; ++x) {
					cout << "RGB"[res[x][y]];
				}
				cout << '\n';
			}
		}
	} else {
		build(h, w);
		for (int y = 0; y < h; ++y) {
			for (int x = 0; x < w; ++x) {
				cout << "RGB"[res[h-1-y][x]];
			}
			cout << '\n';
		}
	}
}

Test details

Test 1

Group: 1

Verdict: ACCEPTED

input
2 2

correct output
RG
GR

user output
RG
GB

Test 2

Group: 1

Verdict: ACCEPTED

input
2 4

correct output
RRRG
GRRR

user output
GGGB
RGGG

Test 3

Group: 1

Verdict: ACCEPTED

input
2 6

correct output
RRRRRG
GRRRRR

user output
GGGGGB
RGGGGG

Test 4

Group: 1

Verdict: ACCEPTED

input
2 10

correct output
RRRRRRRRRG
GRRRRRRRRR

user output
GGGGGGGGGB
RGGGGGGGGG

Test 5

Group: 1

Verdict: ACCEPTED

input
2 50

correct output
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRR...

user output
GGGGGGGGGGGGGGGGGGGGGGGGGGGGGG...
Truncated

Test 6

Group: 1

Verdict: ACCEPTED

input
2 80

correct output
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRR...

user output
GGGGGGGGGGGGGGGGGGGGGGGGGGGGGG...
Truncated

Test 7

Group: 1

Verdict: ACCEPTED

input
2 98

correct output
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRR...

user output
GGGGGGGGGGGGGGGGGGGGGGGGGGGGGG...
Truncated

Test 8

Group: 1

Verdict: ACCEPTED

input
2 100

correct output
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRR...

user output
GGGGGGGGGGGGGGGGGGGGGGGGGGGGGG...
Truncated

Test 9

Group: 2

Verdict: ACCEPTED

input
2 2

correct output
RG
GR

user output
RG
GB

Test 10

Group: 2

Verdict: ACCEPTED

input
2 4

correct output
RRRG
GRRR

user output
GGGB
RGGG

Test 11

Group: 2

Verdict: ACCEPTED

input
2 6

correct output
RRRRRG
GRRRRR

user output
GGGGGB
RGGGGG

Test 12

Group: 2

Verdict: ACCEPTED

input
4 2

correct output
RG
GG
GG
GR

user output
RG
GG
GG
GB

Test 13

Group: 2

Verdict: ACCEPTED

input
4 4

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 14

Group: 2

Verdict: ACCEPTED

input
4 6

correct output
RRRRRG
GBGRGG
GGRBRG
GRRBRR

user output
GGBBBR
RRBRBR
RBGGRR
RGGGGG

Test 15

Group: 2

Verdict: ACCEPTED

input
6 2

correct output
RG
GG
GG
GG
GG
...

user output
RG
GG
GG
GG
GG
...

Test 16

Group: 2

Verdict: ACCEPTED

input
6 4

correct output
RRRG
RGBG
RRGG
BBGG
GRBG
...

user output
RRRG
GBRG
GGBB
GGRB
GRBB
...

Test 17

Group: 2

Verdict: ACCEPTED

input
6 6

correct output
RRRRRG
GBGRBG
GGGBBG
GGGBBG
GGRBRG
...

user output
RRRRRG
BBRBRG
BRGGBB
BBGGRB
GRBRBB
...

Test 18

Group: 3

Verdict: ACCEPTED

input
2 2

correct output
RG
GR

user output
RG
GB

Test 19

Group: 3

Verdict: ACCEPTED

input
2 4

correct output
RRRG
GRRR

user output
GGGB
RGGG

Test 20

Group: 3

Verdict: ACCEPTED

input
2 6

correct output
RRRRRG
GRRRRR

user output
GGGGGB
RGGGGG

Test 21

Group: 3

Verdict: ACCEPTED

input
4 2

correct output
RG
GG
GG
GR

user output
RG
GG
GG
GB

Test 22

Group: 3

Verdict: ACCEPTED

input
4 4

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 23

Group: 3

Verdict: ACCEPTED

input
4 6

correct output
RRRRRG
GBGRGG
GGRBRG
GRRBRR

user output
GGBBBR
RRBRBR
RBGGRR
RGGGGG

Test 24

Group: 3

Verdict: ACCEPTED

input
6 2

correct output
RG
GG
GG
GG
GG
...

user output
RG
GG
GG
GG
GG
...

Test 25

Group: 3

Verdict: ACCEPTED

input
6 4

correct output
RRRG
RGBG
RRGG
BBGG
GRBG
...

user output
RRRG
GBRG
GGBB
GGRB
GRBB
...

Test 26

Group: 3

Verdict: ACCEPTED

input
6 6

correct output
RRRRRG
GBGRBG
GGGBBG
GGGBBG
GGRBRG
...

user output
RRRRRG
BBRBRG
BRGGBB
BBGGRB
GRBRBB
...

Test 27

Group: 3

Verdict: ACCEPTED

input
2 100

correct output
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRR...

user output
GGGGGGGGGGGGGGGGGGGGGGGGGGGGGG...
Truncated

Test 28

Group: 3

Verdict: ACCEPTED

input
4 20

correct output
RRRRRRRRRRRRRRRRRRRG
GBBBBBBBBBBBBBBBGRGG
GGRRRRRRRRRRRRRRRBRG
GRRRRRRRRRRRRRRRRBRR

user output
GGBBBBBBBBBBBBBBBBBR
RRBRRRRRRRRRRRRRRRBR
RBGGRRRRRRRRRRRRRRRR
RGGGGGGGGGGGGGGGGGGG

Test 29

Group: 3

Verdict: ACCEPTED

input
4 100

correct output
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRR...

user output
GGBBBBBBBBBBBBBBBBBBBBBBBBBBBB...
Truncated

Test 30

Group: 3

Verdict: ACCEPTED

input
10 10

correct output
RRRRRRRRRG
GBGRBBGRBG
GGGBBGGBBG
GGGBBGGBBG
GGGBBGGBBG
...

user output
RRRRRRRRRG
GRRGGGBBRG
GBRRBRRGBB
GBRGBBRGRB
GGBBBRRRRB
...
Truncated

Test 31

Group: 3

Verdict: ACCEPTED

input
12 12

correct output
RRRRRRRRRRRG
RGBBGRBBGRBG
RRBGGBBGGBBG
RRBGGBBGGBBG
RRBGGBBGGBBG
...

user output
RRRRRRRRRRRG
BBRRRGGGBBRG
BRRBRRBRRGBB
BRRBRGBBRGRB
BRRGBBBRRRRB
...
Truncated

Test 32

Group: 3

Verdict: ACCEPTED

input
10 12

correct output
RRRRRRRRRRRG
RGBBGRBBGRBG
RRBGGBBGGBBG
RRBGGBBGGBBG
RRBGGBBGGBBG
...

user output
GGBBBBBBBBBR
RRBRRRRRRRBR
RBGGRRRRRRRR
RBRRRRRRGGBR
RGRBRRRRRBRR
...
Truncated

Test 33

Group: 3

Verdict: ACCEPTED

input
12 10

correct output
RRRRRRRRRG
GBGRBBGRBG
GGGBBGGBBG
GGGBBGGBBG
GGGBBGGBBG
...

user output
RRRRRRRRRG
GRRGGGBBRG
GBRRBRRGBB
GBRGBBRGRB
GGBBBRRRRB
...
Truncated

Test 34

Group: 3

Verdict: ACCEPTED

input
10 90

correct output
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRR...

user output
GGBBBBBBBBBBBBBBBBBBBBBBBBBBBB...
Truncated

Test 35

Group: 3

Verdict: ACCEPTED

input
90 10

correct output
RRRRRRRRRG
GBGRBBGRBG
GGGBBGGBBG
GGGBBGGBBG
GGGBBGGBBG
...

user output
RRRRRRRRRG
GRRGGGBBRG
GBRRBRRGBB
GBRGBBRGRB
GGBBBRRRRB
...
Truncated

Test 36

Group: 3

Verdict: ACCEPTED

input
100 100

correct output
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRR...

user output
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRR...
Truncated

Test 37

Group: 3

Verdict: ACCEPTED

input
98 100

correct output
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRR...

user output
GGGGGGGGGGGGGGGGGGGGGGGGGGGGGG...
Truncated

Test 38

Group: 3

Verdict: ACCEPTED

input
100 98

correct output
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRR...

user output
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRR...
Truncated

Test 39

Group: 3

Verdict: ACCEPTED

input
98 98

correct output
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRR...

user output
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRR...
Truncated