Submission #297347

#TimeUsernameProblemLanguageResultExecution timeMemory
297347SaboonArranging Shoes (IOI19_shoes)C++17
50 / 100
1064 ms27356 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; map<int,set<int>> S; long long count_swaps(vector<int> a){ int n = (int)a.size() / 2; long long ret = 0; for (int now = 0; now < 2*n; now += 2){ vector<pair<int,int>> Joft; for (int i = 0; i < a.size(); i++){ int x = a[i]; if (!S[-x].empty()){ Joft.push_back({*S[-x].begin(),i}); S[-x].erase(S[-x].begin()); } else S[x].insert(i); } auto it = *min_element(Joft.begin(), Joft.end()); int v = it.first, u = it.second; if (a[v] > a[u]) ret ++; ret += v+u-1; a.erase(a.begin()+u); a.erase(a.begin()+v); } return ret; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:11:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |   for (int i = 0; i < a.size(); i++){
      |                   ~~^~~~~~~~~~
#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...