結果

問題 No.457 (^^*)
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-21 20:08:32
言語 Java21
(openjdk 21)
結果
AC  
実行時間 379 ms / 2,000 ms
コード長 842 bytes
コンパイル時間 2,577 ms
コンパイル使用メモリ 79,660 KB
実行使用メモリ 58,656 KB
最終ジャッジ日時 2023-10-19 11:41:48
合計ジャッジ時間 8,180 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 156 ms
58,348 KB
testcase_01 AC 162 ms
58,408 KB
testcase_02 AC 159 ms
58,272 KB
testcase_03 AC 159 ms
58,376 KB
testcase_04 AC 158 ms
58,148 KB
testcase_05 AC 157 ms
58,588 KB
testcase_06 AC 157 ms
58,344 KB
testcase_07 AC 165 ms
58,148 KB
testcase_08 AC 187 ms
58,592 KB
testcase_09 AC 184 ms
58,640 KB
testcase_10 AC 215 ms
58,656 KB
testcase_11 AC 305 ms
58,652 KB
testcase_12 AC 379 ms
58,632 KB
testcase_13 AC 374 ms
58,548 KB
testcase_14 AC 178 ms
58,372 KB
testcase_15 AC 367 ms
58,620 KB
testcase_16 AC 366 ms
58,608 KB
testcase_17 AC 176 ms
58,392 KB
testcase_18 AC 160 ms
58,312 KB
testcase_19 AC 159 ms
58,360 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		String s = sc.next();
		
		int L = 0;
		int R = 0;
		StringBuilder l = new StringBuilder();
		StringBuilder r = new StringBuilder();
		for (int i=0; i<s.length(); i++) {
			if (s.charAt(i)=='(') {
				for (int j=i+1; j<s.length(); j++) {
					char c = s.charAt(j);
					if (c=='*') {
						if (r.length()==0) {r.append("*");}
						if (l.length()==2) {l.append("*");}
					}
					else if (c=='^') {
						if (r.length()==1 || r.length()==2) {r.append("^");}
						if (l.length()==0 || l.length()==1) {l.append("^");}
					}
					else if (c==')') {
						if (r.length()==3) {R++;}
						if (l.length()==3) {L++;}
					}
				}
				r.setLength(0);
				l.setLength(0);
			}
		}
		
		System.out.println(L+" "+R);
	}
}
0