# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
441485 | QuantumK9 | Arranging Shoes (IOI19_shoes) | C++17 | 1092 ms | 146460 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 ll long long
#define pb push_back
#define mp make_pair
map<int, queue<int> > rgt;
long long count_swaps(vector<int> s) {
//nums
ll n = s.size()/2;
ll S = s.size();
//iterate through s -- preprocess
for( int i = 0; i < S; i++ ){
rgt[ s[i] ].push(i);
}
bool idim[S];
memset( idim, true, sizeof idim );
//process
ll grand = 0;
for( int i = 0; i < S; i++ ){
if( idim[i] ){
idim[i] = false;
rgt[ s[i] ].pop();
//move partner
ll val = rgt[ -s[i] ].front();
for( int j = 0; j < val; j++ ){ grand += idim[j]; }
idim[val] = false;
rgt[ -s[i] ].pop();
if( s[i] > 0 ){ grand++; }
}
}
return grand;
}
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... |