제출 #1256068

#제출 시각아이디문제언어결과실행 시간메모리
1256068trandangquangBitaro, who Leaps through Time (JOI19_timeleap)C++20
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define foru(i,a,b) for(int i=(a); i<=(b); ++i) #define ll long long const int N=3e5+5; bool stmem; int n,q; int fl[N],fr[N]; struct Node{ int x,y; ll p=-1; // void print(){ // printf("x: %d, y: %d, p: %lld\n",x,y,p); // } }; Node combine(Node u, Node v){ if(u.p==-1 && v.p==-1){ if(u.x>v.y) return Node{u.x, v.y, u.x-v.y}; if(u.y<v.x) return Node{u.y, v.x, 0ll}; return Node{max(u.x,v.x), min(u.y,v.y), -1}; } else if(u.p==-1 && v.p!=-1){ return Node{min(max(u.x,v.x),u.y), v.y, v.p+max(0ll,u.x-v.x)}; } else if(v.p==-1 && u.p!=-1){ return Node{u.x, max(min(u.y,v.y),v.x), u.p+max(0ll,u.y-v.y)}; } else{ return Node{u.x, v.y, u.p+v.p+max(0ll,u.y-v.x)}; } return Node{-1,-1,-1}; } struct SegmentTree{ int mode; Node st[N<<2]; void build(int id, int l, int r){ if(l==r){ if(mode==1) st[id]={fl[l]-l, fr[l]-l-1, -1}; else if(mode==2) st[id]={fl[l]-(n-l), fr[l]-(n-l)-1, -1}; return; } int mid=(l+r)>>1; build(id<<1,l,mid); build(id<<1|1,mid+1,r); if(mode==1) st[id]=combine(st[id<<1],st[id<<1|1]); else st[id]=combine(st[id<<1|1],st[id<<1]); } void upd(int x, int s, int t){ int id=1, l=1, r=n-1; while(true){ if(l==r) break; int mid=(l+r)>>1; if(x<=mid){ id=id<<1; r=mid; } else{ id=id<<1|1; l=mid+1; } } st[id]={s,t,-1}; while(id>1){ id/=2; if(mode==1) st[id]=combine(st[id<<1],st[id<<1|1]); else st[id]=combine(st[id<<1|1],st[id<<1]); } } Node get(int u, int v, int id, int l, int r){ if(u>r||v<l) return Node{-1,-1,-1}; if(u<=l&&r<=v) return st[id]; int mid=(l+r)>>1; if(v<=mid) return get(u,v,id<<1,l,mid); if(u>mid) return get(u,v,id<<1|1,mid+1,r); if(mode==1) return combine(get(u,v,id<<1,l,mid), get(u,v,id<<1|1,mid+1,r)); else return combine(get(u,v,id<<1|1,mid+1,r), get(u,v,id<<1,l,mid)); } } st1, st2; bool enmem; int32_t main(){ // freopen("test.inp","r",stdin); // freopen("test.out","w",stdout); cin.tie(0)->sync_with_stdio(0); cin>>n>>q; foru(i,1,n-1){ cin>>fl[i]>>fr[i]; } if(n>1){ st1.mode=1; st1.build(1,1,n-1); st2.mode=2; st2.build(1,1,n-1); } int a,b,c,d; foru(i,1,q){ int t; cin>>t; if(t==1){ cin>>a>>b>>c; st1.upd(a,b-a,c-a-1); st2.upd(a,b-(n-a),c-(n-a)-1); } else{ cin>>a>>b>>c>>d; if(a==c){ cout<<max(0ll,b-d)<<'\n'; continue; } if(a<c){ b-=a, d-=c; cout<<max(0ll,combine(combine(Node{b,b,-1},st1.get(a,c-1,1,1,n-1)),Node{d,d,-1}).p)<<'\n'; } else{ b-=n-(a-1), d-=n-(c-1); cout<<max(0ll,combine(combine(Node{b,b,-1},st2.get(c,a-1,1,1,n-1)),Node{d,d,-1}).p)<<'\n'; } } } fprintf(stderr,"Memory used: %.2fMB.\n", (&stmem-&enmem)/1024.0/1024.0); }

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

