s_id stringlengths 10 10 | p_id stringlengths 6 6 | u_id stringlengths 10 10 | date stringlengths 10 10 | language stringclasses 1
value | original_language stringclasses 11
values | filename_ext stringclasses 1
value | status stringclasses 1
value | cpu_time stringlengths 1 5 | memory stringlengths 1 7 | code_size stringlengths 1 6 | code stringlengths 1 539k |
|---|---|---|---|---|---|---|---|---|---|---|---|
s677705837 | p03612 | u212328220 | 1588874085 | Python | Python (3.4.3) | py | Runtime Error | 74 | 13880 | 201 | N = int(input())
pl = list(map(int, input().split()))
cnt = 0
for i in range(1,N+1):
if pl[i-1] == i:
a = pl[i - 1]
pl[i - 1] = pl[i]
pl[i] = a
cnt += 1
print(cnt)
|
s172721105 | p03612 | u636683284 | 1588820807 | Python | PyPy3 (2.4.0) | py | Runtime Error | 219 | 52460 | 269 | n = int(input())
l = list(map(int,input().split()))
count = 0
if l[0] == 1:
l[1] = l[0]
count += 1
for i in range(1,n):
if l[i] == i+1:
if l[i+1] == i+2:
l[i],l[i+1] = l[i+1],l[i]
i += 1
else:
l[i] = l[i-1]
count += 1
print(count) |
s877652845 | p03612 | u300579805 | 1588801168 | Python | Python (3.4.3) | py | Runtime Error | 64 | 14008 | 173 | n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(n):
if p[i] == i+1:
ans += 1
if i != n:
p[i+1] = 0
print(ans) |
s605355723 | p03612 | u025501820 | 1588673562 | Python | Python (3.4.3) | py | Runtime Error | 50 | 14008 | 315 | #!/usr/bin/env python3
N = int(input())
# S = input()
# N, K = map(int, input().split())
P = list(map(int, input().split()))
def main():
pre = 0
ans = 0
for i, p in enumerate(P, 1):
if i == p:
ans += 1
P[i] = p
print(ans)
if __name__ == "__main__":
main()
|
s812209412 | p03612 | u135116520 | 1588646599 | Python | Python (3.4.3) | py | Runtime Error | 78 | 14008 | 247 | N=int(input())
p=list(map(int,input().split()))
t=0
for i in range(N):
if i!=N:
if p[i]==i+1:
s=p[i+1]
p[i]=s
p[i+1]=i+1
t+=1
else:
if p[i]==i+1:
u=p[i-1]
p[i]=u
p[i-1]=i+1
t+=1
print(t)
|
s751349301 | p03612 | u135116520 | 1588644434 | Python | Python (3.4.3) | py | Runtime Error | 74 | 13880 | 143 | N=int(input())
p=list(map(int,input().split()))
t=0
for i in range(N):
if p[i]==i+1:
s=p[i+1]
p[i]=s
p[i+1]=i+1
t+=1
print(t) |
s442864835 | p03612 | u057109575 | 1588432378 | Python | PyPy3 (2.4.0) | py | Runtime Error | 214 | 60016 | 156 | N, *X = map(int, open(0).read().split())
ans = 0
for i in range(N - 1):
if X[i] == i + 1:
X[i], X[j] = X[j], X[i]
ans += 1
print(ans)
|
s126863434 | p03612 | u203843959 | 1588358241 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 253 | N=int(input())
alist=[0]+list(map(int,input().split()))
answer=0
if alist[N]=N:
alist[N-1],alist[N]=alist[N],alist[N-1]
answer+=1
for i in range(1,N+1):
if alist[i]==i:
alist[i],alist[i+1]=alist[i+1],alist[i]
answer+=1
print(answer) |
s602247948 | p03612 | u203843959 | 1588358221 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 253 | N=int(input())
alist=[0]+list(map(int,input().split()))
if alist[N]=N:
alist[N-1],alist[N]=alist[N],alist[N-1]
answer+=1
answer=0
for i in range(1,N+1):
if alist[i]==i:
alist[i],alist[i+1]=alist[i+1],alist[i]
answer+=1
print(answer) |
s507934757 | p03612 | u203843959 | 1588358014 | Python | Python (3.4.3) | py | Runtime Error | 73 | 14008 | 183 | N=int(input())
alist=[0]+list(map(int,input().split()))
answer=0
for i in range(1,N+1):
if alist[i]==i:
alist[i],alist[i+1]=alist[i+1],alist[i]
answer+=1
print(answer) |
s180717102 | p03612 | u394731058 | 1588355184 | Python | Python (3.4.3) | py | Runtime Error | 57 | 14008 | 257 | def main():
ans = 0
n = int(input())
l = list(map(int, input().split()))
for i in range(n):
if l[i] == i+1:
l[i] = l[i+1]
l[i+1] = i+1
ans += 1
print(ans)
if __name__ == '__main__':
main() |
s848983388 | p03612 | u597455618 | 1588310114 | Python | Python (3.4.3) | py | Runtime Error | 74 | 14008 | 192 | n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(n):
if p[i] == i+1:
p[i], p[i+1] = p[i+1], p[i]
ans += 1
if p[-1] == n:
ans += 1
print(ans) |
s469611945 | p03612 | u497952650 | 1588136196 | Python | Python (3.4.3) | py | Runtime Error | 75 | 14008 | 161 | N = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(N):
if p[i] == i+1:
p[i],p[i+1] = p[i+1],p[i]
ans += 1
print(ans) |
s154822966 | p03612 | u781262926 | 1588112909 | Python | Python (3.4.3) | py | Runtime Error | 80 | 13940 | 195 | n, *P = map(int, open(0).read().split())
c = 0
if P[0] == 1:
c, P[0], P[1] = 1, P[1], 1
for i, (p0, p1) in enumerate(zip(P, P[1:]), 2):
if i == p1:
c, P[i-1], P[i] = c+1, P[i], i
print(c) |
s352253621 | p03612 | u644516473 | 1587940825 | Python | Python (3.4.3) | py | Runtime Error | 64 | 14008 | 152 | N = int(input())
P = list(map(int, input().split()))
ans = 0
for i in range(N):
if i + 1 == P[i]:
ans += 1
P[i+1] = P[i]
print(ans)
|
s679408089 | p03612 | u595375942 | 1587827939 | Python | Python (3.4.3) | py | Runtime Error | 87 | 14008 | 317 | N = int(input())
P = list(map(int, input().split()))
ans = 0
cnt = 0
flag = 1
while flag:
flag = 0
if cnt == N-1:
break
for i in range(cnt, N):
if P[i] == i+1:
P[i], P[i+1] = P[i+1], P[i]
ans += 1
flag = 1
else:
cnt += 1
print(ans) |
s943761014 | p03612 | u595375942 | 1587827817 | Python | Python (3.4.3) | py | Runtime Error | 91 | 14008 | 284 | N = int(input())
P = list(map(int, input().split()))
ans = 0
cnt = 0
flag = 1
while flag:
flag = 0
for i in range(cnt, N):
if P[i] == i+1:
P[i], P[i+1] = P[i+1], P[i]
ans += 1
flag = 1
else:
cnt += 1
print(ans) |
s979552811 | p03612 | u930705402 | 1587069785 | Python | PyPy3 (2.4.0) | py | Runtime Error | 211 | 52908 | 185 | N=int(input())
A=list(map(int,input().split()))
i=0
cnt=0
while(i<N):
if(A[i]==i+1):
A[i],A[i+1]=A[i+1],A[i]
cnt+=1
i+=2
continue
i+=1
print(cnt) |
s009133494 | p03612 | u836737505 | 1586908469 | Python | Python (3.4.3) | py | Runtime Error | 66 | 14008 | 177 | n = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(n-1):
if i+1 == p[i]:
p[i+1] = p[i]
ans += 1
if p[n] == n:
ans += 1
print(ans) |
s754397195 | p03612 | u784022244 | 1586887940 | Python | Python (3.4.3) | py | Runtime Error | 61 | 14008 | 321 | N=int(input())
A=list(map(int, input().split()))
pre=(A[0]==1)
count=0
ans=0
if pre:
count+=1
for i in range(1,N):
if pre:
if A[i]!=i+1:
ans+=ceil(count/2)
count=0
pre=False
else:
count+=1
else:
if A[i]==i+1:
count+=1
pre=True
if pre:
ans+=ceil(count/2)
print(ans... |
s238358372 | p03612 | u836737505 | 1586865592 | Python | Python (3.4.3) | py | Runtime Error | 80 | 14008 | 288 | n = int(input())
l = list(map(int,input().split()))
ans = 0
for i in range(n):
if i != n:
if i+1 == l[i]:
a = l[i]
b = l[i+1]
l[i]=b
l[i+1]=a
ans += 1
else:
if i+1 == l[i]:
ans += 1
print(ans) |
s829578587 | p03612 | u608088992 | 1586865520 | Python | Python (3.4.3) | py | Runtime Error | 68 | 13876 | 330 | import sys
def solve():
input = sys.stdin.readline
N = int(input())
P = [int(p) for p in input().split()]
swap = 0
i = 0
while i < N:
if P[i] == i + 1:
P[i], P[i+1] = P[i+1], P[i]
swap += 1
i += 1
print(swap)
return 0
if __name__ == "__main__":
... |
s748661133 | p03612 | u293198424 | 1586865465 | Python | PyPy3 (2.4.0) | py | Runtime Error | 209 | 52908 | 231 | N = int(input())
p = [int(i) for i in input().split()]
count = 0
i = 0
while i < N:
if p[i]-1==i:
if p[i+1]-1==i+1:
i += 1
count += 1
else:
count += 1
i += 1
print(count) |
s937907583 | p03612 | u836737505 | 1586865426 | Python | Python (3.4.3) | py | Runtime Error | 76 | 13940 | 194 | n = int(input())
l = list(map(int,input().split()))
ans = 0
for i in range(n):
if i+1 == l[i]:
a = l[i]
b = l[i+1]
l[i]=b
l[i+1]=a
ans += 1
print(ans) |
s578758224 | p03612 | u392319141 | 1586865115 | Python | Python (3.4.3) | py | Runtime Error | 72 | 14008 | 171 | N = int(input())
P = list(map(int, input().split()))
ans = 0
for i in range(N):
if P[i] == i + 1:
P[i], P[i + 1] = P[i + 1], P[i]
ans += 1
print(ans)
|
s947269491 | p03612 | u599114793 | 1586864692 | Python | PyPy3 (2.4.0) | py | Runtime Error | 222 | 52908 | 162 | n = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(n):
if p[i]-1 == i:
p[i], p[i+1] = p[i+1],p[i]
ans += 1
print(ans)
|
s959677542 | p03612 | u489959379 | 1586712805 | Python | Python (3.4.3) | py | Runtime Error | 72 | 14008 | 170 | n = int(input())
P = list(map(int, input().split()))
res = 0
for i in range(n):
if i + 1 == P[i]:
P[i], P[i + 1] = P[i + 1], P[i]
res += 1
print(res) |
s990165288 | p03612 | u870575557 | 1586368052 | Python | Python (3.4.3) | py | Runtime Error | 71 | 14008 | 179 | #解説見た
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(n):
if p[i] == (i+1):
p[i],p[i+1] = p[i+1], p[i]
ans += 1
print(ans) |
s011846371 | p03612 | u682860781 | 1586230063 | Python | Python (3.4.3) | py | Runtime Error | 77 | 14008 | 187 | n = int(input())
p = list(map(int, input().split()))
cnt = 0
for i in range(n):
if p[i] == i+1:
if i < n:
p[i], p[i+1] = p[i+1], p[i]
cnt += 1
print(cnt)
|
s841488328 | p03612 | u191394596 | 1586042536 | Python | Python (3.4.3) | py | Runtime Error | 77 | 14008 | 243 | N = int(input())
P = list(map(int, input().split()))
count = 0
for i in range(N):
if P[i] == i + 1:
if i == N:
P[i - 1], P[i] = P[i], P[i - 1]
else:
P[i], P[i + 1] = P[i + 1], P[i]
count += 1
print(count) |
s624721880 | p03612 | u641406334 | 1586029769 | Python | Python (3.4.3) | py | Runtime Error | 94 | 14008 | 213 | n = int(input())
p = list(map(int, input().split()))
cnt = 0
pp = [1 if p[i-1] == i else 0 for i in range(1, n+1)]
for i in range(n):
if pp[i]==1:
p[i], p[i+1] = p[i+1], p[i]
cnt+=1
print(cnt)
|
s378579351 | p03612 | u262597910 | 1585976046 | Python | Python (3.4.3) | py | Runtime Error | 122 | 14008 | 366 | n = int(input())
p = list(map(int, input().split()))
st = []
c = 0
for i in range(0,n):
if (p[i] == i+1):
st.append(1)
else:
st.append(0)
def cal(a):
global c
for j in range(a,n-1):
if (st[j] == 1 and st[j+1]==1):
c += 1
cal(j+2)
return c
... |
s630281249 | p03612 | u021548497 | 1585868118 | Python | Python (3.4.3) | py | Runtime Error | 85 | 13880 | 197 | n = int(input())
a = [int(x) for x in input().split()]
ans = 0
for i in range(n):
if i == n-1 and a[i] == n:
ans += 1
if a[i] == i+1:
ans += 1
a[i], a[i+1] = a[i+1], a[i]
print(ans) |
s430492528 | p03612 | u089142196 | 1585698101 | Python | Python (3.4.3) | py | Runtime Error | 71 | 14008 | 198 | N=int(input())
p=list(map(int,input().split()))
cnt=0
for i in range(N-1):
if p[i]==i+1:
p[i],p[i+1] = p[i+1],p[i]
cnt+=1
if p[N-1]==N:
p[N-1],p[N] = p[N],p[N-1]
cnt+=1
print(cnt)
|
s124335274 | p03612 | u896726004 | 1585434607 | Python | Python (3.4.3) | py | Runtime Error | 73 | 14008 | 165 | N = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(N):
if p[i] == i+1:
p[i], p[i+1] = p[i+1], p[i]
ans += 1
print(ans) |
s655892430 | p03612 | u836737505 | 1584791166 | Python | Python (3.4.3) | py | Runtime Error | 75 | 13812 | 213 | import math
n = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(n):
if i+1 == a[i]:
b = a[i]
c = a[i+1]
a[i] = c
a[i+1] = b
ans += 1
print(ans) |
s678599435 | p03612 | u392319141 | 1584791089 | Python | Python (3.4.3) | py | Runtime Error | 93 | 14008 | 204 | N = int(input())
P = list(map(lambda a: int(a) - 1, input().split()))
ans = 0
for i in range(N):
p = P[i]
if p == i and i < N:
P[i], P[i + 1] = P[i + 1], P[i]
ans += 1
print(ans) |
s043777587 | p03612 | u599114793 | 1584790971 | Python | Python (3.4.3) | py | Runtime Error | 70 | 14008 | 164 | n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
if a[i] == i+1:
a[i], a[i+1] = a[i+1], a[i]
ans += 1
print(ans)
|
s285667767 | p03612 | u358254559 | 1584491302 | Python | PyPy3 (2.4.0) | py | Runtime Error | 166 | 38384 | 395 | n = int(input())
p = list(map(int, input().split()))
i=0
ans=0
while i<n-1: if p[i] == i+1 and p[i+1] == i+2:
p[i],p[i+1] = p[i+1],p[i]
ans+=1
elif p[i] == i+1 and p[i+1] != i+2:
p[i],p[i+1] = p[i+1],p[i]
... |
s793464008 | p03612 | u078349616 | 1584405447 | Python | Python (3.4.3) | py | Runtime Error | 74 | 14008 | 175 | N = int(input())
P = list(map(int,input().split()))
cnt = 0
for i in range(1, N+1):
if P[i-1] == i:
tmp = P[i-1]
P[i-1] = P[i]
P[i] = tmp
cnt += 1
print(cnt) |
s610011162 | p03612 | u721970149 | 1584068170 | Python | Python (3.4.3) | py | Runtime Error | 79 | 13880 | 170 | N = int(input())
p = [int(x) for x in input().split()]
ans = 0
for i in range(N) :
if p[i] == i+1 :
p[i], p[i+1] = p[i+1], p[i]
ans += 1
print(ans)
|
s454663356 | p03612 | u747703115 | 1583888104 | Python | Python (3.4.3) | py | Runtime Error | 68 | 14004 | 202 | n = int(input())
P = list(map(int, input().split()))
r = 0
for i in range(n):
if P[i] == i+1:
if i!=n:
P[i+1] = P[i]
r += 1
else:
r += 1
print(r) |
s183201487 | p03612 | u490553751 | 1583804469 | Python | Python (3.4.3) | py | Runtime Error | 85 | 13880 | 364 | N = int(input())
p = [int(i) for i in input().split()]
ans = 0
for i in range(N):
if i+1 == p[i]:
if i == N-1:
l = p[i]
k = l[i-1]
p[i] = k
p[i-1] = l
ans +=1
else:
l = p[i]
k = p[i+1]
p[i] = k
... |
s221575178 | p03612 | u312025627 | 1583330643 | Python | PyPy3 (2.4.0) | py | Runtime Error | 227 | 52908 | 250 | def main():
N = int(input())
P = [int(i) for i in input().split()]
ans = 0
for i in range(N):
if i+1 == P[i]:
P[i], P[i+1] = P[i+1], P[i]
ans += 1
print(ans)
if __name__ == '__main__':
main()
|
s526411233 | p03612 | u241159583 | 1583326490 | Python | Python (3.4.3) | py | Runtime Error | 73 | 14008 | 184 | N = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(N):
if p[i] - 1 == i:
a = p[i]
b = p[i + 1]
p[i] = b
p[i + 1] = a
ans += 1
print(ans) |
s494564520 | p03612 | u698919163 | 1583202019 | Python | Python (3.4.3) | py | Runtime Error | 76 | 14004 | 269 | N = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(N):
if i+1 == p[i]:
p[i],p[i+1] = p[i+1],p[i]
ans += 1
elif i == N-1:
if i+1 == p[i]:
p[i],p[0] = p[0],p[i]
ans += 1
print(ans) |
s497897147 | p03612 | u698919163 | 1583201485 | Python | Python (3.4.3) | py | Runtime Error | 80 | 14008 | 276 | N = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(N):
if i+1 == p[i]:
p[i],p[i+1] = p[i+1],p[i]
ans += 1
if i == N-1:
if i+1 == p[i]:
p[i],p[0] = p[0],p[i]
ans += 1
print(ans) |
s548964765 | p03612 | u698919163 | 1583201123 | Python | Python (3.4.3) | py | Runtime Error | 72 | 14008 | 171 | N = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(N):
if i+1 == p[i]:
p[i],p[i+1] = p[i+1],p[i]
ans += 1
print(ans) |
s100921974 | p03612 | u498487134 | 1583187906 | Python | PyPy3 (2.4.0) | py | Runtime Error | 234 | 52316 | 356 | import sys
input = sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def main():
mod=10**9+7
N=I()
p=LI()
ans=0
for i in range(N):
if p[i]==i+1:
p[i],p[i+1]=p[i+1],p[i]
ans+=1
... |
s044534483 | p03612 | u391667116 | 1582842700 | Python | Python (3.4.3) | py | Runtime Error | 74 | 13880 | 192 | N = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(N):
if p[i] != i+1:
continue
tmp = p[i]
p[i] = p[i+1]
p[i+1] = tmp
ans += 1
print(ans)
|
s141976839 | p03612 | u022979415 | 1582339983 | Python | Python (3.4.3) | py | Runtime Error | 57 | 13880 | 322 | def main():
N = int(input())
permutation = list(map(int, input().split()))
answer = 0
for i in range(N):
if permutation[i] == i + 1:
permutation[i], permutation[i + 1] = permutation[i + 1], permutation[i]
answer += 1
print(answer)
if __name__ == '__main__':
main... |
s566925185 | p03612 | u618002097 | 1582286500 | Python | PyPy3 (2.4.0) | py | Runtime Error | 215 | 53932 | 151 | N = input()
A = list(map(int, input().split()))
count = 0
for i, a in enumerate(A[:-1]):
if a == i+1:
count += 1
A[i+1] = a
peint(count) |
s097740944 | p03612 | u871352270 | 1582267408 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 229 | n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(n-1):
if p[i] == i+1:
p[i], p[i+1] = p[i+1], p[i]
ans += 1
if p[n-1] = n:
p[n-1], p[n-2] = p[n-2], p[n-1]
ans += 1
print(ans) |
s515020995 | p03612 | u871352270 | 1582267284 | Python | Python (3.4.3) | py | Runtime Error | 73 | 14004 | 163 | n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(n):
if p[i] == i+1:
p[i], p[i+1] = p[i+1], p[i]
ans += 1
print(ans) |
s389747027 | p03612 | u797994565 | 1582235449 | Python | Python (3.4.3) | py | Runtime Error | 72 | 13880 | 160 | N = int(input())
P = list(map(int,input().split()))
ans = 0
for i in range(N):
if i+1 == P[i]:
P[i],P[i+1] = P[i+1],P[i]
ans += 1
print(ans) |
s556931433 | p03612 | u904943473 | 1582014028 | Python | PyPy3 (2.4.0) | py | Runtime Error | 224 | 53292 | 188 | N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(len(A)-1):
if (i+1 == A[i]):
ans += 1
A[i],A[i+1] = A[i+1],A[i]
if (A[-1] == l):
ans += 1
print(ans) |
s905414462 | p03612 | u593934357 | 1581343916 | Python | PyPy3 (2.4.0) | py | Runtime Error | 175 | 38256 | 818 | import sys
from collections import deque, Counter, defaultdict
from fractions import gcd
input = sys.stdin.readline
def eprint(s):
if type(s) != type('str'):
s=str(s)
sys.stderr.write(s+'\n')
return
def check(h):
n = len(h)
cps = [False]*n
for i in range(n):
if h[i] != i+1:
... |
s428066185 | p03612 | u762420987 | 1581113840 | Python | PyPy3 (2.4.0) | py | Runtime Error | 206 | 52908 | 226 | N = int(input())
plist = list(map(int, input().split()))
ans = 0
for i in range(N):
if plist[i] == i + 1:
plist[i], plist[i + 1] = plist[i + 1], plist[i]
ans += 1
if plist[-1] == N:
ans += 1
print(ans)
|
s458096140 | p03612 | u934788990 | 1581000397 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 225 | n = int(input())
p = [int(i) for i in input().split()]
count = 0
for i in range(1,n):
if i+1 == p[i]:
cha = p[i-1]
p[i-1] = p[i]
p[i] = cha
count+=1
if n == p[n-1]
count+=1
print(count) |
s833850101 | p03612 | u934788990 | 1580999462 | Python | Python (3.4.3) | py | Runtime Error | 89 | 13880 | 235 | n = int(input())
p = [int(i) for i in input().split()]
liI = [int(j) for j in range(1,n+1)]
count = 0
for i in range(n):
if p[i] == liI[i]:
cha = p[i]
p[i] = p[i+1]
p[i+1] = cha
count+=1
print(count) |
s348777906 | p03612 | u762420987 | 1580609299 | Python | Python (3.4.3) | py | Runtime Error | 71 | 13880 | 198 | N = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(N):
if p[i] == i + 1:
ans += 1
p[i], p[i + 1] = p[i + 1], p[i]
if p[-1] == N:
ans += 1
print(ans)
|
s838242652 | p03612 | u572142121 | 1580441550 | Python | Python (3.4.3) | py | Runtime Error | 73 | 14008 | 158 | N=int(input())
A=list(map(int,input().split()))
cnt=0
for i in range(N):
if i+1==A[i]:
a=A[i]
b=A[i+1]
A[i]=b
A[i+1]=a
cnt+=1
print(cnt) |
s662844957 | p03612 | u183896397 | 1580010803 | Python | Python (3.4.3) | py | Runtime Error | 72 | 14008 | 162 | N = int(input())
P = list(map(int,input().split()))
ans = 0
for i in range(N):
if P[i] == i + 1:
P[i],P[i+1] = P[i+1],P[i]
ans += 1
print(ans) |
s542383449 | p03612 | u852690916 | 1579570307 | Python | Python (3.4.3) | py | Runtime Error | 80 | 14008 | 264 | N=int(input())
P=[1]+list(map(int,input().split()))
ans=0
for i in range(1,N+1):
if P[i]==i:
if i+1==P[i+1] or i==1:
P[i+1],P[i]=P[i],P[i+1]
ans+=1
else:
P[i-1],P[i]=P[i],P[i-1]
ans+=1
print(ans) |
s077595870 | p03612 | u811000506 | 1579409629 | Python | Python (3.4.3) | py | Runtime Error | 106 | 13880 | 255 | N = int(input())
p = list(map(int,input().split()))
now = count = 0
while(now<N):
if p[now]==now+1:
tmp = p[now]
p[now] = p[now+1]
p[now+1] = tmp
now -= 1
count += 1
continue
now += 1
print(count)
|
s820290125 | p03612 | u998679483 | 1579197340 | Python | Python (3.4.3) | py | Runtime Error | 75 | 14008 | 254 | # ALC 005 D
N = int(input())
list_p = list(map(int, input().split()))
swapCount = 0
for i in range(N):
if list_p[i] == i+1:
temp = list_p[i]
list_p[i] = list_p[i+1]
list_p[i+1] = temp
swapCount += 1
print(swapCount) |
s357969535 | p03612 | u779455925 | 1578633199 | Python | PyPy3 (2.4.0) | py | Runtime Error | 211 | 52908 | 218 | N=int(input())
P=list(map(int,input().split()))
count=0
flag=0
for i in range(N):
if flag:
flag=0
continue
if P[i]==i+1:
count+=1
if P[i+1]==i+2:
flag=1
print(count)
|
s125332045 | p03612 | u113971909 | 1578420690 | Python | Python (3.4.3) | py | Runtime Error | 69 | 14008 | 146 | N=int(input())
P=list(map(int,input().split()))
ans = 0
for i in range(1,N+1):
if P[i-1]==i:
P[i-1],P[i]=P[i],P[i-1]
ans += 1
print(ans) |
s683367841 | p03612 | u279493135 | 1578355915 | Python | Python (3.4.3) | py | Runtime Error | 83 | 15956 | 747 | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, atan, degrees
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ... |
s780856458 | p03612 | u474423089 | 1578064172 | Python | Python (3.4.3) | py | Runtime Error | 100 | 14008 | 369 | n = int(input())
a = list(map(int,input().split(' ')))
ans = 0
for i in range(n):
if i ==0 and a[0]==1:
a[0],a[1] = a[1],a[0]
ans += 1
continue
if i+1 == a[i] and i+1 != a[i+1] and i <n:
a[i],a[i+1] = a[i+1],a[i]
ans += 1
if i+1 ==a[i] and i+1 != a[i-1]:
a[i-... |
s268986659 | p03612 | u474423089 | 1578064032 | Python | Python (3.4.3) | py | Runtime Error | 92 | 14008 | 360 | n = int(input())
a = list(map(int,input().split(' ')))
ans = 0
for i in range(n):
if i ==0 and a[0]==1:
a[0],a[1] = a[1],a[0]
ans += 1
continue
if i+1 == a[i] and i+1 != a[i+1]:
a[i],a[i+1] = a[i+1],a[i]
ans += 1
if i+1 ==a[i] and i+1 != a[i-1]:
a[i-1],a[i] =... |
s706131684 | p03612 | u245870380 | 1577386800 | Python | Python (3.4.3) | py | Runtime Error | 71 | 14008 | 164 | N = int(input())
P = list(map(int, input().split()))
cnt = 0
for i in range(N):
if i+1 == P[i]:
P[i], P[i+1] = P[i+1], P[i]
cnt += 1
print(cnt)
|
s291103771 | p03612 | u735069283 | 1577306789 | Python | Python (3.4.3) | py | Runtime Error | 83 | 13880 | 196 | N = int(input())
A = [int(x) for x in input().split()]
X = [0]*N
answer = 0
for i in range(N):
if A[i]==i+1:
X[i]=1
for i in range(N):
if X[i]==1:
answer +=1
X[i+1]=0
print(answer) |
s573910672 | p03612 | u261891508 | 1577275631 | Python | Python (3.4.3) | py | Runtime Error | 71 | 14004 | 155 | n=int(input())
p=list(map(int,input().split()))
r=p[:]
ans=0
for i in range(n):
if p[i]==i+1:
ans+=1
p[i]=r[i+1]
p[i+1]=r[i]
print(ans) |
s529264741 | p03612 | u846634344 | 1577235688 | Python | Python (3.4.3) | py | Runtime Error | 63 | 14260 | 444 | import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]
def main():
N = INT()
A = MAP()
i = 0
cnt = 0
while i < N:
if A[i] == i+1:
cnt ... |
s277396897 | p03612 | u277312083 | 1576890662 | Python | Python (3.4.3) | py | Runtime Error | 75 | 13880 | 231 | n = int(input())
p = list(map(int, input().rstrip().split(" ")))
c = 0
f = 0
for i in range(n):
if p[i] == i + 1:
p[i] , p[i + 1] = p[i + 1] , p[i]
c += 1
f = i + 1
if p[n - 1] == n:
c += 1
print(c)
|
s142144478 | p03612 | u277312083 | 1576889131 | Python | Python (3.4.3) | py | Runtime Error | 72 | 14008 | 198 | n = int(input())
p = list(map(int, input().rstrip().split(" ")))
c = 0
for i in range(n):
if p[i] == i + 1:
x = p[i]
p[i] = p[i + 1]
p[i + 1] = x
c += 1
print(c)
|
s342677218 | p03612 | u617515020 | 1576711029 | Python | Python (3.4.3) | py | Runtime Error | 73 | 14008 | 139 | n=int(input())
p=list(map(int,input().split()))
cnt=0
for i in range(n):
if p[i]==i+1:
p[i], p[i+1]=p[i+1],p[i]
cnt+=1
print(cnt) |
s762790870 | p03612 | u614734359 | 1576704385 | Python | Python (3.4.3) | py | Runtime Error | 74 | 13880 | 182 | n = int(input())
P = [int(i) for i in input().split()]
ans = 0
for i in range(n):
if P[i] == i+1 :
P[i],P[i+1] = P[i+1],P[i]
ans += 1
#print(P)
print(ans)
|
s610803764 | p03612 | u989345508 | 1576548257 | Python | Python (3.4.3) | py | Runtime Error | 71 | 14008 | 205 | n=int(input())
f1=list(map(int,input().split()))
c=0
for i in range(n-1):
if f1[i]==i+1:
c+=1
f1[i],f1[i+1]=f1[i+1],f1[i]
if f[n-1]==n:
f[n-2],f[n-1]=f[n-1],f[n-2]
c+=1
print(c) |
s952085232 | p03612 | u989345508 | 1576548230 | Python | Python (3.4.3) | py | Runtime Error | 71 | 14008 | 203 | n=int(input())
f1=list(map(int,input().split()))
c=0
for i in range(n-1):
if f1[i]==i+1:
c+=1
f1[i],f1[i+1]=f1[i+1],f1[i]
if f[n-1]==n:
f[n-2],f[n-1]=f[n-1],f[n-2]
c+=1
print(c) |
s237788554 | p03612 | u027929618 | 1576035864 | Python | Python (3.4.3) | py | Runtime Error | 65 | 13880 | 129 | n=int(input())
p=list(map(int,input().split()))
cnt=0
for i in range(n):
if i+1 == p[i]:
p[i+1]=p[i]
cnt+=1
print(cnt)
|
s394706133 | p03612 | u278356323 | 1575563825 | Python | Python (3.4.3) | py | Runtime Error | 77 | 13876 | 265 | # ABC072d
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(n):
if p[i] == i+1:
t = p[i]
p[i] = p[i+1]
p[i+1] = t
ans += 1
print(ans)
|
s904530533 | p03612 | u957872856 | 1575347615 | Python | Python (3.4.3) | py | Runtime Error | 78 | 13880 | 167 | n = int(input())
P = [int(i) for i in input().split()]
cnt = 0
for i in range(n):
if i+1==P[i]:
a = P[i]
P[i] = P[i+1]
P[i+1] = a
cnt += 1
print(cnt) |
s249192374 | p03612 | u936985471 | 1574545228 | Python | Python (3.4.3) | py | Runtime Error | 341 | 22640 | 205 | n=int(input())
import numpy as np
a=np.array(input().split(),dtype=int)
np.append(a,[0])
i=0
ans=0
while i<a.size:
if a[i]==i+1:
ans+=1
if a[i+1]==i+2:
i+=2
continue
i+=1
print(ans) |
s260314825 | p03612 | u815878613 | 1574129592 | Python | Python (3.4.3) | py | Runtime Error | 74 | 12392 | 501 | import sys
readline = sys.stdin.buffer.readline
def main():
N = int(readline())
P = list(map(int, readline().split()))
P = list(map(lambda x: x-1, P))
cnt = 0
for i in range(0, N):
if P[i] == i:
if P[i+1] == i+1 and i != N-1:
P[i], P[i+1] = P[i+1], P[i]
... |
s452448759 | p03612 | u814986259 | 1574085323 | Python | Python (3.4.3) | py | Runtime Error | 85 | 17212 | 273 | N=int(input())
p=list(map(int,input().split()))
count=0
import collections
s=collections.deque()
t=set()
for i in range(N):
if p[i]==i+1:
s.append(i)
t.add(i)
ans=0
id=0
while(id<N):
if id in t:
if x+1 in t:
id+=1
ans+=1
id+=1
print(ans)
|
s483952451 | p03612 | u814986259 | 1574083826 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 148 | N=int(input())
p=list(map(int,input().))
count=0
for i in range(N):
if p[i]==i:
count+=1
ans=count//2
if count%2==1:
ans+=1
print(ans) |
s139375498 | p03612 | u514894322 | 1573822891 | Python | Python (3.4.3) | py | Runtime Error | 19 | 2940 | 161 | n = int(input())
*l, = map(int,input().split())
ans = 0
for i in range(n-1):
if l[i] == i+1:
l[i+1] = l[i]
ans += 1
if l[-1] = n:
ans += 1
print(ans) |
s973813892 | p03612 | u047816928 | 1573712062 | Python | Python (3.4.3) | py | Runtime Error | 65 | 14008 | 142 | N = int(input())
P = list(map(int,input().split()))
ans = 0
for i in range(N):
if P[i]==i+1:
P[i+1]=P[i]
ans+=1
print(ans) |
s953716667 | p03612 | u768896740 | 1573131758 | Python | Python (3.4.3) | py | Runtime Error | 84 | 14008 | 255 | n = int(input())
a = list(map(int, input().split()))
count = 0
i = 0
while i <= (n-1):
if a[i] == i+1 and a[i+1] == i+2:
count += 1
i += 2
elif a[i] == i+1:
count += 1
i += 1
else:
i += 1
print(count)
|
s819530130 | p03612 | u614875193 | 1573013525 | Python | PyPy3 (2.4.0) | py | Runtime Error | 219 | 56940 | 332 | N=int(input())
P=list(map(int,input().split()))
c=[]
for i in range(N):
if P[i]==i+1:
c.append(i+1)
import sys
if c==[]:
print(0)
sys.exit()
d=[]
for i in range(1,len(c)):
d.append(c[i]-c[i-1])
if len(c)==2:
print(c[1]-c[0])
elif len(c)%2==0:
print(sum(d)-max(d))
else:
print(sum(... |
s596989181 | p03612 | u311379832 | 1572921739 | Python | Python (3.4.3) | py | Runtime Error | 89 | 13880 | 277 | N = int(input())
p = list(map(int, input().split()))
cnt = 0
if p[0] == 1:
tmp = p[1]
p[1] = p[0]
p[0] = tmp
cnt += 1
for i in range(N, 0, -1):
if i == p[i - 1]:
tmp = p[i]
p[i] = p[i - 1]
p[i - 1] = tmp
cnt += 1
print(cnt) |
s551465677 | p03612 | u311379832 | 1572921704 | Python | Python (3.4.3) | py | Runtime Error | 93 | 14008 | 280 | N = int(input())
p = list(map(int, input().split()))
cnt = 0
if p[0] == 1:
tmp = p[1]
p[1] = p[0]
p[0] = tmp
cnt += 1
for i in range(N, 0, -1):
if i == p[i - 1]:
tmp = p[i]
p[i] = p[i - 1]
p[i - 1] = tmp
cnt += 1
print(p, cnt) |
s952961646 | p03612 | u970449052 | 1572322444 | Python | Python (3.4.3) | py | Runtime Error | 62 | 14008 | 140 | n=int(input())
pl=list(map(int,input().split()))
ans=0
for i in range(n):
if pl[i]==i+1:
ans+=1
pl[i+1]=pl[i]
print(ans) |
s200736269 | p03612 | u691896522 | 1572161834 | Python | Python (3.4.3) | py | Runtime Error | 85 | 14008 | 254 | n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(n):
if i == n - 1 and i + 1 == p[i]:
count += 1
if i + 1 == p[i]:
tmp = p[i]
p[i] = p[i+1]
p[i+1] = tmp
count += 1
print(count)
|
s301936679 | p03612 | u691896522 | 1572161493 | Python | Python (3.4.3) | py | Runtime Error | 74 | 14008 | 198 | n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(n):
if i + 1 == p[i]:
tmp = p[i]
p[i] = p[i+1]
p[i+1] = tmp
count += 1
print(count)
|
s199013862 | p03612 | u924374652 | 1571777597 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 14008 | 403 | n = int(input())
list_p = list(map(int, input().split()))
same_p = [1 if i+1 == p else 0 for i, p in enumerate(list_p)]
count = 0
i = 0
while i < n:
if sum(same_p) == 0:
break
if same_p[i] == 1:
temp_p = list_p[i]
list_p[i] = list_p[i+1]
list_p[i+1] = temp_p
same_p[i] = 0
same_p[i+1] = 0
... |
s064568339 | p03612 | u897328029 | 1571322303 | Python | Python (3.4.3) | py | Runtime Error | 86 | 14008 | 648 | #!/usr/bin/env python3
N = int(input().split()[0])
p_list = list(map(int, input().split()))
count = 0
for i in range(N):
index = i + 1
if index == p_list[i]:
if i != 0 and i != 1:
if p_list[i + 1] == index + 1:
p_list[i] = p_list[i + 1]
p_list[i + 1] = index
... |
s260343718 | p03612 | u033606236 | 1570358074 | Python | Python (3.4.3) | py | Runtime Error | 73 | 13880 | 228 | n = int(input())
ary = list(map(int,input().split()))
ans = 0
for i in range(n):
if i+1 == ary[i]:
a = ary[i]
b = ary[i+1]
ary[i] = b
ary[i+1] = a
ans += 1
else:continue
print(ans) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.