Submission #912823

#TimeUsernameProblemLanguageResultExecution timeMemory
912823GabrielArranging Shoes (IOI19_shoes)C++17
45 / 100
17 ms3160 KiB
#include "shoes.h" #include "bits/stdc++.h" using namespace std; bool Ordenado(vector<int> s){ bool S_ = 1; for(long long i = 0; i < (long long)s.size(); i += 2){ if(!(s[i] < 0 and s[i + 1] == -s[i])) S_ = 0; cout<<s[i]<<" "<<s[i + 1]<<" "; } cout<<"\n"; return S_; } long long count_swaps(vector<int> s){ long long n = s.size(); if(n == 2){ if(s[0] < 0) return 0; else return 1; } else if(n <= 22){ long long Contador = 0; for(long long i = 0; i < n; i++){ //cout<<j<<" j\n"; /*for(auto E: s) cout<<E<<" "; cout<<"\n";*/ if(i % 2 == 0){ if(s[i] > 0){ for(long long j = i; j < n; j++){ if(s[j] == -s[i]){ for(long long k = j; k > i; k--){ swap(s[k], s[k - 1]); Contador++; } break; } } } } else { if(!(s[i] == -s[i - 1] and s[i] > 0)){ for(long long j = i; j < n; j++){ if(s[j] == -s[i - 1]){ for(long long k = j; k > i; k--){ swap(s[k], s[k - 1]); Contador++; } break; } } } } } return Contador; } else { n /= 2; return n * (n - 1) / 2; } return 1; }
#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...