Submission #590992

#TimeUsernameProblemLanguageResultExecution timeMemory
590992almothana05Arranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include "shoes.h"
#include <bits/stdc++.h>
using namespace std;
map<long long , vector<long long> >num;
vector<pair<long long , long long> >erg;
long long vis[200000] , pref[200000];
long long count_swaps(vector<long long> s) {
	long long menge = s.size() , be , en , re = 0;
	for(long long i = menge - 1 ; i >= 0 ; i--){
		num[s[i]].push_back(i);
	}
	for(long long i = 0 ; i < menge ; i++){
		if(vis[i] == 1){
			continue;
		}
		be = i;
		en = num[s[i] * -1][num[s[i] * -1].size() - 1];
		num[s[i] * -1].pop_back();
		num[s[i]].pop_back();
		if(be > en){
			swap(be , en);
		}
		for(long long j = be ; j <= en ; j++){
			pref[j]++;
		}
		vis[be] = 1;
		vis[en] = 1;
		be += pref[be];
		en += pref[en];
		if(s[i] > 0){
			re++;
		}
		re += (en - be - 1);
	}

	return re;
}

Compilation message (stderr)

/usr/bin/ld: /tmp/cctB80G8.o: in function `main':
grader.cpp:(.text.startup+0x29d): undefined reference to `count_swaps(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status