제출 #283545

#제출 시각아이디문제언어결과실행 시간메모리
283545test2Arranging Shoes (IOI19_shoes)C++14
10 / 100
1092 ms23276 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 ;i ++){ per.push_back(i) ; } for(auto u : v){ //cout<< u.first <<" " << u.second <<"..\n" ; } do{ bool bad = 0 ; ll ret1 = 0 ; for(int i = 1 ;i < n;i+=2){ int x = s[per[i-1]] , y = s[per[i]] ; if(!(x == -y && x < y)){ bad = 1; break ; } ret1+= abs(i - per[i]) ; ret1+= abs((i-1) - per[i-1]) ; } if(!bad){ 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...