Submission #899358

#TimeUsernameProblemLanguageResultExecution timeMemory
899358SuPythonyArranging Shoes (IOI19_shoes)C++17
50 / 100
1056 ms3164 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll count_swaps(vector<int> S) { ll ans=0; for (int i=0; i<S.size(); i+=2) { ll val=S[i]; auto f=find(S.begin()+i+1, S.end(), -val); ll k=f-S.begin()-i; if (S[i]<=0) ans+=(k-1); else ans+=k; S.erase(f); S.insert(S.begin()+i+1, 1); } return ans; }

Compilation message (stderr)

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