結果
問題 | No.592 括弧の対応 (2) |
ユーザー | tsuchinaga |
提出日時 | 2019-04-04 15:20:39 |
言語 | Go (1.21.3) |
結果 |
AC
|
実行時間 | 279 ms / 5,000 ms |
コード長 | 670 bytes |
コンパイル時間 | 15,727 ms |
コンパイル使用メモリ | 203,492 KB |
実行使用メモリ | 8,044 KB |
最終ジャッジ日時 | 2023-08-26 20:53:27 |
合計ジャッジ時間 | 17,161 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 279 ms
7,848 KB |
testcase_02 | AC | 278 ms
8,044 KB |
testcase_03 | AC | 270 ms
7,796 KB |
ソースコード
package main import ( "bufio" "fmt" "os" ) func main() { var n int _, _ = fmt.Scan(&n) rdr := bufio.NewReaderSize(os.Stdin, 1000000) buf := make([]byte, 0, 1000000) for { l, p, e := rdr.ReadLine() if e != nil { panic(e) } buf = append(buf, l...) if !p { break } } r := []rune(string(buf)) ans := make([]int, n) indexes := make([]int, 0) for i, c := range r { if c == '(' { indexes = append(indexes, i) } else { ans[indexes[len(indexes)-1]], ans[i] = i, indexes[len(indexes)-1] indexes = indexes[:len(indexes)-1] } // fmt.Println(indexes, ans) } // fmt.Print(ans) for _, a := range ans { fmt.Println(a + 1) } }