Task: | Robotti |
Sender: | antti röyskö |
Submission time: | 2019-01-17 12:49:14 +0200 |
Language: | C++ |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 12 |
#2 | ACCEPTED | 32 |
#3 | ACCEPTED | 56 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.04 s | 1 | details |
#2 | ACCEPTED | 0.01 s | 1 | details |
#3 | ACCEPTED | 0.03 s | 1 | details |
#4 | ACCEPTED | 0.02 s | 1 | details |
#5 | ACCEPTED | 0.01 s | 1 | details |
#6 | ACCEPTED | 0.02 s | 1 | details |
#7 | ACCEPTED | 0.02 s | 1 | details |
#8 | ACCEPTED | 0.02 s | 1 | details |
#9 | ACCEPTED | 0.01 s | 2 | details |
#10 | ACCEPTED | 0.01 s | 2 | details |
#11 | ACCEPTED | 0.01 s | 2 | details |
#12 | ACCEPTED | 0.03 s | 2 | details |
#13 | ACCEPTED | 0.02 s | 2 | details |
#14 | ACCEPTED | 0.01 s | 2 | details |
#15 | ACCEPTED | 0.01 s | 2 | details |
#16 | ACCEPTED | 0.02 s | 2 | details |
#17 | ACCEPTED | 0.01 s | 2 | details |
#18 | ACCEPTED | 0.02 s | 3 | details |
#19 | ACCEPTED | 0.01 s | 3 | details |
#20 | ACCEPTED | 0.01 s | 3 | details |
#21 | ACCEPTED | 0.01 s | 3 | details |
#22 | ACCEPTED | 0.02 s | 3 | details |
#23 | ACCEPTED | 0.02 s | 3 | details |
#24 | ACCEPTED | 0.02 s | 3 | details |
#25 | ACCEPTED | 0.02 s | 3 | details |
#26 | ACCEPTED | 0.01 s | 3 | details |
#27 | ACCEPTED | 0.01 s | 3 | details |
#28 | ACCEPTED | 0.02 s | 3 | details |
#29 | ACCEPTED | 0.02 s | 3 | details |
#30 | ACCEPTED | 0.02 s | 3 | details |
#31 | ACCEPTED | 0.02 s | 3 | details |
#32 | ACCEPTED | 0.01 s | 3 | details |
#33 | ACCEPTED | 0.02 s | 3 | details |
#34 | ACCEPTED | 0.03 s | 3 | details |
#35 | ACCEPTED | 0.02 s | 3 | details |
#36 | ACCEPTED | 0.03 s | 3 | details |
#37 | ACCEPTED | 0.03 s | 3 | details |
#38 | ACCEPTED | 0.03 s | 3 | details |
#39 | ACCEPTED | 0.02 s | 3 | details |
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 |