제출 #947733

#제출 시각아이디문제언어결과실행 시간메모리
947733biankArranging Shoes (IOI19_shoes)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define sz(x) int(x.size()) typedef long long ll; const int MAX_N = 2e5 + 20; int ft[MAX_N]; inline int lsb(int i) { return i & (-i); } void update(int i) { i++; while (i < MAX_N) { ft[i]++; i += lsb(i); } } int query(int i) { int s = 0; while (i > 0) { s += ft[i]; i -= lsb(i); } return s; } ll count_swaps(vector<int> S) { int n = sz(S); vector<pair<int, int>> pairs; map<int, queue<int>> m; for (int i = 0; i < n; i++) { if (!m[S[i]].empty()) { pairs.emplace_back(m[S[i]].front(), i); m[S[i]].pop(); } else { m[-S[i]].push(i); } } ll ans = 0; for (auto [x, y] : pairs) { if (S[y] < S[x]) { swap(x, y); } for (int p : vector{x, y}) { ans += p - query(p); update(p); } } return ans; }

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

shoes.cpp: In function 'll count_swaps(std::vector<int>)':
shoes.cpp:50:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   50 |  for (auto [x, y] : pairs) {
      |            ^
shoes.cpp:54:28: error: missing template arguments before '{' token
   54 |         for (int p : vector{x, y}) {
      |                            ^
shoes.cpp:54:28: error: expected ')' before '{' token
   54 |         for (int p : vector{x, y}) {
      |             ~              ^
      |                            )
shoes.cpp:54:29: warning: left operand of comma operator has no effect [-Wunused-value]
   54 |         for (int p : vector{x, y}) {
      |                             ^
shoes.cpp:54:33: error: expected ';' before '}' token
   54 |         for (int p : vector{x, y}) {
      |                                 ^
      |                                 ;
shoes.cpp:54:32: warning: right operand of comma operator has no effect [-Wunused-value]
   54 |         for (int p : vector{x, y}) {
      |                                ^
shoes.cpp:54:18: warning: unused variable 'p' [-Wunused-variable]
   54 |         for (int p : vector{x, y}) {
      |                  ^
shoes.cpp:54:34: error: expected primary-expression before ')' token
   54 |         for (int p : vector{x, y}) {
      |                                  ^