Submission #607608

#TimeUsernameProblemLanguageResultExecution timeMemory
607608nyaruhodoArranging Shoes (IOI19_shoes)C++14
10 / 100
1 ms284 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; long long count_swaps(std::vector<int> s) { set<pair<ll,ll>> st; // val, pos ll cnt=0; vector<ll> vis(s.size(),0); for(ll i = 0;i < s.size();i++){ if(s[i] > 0){ auto lb = st.lower_bound({-s[i],-1}); if(lb!=st.end() && lb->first==-s[i]){ auto p = *lb; st.erase(lb); cnt+=i-p.second-1; if(s[i]<0) cnt++; vis[i]=1,vis[p.second]=1; } }else st.insert({s[i],i}); } st.clear(); for(ll i = 0;i < s.size();i++){ if(vis[i]) continue; auto lb = st.lower_bound({-s[i],-1}); if(lb == st.end() || lb->first!=-s[i]){ st.insert({s[i],i}); continue; } auto p = *lb; st.erase(lb); cnt+=i-p.second-1; if(s[i]<0) cnt++; } return cnt; }

Compilation message (stderr)

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