結果

問題 No.457 (^^*)
ユーザー YamaKasaYamaKasa
提出日時 2018-09-22 17:12:54
言語 Java21
(openjdk 21)
結果
AC  
実行時間 332 ms / 2,000 ms
コード長 695 bytes
コンパイル時間 2,367 ms
コンパイル使用メモリ 74,252 KB
実行使用メモリ 57,048 KB
最終ジャッジ日時 2023-09-25 11:08:05
合計ジャッジ時間 7,371 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 145 ms
57,048 KB
testcase_01 AC 145 ms
56,984 KB
testcase_02 AC 145 ms
56,708 KB
testcase_03 AC 143 ms
56,896 KB
testcase_04 AC 146 ms
56,860 KB
testcase_05 AC 143 ms
56,924 KB
testcase_06 AC 146 ms
56,720 KB
testcase_07 AC 152 ms
56,736 KB
testcase_08 AC 162 ms
56,528 KB
testcase_09 AC 164 ms
56,792 KB
testcase_10 AC 188 ms
56,532 KB
testcase_11 AC 283 ms
56,648 KB
testcase_12 AC 330 ms
56,468 KB
testcase_13 AC 293 ms
56,600 KB
testcase_14 AC 167 ms
56,732 KB
testcase_15 AC 332 ms
56,804 KB
testcase_16 AC 286 ms
56,632 KB
testcase_17 AC 166 ms
56,456 KB
testcase_18 AC 148 ms
56,708 KB
testcase_19 AC 146 ms
56,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String S = scan.next();
		scan.close();
		int l = S.length();
		int R = 0;
		int L = 0;
		int t1 = 0;
		int t2 = 0;

		for(int i = 0; i < l; i++) {
			if(S.charAt(i) == '(') {
				t1 = 0;
				t2 = 0;
				for(int j = i + 1; j < l; j++) {
					if(S.charAt(j) == '*') {
						if(t1 == 0) t1++;
						if(t2 == 2) t2++;
					}else if(S.charAt(j) == '^') {
						if(t1 == 1 || t1 == 2) t1++;
						if(t2 == 0 || t2 == 1) t2++;
					}else if(S.charAt(j) == ')') {
						if(t1 == 3) L++;
						if(t2 == 3) R++;
					}
				}
			}
		}
		System.out.println(R +" " + L);
	}
}
0