제출 #465696

#제출 시각아이디문제언어결과실행 시간메모리
465696tomsydArranging Shoes (IOI19_shoes)C++17
10 / 100
1084 ms5396 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; bool ok(vector<int>& s){ for (int i=1; i<s.size(); i += 2){ if (s[i-1] < 0 and -s[i-1] == s[i]){ continue; } return false; } return true; } long long count_swaps(vector<int> s) { vector<pair<int,int>> v; for (int i=1; i<s.size(); ++i){ v.emplace_back(i-1,i); } int ans = 1e9; if (ok(s)) ans = 0; do{ vector<int> cp = s; int cnt = 0; for (auto j:v){ swap(cp[j.first],cp[j.second]); ++cnt; if (ok(cp)) break; } ans = min(ans,cnt); } while (next_permutation(v.begin(),v.end())); return ans; }

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

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