Submission #387258

# Submission time Handle Problem Language Result Execution time Memory
387258 2021-04-08T07:41:27 Z ismoilov Arranging Shoes (IOI19_shoes) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).begin(), (x).end()
#define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
#define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
#define fv(c) for(int (a) = (1); (a) <= (c); (a)++)
#define fz(c) for(int (a) = (0); (a) < (c); (a)++)
#define fm(a,i,c) for(int (a) = (i); (a) > (c); (a)--)
#define fmm(a,i,c) for(int (a) = (i); (a) >= (c); (a)--)
#define pb push_back
#define in insert
#define ss second
#define ff first

ll S(vector <int> &s)
{
	int n = s.size(), i = 0;
	ll ans = 0;
	while(!s.empty())
	{
		auto x = find(all(s), -s[i]);
		ans += x - s.begin() - (s[i] < 0);
		//cout << ans << " " << s[i] << " " << x-s.begin() <<" " << i << "\n";
		s.erase(x);
		s.erase(s.begin());
	//	i ++;
	}
	return ans;
}
int main()
{
	IOS;
	int n;
	cin >> n;
	vector <int> c(2*n);
	fp(i,0,2*n)
		cin >> c[i];
	cout << S(c);
	/*int t;
	cin >> t;
	while(t--)
		 S();*/
}

Compilation message

shoes.cpp: In function 'll S(std::vector<int>&)':
shoes.cpp:22:6: warning: unused variable 'n' [-Wunused-variable]
   22 |  int n = s.size(), i = 0;
      |      ^
shoes.cpp: In function 'int main()':
shoes.cpp:9:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    9 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
shoes.cpp:41:2: note: in expansion of macro 'fp'
   41 |  fp(i,0,2*n)
      |  ^~
/tmp/cc5wDGnL.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cctD0yMz.o:shoes.cpp:(.text.startup+0x0): first defined here
/tmp/cc5wDGnL.o: In function `main':
grader.cpp:(.text.startup+0x278): undefined reference to `count_swaps(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status