結果
| 問題 |
No.592 括弧の対応 (2)
|
| コンテスト | |
| ユーザー |
tsuchinaga
|
| 提出日時 | 2019-04-04 15:20:39 |
| 言語 | Go (1.23.4) |
| 結果 |
AC
|
| 実行時間 | 307 ms / 5,000 ms |
| コード長 | 670 bytes |
| コンパイル時間 | 15,788 ms |
| コンパイル使用メモリ | 225,060 KB |
| 実行使用メモリ | 7,808 KB |
| 最終ジャッジ日時 | 2024-12-25 23:13:24 |
| 合計ジャッジ時間 | 13,287 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 3 |
ソースコード
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)
}
}
tsuchinaga