| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 428218 | Hazem | Arranging Shoes (IOI19_shoes) | C++14 | 1096 ms | 3552 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>
#define LL long long
#define F first
#define S second
using namespace std;
const int N = 2e5+10;
vector<pair<LL,LL>>vec;
bool matched[N];
long long count_swaps(std::vector<int> s) {
LL n = s.size()/2,ans = 0;
int cnt = 0;
for(int i=0;i<n*2;i++){
if(s[i]<0){
bool q = 0;
for(int j=0;j<i;j++)
if(s[j]==abs(s[i])&&!matched[j]){
vec.push_back({i,j});ans += abs(i-j);
q = 1;
matched[j] = 1;
break;
}
if(q)continue;
for(int j=i+1;j<n*2;j++)
if(s[j]==abs(s[i])&&!matched[j]){
vec.push_back({i,j});ans += abs(i-j)-1;
matched[j] = 1;
break;
}
}
}
for(int i=0;i<vec.size();i++){
for(int j=i+1;j<vec.size();j++){
pair<int,int>p1 = make_pair(min(vec[i].F,vec[i].S),max(vec[i].F,vec[i].S));
pair<int,int>p2 = make_pair(min(vec[j].F,vec[j].S),max(vec[j].F,vec[j].S));
pair<int,int>p3 = make_pair(max(p1.F,p2.F),min(p1.S,p2.S));
if(p3!=p1&&p3!=p2&&p3.F<p3.S)
ans--;
}
}
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... | ||||
