제출 #465345

#제출 시각아이디문제언어결과실행 시간메모리
465345dattranxxxArranging Shoes (IOI19_shoes)C++14
25 / 100
32 ms1868 KiB
/* * Author : shora */ #include "shoes.h" #include <bits/stdc++.h> #define print(_v) for (auto &_ : _v) {cerr << _ << ' ';} cerr << endl; using namespace std; using ll = long long; const int oo = 1e9; ll n; namespace task_2 { map<vector<int>, int> dis; ll solve(vector<int> a) { vector<int> fin(a.size()); for (int i = 0; i < n; ++i) fin[2*i] = i+1, fin[2*i+1] = -i-1; dis[a] = 0; queue<vector<int>> q; q.push(a); while (!q.empty()) { vector<int> cur = q.front(); q.pop(); if (cur == fin) return dis[cur]; int d = dis[cur]; for (int i = 1; i < cur.size(); ++i) { swap(cur[i], cur[i-1]); if (!dis.count(cur) || d + 1 < dis[cur]) { dis[cur] = d + 1; q.push(cur); } swap(cur[i], cur[i-1]); } } return dis[fin]; } } namespace task_3 { bool check(vector<int>& a) { for (int i = 0; i < n; ++i) if (a[i] > 0 || a[i] != -a[i+n]) return 0; return 1; } } long long count_swaps(std::vector<int> a) { n = a.size() / 2; if (n == 1) return a[0] > 0; if (task_3::check(a)) return n * (n-1) / 2; if (n <= 8) return task_2::solve(a); return -1; }

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

shoes.cpp: In function 'll task_2::solve(std::vector<int>)':
shoes.cpp:25:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |    for (int i = 1; i < cur.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...