結果

問題 No.2080 Simple Nim Query
ユーザー ripityripity
提出日時 2022-10-30 10:20:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 920 bytes
コンパイル時間 2,318 ms
コンパイル使用メモリ 202,144 KB
実行使用メモリ 4,928 KB
最終ジャッジ日時 2023-09-21 09:47:45
合計ジャッジ時間 8,162 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 WA -
testcase_04 AC 304 ms
4,380 KB
testcase_05 AC 489 ms
4,664 KB
testcase_06 AC 453 ms
4,668 KB
testcase_07 AC 449 ms
4,556 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 437 ms
4,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/fenwicktree>
using namespace std;
using namespace atcoder;
int main() {
  int N, Q;
  cin >> N >> Q;
  vector<int> A(N);
  fenwick_tree<int> fw(N);
  for( int i = 0; i < N; i++ ) {
    cin >> A[i];
    A[i] = ( A[i] == 1 );
    fw.add(i, A[i]);
  }
  for( int q = 0; q < Q; q++ ) {
    int T, X, Y;
    cin >> T >> X >> Y;
    if( T == 1 ) {
      X--;
      Y = ( Y == 1 );
      if( A[X] == 0 && Y == 1 ) fw.add(X, 1);
      else if( A[X] == 1 && Y == 0 ) fw.add(X, -1);
    }else {
      X--;
      Y--;
      int l = X, r = Y+1, m;
      while( l < r ) {
        m = (l+r)>>1;
        if( fw.sum(m, Y+1) != Y+1-m ) l = m+1;
        else r = m;
      }
      int k = Y+1-l;
      if( l == X ) {
        if( k&1 ) cout << 'F' << endl;
        else cout << 'S' << endl;
      }else {
        if( k&1 ) cout << 'S' << endl;
        else cout << 'F' << endl;
      }
    }
  }
}
0