제출 #549840

#제출 시각아이디문제언어결과실행 시간메모리
549840esomerArranging Shoes (IOI19_shoes)C++17
50 / 100
1084 ms3120 KiB
#include "shoes.h" #include<bits/stdc++.h> using namespace std; #define intt long long long long count_swaps(vector<int> s) { intt ans = 0; for(int i = 0; i < s.size(); i += 2){ int ind; for(int j = i + 1; j < s.size(); j++){ if(-s[j] == s[i]){ ind = j; break; } } for(int j = ind - 1; j > i; j--){ s[j + 1] = s[j]; ans++; } if(s[i] < 0) s[i + 1] = -s[i]; else{ ans++; s[i + 1] = s[i]; s[i] = -s[i]; } } return ans; }

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:10:20: 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 += 2){
      |                  ~~^~~~~~~~~~
shoes.cpp:12:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     for(int j = i + 1; j < s.size(); j++){
      |                        ~~^~~~~~~~~~
shoes.cpp:18:13: warning: 'ind' may be used uninitialized in this function [-Wmaybe-uninitialized]
   18 |     for(int j = ind - 1; j > i; 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...