Submission #465875

#TimeUsernameProblemLanguageResultExecution timeMemory
465875dattranxxxArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 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_5 { ll solve(vector<int>& a) { ll res = 0; for (int i = 0; i < a.size(); i += 2) { int j = find(a.begin() + i + 1, a.end(), -a[i]) - a.begin(); int lim = a[i] < 0 ? j-i-1 : j-i; for (int k = 0; k <= lim; ++k) { swap(a[j], a[j-1]); j--; } res ++ lim; } return res; } } long long count_swaps(std::vector<int> a) { n = a.size() / 2; return task_5::solve(a); }

Compilation message (stderr)

shoes.cpp: In function 'll task_5::solve(std::vector<int>&)':
shoes.cpp:15:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |   for (int i = 0; i < a.size(); i += 2) {
      |                   ~~^~~~~~~~~~
shoes.cpp:21:10: error: expected ';' before 'lim'
   21 |    res ++ lim;
      |          ^~~~
      |          ;