timeleap.cpp: In function 'Node combine(Node, Node)':
timeleap.cpp:26:56: error: no matching function for call to 'max(long long int, int)'
   26 |         return Node{min(max(u.x,v.x),u.y), v.y, v.p+max(0ll,u.x-v.x)};
      |                                                     ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from timeleap.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
timeleap.cpp:26:56: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   26 |         return Node{min(max(u.x,v.x),u.y), v.y, v.p+max(0ll,u.x-v.x)};
      |                                                     ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from timeleap.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
timeleap.cpp:26:56: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   26 |         return Node{min(max(u.x,v.x),u.y), v.y, v.p+max(0ll,u.x-v.x)};
      |                                                     ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from timeleap.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3461 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3461:5: note:   template argument deduction/substitution failed:
timeleap.cpp:26:56: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   26 |         return Node{min(max(u.x,v.x),u.y), v.y, v.p+max(0ll,u.x-v.x)};
      |                                                     ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from timeleap.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   template argument deduction/substitution failed:
timeleap.cpp:26:56: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   26 |         return Node{min(max(u.x,v.x),u.y), v.y, v.p+max(0ll,u.x-v.x)};
      |                                                     ~~~^~~~~~~~~~~~~
timeleap.cpp:28:56: error: no matching function for call to 'max(long long int, int)'
   28 |         return Node{u.x, max(min(u.y,v.y),v.x), u.p+max(0ll,u.y-v.y)};
      |                                                     ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from timeleap.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
timeleap.cpp:28:56: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   28 |         return Node{u.x, max(min(u.y,v.y),v.x), u.p+max(0ll,u.y-v.y)};
      |                                                     ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from timeleap.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
timeleap.cpp:28:56: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   28 |         return Node{u.x, max(min(u.y,v.y),v.x), u.p+max(0ll,u.y-v.y)};
      |                                                     ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from timeleap.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3461 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3461:5: note:   template argument deduction/substitution failed:
timeleap.cpp:28:56: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   28 |         return Node{u.x, max(min(u.y,v.y),v.x), u.p+max(0ll,u.y-v.y)};
      |                                                     ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from timeleap.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   template argument deduction/substitution failed:
timeleap.cpp:28:56: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   28 |         return Node{u.x, max(min(u.y,v.y),v.x), u.p+max(0ll,u.y-v.y)};
      |                                                     ~~~^~~~~~~~~~~~~
timeleap.cpp:30:42: error: no matching function for call to 'max(long long int, int)'
   30 |         return Node{u.x, v.y, u.p+v.p+max(0ll,u.y-v.x)};
      |                                       ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from timeleap.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
timeleap.cpp:30:42: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   30 |         return Node{u.x, v.y, u.p+v.p+max(0ll,u.y-v.x)};
      |                                       ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from timeleap.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
timeleap.cpp:30:42: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   30 |         return Node{u.x, v.y, u.p+v.p+max(0ll,u.y-v.x)};
      |                                       ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from timeleap.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3461 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3461:5: note:   template argument deduction/substitution failed:
timeleap.cpp:30:42: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   30 |         return Node{u.x, v.y, u.p+v.p+max(0ll,u.y-v.x)};
      |                                       ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from timeleap.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   template argument deduction/substitution failed:
timeleap.cpp:30:42: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   30 |         return Node{u.x, v.y, u.p+v.p+max(0ll,u.y-v.x)};
      |                                       ~~~^~~~~~~~~~~~~
timeleap.cpp: In function 'int32_t main()':
timeleap.cpp:111:26: error: no matching function for call to 'max(long long int, int)'
  111 |                 cout<<max(0ll,b-d)<<'\n';
      |                       ~~~^~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from timeleap.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
timeleap.cpp:111:26: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
  111 |                 cout<<max(0ll,b-d)<<'\n';
      |                       ~~~^~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from timeleap.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
timeleap.cpp:111:26: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
  111 |                 cout<<max(0ll,b-d)<<'\n';
      |                       ~~~^~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from timeleap.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3461 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3461:5: note:   template argument deduction/substitution failed:
timeleap.cpp:111:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  111 |                 cout<<max(0ll,b-d)<<'\n';
      |                       ~~~^~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from timeleap.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   template argument deduction/substitution failed:
timeleap.cpp:111:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  111 |                 cout<<max(0ll,b-d)<<'\n';
      |                       ~~~^~~~~~~~~