제출 #992513

#제출 시각아이디문제언어결과실행 시간메모리
992513MuntherCarrotArranging Shoes (IOI19_shoes)C++14
10 / 100
0 ms348 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define all(x) x.begin(), x.end() ll count_swaps(vector<int> vec){ auto prm = vec; int n = vec.size(); sort(all(prm)); ll ans = LLONG_MAX; do{ bool good = 1; for(int i = 0; i < n; i += 2){ if(prm[i] > 0 || -prm[i] != prm[i + 1]){ good = 0; } } if(good == 0) continue; ll cnt = 0; auto f = vec; for(int i = 0; i < n - 1; i++){ int j = i; while(f[j] != prm[i]) j++; while(j > i){ cnt++; swap(f[j], f[--j]); } } ans = min(ans, cnt); }while(next_permutation(all(prm))); return ans; }

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:27:30: warning: operation on 'j' may be undefined [-Wsequence-point]
   27 |                 swap(f[j], f[--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...