Submission #52593619
Source Code Expand
Copy
#ABC350_20240420_CN=int(input())A=list(map(int,input().split()))D={}for i in range(N):D[A[i]]=i+1ans=[]#print(D)#D K=数字、値=A上の位置for i in range(N-1):#print(A[i],i+1)if(A[i]!=i+1): #Aの位置と値にずれがあったら#本操作で元(i+1)と先(D[i+1])を入れ替える#MOTOV(A[i])SAKIV(A[D[i]])#MOTOP(i+1),SAKIP(D[A[i]])#MOTOP=i+1SAKIP=D[i+1]MOTOV=A[i]SAKIV=A[SAKIP-1]#print(i+1,SAKIP,MOTOV,SAKIV)ans.append((i+1,SAKIP))
#ABC350_20240420_C N=int(input()) A=list(map(int,input().split())) D={} for i in range(N): D[A[i]]=i+1 ans=[] #print(D) #D K=数字、値=A上の位置 for i in range(N-1): #print(A[i],i+1) if(A[i]!=i+1): #Aの位置と値にずれがあったら #本操作で元(i+1)と先(D[i+1])を入れ替える #MOTOV(A[i])SAKIV(A[D[i]]) #MOTOP(i+1),SAKIP(D[A[i]]) #MOTOP=i+1 SAKIP=D[i+1] MOTOV=A[i] SAKIV=A[SAKIP-1] #print(i+1,SAKIP,MOTOV,SAKIV) ans.append((i+1,SAKIP)) #Aの書き換え A[i]=SAKIV A[SAKIP-1]=MOTOV #Dの書き換え D[MOTOV]=SAKIP D[SAKIV]=i+1 #print(D) #print(A) print(len(ans)) for x,y in ans: print(x,y) #print(A)
Submission Info
Submission Time | |
---|---|
Task | C - Sort |
User | Konini |
Language | Python (PyPy 3.10-v7.3.12) |
Score | 300 |
Code Size | 811 Byte |
Status | AC |
Exec Time | 189 ms |
Memory | 148608 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt, sample_03.txt |
All | random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, sample_01.txt, sample_02.txt, sample_03.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
random_01.txt | AC | 187 ms | 148340 KB |
random_02.txt | AC | 162 ms | 137876 KB |
random_03.txt | AC | 188 ms | 148596 KB |
random_04.txt | AC | 81 ms | 86732 KB |
random_05.txt | AC | 189 ms | 148232 KB |
random_06.txt | AC | 138 ms | 131140 KB |
random_07.txt | AC | 55 ms | 76340 KB |
random_08.txt | AC | 56 ms | 76560 KB |
random_09.txt | AC | 96 ms | 143584 KB |
random_10.txt | AC | 84 ms | 122888 KB |
random_11.txt | AC | 138 ms | 148608 KB |
random_12.txt | AC | 97 ms | 108636 KB |
random_13.txt | AC | 189 ms | 148232 KB |
random_14.txt | AC | 104 ms | 105836 KB |
random_15.txt | AC | 187 ms | 148356 KB |
random_16.txt | AC | 138 ms | 131200 KB |
random_17.txt | AC | 154 ms | 147864 KB |
random_18.txt | AC | 78 ms | 86300 KB |
random_19.txt | AC | 156 ms | 148248 KB |
random_20.txt | AC | 97 ms | 104916 KB |
sample_01.txt | AC | 55 ms | 76460 KB |
sample_02.txt | AC | 55 ms | 76252 KB |
sample_03.txt | AC | 55 ms | 76336 KB |