제출 #1011684

#제출 시각아이디문제언어결과실행 시간메모리
1011684u_suck_oArranging Shoes (IOI19_shoes)C++17
50 / 100
1080 ms3536 KiB
#include "bits/stdc++.h" #include "shoes.h" using namespace std; long long count_swaps(vector<int> s) { long long ans = 0; long long n = s.size()/2; long long minloc[n+1][2]; for (int p = 0; p < n; p++) { memset(minloc, 0x3f, sizeof minloc); for (long long i = 0; i < s.size(); i++) { if (s[i] < 0) minloc[-s[i]][0] = min(minloc[-s[i]][0], i); else minloc[s[i]][1] = min(minloc[s[i]][1], i); } long long mind = LONG_LONG_MAX, mini = -1; for (int i = 1; i <= n; i++) { long long d = minloc[i][0] + minloc[i][1] - 1; if (minloc[i][0] > minloc[i][1]) d += 1; if (d < mind) { mind = d; mini = i; } } ans += mind; s.erase(s.begin() + max(minloc[mini][0], minloc[mini][1])); s.erase(s.begin() + min(minloc[mini][0], minloc[mini][1])); } return ans; }

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

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