Submission #145372

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

long long ans=0;

vector<int> a;

int swapp(int l,int r){
	int t=a[r];
	for (int i=r;i>l;i--) a[i]=a[i-1];
	a[l]=t;
}

long long count_swaps(vector<int> s){
	a=s;
	int n=s.size();

	for (int i=0;i<n;i++)
	if (i%2==0){
		for (int j=i+1;;j++)
		 if (a[i]+a[j]==0) break;
		if (a[i]<0){
			swapp(i+1,j);
			ans+=j-i-1;
		}else{
			swapp(i,j);
			ans+=j-i;
		}
	}
	return ans;
}

Compilation message (stderr)

shoes.cpp: In function 'int swapp(int, int)':
shoes.cpp:13:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:24:14: error: 'j' was not declared in this scope
    swapp(i+1,j);
              ^
shoes.cpp:27:12: error: 'j' was not declared in this scope
    swapp(i,j);
            ^