Submission #42232
ソースコード
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 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayDeque; import java.util.Arrays; import java.util.NoSuchElementException; import java.util.Queue; public class Main { private static final InputStream in = System.in; private static final PrintWriter out = new PrintWriter(System.out); private static int dx[] = {1, 0, -1, 0, 1, 1, -1, -1}; private static int dy[] = {0, 1, 0, -1, 1, -1, 1, -1}; private static int INF = 1 << 29; private static int colour; public static void main(String[] args) { // This is from IntelliJ IDEA if ( System.getProperty( "os.name" ).contains( "indows" ) ) { System.err.println( "Operating System not found" ); System. exit (1); } colour = Integer.parseInt(fgetStr(), 16); String command = fgetStr(); while ( ! "quit" .equals(command) ) { if ( "disp" .equals(command) ) { out. printf ( "%06X\n" , colour); } else if ( "update" .equals(command) ) { update(fgetInt(), fgetInt(), fgetInt()); } else if ( "shift" .equals(command) ) { shift(fgetInt()); } else { reverse(); } command = fgetStr(); } ifin(); } private static void update( int r, int g, int b) { if ( r != -1 ) { colour &= 0x00ffff; colour += ( r << 16 ); } if ( g != -1 ) { colour &= 0xff00ff; colour += ( g << 8 ); } if ( b != -1 ) { colour &= 0xffff00; colour += b; } } private static void shift ( int n ) { if ( n > 0 ) { colour = colour >> n; } else { colour = colour << -n; } colour &= 0xffffff; } private static void reverse () { colour ^= 0xffffff; } private static long pow ( long x, long n ) { long ans = 1; while ( n > 0 ) { if ( ( n & 1 ) == 1 ) { ans = (ans * x); } x = ( x * x ); n >>= 1; } return ans; } private static long gcd( long x, long y) { return x % y == 0 ? y : gcd(y, x % y); } private static long lcm( long x, long y) { return ( x / gcd(x, y) * y); } private static boolean isMovable( int x, int y, int w, int h ) { return ( x >= 0 && y >= 0 && x < w && y < h ); } private static int getIndex( int w, int x, int y ) { return (w*y) + x; } private static String fgetStr(){ return next(); } private static String fgetLine(){ return nextLine(); } private static char fgetChar(){ return fgetStr().charAt(0); } private static int fgetInt(){ return nextInt(); } private static long fgetLong(){ return nextLong(); } private static double fgetDouble(){ return nextDouble(); } private static BigInteger fgetBig(){ return new BigInteger(fgetStr()); } private static String reverseStr(String str){ StringBuffer sb = new StringBuffer(str); return sb.reverse().toString(); } private static void iprint(Object a){ out.println(a); } private static void iprintf(Object a){ out.print(a); } private static void ifin(){ out.flush(); } private static final byte[] buffer = new byte[1024]; private static int ptr = 0; private static int buflen = 0; private static boolean hasNextByte() { if (ptr < buflen) { return true ; } else { ptr = 0; try { buflen = in.read(buffer); } catch ( IOException e) { e.printStackTrace(); } if (buflen <= 0) { return false ; } } return true ; } private static int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1; } private static boolean isPrintableChar( int c) { return 33 <= c && c <= 126; } private static boolean hasNext() { while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte(); } private static String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while (isPrintableChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } private static String nextLine() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while (isPrintableChar(b) || b == 32) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } private static long nextLong() { if (!hasNext()) throw new NoSuchElementException(); long n = 0; boolean minus = false ; int b = readByte(); if (b == '-' ) { minus = true ; b = readByte(); } if (b < '0' || '9' < b) { throw new NumberFormatException(); } while ( true ){ if ( '0' <= b && b <= '9' ) { n *= 10; n += b - '0' ; } else if (b == -1 || !isPrintableChar(b)){ return minus ? -n : n; } else { throw new NumberFormatException(); } b = readByte(); } } private static int nextInt() { long nl = nextLong(); if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException(); return ( int ) nl; } private static double nextDouble() { return Double.parseDouble(next()); } } class Pair { int first, second; public Pair( int a, int b) { this .first = a; this .second = b; } } class UnionFind { private int [] parent; private int [] sizes; public UnionFind( int n) { parent = new int [n+5]; sizes = new int [n+5]; for ( int i = 0; i < n; i++) { parent[i] = i; sizes[i] = 1; } } public void unite( int x, int y) { int rootX = getRoot(x); int rootY = getRoot(y); if ( !isUnited(rootX, rootY) ) { sizes[rootY] += sizes[rootX]; parent[rootX] = rootY; } } public int getRoot( int i) { if (i != parent[i]) { parent[i] = getRoot(parent[i]); } return parent[i]; } public int getSize( int n) { return sizes[getRoot(n)]; } public boolean isUnited( int x, int y) { return getRoot(x) == getRoot(y); } } class SegmentTree { private int size; private long [] data = new long [1<<21]; SegmentTree( int n, int init) { for ( size = 1; size < n; size *= 2); Arrays.fill(data, init); } void update ( int k, int a ) { k += size-1; data[k] = a; while ( k > 0 ) { k = (k-1) / 2; data[k] = Math.min(data[k*2+1], data[k*2+2]); } } long getMin ( int a, int b, int k, int l, int r ) { if ( r <= a || b <= l ) return 1<<29; if ( a <= l && r <= b ) return data[k]; return Math.min(getMin( a, b, k*2+1, l, (l+r)/2), getMin( a, b, k*2+2, (l+r)/2, r)); } long getMin ( int a, int b ) { return this .getMin( a, b, 0, 0, size ); } } class BinaryIndexedTree { private long [] bit = new long [1<<21]; private long size; BinaryIndexedTree( int n){ size = n; } long getSum( int i) { int s = 0; while ( i > 0 ) { s += bit[i]; i -= (i & -i); } return s; } void add( int i, int x){ while ( i <= size ) { bit[i] += x; i += (i & -i); } } } |
ステータス
項目 | データ |
---|---|
問題 | 0900 - あーるじーびー操作 |
ユーザー名 | r1825 |
投稿日時 | 2018-08-29 17:31:42 |
言語 | Java |
状態 | Accepted |
得点 | 3 |
ソースコード長 | 8557 Byte |
最大実行時間 | 212 ms |
最大メモリ使用量 | 29120 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 3 / 3 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
input01 | AC | 212 ms | 18664 KB |
1
|
input02 | AC | 165 ms | 19336 KB |
1
|
input03 | AC | 205 ms | 20208 KB |
1
|
input04 | AC | 160 ms | 20332 KB |
1
|
input05 | AC | 187 ms | 21108 KB |
1
|
input06 | AC | 161 ms | 21548 KB |
1
|
input07 | AC | 185 ms | 22324 KB |
1
|
input08 | AC | 176 ms | 22756 KB |
1
|
input09 | AC | 209 ms | 23916 KB |
1
|
input10 | AC | 209 ms | 27296 KB |
1
|
input11 | AC | 203 ms | 26488 KB |
1
|
input12 | AC | 112 ms | 20644 KB |
1
|
input13 | AC | 167 ms | 26640 KB |
1
|
input14 | AC | 163 ms | 27156 KB |
1
|
input15 | AC | 189 ms | 27976 KB |
1
|
input16 | AC | 188 ms | 29120 KB |
1
|
input_sample1 | AC | 109 ms | 25308 KB |
1
|
input_sample2 | AC | 109 ms | 25080 KB |
1
|
input_sample3 | AC | 123 ms | 25216 KB |
1
|
input_sample4 | AC | 120 ms | 25168 KB |
1
|