Submission #156149

#TimeUsernameProblemLanguageResultExecution timeMemory
156149wildturtleArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include "shoes.h" long long a,b,c,d,i,e,f,g,n,m,k,l,ans,idx,tree[200005],fix[200005],A[200005],B[200005]; vector <long long> L[200005],R[200005]; void upd(long long node,long long tl,long long tr,long long pos){ if(tl==tr) { tree[node]=1; return; } long long mid=(tl+tr)/2; if(pos<=mid) upd(node*2,tl,mid,pos); else upd(node*2+1,mid+1,tr,pos); tree[node]=tree[node*2]+tree[node*2+1]; } long long get(long long node,long long tl,long long tr){ if(ri<tl || tr<le) return 0; if(tr<=ro && le<=tl) return tree[node]; long long mid=(tr+tl)/2; long long x=get(node*2,tl,mid); long long y=get(node*2+1,mid+1,tr); return x+y; } long long count_swaps(std::vector<int> s) { n=s.size(); for(long long i=0;i<n;i++) { if(s[i]<0) { L[-s[i]].push_back(i); } else { R[s[i]].push_back(i); } } for(long long i=0;i<n;i++) { if(fix[i]==0) { if(s[i]<0) { idx=L[-s[i]][A[-s[i]]]; ri=idx; le=i; ans+=(ri-le-1-get(1,0,n-1)); A[-s[i]]++; B[-s[i]]++; fix[idx]++; upd(1,0,n-1,idx); } else { idx=R[s[i]][B[s[i]]]; ri=idx; le=i; ans+=(ri-le-1-get(1,0,n-1)); A[s[i]]++; B[s[i]]++; fix[idx]++; upd(1,0,n-1,idx); } } } return ans; }

Compilation message (stderr)

shoes.cpp:3:1: error: 'vector' does not name a type
 vector <long long> L[200005],R[200005];
 ^~~~~~
shoes.cpp: In function 'long long int get(long long int, long long int, long long int)':
shoes.cpp:12:5: error: 'ri' was not declared in this scope
  if(ri<tl || tr<le) return 0;
     ^~
shoes.cpp:12:5: note: suggested alternative: 'i'
  if(ri<tl || tr<le) return 0;
     ^~
     i
shoes.cpp:12:17: error: 'le' was not declared in this scope
  if(ri<tl || tr<le) return 0;
                 ^~
shoes.cpp:12:17: note: suggested alternative: 'l'
  if(ri<tl || tr<le) return 0;
                 ^~
                 l
shoes.cpp:13:9: error: 'ro' was not declared in this scope
  if(tr<=ro && le<=tl) return tree[node];
         ^~
shoes.cpp:13:15: error: 'le' was not declared in this scope
  if(tr<=ro && le<=tl) return tree[node];
               ^~
shoes.cpp:13:15: note: suggested alternative: 'l'
  if(tr<=ro && le<=tl) return tree[node];
               ^~
               l
shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:23:34: error: 'L' was not declared in this scope
                                  L[-s[i]].push_back(i);
                                  ^
shoes.cpp:26:34: error: 'R' was not declared in this scope
                                  R[s[i]].push_back(i);
                                  ^
shoes.cpp:32:49: error: 'L' was not declared in this scope
                                             idx=L[-s[i]][A[-s[i]]];
                                                 ^
shoes.cpp:33:45: error: 'ri' was not declared in this scope
                                             ri=idx;
                                             ^~
shoes.cpp:33:45: note: suggested alternative: 'i'
                                             ri=idx;
                                             ^~
                                             i
shoes.cpp:34:45: error: 'le' was not declared in this scope
                                             le=i;
                                             ^~
shoes.cpp:34:45: note: suggested alternative: 'l'
                                             le=i;
                                             ^~
                                             l
shoes.cpp:42:49: error: 'R' was not declared in this scope
                                             idx=R[s[i]][B[s[i]]];   
                                                 ^
shoes.cpp:43:45: error: 'ri' was not declared in this scope
                                             ri=idx;
                                             ^~
shoes.cpp:43:45: note: suggested alternative: 'i'
                                             ri=idx;
                                             ^~
                                             i
shoes.cpp:44:45: error: 'le' was not declared in this scope
                                             le=i;
                                             ^~
shoes.cpp:44:45: note: suggested alternative: 'l'
                                             le=i;
                                             ^~
                                             l