結果

問題 No.2080 Simple Nim Query
ユーザー やうやう
提出日時 2022-09-25 22:20:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 881 bytes
コンパイル時間 1,554 ms
コンパイル使用メモリ 168,144 KB
実行使用メモリ 6,604 KB
最終ジャッジ日時 2023-08-24 02:19:42
合計ジャッジ時間 3,981 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,480 KB
testcase_01 AC 3 ms
4,564 KB
testcase_02 AC 3 ms
4,600 KB
testcase_03 WA -
testcase_04 AC 314 ms
4,676 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
using V=vector<ll>;
#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,n) for(ll i=1;i<=n;i++)

int n=1;
V k(202020);

void update(int i,int x){
    i+=n-1;
    k[i]=x;
    while(i){
        i=(i-1)/2;
        k[i]=k[i*2+1]+k[i*2+2];
    }
}

int query(int a,int b,int i,int l,int r){
    if(b<=l||r<=a) return 0;
    if(a<=l&&r<=b) return k[i];
    return query(a,b,i*2+1,l,(l+r)/2)+query(a,b,i*2+2,(l+r)/2,r);
}

int main(){
    int _n,q,count=0;
    cin >> _n >> q;
    while(n<=_n) n*=2;
    V a(_n);
    rep(i,_n){
        cin >> a[i];
        update(i,(a[i]==1));
    }
    rep(i,q){
        int t,x,y;
        cin >> t >> x >> y;
        if(t==1) update(x-1,(y==1));
        else if(query(x,y,0,0,n)%2) cout << "S" << endl;
        else cout << "F" << endl;
    }
}
0