제출 #767681

#제출 시각아이디문제언어결과실행 시간메모리
767681ono_de206Arranging Shoes (IOI19_shoes)C++14
컴파일 에러
0 ms0 KiB
#include "shoes.h" #include<bits/stdc++.h> using namespace std; #define in insert #define all(x) x.begin(),x.end() #define pb push_back #define eb emplace_back #define ff first #define ss second // #define int long long typedef long long ll; typedef vector<int> vi; typedef set<int> si; typedef multiset<int> msi; typedef pair<int, int> pii; typedef vector<pii> vpii; const int mxn = 1e5 + 10; int a[mxn], fn[mxn], n; queue<int> q[mxn][3]; void add(int i, int val) { for(; i; i -= (i & -i)) { fn[i] += val; } } int get(int i) { int ret = 0; for(; i <= n; i += (i & -i)) { ret += fn[i]; } return ret; } long long count_swaps(vector<int> s) { n = (int)s.size() * 2; for(int i = 1; i <= n; i++) { a[i] = s[i - 1]; } int ret = 0; for(int i = 1; i <= n; i++) { if(a[i] > 0) { if(q[a[i]][0].size()) { int lst = q[a[i]][0].front(); q[a[i]][0].pop(); ans += (i - lst - 1) - (get(i) - get(lst)); add(i, -1); add(lst, 1); } else { q[a[i]][1].push(i); } } else { if(q[a[i]][1].size()) { int lst = q[a[i]][1].front(); q[a[i]][1].pop(); ans += (i - lst) - (get(i) - get(lst)); add(i, -1); add(lst, 1); } else { q[a[i]][0].push(i); } } } return ret; }

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:50:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   50 |     ans += (i - lst - 1) - (get(i) - get(lst));
      |     ^~~
      |     abs
shoes.cpp:60:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   60 |     ans += (i - lst) - (get(i) - get(lst));
      |     ^~~
      |     abs