Submission #1215775

#TimeUsernameProblemLanguageResultExecution timeMemory
1215775szz0liArranging Shoes (IOI19_shoes)C++20
Compilation error
0 ms0 KiB
#include "shoes.h"
#include <bits/stdc++.h>
using namespace std;

long long count_swaps(vector<int> s) {
	int ans=INT_MAX/2;
	vector<int> perm;
	for(int i=0;i<n*2;i++){
		if(s[i]<0)perm.push_back(abs(s[i]));
	}
	sort(perm.begin(), perm.end());
	do{
		int cnt=0;
		vector<int> helyes(2*n), copi=s;
		for(int i=0;i<n;i++){
			helyes[2*i]=-1*perm[i];
			helyes[2*i+1]=perm[i];
		}
		for(int i=0;i<2*n;i++){
			for(int j=i;j<2*n;j++){
				if(copi[j]==helyes[i]){
					while(j!=i){
						swap(copi[j], copi[j-1]);
						j--;
						cnt++;
					}
				}
			}
		}
		ans=min(ans, cnt);
	}
	while(next_permutation(perm.begin(), perm.end()));
	return ans;

}

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:8:23: error: 'n' was not declared in this scope
    8 |         for(int i=0;i<n*2;i++){
      |                       ^
shoes.cpp:14:38: error: 'n' was not declared in this scope
   14 |                 vector<int> helyes(2*n), copi=s;
      |                                      ^