Submission #1274575

#TimeUsernameProblemLanguageResultExecution timeMemory
1274575KluydQArranging Shoes (IOI19_shoes)C++20
Compilation error
0 ms0 KiB
//#include "molecules.h"
#include <bits/stdc++.h>

//define respagold ios_base::sync_with_stdio(0), cin.tie(0);
#define int long long
#define ll long long
#define int2 __int128_t
#define FOR( i, x, n, d ) for( int i = x; i <= n; i += d )
#define FORR( i, x, n, d ) for( int i = x; i >= n; i -= d )
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x.size())
#define pb push_back
#define ins insert
#define lb lower_bound
#define ub upper_bound
#define pii pair <int, int>

using namespace std;
 
const int N = 2e5 + 12;
const int mod = 1e9 + 7;
const int inf = 2e18;

int n, m, x, y, a[N], b[N], ans, timer, t[N];
deque <int> g[N];

void update( int p, int v )
{
	for(; p <= n; p |= (p + 1)) t[p] += v;
}
int gt( int r )
{
	int res = 0;
	for(; r >= 0; r = (r & r + 1) - 1) res += t[r];
	return res;
}
int get( int l, int r )
{
	return gt(r) - gt(l - 1);
}
int count_swaps( vector <int> ww )
{
	for( auto i : ww ) a[++ n] = i;
	
	FOR( i, 1, n, 1 )
	{
		cin >> a[i];
		x = -a[i] + n;
		
		if( !g[x].empty() )
		{
			ans += (a[i] < 0);
			a[g[x].front()] = a[i] = ++ timer;
			b[g[x].front()] = i, g[x].pop_front();
		}
		else g[a[i] + n].pb(i);
	}
	FOR( i, 1, n, 1 )
	{
		if( b[i] == 0 ) continue;
		
		update(b[i], 1);
		ans += get(i + 1, b[i] - 1) + get(b[i] + 1, n) * 2;
	}
	cout << ans << '\n';
}/*
signed main()
{
	//respagold;
	
	int test = 1;
	if( !test ) cin >> test;
	while( test -- ) solve();
}*/

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<long long int>)':
shoes.cpp:68:1: warning: no return statement in function returning non-void [-Wreturn-type]
   68 | }/*
      | ^
/usr/bin/ld: /tmp/ccM24d7Z.o: in function `main':
grader.cpp:(.text.startup+0x26b): undefined reference to `count_swaps(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status