結果

問題 No.905 Sorted?
ユーザー kawacchukawacchu
提出日時 2019-10-11 22:47:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 767 ms / 2,000 ms
コード長 1,091 bytes
コンパイル時間 71 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 22,820 KB
最終ジャッジ日時 2024-05-04 02:34:56
合計ジャッジ時間 8,623 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
10,880 KB
testcase_01 AC 26 ms
10,880 KB
testcase_02 AC 26 ms
10,880 KB
testcase_03 AC 25 ms
10,880 KB
testcase_04 AC 26 ms
10,880 KB
testcase_05 AC 30 ms
11,264 KB
testcase_06 AC 29 ms
11,008 KB
testcase_07 AC 38 ms
11,904 KB
testcase_08 AC 608 ms
16,236 KB
testcase_09 AC 422 ms
15,640 KB
testcase_10 AC 554 ms
21,728 KB
testcase_11 AC 640 ms
19,080 KB
testcase_12 AC 762 ms
17,832 KB
testcase_13 AC 635 ms
22,820 KB
testcase_14 AC 622 ms
22,020 KB
testcase_15 AC 767 ms
18,656 KB
testcase_16 AC 767 ms
20,756 KB
testcase_17 AC 727 ms
20,736 KB
testcase_18 AC 566 ms
20,608 KB
testcase_19 AC 26 ms
10,880 KB
testcase_20 AC 26 ms
10,880 KB
testcase_21 AC 24 ms
10,880 KB
testcase_22 AC 25 ms
11,008 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