제출 #776983

#제출 시각아이디문제언어결과실행 시간메모리
776983Trisanu_DasArranging Shoes (IOI19_shoes)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long ll n, BIT[100005]; queue<ll> l_unpair[100005], r_unpair[100005]; void upd(int idx, ll val){ for(int i = idx; i < n + 1; i += (i & (-i))) BIT[i] += val; } ll qry(int idx){ ll ans = 0; for(int i = idx; i > 0; i -= (i & (-i))) ans += BIT[i]; return ans; } ll count_swaps(vector<int> s){ n = s.size(); ll swaps = 0; for(int i = 1; i < n + 1; i++){ ll shoe_sz = s[i - 1]; if(s_szhoe < 0){ shoe_sz *= -1; // extracting shoe size; if(!r_unpair[shoe_sz].empty()){ //has a shoe unpaired of this(shoe_sz) size. ll shoe_need = r_unpair[shoe_sz].front(); r_unpair[shoe_sz].pop(); swaps += qry(i) - qry(shoe_need - 1); upd(shoe_need, 1); }else{ // no shoe. l_unpair[shoe_sz].push(i); upd(i, 1); } }else{ if(!l_unpair[shoe_sz].empty()){ //has a shoe unpaired of this(shoe_sz) size. ll shoe_need = l_unpair[shoe_sz].front(); l_unpair[shoe_sz].pop(); swaps += qry(i) - qry(shoe_need); upd(shoe_need, 1); }else{ // no shoe. r_unpair[shoe_sz].push(i); upd(i, 1); } } } return swaps; }

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:23:8: error: 's_szhoe' was not declared in this scope
   23 |     if(s_szhoe < 0){
      |        ^~~~~~~