제출 #151495

#제출 시각아이디문제언어결과실행 시간메모리
151495outsiderArranging Shoes (IOI19_shoes)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "shoes.h" #define int #define x first #define y second using namespace std; ll n; vector<ll>a; vector<ll>t; void build(ll v,ll tl,ll tr) { if (tl==tr) t[v]=a[tl]; else { ll tm=(tl+tr)/2; build(v*2,tl,tm); build(v*2+1,tm+1,tr); t[v]=t[2*v]+t[2*v+1]; } } void update(ll v,ll tl,ll tr,ll l,ll r,ll new_value) { if (tl==l && tr==r) t[v]=new_value; else { if (l>r)return; ll tm=(tl+tr)/2; update(v*2,tl,tm,l,min(tm,r),new_value); update(v*2+1,tm+1,tr,max(tm+1,l),r,new_value); t[v]=t[2*v]+t[2*v+1]; } } ll get_sum(ll v,ll tl,ll tr,ll l,ll r) { if (l>r)return 0; if (tl==l && tr==r) return t[v]; ll tm=(tl+tr)/2; return min(get_sum(v*2,tl,tm,l,min(tm,r)), get_sum(v*2+1,tm+1,tr,max(l,tm+1),r)); } int count_swaps(vector<int> d) { n=d.size(); a.resize(n+1,1); t.resize(4*n+1); build(1,1,n); map<ll,deque<ll> >mp; for (int i=0;i<n;i++) mp[d[i]].push_back(i); ll ans=0; for (ll i=0;i<n;i++) { if (a[i]==0) continue; ll p=mp[-d[i]].front(); mp[-d[i]].pop_front(); mp[d[i]].pop_front(); update(1,1,n,p,p,0); update(1,1,n,i,i,0); a[i]=a[p]=0; ans+=get_sum(1,1,n,i,p); if (d[i]>0)ans++; } return ans; }

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

shoes.cpp:7:1: error: 'll' does not name a type
 ll n;
 ^~
shoes.cpp:8:8: error: 'll' was not declared in this scope
 vector<ll>a;
        ^~
shoes.cpp:8:10: error: template argument 1 is invalid
 vector<ll>a;
          ^
shoes.cpp:8:10: error: template argument 2 is invalid
shoes.cpp:9:8: error: 'll' was not declared in this scope
 vector<ll>t;
        ^~
shoes.cpp:9:10: error: template argument 1 is invalid
 vector<ll>t;
          ^
shoes.cpp:9:10: error: template argument 2 is invalid
shoes.cpp:10:12: error: variable or field 'build' declared void
 void build(ll v,ll tl,ll tr)
            ^~
shoes.cpp:10:12: error: 'll' was not declared in this scope
shoes.cpp:10:17: error: 'll' was not declared in this scope
 void build(ll v,ll tl,ll tr)
                 ^~
shoes.cpp:10:23: error: 'll' was not declared in this scope
 void build(ll v,ll tl,ll tr)
                       ^~
shoes.cpp:22:13: error: variable or field 'update' declared void
 void update(ll v,ll tl,ll tr,ll l,ll r,ll new_value)
             ^~
shoes.cpp:22:13: error: 'll' was not declared in this scope
shoes.cpp:22:18: error: 'll' was not declared in this scope
 void update(ll v,ll tl,ll tr,ll l,ll r,ll new_value)
                  ^~
shoes.cpp:22:24: error: 'll' was not declared in this scope
 void update(ll v,ll tl,ll tr,ll l,ll r,ll new_value)
                        ^~
shoes.cpp:22:30: error: 'll' was not declared in this scope
 void update(ll v,ll tl,ll tr,ll l,ll r,ll new_value)
                              ^~
shoes.cpp:22:35: error: 'll' was not declared in this scope
 void update(ll v,ll tl,ll tr,ll l,ll r,ll new_value)
                                   ^~
shoes.cpp:22:40: error: 'll' was not declared in this scope
 void update(ll v,ll tl,ll tr,ll l,ll r,ll new_value)
                                        ^~
