結果
問題 | No.457 (^^*) |
ユーザー | uafr_cs |
提出日時 | 2017-11-02 19:25:25 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 356 ms / 2,000 ms |
コード長 | 1,133 bytes |
コンパイル時間 | 2,484 ms |
コンパイル使用メモリ | 76,336 KB |
実行使用メモリ | 41,252 KB |
最終ジャッジ日時 | 2023-08-14 15:27:38 |
合計ジャッジ時間 | 7,646 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 137 ms
41,024 KB |
testcase_01 | AC | 134 ms
40,528 KB |
testcase_02 | AC | 136 ms
40,472 KB |
testcase_03 | AC | 134 ms
40,500 KB |
testcase_04 | AC | 131 ms
40,888 KB |
testcase_05 | AC | 133 ms
40,296 KB |
testcase_06 | AC | 131 ms
40,572 KB |
testcase_07 | AC | 137 ms
40,688 KB |
testcase_08 | AC | 152 ms
40,660 KB |
testcase_09 | AC | 155 ms
40,464 KB |
testcase_10 | AC | 202 ms
40,524 KB |
testcase_11 | AC | 333 ms
40,756 KB |
testcase_12 | AC | 316 ms
41,200 KB |
testcase_13 | AC | 356 ms
40,720 KB |
testcase_14 | AC | 152 ms
41,056 KB |
testcase_15 | AC | 330 ms
41,240 KB |
testcase_16 | AC | 346 ms
41,252 KB |
testcase_17 | AC | 161 ms
40,488 KB |
testcase_18 | AC | 139 ms
40,252 KB |
testcase_19 | AC | 149 ms
40,972 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); } }