結果

問題 No.457 (^^*)
ユーザー fal_rndfal_rnd
提出日時 2016-12-09 17:38:18
言語 Java19
(openjdk 21)
結果
AC  
実行時間 544 ms / 2,000 ms
コード長 1,338 bytes
コンパイル時間 2,010 ms
コンパイル使用メモリ 80,888 KB
実行使用メモリ 59,712 KB
最終ジャッジ日時 2023-08-19 03:17:31
合計ジャッジ時間 7,173 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 104 ms
55,436 KB
testcase_01 AC 104 ms
55,896 KB
testcase_02 AC 106 ms
55,656 KB
testcase_03 AC 108 ms
55,808 KB
testcase_04 AC 103 ms
55,720 KB
testcase_05 AC 103 ms
55,748 KB
testcase_06 AC 109 ms
55,688 KB
testcase_07 AC 116 ms
56,020 KB
testcase_08 AC 146 ms
56,764 KB
testcase_09 AC 164 ms
56,852 KB
testcase_10 AC 242 ms
57,512 KB
testcase_11 AC 233 ms
56,664 KB
testcase_12 AC 492 ms
57,672 KB
testcase_13 AC 511 ms
57,048 KB
testcase_14 AC 126 ms
56,044 KB
testcase_15 AC 472 ms
57,588 KB
testcase_16 AC 544 ms
59,712 KB
testcase_17 AC 127 ms
56,204 KB
testcase_18 AC 108 ms
55,672 KB
testcase_19 AC 107 ms
55,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package src;

import java.util.*;
class C{
	static Scanner s = new Scanner(System.in);
	static int resL=0,resR=0,availableEdgeL=0,availableEdgeR=0;

	public static void main(String[] args) {
		char[] in = s.next().toCharArray();

		ArrayList<Checker> L=new ArrayList<>(),R=new ArrayList<>();

		for(int i=0;i<in.length;i++) {
			char c=in[i];

			if(c=='(') {
				L.add(new Checker());
				R.add(new Checker());
			}


			ListIterator<Checker> it = L.listIterator();
			while(it.hasNext()) {
				checkL(it.next(), c);
			}
			it = R.listIterator();
			while(it.hasNext()) {
				checkR(it.next(), c);
			}
//			System.out.printf("%d %d\n",resL,resR);
		}
		System.out.printf("%d %d\n",resL,resR);
	}

	static void checkR(Checker checker,char c){
		switch(checker.flag) {
		case 0:
			if(c=='(')
				checker.flag++;
			break;
		case 1:
			if(c=='*')
				checker.flag++;
			break;
		case 2:
		case 3:
			if(c=='^')
				checker.flag++;
			break;
		case 4:
			if(c==')')
				resR++;
			break;
		}
	}
	static void checkL(Checker checker,char c){
		switch(checker.flag) {
		case 0:
			if(c=='(')
				checker.flag++;
			break;
		case 1:
		case 2:
			if(c=='^')
				checker.flag++;
			break;
		case 3:
			if(c=='*')
				checker.flag++;
			break;
		case 4:
			if(c==')')
				resL++;
			break;
		}
	}
}

class Checker{
	int flag=0;
	Checker() {
	}
}
0