# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
195648 | Swan | Arranging Shoes (IOI19_shoes) | C++14 | 1097 ms | 3192 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>
#include "shoes.h"
#define stop system("pause")
#define stop2 char o; cin >> o
#define INP freopen("pcb.in","r",stdin)
#define OUTP freopen ("pcb.out","w",stdout)
using namespace std;
long long count_swaps(std::vector<int> s) {
int ans = 0;
for(int i(0); i < s.size();i+=2){
if(s[i] == -s[i+1] && s[i] < 0 && s[i+1] > 0)continue;
int need;
for(int to(i+1); to < s.size();to++){
if(s[to]!=-s[i])continue;
else{
need = to;
break;
}
}
while(need!=i){
swap(s[need],s[need-1]);
need--;
ans++;
}
if(s[i] > 0){
ans--;
swap(s[i],s[i+1]);
}
//cout << i+1 << ' ' << ans << endl;
}
return ans;
}
/*
6
-2 2 2 -2 -2 2
*/
/*
main(){
ios_base::sync_with_stdio(0);
int n; cin >> n;
vector<int> v;
for(int i(0); i < n;i++){
int x; cin >> x;
v.push_back(x);
}
cout << count_swaps(v);
return 0;
}*/
/*
*/
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... |