Submission #211086

#TimeUsernameProblemLanguageResultExecution timeMemory
211086wanling1212Arranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #inclde "shoes.h" using namespace std; #define pb push_back #define rep(i,n) for(ll i=0;i<n;i++) #define rep1(i,n) for(ll i=1;i<=n;i++) #define mp make_pair #define F first #define S second #define pf pop_front #define IOS ios_base::sync_with_stdio(0); cin.tie(0) #define ll int typedef long long ll; const ll mod=1e9+7; const ll maxn=100005; const ll inf=1e9+7; map<ll,queue<int>> m; int bit[maxn]; int lsb(int x) { return x&(-x); } void add(int x,int v) { while(x<maxn) { bit[x]+=v; x+=lsb(x); } } int query(int x) { int res=0; while(x) { res+=bit[x]; x-=lsb(x); } return res; } ll count_swaps(std::vector<int> s) { rep(i,s.size()) { m[s[i]].push(i); add(i+1,1); } ll sum=0; rep(i,s.size()) { queue<int> q=m[-s[i]]; if(q.empty()) continue; if(m[s[i]].front()!=i) continue; int p=q.front(); m[-s[i]].pop(); m[s[i]].pop(); sum+=query(p)-query(i+1); if(s[i]>0) sum++; //cout<<i<<" "<<sum<<"\n"; add(p+1,-1); add(i+1,-1); } return sum; } ll n; vector<int> v; int main() { while(cin>>n) { rep(i,n) { ll tmp; cin>>tmp; v.pb(tmp); } cout<<count_swaps(v)<<"\n"; } }

Compilation message (stderr)

shoes.cpp:2:2: error: invalid preprocessing directive #inclde; did you mean #include?
 #inclde "shoes.h"
  ^~~~~~
  include
shoes.cpp:12:12: error: declaration does not declare anything [-fpermissive]
 #define ll int
            ^
shoes.cpp:13:19: note: in expansion of macro 'll'
 typedef long long ll;
                   ^~
shoes.cpp: In function 'int count_swaps(std::vector<int>)':
shoes.cpp:5:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define rep(i,n) for(ll i=0;i<n;i++)
shoes.cpp:43:9:
     rep(i,s.size())
         ~~~~~~~~~~            
shoes.cpp:43:5: note: in expansion of macro 'rep'
     rep(i,s.size())
     ^~~
shoes.cpp:5:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define rep(i,n) for(ll i=0;i<n;i++)
shoes.cpp:49:9:
     rep(i,s.size())
         ~~~~~~~~~~            
shoes.cpp:49:5: note: in expansion of macro 'rep'
     rep(i,s.size())
     ^~~