Submission #1272959

#TimeUsernameProblemLanguageResultExecution timeMemory
1272959arkanefuryArranging Shoes (IOI19_shoes)C++20
10 / 100
1095 ms2448 KiB
#include "shoes.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5+5;
int a[N], b[N];
long long count_swaps(vector <int> v){
    int n = v.size(), k;
    long long ans = 0;
	for(int i = 0; i < n; i += 2){
		if(v[i] < 0){
		for(int j = i+1; j < n; j ++){
			if(v[j] > 0 && v[j] == abs(v[i])){
			k = j;break;
			}
		}
			for(int j = k; j > i+1; j --){
				swap(a[j], a[j-1]);
				ans ++;
			}
		}
		else{
			for(int j = i+1; j < n; j ++){
			if(v[j] < 0 && abs(v[j]) == v[i]){
			k = j;break;
			}
		}
			for(int j = k; j > i; j --){
				swap(a[j], a[j-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...