結果
| 問題 |
No.592 括弧の対応 (2)
|
| コンテスト | |
| ユーザー |
takeya_okino
|
| 提出日時 | 2017-11-11 20:16:31 |
| 言語 | Java (openjdk 23) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 554 bytes |
| コンパイル時間 | 1,922 ms |
| コンパイル使用メモリ | 75,084 KB |
| 実行使用メモリ | 59,488 KB |
| 最終ジャッジ日時 | 2024-11-24 19:27:47 |
| 合計ジャッジ時間 | 3,244 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 1 |
| other | RE * 3 |
ソースコード
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
String s = sc.next();
Stack<Integer> stack = new Stack<Integer>();
int[] cor = new int[n];
for(int i = 0; i < n; i++) {
char c = s.charAt(i);
if(c == '(') {
stack.push(i + 1);
} else {
int pos = stack.pop();
cor[pos] = i + 1;
cor[i + 1] = pos;
}
}
for(int i = 0; i < n; i++) {
System.out.println(cor[i]);
}
}
}
takeya_okino