結果

問題 No.3503 Brackets Stack Query 2
コンテスト
ユーザー Bokuneko
提出日時 2026-04-18 11:07:22
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 815 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,525 ms
コンパイル使用メモリ 336,468 KB
実行使用メモリ 7,976 KB
最終ジャッジ日時 2026-04-18 11:08:04
合計ジャッジ時間 30,160 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 6 WA * 24
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:9:11: warning: ignoring return value of 'constexpr bool std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::empty() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]', declared with attribute 'nodiscard' [-Wunused-result]
    9 |   S2.empty();
      |   ~~~~~~~~^~
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/string:56,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bitset:54,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/x86_64-pc-linux-gnu/bits/stdc++.h:54,
                 from main.cpp:1:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/basic_string.h:1331:7: note: declared here
 1331 |       empty() const _GLIBCXX_NOEXCEPT
      |       ^~~~~

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int Q;
  cin >> Q;
  string S = "aa";
  string S2;
  S2.empty();
  int type;
  char q;
  int l = 2;
  int k = 0;
  for(int i = 0; i < Q; i++){
    cin >> type;
    if(type == 1){
      k++;
      cin >> q;
      S.push_back(q);
      S2.push_back(q);
      if(S.at(l) == ')' && S.at(l-1) == '|' && S.at(l-2) == '('){
        S.erase(l-2,3);
        l -= 2;
      }
      else{
        l++;
      }
    }
    else{
      if(S.at(l-1) != ')' && S2.at(k-1) == ')'){
        S.push_back('(');
        S.push_back('|');
        l += 2;
      }
      else{
        S.erase(l-1,1);
        l--;
        S2.erase(k-1,1);
        k--;
      }
    }
    if(l == 2){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  return 0;
}
0