제출 #334295

#제출 시각아이디문제언어결과실행 시간메모리
334295nicholaskArranging Shoes (IOI19_shoes)C++14
컴파일 에러
0 ms0 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; int bit[200005]; void add(int x,int v){ for (int i=x; i<200005; i+=(i&-i)) bit[i]+=v; } int query(int x){ int ans=0; for (int i=x; i; i-=(i&-i)) ans+=bit[i]; return ans; } long long count_swaps(vector <int> s){ int n=(s.size()>>1),ans=0; vector <pair <int,int> > shs[100001]; vector <pair <int,int> > q; for (int i=0; i<n+n; i++) shs[abs(s[i])].push_back({s[i],i}); for (int i=1; i<100001; i++){ sort(shs[i].begin(),shs[i].end()); int m=(shs[i].size()>>1); for (int j=0; j<m; j++){ int ff=shs[i][j].second,ss=shs[i][j+m].second; if (ff>ss){ swap(ff,ss); ans++; } q.push_back(ff+1,rr+1); } } sort(q.begin(),q.end()); for (int i=1; i<=n+n; i++) add(i,1); for (auto&i:q){ ans+=query(i.second-1)-query(i.first); add(i.first,-1); add(i.second,-1); } return ans; }

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:27:21: error: 'rr' was not declared in this scope
   27 |    q.push_back(ff+1,rr+1);
      |                     ^~