제출 #1030182

#제출 시각아이디문제언어결과실행 시간메모리
1030182enderArranging Shoes (IOI19_shoes)C++17
10 / 100
1096 ms3264 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; long long count_swaps(std::vector<int> s) { long long ans = 0; for(int i = 0; i < s.size(); ++i){ if(i%2 == 0){ // debe ser zapato izquierdo if(s[i] < 0) continue; for(int j = i+1; j < s.size(); ++j){ if(s[j] < 0){ for(int k = j; k > i; --k){ swap(s[k], s[k-1]); ans++; } break; } } }else { // debe ser zapato derecho if(s[i] == s[i-1] * -1) continue; int target = s[i-1] * -1; for(int j = i+1; j < s.size(); ++j){ if(s[j] == target){ for(int k = j; k > i; --k){ swap(s[k], s[k-1]); ans++; } break; } } } } return ans; }

컴파일 시 표준 에러 (stderr) 메시지

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:10:19: 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(); ++i){
      |                 ~~^~~~~~~~~~
shoes.cpp:16:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |    for(int j = i+1; j < s.size(); ++j){
      |                     ~~^~~~~~~~~~
shoes.cpp:39:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |    for(int j = i+1; j < s.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...