結果

問題 No.742 にゃんにゃんにゃん 猫の挨拶
ユーザー tkr182tkr182
提出日時 2018-10-06 01:02:38
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,335 bytes
コンパイル時間 229 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 19,200 KB
最終ジャッジ日時 2024-04-20 18:02:33
合計ジャッジ時間 7,340 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 34 ms
11,008 KB
testcase_02 AC 34 ms
11,136 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 148 ms
11,008 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 32 ms
11,008 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
t=[int(input()) for i in range(n)] 
s=[(i,t.index(i)+1) for i in range(1,n+1)] 
c=0
d=0
for i in range(0,n):
    if s[i][0]==s[i][1]:
        for t in range(0,n):
            if (s[i][0]==s[t][1] and s[i][1]==s[t][0]):
                d+=1
for i in range(0,n):
    if s[i][0]<=s[i][1]:
        for p in range(0,i):
            if s[p][0]<=s[p][1]:
                if s[i][0]<=s[p][0]<=s[p][1]<=s[i][1]:
                    c+=1
            elif s[i][0]<=s[p][1]<=s[p][0]<=s[i][1]or s[i][0]<s[p][1]<s[i][1]<s[p][0]:
                    c+=1
        for p in range(i+1,n):
            if s[p][0]<=s[p][1]:
                if s[i][0]<=s[p][0]<=s[p][1]<=s[i][1]:
                    c+=1
            elif s[i][0]<=s[p][1]<=s[p][0]<=s[i][1]or s[i][0]<s[p][1]<s[i][1]<s[p][0]:
                c+=1
    else:
        for p in range(0,i):
            if s[p][0]<=s[p][1]:
                if s[i][1]<=s[p][0]<=s[p][1]<=s[i][0]or s[i][1]<s[p][0]<s[i][0]<s[p][1]:
                    c+=1
            elif s[i][1]<=s[p][1]<=s[p][0]<=s[i][0]:
                c+=1
        for p in range(i+1,n):
            if s[p][0]<=s[p][1]:
                if s[i][1]<=s[p][0]<=s[p][1]<=s[i][0] or s[i][1]<s[p][0]<s[i][0]<s[p][1]:
                    c+=1
            elif s[i][1]<=s[p][1]<=s[p][0]<=s[i][0]:
                c+=1
print(int(c-d))
0