# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
143263 | 2019-08-13T12:54:10 Z | daniel920712 | Arranging Shoes (IOI19_shoes) | C++14 | 35 ms | 3640 KB |
#include <iostream> #include <stdio.h> #include <vector> #include <algorithm> #include <assert.h> using namespace std; int S1[1005]; bool F(int a,int b) { return a<b; } long long count_swaps(std::vector<int> S) { long long ans1=0,ans2=0,ans3=1e18,ans4=1e18,N=S.size(),i,j,k,now=0; long long t; for(i=0;i<N;i++) S1[i]=S[i]; for(i=0;i<N/2;i++) { for(j=2*i;j<N;j++) { if(S1[j]<0) { t=0-S1[j]; for(k=j;k>2*i;k--) { ans1++; swap(S1[k],S1[k-1]); } break; } } for(j=2*i+1;j<N;j++) { if(S1[j]==t) { for(k=j;k>2*i+1;k--) { ans1++; swap(S1[k],S1[k-1]); } break; } } } ans2=0; for(i=0;i<N;i++) S1[i]=S[i]; for(i=0;i<N/2;i++) { for(j=2*i;j<N;j++) { if(S1[j]>0) { t=0-S1[j]; break; } } for(j=2*i;j<N;j++) { if(S1[j]==t) { for(k=j;k>2*i;k--) { ans2++; swap(S1[k],S1[k-1]); } break; } } for(j=2*i+1;j<N;j++) { if(S1[j]==0-t) { for(k=j;k>2*i+1;k--) { ans2++; swap(S1[k],S1[k-1]); } break; } } } ans3=0; for(i=0;i<N;i++) S1[i]=S[i]; for(i=0;i<N/2;i++) { for(j=N-2*i-1;j>=0;j--) { if(S1[j]>0) { t=0-S1[j]; for(k=j;k<N-2*i-1;k++) { ans3++; swap(S1[k],S1[k+1]); } break; } } for(j=N-2*i-2;j>=0;j--) { if(S1[j]==t) { for(k=j;k<N-2*i-2;k++) { ans3++; swap(S1[k],S1[k+1]); } break; } } /*for(j=0;j<N;j++) printf("%d ",S1[j]); printf("\n");*/ } //printf("%lld %lld %lld\n",ans1,ans2,ans3); return min(min(ans1,ans2),min(ans3,ans4)); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 380 KB | Output is correct |
9 | Correct | 2 ms | 256 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 256 KB | Output is correct |
12 | Correct | 2 ms | 256 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 380 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 2 ms | 376 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 376 KB | Output is correct |
20 | Correct | 2 ms | 380 KB | Output is correct |
21 | Correct | 2 ms | 380 KB | Output is correct |
22 | Correct | 2 ms | 380 KB | Output is correct |
23 | Correct | 2 ms | 376 KB | Output is correct |
24 | Incorrect | 2 ms | 256 KB | Output isn't correct |
25 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 256 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 256 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 2 ms | 256 KB | Output is correct |
17 | Correct | 2 ms | 376 KB | Output is correct |
18 | Runtime error | 3 ms | 504 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
19 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 252 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Runtime error | 35 ms | 3640 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 380 KB | Output is correct |
9 | Correct | 2 ms | 256 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 256 KB | Output is correct |
12 | Correct | 2 ms | 256 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 380 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 2 ms | 376 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 376 KB | Output is correct |
20 | Correct | 2 ms | 380 KB | Output is correct |
21 | Correct | 2 ms | 380 KB | Output is correct |
22 | Correct | 2 ms | 380 KB | Output is correct |
23 | Correct | 2 ms | 376 KB | Output is correct |
24 | Incorrect | 2 ms | 256 KB | Output isn't correct |
25 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 380 KB | Output is correct |
9 | Correct | 2 ms | 256 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 256 KB | Output is correct |
12 | Correct | 2 ms | 256 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 380 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 2 ms | 376 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 376 KB | Output is correct |
20 | Correct | 2 ms | 380 KB | Output is correct |
21 | Correct | 2 ms | 380 KB | Output is correct |
22 | Correct | 2 ms | 380 KB | Output is correct |
23 | Correct | 2 ms | 376 KB | Output is correct |
24 | Incorrect | 2 ms | 256 KB | Output isn't correct |
25 | Halted | 0 ms | 0 KB | - |