제출 #283544

#제출 시각아이디문제언어결과실행 시간메모리
283544test2Arranging Shoes (IOI19_shoes)C++14
10 / 100
1 ms256 KiB
#include<bits/stdc++.h> #include "shoes.h" #define I inline void using namespace std ; using ll = long long ; using ld = long double ; const int N = 3000 + 7 , mod = 1e9 + 7 ; // How interesting! int n; long long count_swaps(std::vector<int> s) { map<int,vector<int> > mp ; ll ret = 1e9 ; vector<pair<int,int>> v ; int pos = 0 ; for(auto u : s){ if(mp[-u].size()){ v.push_back({mp[-u].back() , pos}) ; mp[-u].pop_back() ; } else{ mp[u].push_back(pos) ; } pos ++ ; } int n = (int) s.size() ; vector<int> per ; for(int i = 0 ;i < n / 2 ;i ++){ per.push_back(i) ; } for(auto u : v){ //cout<< u.first <<" " << u.second <<"..\n" ; } do{ int k = 0; ll ret1 = 0 ; for(int i = 0 ; i < n/2 ;i++){ pair<int,int> u = v[per[i]] ; int l = u.first , r = u.second ; if(s[l] > s[r]) swap(l , r) ; ret1+= abs(k - l) ; ret1+= abs((k+1) - r) ; k+= 2; } ret = min(ret , ret1/2) ; } while(next_permutation(per.begin() , per.end())) ; return ret; }

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:45:11: warning: variable 'u' set but not used [-Wunused-but-set-variable]
   45 |  for(auto u : v){
      |           ^
#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...