제출 #346598

#제출 시각아이디문제언어결과실행 시간메모리
346598PetyArranging Shoes (IOI19_shoes)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "shoes.h" using namespace std; int count_swaps (vector<int>v) { map<int, int>mp[2]; set<pair<int, int>> s; int ans = 0; for (int i = 0; i < v.size(); i++) { int x = v[i]; auto it = s.lower_bound({-x, 0}); if ((*it).first == -x) { if (x > 0) ans += i - (*it).second - 1; else ans += i - (*it).second; s.erase(it); } else s.insert({x, i}); } return ans; }

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

shoes.cpp:6:5: error: ambiguating new declaration of 'int count_swaps(std::vector<int>)'
    6 | int count_swaps (vector<int>v) {
      |     ^~~~~~~~~~~
In file included from shoes.cpp:2:
shoes.h:7:11: note: old declaration 'long long int count_swaps(std::vector<int>)'
    7 | long long count_swaps(std::vector<int> S);
      |           ^~~~~~~~~~~
shoes.cpp: In function 'int count_swaps(std::vector<int>)':
shoes.cpp:10:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |   for (int i = 0; i < v.size(); i++) {
      |                   ~~^~~~~~~~~~