제출 #283561

#제출 시각아이디문제언어결과실행 시간메모리
283561test2Arranging Shoes (IOI19_shoes)C++14
50 / 100
1087 ms7676 KiB
#include<bits/stdc++.h>
#include "shoes.h"
#include<ext/rope>
#define I inline void 
 
using namespace __gnu_cxx ; 
 
using namespace std ; 
 
using ll = long long ; 
using ld = long double ; 
 
const int N = 3000 + 7 , mod = 1e9 + 7 ;
 
// How interesting!
 
int n; 
 
 
long long count_swaps(std::vector<int> s) {
 
	int n = (int) s.size() ;
	ll ret = 0 ; 
	rope<int> shoes (n * 2 , 0) ; 
	for(int i = 0 ;i < n;i ++){
		shoes.mutable_reference_at(i) = s[i] ; 
	}
 
	for(int i = 0 ;i < n / 2; i++){	
		int pos = shoes.find(-shoes[0]) ; 
 
		ret += pos - 1;  
 
		if( shoes[0] > 0 ){
			ret++ ;
		}
		shoes.erase(pos , 1) ; 
		shoes.erase(0 , 1) ; 
 
	}
 
	return ret;
}
#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...