結果
問題 | No.457 (^^*) |
ユーザー |
![]() |
提出日時 | 2018-02-21 20:08:32 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 373 ms / 2,000 ms |
コード長 | 842 bytes |
コンパイル時間 | 3,122 ms |
コンパイル使用メモリ | 78,988 KB |
実行使用メモリ | 42,664 KB |
最終ジャッジ日時 | 2024-09-19 07:48:36 |
合計ジャッジ時間 | 8,609 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
ソースコード
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);}}