Submission #32435


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <iostream>
#include <string>
using namespace std;
class Color
{
private:
unsigned int rgb_bit;
public:
Color() = default;
Color(int r, int g, int b)
{
rgb_bit = r << 16;
rgb_bit |= g << 8;
rgb_bit |= b;
}
void disp()
{
unsigned char r, g, b;
r = (rgb_bit >> 16) & 0xff;
g = (rgb_bit >> 8) & 0xff;
b = rgb_bit & 0xff;
printf("%02X%02X%02X\n", r, g, b);
}
void update(int r, int g, int b)
{
if (r != -1) {
rgb_bit &= 0x00ffff;
rgb_bit |= r << 16;
}
if (g != -1) {
rgb_bit &= 0xff00ff;
rgb_bit |= g << 8;
}
if (b != -1) {
rgb_bit &= 0xffff00;
rgb_bit |= b;
}
}
void shift(int n)
{
if (n >= 0) {
rgb_bit >>= n;
} else {
rgb_bit <<= -n;
}
rgb_bit &= 0xffffff;
}
void reverse()
{
rgb_bit = ~rgb_bit;
rgb_bit &= 0xffffff;
}
};
int main()
{
int r, g, b;
string command;
Color color;
scanf("%2X%2X%2X", &r, &g, &b);
color = Color(r, g, b);
while (cin >> command, command != "quit") {
if (command == "update") {
cin >> r >> g >> b;
color.update(r, g, b);
} else if (command == "disp") {
color.disp();
} else if (command == "shift") {
int n;
cin >> n;
color.shift(n);
} else if (command == "reverse") {
color.reverse();
}
}
return 0;
}

ステータス

項目 データ
問題 0900 - あーるじーびー操作
ユーザー名 ei1503
投稿日時 2018-03-30 14:44:11
言語 C++11
状態 Accepted
得点 3
ソースコード長 1356 Byte
最大実行時間 114 ms
最大メモリ使用量 3600 KB

セット

セット 得点 Cases
1 ALL 3 / 3 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
input01 AC 68 ms 608 KB
1
input02 AC 56 ms 716 KB
1
input03 AC 83 ms 1076 KB
1
input04 AC 37 ms 1184 KB
1
input05 AC 89 ms 1292 KB
1
input06 AC 43 ms 1400 KB
1
input07 AC 89 ms 1636 KB
1
input08 AC 70 ms 1864 KB
1
input09 AC 108 ms 2096 KB
1
input10 AC 110 ms 2460 KB
1
input11 AC 114 ms 2820 KB
1
input12 AC 20 ms 2924 KB
1
input13 AC 38 ms 2904 KB
1
input14 AC 42 ms 3140 KB
1
input15 AC 97 ms 3368 KB
1
input16 AC 92 ms 3600 KB
1
input_sample1 AC 27 ms 3576 KB
1
input_sample2 AC 16 ms 3552 KB
1
input_sample3 AC 19 ms 3532 KB
1
input_sample4 AC 18 ms 3508 KB
1