Submission #32373


ソースコード

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
91
92
93
94
95
96
97
98
99
100
import java.io.*;
import java.util.*;
import static java.lang.Math.*;
import static java.lang.Integer.parseInt;
class Main {
private final static Scanner in = new Scanner(System.in);
private final static PrintWriter out = new PrintWriter(System.out);
private void solve() {
Color color = new Color(in.nextLine());
for(;;)
{
String com = in.next();
if (com.charAt(0) == 'q')
break;
switch(com.charAt(0))
{
case 'u':
color.update(getint(), getint(), getint());
break;
case 'd':
color.disp(out);
break;
case 'r':
color.reverse();
break;
case 's':
color.shift(getint());
break;
}
}
}
private int getint() { return parseInt(in.next()); }
public static void main(String[] args) {
new Main().solve();
out.close();
}
//====================================================================
static class Color
{
private int color;
private static final int MASK = 0xFF;
public Color(final String str)
{
this.color = parseInt(str, 16);
}
public void update(int R, int G, int B)
{
int newR = (R == -1) ? this.getR() : R;
int newG = (G == -1) ? this.getG() : G;
int newB = (B == -1) ? this.getB() : B;
this.color = makeRGB(newR, newG, newB);
}
public void reverse()
{
this.color = makeRGB(
255 - getR(),
255 - getG(),
255 - getB() );
}
public void shift(int N)
{
if (N < 0) {
this.color <<= -N;
this.color &= 0xFfFfFf;
} else {
this.color >>>= N;
}
}
public void disp(PrintWriter out)
{
out.printf("%06X\n", this.color);
}
private int getR() { return( (this.color >> 16) & MASK ); }
private int getG() { return( (this.color >> 8) & MASK ); }
private int getB() { return( this.color & MASK ); }
private static int makeRGB(int r, int g, int b)
{
return (r<<16 | g<<8 | b);
}
}
}

ステータス

項目 データ
問題 0900 - あーるじーびー操作
ユーザー名 Arumakan_ei1727
投稿日時 2018-03-23 16:51:51
言語 Java
状態 Accepted
得点 3
ソースコード長 2611 Byte
最大実行時間 264 ms
最大メモリ使用量 38700 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
input01 AC 191 ms 38700 KB
1
input02 AC 161 ms 36320 KB
1
input03 AC 207 ms 33864 KB
1
input04 AC 143 ms 29880 KB
1
input05 AC 225 ms 38012 KB
1
input06 AC 148 ms 37504 KB
1
input07 AC 197 ms 34424 KB
1
input08 AC 173 ms 35932 KB
1
input09 AC 255 ms 37972 KB
1
input10 AC 256 ms 37032 KB
1
input11 AC 264 ms 35724 KB
1
input12 AC 77 ms 15856 KB
1
input13 AC 128 ms 32852 KB
1
input14 AC 140 ms 37172 KB
1
input15 AC 247 ms 37116 KB
1
input16 AC 237 ms 37168 KB
1
input_sample1 AC 77 ms 19532 KB
1
input_sample2 AC 75 ms 17340 KB
1
input_sample3 AC 77 ms 17664 KB
1
input_sample4 AC 72 ms 16800 KB
1