제출 #289537

#제출 시각아이디문제언어결과실행 시간메모리
289537nekiArranging Shoes (IOI19_shoes)C++14
컴파일 에러
0 ms0 KiB
#include "shoes.h" #include <bits/stdc++.h> #define loop(i, a, b) for(long long i=a;i<b;i++) #define pool(i, a, b) for(long long i=a-1;i>=b;i--) #define fore(i, a) for(auto&& i:a) #define fi first #define se second #define ps(a) push_back(a) #define pb(a) pop_back(a) #define sc scanf #define vc vector #define pa pair<ll, ll> #define ll int #define lb lower_bound #define ub upper_bound #define all(a) a.begin(), a.end() #define llmax LLONG_MAX/2 #define llmin -LLONG_MAX/2 using namespace std; #define mn 262144 #define pa pair<ll, ll> #define ld long double queue<ll> poi[mn][2]; ll t[2 * mn]; void upd(ll l, ll r, ll val=1){ for(l+=mn, r+=mn;l<r;l>>=1, r>>=1){ if(l&1) t[l++]+=val; if(r&1) t[--r]+=val; } } ll get(ll pos){ ll ret=0; for(pos+=mn;pos>0;pos>>=1) ret+=t[pos]; return ret; } ll count_swaps(vc<ll> a){ ll n=a.size()/2; ll ans=0; loop(i, 0, 2* n){ ll t=a[i]; if(poi[abs(t)][t<0].size()){ ll match=poi[abs(t)][t<0].front();poi[abs(t)][t<0].pop(); ans+=i-get(match)-match; if(t>0) ans--; upd(match, i); } else poi[abs(t)][t>0].push(i); } cout << ans<<endl; }

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

shoes.cpp:38:4: error: ambiguating new declaration of 'int count_swaps(std::vector<int>)'
   38 | ll count_swaps(vc<ll> a){
      |    ^~~~~~~~~~~
In file included from shoes.cpp:1:
shoes.h:7:11: note: old declaration 'long long int count_swaps(std::vector<int>)'
    7 | long long count_swaps(std::vector<int> S);
      |           ^~~~~~~~~~~
shoes.cpp: In function 'int count_swaps(std::vector<int>)':
shoes.cpp:52:1: warning: no return statement in function returning non-void [-Wreturn-type]
   52 | }
      | ^