# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1069171 | 2024-08-21T16:48:34 Z | hasan2006 | Arranging Shoes (IOI19_shoes) | C++17 | 190 ms | 282744 KB |
#include "shoes.h" #include <bits/stdc++.h> using namespace std; #define TL ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define rall(s) s.rbegin(),s.rend() #define all(s) s.begin(),s.end() #define pb push_back #define se second #define fi first #define ll long long #define ld long double #define YES cout<<"YES\n" #define Yes cout<<"Yes\n" #define yes cout<<"yes\n" #define NO cout<<"NO\n" #define No cout<<"No\n" #define no cout<<"no\n" const int N = 2e5 + 9 , mod = 1e9 + 7; ll a[N] , b[N] , dp[N]; vector<int>v[N]; void add(int x , int y){ while(x <= 200000){ dp[x] += y; x += x & (-x); } } ll get(int x){ ll ans = 0; while(x > 0) ans += dp[x] , x -= (x & (-x)); return ans; } deque<int>d[N][2]; //int press(string a){} ll count_swaps(vector<int>vc){ ll i , j , l , r , s = 0, f , n , m , x , y , k; n = vc.size(); for(i = 1; i <= n; i++){ a[i] = vc[i - 1]; b[i] = abs(a[i]); add(i , 1); d[b[i]][(a[i] > 0)].pb(i); } for(i = 1; i <= n; i++){ if(d[b[i]][(a[i] > 0)].size() && d[b[i]][(a[i] > 0)].front() == i){ x = d[b[i]][1 - (a[i] > 0)].front(); add(i , -1); d[b[i]][(a[i] > 0)].pop_front(); d[b[i]][1 - (a[i] > 0)].pop_front(); add(x , -1); s += get(x) + (a[i] > 0); } } return s; } /* int main(){ #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif cout<<count_swaps({2, 1, -1, -2}); }*/ // Author : حسن
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 102 ms | 277332 KB | Output is correct |
2 | Correct | 121 ms | 277332 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 102 ms | 277332 KB | Output is correct |
2 | Correct | 121 ms | 277332 KB | Output is correct |
3 | Correct | 114 ms | 277332 KB | Output is correct |
4 | Correct | 116 ms | 277328 KB | Output is correct |
5 | Correct | 114 ms | 277380 KB | Output is correct |
6 | Correct | 111 ms | 277332 KB | Output is correct |
7 | Correct | 115 ms | 277328 KB | Output is correct |
8 | Correct | 118 ms | 277516 KB | Output is correct |
9 | Correct | 116 ms | 277336 KB | Output is correct |
10 | Correct | 115 ms | 277492 KB | Output is correct |
11 | Correct | 116 ms | 277328 KB | Output is correct |
12 | Correct | 121 ms | 277548 KB | Output is correct |
13 | Correct | 115 ms | 277536 KB | Output is correct |
14 | Correct | 119 ms | 277328 KB | Output is correct |
15 | Correct | 117 ms | 277328 KB | Output is correct |
16 | Correct | 116 ms | 277332 KB | Output is correct |
17 | Correct | 110 ms | 277564 KB | Output is correct |
18 | Correct | 121 ms | 277524 KB | Output is correct |
19 | Correct | 116 ms | 277328 KB | Output is correct |
20 | Correct | 120 ms | 277328 KB | Output is correct |
21 | Correct | 126 ms | 277328 KB | Output is correct |
22 | Correct | 121 ms | 277424 KB | Output is correct |
23 | Correct | 112 ms | 277320 KB | Output is correct |
24 | Correct | 107 ms | 277332 KB | Output is correct |
25 | Correct | 117 ms | 277332 KB | Output is correct |
26 | Correct | 107 ms | 277328 KB | Output is correct |
27 | Correct | 103 ms | 277396 KB | Output is correct |
28 | Correct | 113 ms | 277412 KB | Output is correct |
29 | Correct | 112 ms | 277468 KB | Output is correct |
30 | Correct | 108 ms | 277328 KB | Output is correct |
31 | Correct | 97 ms | 277332 KB | Output is correct |
32 | Correct | 109 ms | 277532 KB | Output is correct |
33 | Correct | 100 ms | 277404 KB | Output is correct |
34 | Correct | 107 ms | 277332 KB | Output is correct |
35 | Correct | 112 ms | 277332 KB | Output is correct |
36 | Correct | 106 ms | 277452 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 102 ms | 277332 KB | Output is correct |
2 | Correct | 121 ms | 277332 KB | Output is correct |
3 | Correct | 105 ms | 277332 KB | Output is correct |
4 | Correct | 100 ms | 277356 KB | Output is correct |
5 | Correct | 116 ms | 277320 KB | Output is correct |
6 | Correct | 115 ms | 277332 KB | Output is correct |
7 | Correct | 123 ms | 277332 KB | Output is correct |
8 | Correct | 116 ms | 277372 KB | Output is correct |
9 | Correct | 113 ms | 277332 KB | Output is correct |
10 | Correct | 115 ms | 277332 KB | Output is correct |
11 | Correct | 117 ms | 277324 KB | Output is correct |
12 | Correct | 112 ms | 277492 KB | Output is correct |
13 | Correct | 111 ms | 277328 KB | Output is correct |
14 | Correct | 113 ms | 277328 KB | Output is correct |
15 | Correct | 114 ms | 277332 KB | Output is correct |
16 | Correct | 115 ms | 277516 KB | Output is correct |
17 | Correct | 119 ms | 277492 KB | Output is correct |
18 | Correct | 136 ms | 277588 KB | Output is correct |
19 | Correct | 136 ms | 277840 KB | Output is correct |
20 | Correct | 129 ms | 277988 KB | Output is correct |
21 | Correct | 140 ms | 277840 KB | Output is correct |
22 | Correct | 155 ms | 282744 KB | Output is correct |
23 | Correct | 143 ms | 282708 KB | Output is correct |
24 | Correct | 161 ms | 282704 KB | Output is correct |
25 | Correct | 164 ms | 282456 KB | Output is correct |
26 | Correct | 160 ms | 282708 KB | Output is correct |
27 | Correct | 149 ms | 282448 KB | Output is correct |
28 | Correct | 158 ms | 282708 KB | Output is correct |
29 | Correct | 149 ms | 282704 KB | Output is correct |
30 | Correct | 157 ms | 282704 KB | Output is correct |
31 | Correct | 150 ms | 282736 KB | Output is correct |
32 | Correct | 168 ms | 282708 KB | Output is correct |
33 | Correct | 157 ms | 282428 KB | Output is correct |
34 | Correct | 157 ms | 282708 KB | Output is correct |
35 | Correct | 118 ms | 277484 KB | Output is correct |
36 | Correct | 121 ms | 277328 KB | Output is correct |
37 | Correct | 154 ms | 282688 KB | Output is correct |
38 | Correct | 149 ms | 282704 KB | Output is correct |
39 | Correct | 160 ms | 282556 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 114 ms | 277496 KB | Output is correct |
2 | Correct | 119 ms | 277488 KB | Output is correct |
3 | Correct | 120 ms | 277504 KB | Output is correct |
4 | Correct | 109 ms | 277344 KB | Output is correct |
5 | Correct | 175 ms | 281852 KB | Output is correct |
6 | Correct | 159 ms | 281736 KB | Output is correct |
7 | Correct | 190 ms | 281876 KB | Output is correct |
8 | Correct | 155 ms | 282704 KB | Output is correct |
9 | Correct | 175 ms | 281884 KB | Output is correct |
10 | Correct | 168 ms | 281684 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 102 ms | 277332 KB | Output is correct |
2 | Correct | 121 ms | 277332 KB | Output is correct |
3 | Correct | 114 ms | 277332 KB | Output is correct |
4 | Correct | 116 ms | 277328 KB | Output is correct |
5 | Correct | 114 ms | 277380 KB | Output is correct |
6 | Correct | 111 ms | 277332 KB | Output is correct |
7 | Correct | 115 ms | 277328 KB | Output is correct |
8 | Correct | 118 ms | 277516 KB | Output is correct |
9 | Correct | 116 ms | 277336 KB | Output is correct |
10 | Correct | 115 ms | 277492 KB | Output is correct |
11 | Correct | 116 ms | 277328 KB | Output is correct |
12 | Correct | 121 ms | 277548 KB | Output is correct |
13 | Correct | 115 ms | 277536 KB | Output is correct |
14 | Correct | 119 ms | 277328 KB | Output is correct |
15 | Correct | 117 ms | 277328 KB | Output is correct |
16 | Correct | 116 ms | 277332 KB | Output is correct |
17 | Correct | 110 ms | 277564 KB | Output is correct |
18 | Correct | 121 ms | 277524 KB | Output is correct |
19 | Correct | 116 ms | 277328 KB | Output is correct |
20 | Correct | 120 ms | 277328 KB | Output is correct |
21 | Correct | 126 ms | 277328 KB | Output is correct |
22 | Correct | 121 ms | 277424 KB | Output is correct |
23 | Correct | 112 ms | 277320 KB | Output is correct |
24 | Correct | 107 ms | 277332 KB | Output is correct |
25 | Correct | 117 ms | 277332 KB | Output is correct |
26 | Correct | 107 ms | 277328 KB | Output is correct |
27 | Correct | 103 ms | 277396 KB | Output is correct |
28 | Correct | 113 ms | 277412 KB | Output is correct |
29 | Correct | 112 ms | 277468 KB | Output is correct |
30 | Correct | 108 ms | 277328 KB | Output is correct |
31 | Correct | 97 ms | 277332 KB | Output is correct |
32 | Correct | 109 ms | 277532 KB | Output is correct |
33 | Correct | 100 ms | 277404 KB | Output is correct |
34 | Correct | 107 ms | 277332 KB | Output is correct |
35 | Correct | 112 ms | 277332 KB | Output is correct |
36 | Correct | 106 ms | 277452 KB | Output is correct |
37 | Correct | 122 ms | 277328 KB | Output is correct |
38 | Correct | 117 ms | 277328 KB | Output is correct |
39 | Correct | 132 ms | 277520 KB | Output is correct |
40 | Correct | 115 ms | 277328 KB | Output is correct |
41 | Correct | 118 ms | 277412 KB | Output is correct |
42 | Correct | 113 ms | 277452 KB | Output is correct |
43 | Correct | 113 ms | 277436 KB | Output is correct |
44 | Correct | 116 ms | 277328 KB | Output is correct |
45 | Correct | 113 ms | 277480 KB | Output is correct |
46 | Correct | 107 ms | 277480 KB | Output is correct |
47 | Correct | 131 ms | 277568 KB | Output is correct |
48 | Correct | 114 ms | 277340 KB | Output is correct |
49 | Correct | 110 ms | 277412 KB | Output is correct |
50 | Correct | 127 ms | 277584 KB | Output is correct |
51 | Correct | 139 ms | 277584 KB | Output is correct |
52 | Correct | 115 ms | 277416 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 102 ms | 277332 KB | Output is correct |
2 | Correct | 121 ms | 277332 KB | Output is correct |
3 | Correct | 114 ms | 277332 KB | Output is correct |
4 | Correct | 116 ms | 277328 KB | Output is correct |
5 | Correct | 114 ms | 277380 KB | Output is correct |
6 | Correct | 111 ms | 277332 KB | Output is correct |
7 | Correct | 115 ms | 277328 KB | Output is correct |
8 | Correct | 118 ms | 277516 KB | Output is correct |
9 | Correct | 116 ms | 277336 KB | Output is correct |
10 | Correct | 115 ms | 277492 KB | Output is correct |
11 | Correct | 116 ms | 277328 KB | Output is correct |
12 | Correct | 121 ms | 277548 KB | Output is correct |
13 | Correct | 115 ms | 277536 KB | Output is correct |
14 | Correct | 119 ms | 277328 KB | Output is correct |
15 | Correct | 117 ms | 277328 KB | Output is correct |
16 | Correct | 116 ms | 277332 KB | Output is correct |
17 | Correct | 110 ms | 277564 KB | Output is correct |
18 | Correct | 121 ms | 277524 KB | Output is correct |
19 | Correct | 116 ms | 277328 KB | Output is correct |
20 | Correct | 120 ms | 277328 KB | Output is correct |
21 | Correct | 126 ms | 277328 KB | Output is correct |
22 | Correct | 121 ms | 277424 KB | Output is correct |
23 | Correct | 112 ms | 277320 KB | Output is correct |
24 | Correct | 107 ms | 277332 KB | Output is correct |
25 | Correct | 117 ms | 277332 KB | Output is correct |
26 | Correct | 107 ms | 277328 KB | Output is correct |
27 | Correct | 103 ms | 277396 KB | Output is correct |
28 | Correct | 113 ms | 277412 KB | Output is correct |
29 | Correct | 112 ms | 277468 KB | Output is correct |
30 | Correct | 108 ms | 277328 KB | Output is correct |
31 | Correct | 97 ms | 277332 KB | Output is correct |
32 | Correct | 109 ms | 277532 KB | Output is correct |
33 | Correct | 100 ms | 277404 KB | Output is correct |
34 | Correct | 107 ms | 277332 KB | Output is correct |
35 | Correct | 112 ms | 277332 KB | Output is correct |
36 | Correct | 106 ms | 277452 KB | Output is correct |
37 | Correct | 105 ms | 277332 KB | Output is correct |
38 | Correct | 100 ms | 277356 KB | Output is correct |
39 | Correct | 116 ms | 277320 KB | Output is correct |
40 | Correct | 115 ms | 277332 KB | Output is correct |
41 | Correct | 123 ms | 277332 KB | Output is correct |
42 | Correct | 116 ms | 277372 KB | Output is correct |
43 | Correct | 113 ms | 277332 KB | Output is correct |
44 | Correct | 115 ms | 277332 KB | Output is correct |
45 | Correct | 117 ms | 277324 KB | Output is correct |
46 | Correct | 112 ms | 277492 KB | Output is correct |
47 | Correct | 111 ms | 277328 KB | Output is correct |
48 | Correct | 113 ms | 277328 KB | Output is correct |
49 | Correct | 114 ms | 277332 KB | Output is correct |
50 | Correct | 115 ms | 277516 KB | Output is correct |
51 | Correct | 119 ms | 277492 KB | Output is correct |
52 | Correct | 136 ms | 277588 KB | Output is correct |
53 | Correct | 136 ms | 277840 KB | Output is correct |
54 | Correct | 129 ms | 277988 KB | Output is correct |
55 | Correct | 140 ms | 277840 KB | Output is correct |
56 | Correct | 155 ms | 282744 KB | Output is correct |
57 | Correct | 143 ms | 282708 KB | Output is correct |
58 | Correct | 161 ms | 282704 KB | Output is correct |
59 | Correct | 164 ms | 282456 KB | Output is correct |
60 | Correct | 160 ms | 282708 KB | Output is correct |
61 | Correct | 149 ms | 282448 KB | Output is correct |
62 | Correct | 158 ms | 282708 KB | Output is correct |
63 | Correct | 149 ms | 282704 KB | Output is correct |
64 | Correct | 157 ms | 282704 KB | Output is correct |
65 | Correct | 150 ms | 282736 KB | Output is correct |
66 | Correct | 168 ms | 282708 KB | Output is correct |
67 | Correct | 157 ms | 282428 KB | Output is correct |
68 | Correct | 157 ms | 282708 KB | Output is correct |
69 | Correct | 118 ms | 277484 KB | Output is correct |
70 | Correct | 121 ms | 277328 KB | Output is correct |
71 | Correct | 154 ms | 282688 KB | Output is correct |
72 | Correct | 149 ms | 282704 KB | Output is correct |
73 | Correct | 160 ms | 282556 KB | Output is correct |
74 | Correct | 114 ms | 277496 KB | Output is correct |
75 | Correct | 119 ms | 277488 KB | Output is correct |
76 | Correct | 120 ms | 277504 KB | Output is correct |
77 | Correct | 109 ms | 277344 KB | Output is correct |
78 | Correct | 175 ms | 281852 KB | Output is correct |
79 | Correct | 159 ms | 281736 KB | Output is correct |
80 | Correct | 190 ms | 281876 KB | Output is correct |
81 | Correct | 155 ms | 282704 KB | Output is correct |
82 | Correct | 175 ms | 281884 KB | Output is correct |
83 | Correct | 168 ms | 281684 KB | Output is correct |
84 | Correct | 122 ms | 277328 KB | Output is correct |
85 | Correct | 117 ms | 277328 KB | Output is correct |
86 | Correct | 132 ms | 277520 KB | Output is correct |
87 | Correct | 115 ms | 277328 KB | Output is correct |
88 | Correct | 118 ms | 277412 KB | Output is correct |
89 | Correct | 113 ms | 277452 KB | Output is correct |
90 | Correct | 113 ms | 277436 KB | Output is correct |
91 | Correct | 116 ms | 277328 KB | Output is correct |
92 | Correct | 113 ms | 277480 KB | Output is correct |
93 | Correct | 107 ms | 277480 KB | Output is correct |
94 | Correct | 131 ms | 277568 KB | Output is correct |
95 | Correct | 114 ms | 277340 KB | Output is correct |
96 | Correct | 110 ms | 277412 KB | Output is correct |
97 | Correct | 127 ms | 277584 KB | Output is correct |
98 | Correct | 139 ms | 277584 KB | Output is correct |
99 | Correct | 115 ms | 277416 KB | Output is correct |
100 | Correct | 114 ms | 277332 KB | Output is correct |
101 | Correct | 117 ms | 277844 KB | Output is correct |
102 | Correct | 133 ms | 277844 KB | Output is correct |
103 | Correct | 171 ms | 281680 KB | Output is correct |
104 | Correct | 157 ms | 281684 KB | Output is correct |
105 | Correct | 166 ms | 281680 KB | Output is correct |
106 | Correct | 168 ms | 281876 KB | Output is correct |
107 | Correct | 140 ms | 281680 KB | Output is correct |
108 | Correct | 150 ms | 281684 KB | Output is correct |
109 | Correct | 151 ms | 282704 KB | Output is correct |
110 | Correct | 149 ms | 282548 KB | Output is correct |
111 | Correct | 158 ms | 281684 KB | Output is correct |
112 | Correct | 169 ms | 281684 KB | Output is correct |
113 | Correct | 137 ms | 281684 KB | Output is correct |
114 | Correct | 165 ms | 281680 KB | Output is correct |
115 | Correct | 161 ms | 281684 KB | Output is correct |