結果

問題 No.592 括弧の対応 (2)
ユーザー tsuchinagatsuchinaga
提出日時 2019-04-04 15:13:37
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 514 bytes
コンパイル時間 18,933 ms
コンパイル使用メモリ 209,736 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-26 20:52:20
合計ジャッジ時間 17,304 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,356 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	var n int
	_, _ = fmt.Scan(&n)

	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	r := []rune(sc.Text())
	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)
	}
}
0