結果
問題 | No.592 括弧の対応 (2) |
ユーザー |
|
提出日時 | 2024-11-12 17:59:47 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 16 ms / 5,000 ms |
コード長 | 496 bytes |
コンパイル時間 | 860 ms |
コンパイル使用メモリ | 78,748 KB |
最終ジャッジ日時 | 2025-02-25 04:00:44 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 3 |
ソースコード
#include <iostream>#include <cstdint>#include <vector>#include <stack>using namespace std;int main(){cin.tie(nullptr);ios::sync_with_stdio(false);uint32_t N, i;cin >> N;string S;S.reserve(N), cin >> S;vector<uint32_t> C(N);stack<uint32_t> s;for (i = 0; i != N; ++i)switch (S[i]){case '(':s.push(i);break;case ')':C[s.top()] = i + 1, C[i] = s.top() + 1;s.pop();break;}for (i = 0; i != N; ++i)cout << C[i] << '\n';return 0;}