# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
382094 | ritul_kr_singh | Arranging Shoes (IOI19_shoes) | C++17 | 1 ms | 384 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 "shoes.h"
#include <bits/stdc++.h>
using namespace std;
#define sp << " " <<
#define nl << "\n"
long long count_swaps(vector<int> s){
int n = (int)s.size()/2;
vector<vector<int>> pos0(n), pos1(n);
for(int i=0; i<2*n; ++i){
if(s[i]>0) pos1[s[i]-1].push_back(i);
else pos0[-s[i]-1].push_back(i);
}
long long ans = 0;
for(int i=0; i<n; ++i){
for(int j=0; j<pos0[i].size(); ++j){
if(pos0[i][j]>pos1[i][j]) ans += (long long)(pos0[i][j] - pos1[i][j]);
else ans += (long long)(pos1[i][j] - pos0[i][j] - 1);
}
}
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... |