結果
| 問題 | No.592 括弧の対応 (2) | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2017-11-13 02:14:11 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 239 ms / 5,000 ms | 
| コード長 | 286 bytes | 
| コンパイル時間 | 546 ms | 
| コンパイル使用メモリ | 72,788 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-11-24 23:25:41 | 
| 合計ジャッジ時間 | 1,781 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 3 | 
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main()
      | ^~~~
            
            ソースコード
#include<iostream>
#include<stack>
using namespace std;
string s;
int c[1<<18],n;
stack<int>P;
main()
{
	cin>>n>>s;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='(')
		{
			P.push(i);
		}
		else
		{
			int a=P.top();P.pop();
			c[a]=i+1,c[i]=a+1;
		}
	}
	for(int i=0;i<n;i++)cout<<c[i]<<endl;
}
            
            
            
        