제출 #465875

#제출 시각아이디문제언어결과실행 시간메모리
465875dattranxxxArranging Shoes (IOI19_shoes)C++14
컴파일 에러
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); }

컴파일 시 표준 에러 (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;
      |          ^~~~
      |          ;