제출 #708012

#제출 시각아이디문제언어결과실행 시간메모리
708012MODDIArranging Shoes (IOI19_shoes)C++14
50 / 100
1086 ms3924 KiB
//#include "shoes.h"
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vl vector<ll>
#define mp make_pair
#define pb push_back
#define fi first
#define se second;
using namespace std;
long long count_swaps(std::vector<int> s) {
	ll ans = 0;
	vi arr = s;
	int n = s.size();
	for(int i = 0; i < n; i+=2){
		int target = arr[i] * -1;
		int j = i + 1;
		while(j < n && arr[j] != target){
			j++;
		}
		//cout<<i<<" "<<j<<endl;
		for(int at = j; at > i + 1; at--){
			swap(arr[at], arr[at-1]);
			ans++;
		}
		if(arr[i] > 0){
			swap(arr[i], arr[i+1]);
			ans++;
		}
	}
	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...