제출 #145540

#제출 시각아이디문제언어결과실행 시간메모리
145540Sarah_MokhtarArranging Shoes (IOI19_shoes)C++14
컴파일 에러
0 ms0 KiB
#include "shoes.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=1e6+10,M=(N<<4),OO=0x3f3f3f; int pos[N],BIT[M],n; void update(int idx,int val){ ++idx; while(idx<=n){ BIT[idx]+=val; idx+=(idx&-idx); } } ll query(int r){ ll res=0; ++r; while(r>0){ res+=BIT[r]; r-=(r&-r); } return res; } ll count_swaps(vector<int>s){ map<int,vector<int>>m; ret=0; int n=s.size(); for(int i=0;i<n;++i) update(i,1); for(int i=n-1;i>=0;--i) m[s[i]].push_back(i); for(int i=0;i<n;++i){ if(query(i)-query(i-1)!=1) continue; int k=m[-s[i]].back(); m[s[i]].pop_back(); m[-s[i]].pop_back(); update(i,-1); update(k,-1); ret+=query(k)-query(i); if(s[i]>0) ++ret; } return ret; }

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

shoes.cpp: In function 'll count_swaps(std::vector<int>)':
shoes.cpp:25:5: error: 'ret' was not declared in this scope
     ret=0;
     ^~~
shoes.cpp:25:5: note: suggested alternative: 'getw'
     ret=0;
     ^~~
     getw