# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
340606 | israeladewuyi | Arranging Shoes (IOI19_shoes) | C++17 | 0 ms | 0 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;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pair<int,int>> vp;
#define PB push_back
#define pb pop_back
#define in insert
#define endl "\n"
#define MP make_pair
#define f first
#define Trav(a,x) for(auto& a: x)
const unsigned int M = 1000000007;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n; cin>>n;
vi v(2 * n);
Trav(a,v)cin>>a;
int mxs = 0;
for(int i = 0; i < (2 * n)-1; i++){
int y = v[i];
for(int j = i + 1; j<2*n; j++){
if(v[j] == y){
while(v[i+1] != y){
swap(v[j],v[j-1]);
mxs++;
j = j-1;
}
}
}
}
cout<<mxs<<endl;
return 0;
}