shoes.cpp:37:1: error: 'll' does not name a type
 ll get_sum(ll v,ll tl,ll tr,ll l,ll r)
 ^~
shoes.cpp:49:27: error: wrong number of template arguments (0, should be at least 1)
 int count_swaps(vector<int> d)
                           ^
In file included from /usr/include/c++/7/vector:64:0,
                 from /usr/include/c++/7/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from shoes.cpp:1:
/usr/include/c++/7/bits/stl_vector.h:216:11: note: provided for 'template<class _Tp, class _Alloc> class std::vector'
     class vector : protected _Vector_base<_Tp, _Alloc>
           ^~~~~~
shoes.cpp:49:30: error: ISO C++ forbids declaration of 'count_swaps' with no type [-fpermissive]
 int count_swaps(vector<int> d)
                              ^
shoes.cpp: In function 'int count_swaps(int)':
shoes.cpp:51:1: error: 'n' was not declared in this scope
 n=d.size();
 ^
shoes.cpp:51:5: error: request for member 'size' in 'd', which is of non-class type 'int'
 n=d.size();
     ^~~~
shoes.cpp:52:3: error: request for member 'resize' in 'a', which is of non-class type 'int'
 a.resize(n+1,1);
   ^~~~~~
shoes.cpp:53:3: error: request for member 'resize' in 't', which is of non-class type 'int'
 t.resize(4*n+1);
   ^~~~~~
shoes.cpp:54:1: error: 'build' was not declared in this scope
 build(1,1,n);
 ^~~~~
shoes.cpp:55:5: error: 'll' was not declared in this scope
 map<ll,deque<ll> >mp;
     ^~
shoes.cpp:55:16: error: type/value mismatch at argument 1 in template parameter list for 'template<class _Tp, class _Alloc> class std::deque'
 map<ll,deque<ll> >mp;
                ^
shoes.cpp:55:16: note:   expected a type, got 'll'
shoes.cpp:55:16: error: template argument 2 is invalid
shoes.cpp:55:18: error: template argument 1 is invalid
 map<ll,deque<ll> >mp;
                  ^
shoes.cpp:55:18: error: template argument 2 is invalid
shoes.cpp:55:18: error: template argument 3 is invalid
shoes.cpp:55:18: error: template argument 4 is invalid
shoes.cpp:56:10: error: 'i' was not declared in this scope
 for (int i=0;i<n;i++)
          ^
shoes.cpp:58:4: error: expected ';' before 'ans'
 ll ans=0;
    ^~~
shoes.cpp:59:10: error: expected ';' before 'i'
  for (ll i=0;i<n;i++)
          ^
shoes.cpp:59:14: error: 'i' was not declared in this scope
  for (ll i=0;i<n;i++)
              ^
shoes.cpp:63:6: error: expected ';' before 'p'
   ll p=mp[-d[i]].front();
      ^
shoes.cpp:66:16: error: 'p' was not declared in this scope
   update(1,1,n,p,p,0);
                ^
shoes.cpp:66:16: note: suggested alternative: 'mp'
   update(1,1,n,p,p,0);
                ^
                mp
shoes.cpp:66:3: error: 'update' was not declared in this scope
   update(1,1,n,p,p,0);
   ^~~~~~
shoes.cpp:66:3: note: suggested alternative: 'getdate'
   update(1,1,n,p,p,0);
   ^~~~~~
   getdate
shoes.cpp:69:3: error: 'ans' was not declared in this scope
   ans+=get_sum(1,1,n,i,p);
   ^~~
shoes.cpp:69:3: note: suggested alternative: 'abs'
   ans+=get_sum(1,1,n,i,p);
   ^~~
   abs
shoes.cpp:69:8: error: 'get_sum' was not declared in this scope
   ans+=get_sum(1,1,n,i,p);
        ^~~~~~~
shoes.cpp:73:8: error: 'ans' was not declared in this scope
 return ans;
        ^~~
shoes.cpp:73:8: note: suggested alternative: 'abs'
 return ans;
        ^~~
        abs