Submission #924432
Source Code Expand
import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; import java.util.function.BiFunction; public class Main { Scanner sc = new Scanner(System.in); public static void main(String[] args) { new Main().run(); } int[][] ofs = { {-1, 0}, {1, 0}, {0, 1}, {0, -1} }; String list = "LRUD?"; void run() { String str = sc.next(); int u = 0; int x = 0; int y = 0; for (int i = 0; i < str.length(); ++i) { char c = str.charAt(i); int idx = list.indexOf(c); if (idx < 4) { x += ofs[idx][0]; y += ofs[idx][1]; } else { ++u; } } int T = ni(); int h = Math.abs(x) + Math.abs(y); if (T == 1) { System.out.println(h + u); } else { if (h >= u) { System.out.println(h - u); } else { System.out.println((u - h) % 2); } } } int ni() { return Integer.parseInt(sc.next()); } void debug(Object... os) { System.err.println(Arrays.deepToString(os)); } class BIT<T> { int n; ArrayList<T> bit; BiFunction<T, T, T> bif; BIT(int n, BiFunction<T, T, T> bif, T defaultValue) { this.n = n; bit = new ArrayList<>(n + 1); for (int i = 0; i < n + 1; ++i) { bit.add(defaultValue); } this.bif = bif; } void update(int i, T v) { for (int x = i; x <= n; x += x & -x) { bit.set(x, bif.apply(bit.get(x), v)); } } T reduce(int i, T defaultValue) { T ret = defaultValue; for (int x = i; x > 0; x -= x & -x) { ret = bif.apply(ret, bit.get(x)); } return ret; } } }
Submission Info
Submission Time | |
---|---|
Task | B - ドローン |
User | arukuka |
Language | Java8 (OpenJDK 1.8.0) |
Score | 101 |
Code Size | 1768 Byte |
Status | AC |
Exec Time | 196 ms |
Memory | 13736 KB |
Judge Result
Set Name | Sample | Subtask1 | All | ||||||
---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 100 / 100 | 1 / 1 | ||||||
Status |
|
|
|
Set Name | Test Cases |
---|---|
Sample | 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 00_example_04.txt |
Subtask1 | 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 10_rand_01.txt, 10_rand_02.txt, 10_rand_03.txt, 10_rand_04.txt, 20_no_question_01.txt, 20_no_question_02.txt, 20_no_question_03.txt, 20_no_question_04.txt, 30_max_01.txt, 30_max_02.txt, 30_max_03.txt, 30_max_04.txt, 40_corner_01.txt, 40_corner_02.txt, 40_corner_03.txt, 40_corner_04.txt |
All | 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 00_example_04.txt, 10_rand_01.txt, 10_rand_02.txt, 10_rand_03.txt, 10_rand_04.txt, 20_no_question_01.txt, 20_no_question_02.txt, 20_no_question_03.txt, 20_no_question_04.txt, 30_max_01.txt, 30_max_02.txt, 30_max_03.txt, 30_max_04.txt, 40_corner_01.txt, 40_corner_02.txt, 40_corner_03.txt, 40_corner_04.txt, 50_hand_01.txt, 50_hand_02.txt, 50_hand_03.txt, 60_rand_01.txt, 60_rand_02.txt, 60_rand_03.txt, 60_rand_04.txt, 70_no_ques_01.txt, 70_no_ques_02.txt, 70_no_ques_03.txt, 70_no_ques_04.txt, 80_max_01.txt, 80_max_02.txt, 80_max_03.txt, 80_max_04.txt, 90_corner_01.txt, 90_corner_02.txt, 90_corner_03.txt, 90_corner_04.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_example_01.txt | AC | 122 ms | 9552 KB |
00_example_02.txt | AC | 122 ms | 9676 KB |
00_example_03.txt | AC | 122 ms | 9552 KB |
00_example_04.txt | AC | 120 ms | 9552 KB |
10_rand_01.txt | AC | 152 ms | 10064 KB |
10_rand_02.txt | AC | 133 ms | 9556 KB |
10_rand_03.txt | AC | 138 ms | 9812 KB |
10_rand_04.txt | AC | 129 ms | 9812 KB |
20_no_question_01.txt | AC | 149 ms | 10196 KB |
20_no_question_02.txt | AC | 125 ms | 9548 KB |
20_no_question_03.txt | AC | 139 ms | 10116 KB |
20_no_question_04.txt | AC | 130 ms | 9924 KB |
30_max_01.txt | AC | 190 ms | 13016 KB |
30_max_02.txt | AC | 189 ms | 13720 KB |
30_max_03.txt | AC | 186 ms | 12680 KB |
30_max_04.txt | AC | 196 ms | 13604 KB |
40_corner_01.txt | AC | 190 ms | 12540 KB |
40_corner_02.txt | AC | 189 ms | 13004 KB |
40_corner_03.txt | AC | 191 ms | 13472 KB |
40_corner_04.txt | AC | 188 ms | 12636 KB |
50_hand_01.txt | AC | 121 ms | 9552 KB |
50_hand_02.txt | AC | 122 ms | 9552 KB |
50_hand_03.txt | AC | 122 ms | 9544 KB |
60_rand_01.txt | AC | 153 ms | 10064 KB |
60_rand_02.txt | AC | 123 ms | 9676 KB |
60_rand_03.txt | AC | 132 ms | 10192 KB |
60_rand_04.txt | AC | 130 ms | 9808 KB |
70_no_ques_01.txt | AC | 152 ms | 10064 KB |
70_no_ques_02.txt | AC | 125 ms | 9676 KB |
70_no_ques_03.txt | AC | 143 ms | 9804 KB |
70_no_ques_04.txt | AC | 141 ms | 9804 KB |
80_max_01.txt | AC | 194 ms | 13364 KB |
80_max_02.txt | AC | 184 ms | 12500 KB |
80_max_03.txt | AC | 177 ms | 12960 KB |
80_max_04.txt | AC | 181 ms | 12588 KB |
90_corner_01.txt | AC | 185 ms | 13736 KB |
90_corner_02.txt | AC | 183 ms | 12944 KB |
90_corner_03.txt | AC | 191 ms | 13580 KB |
90_corner_04.txt | AC | 183 ms | 12372 KB |