제출 #143499

#제출 시각아이디문제언어결과실행 시간메모리
143499muradeynArranging Shoes (IOI19_shoes)C++14
50 / 100
1053 ms2040 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; long long count_swaps(vector<int> s) { long long ret = 0; int n = s.size(); for (int i = 0;i<n;i+=2) { if (s[i] != -s[i + 1]) { int fn; for (int j = i + 2;j < n;j++) { if (s[j] == -s[i]) { fn = j; break; } } while (fn != i + 1) { ret++; swap(s[fn] , s[fn - 1]); fn--; } } if (s[i] > s[i + 1]) { ret++; swap(s[i] , s[i + 1]); } } return ret; }

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:13:17: warning: 'fn' may be used uninitialized in this function [-Wmaybe-uninitialized]
             int fn;
                 ^~
#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...