We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7436ab1 commit ad4c82dCopy full SHA for ad4c82d
1 file changed
source/BOJ/Java/src/B1/Boj_15920_선로에마네킹이야.java
@@ -0,0 +1,44 @@
1
+package B1;
2
+
3
+import java.io.BufferedReader;
4
+import java.io.IOException;
5
+import java.io.InputStreamReader;
6
7
+public class Boj_15920_선로에마네킹이야 {
8
+ public static void main(String[] args) throws IOException {
9
+ BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
10
11
+ int N = Integer.parseInt(br.readLine());
12
+ String S = br.readLine();
13
14
+ int flag = 1;
15
+ int cnt = 0;
16
17
+ for (int i = 0; i < N; i++) {
18
+ if (S.charAt(i) == 'P') {
19
+ if (cnt == 1) {
20
+ flag = 0;
21
+ }
22
+ flag *= -1;
23
+ } else {
24
+ if (++cnt > 1) {
25
+ break;
26
27
28
29
30
+ int result = 0;
31
32
+ if (cnt == 2) {
33
+ if (flag > 0) {
34
+ result = 5;
35
+ } else if (flag < 0) {
36
+ result = 1;
37
38
+ result = 6;
39
40
41
42
+ System.out.print(result);
43
44
+}
0 commit comments