# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
51690 | 2018-06-20T04:14:23 Z | tmwilliamlin168 | Fireworks (APIO16_fireworks) | C++14 | 컴파일 오류 |
0 ms | 0 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long const int mxN=3e5; int n, m, p[mxN]; vector<int> adj[mxN]; ll c[mxN], y0[mxN], y1[mxN]; vector<ll> pc[mxN]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; for(int i=1; i<n+m; ++i) { cin >> p[i] >> c[i], --p[i]; adj[p[i]].push_back(i); } for(int i=1; i<n; ++i) { if(adj[i].size()==1) { c[adj[i][0]]+=c[i]; adj[p[i]].push_back(adj[i][0]); } } for(int i=n+m-1; i>=0; --i) { if(adj[i].size()==1&&i) continue; if(i>=n) { y1[i]=-1; pc[i].push_back(0); pc[i].push_back(0); } for(int j : adj[i]) { if(!y0[j]) continue; y0[i]+=y0[j]; y1[i]+=y1[j]; pc[i].insert(pc[i].end(), pc[j].begin(), pc[j].end()); } sort(pc[i].begin(), pc[i].end()); pc[i].erase(pc[i].begin()-y1[i]+1, pc[i].end()); pc[i][-y1[i]-1]+=c[i]; pc[i][-y1[i]]+=c[i]; y0[i]+=c[i]; } ll ans=y0[0]; for(int i=0; i<-y1[0]; ++i) ans+=(y1[0]+i)*(pc[0][i+1]-pc[0][i]); cout << ans; }
Compilation message
fireworks.cpp:9:18: error: 'long long int y0 [300000]' redeclared as different kind of symbol ll c[mxN], y0[mxN], y1[mxN]; ^ In file included from /usr/include/features.h:367:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/os_defines.h:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/c++config.h:533, from /usr/include/c++/7/cassert:43, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:33, from fireworks.cpp:1: /usr/include/x86_64-linux-gnu/bits/mathcalls.h:250:1: note: previous declaration 'double y0(double)' __MATHCALL (y0,, (_Mdouble_)); ^ fireworks.cpp:9:27: error: 'long long int y1 [300000]' redeclared as different kind of symbol ll c[mxN], y0[mxN], y1[mxN]; ^ In file included from /usr/include/features.h:367:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/os_defines.h:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/c++config.h:533, from /usr/include/c++/7/cassert:43, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:33, from fireworks.cpp:1: /usr/include/x86_64-linux-gnu/bits/mathcalls.h:251:1: note: previous declaration 'double y1(double)' __MATHCALL (y1,, (_Mdouble_)); ^ fireworks.cpp: In function 'int main()': fireworks.cpp:31:8: warning: pointer to a function used in arithmetic [-Wpointer-arith] y1[i]=-1; ^ fireworks.cpp:31:11: error: assignment of read-only location '*(y1 + ((sizetype)i))' y1[i]=-1; ^ fireworks.cpp:31:11: error: cannot convert 'int' to 'double(double) throw ()' in assignment fireworks.cpp:36:12: warning: pointer to a function used in arithmetic [-Wpointer-arith] if(!y0[j]) ^ fireworks.cpp:38:8: warning: pointer to a function used in arithmetic [-Wpointer-arith] y0[i]+=y0[j]; ^ fireworks.cpp:38:15: warning: pointer to a function used in arithmetic [-Wpointer-arith] y0[i]+=y0[j]; ^ fireworks.cpp:38:9: error: invalid operands of types 'double(double) throw ()' and 'double(double) throw ()' to binary 'operator+' y0[i]+=y0[j]; ~~~~~^~~~~~~ fireworks.cpp:38:15: error: in evaluation of 'operator+=(double(double) throw (), double(double) throw ())' y0[i]+=y0[j]; ^ fireworks.cpp:39:8: warning: pointer to a function used in arithmetic [-Wpointer-arith] y1[i]+=y1[j]; ^ fireworks.cpp:39:15: warning: pointer to a function used in arithmetic [-Wpointer-arith] y1[i]+=y1[j]; ^ fireworks.cpp:39:9: error: invalid operands of types 'double(double) throw ()' and 'double(double) throw ()' to binary 'operator+' y1[i]+=y1[j]; ~~~~~^~~~~~~ fireworks.cpp:39:15: error: in evaluation of 'operator+=(double(double) throw (), double(double) throw ())' y1[i]+=y1[j]; ^ fireworks.cpp:43:33: warning: pointer to a function used in arithmetic [-Wpointer-arith] pc[i].erase(pc[i].begin()-y1[i]+1, pc[i].end()); ^ fireworks.cpp:43:28: error: no match for 'operator-' (operand types are 'std::vector<long long int>::iterator {aka __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >}' and 'double(double) throw ()') pc[i].erase(pc[i].begin()-y1[i]+1, pc[i].end()); ~~~~~~~~~~~~~^~~~~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from fireworks.cpp:1: /usr/include/c++/7/bits/stl_iterator.h:840:7: note: candidate: __gnu_cxx::__normal_iterator<_Iterator, _Container> __gnu_cxx::__normal_iterator<_Iterator, _Container>::operator-(__gnu_cxx::__normal_iterator<_Iterator, _Container>::difference_type) const [with _Iterator = long long int*; _Container = std::vector<long long int>; __gnu_cxx::__normal_iterator<_Iterator, _Container>::difference_type = long int] <near match> operator-(difference_type __n) const _GLIBCXX_NOEXCEPT ^~~~~~~~ /usr/include/c++/7/bits/stl_iterator.h:840:7: note: conversion of argument 1 would be ill-formed: fireworks.cpp:43:33: error: invalid conversion from 'double (*)(double) throw ()' to '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >::difference_type {aka long int}' [-fpermissive] pc[i].erase(pc[i].begin()-y1[i]+1, pc[i].end()); ~~~~^ In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from fireworks.cpp:1: /usr/include/c++/7/bits/stl_iterator.h:389:5: note: candidate: template<class _IteratorL, class _IteratorR> decltype ((__y.base() - __x.base())) std::operator-(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&) operator-(const reverse_iterator<_IteratorL>& __x, ^~~~~~~~ /usr/include/c++/7/bits/stl_iterator.h:389:5: note: template argument deduction/substitution failed: fireworks.cpp:43:33: note: 'std::vector<long long int>::iterator {aka __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >}' is not derived from 'const std::reverse_iterator<_Iterator>' pc[i].erase(pc[i].begin()-y1[i]+1, pc[i].end()); ^ In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from fireworks.cpp:1: /usr/include/c++/7/bits/stl_iterator.h:1191:5: note: candidate: template<class _IteratorL, class _IteratorR> decltype ((__x.base() - __y.base())) std::operator-(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorR>&) operator-(const move_iterator<_IteratorL>& __x, ^~~~~~~~ /usr/include/c++/7/bits/stl_iterator.h:1191:5: note: template argument deduction/substitution failed: fireworks.cpp:43:33: note: 'std::vector<long long int>::iterator {aka __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >}' is not derived from 'const std::move_iterator<_IteratorL>' pc[i].erase(pc[i].begin()-y1[i]+1, pc[i].end()); ^ In file included from /usr/include/c++/7/ccomplex:39:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from fireworks.cpp:1: /usr/include/c++/7/complex:356:5: note: candidate: template<class _Tp> std::complex<_Tp> std::operator-(const std::complex<_Tp>&, const std::complex<_Tp>&) operator-(const complex<_Tp>& __x, const complex<_Tp>& __y) ^~~~~~~~ /usr/include/c++/7/complex:356:5: note: template argument deduction/substitution failed: fireworks.cpp:43:33: note: 'std::vector<long long int>::iterator {aka __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >}' is not derived from 'const std::complex<_Tp>' pc[i].erase(pc[i].begin()-y1[i]+1, pc[i].end()); ^ In file included from /usr/include/c++/7/ccomplex:39:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from fireworks.cpp:1: /usr/include/c++/7/complex:365:5: note: candidate: template<class _Tp> std::complex<_Tp> std::operator-(const std::complex<_Tp>&, const _Tp&) operator-(const complex<_Tp>& __x, const _Tp& __y) ^~~~~~~~ /usr/include/c++/7/complex:365:5: note: template argument deduction/substitution failed: fireworks.cpp:43:33: note: 'std::vector<long long int>::iterator {aka __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >}' is not derived from 'const std::complex<_Tp>' pc[i].erase(pc[i].begin()-y1[i]+1, pc[i].end()); ^ In file included from /usr/include/c++/7/ccomplex:39:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from fireworks.cpp:1: /usr/include/c++/7/complex:374:5: note: candidate: template<class _Tp> std::complex<_Tp> std::operator-(const _Tp&, const std::complex<_Tp>&) operator-(const _Tp& __x, const complex<_Tp>& __y) ^~~~~~~~ /usr/include/c++/7/complex:374:5: note: template argument deduction/substitution failed: fireworks.cpp:43:33: note: mismatched types 'const std::complex<_Tp>' and 'double(double) throw ()' pc[i].erase(pc[i].begin()-y1[i]+1, pc[i].end()); ^ In file included from /usr/include/c++/7/ccomplex:39:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from fireworks.cpp:1: /usr/include/c++/7/complex:451:5: note: candidate: template<class _Tp> std::complex<_Tp> std::operator-(const std::complex<_Tp>&) operator-(const complex<_Tp>& __x) ^~~~~~~~ /usr/include/c++/7/complex:451:5: note: template argument deduction/substitution failed: fireworks.cpp:43:33: note: 'std::vector<long long int>::iterator {aka __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >}' is not derived from 'const std::complex<_Tp>' pc[i].erase(pc[i].begin()-y1[i]+1, pc[i].end()); ^ In file included from /usr/include/c++/7/deque:64:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:68, from fireworks.cpp:1: /usr/include/c++/7/bits/stl_deque.h:351:5: note: candidate: template<class _Tp, class _Ref, class _Ptr> typename std::_Deque_iterator<_Tp, _Ref, _Ptr>::difference_type std::operator-(const std::_Deque_iterator<_Tp, _Ref, _Ptr>&, const std::_Deque_iterator<_Tp, _Ref, _Ptr>&) operator-(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x, ^~~~~~~~ /usr/include/c++/7/bits/stl_deque.h:351:5: note: template argument deduction/substitution failed: fireworks.cpp:43:33: note: 'std::vector<long long int>::iterator {aka __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >}' is not derived from 'const std::_Deque_iterator<_Tp, _Ref, _Ptr>' pc[i].erase(pc[i].begin()-y1[i]+1, pc[i].end()); ^ In file included from /usr/include/c++/7/deque:64:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:68, from fireworks.cpp:1: /usr/include/c++/7/bits/stl_deque.h:363:5: note: candidate: template<class _Tp, class _RefL, class _PtrL, class _RefR, class _PtrR> typename std::_Deque_iterator<_Tp, _Ref, _Ptr>::difference_type std::operator-(const std::_Deque_iterator<_Tp, _Ref, _Ptr>&, const std::_Deque_iterator<_Tp, _RefR, _PtrR>&) operator-(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x, ^~~~~~~~ /usr/include/c++/7/bits/stl_deque.h:363:5: note: template argument deduction/substitution failed: fireworks.cpp:43:33: note: 'std::vector<long long int>::iterator {aka __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >}' is not derived from 'const std::_Deque_iterator<_Tp, _Ref, _Ptr>' pc[i].erase(pc[i].begin()-y1[i]+1, pc[i].end()); ^ In file included from /usr/include/c++/7/vector:65:0, from /usr/include/c++/7/queue:61, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86, from fireworks.cpp:1: /usr/include/c++/7/bits/stl_bvector.h:208:3: note: candidate: std::ptrdiff_t std::operator-(const std::_Bit_iterator_base&, const std::_Bit_iterator_base&) operator-(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) ^~~~~~~~ /usr/include/c++/7/bits/stl_bvector.h:208:3: note: no known conversion for argument 1 from 'std::vector<long long int>::iterator {aka __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >}' to 'const std::_Bit_iterator_base&' In file included from /usr/include/c++/7/valarray:592:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:95, from fireworks.cpp:1: /usr/include/c++/7/bits/valarray_after.h:403:5: note: candidate: template<class _Dom1, class _Dom2> std::_Expr<std::_BinClos<std::__minus, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const std::_Expr<_Dom1, typename _Dom1::value_type>&, const std::_Expr<_Dom2, typename _Dom2::value_type>&) _DEFINE_EXPR_BINARY_OPERATOR(-, __minus) ^ /usr/include/c++/7/bits/valarray_after.h:403:5: note: template argument deduction/substitution failed: fireworks.cpp:43:33: note: 'std::vector<long long int>::iterator {aka __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >}' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' pc[i].erase(pc[i].begin()-y1[i]+1, pc[i].end()); ^ In file included from /usr/include/c++/7/valarray:592:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:95, from fireworks.cpp:1: /usr/include/c++/7/bits/valarray_after.h:403:5: note: candidate: template<class _Dom> std::_Expr<std::_BinClos<std::__minus, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const std::_Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&) _DEFINE_EXPR_BINARY_OPERATOR(-, __minus) ^ /usr/include/c++/7/bits/valarray_after.h:403:5: note: template argument deduction/substitution failed: fireworks.cpp:43:33: note: 'std::vector<long long int>::iterator {aka __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >}' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' pc[i].erase(pc[i].begin()-y1[i]+1, pc[i].end()); ^ In file included from /usr/include/c++/7/valarray:592:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:95, from fireworks.cpp:1: /usr/include/c++/7/bits/valarray_after.h:403:5: note: candidate: template<class _Dom> std::_Expr<std::_BinClos<std::__minus, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const typename _Dom::value_type&, const std::_Expr<_Dom1, typename _Dom1::value_type>&) _DEFINE_EXPR_BINARY_OPERATOR(-, __minus) ^ /usr/include/c++/7/bits/valarray_after.h:403:5: note: template argument deduction/substitution failed: fireworks.cpp:43:33: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'double(double) throw ()' pc[i].erase(pc[i].begin()-y1[i]+1, pc[i].end()); ^ In file included from /usr/include/c++/7/valarray:592:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:95, from fireworks.cpp:1: /usr/include/c++/7/bits/valarray_after.h:403:5: note: candidate: template<class _Dom> std::_Expr<std::_BinClos<std::__minus, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const std::_Expr<_Dom1, typename _Dom1::value_type>&, const std::valarray<typename _Dom::value_type>&) _DEFINE_EXPR_BINARY_OPERATOR(-, __minus) ^ /usr/include/c++/7/bits/valarray_after.h:403:5: note: template argument deduction/substitution failed: fireworks.cpp:43:33: note: 'std::vector<long long int>::iterator {aka __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >}' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' pc[i].erase(pc[i].begin()-y1[i]+1, pc[i].end()); ^ In file included from /usr/include/c++/7/valarray:592:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:95, from fireworks.cpp:1: /usr/include/c++/7/bits/valarray_after.h:403:5: note: candidate: template<class _Dom> std::_Expr<std::_BinClos<std::__minus, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const std::valarray<typename _Dom::value_type>&, const std::_Expr<_Dom1, typename _Dom1::value_type>&) _DEFINE_EXPR_BINARY_OPERATOR(-, __minus) ^ /usr/include/c++/7/bits/valarray_after.h:403:5: note: template argument deduction/substitution failed: fireworks.cpp:43:33: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'double(double) throw ()' pc[i].erase(pc[i].begin()-y1[i]+1, pc[i].end()); ^ In file included from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:95:0, from fireworks.cpp:1: /usr/include/c++/7/valarray:1173:1: note: candidate: template<class _Tp> std::_Expr<std::_BinClos<std::__minus, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__minus, _Tp>::result_type> std::operator-(const std::valarray<_Tp>&, const std::valarray<_Tp>&) _DEFINE_BINARY_OPERATOR(-, __minus) ^ /usr/include/c++/7/valarray:1173:1: note: template argument deduction/substitution failed: fireworks.cpp:43:33: note: 'std::vector<long long int>::iterator {aka __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >}' is not derived from 'const std::valarray<_Tp>' pc[i].erase(pc[i].begin()-y1[i]+1, pc[i].end()); ^ In file included from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:95:0, from fireworks.cpp:1: /usr/include/c++/7/valarray:1173:1: note: candidate: template<class _Tp> std::_Expr<std::_BinClos<std::__minus, std::_ValArray, std::_Constant, _Tp, _Tp>, t