제출 #438730

#제출 시각아이디문제언어결과실행 시간메모리
438730farukArranging Shoes (IOI19_shoes)C++17
컴파일 에러
0 ms0 KiB
#include <iostream> #include <algorithm> #include <map> #include <vector> #define ll long long using namespace std; class BIT { private: vector<ll> tree; int n; public: BIT(int sizeOfTree) { n = sizeOfTree; tree.resize(n + 1, 0); } void update(int index, ll value) { index++; while (index < n) tree[index] += value, index += index & (-index); } ll query(int index) { index++; ll out = 0; while (index > 0) out += tree[index], index -= index & (-index); return out; } }; map<int, vector<int> > located; map<int, int> used; map<int, bool> matched; ll count_swaps(int[] S) { int n = sizeof(S); BIT passed(n); for (int i = 0; i < n; i++) located[S[i]].push_back(i); ll out = 0; for (int i = 0; i < n; i++) { if (matched[i]) continue; int counterpart = upper_bound(located[-S[i]].begin(), located[-S[i]].end(), used[-S[i]]) - located[-S[i]].begin(); int val = located[-S[i]][counterpart]; matched[val] = true; int swaps = (val - i) /*+ passed.query(val)*/; passed.update(val, 1); used[-S[i]] = val; used[S[i]] = i; if (S[i] < 0) swaps--; out += swaps; } return out; }

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

shoes.cpp:44:22: error: expected ',' or '...' before 'S'
   44 | ll count_swaps(int[] S)
      |                      ^
shoes.cpp: In function 'long long int count_swaps(int*)':
shoes.cpp:46:20: error: 'S' was not declared in this scope
   46 |     int n = sizeof(S);
      |                    ^