結果
問題 |
No.592 括弧の対応 (2)
|
ユーザー |
![]() |
提出日時 | 2018-01-21 12:49:30 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 901 ms / 5,000 ms |
コード長 | 792 bytes |
コンパイル時間 | 3,429 ms |
コンパイル使用メモリ | 103,808 KB |
実行使用メモリ | 23,296 KB |
最終ジャッジ日時 | 2024-12-25 18:15:53 |
合計ジャッジ時間 | 4,352 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 3 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections.Generic; namespace y { class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); string s = Console.ReadLine(); int[] a = new int[n]; var li = new List<int>(); for (int i = 0; i < n; i++) { if (s[i] == '(') { li.Add(i); } else { a[li[li.Count - 1]] = i; a[i] = li[li.Count - 1]; li.RemoveAt(li.Count - 1); } } foreach (var ans in a) { Console.WriteLine(ans + 1); } } } }