제출 #301222

#제출 시각아이디문제언어결과실행 시간메모리
301222eagle30Arranging Shoes (IOI19_shoes)C++14
30 / 100
1139 ms814420 KiB
#include "shoes.h" #include<bits/stdc++.h> using namespace std; int mi(vector<int> vi, vector<int> pe, multiset<int> mu, int s){ int n=vi.size(); if(s==n){ int coun=0; for(int i=0; i<n; i++){ for(int j=i; j<n; j++){ if(pe[i]==vi[j]){ for(int k=j-1; k>=i; k--) swap(vi[k], vi[k+1]), coun++; break; } } } return coun; } int mini=2e9; vector<int> asdf; for(auto x:mu){ asdf.push_back(x); } for(int i=0; i<asdf.size(); i++){ pe[s]=-asdf[i]; pe[s+1]=asdf[i]; mu.erase(mu.find(asdf[i])); mini=min(mini, mi(vi, pe, mu, s+2)); mu.insert(asdf[i]); } return mini; } long long count_swaps(vector<int> s) { vector<int> yo; int n=s.size(); yo.assign(n, 0); map<int, int> mp; for(int i=0; i<n; i++) mp[abs(s[i])]++; multiset<int> mu; for(auto x:mp){ for(int i=0; i<x.second/2; i++) mu.insert(x.first); } return mi(s, yo, mu, 0); }

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

shoes.cpp: In function 'int mi(std::vector<int>, std::vector<int>, std::multiset<int>, int)':
shoes.cpp:24:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for(int i=0; i<asdf.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...