Submission #1047250

#TimeUsernameProblemLanguageResultExecution timeMemory
1047250vjudge1Arranging Shoes (IOI19_shoes)C++17
10 / 100
0 ms348 KiB
#include "shoes.h" #include<bits/stdc++.h> using namespace std; #define ll long long int #define pb push_back long long count_swaps(std::vector<int> s) { int n = s.size() + 5; vector<deque<int>> pos(n + n); ll ans = 0; for(int i = 0; i < s.size(); ++i){ if(s[i] < 0){ if(pos[-s[i] + n].empty()){ pos[-s[i]].pb(i); }else{ ans += i - pos[-s[i] + n].front(); pos[-s[i] + n].pop_front(); } }else{ if(pos[s[i]].empty()){ pos[s[i] + n].pb(i); }else{ ans += i - 1 - pos[s[i]].front(); pos[s[i]].pop_front(); } } // cout << ans << ' '; } return ans; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:11:19: 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 < s.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...