Submission #892726

#TimeUsernameProblemLanguageResultExecution timeMemory
892726Lincito_31Arranging Shoes (IOI19_shoes)C++14
45 / 100
21 ms3924 KiB
#include <bits/stdc++.h> #include "shoes.h" using namespace std; long long x=0; long long count_swaps(vector<int> s) { bool jaja=true; bool ja=true; int xx=s.size()/2; for(int i=0;i<xx;i++){ if(s[i]!=-s[i+xx]){ jaja=false; break; } } int ayu=s[0]; for(int i=0;i<s.size();i++){ if(!(s[i]==ayu || s[i]==-ayu)){ ja=false; break; } } if(jaja || ja){ vector<int> xd_po; vector<int> xd_ne; for(int i=0;i<s.size();i++){ if(s[i]<0){ if(i%2!=0){ xd_ne.push_back(i); } }else{ if(i%2==0){ xd_po.push_back(i); } } } for(int i=0;i<xd_po.size();i++){ if(xd_po[i]>xd_ne[i]){ x+=xd_po[i]-xd_ne[i]; }else{ x+=xd_ne[i]-xd_po[i]; } } }else{ int con=0; while(con<s.size()){ int temp=s[con]; if(temp==0){ con++; continue; } if(temp<0){ int cero=0; for(int i=con+1;i<s.size();i++){ if(s[i]==0){ cero++; } if(s[i]==-temp){ x+=i-con-1-cero; s[i]=0; break; } } s[con]=0; }else{ int cero=0; for(int i=con+1;i<s.size();i++){ if(s[i]==0){ cero++; } if(s[i]==-temp){ x+=i-con-cero; s[i]=0; break; } } s[con]=0; } con++; } } return x; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:16:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for(int i=0;i<s.size();i++){
      |                 ~^~~~~~~~~
shoes.cpp:25:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         for(int i=0;i<s.size();i++){
      |                     ~^~~~~~~~~
shoes.cpp:36:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         for(int i=0;i<xd_po.size();i++){
      |                     ~^~~~~~~~~~~~~
shoes.cpp:45:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         while(con<s.size()){
      |               ~~~^~~~~~~~~
shoes.cpp:53:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |                 for(int i=con+1;i<s.size();i++){
      |                                 ~^~~~~~~~~
shoes.cpp:66:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |                 for(int i=con+1;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...