제출 #912811

#제출 시각아이디문제언어결과실행 시간메모리
912811GabrielArranging Shoes (IOI19_shoes)C++17
10 / 100
19 ms1996 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; long long i = 0; //while(!(Ordenado(s))){ for(long long j = i; j < n; j++){ //cout<<j<<" j\n"; if(j % 2 == 0){ if(s[j] < 0) i++; else { for(long long k = j; k < n; k++){ if(s[k] < 0){ for(long long l = k; l > j; l--){ swap(s[k], s[k - 1]); Contador++; } break; } } //break; } } else { if(s[j] == -s[j - 1]) i++; else { for(long long k = j; k < n; k++){ if(s[k] == -s[j - 1]){ for(long long l = k; l > j; l--){ swap(s[k], s[k - 1]); Contador++; } break; } } //break; } } } //} return Contador; } 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...