結果

問題 No.3823 Make 1
コンテスト
ユーザー テナガザル
提出日時 2026-11-22 13:54:29
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 528 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,038 ms
コンパイル使用メモリ 172,508 KB
実行使用メモリ 9,924 KB
最終ジャッジ日時 2026-11-22 13:54:32
合計ジャッジ時間 2,904 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 6 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

void solve()
{
  int n;
  string s;
  cin >> n >> s;
  int now = 1, f = 1;
  while (now < n)
  {
    now <<= 1;
    f ^= 1;
  }
  now <<= 1;
  f ^= 1;
  int cnt[2] = {0, 0};
  for (auto c : s) ++cnt[c - '0'];
  int check = 0;
  for (int i = 0; i < n - 1; ++i) if (s[i] == s[i + 1]) check = 1;
  now -= cnt[f] + 2 * cnt[1 ^ f];
  cout << (now % 3 == 0 && check ? "Yes" : "No") << endl;
}

int main()
{
  int t;
  cin >> t;
  while (t--) solve();
}
0