Submission #1020073

#TimeUsernameProblemLanguageResultExecution timeMemory
1020073mindiyakArranging Shoes (IOI19_shoes)C++14
50 / 100
1079 ms139588 KiB
#include "shoes.h"

#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cmath>
#include <numeric>
#include <queue>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<int, int> pl;
typedef pair<ld, ld> pd;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<ld> vd;
typedef vector<long> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto &a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
#define len(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fst first
#define nl endl
#define sec second
#define lb lower_bound
#define ub upper_bound
#define aint(x) x.begin(), x.end()
#define raint(x) x.rbegin(), x.rend()
#define ins insert
const int MOD = 1000000007;
using namespace std;

long long count_swaps(vector<int> s) {
	vector<deque<ll>> arr(2e5+5);
	vl num_swaps(1e5+2,0);
	vl in_list;
	ll ans = 0;
	FOR(i,0,s.size()){
		if(arr[100001-s[i]].size() != 0){
			if(s[i]>0)ans--;
			ans += (i-arr[100001-s[i]][0]-num_swaps[arr[100001-s[i]][0]]);
			for(int j=0;j<in_list.size();j++){
				if(arr[100001-s[i]][0] <= in_list[j]){
					num_swaps[in_list[j]] += 1;
				}
			}
			arr[100001-s[i]].pop_front();
		}else{
			arr[100001+s[i]].pb(i);
			in_list.pb(i);
		}

	}
	return ans;
}

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:23:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 | #define FOR(i, a, b) for (int i = a; i < (b); i++)
      |                                        ^
shoes.cpp:48:2: note: in expansion of macro 'FOR'
   48 |  FOR(i,0,s.size()){
      |  ^~~
shoes.cpp:52:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |    for(int j=0;j<in_list.size();j++){
      |                ~^~~~~~~~~~~~~~~
#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...