제출 #156150

#제출 시각아이디문제언어결과실행 시간메모리
156150wildturtleArranging Shoes (IOI19_shoes)C++14
컴파일 에러
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],le,ri; 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<=ri && 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; }

컴파일 시 표준 에러 (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 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:42:49: error: 'R' was not declared in this scope
                                             idx=R[s[i]][B[s[i]]];   
                                                 ^