# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
310964 | saarang123 | Arranging Shoes (IOI19_shoes) | C++14 | 1055 ms | 3200 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;
using ll = long long;
using ld = long double;
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
template<class T> bool remin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool remax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());
ll count_swaps(vector<int> a) {
std::ios::sync_with_stdio(0);
std::cout.tie(0);
std::cin.tie(0);
ll i, j, n, m;
n = a.size() / 2;
//cin >> n;
//vector<int> a(2 * n);
//for(auto &x : a) cin >> x;
ll ans = 0;
for(i = 0; i < 2 * n; i += 2) {
int id = -1;
for(j = i; j < 2 * n; j++) {
if(a[j] < 0) {
id = j;
break;
}
}
for(j = id; j > i; j--) {
swap(a[j], a[j - 1]);
//cout << j << " " << j - 1 << endl;
ans++;
}
for(j = i + 1; j < 2 * n; j++) {
if(a[j] == - a[i]) {
id = j;
break;
}
}
for(j = id; j > i + 1; j--) {
swap(a[j], a[j - 1]);
//cout << j << " " << j - 1 << endl;
ans++;
}
//for(auto &x : a) cout << x << " "; cout << endl;
}
//cout << ans << "\n";
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... |