結果
| 問題 | No.905 Sorted? | 
| コンテスト | |
| ユーザー |  kawacchu | 
| 提出日時 | 2019-10-11 22:47:37 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 807 ms / 2,000 ms | 
| コード長 | 1,091 bytes | 
| コンパイル時間 | 89 ms | 
| コンパイル使用メモリ | 12,672 KB | 
| 実行使用メモリ | 22,440 KB | 
| 最終ジャッジ日時 | 2024-11-25 08:46:03 | 
| 合計ジャッジ時間 | 9,067 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 23 | 
ソースコード
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)
            
            
            
        