Submission #1030687

#TimeUsernameProblemLanguageResultExecution timeMemory
1030687fv3Arranging Shoes (IOI19_shoes)C++14
10 / 100
1054 ms1048576 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; bool isValid(vector<int> v) { for (int i = 0; i < v.size(); i += 2) { if (v[i] > v[i+1] || v[i] != -v[i+1]) return false; } return true; } ll count_swaps(vector<int> s) { const int N = s.size() / 2; map<vector<int>, int> visited; visited[s] = 0; queue<vector<int>> q; q.push(s); while (!q.empty()) { vector<int> v = q.front(); int d = visited[v]; if (isValid(v)) { return d; } q.pop(); for (int i = 0; i < 2 * N - 1; i++) { swap(v[i], v[i+1]); if (visited.count(v) == 0) { visited[v] = d + 1; q.push(v); } swap(v[i], v[i+1]); } } return 0; }

Compilation message (stderr)

shoes.cpp: In function 'bool isValid(std::vector<int>)':
shoes.cpp:9:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |  for (int i = 0; i < v.size(); i += 2)
      |                  ~~^~~~~~~~~~
#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...