結果

問題 No.2080 Simple Nim Query
ユーザー titiatitia
提出日時 2022-09-25 22:51:32
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,579 bytes
コンパイル時間 285 ms
コンパイル使用メモリ 86,768 KB
実行使用メモリ 110,692 KB
最終ジャッジ日時 2023-08-24 02:28:34
合計ジャッジ時間 4,216 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,272 KB
testcase_01 AC 73 ms
71,236 KB
testcase_02 AC 72 ms
71,096 KB
testcase_03 WA -
testcase_04 AC 225 ms
79,240 KB
testcase_05 AC 359 ms
107,380 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 389 ms
109,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N,Q=map(int,input().split())
A=list(map(int,input().split()))
B=[0]*N

for i in range(N):
    if A[i]==1:
        B[i]=0
    else:
        B[i]=i+1

def seg_function(x,y): # Segment treeで扱うfunction
    return max(x,y)

seg_el=1<<(N.bit_length()) # Segment treeの台の要素数
SEG=[0]*(2*seg_el) # 1-indexedなので、要素数2*seg_el.Segment treeの初期値で初期化

for i in range(N): # Aを対応する箇所へupdate
    SEG[i+seg_el]=B[i]

for i in range(seg_el-1,0,-1): # 親の部分もupdate
    SEG[i]=seg_function(SEG[i*2],SEG[i*2+1])

def update(n,x,seg_el): # A[n]をxへ更新
    i=n+seg_el
    SEG[i]=x
    i>>=1 # 子ノードへ
    
    while i!=0:
        SEG[i]=seg_function(SEG[i*2],SEG[i*2+1])
        i>>=1
        
def getvalues(l,r): # 区間[l,r)に関するseg_functionを調べる
    L=l+seg_el
    R=r+seg_el
    ANS=0

    while L<R:
        if L & 1:
            ANS=seg_function(ANS , SEG[L])
            L+=1

        if R & 1:
            R-=1
            ANS=seg_function(ANS , SEG[R])
        L>>=1
        R>>=1

    return ANS

for i in range(Q):
    t,x,y=map(int,input().split())

    if t==1:
        x-=1
        if y==1:
            update(x,0,seg_el)
        else:
            update(x,x+1,seg_el)

    else:
        k=getvalues(x-1,y)

        if k==0:
            if (y-x)%2==0:
                print("S")
            else:
                print("F")
        else:
            if (y-k)%2==1:
                print("S")
            else:
                print("F")
        
    
0