結果
問題 | No.22 括弧の対応 |
ユーザー |
![]() |
提出日時 | 2025-03-05 11:27:57 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 399 bytes |
コンパイル時間 | 665 ms |
コンパイル使用メモリ | 27,392 KB |
実行使用メモリ | 8,612 KB |
最終ジャッジ日時 | 2025-03-05 11:27:59 |
合計ジャッジ時間 | 1,240 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 19 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:5:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 5 | scanf("%d %d",&len,&val); | ~~~~~^~~~~~~~~~~~~~~~~~~ main.cpp:10:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | scanf("%c",&p[i]); | ~~~~~^~~~~~~~~~~~
ソースコード
#include <stdio.h> int main(){ int len, val; scanf("%d %d",&len,&val); char str[len]; char *p = str; for(int i = 0;i < len;i++){ scanf("%c",&p[i]); } int count = 1; for(int i = val;i < len;i++){ if(p[i] == '('){ count++; }else{ count--; } //printf("int:%d count:%d str:%c\n",i,count,p[i]); if(count == 0 && p[i] == ')'){ printf("%d",i + 1); break; } } }