Submission #33674915
Source Code Expand
Copy
def main(N, a):a = [None] + apat = 0same = 0for i in range(1, N+1):if a[i] == i: same += 1elif a[a[i]] == i: pat += 1return same * (same-1) // 2 + pat // 2N = int(input())*a, = map(int, input().split())print(main(N, a))
def main(N, a): a = [None] + a pat = 0 same = 0 for i in range(1, N+1): if a[i] == i: same += 1 elif a[a[i]] == i: pat += 1 return same * (same-1) // 2 + pat // 2 N = int(input()) *a, = map(int, input().split()) print(main(N, a))
Submission Info
Submission Time | |
---|---|
Task | C - Min Max Pair |
User | arakaki_tokyo |
Language | PyPy3 (7.3.0) |
Score | 300 |
Code Size | 289 Byte |
Status | AC |
Exec Time | 189 ms |
Memory | 147948 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example_00.txt, example_01.txt |
All | example_00.txt, example_01.txt, test_00.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
example_00.txt | AC | 69 ms | 61824 KB |
example_01.txt | AC | 46 ms | 61832 KB |
test_00.txt | AC | 176 ms | 130180 KB |
test_01.txt | AC | 81 ms | 87868 KB |
test_02.txt | AC | 135 ms | 116728 KB |
test_03.txt | AC | 129 ms | 113600 KB |
test_04.txt | AC | 91 ms | 91512 KB |
test_05.txt | AC | 122 ms | 109032 KB |
test_06.txt | AC | 186 ms | 147840 KB |
test_07.txt | AC | 187 ms | 147948 KB |
test_08.txt | AC | 189 ms | 147796 KB |
test_09.txt | AC | 50 ms | 61760 KB |