結果

問題 No.457 (^^*)
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-12-08 03:39:17
言語 Java19
(openjdk 21)
結果
TLE  
実行時間 -
コード長 1,802 bytes
コンパイル時間 5,365 ms
コンパイル使用メモリ 75,236 KB
実行使用メモリ 57,956 KB
最終ジャッジ日時 2023-08-18 20:56:26
合計ジャッジ時間 11,150 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
57,408 KB
testcase_01 AC 132 ms
56,544 KB
testcase_02 AC 132 ms
56,916 KB
testcase_03 AC 128 ms
56,936 KB
testcase_04 AC 130 ms
56,812 KB
testcase_05 AC 131 ms
56,380 KB
testcase_06 AC 129 ms
56,632 KB
testcase_07 AC 137 ms
56,904 KB
testcase_08 AC 175 ms
57,956 KB
testcase_09 AC 201 ms
57,268 KB
testcase_10 AC 247 ms
57,260 KB
testcase_11 AC 409 ms
56,912 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int L=0;
        int R=0;
        int length=S.length();
        for(int i=0; i<length; i++){
            if(S.charAt(i)=='('){
                for(int j=i+4; j<length; j++){
                    if(S.charAt(j)==')'){
                        int cL=0;
                        int fL=0;
                        for(int k=i+1; k<j; k++){
                            if(S.charAt(k)=='^'){cL++;}
                            if(cL==2){
                                for(int m=k; m<j; m++){
                                    if(S.charAt(m)=='*'){
                                        L++;
                                        fL=1;
                                        break;
                                    }
                                }
                            }
                            if(fL==1){break;}
                        }
                        int cR=0;
                        int fR=0;
                        for(int k=j-1; k>=i+1; k--){
                            if(S.charAt(k)=='^'){cR++;}
                            if(cR==2){
                                for(int m=k; m>=i+1; m--){
                                    if(S.charAt(m)=='*'){
                                        R++;
                                        fR=1;
                                        break;
                                    }
                                }
                            }
                            if(fR==1){break;}
                        }                        
                    }
                }
            }
        }
        System.out.println(L+" "+R);
    }
}
0