結果
問題 | No.592 括弧の対応 (2) |
ユーザー |
|
提出日時 | 2017-11-27 19:23:30 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 22 ms / 5,000 ms |
コード長 | 414 bytes |
コンパイル時間 | 320 ms |
コンパイル使用メモリ | 22,528 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-27 11:22:04 |
合計ジャッジ時間 | 771 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 3 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:9:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | scanf("%d",&n); | ~~~~~^~~~~~~~~ main.cpp:10:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | scanf("%s",s); | ~~~~~^~~~~~~~
ソースコード
#include<cstdio>char s[300000];int prevd[300000];int map[300000];int main(void) {int n;scanf("%d",&n);scanf("%s",s);int d=0;for(int i=0; i<n; i++)if(s[i]=='(') {prevd[d] = i;d++;} else {d--;map[i] = prevd[d];map[prevd[d]] = i;}for(int i=0; i<n; i++)printf("%d\n", map[i]+1);}