結果

問題 No.905 Sorted?
ユーザー kawacchukawacchu
提出日時 2019-10-11 22:47:37
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 700 ms / 2,000 ms
コード長 1,091 bytes
コンパイル時間 109 ms
コンパイル使用メモリ 10,816 KB
実行使用メモリ 21,728 KB
最終ジャッジ日時 2023-08-16 19:04:17
合計ジャッジ時間 8,120 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,172 KB
testcase_01 AC 15 ms
8,092 KB
testcase_02 AC 14 ms
8,176 KB
testcase_03 AC 14 ms
8,280 KB
testcase_04 AC 13 ms
8,288 KB
testcase_05 AC 17 ms
8,612 KB
testcase_06 AC 15 ms
8,404 KB
testcase_07 AC 28 ms
9,296 KB
testcase_08 AC 530 ms
14,708 KB
testcase_09 AC 350 ms
13,616 KB
testcase_10 AC 477 ms
19,420 KB
testcase_11 AC 557 ms
17,200 KB
testcase_12 AC 700 ms
16,356 KB
testcase_13 AC 560 ms
21,688 KB
testcase_14 AC 554 ms
21,728 KB
testcase_15 AC 670 ms
17,360 KB
testcase_16 AC 657 ms
20,184 KB
testcase_17 AC 659 ms
19,696 KB
testcase_18 AC 499 ms
19,540 KB
testcase_19 AC 14 ms
8,204 KB
testcase_20 AC 12 ms
8,156 KB
testcase_21 AC 13 ms
8,228 KB
testcase_22 AC 13 ms
8,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int,input().split()))

dec = [1]*N
c = 1
f = True
for i in range(1,N) :
    if A[i-1] >= A[i] :
        if not f :
            f = True
            c += 1
            dec[i-1] = c
            dec[i] = c
        else :
            dec[i] = c
    else :
        dec[i] = False
        f = False



inc = [1]*N
c = 1
f = True
for i in range(1,N) :
    if A[i-1] <= A[i] :
        if not f :
            f = True
            c += 1
            inc[i-1] = c
            inc[i] = c
        else :
            inc[i] = c
    else :
        inc[i] = False
        f = False


for i in range(int(input())) :
    p,q = map(int,input().split())
    if p == q :
        print(1,1)
    else :
        if (inc[p] == False) or (inc[q] == False) :
            x = 0
        elif inc[p] == inc[q] :
            x = 1
        else :
            x = 0
        
        if (dec[p] == False) or (dec[q] == False) :
            y = 0
            #print(p,q,dec[p],dec[q])
        elif dec[p] == dec[q] :
            y = 1
        else :
            y = 0
        
        print(x,y)
0