Submission #1268832

#TimeUsernameProblemLanguageResultExecution timeMemory
1268832FaresSTHArranging Shoes (IOI19_shoes)C++20
Compilation error
0 ms0 KiB
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
#define S second
#define F first
ll count_swaps(vector<int>a){
	ll res=0;
	set<int>p[2];
	int n=a.size();
	for(int i=0;i<n;i++){
		if(a[i]<0)p[0].insert(i);
		else p[1].insert(i);
	}
	for(int i=0;i<n;i++){
		auto *it=p[i%2].lower_bound(i);
		p[i%2].erase(it);
		p[i%2].insert(i);
		p[1-i%2].insert(it);
		p[1-i%2].erase(i);
		res+=it-i;
	}
	return res;
}
// MalekLoky 3mk

Compilation message (stderr)

shoes.cpp: In function 'll count_swaps(std::vector<int>)':
shoes.cpp:15:44: error: unable to deduce 'auto*' from 'p[(i % 2)].std::set<int>::lower_bound(i)'
   15 |                 auto *it=p[i%2].lower_bound(i);
      |                          ~~~~~~~~~~~~~~~~~~^~~
shoes.cpp:15:46: note:   mismatched types 'auto*' and 'std::_Rb_tree_const_iterator<int>'
   15 |                 auto *it=p[i%2].lower_bound(i);
      |                                              ^