Submission #3446127
Source Code Expand
import java.io.*; import java.util.*; class Main { static FastScanner sc = new FastScanner(); static PrintWriter out = new PrintWriter(System.out); public void solve() { int N = sc.nextInt(); int Q = sc.nextInt(); int[] arr = new int[N]; for (int i = 0; i < Q; i++) { int l = sc.nextInt()-1; int r = sc.nextInt(); arr[l]++; if (r < arr.length) { arr[r]--; } } int sum = 0; for (int i=0; i<N; i++) { sum += arr[i]; arr[i] = sum; } for (int i = 0; i < N; i++) { if (arr[i] % 2 == 0) { out.print("0"); } else { out.print("1"); } } out.println(); } public static void main(String[] args) { new Main().solve(); out.flush(); } } class FastScanner { private final InputStream in = System.in; private final byte[] buffer = new byte[1024]; private int ptr = 0; private int buflen = 0; private 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 int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1; } private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126; } public boolean hasNext() { while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte(); } public 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(); } public 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(); } } public int nextInt() { long nl = nextLong(); if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException(); return (int) nl; } public double nextDouble() { return Double.parseDouble(next()); } }
Submission Info
Submission Time | |
---|---|
Task | C - オセロ |
User | r_k |
Language | Java8 (OpenJDK 1.8.0) |
Score | 100 |
Code Size | 2560 Byte |
Status | AC |
Exec Time | 166 ms |
Memory | 25916 KB |
Judge Result
Set Name | Sample | Subtask1 | All | ||||||
---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 60 / 60 | 40 / 40 | ||||||
Status |
|
|
|
Set Name | Test Cases |
---|---|
Sample | 00_example_01.txt, 00_example_02.txt |
Subtask1 | 00_example_01.txt, 00_example_02.txt, 10_small_01.txt, 10_small_02.txt, 10_small_03.txt, 10_small_04.txt, 10_small_05.txt, 10_small_06.txt, 10_small_07.txt, 10_small_08.txt, 10_small_09.txt, 10_small_10.txt |
All | 00_example_01.txt, 00_example_02.txt, 10_small_01.txt, 10_small_02.txt, 10_small_03.txt, 10_small_04.txt, 10_small_05.txt, 10_small_06.txt, 10_small_07.txt, 10_small_08.txt, 10_small_09.txt, 10_small_10.txt, 20_rand_01.txt, 20_rand_02.txt, 20_rand_03.txt, 20_rand_04.txt, 20_rand_05.txt, 20_rand_06.txt, 20_rand_07.txt, 20_rand_08.txt, 20_rand_09.txt, 20_rand_10.txt, 30_max_01.txt, 30_max_02.txt, 30_max_03.txt, 30_max_04.txt, 30_max_05.txt, 40_corner_01.txt, 40_corner_02.txt, 40_corner_03.txt, 40_corner_04.txt, 40_corner_05.txt, 40_corner_06.txt, 40_corner_07.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_example_01.txt | AC | 67 ms | 19412 KB |
00_example_02.txt | AC | 67 ms | 19412 KB |
10_small_01.txt | AC | 81 ms | 19668 KB |
10_small_02.txt | AC | 70 ms | 19156 KB |
10_small_03.txt | AC | 82 ms | 20564 KB |
10_small_04.txt | AC | 70 ms | 18260 KB |
10_small_05.txt | AC | 68 ms | 19412 KB |
10_small_06.txt | AC | 72 ms | 20948 KB |
10_small_07.txt | AC | 70 ms | 18260 KB |
10_small_08.txt | AC | 69 ms | 19412 KB |
10_small_09.txt | AC | 71 ms | 21204 KB |
10_small_10.txt | AC | 68 ms | 21204 KB |
20_rand_01.txt | AC | 123 ms | 20536 KB |
20_rand_02.txt | AC | 100 ms | 21584 KB |
20_rand_03.txt | AC | 108 ms | 19920 KB |
20_rand_04.txt | AC | 115 ms | 20072 KB |
20_rand_05.txt | AC | 98 ms | 18872 KB |
20_rand_06.txt | AC | 118 ms | 21208 KB |
20_rand_07.txt | AC | 118 ms | 22200 KB |
20_rand_08.txt | AC | 93 ms | 19668 KB |
20_rand_09.txt | AC | 93 ms | 21128 KB |
20_rand_10.txt | AC | 100 ms | 22200 KB |
30_max_01.txt | AC | 159 ms | 19768 KB |
30_max_02.txt | AC | 159 ms | 21604 KB |
30_max_03.txt | AC | 160 ms | 23924 KB |
30_max_04.txt | AC | 158 ms | 21824 KB |
30_max_05.txt | AC | 157 ms | 23816 KB |
40_corner_01.txt | AC | 101 ms | 22032 KB |
40_corner_02.txt | AC | 152 ms | 23700 KB |
40_corner_03.txt | AC | 148 ms | 24004 KB |
40_corner_04.txt | AC | 166 ms | 25916 KB |
40_corner_05.txt | AC | 152 ms | 21204 KB |
40_corner_06.txt | AC | 115 ms | 22048 KB |
40_corner_07.txt | AC | 150 ms | 25272 KB |