제출 #1004499

#제출 시각아이디문제언어결과실행 시간메모리
1004499jamjanekBulldozer (JOI17_bulldozer)C++14
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; pair<pair<int,int>,int>tab[2010]; int miejsce[2010]; vector<pair<int,int>>vec; int sign(long long x){ if(x<0)return -1; return x>0; } bool notparallel(pair<int,int> a, pair<int,int> b){ long long Ax=tab[a.first].first.first-tab[a.second].first.first, Ay=tab[a.first].first.second-tab[a.second].first.second, Bx=tab[b.first].first.first-tab[b.second].first.first, By=tab[b.first].first.second-tab[b.second].first.second; if(sign(Ax)!=sign(Bx) || sign(Ay)!=sign(By))return 1; return Ax*By!=Ay*Bx; } bool cmp(pair<int,int>a, pair<int,int>b){ long long Ax=tab[a.first].first.first-tab[a.second].first.first, Ay=tab[a.first].first.second-tab[a.second].first.second, Bx=tab[b.first].first.first-tab[b.second].first.first, By=tab[b.first].first.second-tab[b.second].first.second; if(!notparallel(a,b))return 0; if(Bx==0&&By>0)return 0; if(Ax==0&&Ay>0)return 1; if(Bx==0)return Ax>0; if(Ax==0)return Bx<0; if(sign(Ax)!=sign(Bx))return Ax>0; return Ay*Bx>By*Ax;//Ay/Ax>By/Bx; } const int base=1<<11; struct node{long long sum, maxi, lmaxi, rmaxi;}; node tree[2*base]; void ustaw(int x, long long val){ x+=base; tree[x].sum=val; tree[x].lmaxi = tree[x].rmaxi = tree[x].maxi=max(0,val); x/=2; while(x>0){ tree[x].maxi=max({tree[x*2].maxi, tree[x*2+1].maxi, tree[x*2].rmaxi+tree[x*2+1].lmaxi}); tree[x].sum=tree[x*2].sum+tree[x*2+1].sum; tree[x].lmaxi=max(tree[x*2].lmaxi, tree[x*2].sum+tree[x*2+1].lmaxi); tree[x].rmaxi=max(tree[x*2+1].rmaxi, tree[x*2+1].sum+tree[x*2].rmaxi); x/=2; } } int main() { int n, i, j; scanf("%d", &n); for(i=0;i<n;i++){ scanf("%d%d%d", &tab[i].first.first, &tab[i].first.second, &tab[i].second); } sort(tab, tab+n); for(i=0;i<n;i++){ for(j=0;j<n;j++) if(i!=j){ vec.push_back({i,j}); } } sort(vec.begin(), vec.end(), cmp); for(i=0;i<n;i++){ ustaw(i, tab[i].second); miejsce[i] = i; } long long res = max(0ll, tree[1].maxi); for(i=0;i<(int)vec.size();i++){ swap(miejsce[vec[i].first], miejsce[vec[i].second]); ustaw(miejsce[vec[i].first], tab[vec[i].first].second); ustaw(miejsce[vec[i].second], tab[vec[i].second].second); if(i!=(int)vec.size()-1 && notparallel(vec[i], vec[i+1])) res = max(res, tree[1].maxi); } printf("%lld\n", res); }

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

bulldozer.cpp: In function 'void ustaw(int, long long int)':
bulldozer.cpp:31:57: error: no matching function for call to 'max(int, long long int&)'
   31 |   tree[x].lmaxi = tree[x].rmaxi = tree[x].maxi=max(0,val);
      |                                                         ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from bulldozer.cpp:1:
/usr/include/c++/10/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++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
bulldozer.cpp:31:57: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   31 |   tree[x].lmaxi = tree[x].rmaxi = tree[x].maxi=max(0,val);
      |                                                         ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from bulldozer.cpp:1:
/usr/include/c++/10/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++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
bulldozer.cpp:31:57: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   31 |   tree[x].lmaxi = tree[x].rmaxi = tree[x].maxi=max(0,val);
      |                                                         ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from bulldozer.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
bulldozer.cpp:31:57: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   31 |   tree[x].lmaxi = tree[x].rmaxi = tree[x].maxi=max(0,val);
      |                                                         ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from bulldozer.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
bulldozer.cpp:31:57: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   31 |   tree[x].lmaxi = tree[x].rmaxi = tree[x].maxi=max(0,val);
      |                                                         ^
bulldozer.cpp: In function 'int main()':
bulldozer.cpp:44:12: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |       scanf("%d", &n);
      |       ~~~~~^~~~~~~~~~
bulldozer.cpp:46:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |         scanf("%d%d%d", &tab[i].first.first, &tab[i].first.second, &tab[i].second);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~