Submission #890592

#TimeUsernameProblemLanguageResultExecution timeMemory
890592svazArranging Shoes (IOI19_shoes)C++14
10 / 100
1095 ms3140 KiB
#include "shoes.h" #include<iostream> #include<vector> using namespace std; long long count_swaps(std::vector<int> S){ long long sw=0; bool ruin=false; vector<int> pos_der, pos_izq; for(int i=0;i<S.size()-1;i+=2){ if(!(S[i]<0 && S[i+1]>0 && abs(S[i])==abs(S[i+1])) or ruin){ if(S[i]>0)pos_der.push_back(i); else pos_izq.push_back(i); if(S[i+1]>0)pos_der.push_back(i+1); else pos_izq.push_back(i+1); ruin=true; } } for(int i=0;i<pos_izq.size();i++){ sw+=abs(pos_der[i]-pos_izq[i]); if(pos_izq[i]<pos_der[i])sw--; for(int j=i+1;j<pos_izq.size();j++){ if(pos_der[i]>pos_izq[j])pos_izq[j]++; else break; } for(int j=i+1;j<pos_der.size();j++){ if(pos_izq[i]>pos_der[j])pos_der[j]++; else break; } /* for(int i=0;i<pos_der.size();i++){ cout<<pos_der[i]<<" "; } cout<<endl; for(int i=0;i<pos_der.size();i++){ cout<<pos_izq[i]<<" "; } cout<<endl;*/ } return sw; } /*int main(){ cin.tie(NULL); ios_base::sync_with_stdio(false); int n,zap; cin>>n; vector<int>zapatos; for(int i=0;i<(n*2);i++){ cin>>zap; zapatos.push_back(zap); } cout<<count_swaps(zapatos)<<"\n"; return 0; }*/

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:10:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for(int i=0;i<S.size()-1;i+=2){
      |                 ~^~~~~~~~~~~
shoes.cpp:19:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for(int i=0;i<pos_izq.size();i++){
      |                 ~^~~~~~~~~~~~~~~
shoes.cpp:22:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         for(int j=i+1;j<pos_izq.size();j++){
      |                       ~^~~~~~~~~~~~~~~
shoes.cpp:26:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         for(int j=i+1;j<pos_der.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...