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
s809536403
p03612
u777283665
1570041759
Python
Python (3.4.3)
py
Runtime Error
79
13880
166
n = int(input()) p = [int(i)-1 for i in input().split()] ans = 0 for i in range(n): if p[i] == i: p[i], p[i+1] = p[i+1], p[i] ans += 1 print(ans)
s406320156
p03612
u094191970
1569954305
Python
Python (3.4.3)
py
Runtime Error
88
14008
358
n=int(input()) p=list(map(int,input().split())) cnt=0 for i in range(n): if p[i]==i+1: cnt+=1 x=1 if i==n: break while True: if p[i+x]!=i+1: temp_v=p[i+x] p[i+x]=p[i] p[i]=temp_v break ...
s025121845
p03612
u094191970
1569954241
Python
Python (3.4.3)
py
Runtime Error
86
14008
323
n=int(input()) p=list(map(int,input().split())) cnt=0 for i in range(n): if p[i]==i+1: cnt+=1 x=1 while True: if p[i+x]!=i+1: temp_v=p[i+x] p[i+x]=p[i] p[i]=temp_v break else: x+=1 print(c...
s720651067
p03612
u645250356
1569682159
Python
PyPy3 (2.4.0)
py
Runtime Error
256
57192
579
from collections import Counter,defaultdict,deque import sys,heapq,bisect,math,itertools,string,queue sys.setrecursionlimit(10**8) mod = 10**9+7 def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) def inpl_str(): return list(sys.stdin.readline().split()) def inpln...
s346025087
p03612
u665038048
1569474724
Python
Python (3.4.3)
py
Runtime Error
72
14008
163
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)
s433693392
p03612
u433532588
1569374769
Python
Python (3.4.3)
py
Runtime Error
76
14068
367
import sys input = sys.stdin.readline sys.setrecursionlimit(2147483647) INF=float("inf") MOD=10**9+7 # A = [ int(input()) for _ in range(N) ] ############################## N = int(input()) P = list(map(int,input().split())) count = 0 for i in range(N): if P[i] == i+1: x = P[i] P[i] = P[i+1] ...
s427668366
p03612
u745223262
1569097282
Python
Python (3.4.3)
py
Runtime Error
77
13880
263
n = int(input()) p = list(map(int, input().split())) cnt = 0 for i in range(n): if p[i] == i + 1: if p[i - 1] == i + 1: p[i], p[i - 1] = p[i - 1], p[i] else: p[i], p[i + 1] = p[i + 1], p[i] cnt += 1 print(cnt)
s447638653
p03612
u693694535
1568853856
Python
Python (3.4.3)
py
Runtime Error
77
14008
156
N=int(input()) p=list(map(int,input().split())) M=0 for i in range(N): if p[i]==i+1: p[i],p[i+1]=p[i+1],p[i] M+=1 print(M)
s696183596
p03612
u663710122
1568575465
Python
Python (3.4.3)
py
Runtime Error
75
14008
194
N = int(input()) P = list(map(int, input().split())) res = 0 for i in range(N): if P[i] == i + 1: res += 1 if i < N: P[i], P[i + 1] = P[i + 1], P[i] print(res)
s133066680
p03612
u663710122
1568575385
Python
Python (3.4.3)
py
Runtime Error
71
14008
172
N = int(input()) P = list(map(int, input().split())) res = 0 for i in range(N): if P[i] == i + 1: res += 1 P[i], P[i + 1] = P[i + 1], P[i] print(res)
s025645151
p03612
u668705838
1568382324
Python
Python (3.4.3)
py
Runtime Error
69
14008
172
n = int(input()) p = list(map(int, input().split())) count = 0 for idx,i in enumerate(p): if i == idx+1: p[idx],p[idx+1] = p[idx+1],i count += 1 print(count)
s656704768
p03612
u623687794
1568077316
Python
PyPy3 (2.4.0)
py
Runtime Error
175
38256
177
n=int(input().split()) l=list(map(int,input().split())) cnt=0 for i in range(n-1): if (l[i] == i+1) and (l[i+1] == i+2): {l[i],l[i+1]}={l[i+1],l[i]} cnt+=1 print(cnt)
s761944923
p03612
u623687794
1568077236
Python
PyPy3 (2.4.0)
py
Runtime Error
175
38256
191
n=int(input().split()) l=list(map(int,input().split())) cnt=0 for i in range(n-1): if l[i] == i+1 and l[i+1] == i+2: l[i]=change change=l[i+1] l[i+1]=l[i] cnt+=1 print(cnt)
s419952673
p03612
u623687794
1568077185
Python
PyPy3 (2.4.0)
py
Runtime Error
166
38384
172
n=int(input().split()) l=list(map(int,input().split())) cnt=0 for i in range(n-1): if l[i] == i+1 and l[i+1] == i+2: {l[i],l[i+1]}={l[i+1],l[i]} cnt+=1 print(cnt)
s079595188
p03612
u625963200
1568023377
Python
Python (3.4.3)
py
Runtime Error
103
14008
255
n=int(input()) P=list(map(int,input().split())) ans=0 if P[0]==1: P[0]=P[1] P[1]=1 ans+=1 for i in range(1,n): if P[i]==i+1: if P[i+1]!=i+2: P[i]=P[i+1] P[i+1]=i+1 else: P[i]=P[i-1] P[i-1]=i+1 ans+=1 print(ans)
s270659894
p03612
u625963200
1568023270
Python
Python (3.4.3)
py
Runtime Error
109
14008
340
n=int(input()) P=list(map(int,input().split())) ans=0 if P[0]==1: P[0]=P[1] P[1]=1 ans+=1 while True: flag=True for i in range(1,n): if P[i]==i+1: if P[i+1]!=i+2: P[i]=P[i+1] P[i+1]=i+1 else: P[i]=P[i-1] P[i-1]=i+1 ans+=1 flag=False if flag==True: ...
s347011948
p03612
u625963200
1568023059
Python
Python (3.4.3)
py
Runtime Error
86
13880
263
n=int(input()) P=list(map(int,input().split())) ans=0 if P[0]==1: P[0]=P[1] P[1]=1 ans+=1 while True: flag=True for i in range(1,n): if P[i]==i+1: P[i]=P[i+1] P[i+1]=i+1 ans+=1 flag=False if flag==True: break print(ans)
s826747874
p03612
u827202523
1567963553
Python
PyPy3 (2.4.0)
py
Runtime Error
179
38384
291
n = input().split() nums = list(map(int, input.split())) flag = 0 ans = 0 for i, num in enumerate(nums): if i == num: if flag: ans += 1 flag = 0 else: flag = 1 else: if flag == 1: ans += 1 flag = 0 if flag == 1: ans += 1 print(ans)
s667253234
p03612
u267683315
1566604849
Python
Python (3.4.3)
py
Runtime Error
17
2940
205
n=int(input()) alist = [int(i) for i in input().split()] ans=0 for i in range(n-1): if alist[i]==i+1: temp=alist[i+1] alist[i+1]=alist[i] alist[i]=temp ans+=1 if alist[n-1]=n: ans+=1 print(ans)
s834600451
p03612
u267683315
1566604710
Python
Python (3.4.3)
py
Runtime Error
77
13880
177
n=int(input()) alist = [int(i) for i in input().split()] ans=0 for i in range(n): if alist[i]==i+1: temp=alist[i+1] alist[i+1]=alist[i] alist[i]=temp ans+=1 print(ans)
s321065003
p03612
u997113115
1565999915
Python
Python (3.4.3)
py
Runtime Error
69
14008
248
N = int(input()) p = list(map(int, input().split())) ans = 0 flag = False for i in range(N): if flag: n = p[i+1] else: n = p[i] if n == i+1: ans += 1 flag = True else: flag = False print(ans)
s260566434
p03612
u480138356
1565130681
Python
Python (3.4.3)
py
Runtime Error
61
14004
391
# import sys # input = sys.stdin.readline def main(): N = int(input()) p = list(map(int, input().split())) ans = 0 i = 0 # while i < N: for i in range(N): if i+1 == p[i]: tmp = p[i] p[i] = p[i+1] p[i+1] = tmp ans += 1 # i += 1...
s354115198
p03612
u480138356
1565130409
Python
Python (3.4.3)
py
Runtime Error
57
13876
387
import sys input = sys.stdin.readline def main(): N = int(input()) p = list(map(int, input().split())) ans = 0 i = 0 # while i < N: for i in range(N): if i+1 == p[i]: tmp = p[i] p[i] = p[i+1] p[i+1] = tmp ans += 1 # i += 1 ...
s447349276
p03612
u480138356
1565130273
Python
Python (3.4.3)
py
Runtime Error
60
13876
358
import sys input = sys.stdin.readline def main(): N = int(input()) p = list(map(int, input().split())) ans = 0 i = 0 while i < N: if i+1 == p[i]: tmp = p[i] p[i] = p[i+1] p[i+1] = tmp ans += 1 i += 1 i += 1 print(ans) ...
s398176109
p03612
u947883560
1564944920
Python
Python (3.4.3)
py
Runtime Error
75
14008
773
#!/usr/bin/env python3 import sys INF = float("inf") def solve(N: int, p: "List[int]"): counter = 0 i = 0 while i < N: if i+1 == p[i]: if i+2 == p[i+1]: counter += 1 i += 2 continue else: counter += 1 ...
s140202444
p03612
u698176039
1564779236
Python
Python (3.4.3)
py
Runtime Error
73
14008
297
N = int(input()) P = list(map(int,input().split())) #PS = [i for i in range(1,N+1)] cnt = 0 i = 0 idx = [] while i < N: if P[i] == i+1: if P[i+1] == i+2: cnt += 1 i += 1 else: cnt += 1 i += 1 print(cnt)
s957372333
p03612
u960653324
1564591659
Python
Python (3.4.3)
py
Runtime Error
73
13880
163
N = int(input()) P = [int(i) for i in input().split()] count = 0 for i in range(N): if P[i] == i+1: P[i],P[i+1] = P[i+1],P[i] count += 1 print(count)
s815230460
p03612
u728566015
1563058797
Python
Python (3.4.3)
py
Runtime Error
64
14004
174
N = int(input()) p = list(map(int, input().split())) p.insert(0, -1) j = [0] * N for i in range(1, N + 1): if p[i] == i and j[i - 1] == 0: j[i] = 1 print(sum(j))
s129397044
p03612
u923712635
1560829070
Python
Python (3.4.3)
py
Runtime Error
72
13880
238
N = int(input()) p = [int(x) for x in input().split()] cnt = 0 flag = True for ind,i in enumerate(p): if(ind+1==i and flag): cnt+=1 if(p[ind+1]==ind+2): flag = False else: flag = True print(cnt)
s177235055
p03612
u895515293
1560054478
Python
Python (3.4.3)
py
Runtime Error
93
13880
239
N=int(input()) INL=list(map(int,input().split())) swp = 0 for i in range(0, N): if i+1 == INL[i]: INL[i] = INL[i] ^ INL[i+1] INL[i+1] = INL[i] ^ INL[i+1] INL[i] = INL[i] ^ INL[i+1] swp += 1 print(swp)
s666158617
p03612
u895515293
1560054380
Python
PyPy3 (2.4.0)
py
Runtime Error
204
52908
176
N=int(input()) INL=list(map(int,input().split())) swp = 0 for i in range(0, N): if i+1 == INL[i]: INL[i], INL[i+1] = INL[i+1], INL[i] swp += 1 print(swp)
s287991053
p03612
u895515293
1560054282
Python
Python (3.4.3)
py
Runtime Error
72
14008
176
N=int(input()) INL=list(map(int,input().split())) swp = 0 for i in range(0, N): if i+1 == INL[i]: INL[i], INL[i+1] = INL[i+1], INL[i] swp += 1 print(swp)
s919596551
p03612
u129836004
1559790649
Python
Python (3.4.3)
py
Runtime Error
73
13880
175
N = int(input()) ps = list(map(int, input().split())) ans = 0 for i in range(N): if ps[i] == i+1: ps[i] = ps[i+1] ps[i+1] = i+1 ans += 1 print(ans)
s469140688
p03612
u191829404
1559622230
Python
PyPy3 (2.4.0)
py
Runtime Error
224
56560
979
import math import copy from collections import defaultdict from collections import Counter from collections import deque # 直積 A={a, b, c}, B={d, e}:のとき,A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B) from itertools import product # 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n) from iterto...
s017773239
p03612
u677440371
1559431087
Python
Python (3.4.3)
py
Runtime Error
74
13880
248
N = int(input()) P = [int(i) for i in input().split()] ans = 0 for i,p in enumerate(P): if p == i+1: # print('i+1,p',i+1,p) tmp0 = P[i+1] P[i] = tmp0 P[i+1] = p ans += 1 # print('P',P) print(ans)
s982791841
p03612
u389910364
1559351993
Python
PyPy3 (2.4.0)
py
Runtime Error
279
65260
534
import bisect from collections import Counter, deque from fractions import gcd from functools import lru_cache from functools import reduce import functools import heapq import itertools import math import numpy as np import re import sys sys.setrecursionlimit(10000) INF = float('inf') N = int(sys.stdin.readline()) P...
s393638116
p03612
u350248178
1559332832
Python
Python (3.4.3)
py
Runtime Error
92
13880
297
n=int(input()) p=[int(i) for i in input().split()] ans=0 if p[0]==1: ans+=1 p[1]=1 for i in range(1,n): if p[i]==i+1: if p[i-1]==i: ans+=1 p[i]=i else: if p[i+1]!=i+2: ans+=1 p[i]=p[i-1] print(ans)
s712491800
p03612
u955251526
1558413587
Python
Python (3.4.3)
py
Runtime Error
1615
141060
210
n = int(input()) p = list(map(int, input().split())) ans = 0 for i in range(n-1): if p[i] == i+1: print(p) p[i], p[i+1] = p[i+1], p[i] ans += 1 if p[-1] == n: ans += 1 print(ans)
s398600453
p03612
u724742135
1556928393
Python
Python (3.4.3)
py
Runtime Error
75
13880
319
from sys import exit, stdin N = int(stdin.readline().rstrip()) A = [int(_) for _ in stdin.readline().rstrip().split()] count, ignore = 0, 0 for i, a in enumerate(A): if ignore == 1: ignore = 0 continue if a-1 == i: count += 1 if A[i+1] != i+1: ignore = 1 print(count)
s731405548
p03612
u798129018
1554762054
Python
PyPy3 (2.4.0)
py
Runtime Error
225
52908
173
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 else: continue print(ans)
s300221002
p03612
u430937688
1553642520
Python
Python (3.4.3)
py
Runtime Error
79
13880
238
input() nums = list(map(int, input().split())) lis = [num - (i + 1) for i, num in enumerate(nums)] cnt = 0 i = 0 while i < len(lis): if lis[i] == 0: cnt += 1 if lis[i + 1] == 0: i += 1 i += 1 print(cnt)
s667094789
p03612
u430937688
1553642221
Python
Python (3.4.3)
py
Runtime Error
81
14008
238
input() nums = list(map(int, input().split())) lis = [num - (i + 1) for i, num in enumerate(nums)] cnt = 0 i = 0 while i < len(lis): if lis[i] == 0: cnt += 1 if lis[i + 1] == 0: i += 1 i += 1 print(cnt)
s232962292
p03612
u619819312
1553639331
Python
Python (3.4.3)
py
Runtime Error
18
2940
245
n=int(input()) p=list(map(int,input().split())) c=0 for i in range(n): if i!=n-1 if p[i]==i+1: d=p[i+1] p[i+1]=p[i] p[i]=d c+=1 else: if p[i]==i+1: c+=1 print(c)
s082603053
p03612
u501952592
1553043653
Python
Python (3.4.3)
py
Runtime Error
72
14008
226
N = int(input()) p = list(map(int, input().split())) count = 0 for i in range(N): if p[i] == i+1: p[i], p[i+1] = p[i+1], p[i] count += 1 if p[N-1] == N: p[N-2], p[N-1] = p[N-1], p[N-2] count += 1 print(count)
s325691839
p03612
u037098269
1552857380
Python
Python (3.4.3)
py
Runtime Error
65
13880
169
n = int(input()) p_list = list(map(int, input().split())) cnt = 0 for i in range(n): if p_list[i] == i+1: p_list[i+1] = p_list[i] cnt += 1 print(cnt)
s738802556
p03612
u644778646
1551143828
Python
Python (3.4.3)
py
Runtime Error
85
14008
239
N = int(input()) p = list(map(int,input().split())) ans = 0 for i in range(1,N+1): if i == p[i-1]: ans += 1 k = 0 for i in range(1,N): i += k if i == p[i-1] and i+1 == p[i]: ans -= 1 k += 1 print(ans)
s182065276
p03612
u766684188
1550362167
Python
Python (3.4.3)
py
Runtime Error
73
13880
199
n=int(input()) P=list(map(int,input().split())) cnt=0 for i in range(n-1): if P[i]==i+1: tmp=P[i] P[i]=P[i+1] P[i+1]=tmp cnt+=1 if P[n]==n+1: cnt+=1 print(cnt)
s835491964
p03612
u179169725
1550286733
Python
PyPy3 (2.4.0)
py
Runtime Error
220
54188
242
N = int(input()) P = list(map(int, input().split())) ans = 0 # print(P) for i in range(N): if P[i] != int(i + 1): continue else: P[i], P[i + 1] = P[i + 1], P[i] # print(i + 1, P) ans += 1 print(ans)
s267375335
p03612
u179169725
1550286716
Python
Python (3.4.3)
py
Runtime Error
82
14004
242
N = int(input()) P = list(map(int, input().split())) ans = 0 # print(P) for i in range(N): if P[i] != int(i + 1): continue else: P[i], P[i + 1] = P[i + 1], P[i] # print(i + 1, P) ans += 1 print(ans)
s430432298
p03612
u174394352
1550038386
Python
PyPy3 (2.4.0)
py
Runtime Error
207
52908
138
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+1]=p[i] print(ans)
s200527677
p03612
u175034939
1549344884
Python
Python (3.4.3)
py
Runtime Error
83
14008
217
n = int(input()) a = list(map(int,input().split())) t = 0 cnt = 0 for i in range(n): if a[i] == i+1: t += 1 for i in range(0,n,2): if (a[i] == i+1) and (a[i+1] == i+2): cnt += 1 print(t-cnt)
s745924063
p03612
u178536051
1549166392
Python
PyPy3 (2.4.0)
py
Runtime Error
232
54172
298
import sys input = sys.stdin.readline N = int(input()) P = list(map(int, input().split())) cnt = 0 for i, p in enumerate(P): num = i + 1 if num != p: continue else: next = P[i+1] tmp = P[i] P[i] = P[i+1] P[i+1] = tmp cnt += 1 print(cnt)
s382909269
p03612
u587482466
1549165362
Python
Python (3.4.3)
py
Runtime Error
56
13812
336
import sys import math # -*- coding: utf-8 -*- n = int(input()) a = list(map(int, input().split())) # 整数 ##ラストが同一だったら先に入れ替えておく count = 0 ## 同一なら次と入れ替える for i in range(n ): if a[i] is i + 1: a[i], a[i + 1] = a[i + 1], a[i] count += 1 print(count)
s760708227
p03612
u427344224
1546484536
Python
Python (3.4.3)
py
Runtime Error
297
16996
1406
class UnionFind: def __init__(self, n): self.parent = [i for i in range(n + 1)] self.rank = [0 for _ in range(n + 1)] self.weight = [0 for _ in range(n + 1)] def find(self, x): if self.parent[x] == x: return x else: y = self.find(self.parent[x]) ...
s433694287
p03612
u198062737
1543592537
Python
Python (3.4.3)
py
Runtime Error
92
13880
396
N = int(input()) p = [int(i) for i in input().split(" ")] ans = 0 for i in range(0,N): if p[i] == (i+1): if p[i+1] == (i+2): t = p[i] p[i] = p[i+1] p[i+1] = t ans += 1 else: ans += 1 d = -1 if i == N-1 else 1 t = p[...
s216058853
p03612
u198062737
1543592459
Python
Python (3.4.3)
py
Runtime Error
94
13880
396
N = int(input()) p = [int(i) for i in input().split(" ")] ans = 0 for i in range(0,N): if p[i] == (i+1): if p[i+1] == (i+1): t = p[i] p[i] = p[i+1] p[i+1] = t ans += 1 else: ans += 1 d = -1 if i == N-1 else 1 t = p[...
s966758876
p03612
u634208461
1542181023
Python
Python (3.4.3)
py
Runtime Error
1723
141056
271
N = int(input()) p = list(map(int, input().split())) i = 0 ans = 0 while(i < N - 1): print(p) print(' ' * (3 * i + 1) + str(i + 1)) if p[i] == i + 1: ans += 1 p[i], p[i + 1] = p[i + 1], p[i] i += 1 if p[N - 1] == N: ans += 1 print(ans)
s498640644
p03612
u270681687
1538477590
Python
Python (3.4.3)
py
Runtime Error
63
14008
151
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)
s317734057
p03612
u474270503
1535848296
Python
Python (3.4.3)
py
Runtime Error
103
14008
388
N=int(input()) p=list(map(int,input().split())) q=['x' for _ in range(N)] ans=0 for i in range(N): if p[i]!=i+1: q[i]='o' for i in range(N): if q[i]=='x': if i<N-1: p[i], p[i+1]=p[i+1], p[i] q[i+1]='o' else: p[i], p[i-1]=p[i-1], p[i] q[i-1]...
s533377340
p03612
u474270503
1535848194
Python
Python (3.4.3)
py
Runtime Error
100
14008
342
N=int(input()) p=list(map(int,input().split())) q=['x' for _ in range(N)] ans=0 for i in range(N): if p[i]!=i+1: q[i]='o' for i in range(N): if q[i]=='x': if i<N-1: p[i], p[i+1]=p[i+1], p[i] else: p[i], p[i-1]=p[i-1], p[i] q[i]='o' q[i+1]='o' ...
s076713401
p03612
u474270503
1535848139
Python
Python (3.4.3)
py
Runtime Error
100
14008
343
N=int(input()) p=list(map(int,input().split())) q=['x' for _ in range(N)] ans=0 for i in range(N): if p[i]!=i+1: q[i]='o' for i in range(N): if q[i]=='x': if i<N-1: p[i], p[i+1]=p[i+1], p[i] else: p[i], p[i-a1]=p[i-1], p[i] q[i]='o' q[i+1]='o' ...
s241003378
p03612
u474270503
1535847987
Python
Python (3.4.3)
py
Runtime Error
69
14008
345
N=int(input()) p=list(map(int,input().split())) q=['x' for _ in range(N)] ans=0 for i in range(N): if p[i]!=i+1: q[i]='o' for i in range(N-1): if q[i]=='x': if i<n-1: p[i], p[i+1]=p[i+1], p[i] else: p[i], p[i-a1]=p[i-1], p[i] q[i]='o' q[i+1]='o' ...
s679221565
p03612
u982762220
1531978062
Python
Python (3.4.3)
py
Runtime Error
77
14008
210
N = int(input()) P = list(map(int, input().split())) res = 0 for idx in range(len(P)): if P[idx] == idx + 1: if idx < N: P[idx], P[idx+1] = P[idx+1], P[idx] res += 1 print(res)
s368513540
p03612
u982762220
1531977553
Python
Python (3.4.3)
py
Runtime Error
70
13880
186
N = int(input()) P = list(map(int, input().split())) res = 0 for idx in range(len(P)): if P[idx] == idx + 1: P[idx], P[idx+1] = P[idx+1], P[idx] res += 1 print(res)
s808577099
p03612
u480847874
1526054549
Python
Python (3.4.3)
py
Runtime Error
61
14008
432
def m(): def is_satisfied(p): for i in range(N): if i+1 == p[i]: return False return True def swap(i): tmp = p[i] p[i] = p[i+1] p[i+1] = tmp N = int(input()) p = list(map(int, input().split())) if is_satisfied(p): return 0 cnt = 0 ...
s768952535
p03612
u075012704
1525305837
Python
Python (3.4.3)
py
Runtime Error
82
14008
249
N = int(input()) P = list(map(int, input().split())) ans = 0 for i in range(N): if P[i] == i+1: tmp = P[i] P[i] = P[i+1] P[i+1] = tmp ans += 1 for i in range(N): if P[i] == i+1: ans += 1 print(ans)
s297089419
p03612
u952708174
1524709118
Python
Python (3.4.3)
py
Runtime Error
44
13880
498
def d_derangement(N, P): ans = 0 is_target = True # 要素番号iはチェックする必要があるか否か for i in range(N): if P[i] == i + 1 and is_target: # p_i=iならp_{i+1}とスワップすれば条件を満たす ans += 1 is_target = False # i+1番目はチェックする必要がない else: is_target = True return ans N...
s135711001
p03612
u064408584
1524194227
Python
Python (3.4.3)
py
Runtime Error
72
14008
160
n=int(input()) a=list(map(int, input().split())) count=0 for i in range(len(a)): if a[i]==i+1: a[i],a[i+1]=a[i+1],a[i] count+=1 print(count)
s297307360
p03612
u214617707
1521158245
Python
Python (3.4.3)
py
Runtime Error
71
14008
180
n = int(input()) p = [0] + list(map(int, input().split())) num = 0 for i in range(1, n + 1): if i == p[i]: num += 1 p[i], p[i + 1] = p[i + 1], p[i] print(num)
s222940543
p03612
u497046426
1520558098
Python
Python (3.4.3)
py
Runtime Error
77
14008
332
N = int(input()) P = list(map(int, input().split())) dist = [P[i-1] - i for i in range(1, N+1)] count = 0 for i in range(N): if dist[i] == 0: count += 1 dist[i] -= 1 dist[i+1] += 1 elif i == N-1 and dist[i] == 0: count += 1 dist[i] += 1 dist[i-1] -= 1 ...
s999148640
p03612
u497046426
1520558013
Python
Python (3.4.3)
py
Runtime Error
77
14008
334
N = int(input()) P = list(map(int, input().split())) dist = [P[i-1] - i for i in range(1, N+1)] count = 0 for i in range(N): if dist[i] == 0: count += 1 dist[i] -= 1 dist[i+1] += 1 elif i == N-1 and dist[i+1] == 0: count += 1 dist[i] -= 1 dist[i+1] += 1 ...
s884686535
p03612
u865741247
1516565096
Python
Python (3.4.3)
py
Runtime Error
73
14008
203
N=int(input()) p=list(map(int,input().split(" "))) i=0 c=0 while i<N: if p[i]==i+1: if i<N and p[i+1]==i+2: c+=1 i+=1 else: c+=1 i+=1 print(c)
s197318565
p03612
u926678805
1507690307
Python
Python (3.4.3)
py
Runtime Error
79
13880
173
input() data=list(map(int,input().split())) count=0 for i in range(len(data)): if data[i]==i+1: data[i],data[i+1]=data[i+1],data[i] count+=1 print(count)
s455929438
p03612
u663230781
1505345878
Python
Python (3.4.3)
py
Runtime Error
40
14008
603
def solve(n,p): memo = {} items = [(0,p)] result = 0 while items: step, p = items.pop(0) if check(n,p): result = step break else: for i in range(n-1): candidate = tuple( p[:i] +[ p[i+1] ,p[i]] + p[i+2:] ) if...
s529358995
p03612
u663230781
1505345232
Python
Python (3.4.3)
py
Runtime Error
40
14008
565
def solve(n,p): memo = {} items = [(0,p)] result = 0 while items: step, p = items.pop(0) if check(n,p): result = step break else: for i in range(n-1): candidate = tuple( p[:i] +[ p[i+1] ,p[i]] + p[i+2:] ) if...
s257645932
p03612
u663230781
1505345188
Python
Python (3.4.3)
py
Runtime Error
25
10420
558
def solve(n,p): memo = {} items = [(0,p)] result = 0 while items: step, p = items.pop(0) if check(n,p): result = step break else: for i in range(n-1): candidate = tuple( p[:i] +[ p[i+1] ,p[i]] + p[i+2:] ) if...
s725635008
p03612
u050708958
1505003800
Python
Python (3.4.3)
py
Runtime Error
73
13880
160
input() nums = [int(i)-1 for i in input().split()] c = 0 for i, j in enumerate(nums): if i == j: nums[i], nums[i+1] = nums[i+1], nums[i] c += 1 print(c)
s852537158
p03612
u410717334
1504929587
Python
Python (3.4.3)
py
Runtime Error
81
14008
264
N=int(input()) a=list(map(int,input().split())) c=0 d=[] for i in range(N): if(i+1==a[i]): d.append("x") else: d.append("o") for i in range(len(d)): if d[i]=="x": d[i]="o" d[i+1]="o" c+=1 print(c)
s364590560
p03612
u112465297
1504842468
Python
Python (3.4.3)
py
Runtime Error
85
14008
245
N = int(input()) a = list(map(int, input().split())) cnt=0 for i in range(len(a)): if i < len(a): if a[i] == i+1: inter=a[i] a[i]=a[i+1] a[i+1]=inter cnt +=1 continue print(cnt)
s318051281
p03612
u112465297
1504839838
Python
Python (3.4.3)
py
Runtime Error
93
13880
182
N=int(input()) a=list(map(int,input().split())) cnt=0 for i in range(len(a)): if a[i] == i+1: int=a[i+1] a[i]=a[i+1] a[i+1]=int cnt +=1 print(cnt)
s126878127
p03612
u566924053
1504835397
Python
Python (3.4.3)
py
Runtime Error
2104
14324
763
def has_match_with_index(ls, left_inx): for inx, item in enumerate(ls[left_inx:]): if inx + left_inx == item - 1: return True return False def swap(ls, left_inx): left_inx = get_left_inx(ls, left_inx) ls[left_inx], ls[left_inx + 1] = ls[left_inx + 1], ls[left_inx] return ls, l...
s481127424
p03612
u566924053
1504834739
Python
Python (3.4.3)
py
Runtime Error
2104
14324
622
def count_match_with_index(ls): cnt = 0 for inx, item in enumerate(ls): if inx == item - 1: cnt += 1 return cnt def swap(ls): left_inx = get_left_inx(ls) ls[left_inx], ls[left_inx + 1] = ls[left_inx + 1], ls[left_inx] return ls def get_left_inx(ls): for inx, item in e...
s294407238
p03612
u594377052
1504812466
Python
Python (2.7.6)
py
Runtime Error
90
11560
577
import sys test =False if test: N = 9 items = [1,2,4,9,5,8,7,3,6] else: N = int(raw_input()) items = raw_input().split() items = [int(item) for item in items] counter = 0 i = 0 if test: print items while i < N: if i + 1 == items[i]: tmp = items[i+1] items[i+1] = items[i] ...
s891515119
p03612
u058240079
1504530153
Python
Python (2.7.6)
py
Runtime Error
71
11304
185
n = int(raw_input()) l = map(int, raw_input().split()) ans = 0 i = 0 while i < n: if i+1 == l[i]: ans += 1 if i+2 == l[i+1]: i += 1 i += 1 print ans
s289552494
p03612
u992287017
1504493629
Python
Python (3.4.3)
py
Runtime Error
132
14008
652
if __name__ == '__main__': N = int(input()) p = list(map(int, input().split())) flag = [False] * 100000 cnt = 0 for i in range(p.__len__()): if p[i] == i+1: flag[i] = True for j in range(p.__len__()): if flag[j]: if flag[j+1]: p[j], p[j+1]...
s080632658
p03612
u992287017
1504493579
Python
Python (3.4.3)
py
Runtime Error
59
14008
673
if __name__ == '__main__': N = int(input()) p = list(map(int, input().split())) flag = [False] * 100000 cnt = 0 for i in range(p.__len__()): if p[i] == i+1: flag[i] = True for j in range(p.__len__()): chk(flag, p) if flag[j]: if flag[j+1]: ...
s737432300
p03612
u069868485
1504479504
Python
Python (3.4.3)
py
Runtime Error
90
10420
208
N=(int)(input()) p=(input()).split(' ') count=0 now=1 for k in p: if (int)(k)==now: p[now-1:(now+1 if now<len(p) else now-3)]=[p[now],p[now-1]] count=count+1 now=now+1 print(count)
s604220324
p03612
u069868485
1504479199
Python
Python (3.4.3)
py
Runtime Error
79
10420
181
N=(int)(input()) p=(input()).split(' ') count=0 now=1 for k in p: if (int)(k)==now: p[now-1:now+1]=[p[now],p[now-1]] count=count+1 now=now+1 print(count)
s163793600
p03612
u665415433
1504464602
Python
Python (3.4.3)
py
Runtime Error
56
14008
260
def solve(): N = int(input()) p = list(map(int, input().split())) count = int(0) for i in range(N): if p[i] == i+1: p[i], p[i+1] = p[i+1], p[i] count += 1 print(count) if __name__ == '__main__': solve()
s141214710
p03612
u177756077
1504459875
Python
Python (3.4.3)
py
Runtime Error
25
10420
205
N=int(input().strip()) p=map(int,input().split()) ans=0 flag=0 for i in range(len(p)): if i+1 == p[i]: if flag==0: ans+=1 else: # if flag == 1 flag=0 print(ans)
s670883516
p03612
u165538494
1504455951
Python
Python (3.4.3)
py
Runtime Error
17
2940
269
n=int(input()) array=list(map(int,input().split())) ans=0 flag=0 for i in range(len(array)): if i+1==array[i]: if flag==0: ans+=1 if(i<len(array)-1&&array[i+1]==i+2): flag=1 else: flag=0 print(ans)
s823560578
p03612
u665415433
1504455724
Python
Python (3.4.3)
py
Runtime Error
56
14008
260
def solve(): N = int(input()) p = list(map(int, input().split())) count = int(0) for i in range(N): if p[i] == i+1: p[i], p[i+1] = p[i+1], p[i] count += 1 print(count) if __name__ == '__main__': solve()
s490062410
p03612
u665415433
1504455333
Python
Python (3.4.3)
py
Runtime Error
18
4724
162
N = int(input()) p = list(map(int,input().split)) count = 0 for i in range(N): if p[i] == i: p[i],p[i+1] = p[i+1],p[i] count += 1 print(count)
s147820647
p03612
u665415433
1504455221
Python
Python (3.4.3)
py
Runtime Error
18
4724
248
def solve(): N = int(input()) p = list(map(int,input().split)) count = 0 for i in range(N): if p[i] == i: p[i],p[i+1] = p[i+1],p[i] count += 1 print(count) if __name__ == '__main__': solve()
s966277339
p03612
u981169657
1504435774
Python
Python (3.4.3)
py
Runtime Error
81
14008
291
N = int(input()) p = list(map(int, input().split())) plen = len(p) count = 0 for i in range(plen): if p[i] == N - 1: p[i - 1], p[i] = p[i], p[i - 1] count += 1 elif p[i] == i + 1: p[i], p[i + 1] = p[i + 1], p[i] count += 1 print(count)
s814431104
p03612
u981169657
1504435660
Python
Python (3.4.3)
py
Runtime Error
84
14008
291
N = int(input()) p = list(map(int, input().split())) plen = len(p) count = 0 for i in range(plen): if p[i] == N - 1: p[i], p[i - 1] = p[i - 1], p[i] count += 1 elif p[i] == i + 1: p[i], p[i + 1] = p[i + 1], p[i] count += 1 print(count)
s568789481
p03612
u981169657
1504434890
Python
Python (3.4.3)
py
Runtime Error
53
14008
322
N = int(input()) p = list(map(int, input().split())) plen = len(p) count = 0 for i in range(1, plen): if p[i] == i : if p[i] == N: p[i -1], p[i] = p[i], p[i - 1] count += 1 break else: p[i], p[i + 1] = p[i + 1], p[i] count += 1 print(count...
s806511339
p03612
u981169657
1504434446
Python
Python (3.4.3)
py
Runtime Error
73
13880
194
N = int(input()) p = list(map(int, input().split())) plen = len(p) count = 0 for i in range(plen): if p[i] == i + 1: p[i], p[i + 1] = p[i + 1], p[i] count += 1 print(count)
s375048927
p03612
u981169657
1504434178
Python
Python (3.4.3)
py
Runtime Error
70
14008
194
N = int(input()) p = list(map(int, input().split())) plen = len(p) count = 0 for i in range(plen): if p[i] == i + 1: p[i], p[i + 1] = p[i + 1], p[i] count += 1 print(count)
s455004516
p03612
u943004959
1504411079
Python
Python (3.4.3)
py
Runtime Error
1761
141184
525
def swap(a, b): tmp = a a = b b = tmp return a, b def solve(): # 072D- Derangement N = int(input()) p = list(map(int, input().split(" "))) p.insert(0, 1) cnt = 0 for i in range(1, N+1): if i == p[i]: p[i], p[i+1] = swap(p[i], p[i+1]) cnt += 1 ...