제출 #398456

#제출 시각아이디문제언어결과실행 시간메모리
398456iulia13Arranging Shoes (IOI19_shoes)C++14
컴파일 에러
0 ms0 KiB
#include <iostream> #include <vector> #include "shoes.h" using namespace std; const int nmax = 1e5 + 5; int aib[nmax * 4]; int moved[nmax], n; vector <int> a[nmax * 4]; int lsb(int x) { return x & (-x); } void upd(int x, int val) { for (x; x <= n; x += lsb(x)) aib[x] += val; } int qry(int x) { int s = 0; while (x) { s += aib[x]; x -= lsb(x); } return x; } int count_swaps(vector<int> v) { int i, ans = 0; n = v.size(); for (i = n - 1; 0 <= i; i--) a[v[i] + n].push_back(i); for (i = 0; i < n; i++) { if (moved[i]) continue; int j = a[n - v[i]].back(), swaps = 0; ///i < j if (v[i] > 0) swaps = 1; ///aduci j langa i adica pe i + 1 swaps += j - i - 1 - (qry(j) - qry(i)); upd(j, 1); ans += swaps; moved[j] = 1; a[n - v[i]].pop_back(); a[n + v[i]].pop_back(); } return ans; }/* int main() { int N, i; cin >> N; vector <int> v; v.resize(N); for (i = 0; i < N; i++) cin >> v[i]; cout << count_swaps(v); return 0; }*/

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

shoes.cpp: In function 'void upd(int, int)':
shoes.cpp:15:10: warning: statement has no effect [-Wunused-value]
   15 |     for (x; x <= n; x += lsb(x))
      |          ^
shoes.cpp: At global scope:
shoes.cpp:28:5: error: ambiguating new declaration of 'int count_swaps(std::vector<int>)'
   28 | int count_swaps(vector<int> v)
      |     ^~~~~~~~~~~
In file included from shoes.cpp:3:
shoes.h:7:11: note: old declaration 'long long int count_swaps(std::vector<int>)'
    7 | long long count_swaps(std::vector<int> S);
      |           ^~~~~~~~~~~