# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
832213 | devariaota | Arranging Shoes (IOI19_shoes) | C++17 | 1085 ms | 3116 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define ioss ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define tup tuple<int, int, int>
#define pii pair<int, int>
#define fi first
#define se second
#define pub push_back
#define pob pop_back
ll count_swaps(vector<int> s) {
ll ans = 0;
for(int i = 0; i < s.size(); i++) {
if(s[i] == 0) continue;
if(s[i] < 0) {
ll cnt = 0;
for(int j = i+1; j < s.size(); j++) {
if(s[j] == 0) {
cnt++;
continue;
}
if(s[j] == -s[i]) {
ans += 1ll*(j-i-1) - cnt;
s[i] = s[j] = 0;
break;
}
}
}
else {
ll cnt = 0;
for(int j = i+1; j < s.size(); j++) {
if(s[j] == 0) {
cnt++;
continue;
}
if(s[j] == -s[i]) {
ans += 1ll*(j-i) - cnt;
s[i] = s[j] = 0;
break;
}
}
}
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |