Submission #645373

#TimeUsernameProblemLanguageResultExecution timeMemory
645373rc_catuntaArranging Shoes (IOI19_shoes)C++17
0 / 100
0 ms212 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; long long count_swaps(vector<int> s) { if(s.size()/2 <= 8){ int n = s.size()/2; // Etiquetar los zapatos map<int, int> m; int id = 1; for(auto zapato: s){ if(zapato>0){ m[id]=-zapato; id++; } } // Creamos el vector de posibilidades vector<int> v; for(int i=1;i<=n;i++) v.push_back(i); int res = 100000000; // Generador de posibilidades int it=0; int pasos = 0; vector<int> cs = s; for(int i=0;i<v.size();i++){ int tam = m[v[i]]; // Colocar el izquierdo // Buscamos el izquierdo for(int j=i*2;j<cs.size();j++){ if(cs[j]==-tam){ for(int k=j-1;k>=i*2;k--){ swap(cs[k],cs[k+1]); pasos++; } break; } } // Buscamos el izquierdo for(int j=i*2+1;j<cs.size();j++){ if(cs[j]==tam){ for(int k=j-1;k>=i*2+1;k--){ swap(cs[k],cs[k+1]); pasos++; } break; } } } res = min(res,pasos); return res; } else return 0; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:26:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |    for(int i=0;i<v.size();i++){
      |                ~^~~~~~~~~
shoes.cpp:30:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for(int j=i*2;j<cs.size();j++){
      |                   ~^~~~~~~~~~
shoes.cpp:40:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     for(int j=i*2+1;j<cs.size();j++){
      |                     ~^~~~~~~~~~
shoes.cpp:23:7: warning: unused variable 'it' [-Wunused-variable]
   23 |   int it=0;
      |       ^~
#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...