結果
問題 | No.457 (^^*) |
ユーザー | uafr_cs |
提出日時 | 2017-11-02 19:25:25 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 340 ms / 2,000 ms |
コード長 | 1,133 bytes |
コンパイル時間 | 2,536 ms |
コンパイル使用メモリ | 79,376 KB |
実行使用メモリ | 42,400 KB |
最終ジャッジ日時 | 2024-05-02 03:31:55 |
合計ジャッジ時間 | 6,721 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 135 ms
42,120 KB |
testcase_01 | AC | 141 ms
42,124 KB |
testcase_02 | AC | 129 ms
42,288 KB |
testcase_03 | AC | 139 ms
42,140 KB |
testcase_04 | AC | 126 ms
41,516 KB |
testcase_05 | AC | 133 ms
41,836 KB |
testcase_06 | AC | 136 ms
42,012 KB |
testcase_07 | AC | 144 ms
42,096 KB |
testcase_08 | AC | 134 ms
42,100 KB |
testcase_09 | AC | 152 ms
42,244 KB |
testcase_10 | AC | 196 ms
42,324 KB |
testcase_11 | AC | 321 ms
42,152 KB |
testcase_12 | AC | 331 ms
42,156 KB |
testcase_13 | AC | 279 ms
42,132 KB |
testcase_14 | AC | 141 ms
42,396 KB |
testcase_15 | AC | 281 ms
42,308 KB |
testcase_16 | AC | 340 ms
42,368 KB |
testcase_17 | AC | 145 ms
42,400 KB |
testcase_18 | AC | 131 ms
42,128 KB |
testcase_19 | AC | 119 ms
41,968 KB |
ソースコード
import java.util.Arrays; import java.util.LinkedList; import java.util.Scanner; public class Main { public static long MOD = 1000000007; public static void main(String[] args) { Scanner sc = new Scanner(System.in); final char[] chs = sc.next().toCharArray(); int lefts = 0, rights = 0; for(int begin = 0; begin < chs.length; begin++){ if(chs[begin] != '('){ continue; } { boolean find_left_star = false; int hat_count = 0; for(int next = begin + 1; next < chs.length; next++){ if(chs[next] == '^'){ if(find_left_star){ hat_count++; } }else if(chs[next] == '*'){ find_left_star = true; }else if(chs[next] == ')' && hat_count >= 2){ rights++; } } } { int hat_count = 0; boolean find_right_star = false; for(int next = begin + 1; next < chs.length; next++){ if(chs[next] == '^'){ hat_count++; }else if(chs[next] == '*'){ if(hat_count >= 2){ find_right_star = true; } }else if(chs[next] == ')' && find_right_star){ lefts++; } } } } System.out.println(lefts + " " + rights); } }