結果

問題 No.592 括弧の対応 (2)
ユーザー NoNo
提出日時 2018-01-21 12:49:30
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 825 ms / 5,000 ms
コード長 792 bytes
コンパイル時間 2,932 ms
コンパイル使用メモリ 104,840 KB
実行使用メモリ 28,972 KB
最終ジャッジ日時 2023-08-26 18:17:24
合計ジャッジ時間 5,562 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
20,648 KB
testcase_01 AC 825 ms
28,412 KB
testcase_02 AC 825 ms
28,972 KB
testcase_03 AC 814 ms
23,952 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

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);
            }
        }
    }
}
0