제출 #409613

#제출 시각아이디문제언어결과실행 시간메모리
409613MKopchev모임들 (IOI18_meetings)C++14
컴파일 에러
0 ms0 KiB
#include "meetings.h" #include<bits/stdc++.h> using namespace std; /* namespace { int read_int() { int x; if (scanf("%d", &x) != 1) { fprintf(stderr, "Error while reading input\n"); exit(1); } return x; } } // namespace struct info { int l,r,av; long long outp; int left_child,right_child; }; */ vector<info> tree; vector<int> inp; long long build(int node,int l,int r) { if(l>r)return 0; int mx=0; for(int j=l;j<=r;j++) mx=max(mx,inp[j]); vector<int> v={}; for(int j=l;j<=r;j++) if(inp[j]==mx)v.push_back(j); int cur=tree.size(); int av=v[v.size()/2]; info me; me.l=l; me.r=r; me.av=av; tree.push_back(me); tree[node].left_child=node+1; long long LHS=build(tree.size(),l,av-1)+1LL*mx*(r-av+1); tree[node].right_child=tree.size(); long long RHS=build(tree.size(),av+1,r)+1LL*mx*(av-l+1); tree[node].outp=min(LHS,RHS); //cout<<l<<" "<<r<<" -> "<<tree[node].outp<<endl; return min(LHS,RHS); } long long query(int node,int l,int r,int lq,int rq) { if(l>r||lq>rq)return 0; if(l==lq&&r==rq)return tree[node].outp; int av=tree[node].av; if(rq<av)return query(tree[node].left_child,l,tree[node].av-1,lq,rq); if(av<lq)return query(tree[node].right_child,tree[node].av+1,r,lq,rq); long long LHS=query(tree[node].left_child,l,av-1,lq,av-1)+1LL*(rq-av+1)*inp[tree[node].av]; long long RHS=query(tree[node].right_child,av+1,r,av+1,rq)+1LL*(av-lq+1)*inp[tree[node].av]; return min(LHS,RHS); } std::vector<long long> minimum_costs(std::vector<int> H, std::vector<int> L, std::vector<int> R) { inp=H; build(0,0,inp.size()-1); vector<long long> outp={}; for(int i=0;i<L.size();i++) outp.push_back(query(0,0,inp.size()-1,L[i],R[i])); return outp; } /* int main() { int N = read_int(); int Q = read_int(); std::vector<int> H(N); for (int i = 0; i < N; ++i) { H[i] = read_int(); } std::vector<int> L(Q), R(Q); for (int j = 0; j < Q; ++j) { L[j] = read_int(); R[j] = read_int(); } std::vector<long long> C = minimum_costs(H, L, R); for (size_t j = 0; j < C.size(); ++j) { printf("%lld\n", C[j]); } return 0; } */

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

meetings.cpp:26:8: error: 'info' was not declared in this scope
   26 | vector<info> tree;
      |        ^~~~
meetings.cpp:26:12: error: template argument 1 is invalid
   26 | vector<info> tree;
      |            ^
meetings.cpp:26:12: error: template argument 2 is invalid
meetings.cpp: In function 'long long int build(int, int, int)':
meetings.cpp:42:18: error: request for member 'size' in 'tree', which is of non-class type 'int'
   42 |     int cur=tree.size();
      |                  ^~~~
meetings.cpp:46:5: error: 'info' was not declared in this scope
   46 |     info me;
      |     ^~~~
meetings.cpp:47:5: error: 'me' was not declared in this scope; did you mean 'mx'?
   47 |     me.l=l;
      |     ^~
      |     mx
meetings.cpp:51:10: error: request for member 'push_back' in 'tree', which is of non-class type 'int'
   51 |     tree.push_back(me);
      |          ^~~~~~~~~
meetings.cpp:53:9: error: invalid types 'int[int]' for array subscript
   53 |     tree[node].left_child=node+1;
      |         ^
meetings.cpp:55:30: error: request for member 'size' in 'tree', which is of non-class type 'int'
   55 |     long long LHS=build(tree.size(),l,av-1)+1LL*mx*(r-av+1);
      |                              ^~~~
meetings.cpp:57:9: error: invalid types 'int[int]' for array subscript
   57 |     tree[node].right_child=tree.size();
      |         ^
meetings.cpp:57:33: error: request for member 'size' in 'tree', which is of non-class type 'int'
   57 |     tree[node].right_child=tree.size();
      |                                 ^~~~
meetings.cpp:59:30: error: request for member 'size' in 'tree', which is of non-class type 'int'
   59 |     long long RHS=build(tree.size(),av+1,r)+1LL*mx*(av-l+1);
      |                              ^~~~
meetings.cpp:61:9: error: invalid types 'int[int]' for array subscript
   61 |     tree[node].outp=min(LHS,RHS);
      |         ^
meetings.cpp:42:9: warning: unused variable 'cur' [-Wunused-variable]
   42 |     int cur=tree.size();
      |         ^~~
meetings.cpp: In function 'long long int query(int, int, int, int, int)':
meetings.cpp:72:32: error: invalid types 'int[int]' for array subscript
   72 |     if(l==lq&&r==rq)return tree[node].outp;
      |                                ^
meetings.cpp:74:16: error: invalid types 'int[int]' for array subscript
   74 |     int av=tree[node].av;
      |                ^
meetings.cpp:76:31: error: invalid types 'int[int]' for array subscript
   76 |     if(rq<av)return query(tree[node].left_child,l,tree[node].av-1,lq,rq);
      |                               ^
meetings.cpp:76:55: error: invalid types 'int[int]' for array subscript
   76 |     if(rq<av)return query(tree[node].left_child,l,tree[node].av-1,lq,rq);
      |                                                       ^
meetings.cpp:78:31: error: invalid types 'int[int]' for array subscript
   78 |     if(av<lq)return query(tree[node].right_child,tree[node].av+1,r,lq,rq);
      |                               ^
meetings.cpp:78:54: error: invalid types 'int[int]' for array subscript
   78 |     if(av<lq)return query(tree[node].right_child,tree[node].av+1,r,lq,rq);
      |                                                      ^
meetings.cpp:80:29: error: invalid types 'int[int]' for array subscript
   80 |     long long LHS=query(tree[node].left_child,l,av-1,lq,av-1)+1LL*(rq-av+1)*inp[tree[node].av];
      |                             ^
meetings.cpp:80:85: error: invalid types 'int[int]' for array subscript
   80 |     long long LHS=query(tree[node].left_child,l,av-1,lq,av-1)+1LL*(rq-av+1)*inp[tree[node].av];
      |                                                                                     ^
meetings.cpp:81:29: error: invalid types 'int[int]' for array subscript
   81 |     long long RHS=query(tree[node].right_child,av+1,r,av+1,rq)+1LL*(av-lq+1)*inp[tree[node].av];
      |                             ^
meetings.cpp:81:86: error: invalid types 'int[int]' for array subscript
   81 |     long long RHS=query(tree[node].right_child,av+1,r,av+1,rq)+1LL*(av-lq+1)*inp[tree[node].av];
      |                                                                                      ^
meetings.cpp: In function 'std::vector<long long int> minimum_costs(std::vector<int>, std::vector<int>, std::vector<int>)':
meetings.cpp:93:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   93 |   for(int i=0;i<L.size();i++)
      |               ~^~~~~~~~~