Submission #387260

#TimeUsernameProblemLanguageResultExecution timeMemory
387260ismoilovArranging Shoes (IOI19_shoes)C++14
50 / 100
1096 ms3180 KiB
#include "shoes.h"
#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

long long count_swaps(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;
}

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:22:6: warning: unused variable 'n' [-Wunused-variable]
   22 |  int n = s.size(), i = 0;
      |      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...