Submission #486800

#TimeUsernameProblemLanguageResultExecution timeMemory
486800HaidaraArranging Shoes (IOI19_shoes)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
#define rep(i,x,n) for(int i=(x);i<(n);i++)
#define FOR(i,n) rep(i,0,n)
#define v(i) vector< i >
#define ll long long 
using namespace std;
const ll inf=1LL<<62LL;
const ll mod=1e9+7;
const ll maxn=100200;
ll count_swaps(v(ll)a)
{
	ll ans=0;
	ll n=a.size()
	set<int>posl[maxn],posr[maxn];
	FOR(i,n)
	if(a[i]<0)
		posl[-a[i]].insert(i);
	else 
		posr[a[i]].insert(i);
	
	v(bool)vis(maxn,0);
	for(int i=0;i<n;i++)
	{
		if(vis[i])
			continue;
		if(a[i]>0)
			ans++;
		if(a[i]<0)
			a[i]*=-1;
		vis[*posr[a[i]].begin()]=1;
		vis[*posl[a[i]].begin()]=1;
		ans+=abs(*posr[a[i]].begin()-*posl[a[i]].begin());
		posl[a[i]].erase(posl[a[i]].begin());
		posr[a[i]].erase(posr[a[i]].begin());
	}
	return ans;
}

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<long long int>)':
shoes.cpp:14:2: error: expected ',' or ';' before 'set'
   14 |  set<int>posl[maxn],posr[maxn];
      |  ^~~
shoes.cpp:17:3: error: 'posl' was not declared in this scope; did you mean 'powl'?
   17 |   posl[-a[i]].insert(i);
      |   ^~~~
      |   powl
shoes.cpp:19:3: error: 'posr' was not declared in this scope
   19 |   posr[a[i]].insert(i);
      |   ^~~~
shoes.cpp:30:8: error: 'posr' was not declared in this scope
   30 |   vis[*posr[a[i]].begin()]=1;
      |        ^~~~
shoes.cpp:31:8: error: 'posl' was not declared in this scope; did you mean 'powl'?
   31 |   vis[*posl[a[i]].begin()]=1;
      |        ^~~~
      |        powl