Submission #301743

#TimeUsernameProblemLanguageResultExecution timeMemory
301743letandatArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;
int64_t count_swaps(vector <int> a) {
	int n = a.size();
	int ans = 0;
	for (int i=0; i<2*n-1; i+=2) {
		if (abs(a[i])==abs(a[i+1])) continue;
		for (int j=i+2; j<2*n; j++) {
			if (abs(a[j]) == abs(a[i])) {
				ans += j-i-1;
				for (int k=j; k>=i+2; k--) {
					a[k] = a[k-1];
				}
				a[i+1] = a[i];
			}
		}
	}
	for (int i=0; i<2*n-1; i+=2) {
		if (a[i] > 0) ans += 1;
	}
	return ans;
}
int main () {
	int n; cin >> n;
	vector<int> a;
	for (int i=0; i<2*n; i++) {
		int c; cin >> c;
		a.push_back(c);
	}
	cout << count_swaps(a);
	return 0;
}

Compilation message (stderr)

/tmp/cchdbHXb.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccGZK4dE.o:shoes.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status