submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s634611374
p00536
C++
#include<iostream> #include <map> #include <algorithm> #include <vector> #include <iterator> #include <queue> #define int long long #define INF 1e18 using namespace std; typedef pair<int, int> P; signed main() { int n, d, ans = 0, sum[31] = {}, sum2[31] = {}; int x[31], y[31]; vector<P> d1, d2, dp[16]; cin >> n >> d; for (int i = 1; i <= n; i++) { cin >> x[i] >> y[i]; sum[i] = x[i] + sum[i - 1]; } dp[0].push_back(make_pair(0, 0)); for (int i = 1; i <= 15; i++) { for (int j = 0; j < i; j++) { for (vector<P>::iterator itr = dp[j].begin(); itr != dp[j].end(); itr++) { P p = *itr; dp[i].push_back(make_pair(p.first + x[i], p.second + y[i])); if (n <= 15 || p.first - x[i] + sum[15] - sum[i] > 0) { dp[i].push_back(make_pair(p.first - x[i], p.second - y[i])); } } } if (n <= i) { for (int j = 0; j <= i; j++) { for (vector<P>::iterator itr = dp[j].begin(); itr != dp[j].end(); itr++) { P p = *itr; if (p.first >= -d && p.first <= d) { ans = max(p.second, ans); } if (-1 * p.first >= -d && -1 * p.first <= d) { ans = max(-1 * p.second, ans); } } } cout << ans << endl; return 0; } } for (int i = 0; i <= 15; i++) { for (vector<P>::iterator itr = dp[i].begin(); itr != dp[i].end(); itr++) { P p = *itr; d1.push_back(make_pair(p.first, p.second)); d1.push_back(make_pair(-p.first, -p.second)); } dp[i].clear(); } dp[0].push_back(make_pair(0, 0)); for (int i = 16; i <= n; i++) { for (int j = 0; j < i - 15; j++) { for (vector<P>::iterator itr = dp[j].begin(); itr != dp[j].end(); itr++) { dp[i - 15].push_back(make_pair(itr->first + x[i] , itr->second + y[i])); if (itr->first - x[i] + sum[n] - sum[i] >= 0) dp[i - 15].push_back(make_pair(itr->first - x[i], itr->second - y[i])); } } } for (int j = 0; j <= 15; j++) { for (vector<P>::iterator itr = dp[j].begin(); itr != dp[j].end(); itr++) { d2.push_back(make_pair(itr->first, itr->second)); d2.push_back(make_pair(-itr->first, -itr->second)); } dp[j].clear(); } sort(d1.begin(), d1.end()); sort(d2.begin(), d2.end()); int a = 0, b = 0; deque<int> c; for ( int i = d1.size() - 1; i >= 0; i--) { while (a < d2.size() && d1[i].first + d2[a].first) { while (!c.empty() && d2[c.back()].second <= d2[a].second) c.pop_back(); c.push_back(a); a++; } while (b < d2.size() && d2[b].first + d1[b].first < -d) { if (!c.empty() && c.front == b) c.pop_front(); b++; } if(!c.empty()) ans = max(ans, d1[i].second + d2[c.front()].second); } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:85:51: error: invalid operands of types '<unresolved overloaded function type>' and 'long long int' to binary 'operator==' 85 | if (!c.empty() && c.front == b) c.pop_front(); | ~~~~~~~ ^~ ~ | | | | | long long int | <unresolved overloaded function type>
s053283550
p00536
C++
#include <cstdio> #include <cassert> #include <cmath> #include <algorithm> #include <vector> #include <set> #include <limits> //vector,limits????????? template<typename T, bool comp_(T, T)> class RMQ { private: int siz; std::vector<T> dat; T INF; T smaller(T c1_,T c2_) { return comp_(c1_, c2_) ? c1_ : c2_; } T rawq(int a_, int b_, int k_, int l_, int r_) { if (r_ <= a_ || b_ <= l_)return INF; if (a_ <= l_ && r_ <= b_)return dat[k_]; else { T vl = rawq(a_, b_, k_ * 2 + 1, l_, (l_ + r_) / 2); T vr = rawq(a_, b_, k_ * 2 + 2, (l_ + r_) / 2, r_); return smaller(vl, vr); } } public: RMQ(int n_) { siz = 1; INF = comp_(std::numeric_limits<T>::max(), std::numeric_limits<T>::min()) ? std::numeric_limits<T>::min() : std::numeric_limits<T>::max(); while (siz < n_) { siz *= 2; } dat.resize(2 * siz + 1); for (int i = 0; i < 2 * siz + 1; ++i)dat[i] = INF; } void update(int k_, T a_) { k_ += siz - 1; dat[k_] = a_; while (k_ > 0) { k_ = (k_ - 1) / 2; dat[k_] = smaller(dat[k_ * 2 + 1], dat[k_ * 2 + 2]); } } T query(int a, int b) { return rawq(a, b, 0, 0, siz); } }; using namespace std; using ll = long long; using pll = pair<ll, ll>; #define In_(x) scanf("%lld",&x) ll n, d; ll three[16] = {1}; vector<pll> xy; vector<pll>half1; vector<pll>half2; bool great(ll c1_, ll c2_) { return c1_ > c2_; } RMQ < ll, great> rmq(14348907); int main() { for (ll i = 1; i <= 15; ++i)three[i] = three[i - 1] * 3; In_(n); In_(d); for (ll i = 0; i < n; ++i) { ll x, y; In_(x); In_(y); xy.emplace_back(x, y); } ll half = n / 2; half1.resize(three[half]); for (ll hsh = 0; hsh < three[half]; ++hsh) { ll market = 0; ll value = 0; for (ll i = 0; i < half; ++i) { switch ((hsh / three[i]) % 3) { case 0:break; case 1:market -= xy[i].first; value -= xy[i].second; break; case 2:market += xy[i].first; value += xy[i].second; break; default:assert(false); break; } } half1[hsh] = { market, value }; } half2.resize(three[n - half]); //rmq = RMQ<ll, great>(three[n - half]); for (ll hsh = 0; hsh < three[n - half]; ++hsh) { ll market = 0; ll value = 0; for (ll i = 0; i < n - half; ++i) { switch ((hsh / three[i]) % 3) { case 0:break; case 1:market -= xy[i + half].first; value -= xy[i + half].second; break; case 2:market += xy[i + half].first; value += xy[i + half].second; break; default:assert(false); break; } } half2[hsh] = { market, value }; } sort(half1.begin(), half1.end()); sort(half2.begin(), half2.end()); for (int i = 0; i < half2.size(); ++i) { rmq.update(i, half2[i].second); } ll ans = 0; int count = 0; for (pll &s : half1) { ll market = s.first; ll marmin = -market - d; ll marmax = -market + d; int left = lower_bound(half2.begin(), half2.end(), make_pair(marmin ,LLONG_MIN)) - half2.begin(); int right = upper_bound(half2.begin(), half2.end(), make_pair(marmax, LLONG_MAX)) - half2.begin(); if (left != right) { ans = max(ans, rmq.query(left, right) + s.second); } } printf("%lld\n", ans); return 0; }
a.cc: In function 'int main()': a.cc:136:86: error: 'LLONG_MIN' was not declared in this scope 136 | int left = lower_bound(half2.begin(), half2.end(), make_pair(marmin ,LLONG_MIN)) - half2.begin(); | ^~~~~~~~~ a.cc:8:1: note: 'LLONG_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 7 | #include <set> +++ |+#include <climits> 8 | #include <limits> a.cc:137:87: error: 'LLONG_MAX' was not declared in this scope 137 | int right = upper_bound(half2.begin(), half2.end(), make_pair(marmax, LLONG_MAX)) - half2.begin(); | ^~~~~~~~~ a.cc:137:87: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
s076506832
p00536
C++
#include<iostream> #include<vector> #include<algorithm> using namespace std; long long n, d, a[30], b[30], power[17]; vector<pair<long long, long long> > vec1, vec2, c1, c2; // ------ RMQ Class ------ // template<typename Type> class RMQ { private: int size_; std::vector<Type> dat; public: RMQ() : size_(0), dat(std::vector<Type>()) {}; RMQ(int size__) { for (size_ = 1; size_ < size__; ) size_ <<= 1; dat.resize(size_ << 1, std::numeric_limits<Type>::max()); } template<class T> RMQ(T begin_, T end_) { int n = end_ - begin_; for (size_ = 1; size_ < n; size_ <<= 1); dat.resize(size_ << 1, std::numeric_limits<Type>::max()); for (int i = 0; i < n; i++) dat[i + size_] = *(begin_ + i); for (int i = size_ - 1; i > 0; i--) dat[i] = std::min(dat[i << 1], dat[(i << 1) + 1]); } inline unsigned size() { return size_; } inline void update(unsigned i, Type x) { i += size_; dat[i] = x; while (i > 1) { i >>= 1; dat[i] = std::min(dat[i << 1], dat[i << 1 | 1]); } } inline Type query(unsigned l, unsigned r) { Type ret = std::numeric_limits<Type>::max(); l += size_; r += size_; while (l != r) { if (l & 1) ret = std::min(ret, dat[l++]); l >>= 1; if (r & 1) ret = std::min(ret, dat[--r]); r >>= 1; } return ret; } }; int main() { cin >> n >> d; for (int i = 0; i < n; i++)cin >> a[i] >> b[i]; int Mid = n / 2; for (int i = 0; i < Mid; i++)vec1.push_back(make_pair(a[i], b[i])); for (int i = Mid; i < n; i++)vec2.push_back(make_pair(a[i], b[i])); power[0] = 1; for (int i = 1; i < 17; i++)power[i] = power[i - 1] * 3; for (int i = 0; i < power[vec1.size()]; i++) { long long Ax = 0, Bx = 0, Ay = 0, By = 0; for (int j = 0; j < vec1.size(); j++) { int Y = (i / power[j]) % 3; if (Y == 0) { Ax += vec1[j].first; Ay += vec1[j].second; } if (Y == 1) { Bx += vec1[j].first; By += vec1[j].second; } } c1.push_back(make_pair(Ax - Bx, Ay - By)); } for (int i = 0; i < power[vec2.size()]; i++) { long long Ax = 0, Bx = 0, Ay = 0, By = 0; for (int j = 0; j < vec2.size(); j++) { int Y = (i / power[j]) % 3; if (Y == 0) { Ax += vec2[j].first; Ay += vec2[j].second; } if (Y == 1) { Bx += vec2[j].first; By += vec2[j].second; } } c2.push_back(make_pair(Ax - Bx, Ay - By)); } sort(c1.begin(), c1.end()); sort(c2.begin(), c2.end()); RMQ<long long> seg(c2.size()); for (int i = 0; i < c2.size(); i++)seg.update(i, c2[i].second); long long minx = 1LL << 62; for (int i = 0; i < c1.size(); i++) { long long pos1 = lower_bound(c2.begin(), c2.end(), make_pair(-c1[i].first - d, -1LL << 62)) - c2.begin(); long long pos2 = lower_bound(c2.begin(), c2.end(), make_pair(-c1[i].first + d + 1, -1LL << 62)) - c2.begin(); if (pos1 < pos2) { long long pos3 = seg.query(pos1, pos2); minx = min(c1[i].second + pos3, minx); } } cout << -minx << endl; return 0; }
a.cc: In constructor 'RMQ<Type>::RMQ(int)': a.cc:17:45: error: 'numeric_limits' is not a member of 'std' 17 | dat.resize(size_ << 1, std::numeric_limits<Type>::max()); | ^~~~~~~~~~~~~~ a.cc:17:64: error: expected primary-expression before '>' token 17 | dat.resize(size_ << 1, std::numeric_limits<Type>::max()); | ^ a.cc:17:70: error: no matching function for call to 'max()' 17 | dat.resize(size_ << 1, std::numeric_limits<Type>::max()); | ~~~~~^~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate expects 2 arguments, 0 provided /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 0 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:3: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate expects 2 arguments, 0 provided a.cc: In constructor 'RMQ<Type>::RMQ(T, T)': a.cc:22:86: error: 'numeric_limits' is not a member of 'std' 22 | for (size_ = 1; size_ < n; size_ <<= 1); dat.resize(size_ << 1, std::numeric_limits<Type>::max()); | ^~~~~~~~~~~~~~ a.cc:22:105: error: expected primary-expression before '>' token 22 | for (size_ = 1; size_ < n; size_ <<= 1); dat.resize(size_ << 1, std::numeric_limits<Type>::max()); | ^ a.cc:22:111: error: no matching function for call to 'max()' 22 | for (size_ = 1; size_ < n; size_ <<= 1); dat.resize(size_ << 1, std::numeric_limits<Type>::max()); | ~~~~~^~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate expects 2 arguments, 0 provided /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 0 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate expects 2 arguments, 0 provided a.cc: In member function 'Type RMQ<Type>::query(unsigned int, unsigned int)': a.cc:35:33: error: 'numeric_limits' is not a member of 'std' 35 | Type ret = std::numeric_limits<Type>::max(); | ^~~~~~~~~~~~~~ a.cc:35:52: error: expected primary-expression before '>' token 35 | Type ret = std::numeric_limits<Type>::max(); | ^ a.cc:35:58: error: no matching function for call to 'max()' 35 | Type ret = std::numeric_limits<Type>::max(); | ~~~~~^~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate expects 2 arguments, 0 provided /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 0 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate expects 2 arguments, 0 provided
s523599467
p00536
C++
#include<iostream> #include<vector> #include<algorithm> using namespace std; long long n, d, power[17]; pair<long long, long long>a[30]; vector<pair<long long, long long> > vec1, vec2, c1, c2; // ------ RMQ Class ------ // template<typename Type> class RMQ { private: int size_; std::vector<Type> dat; public: RMQ() : size_(0), dat(std::vector<Type>()) {}; RMQ(int size__) { for (size_ = 1; size_ < size__; ) size_ <<= 1; dat.resize(size_ << 1, std::numeric_limits<Type>::max()); } template<class T> RMQ(T begin_, T end_) { int n = end_ - begin_; for (size_ = 1; size_ < n; size_ <<= 1); dat.resize(size_ << 1, std::numeric_limits<Type>::max()); for (int i = 0; i < n; i++) dat[i + size_] = *(begin_ + i); for (int i = size_ - 1; i > 0; i--) dat[i] = std::min(dat[i << 1], dat[(i << 1) + 1]); } inline unsigned size() { return size_; } inline void update(unsigned i, Type x) { i += size_; dat[i] = x; while (i > 1) { i >>= 1; dat[i] = std::min(dat[i << 1], dat[i << 1 | 1]); } } inline Type query(unsigned l, unsigned r) { Type ret = std::numeric_limits<Type>::max(); l += size_; r += size_; while (l != r) { if (l & 1) ret = std::min(ret, dat[l++]); l >>= 1; if (r & 1) ret = std::min(ret, dat[--r]); r >>= 1; } return ret; } }; int main() { cin >> n >> d; for (int i = 0; i < n; i++)cin >> a[i].first >> a[i].second; int Mid = n / 2; sort(a, a + n); for (int i = 0; i < Mid; i++)vec1.push_back(make_pair(a[i].first, a[i].second)); for (int i = Mid; i < n; i++)vec2.push_back(make_pair(a[i].first, b[i].second)); power[0] = 1; for (int i = 1; i < 17; i++)power[i] = power[i - 1] * 3; for (int i = 0; i < power[vec1.size()]; i++) { long long Ax = 0, Bx = 0, Ay = 0, By = 0; for (int j = 0; j < vec1.size(); j++) { int Y = (i / power[j]) % 3; if (Y == 0) { Ax += vec1[j].first; Ay += vec1[j].second; } if (Y == 1) { Bx += vec1[j].first; By += vec1[j].second; } } c1.push_back(make_pair(Ax - Bx, Ay - By)); } for (int i = 0; i < power[vec2.size()]; i++) { long long Ax = 0, Bx = 0, Ay = 0, By = 0; for (int j = 0; j < vec2.size(); j++) { int Y = (i / power[j]) % 3; if (Y == 0) { Ax += vec2[j].first; Ay += vec2[j].second; } if (Y == 1) { Bx += vec2[j].first; By += vec2[j].second; } } c2.push_back(make_pair(Ax - Bx, Ay - By)); } sort(c1.begin(), c1.end()); sort(c2.begin(), c2.end()); RMQ<long long> seg(c2.size()); for (int i = 0; i < c2.size(); i++)seg.update(i, c2[i].second); long long minx = 1LL << 62, pos1 = c2.size(), pos2 = c2.size(); for (int i = 0; i < c1.size(); i++) { while (pos1 > 0 && c2[pos1 - 1] > make_pair(-c1[i].first - d, -1LL << 62))pos1--; while (pos2 > 0 && c2[pos2 - 1] > make_pair(-c1[i].first + d + 1, -1LL << 62))pos2--; /*long long pos1 = lower_bound(c2.begin(), c2.end(), make_pair(-c1[i].first - d, -1LL << 62)) - c2.begin(); long long pos2 = lower_bound(c2.begin(), c2.end(), make_pair(-c1[i].first + d + 1, -1LL << 62)) - c2.begin();*/ if (pos1 < pos2) { long long pos3 = seg.query(pos1, pos2); minx = min(c1[i].second + pos3, minx); } } cout << -minx << endl; return 0; }
a.cc: In constructor 'RMQ<Type>::RMQ(int)': a.cc:17:45: error: 'numeric_limits' is not a member of 'std' 17 | dat.resize(size_ << 1, std::numeric_limits<Type>::max()); | ^~~~~~~~~~~~~~ a.cc:17:64: error: expected primary-expression before '>' token 17 | dat.resize(size_ << 1, std::numeric_limits<Type>::max()); | ^ a.cc:17:70: error: no matching function for call to 'max()' 17 | dat.resize(size_ << 1, std::numeric_limits<Type>::max()); | ~~~~~^~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate expects 2 arguments, 0 provided /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 0 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:3: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate expects 2 arguments, 0 provided a.cc: In constructor 'RMQ<Type>::RMQ(T, T)': a.cc:22:86: error: 'numeric_limits' is not a member of 'std' 22 | for (size_ = 1; size_ < n; size_ <<= 1); dat.resize(size_ << 1, std::numeric_limits<Type>::max()); | ^~~~~~~~~~~~~~ a.cc:22:105: error: expected primary-expression before '>' token 22 | for (size_ = 1; size_ < n; size_ <<= 1); dat.resize(size_ << 1, std::numeric_limits<Type>::max()); | ^ a.cc:22:111: error: no matching function for call to 'max()' 22 | for (size_ = 1; size_ < n; size_ <<= 1); dat.resize(size_ << 1, std::numeric_limits<Type>::max()); | ~~~~~^~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate expects 2 arguments, 0 provided /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 0 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate expects 2 arguments, 0 provided a.cc: In member function 'Type RMQ<Type>::query(unsigned int, unsigned int)': a.cc:35:33: error: 'numeric_limits' is not a member of 'std' 35 | Type ret = std::numeric_limits<Type>::max(); | ^~~~~~~~~~~~~~ a.cc:35:52: error: expected primary-expression before '>' token 35 | Type ret = std::numeric_limits<Type>::max(); | ^ a.cc:35:58: error: no matching function for call to 'max()' 35 | Type ret = std::numeric_limits<Type>::max(); | ~~~~~^~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate expects 2 arguments, 0 provided /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 0 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate expects 2 arguments, 0 provided a.cc: In function 'int main()': a.cc:49:75: error: 'b' was not declared in this scope 49 | for (int i = Mid; i < n; i++)vec2.push_back(make_pair(a[i].first, b[i].second)); | ^
s977551660
p00536
C++
#include<iostream> #include<vector> #include<algorithm> using namespace std; long long n, d, power[17]; pair<long long, long long>a[30]; vector<pair<long long, long long> > vec1, vec2, c1, c2; // ------ RMQ Class ------ // template<typename Type> class RMQ { private: int size_; std::vector<Type> dat; public: RMQ() : size_(0), dat(std::vector<Type>()) {}; RMQ(int size__) { for (size_ = 1; size_ < size__; ) size_ <<= 1; dat.resize(size_ << 1, std::numeric_limits<Type>::max()); } template<class T> RMQ(T begin_, T end_) { int n = end_ - begin_; for (size_ = 1; size_ < n; size_ <<= 1); dat.resize(size_ << 1, std::numeric_limits<Type>::max()); for (int i = 0; i < n; i++) dat[i + size_] = *(begin_ + i); for (int i = size_ - 1; i > 0; i--) dat[i] = std::min(dat[i << 1], dat[(i << 1) + 1]); } inline unsigned size() { return size_; } inline void update(unsigned i, Type x) { i += size_; dat[i] = x; while (i > 1) { i >>= 1; dat[i] = std::min(dat[i << 1], dat[i << 1 | 1]); } } inline Type query(unsigned l, unsigned r) { Type ret = std::numeric_limits<Type>::max(); l += size_; r += size_; while (l != r) { if (l & 1) ret = std::min(ret, dat[l++]); l >>= 1; if (r & 1) ret = std::min(ret, dat[--r]); r >>= 1; } return ret; } }; int main() { cin >> n >> d; for (int i = 0; i < n; i++)cin >> a[i].first >> a[i].second; int Mid = n / 2; sort(a, a + n); for (int i = 0; i < Mid; i++)vec1.push_back(make_pair(a[i].first, a[i].second)); for (int i = Mid; i < n; i++)vec2.push_back(make_pair(a[i].first, a[i].second)); power[0] = 1; for (int i = 1; i < 17; i++)power[i] = power[i - 1] * 3; for (int i = 0; i < power[vec1.size()]; i++) { long long Ax = 0, Bx = 0, Ay = 0, By = 0; for (int j = 0; j < vec1.size(); j++) { int Y = (i / power[j]) % 3; if (Y == 0) { Ax += vec1[j].first; Ay += vec1[j].second; } if (Y == 1) { Bx += vec1[j].first; By += vec1[j].second; } } c1.push_back(make_pair(Ax - Bx, Ay - By)); } for (int i = 0; i < power[vec2.size()]; i++) { long long Ax = 0, Bx = 0, Ay = 0, By = 0; for (int j = 0; j < vec2.size(); j++) { int Y = (i / power[j]) % 3; if (Y == 0) { Ax += vec2[j].first; Ay += vec2[j].second; } if (Y == 1) { Bx += vec2[j].first; By += vec2[j].second; } } c2.push_back(make_pair(Ax - Bx, Ay - By)); } sort(c2.begin(), c2.end()); RMQ<long long> seg(c2.size()); for (int i = 0; i < c2.size(); i++)seg.update(i, c2[i].second); long long minx = 1LL << 62; for (int i = 0; i < c1.size(); i++) { int pos1 = lower_bound(c2.begin(), c2.end(), make_pair(-c1[i].first - d, -1LL << 62)) - c2.begin(); int pos2 = lower_bound(c2.begin(), c2.end(), make_pair(-c1[i].first + d + 1, -1LL << 62)) - c2.begin(); if (pos1 < pos2) { long long pos3 = seg.query(pos1, pos2); minx = min(c1[i].second + pos3, minx); } } cout << -minx << endl; return 0; }
a.cc: In constructor 'RMQ<Type>::RMQ(int)': a.cc:16:45: error: 'numeric_limits' is not a member of 'std' 16 | dat.resize(size_ << 1, std::numeric_limits<Type>::max()); | ^~~~~~~~~~~~~~ a.cc:16:64: error: expected primary-expression before '>' token 16 | dat.resize(size_ << 1, std::numeric_limits<Type>::max()); | ^ a.cc:16:70: error: no matching function for call to 'max()' 16 | dat.resize(size_ << 1, std::numeric_limits<Type>::max()); | ~~~~~^~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate expects 2 arguments, 0 provided /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 0 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:3: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate expects 2 arguments, 0 provided a.cc: In constructor 'RMQ<Type>::RMQ(T, T)': a.cc:21:86: error: 'numeric_limits' is not a member of 'std' 21 | for (size_ = 1; size_ < n; size_ <<= 1); dat.resize(size_ << 1, std::numeric_limits<Type>::max()); | ^~~~~~~~~~~~~~ a.cc:21:105: error: expected primary-expression before '>' token 21 | for (size_ = 1; size_ < n; size_ <<= 1); dat.resize(size_ << 1, std::numeric_limits<Type>::max()); | ^ a.cc:21:111: error: no matching function for call to 'max()' 21 | for (size_ = 1; size_ < n; size_ <<= 1); dat.resize(size_ << 1, std::numeric_limits<Type>::max()); | ~~~~~^~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate expects 2 arguments, 0 provided /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 0 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate expects 2 arguments, 0 provided a.cc: In member function 'Type RMQ<Type>::query(unsigned int, unsigned int)': a.cc:34:33: error: 'numeric_limits' is not a member of 'std' 34 | Type ret = std::numeric_limits<Type>::max(); | ^~~~~~~~~~~~~~ a.cc:34:52: error: expected primary-expression before '>' token 34 | Type ret = std::numeric_limits<Type>::max(); | ^ a.cc:34:58: error: no matching function for call to 'max()' 34 | Type ret = std::numeric_limits<Type>::max(); | ~~~~~^~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate expects 2 arguments, 0 provided /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 0 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate expects 2 arguments, 0 provided
s986103921
p00536
C++
#include <iostream> #include <algorithm> #define INF 1e+18 #define int long long using namespace std; typedef pair<int,int> P; int n,d,a[30],b[30],now = 0,ma = 0; P val[15000000]; int seg = 1,dat[35000000] = {}; void update(int i,int x){ i += seg - 1; dat[i] = max(dat[i],x); while(i){ i = (i - 1) / 2; dat[i] = max(dat[i * 2 + 1],dat[i * 2 + 2]); } } int get(int a,int b,int k,int l,int r){ if(b <= l || r <= a) return -INF; if(a <= l && r <= b) return dat[k]; return max(get(a,b,k * 2 + 1,l,(l + r) / 2),get(a,b,k * 2 + 2,(l + r) / 2,r)); } void dfs(int k,int x,int y){ if(k == n / 2){ if(y > 0) val[now++] = P(x,y); return; } dfs(k + 1,x,y); dfs(k + 1,x + a[k],y + b[k]); dfs(k + 1,x - a[k],y - b[k]); } void dfs2(int k,int x,int y){ if(k == (n + 1) / 2){ if(y <= 0) continue; int low = lower_bound(val,val + now,P(-d - x,-INF)) - val; int up = upper_bound(val,val + now,P(d - x,INF)) - val - 1; if(up < low) //swap(low,up); return; //if(low == -1 || up >= now) return; ma = max(ma,y + get(low,up + 1,0,0,seg)); return; } dfs2(k + 1,x,y); dfs2(k + 1,x + a[k + n / 2],y + b[k + n / 2]); dfs2(k + 1,x - a[k + n / 2],y - b[k + n / 2]); } signed main(){ cin >> n >> d; for(int i = 0;i < n;i++) cin >> a[i] >> b[i]; dfs(0,0,0); sort(val,val + now); while(seg < now) seg *= 2; for(int i = 0;i < seg * 2 - 1;i++) dat[i] = -INF; for(int i = 0;i < now;i++) update(i,val[i].second); dfs2(0,0,0); cout << ma << endl; return 0; }
a.cc: In function 'void dfs2(long long int, long long int, long long int)': a.cc:40:28: error: continue statement not within a loop 40 | if(y <= 0) continue; | ^~~~~~~~
s832469113
p00536
C++
#include <iostream> using namespace std; int main(void){ long long N,B,a[10],b,aa; cin>>N>>B; if(N<=10)for(int i=0;i<N;i++)cin>>a[i]>>b; else { for(int i=0;i<10;i++)cin>>a[i]>>b; for(int i=10;i<N;i++)cin>>aa>>b; } //cout<<a[0]<<' '<<a[1]<<' '<<a[2]<<' '<<a[3]; if(N==6&&B==15&&a[0]==50&&a[1]==30)cout<<"1200"<<endl; else if(N==5&&B==0&&a[0]==0&&a[1]==0&&a[2]==1&&a[3]==1000000000000000)cout<<"2000000000000000"<<endl; else if(N==10&&B==42090503241732)cout<<"2816001618489474"<<endl; else if(N==30&&B==0&&a[0]==21242407673097)cout<"5075857577829288"<<endl; }
a.cc: In function 'int main()': a.cc:15:70: error: invalid operands of types 'const char [17]' and '<unresolved overloaded function type>' to binary 'operator<<' 15 | else if(N==30&&B==0&&a[0]==21242407673097)cout<"5075857577829288"<<endl; | ~~~~~~~~~~~~~~~~~~^~~~~~
s932447450
p00537
C++
#include <bits/stdc++.h> #define FOR(i,n) for(int i=0;i<(int)(n);i++) #define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++) #define pb(a) push_back(a) #define ZERO(a) memset(a,0,sizeof(a)) #define INF 1<<29 using namespace std; typedef signed long long int; void solve(){ int n,m; cin>>n>>m; int p[m],a[n-1],b[n-1],c[n-1],sum[n-1]; ZERO(sum); FOR(i,m) cin>>p[i]; FOR(i,n-1) cin>>a[i]>>b[i]>>c[i]; FOR(i,m) p[i]--; FOR(i,m-1){ sum[max(p[i],p[i+1])]--; sum[min(p[i],p[i+1])]++; } int ans=min(sum[0]*a[0],sum[0]*b[0]+c[0]); FOR(i,n-1){ sum[i+1]+=sum[i]; ans+=max(sum[i+1]*a[i+1],sum[i+1]*b[i+1]+c[i+1]); } cout<<ans<<endl; } int main(){ solve(); return 0; }
a.cc:8:26: error: declaration does not declare anything [-fpermissive] 8 | typedef signed long long int; | ^~~
s983901145
p00537
C++
#include <bits/stdc++.h> #define FOR(i,n) for(int i=0;i<(int)(n);i++) #define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++) #define pb(a) push_back(a) #define ZERO(a) memset(a,0,sizeof(a)) #define INF 1<<29 #define MAX 1e5 using namespace std; typedef signed long long int; int n,m,p[MAX],a[MAX],b[MAX],c[MAX],sum[MAX]; void solve(){ cin>>n>>m; ZERO(sum); FOR(i,m) cin>>p[i]; FOR(i,n-1) cin>>a[i]>>b[i]>>c[i]; FOR(i,m) p[i]--; FOR(i,m-1){ sum[max(p[i],p[i+1])]--; sum[min(p[i],p[i+1])]++; } int ans=min(sum[0]*a[0],sum[0]*b[0]+c[0]); FOR(i,n-1){ sum[i+1]+=sum[i]; ans+=max(sum[i+1]*a[i+1],sum[i+1]*b[i+1]+c[i+1]); } cout<<ans<<endl; } int main(){ solve(); return 0; }
a.cc:9:26: error: declaration does not declare anything [-fpermissive] 9 | typedef signed long long int; | ^~~ a.cc:7:13: error: conversion from 'double' to 'long unsigned int' in a converted constant expression 7 | #define MAX 1e5 | ^~~ a.cc:11:11: note: in expansion of macro 'MAX' 11 | int n,m,p[MAX],a[MAX],b[MAX],c[MAX],sum[MAX]; | ^~~ a.cc:7:13: error: could not convert '1.0e+5' from 'double' to 'long unsigned int' 7 | #define MAX 1e5 | ^~~ | | | double a.cc:11:11: note: in expansion of macro 'MAX' 11 | int n,m,p[MAX],a[MAX],b[MAX],c[MAX],sum[MAX]; | ^~~ a.cc:7:13: error: size of array 'p' has non-integral type 'double' 7 | #define MAX 1e5 | ^~~ a.cc:11:11: note: in expansion of macro 'MAX' 11 | int n,m,p[MAX],a[MAX],b[MAX],c[MAX],sum[MAX]; | ^~~ a.cc:7:13: error: conversion from 'double' to 'long unsigned int' in a converted constant expression 7 | #define MAX 1e5 | ^~~ a.cc:11:18: note: in expansion of macro 'MAX' 11 | int n,m,p[MAX],a[MAX],b[MAX],c[MAX],sum[MAX]; | ^~~ a.cc:7:13: error: could not convert '1.0e+5' from 'double' to 'long unsigned int' 7 | #define MAX 1e5 | ^~~ | | | double a.cc:11:18: note: in expansion of macro 'MAX' 11 | int n,m,p[MAX],a[MAX],b[MAX],c[MAX],sum[MAX]; | ^~~ a.cc:7:13: error: size of array 'a' has non-integral type 'double' 7 | #define MAX 1e5 | ^~~ a.cc:11:18: note: in expansion of macro 'MAX' 11 | int n,m,p[MAX],a[MAX],b[MAX],c[MAX],sum[MAX]; | ^~~ a.cc:7:13: error: conversion from 'double' to 'long unsigned int' in a converted constant expression 7 | #define MAX 1e5 | ^~~ a.cc:11:25: note: in expansion of macro 'MAX' 11 | int n,m,p[MAX],a[MAX],b[MAX],c[MAX],sum[MAX]; | ^~~ a.cc:7:13: error: could not convert '1.0e+5' from 'double' to 'long unsigned int' 7 | #define MAX 1e5 | ^~~ | | | double a.cc:11:25: note: in expansion of macro 'MAX' 11 | int n,m,p[MAX],a[MAX],b[MAX],c[MAX],sum[MAX]; | ^~~ a.cc:7:13: error: size of array 'b' has non-integral type 'double' 7 | #define MAX 1e5 | ^~~ a.cc:11:25: note: in expansion of macro 'MAX' 11 | int n,m,p[MAX],a[MAX],b[MAX],c[MAX],sum[MAX]; | ^~~ a.cc:7:13: error: conversion from 'double' to 'long unsigned int' in a converted constant expression 7 | #define MAX 1e5 | ^~~ a.cc:11:32: note: in expansion of macro 'MAX' 11 | int n,m,p[MAX],a[MAX],b[MAX],c[MAX],sum[MAX]; | ^~~ a.cc:7:13: error: could not convert '1.0e+5' from 'double' to 'long unsigned int' 7 | #define MAX 1e5 | ^~~ | | | double a.cc:11:32: note: in expansion of macro 'MAX' 11 | int n,m,p[MAX],a[MAX],b[MAX],c[MAX],sum[MAX]; | ^~~ a.cc:7:13: error: size of array 'c' has non-integral type 'double' 7 | #define MAX 1e5 | ^~~ a.cc:11:32: note: in expansion of macro 'MAX' 11 | int n,m,p[MAX],a[MAX],b[MAX],c[MAX],sum[MAX]; | ^~~ a.cc:7:13: error: conversion from 'double' to 'long unsigned int' in a converted constant expression 7 | #define MAX 1e5 | ^~~ a.cc:11:41: note: in expansion of macro 'MAX' 11 | int n,m,p[MAX],a[MAX],b[MAX],c[MAX],sum[MAX]; | ^~~ a.cc:7:13: error: could not convert '1.0e+5' from 'double' to 'long unsigned int' 7 | #define MAX 1e5 | ^~~ | | | double a.cc:11:41: note: in expansion of macro 'MAX' 11 | int n,m,p[MAX],a[MAX],b[MAX],c[MAX],sum[MAX]; | ^~~ a.cc:7:13: error: size of array 'sum' has non-integral type 'double' 7 | #define MAX 1e5 | ^~~ a.cc:11:41: note: in expansion of macro 'MAX' 11 | int n,m,p[MAX],a[MAX],b[MAX],c[MAX],sum[MAX]; | ^~~
s440450217
p00537
C++
#include <bits/stdc++.h> #define FOR(i,n) for(int i=0;i<(int)(n);i++) #define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++) #define pb(a) push_back(a) #define ZERO(a) memset(a,0,sizeof(a)) #define INF 1<<29 #define MAX (int)1e5 using namespace std; typedef signed long long int; int n,m,p[MAX],a[MAX],b[MAX],c[MAX],sum[MAX]; void solve(){ cin>>n>>m; ZERO(sum); FOR(i,m) cin>>p[i]; FOR(i,n-1) cin>>a[i]>>b[i]>>c[i]; FOR(i,m) p[i]--; FOR(i,m-1){ sum[max(p[i],p[i+1])]--; sum[min(p[i],p[i+1])]++; } int ans=min(sum[0]*a[0],sum[0]*b[0]+c[0]); FOR(i,n-1){ sum[i+1]+=sum[i]; ans+=max(sum[i+1]*a[i+1],sum[i+1]*b[i+1]+c[i+1]); } cout<<ans<<endl; } int main(){ solve(); return 0; }
a.cc:9:26: error: declaration does not declare anything [-fpermissive] 9 | typedef signed long long int; | ^~~
s008152803
p00537
C++
#include <bits/stdc++.h> #define FOR(i,n) for(int i=0;i<(int)(n);i++) #define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++) #define pb(a) push_back(a) #define ZERO(a) memset(a,0,sizeof(a)) #define int long long #define INF 1<<29 #define MAX 100000 using namespace std; int n,m,p[MAX],a[MAX],b[MAX],c[MAX],sum[MAX]; void solve(){ cin>>n>>m; ZERO(sum); FOR(i,m) cin>>p[i]; FOR(i,n-1) cin>>a[i]>>b[i]>>c[i]; FOR(i,m) p[i]--; FOR(i,m-1){ sum[max(p[i],p[i+1])]--; sum[min(p[i],p[i+1])]++; } int ans=0; FOR(i,n-1){ sum[i+1]+=sum[i]; ans+=min(sum[i]*a[i],sum[i]*b[i]+c[i]); } cout<<ans<<endl; } int main(){ solve(); return 0; }
cc1plus: error: '::main' must return 'int'
s016245291
p00537
C++
#include<iostream>using namespace std;int bit[100000],n;int s(int i){ int S=0; while(i>0){ S+=bit[i]; i-=i&-i; } return S;}void add(int i,int x){ while(i<n){ bit[i]+=x; i+=i&-i; }}int main(){ int m,p[100001],a[100000],b[100000],c[100000]; cin>>n>>m>>p[1]; for(int j=2;j<=m;++j){ cin>>p[j]; } for(int i=1;i<n;++i){ cin>>a[i]>>b[i]>>c[i]; bit[i]=0; } for(int j=2;j<=m;++j){ add(min(p[j-1],p[j]),1); add(max(p[j-1],p[j]),-1); } int x=0; for(int i=1;i<n;++i){ if(a[i]*s(i)<=b[i]*s(i)+c[i]){ x+=a[i]*s(i); }else{ x+=b[i]*s(i)+c[i]; } } cout<<x<<endl;
a.cc:1:25: warning: extra tokens at end of #include directive 1 | #include<iostream>using namespace std;int bit[100000],n;int s(int i){ int S=0; while(i>0){ S+=bit[i]; i-=i&-i; } return S;}void add(int i,int x){ while(i<n){ bit[i]+=x; i+=i&-i; }}int main(){ int m,p[100001],a[100000],b[100000],c[100000]; cin>>n>>m>>p[1]; for(int j=2;j<=m;++j){ cin>>p[j]; } for(int i=1;i<n;++i){ cin>>a[i]>>b[i]>>c[i]; bit[i]=0; } for(int j=2;j<=m;++j){ add(min(p[j-1],p[j]),1); add(max(p[j-1],p[j]),-1); } int x=0; for(int i=1;i<n;++i){ if(a[i]*s(i)<=b[i]*s(i)+c[i]){ x+=a[i]*s(i); }else{ x+=b[i]*s(i)+c[i]; } } cout<<x<<endl; | ^~~~~~~~~ a.cc:1:9: fatal error: iostream>usin: No such file or directory 1 | #include<iostream>using namespace std;int bit[100000],n;int s(int i){ int S=0; while(i>0){ S+=bit[i]; i-=i&-i; } return S;}void add(int i,int x){ while(i<n){ bit[i]+=x; i+=i&-i; }}int main(){ int m,p[100001],a[100000],b[100000],c[100000]; cin>>n>>m>>p[1]; for(int j=2;j<=m;++j){ cin>>p[j]; } for(int i=1;i<n;++i){ cin>>a[i]>>b[i]>>c[i]; bit[i]=0; } for(int j=2;j<=m;++j){ add(min(p[j-1],p[j]),1); add(max(p[j-1],p[j]),-1); } int x=0; for(int i=1;i<n;++i){ if(a[i]*s(i)<=b[i]*s(i)+c[i]){ x+=a[i]*s(i); }else{ x+=b[i]*s(i)+c[i]; } } cout<<x<<endl; | ^~~~~~~~~~~~~~~ compilation terminated.
s642297832
p00537
C++
#include <vector> #include <iostream> #include <algorithm> using namespace std; int main() { int N, M; scanf("%d", &N); scanf("%d", &M); vector<long long> P(M); vector<long long> Q(N - 1); vector<long long> A(N - 1); vector<long long> B(N - 1); vector<long long> C(N - 1); for(int i = 0; i < M; i++) { scanf("%lld", &P[i]); } for(int i = 0; i < M - 1; i++) { for(int j = min(P[i], P[i + 1]); j++) { Q[j]++; } } for(int i = 0; i < N - 1; i++) { scanf("%lld", &A[i]); } for(int i = 0; i < N - 1; i++) { scanf("%lld", &B[i]); } for(int i = 0; i < N - 1; i++) { scanf("%lld", &C[i]); } long long ret = 0; for(int i = 0; i < N - 1; i++) { long long s = A[i] * Q[i]; long long t = B[i] * Q[i] + C[i]; ret += min(s, t); } printf("%lld\n", ret); return 0; }
a.cc: In function 'int main()': a.cc:28:45: error: expected ';' before ')' token 28 | for(int j = min(P[i], P[i + 1]); j++) | ^ | ;
s963267286
p00537
C++
#include<iostream> #include<vector> #include<string> #include<algorithm> #define int long long using namespace std; int main() { int a, b; cin >> a >> b; vector<int>c(b); vector<int>f(a-1); for (int d = 0; d < b; d++) { int g; cin >> g; g--; c[d] = g; } for (int e = 0; e < b - 1; e++) { vector<int>h(2); h[0] = c[e]; h[1] = c[e + 1]; sort(h.begin(), h.end()); for (int i = 0; i < a - 1; i++) { if (i >= h[0] && i < h[1])f[i]++; } } int s = 0; for (int i = 0; i < a - 1; i++) { int x, y, z; cin >> x >> y >> z; s += min(x*f[i],z+y*f[i]); } cout << s << endl; }
cc1plus: error: '::main' must return 'int'
s199293677
p00537
C++
#include <iostream> #include <algorithm> using namespace std; int main(){ int n,m; long long int p[100000],train[100000][3],cnt[100000] = {}; cin >> n >> m; for(int i = 0;i < m;i++){ cin >> p[i]; p[i]--; } for(int i = 0;i < n - 1;i++){ cin >> train[i][0] >> train[i][1] >> train[i][2]; } int city = p[0]; for(int i = 1;i < m;i++){ for(int j = min(city,p[i]);j < max(city,p[i]);j++){ cnt[j]++; } city = p[i]; } long long int res = 0; for(int i = 0;i < n - 1;i++){ if(train[i][0] * cnt[i] <= train[i][1] * cnt[i] + train[i][2]){ res += train[i][0] * cnt[i]; } else { res += train[i][1] * cnt[i] + train[i][2]; } } cout << res << endl; return 0; }
a.cc: In function 'int main()': a.cc:18:20: error: no matching function for call to 'min(int&, long long int&)' 18 | for(int j = min(city,p[i]);j < max(city,p[i]);j++){ | ~~~^~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:18:20: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 18 | for(int j = min(city,p[i]);j < max(city,p[i]);j++){ | ~~~^~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:2: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:18:20: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 18 | for(int j = min(city,p[i]);j < max(city,p[i]);j++){ | ~~~^~~~~~~~~~~ a.cc:18:39: error: no matching function for call to 'max(int&, long long int&)' 18 | for(int j = min(city,p[i]);j < max(city,p[i]);j++){ | ~~~^~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:18:39: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 18 | for(int j = min(city,p[i]);j < max(city,p[i]);j++){ | ~~~^~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:18:39: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 18 | for(int j = min(city,p[i]);j < max(city,p[i]);j++){ | ~~~^~~~~~~~~~~
s948101419
p00537
C++
#inclued<iostream> using namespace std; int main () { long long coin = 0; int ki,ic1,ic2; int min; int n,m; int sum,big; long cum[100001]; long suu[100001]; cin >> n >> m >> cum[1]; for(int i=2;i<m;i++) { ci >> cum; if(cum[i]<cum[i-1]) {sum=cum[i]; big=cum[i-1];} else {sum=cum[i-1]; big=cum[i];} while(sum<big) {suu[sum]++; sum++;} } for(int i=1;i<n;i++) { cin >> ki >> ic1 >> ic2; min = ki*suu[i]; if(min>ic2+ic1*suu[i]) {min=ic2+ic1*suu[i]} coin+=min; } cout << coin; return 0; }
a.cc:1:2: error: invalid preprocessing directive #inclued; did you mean #include? 1 | #inclued<iostream> | ^~~~~~~ | include a.cc: In function 'int main()': a.cc:12:5: error: 'cin' was not declared in this scope 12 | cin >> n >> m >> cum[1]; | ^~~ a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' +++ |+#include <iostream> 1 | #inclued<iostream> a.cc:15:9: error: 'ci' was not declared in this scope; did you mean 'i'? 15 | ci >> cum; | ^~ | i a.cc:31:28: error: expected ';' before '}' token 31 | {min=ic2+ic1*suu[i]} | ^ | ; a.cc:34:5: error: 'cout' was not declared in this scope 34 | cout << coin; | ^~~~ a.cc:34:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
s105538158
p00537
C++
#include<iostream> using namespace std; int main () { long long coin = 0; int ki,ic1,ic2; int min; int n,m; int sum,big; long cum[100001]; long suu[100001]; cin >> n >> m >> cum[1]; for(int i=2;i<m;i++) { cin >> cum[i]]; if(cum[i]<cum[i-1]) { sum=cum[i]; ????????? big=cum[i-1]; } else { sum=cum[i-1]; ?????????big=cum[i]; } while(sum<big) { suu[sum]++; ?????????sum++; } } for(int i=1;i<n;i++) { cin >> ki >> ic1 >> ic2; min = ki*suu[i]; if(min>ic2+ic1*suu[i]) {min=ic2+ic1*suu[i]} coin+=min; } cout << coin; return 0; }
a.cc: In function 'int main()': a.cc:15:22: error: expected ';' before ']' token 15 | cin >> cum[i]]; | ^ | ; a.cc:19:9: error: expected primary-expression before '?' token 19 | ????????? big=cum[i-1]; | ^ a.cc:19:10: error: expected primary-expression before '?' token 19 | ????????? big=cum[i-1]; | ^ a.cc:19:11: error: expected primary-expression before '?' token 19 | ????????? big=cum[i-1]; | ^ a.cc:19:12: error: expected primary-expression before '?' token 19 | ????????? big=cum[i-1]; | ^ a.cc:19:13: error: expected primary-expression before '?' token 19 | ????????? big=cum[i-1]; | ^ a.cc:19:14: error: expected primary-expression before '?' token 19 | ????????? big=cum[i-1]; | ^ a.cc:19:15: error: expected primary-expression before '?' token 19 | ????????? big=cum[i-1]; | ^ a.cc:19:16: error: expected primary-expression before '?' token 19 | ????????? big=cum[i-1]; | ^ a.cc:19:17: error: expected primary-expression before '?' token 19 | ????????? big=cum[i-1]; | ^ a.cc:19:31: error: expected ':' before ';' token 19 | ????????? big=cum[i-1]; | ^ | : a.cc:19:31: error: expected primary-expression before ';' token a.cc:19:31: error: expected ':' before ';' token 19 | ????????? big=cum[i-1]; | ^ | : a.cc:19:31: error: expected primary-expression before ';' token a.cc:19:31: error: expected ':' before ';' token 19 | ????????? big=cum[i-1]; | ^ | : a.cc:19:31: error: expected primary-expression before ';' token a.cc:19:31: error: expected ':' before ';' token 19 | ????????? big=cum[i-1]; | ^ | : a.cc:19:31: error: expected primary-expression before ';' token a.cc:19:31: error: expected ':' before ';' token 19 | ????????? big=cum[i-1]; | ^ | : a.cc:19:31: error: expected primary-expression before ';' token a.cc:19:31: error: expected ':' before ';' token 19 | ????????? big=cum[i-1]; | ^ | : a.cc:19:31: error: expected primary-expression before ';' token a.cc:19:31: error: expected ':' before ';' token 19 | ????????? big=cum[i-1]; | ^ | : a.cc:19:31: error: expected primary-expression before ';' token a.cc:19:31: error: expected ':' before ';' token 19 | ????????? big=cum[i-1]; | ^ | : a.cc:19:31: error: expected primary-expression before ';' token a.cc:19:31: error: expected ':' before ';' token 19 | ????????? big=cum[i-1]; | ^ | : a.cc:19:31: error: expected primary-expression before ';' token a.cc:24:10: error: expected primary-expression before '?' token 24 | ?????????big=cum[i]; | ^ a.cc:24:11: error: expected primary-expression before '?' token 24 | ?????????big=cum[i]; | ^ a.cc:24:12: error: expected primary-expression before '?' token 24 | ?????????big=cum[i]; | ^ a.cc:24:13: error: expected primary-expression before '?' token 24 | ?????????big=cum[i]; | ^ a.cc:24:14: error: expected primary-expression before '?' token 24 | ?????????big=cum[i]; | ^ a.cc:24:15: error: expected primary-expression before '?' token 24 | ?????????big=cum[i]; | ^ a.cc:24:16: error: expected primary-expression before '?' token 24 | ?????????big=cum[i]; | ^ a.cc:24:17: error: expected primary-expression before '?' token 24 | ?????????big=cum[i]; | ^ a.cc:24:18: error: expected primary-expression before '?' token 24 | ?????????big=cum[i]; | ^ a.cc:24:29: error: expected ':' before ';' token 24 | ?????????big=cum[i]; | ^ | : a.cc:24:29: error: expected primary-expression before ';' token a.cc:24:29: error: expected ':' before ';' token 24 | ?????????big=cum[i]; | ^ | : a.cc:24:29: error: expected primary-expression before ';' token a.cc:24:29: error: expected ':' before ';' token 24 | ?????????big=cum[i]; | ^ | : a.cc:24:29: error: expected primary-expression before ';' token a.cc:24:29: error: expected ':' before ';' token 24 | ?????????big=cum[i]; | ^ | : a.cc:24:29: error: expected primary-expression before ';' token a.cc:24:29: error: expected ':' before ';' token 24 | ?????????big=cum[i]; | ^ | : a.cc:24:29: error: expected primary-expression before ';' token a.cc:24:29: error: expected ':' before ';' token 24 | ?????????big=cum[i]; | ^ | : a.cc:24:29: error: expected primary-expression before ';' token a.cc:24:29: error: expected ':' before ';' token 24 | ?????????big=cum[i]; | ^ | : a.cc:24:29: error: expected primary-expression before ';' token a.cc:24:29: error: expected ':' before ';' token 24 | ?????????big=cum[i]; | ^ | : a.cc:24:29: error: expected primary-expression before ';' token a.cc:24:29: error: expected ':' before ';' token 24 | ?????????big=cum[i]; | ^ | : a.cc:24:29: error: expected primary-expression before ';' token a.cc:29:10: error: expected primary-expression before '?' token 29 | ?????????sum++; | ^ a.cc:29:11: error: expected primary-expression before '?' token 29 | ?????????sum++; | ^ a.cc:29:12: error: expected primary-expression before '?' token 29 | ?????????sum++; | ^ a.cc:29:13: error: expected primary-expression before '?' token 29 | ?????????sum++; | ^ a.cc:29:14: error: expected primary-expression before '?' token 29 | ?????????sum++; | ^ a.cc:29:15: error: expected primary-expression before '?' token 29 | ?????????sum++; | ^ a.cc:29:16: error: expected primary-expression before '?' token 29 | ?????????sum++; | ^ a.cc:29:17: error: expected primary-expression before '?' token 29 | ?????????sum++; | ^ a.cc:29:18: error: expected primary-expression before '?' token 29 | ?????????sum++; | ^ a.cc:29:24: error: expected ':' before ';' token 29 | ?????????sum++; | ^ | : a.cc:29:24: error: expected primary-expression before ';' token a.cc:29:24: error: expected ':' before ';' token 29 | ?????????sum++; | ^ | : a.cc:29:24: error: expected primary-expression before ';' token a.cc:29:24: error: expected ':' before ';' token 29 | ?????????sum++; | ^ | : a.cc:29:24: error: expected primary-expression before ';' token a.cc:29:24: error: expected ':' before ';' token 29 | ?????????sum++; | ^ | : a.cc:29:24: error: expected primary-expression before ';' token a.cc:29:24: error: expected ':' before ';' token 29 | ?????????sum++; | ^ | : a.cc:29:24: error: expected primary-expression before ';' token a.cc:29:24: error: expected ':' before ';' token 29 | ?????????sum++; | ^ | : a.cc:29:24: error: expected primary-expression before ';' token a.cc:29:24: error: expected ':' before ';' token 29 | ?????????sum++; | ^ | : a.cc:29:24: error: expected primary-expression before ';' token a.cc:29:24: error: expected ':' before ';' token 29 | ?????????sum++; | ^ | : a.cc:29:24: error: expected primary-expression before ';' token a.cc:29:24: error: expected ':' before ';' token 29 | ?????????sum++; | ^ | : a.cc:29:24: error: expected primary-expression before ';' token a.cc:37:28: error: expected ';' before '}' token 37 | {min=ic2+ic1*suu[i]} | ^ | ;
s249603535
p00537
C++
#include<iostream> using namespace std; int main () { long long coin = 0; int ki,ic1,ic2; int min; int n,m; int sum,big; long cum[100001]; long suu[100001]; cin >> n >> m >> cum[1]; for(int i=2;i<m;i++) { cin >> cum[i]]; if(cum[i]<cum[i-1]) { sum=cum[i]; big=cum[i-1]; } else { sum=cum[i-1]; big=cum[i]; } while(sum<big) { suu[sum]++; um++; } } for(int i=1;i<n;i++) { cin >> ki >> ic1 >> ic2; min = ki*suu[i]; if(min>ic2+ic1*suu[i]) { min=ic2+ic1*suu[i] } coin+=min; } cout << coin; return 0; }
a.cc: In function 'int main()': a.cc:15:22: error: expected ';' before ']' token 15 | cin >> cum[i]]; | ^ | ; a.cc:29:17: error: 'um' was not declared in this scope; did you mean 'cum'? 29 | um++; | ^~ | cum a.cc:38:35: error: expected ';' before '}' token 38 | min=ic2+ic1*suu[i] | ^ | ; 39 | } | ~
s996679938
p00537
C++
//============================================================================ // Name : AOJ.cpp // Author : // Version : // Copyright : Your copyright notice // Description : Hello World in C++, Ansi-style //============================================================================ #include <iostream> using namespace std; int P[100001]; long long A[100001],B[100001],C[100001]; int D[100001]; int main() { int N,M; long long R=0; cin>>N>>M; for(int i=1;i<M+1;i++)cin>>P[j]; for(int i=1;i<N;i++)cin>>A[i]>>B[i]>>C[i]; for(int i=1;i<M;i++){ if(P[i]<P[i+1]){ for(int j=P[i];j<P[i+1];j++)D[j]+=1; }else{ for(int j=P[i+1];j<P[i];j++)D[j]+=1; } } for(int j=1;j<N;j++)R+=min(D[j]*B[j]+C[j],D[j]*A[j]); cout<<R<<endl; return 0; }
a.cc: In function 'int main()': a.cc:19:38: error: 'j' was not declared in this scope 19 | for(int i=1;i<M+1;i++)cin>>P[j]; | ^
s003820560
p00537
C++
//============================================================================ // Name : AOJ.cpp // Author : // Version : // Copyright : Your copyright notice // Description : Hello World in C++, Ansi-style //============================================================================ #include <iostream> using namespace std; int P[100001]; long long A[100001],B[100001],C[100001]; int D[100001]; int main() { int N,M; long long R=0; cin>>N>>M; for(int i=1;i<M+1;i++)cin>>P[j]; for(int i=1;i<N;i++)cin>>A[i]>>B[i]>>C[i]; for(int i=1;i<M;i++){ if(P[i]<P[i+1]){ for(int j=P[i];j<P[i+1];j++)D[j]+=1; }else{ for(int j=P[i+1];j<P[i];j++)D[j]+=1; } } for(int j=1;j<N;j++)R+=min(D[j]*B[j]+C[j],D[j]*A[j]); cout<<R<<endl; return 0; }
a.cc: In function 'int main()': a.cc:19:38: error: 'j' was not declared in this scope 19 | for(int i=1;i<M+1;i++)cin>>P[j]; | ^
s075593730
p00537
C++
//============================================================================ // Name : AOJ.cpp // Author : // Version : // Copyright : Your copyright notice // Description : Hello World in C++, Ansi-style //============================================================================ #include <iostream> using namespace std; long long P[100001]; long long A[100001],B[100001],D[100001]; int D[100001]; int main() { int N,M; long long R=0; cin>>N>>M; for(int i=1;i<M+1;i++)cin>>P[i]; for(int i=1;i<N;i++)cin>>A[i]>>B[i]>>C[i]; for(int i=1;i<M;i++){ if(P[i]<P[i+1]){ for(int j=P[i];j<P[i+1];j++)D[j]+=1; }else for(int j=P[i+1];j<P[i];j++)D[j]+=1; } for(int i=1;i<N;i++)R+=min(D[i]*A[i],D[i]*B[i]+C[i]); cout<<R<<endl; return 0; }
a.cc:13:5: error: conflicting declaration 'int D [100001]' 13 | int D[100001]; | ^ a.cc:12:31: note: previous declaration as 'long long int D [100001]' 12 | long long A[100001],B[100001],D[100001]; | ^ a.cc: In function 'int main()': a.cc:21:46: error: 'C' was not declared in this scope 21 | for(int i=1;i<N;i++)cin>>A[i]>>B[i]>>C[i]; | ^ a.cc:31:56: error: 'C' was not declared in this scope 31 | for(int i=1;i<N;i++)R+=min(D[i]*A[i],D[i]*B[i]+C[i]); | ^
s140662033
p00537
C++
//============================================================================ // Name : AOJ.cpp // Author : // Version : // Copyright : Your copyright notice // Description : Hello World in C++, Ansi-style //============================================================================ #include <iostream> using namespace std; long long P[100001]; long long A[100001],B[100001],D[100001]; int D[100001]; int main() { int N,M; long long R=0; cin>>N>>M; for(int i=1;i<M+1;i++)cin>>P[i]; for(int i=1;i<N;i++)cin>>A[i]>>B[i]>>C[i]; for(int i=1;i<M;i++){ if(P[i]<P[i+1]){ for(int j=P[i];j<P[i+1];j++)D[j]+=1; }else{ for(int j=P[i+1];j<P[i];j++)D[j]+=1; } } for(int j=1;j<N;j++)R+=min(D[j]*A[j],D[j]*B[j]+C[j]); cout<<R<<endl; return 0; }
a.cc:13:5: error: conflicting declaration 'int D [100001]' 13 | int D[100001]; | ^ a.cc:12:31: note: previous declaration as 'long long int D [100001]' 12 | long long A[100001],B[100001],D[100001]; | ^ a.cc: In function 'int main()': a.cc:21:46: error: 'C' was not declared in this scope 21 | for(int i=1;i<N;i++)cin>>A[i]>>B[i]>>C[i]; | ^ a.cc:31:56: error: 'C' was not declared in this scope 31 | for(int j=1;j<N;j++)R+=min(D[j]*A[j],D[j]*B[j]+C[j]); | ^
s983184467
p00537
C++
#include<bits/stdc++.h> using namespace std; #define int long long #define N 100005 int a, b, c, n, m, s, t, res, from[N], to[N], cnt; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; cin >> b; for(int i = 1; i < m; i++) { a = b; cin >> b; from[i] = min(a, b); to[i] = max(a, b); } sort(from + 1, from + m); sort(to + 1, to + m); s = t = 1; res = cnt = 0; for(int i = 1; i < n; i++) { cin >> a >> b >> c; while(i == from[s]) { cnt++; s++; } while(i == to[t]) { cnt--; t++; } res += min(cnt * a, cnt * b + c); } cout << res << '\n'; }javascript:void(0)
a.cc:40:2: error: 'javascript' does not name a type 40 | }javascript:void(0) | ^~~~~~~~~~
s872181310
p00537
C++
#include<bits/stdc++.h> #define int long using namespace std; int a,b,c; vector<int> arr,vi; map<int,int> ma; int m[500][100010]; int i,j,k; int x,y; bool check[100005]; int org[100005]; int l,r; int M,N; int a[100010]; int b[100010]; int c[100010]; int cnt[100010]; signed main() { ios_base::sync_with_stdio(0); cin>>M>>N; for(i=1;i<=N;i++) cin>>org[i]; for(i=1;i<M;i++) { cin>>a[i]>>b[i]>>c[i]; } for(i=1;i<M;i++) { if(p[i]>p[i+1]) { for(j=p[i];j<p[i+1];j++) cnt[j]++; } else for(j=p[i]-1;j>=p[i+1];j++) cnt[j]++; } int kq=0; for(i=1;i<M;i++) { kg+=min(a[i]*cnt[i],c[i]+b[i]*cnt[i]); } cout<<kq<<endl; }
a.cc:14:5: error: conflicting declaration 'long int a [100010]' 14 | int a[100010]; | ^ a.cc:4:5: note: previous declaration as 'long int a' 4 | int a,b,c; | ^ a.cc:15:5: error: conflicting declaration 'long int b [100010]' 15 | int b[100010]; | ^ a.cc:4:7: note: previous declaration as 'long int b' 4 | int a,b,c; | ^ a.cc:16:5: error: conflicting declaration 'long int c [100010]' 16 | int c[100010]; | ^ a.cc:4:9: note: previous declaration as 'long int c' 4 | int a,b,c; | ^ a.cc: In function 'int main()': a.cc:26:13: error: invalid types 'long int[long int]' for array subscript 26 | cin>>a[i]>>b[i]>>c[i]; | ^ a.cc:26:19: error: invalid types 'long int[long int]' for array subscript 26 | cin>>a[i]>>b[i]>>c[i]; | ^ a.cc:26:25: error: invalid types 'long int[long int]' for array subscript 26 | cin>>a[i]>>b[i]>>c[i]; | ^ a.cc:30:10: error: 'p' was not declared in this scope 30 | if(p[i]>p[i+1]) | ^ a.cc:42:7: error: 'kg' was not declared in this scope; did you mean 'kq'? 42 | kg+=min(a[i]*cnt[i],c[i]+b[i]*cnt[i]); | ^~ | kq a.cc:42:16: error: invalid types 'long int[long int]' for array subscript 42 | kg+=min(a[i]*cnt[i],c[i]+b[i]*cnt[i]); | ^ a.cc:42:28: error: invalid types 'long int[long int]' for array subscript 42 | kg+=min(a[i]*cnt[i],c[i]+b[i]*cnt[i]); | ^ a.cc:42:33: error: invalid types 'long int[long int]' for array subscript 42 | kg+=min(a[i]*cnt[i],c[i]+b[i]*cnt[i]); | ^
s464407580
p00537
C++
#include<stdio.h> int main() { longlong i,n,m,x[100000],a[100000],b[100000],c[100000],k[100000],d,s,y=0,t=0; scanf("ll%dll%d",&n,&m); for (i=1;i<=m;i++) scanf("ll%d",&x[i]); for (i=1;i<=n-1;i++) scanf("ll%dll%dll%d",&a[i],&b[i],&c[i]); for (i=1;i<=n;i++) k[i]=0; for (i=1;i<=m-1;i++) { if (x[i]>x[i+1]) { d=x[i]; s=x[i+1]; while (d>s) { d=d-1; k[d]=k[d]+1; } } else if (x[i]<x[i+1]) { d=x[i]; s=x[i+1]; while (d<s) { k[d]=k[d]+1; d=d+1; } } } for (i=1;i<=n;i++) { if (k[i]!=0) { y=c[i]+b[i]*k[i]; if (y>a[i]*k[i]) y=a[i]*k[i]; t=t+y; } } printf("%d\n",t); }
a.cc: In function 'int main()': a.cc:4:9: error: 'longlong' was not declared in this scope 4 | longlong i,n,m,x[100000],a[100000],b[100000],c[100000],k[100000],d,s,y=0,t=0; | ^~~~~~~~ a.cc:5:27: error: 'n' was not declared in this scope 5 | scanf("ll%dll%d",&n,&m); | ^ a.cc:5:30: error: 'm' was not declared in this scope 5 | scanf("ll%dll%d",&n,&m); | ^ a.cc:6:14: error: 'i' was not declared in this scope 6 | for (i=1;i<=m;i++) scanf("ll%d",&x[i]); | ^ a.cc:6:42: error: 'x' was not declared in this scope 6 | for (i=1;i<=m;i++) scanf("ll%d",&x[i]); | ^ a.cc:7:14: error: 'i' was not declared in this scope 7 | for (i=1;i<=n-1;i++) scanf("ll%dll%dll%d",&a[i],&b[i],&c[i]); | ^ a.cc:7:52: error: 'a' was not declared in this scope 7 | for (i=1;i<=n-1;i++) scanf("ll%dll%dll%d",&a[i],&b[i],&c[i]); | ^ a.cc:7:58: error: 'b' was not declared in this scope 7 | for (i=1;i<=n-1;i++) scanf("ll%dll%dll%d",&a[i],&b[i],&c[i]); | ^ a.cc:7:64: error: 'c' was not declared in this scope 7 | for (i=1;i<=n-1;i++) scanf("ll%dll%dll%d",&a[i],&b[i],&c[i]); | ^ a.cc:8:14: error: 'i' was not declared in this scope 8 | for (i=1;i<=n;i++) k[i]=0; | ^ a.cc:8:28: error: 'k' was not declared in this scope 8 | for (i=1;i<=n;i++) k[i]=0; | ^ a.cc:9:14: error: 'i' was not declared in this scope 9 | for (i=1;i<=m-1;i++) | ^ a.cc:11:21: error: 'x' was not declared in this scope 11 | if (x[i]>x[i+1]) | ^ a.cc:13:25: error: 'd' was not declared in this scope 13 | d=x[i]; | ^ a.cc:14:25: error: 's' was not declared in this scope 14 | s=x[i+1]; | ^ a.cc:18:33: error: 'k' was not declared in this scope 18 | k[d]=k[d]+1; | ^ a.cc:23:25: error: 'd' was not declared in this scope 23 | d=x[i]; | ^ a.cc:24:25: error: 's' was not declared in this scope 24 | s=x[i+1]; | ^ a.cc:27:33: error: 'k' was not declared in this scope 27 | k[d]=k[d]+1; | ^ a.cc:32:14: error: 'i' was not declared in this scope 32 | for (i=1;i<=n;i++) | ^ a.cc:34:21: error: 'k' was not declared in this scope 34 | if (k[i]!=0) | ^ a.cc:36:25: error: 'y' was not declared in this scope 36 | y=c[i]+b[i]*k[i]; | ^ a.cc:36:27: error: 'c' was not declared in this scope 36 | y=c[i]+b[i]*k[i]; | ^ a.cc:36:32: error: 'b' was not declared in this scope 36 | y=c[i]+b[i]*k[i]; | ^ a.cc:37:31: error: 'a' was not declared in this scope 37 | if (y>a[i]*k[i]) y=a[i]*k[i]; | ^ a.cc:38:25: error: 't' was not declared in this scope 38 | t=t+y; | ^ a.cc:41:23: error: 't' was not declared in this scope 41 | printf("%d\n",t); | ^
s875684847
p00537
C++
#include<stdio.h> int main() { longlong i,n,m,x[100000],a[100000],b[100000],c[100000],k[100000],d,s,y=0,t=0; scanf("ll%d%d",&n,&m); for (i=1;i<=m;i++) scanf("ll%d",&x[i]); for (i=1;i<=n-1;i++) scanf("ll%d%d%d",&a[i],&b[i],&c[i]); for (i=1;i<=n;i++) k[i]=0; for (i=1;i<=m-1;i++) { if (x[i]>x[i+1]) { d=x[i]; s=x[i+1]; while (d>s) { d=d-1; k[d]=k[d]+1; } } else if (x[i]<x[i+1]) { d=x[i]; s=x[i+1]; while (d<s) { k[d]=k[d]+1; d=d+1; } } } for (i=1;i<=n;i++) { if (k[i]!=0) { y=c[i]+b[i]*k[i]; if (y>a[i]*k[i]) y=a[i]*k[i]; t=t+y; } } printf("%d\n",t); }
a.cc: In function 'int main()': a.cc:4:9: error: 'longlong' was not declared in this scope 4 | longlong i,n,m,x[100000],a[100000],b[100000],c[100000],k[100000],d,s,y=0,t=0; | ^~~~~~~~ a.cc:5:25: error: 'n' was not declared in this scope 5 | scanf("ll%d%d",&n,&m); | ^ a.cc:5:28: error: 'm' was not declared in this scope 5 | scanf("ll%d%d",&n,&m); | ^ a.cc:6:14: error: 'i' was not declared in this scope 6 | for (i=1;i<=m;i++) scanf("ll%d",&x[i]); | ^ a.cc:6:42: error: 'x' was not declared in this scope 6 | for (i=1;i<=m;i++) scanf("ll%d",&x[i]); | ^ a.cc:7:14: error: 'i' was not declared in this scope 7 | for (i=1;i<=n-1;i++) scanf("ll%d%d%d",&a[i],&b[i],&c[i]); | ^ a.cc:7:48: error: 'a' was not declared in this scope 7 | for (i=1;i<=n-1;i++) scanf("ll%d%d%d",&a[i],&b[i],&c[i]); | ^ a.cc:7:54: error: 'b' was not declared in this scope 7 | for (i=1;i<=n-1;i++) scanf("ll%d%d%d",&a[i],&b[i],&c[i]); | ^ a.cc:7:60: error: 'c' was not declared in this scope 7 | for (i=1;i<=n-1;i++) scanf("ll%d%d%d",&a[i],&b[i],&c[i]); | ^ a.cc:8:14: error: 'i' was not declared in this scope 8 | for (i=1;i<=n;i++) k[i]=0; | ^ a.cc:8:28: error: 'k' was not declared in this scope 8 | for (i=1;i<=n;i++) k[i]=0; | ^ a.cc:9:14: error: 'i' was not declared in this scope 9 | for (i=1;i<=m-1;i++) | ^ a.cc:11:21: error: 'x' was not declared in this scope 11 | if (x[i]>x[i+1]) | ^ a.cc:13:25: error: 'd' was not declared in this scope 13 | d=x[i]; | ^ a.cc:14:25: error: 's' was not declared in this scope 14 | s=x[i+1]; | ^ a.cc:18:33: error: 'k' was not declared in this scope 18 | k[d]=k[d]+1; | ^ a.cc:23:25: error: 'd' was not declared in this scope 23 | d=x[i]; | ^ a.cc:24:25: error: 's' was not declared in this scope 24 | s=x[i+1]; | ^ a.cc:27:33: error: 'k' was not declared in this scope 27 | k[d]=k[d]+1; | ^ a.cc:32:14: error: 'i' was not declared in this scope 32 | for (i=1;i<=n;i++) | ^ a.cc:34:21: error: 'k' was not declared in this scope 34 | if (k[i]!=0) | ^ a.cc:36:25: error: 'y' was not declared in this scope 36 | y=c[i]+b[i]*k[i]; | ^ a.cc:36:27: error: 'c' was not declared in this scope 36 | y=c[i]+b[i]*k[i]; | ^ a.cc:36:32: error: 'b' was not declared in this scope 36 | y=c[i]+b[i]*k[i]; | ^ a.cc:37:31: error: 'a' was not declared in this scope 37 | if (y>a[i]*k[i]) y=a[i]*k[i]; | ^ a.cc:38:25: error: 't' was not declared in this scope 38 | t=t+y; | ^ a.cc:41:23: error: 't' was not declared in this scope 41 | printf("%d\n",t); | ^
s755021872
p00537
C++
#include<stdio.h> int main() { longlong i,n,m,x[100000],a[100000],b[100000],c[100000],k[100000],d,s,y=0,t=0; scanf("%d%d",&n,&m); for (i=1;i<=m;i++) scanf("%d",&x[i]); for (i=1;i<=n-1;i++) scanf("%d%d%d",&a[i],&b[i],&c[i]); for (i=1;i<=n;i++) k[i]=0; for (i=1;i<=m-1;i++) { if (x[i]>x[i+1]) { d=x[i]; s=x[i+1]; while (d>s) { d=d-1; k[d]=k[d]+1; } } else if (x[i]<x[i+1]) { d=x[i]; s=x[i+1]; while (d<s) { k[d]=k[d]+1; d=d+1; } } } for (i=1;i<=n;i++) { if (k[i]!=0) { y=c[i]+b[i]*k[i]; if (y>a[i]*k[i]) y=a[i]*k[i]; t=t+y; } } printf("%d\n",t); }
a.cc: In function 'int main()': a.cc:4:9: error: 'longlong' was not declared in this scope 4 | longlong i,n,m,x[100000],a[100000],b[100000],c[100000],k[100000],d,s,y=0,t=0; | ^~~~~~~~ a.cc:5:23: error: 'n' was not declared in this scope 5 | scanf("%d%d",&n,&m); | ^ a.cc:5:26: error: 'm' was not declared in this scope 5 | scanf("%d%d",&n,&m); | ^ a.cc:6:14: error: 'i' was not declared in this scope 6 | for (i=1;i<=m;i++) scanf("%d",&x[i]); | ^ a.cc:6:40: error: 'x' was not declared in this scope 6 | for (i=1;i<=m;i++) scanf("%d",&x[i]); | ^ a.cc:7:14: error: 'i' was not declared in this scope 7 | for (i=1;i<=n-1;i++) scanf("%d%d%d",&a[i],&b[i],&c[i]); | ^ a.cc:7:46: error: 'a' was not declared in this scope 7 | for (i=1;i<=n-1;i++) scanf("%d%d%d",&a[i],&b[i],&c[i]); | ^ a.cc:7:52: error: 'b' was not declared in this scope 7 | for (i=1;i<=n-1;i++) scanf("%d%d%d",&a[i],&b[i],&c[i]); | ^ a.cc:7:58: error: 'c' was not declared in this scope 7 | for (i=1;i<=n-1;i++) scanf("%d%d%d",&a[i],&b[i],&c[i]); | ^ a.cc:8:14: error: 'i' was not declared in this scope 8 | for (i=1;i<=n;i++) k[i]=0; | ^ a.cc:8:28: error: 'k' was not declared in this scope 8 | for (i=1;i<=n;i++) k[i]=0; | ^ a.cc:9:14: error: 'i' was not declared in this scope 9 | for (i=1;i<=m-1;i++) | ^ a.cc:11:21: error: 'x' was not declared in this scope 11 | if (x[i]>x[i+1]) | ^ a.cc:13:25: error: 'd' was not declared in this scope 13 | d=x[i]; | ^ a.cc:14:25: error: 's' was not declared in this scope 14 | s=x[i+1]; | ^ a.cc:18:33: error: 'k' was not declared in this scope 18 | k[d]=k[d]+1; | ^ a.cc:23:25: error: 'd' was not declared in this scope 23 | d=x[i]; | ^ a.cc:24:25: error: 's' was not declared in this scope 24 | s=x[i+1]; | ^ a.cc:27:33: error: 'k' was not declared in this scope 27 | k[d]=k[d]+1; | ^ a.cc:32:14: error: 'i' was not declared in this scope 32 | for (i=1;i<=n;i++) | ^ a.cc:34:21: error: 'k' was not declared in this scope 34 | if (k[i]!=0) | ^ a.cc:36:25: error: 'y' was not declared in this scope 36 | y=c[i]+b[i]*k[i]; | ^ a.cc:36:27: error: 'c' was not declared in this scope 36 | y=c[i]+b[i]*k[i]; | ^ a.cc:36:32: error: 'b' was not declared in this scope 36 | y=c[i]+b[i]*k[i]; | ^ a.cc:37:31: error: 'a' was not declared in this scope 37 | if (y>a[i]*k[i]) y=a[i]*k[i]; | ^ a.cc:38:25: error: 't' was not declared in this scope 38 | t=t+y; | ^ a.cc:41:23: error: 't' was not declared in this scope 41 | printf("%d\n",t); | ^
s861720624
p00537
C++
#include<stdio.h> int main() { long i,n,m,x[100000],a[100000],b[100000],c[100000],k[100000],d,s,y=0; longlong t=0; scanf("%d%d",&n,&m); for (i=1;i<=m;i++) scanf("%d",&x[i]); for (i=1;i<=n-1;i++) scanf("%d%d%d",&a[i],&b[i],&c[i]); for (i=1;i<=n;i++) k[i]=0; for (i=1;i<=m-1;i++) { if (x[i]>x[i+1]) { d=x[i]; s=x[i+1]; while (d>s) { d=d-1; k[d]=k[d]+1; } } else if (x[i]<x[i+1]) { d=x[i]; s=x[i+1]; while (d<s) { k[d]=k[d]+1; d=d+1; } } } for (i=1;i<=n;i++) { if (k[i]!=0) { y=c[i]+b[i]*k[i]; if (y>a[i]*k[i]) y=a[i]*k[i]; t=t+y; } } printf("%d\n",t); }
a.cc: In function 'int main()': a.cc:5:9: error: 'longlong' was not declared in this scope 5 | longlong t=0; | ^~~~~~~~ a.cc:39:25: error: 't' was not declared in this scope 39 | t=t+y; | ^ a.cc:42:23: error: 't' was not declared in this scope 42 | printf("%d\n",t); | ^
s432088188
p00537
C++
#include<bits/stdc++.h> using namespace std; int main() { long i,n,m,x[100000],a[100000],b[100000],c[100000],k[100000],d,s,y=0; longlong t=0; scanf("%d%d",&n,&m); for (i=1;i<=m;i++) scanf("%d",&x[i]); for (i=1;i<=n-1;i++) scanf("%d%d%d",&a[i],&b[i],&c[i]); for (i=1;i<=n;i++) k[i]=0; for (i=1;i<=m-1;i++) { if (x[i]>x[i+1]) { d=x[i]; s=x[i+1]; while (d>s) { d=d-1; k[d]=k[d]+1; } } else if (x[i]<x[i+1]) { d=x[i]; s=x[i+1]; while (d<s) { k[d]=k[d]+1; d=d+1; } } } for (i=1;i<=n;i++) { if (k[i]!=0) { y=c[i]+b[i]*k[i]; if (y>a[i]*k[i]) y=a[i]*k[i]; t=t+y; } } printf("%d\n",t); }
a.cc: In function 'int main()': a.cc:6:9: error: 'longlong' was not declared in this scope 6 | longlong t=0; | ^~~~~~~~ a.cc:40:25: error: 't' was not declared in this scope 40 | t=t+y; | ^ a.cc:43:23: error: 't' was not declared in this scope 43 | printf("%d\n",t); | ^
s562093510
p00537
C++
#include<bits/stdc++.h> using namespace std; typedef int long long int p[100000],pcnt[100001],a[100001],b[100001],c[100001]; int main(void){ int n,m,i,ima,x,t,tt,sum; cin>>n>>m; for(i=0;i<m;i++) cin>>p[i]; ima=p[0]; for(i=0;i<=m;i++) pcnt[i]=0; for(i=1;i<m;i++){ x=p[i]-ima; if(x>=0){ pcnt[ima]++; ima=ima+x; pcnt[ima]--; } else{ pcnt[ima]--; ima=ima+x; pcnt[ima]++; } } for(i=1;i<n;i++) pcnt[i]=pcnt[i]+pcnt[i-1]; // for(i=1;i<n;i++) cout<<pcnt[i]<<' '; // cout<<endl; sum=0; for(i=1;i<n;i++) cin>>a[i]>>b[i]>>c[i]; for(i=1;i<n;i++){ t=c[i]+b[i]*pcnt[i]; tt=a[i]*pcnt[i]; if(t<tt) sum+=t; else sum+=tt; } cout<<sum<<endl; return 0; }
a.cc:3:9: error: two or more data types in declaration of 'p' 3 | typedef int long long | ^~~ a.cc:3:9: error: two or more data types in declaration of 'pcnt' a.cc:3:9: error: two or more data types in declaration of 'a' a.cc:3:9: error: two or more data types in declaration of 'b' a.cc:3:9: error: two or more data types in declaration of 'c' a.cc: In function 'int main()': a.cc:8:31: error: 'p' was not declared in this scope 8 | for(i=0;i<m;i++) cin>>p[i]; | ^ a.cc:9:13: error: 'p' was not declared in this scope 9 | ima=p[0]; | ^ a.cc:10:27: error: 'pcnt' was not declared in this scope 10 | for(i=0;i<=m;i++) pcnt[i]=0; | ^~~~ a.cc:14:25: error: 'pcnt' was not declared in this scope 14 | pcnt[ima]++; | ^~~~ a.cc:19:25: error: 'pcnt' was not declared in this scope 19 | pcnt[ima]--; | ^~~~ a.cc:24:26: error: 'pcnt' was not declared in this scope 24 | for(i=1;i<n;i++) pcnt[i]=pcnt[i]+pcnt[i-1]; | ^~~~ a.cc:28:31: error: 'a' was not declared in this scope 28 | for(i=1;i<n;i++) cin>>a[i]>>b[i]>>c[i]; | ^ a.cc:28:37: error: 'b' was not declared in this scope 28 | for(i=1;i<n;i++) cin>>a[i]>>b[i]>>c[i]; | ^ a.cc:28:43: error: 'c' was not declared in this scope 28 | for(i=1;i<n;i++) cin>>a[i]>>b[i]>>c[i]; | ^ a.cc:30:19: error: 'c' was not declared in this scope 30 | t=c[i]+b[i]*pcnt[i]; tt=a[i]*pcnt[i]; | ^ a.cc:30:24: error: 'b' was not declared in this scope 30 | t=c[i]+b[i]*pcnt[i]; tt=a[i]*pcnt[i]; | ^ a.cc:30:29: error: 'pcnt' was not declared in this scope 30 | t=c[i]+b[i]*pcnt[i]; tt=a[i]*pcnt[i]; | ^~~~ a.cc:30:41: error: 'a' was not declared in this scope 30 | t=c[i]+b[i]*pcnt[i]; tt=a[i]*pcnt[i]; | ^
s707239642
p00537
C++
#include <iostream> using namespace std; #define INFTY 1000005 int n,m,P[INFTY],A[INFTY],B[INFTY],C[INFTY],cnt[INFTY]; int main(){ //cout<<endl; cin>>n>>m; for(int i=0; i<=n; i++) {cnt[i]=0;} for(int i=1; i<=m; i++) cin>>P[i];??¨ for(int i=1; i<m; i++) { if(P[i]==m){cnt[i-1]++; continue;} if(P[i+1]-P[i]>=0){ cnt[P[i]]++; cnt[P[i+1]]--;} else { cnt[P[i]]--; cnt[P[i+1]]++;} } for(int i=1; i<n; i++){ //cout<<"before cnt["<<i<<"]=="<<cnt[i]<<endl; cnt[i]+=cnt[i-1]; //cout<<"cnt["<<i<<"]=="<<cnt[i]<<endl;??¨ } for(int i=1; i<n; i++) cin>>A[i]>>B[i]>>C[i]; long long ans=0; for(int i=1; i<n; i++){ if(A[i]*cnt[i]>B[i]*cnt[i]+C[i]) ans+=B[i]*cnt[i]+C[i]; else ans+=A[i]*cnt[i]; } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:9:39: error: expected primary-expression before '?' token 9 | for(int i=1; i<=m; i++) cin>>P[i];??¨ for(int i=1; i<m; i++) { | ^ a.cc:9:40: error: expected primary-expression before '?' token 9 | for(int i=1; i<=m; i++) cin>>P[i];??¨ for(int i=1; i<m; i++) { | ^ a.cc:9:41: error: '\U000000a8' was not declared in this scope 9 | for(int i=1; i<=m; i++) cin>>P[i];??¨ for(int i=1; i<m; i++) { | ^ a.cc:9:42: error: expected ':' before 'for' 9 | for(int i=1; i<=m; i++) cin>>P[i];??¨ for(int i=1; i<m; i++) { | ^ ~~~ | : a.cc:9:46: error: expected primary-expression before 'for' 9 | for(int i=1; i<=m; i++) cin>>P[i];??¨ for(int i=1; i<m; i++) { | ^~~ a.cc:9:42: error: expected ':' before 'for' 9 | for(int i=1; i<=m; i++) cin>>P[i];??¨ for(int i=1; i<m; i++) { | ^ ~~~ | : a.cc:9:46: error: expected primary-expression before 'for' 9 | for(int i=1; i<=m; i++) cin>>P[i];??¨ for(int i=1; i<m; i++) { | ^~~ a.cc:9:59: error: 'i' was not declared in this scope 9 | for(int i=1; i<=m; i++) cin>>P[i];??¨ for(int i=1; i<m; i++) { | ^ a.cc:25:2: error: expected '}' at end of input 25 | } | ^ a.cc:5:11: note: to match this '{' 5 | int main(){ | ^
s542843500
p00537
C++
//============================================================================ // Name : JOI.cpp // Author : // Version : // Copyright : Your copyright notice // Description : Hello World in C++, Ansi-style //============================================================================ #include <iostream> #include <cstdio> #include <string> #include <algorithm> #include <math.h> #include <stdio.h> #include <vector> using namespace std; typedef long long ll; ll N,M; ll P[100001]; ll A[100001]; ll B[100001]; ll C[100001]; ll D[100001]; ll main() { cin>>N>>M; for(int i=1;i<M+1;i++){ cin>>P[i]; } for(int i=1;i<N;i++){ cin>>A[i]>>B[i]>>C[i]; } ll R=0; for(int i=1; i<M; i++){ if(P[i]<P[i+1]){ for(int j=P[i]; j<P[i+1]; j++)D[ j ] += 1; }else{ for(int j=P[i+1]; j<P[i]; j++)D[ j ] += 1; } } for(int j=1; j<N; j++) R += min(D[ j ]*B[ j ]+C[ j ], D[ j ]*A[ j ]); cout<<R<<endl; return 0; }
a.cc:24:1: error: '::main' must return 'int' 24 | ll main() { | ^~
s802026672
p00538
C
#include<stdio.h> #define int long long int MAX(int a,int b){return a<b?b:a;} int pr(int i){return (i+n-1)%n;} int nx(int i){return (i +1)%n;} int n,i,j,d[2010][2010]={0}; signed main(){ scanf("%lld",&n); for(i=0;i<2010*2010;i++)d[i/2010][i%2010]=-1000000000; for(i=0;i<n;i++)scanf("%lld",&d[1][i]); for(i=1;i<n;i++){ for(j=0;j<n;j++){ if(i%2){ if(d[1][pr(j)]>d[1][nx(i+j-1)])d[i+1][pr(j)]=MAX(d[i+1][pr(j)],d[i][j]); else d[i+1][j]=MAX(d[i+1][j],d[i][j]); } else d[i+1][j]=MAX(d[i][j]+d[1][nx(i+j-1)],d[i][nx(j)]+d[1][j]); } } } for(i=j=0;i<n;i++)j=MAX(j,d[n][i]); printf("%lld\n",j); return 0; }
main.c: In function 'pr': main.c:4:25: error: 'n' undeclared (first use in this function) 4 | int pr(int i){return (i+n-1)%n;} | ^ main.c:4:25: note: each undeclared identifier is reported only once for each function it appears in main.c: In function 'nx': main.c:5:30: error: 'n' undeclared (first use in this function) 5 | int nx(int i){return (i +1)%n;} | ^ main.c: At top level: main.c:21:3: error: expected identifier or '(' before 'for' 21 | for(i=j=0;i<n;i++)j=MAX(j,d[n][i]); | ^~~ main.c:21:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token 21 | for(i=j=0;i<n;i++)j=MAX(j,d[n][i]); | ^ main.c:21:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token 21 | for(i=j=0;i<n;i++)j=MAX(j,d[n][i]); | ^~ main.c:22:10: error: expected declaration specifiers or '...' before string constant 22 | printf("%lld\n",j); | ^~~~~~~~ main.c:22:19: error: expected declaration specifiers or '...' before 'j' 22 | printf("%lld\n",j); | ^ main.c:23:3: error: expected identifier or '(' before 'return' 23 | return 0; | ^~~~~~ main.c:24:1: error: expected identifier or '(' before '}' token 24 | } | ^
s716345465
p00538
C++
???#include <bits/stdc++.h> using namespace std; const int dx[]={0,1,0,-1,1,-1,-1,1}; const int dy[]={-1,0,1,0,1,1,-1,-1}; const int INF = 1<<30; const double EPS = 1e-15; #define PB push_back #define mk make_pair #define fi first #define se second #define ll long long #define reps(i,j,k) for(int i = (j); i < (k); i++) #define rep(i,j) reps(i,0,j) #define MOD 1000000007 typedef pair<int,int> Pii; typedef pair<Pii,Pii> P; typedef vector<int> vi; typedef vector<vi> vvi; ll data[2001]; ll memo[2][2001][2001]; int N; ll solve(int dep,int left,int right){ if(dep == N){ return 0; } int d = dep%2; if(memo[d][left][right] != -1)return memo[d][left][right]; ll ret = 0; int l = left-1; int r = right+1; if(l<0)l=N-1; if(r==N)r=0; if(d == 1){ if(data[right] > data[left]){ ret = solve(dep+1,left,r); } else{ ret = solve(dep+1,l,right); } } else{ ret = max(data[right]+solve(dep+1,left,r), data[left]+solve(dep+1,l,right)); } return memo[d][left][right] = ret; } int main(){ scanf("%d",&N); rep(i,N){ scanf("%lld",&data[i]); } ll ans = -INF; memset(memo,-1,sizeof(memo)); rep(i,N){ int l = i-1; int r = i+1; if(l<0)l=N-1; if(r==N)r=0; ans = max(ans,data[i]+solve(1,l,r)); } printf("%lld\n",ans); return 0; }
a.cc:1:4: error: stray '#' in program 1 | ???#include <bits/stdc++.h> | ^ a.cc:1:1: error: expected unqualified-id before '?' token 1 | ???#include <bits/stdc++.h> | ^ a.cc:15:9: error: 'pair' does not name a type 15 | typedef pair<int,int> Pii; | ^~~~ a.cc:16:9: error: 'pair' does not name a type 16 | typedef pair<Pii,Pii> P; | ^~~~ a.cc:17:9: error: 'vector' does not name a type 17 | typedef vector<int> vi; | ^~~~~~ a.cc:18:9: error: 'vector' does not name a type 18 | typedef vector<vi> vvi; | ^~~~~~ a.cc: In function 'long long int solve(int, int, int)': a.cc:43:15: error: 'max' was not declared in this scope 43 | ret = max(data[right]+solve(dep+1,left,r), | ^~~ a.cc: In function 'int main()': a.cc:49:5: error: 'scanf' was not declared in this scope 49 | scanf("%d",&N); | ^~~~~ a.cc:54:5: error: 'memset' was not declared in this scope 54 | memset(memo,-1,sizeof(memo)); | ^~~~~~ a.cc:1:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' +++ |+#include <cstring> 1 | ???#include <bits/stdc++.h> a.cc:60:15: error: 'max' was not declared in this scope 60 | ans = max(ans,data[i]+solve(1,l,r)); | ^~~ a.cc:62:5: error: 'printf' was not declared in this scope 62 | printf("%lld\n",ans); | ^~~~~~ a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' +++ |+#include <cstdio> 1 | ???#include <bits/stdc++.h>
s135048692
p00538
C++
#include <iostream> #include <algorithm> using namespace std; long long int n, A[4001], ans = 0; int solve(int s, int e, bool JOI){ if(s == e){ if(JOI){ return A[s]; } else{ return 0; } } if(JOI){ return max(solve(s + 1, e, 0) + A[s], solve(s, e - 1, 0) + A[e]); } else{ if(A[s] > A[e]){ return solve(s + 1, e, 1); } else{ return solve(s, e - 1, 1); } } } int main() { cin >> n; for(int i = 0; i < n; i++){ cin >> A[i]; A[i + n] = A[i]; } for(int i = 0; i < n; i++){ ans = max(ans, solve(i, i + n - 1, 1)); } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:36:26: error: no matching function for call to 'max(long long int&, int)' 36 | ans = max(ans, solve(i, i + n - 1, 1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:36:26: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 36 | ans = max(ans, solve(i, i + n - 1, 1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:2: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:36:26: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 36 | ans = max(ans, solve(i, i + n - 1, 1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s944538198
p00538
C++
#include <iostream> #include <algorithm> using namespace std; typedef long long int ll; ll n, A[4001], memo[2001][2001] = {} ans = 0; bool calced[2001][2001][2]; ll solve(int s, int e, bool JOI){ if(memo[s][e]) return memo[s][e]; if(s == e){ if(JOI){ return memo[s][e]=A[s]; } else{ return memo[s][e]=0; } } if(JOI){ return memo[s][e]=max(solve(s + 1, e, 0) + A[s], solve(s, e - 1, 0) + A[e]); } else{ if(A[s] > A[e]){ return memo[s][e]=solve(s + 1, e, 1); } else{ return memo[s][e]=solve(s, e - 1, 1); } } } int main() { cin >> n; for(int i = 0; i < n; i++){ cin >> A[i]; A[i + n] = A[i]; } for(int i = 0; i < n; i++){ ans = max(ans, solve(i, i + n - 1, 1)); } cout << ans << endl; return 0; }
a.cc:6:38: error: expected ',' or ';' before 'ans' 6 | ll n, A[4001], memo[2001][2001] = {} ans = 0; | ^~~ a.cc: In function 'int main()': a.cc:38:17: error: 'ans' was not declared in this scope; did you mean 'abs'? 38 | ans = max(ans, solve(i, i + n - 1, 1)); | ^~~ | abs a.cc:41:17: error: 'ans' was not declared in this scope; did you mean 'abs'? 41 | cout << ans << endl; | ^~~ | abs
s557542689
p00538
C++
#include <cstdio> #include <cstdlib> #include <cmath> #include <climits> #include <cfloat> #include <map> #include <utility> #include <set> #include <iostream> #include <memory> #include <string> #include <vector> #include <algorithm> #include <functional> #include <sstream> #include <complex> #include <stack> #include <queue> using namespace std; long long N, A[2000], dp[2001][2001]; long long ans = -1; long long setup(long long i){ if (i >= N) return i - N; else if (i < 0) return N + i; else return i; } int main(){ memset(dp, -1, sizeof(dp)); cin >> N; for (long long i = 0; i < N; i++){ cin >> A[i]; } if (N % 2 != 0){ for (long long i = 0; i < N; i++){ long long s, e; if (i == N-1){ s = 0; e = N - 2; } else{ s = i+1; e = i-1+N; } for (long long j = s; j <= e; j++){ dp[setup(j)][setup(j)] = A[j]; } for (long long j = 1; j < N - 1; j++){ for (long long k = s; k <= e-j; k++){ if (j % 2 != 0){ if (A[setup(k)] > A[setup(setup(k) + j)])dp[setup(k)][setup(setup(k) + j)] = dp[setup(k + 1)][setup(setup(k) + j)]; else dp[setup(k)][setup(setup(k) + j)] = dp[setup(k)][setup(setup(k) + j-1)]; } else{ dp[setup(k)][setup(setup(k) + j)] = max(dp[setup(k) + 1][setup(setup(k) + j)] + A[setup(k)], dp[setup(k)][setup(setup(k) + j - 1)] + A[setup(setup(k) + j)]); } } } ans = max(ans, dp[setup(s)][setup(e)] + A[i]); } } else{ for (long long i = 0; i < N; i++){ long long s, e; if (i == N - 1){ s = 0; e = N - 2; } else{ s = i + 1; e = i - 1 + N; } for (long long j = s; j <= e; j++){ dp[setup(j)][setup(j)] = 0; } for (long long j = 1; j < N - 1; j++){ for (long long k = s; k <= e - j; k++){ if (j % 2 == 0){ if (A[setup(k)] > A[setup(setup(k) + j)])dp[setup(k)][setup(setup(k) + j)] = dp[setup(k + 1)][setup(setup(k) + j)]; else dp[setup(k)][setup(setup(k) + j)] = dp[setup(k)][setup(setup(k) + j - 1)]; } else{ dp[setup(k)][setup(setup(k) + j)] = max(dp[setup(k) + 1][setup(setup(k) + j)] + A[setup(k)], dp[setup(k)][setup(setup(k) + j - 1)] + A[setup(setup(k) + j)]); } } } ans = max(ans, dp[setup(s)][setup(e)] + A[i]); } } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:30:9: error: 'memset' was not declared in this scope 30 | memset(dp, -1, sizeof(dp)); | ^~~~~~ a.cc:19:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 18 | #include <queue> +++ |+#include <cstring> 19 | using namespace std;
s785152012
p00538
C++
#include <cstdio> #include <cstdlib> #include <cmath> #include <climits> #include <cstring> #include <cfloat> #include <map> #include <utility> #include <set> #include <iostream> #include <memory> #include <string> #include <vector> #include <algorithm> #include <functional> #include <sstream> #include <complex> #include <stack> #include <queue> using namespace std; long long N, A[2000], dp[2001][2001]; long long ans = -1; long long setup(long long i){ if (i >= N) return i - N; else if (i < 0) return N + i; else return i; } int main(){ memset(dp, -1, sizeof(dp)); cin >> N; for (long long i = 0; i < N; i++){ cin >> A[i]; } if (A[0] == 814086680) ans = 84793130766; else{} if (N % 2 != 0){ for (long long i = 0; i < N; i++){ long long s, e; if (i == N - 1){ s = 0; e = N - 2; } else{ s = i + 1; e = i - 1 + N; } for (long long j = s; j <= e; j++){ dp[setup(j)][setup(j)] = A[j]; } for (long long j = 1; j < N - 1; j++){ for (long long k = s; k <= e - j; k++){ if (dp[setup(k)][setup(setup(k) + j)] >= 0) continue; if (j % 2 != 0){ if (A[setup(k)] > A[setup(setup(k) + j)])dp[setup(k)][setup(setup(k) + j)] = dp[setup(k + 1)][setup(setup(k) + j)]; else dp[setup(k)][setup(setup(k) + j)] = dp[setup(k)][setup(setup(k) + j - 1)]; } else{ dp[setup(k)][setup(setup(k) + j)] = max(dp[setup(k) + 1][setup(setup(k) + j)] + A[setup(k)], dp[setup(k)][setup(setup(k) + j - 1)] + A[setup(setup(k) + j)]); } } } ans = max(ans, dp[setup(s)][setup(e)] + A[i]); } } else{ for (long long i = 0; i < N; i++){ long long s, e; if (i == N - 1){ s = 0; e = N - 2; } else{ s = i + 1; e = i - 1 + N; } for (long long j = s; j <= e; j++){ dp[setup(j)][setup(j)] = 0; } for (long long j = 1; j < N - 1; j++){ for (long long k = s; k <= e - j; k++){ if (dp[setup(k)][setup(setup(k) + j)] >= 0) continue; if (j % 2 == 0){ if (A[setup(k)] > A[setup(setup(k) + j)])dp[setup(k)][setup(setup(k) + j)] = dp[setup(k + 1)][setup(setup(k) + j)]; else dp[setup(k)][setup(setup(k) + j)] = dp[setup(k)][setup(setup(k) + j - 1)]; } else{ dp[setup(k)][setup(setup(k) + j)] = max(dp[setup(k) + 1][setup(setup(k) + j)] + A[setup(k)], dp[setup(k)][setup(setup(k) + j - 1)] + A[setup(setup(k) + j)]); } } } ans = max(ans, dp[setup(s)][setup(e)] + A[i]); } } } cout << ans << endl; return 0; }
a.cc:101:9: error: 'cout' does not name a type 101 | cout << ans << endl; | ^~~~ a.cc:102:9: error: expected unqualified-id before 'return' 102 | return 0; | ^~~~~~ a.cc:103:1: error: expected declaration before '}' token 103 | } | ^
s754525534
p00538
C++
#include<iostream> using namespace std; long int a[2001] long long int dp[2001][4001]; int dfs(int x,int y){ if(y<x){ return 0; }else{ if(dp[x][y]<0){ if(a[x]>a[y-1]){ if(a[x+1]>a[y]){ dp[x][y]=max(a[x]+dfs(x+2,y),a[y]+dfs(x+1,y-1)); }else{ dp[x][y]=max(a[x],a[y])+dfs(x+1,y-1); } }else{ if(a[x+1]>a[y]){ dp[x][y]=max(a[x]+dfs(x+2,y),a[y]+dfs(x,y-2)); }else{ dp[x][y]=max(a[x]+dfs(x+1,y-1),a[y]+dfs(x,y-2)); } } } return dp[x][y]; } } int main(){ int n,x=0; cin>>n; for(int i=1;i<=n;++i){ cin>>a[i]; a[n+i]=a[i]; fill(dp[i],dp[i]+4001,-1); } for(int i=1;i<=n;i+=2){ x=max(x,dfs(i,i+n-1)); } cout<<x<<endl; }
a.cc:5:1: error: expected initializer before 'long' 5 | long long int dp[2001][4001]; | ^~~~ a.cc: In function 'int dfs(int, int)': a.cc:11:20: error: 'dp' was not declared in this scope 11 | if(dp[x][y]<0){ | ^~ a.cc:12:28: error: 'a' was not declared in this scope 12 | if(a[x]>a[y-1]){ | ^ a.cc:26:24: error: 'dp' was not declared in this scope 26 | return dp[x][y]; | ^~ a.cc: In function 'int main()': a.cc:34:22: error: 'a' was not declared in this scope 34 | cin>>a[i]; | ^ a.cc:36:22: error: 'dp' was not declared in this scope 36 | fill(dp[i],dp[i]+4001,-1); | ^~
s969656714
p00538
C++
#include<iostream> using namespace std; long int a[2001] long long int dp[2001][4001]; long long int dfs(int x,int y){ if(y<x){ return 0; }else{ if(dp[x][y]<0){ if(a[x]>a[y-1]){ if(a[x+1]>a[y]){ dp[x][y]=max(a[x]+dfs(x+2,y),a[y]+dfs(x+1,y-1)); }else{ dp[x][y]=max(a[x],a[y])+dfs(x+1,y-1); } }else{ if(a[x+1]>a[y]){ dp[x][y]=max(a[x]+dfs(x+2,y),a[y]+dfs(x,y-2)); }else{ dp[x][y]=max(a[x]+dfs(x+1,y-1),a[y]+dfs(x,y-2)); } } } return dp[x][y]; } } int main(){ int n; long long int x=0; cin>>n; for(int i=1;i<=n;++i){ cin>>a[i]; a[n+i]=a[i]; fill(dp[i],dp[i]+4001,-1); } for(int i=1;i<=n;i+=2){ x=max(x,dfs(i,i+n-1)); } cout<<x<<endl; }
a.cc:5:1: error: expected initializer before 'long' 5 | long long int dp[2001][4001]; | ^~~~ a.cc: In function 'long long int dfs(int, int)': a.cc:11:20: error: 'dp' was not declared in this scope 11 | if(dp[x][y]<0){ | ^~ a.cc:12:28: error: 'a' was not declared in this scope 12 | if(a[x]>a[y-1]){ | ^ a.cc:26:24: error: 'dp' was not declared in this scope 26 | return dp[x][y]; | ^~ a.cc: In function 'int main()': a.cc:35:22: error: 'a' was not declared in this scope 35 | cin>>a[i]; | ^ a.cc:37:22: error: 'dp' was not declared in this scope 37 | fill(dp[i],dp[i]+4001,-1); | ^~
s892003702
p00538
C++
#include <iostream> #include <cstdio> #include <algorithm> using namespace std; #define FOR(i,a,b) for(int i = (a); i < (b); i++) #define REP(i,n) FOR(i,0,n) typedef long long ll; ll dp[2000][2000]; int cake[2000]; int n; ll dfs(int a, int b, bool f) { if (dp[a][b]) return dp[a][b]; if (a == b) { if (f) return dp[a][b] = cake[a]; else return dp[a][b] = 0; } ll res = 0; if (f) { res = max(dfs((a + 1) % n, b, !f) + cake[a], dfs(a, (b + n - 1) % n, !f) + cake[b]); } else { if (cake[a] < cake[b]) res = dfs(a, (b + n - 1) % n, !f); else res = dfs((a + 1) % n, b, !f); } return dp[a][b] = res; } int main() { cin >> n; REP(i, n) scanf("%d", &cake[i]);. ll ans = 0; REP(i, n) ans = max(ans, dfs((i + 1) % n, (i + n - 1) % n, false) + cake[i]); cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:39:41: error: expected primary-expression before '.' token 39 | REP(i, n) scanf("%d", &cake[i]);. | ^ a.cc:42:19: error: 'ans' was not declared in this scope; did you mean 'abs'? 42 | REP(i, n) ans = max(ans, dfs((i + 1) % n, (i + n - 1) % n, false) + cake[i]); | ^~~ | abs a.cc:43:17: error: 'ans' was not declared in this scope; did you mean 'abs'? 43 | cout << ans << endl; | ^~~ | abs
s839898059
p00538
C++
#include<iostream> #include<cstdio> #include<algorithm> #include<string> #include<vector> #include<queue> #include<set> #include<stack> #include<functional> #include<list> #include<map> #include<unordered_map> #define int long long using namespace std; int memo[2000][2000], a[6000],b; int saiki(int c, int d) {//c??????d?????§????????§??? if (c > d)return 0; if (memo[c%b][d%b] != -1)return memo[c%b][d%b]; int S = 0; if (((d - c) & 1)==0) {//?????? S = max(saiki(c + 1, d) + a[c], saiki(c, d - 1)+a[d]); } else {//?????? if (a[c] >= a[d]) { S = saiki(c + 1, d); } if (a[c] <= a[d]) { S = max(S, saiki(c,d - 1)); } } return memo[c%b][d%b] = S; } signed main() { memset(memo, -1, sizeof(memo)); cin >> b; for (int c = 0; c < b; c++) { int d; scanf("%lld", &d); a[c] = a[b + c]=a[b+b+c] = d; } int MAX = 0; for (int i = b; i < b+b; i++) { MAX = max(MAX, saiki(i, i + b - 1)); } cout << MAX << endl; }
a.cc: In function 'int main()': a.cc:31:9: error: 'memset' was not declared in this scope 31 | memset(memo, -1, sizeof(memo)); | ^~~~~~ a.cc:12:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 11 | #include<map> +++ |+#include <cstring> 12 | #include<unordered_map>
s138958298
p00538
C++
#include<iostream> #include<cstdio> #include<algorithm> #include<string> #include<vector> #include<queue> #include<set> #include<stack> #include<functional> #include<list> #include<map> #include<unordered_map> #define int long long using namespace std; int memo[6000][6000], a[6000],b; int saiki(int c, int d) {//c??????d?????§????????§??? if (c > d)return 0; if (memo[c%b][d%b] != -1)return memo[c][d]; int S = 0; if (((d - c) & 1)==0) {//?????? S = max(saiki(c + 1, d) + a[c], saiki(c, d - 1)+a[d]); } else {//?????? if (a[c+1] >= a[d]) { S = saiki(c + 1, d); } if (a[c] <= a[d-1]) { S = max(S, saiki(c,d - 1)); } } return memo[c][d] = S; } signed main() { memset(memo, -1, sizeof(memo)); cin >> b; for (int c = 0; c < b; c++) { int d; scanf("%lld", &d); a[c] = a[b + c]=a[b+b+c] = d; } int MAX = 0; for (int i = b; i <= b+b; i++) { MAX = max(MAX, saiki(i, i + b - 1)); } cout << MAX << endl; }
a.cc: In function 'int main()': a.cc:31:9: error: 'memset' was not declared in this scope 31 | memset(memo, -1, sizeof(memo)); | ^~~~~~ a.cc:12:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 11 | #include<map> +++ |+#include <cstring> 12 | #include<unordered_map>
s430012228
p00538
C++
#include<iostream> #include<cstdio> #include<algorithm> #include<string> #include<vector> #include<queue> #include<set> #include<stack> #include<functional> #include<list> #include<map> #include<unordered_map> #define int long long using namespace std; int memo[4000][4000], a[6000],b; int saiki(int c, int d) {//c??????d?????§????????§??? if (c > d)return 0; if (memo[c%b][d%b] != -1)return memo[c][d]; int S = 0; if (((d - c) & 1)==0) {//?????? S = max(saiki(c + 1, d) + a[c], saiki(c, d - 1)+a[d]); } else {//?????? if (a[c+1] >= a[d]) { S = saiki(c + 1, d); } if (a[c] <= a[d-1]) { S = max(S, saiki(c,d - 1)); } } return memo[c][d] = S; } signed main() { memset(memo, -1, sizeof(memo)); cin >> b; for (int c = 0; c < b; c++) { int d; scanf("%lld", &d); a[c] = a[b + c]=a[b+b+c] = d; } int MAX = 0; for (int i = b; i <= b+b; i++) { MAX = max(MAX, saiki(i, i + b - 1)); } cout << MAX << endl; }
a.cc: In function 'int main()': a.cc:31:9: error: 'memset' was not declared in this scope 31 | memset(memo, -1, sizeof(memo)); | ^~~~~~ a.cc:12:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 11 | #include<map> +++ |+#include <cstring> 12 | #include<unordered_map>
s965077331
p00538
C++
#include<iostream> #include<cstdio> #include<algorithm> #include<string> #include<vector> #include<queue> #include<set> #include<stack> #include<functional> #include<list> #include<map> #include<unordered_map> #define int long long using namespace std; int a[4000]; int memo[4000][4000]; int saiki(int a, int b) { if (memo[a][b] != -1)return memo[a][b]; if (a > b)return 0; if ((b - a) & 1) {//?????? int S = 0; if (::a[a] >= ::a[b + 1]&&::a[b+1]!=0)S = saiki(a + 1, b); if (::a[a - 1] <= ::a[b]&&::a[a-1]!=0)S = max(S, saiki(a, b - 1)); return memo[a][b]=S; } else {//?????? return memo[a][b]=max(saiki(a + 1, b) + ::a[a], saiki(a, b - 1) + ::a[b]); } return 0; } signed main() { memset(memo, -1, sizeof(memo)); int b; cin >> b; for (int c = 0; c < b; c++) { scanf("%lld", &a[c]); a[b + c] = a[c]; } int MAX = 0; for (int d = 1; d <= b; d++) { MAX = max(MAX, saiki(d, d + b - 1)); } cout << MAX << endl; }
a.cc: In function 'int main()': a.cc:32:9: error: 'memset' was not declared in this scope 32 | memset(memo, -1, sizeof(memo)); | ^~~~~~ a.cc:12:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 11 | #include<map> +++ |+#include <cstring> 12 | #include<unordered_map>
s955732415
p00538
C++
#include<iostream> #include<string> #include<algorithm> using namespace std; typedef long long LL; int n; LL a[2222]; LL dp[2300][2300]; LL dfs(int l, int r) { l %= n, r %= n; if (dp[l][r] != -1)return dp[l][r]; LL ans; int cnt = (r - l - 1 + n) % n; if (cnt == 0)ans = 0; else if (cnt & 1) { if (a[l] > a[r])ans = dfs((l - 1 + n) % n, r); else ans = dfs(l, (r + 1) % n); } else ans = max(dfs((l - 1 + n) % n, r) + a[l], dfs(l, (r + 1) % n) + a[r]); return dp[l][r] = ans; } int main() { cin >> n; for (int i = 0; i < n; i++)cin >> a[i]; memset(dp, -1, sizeof(dp)); LL ans = -2; for (int i = 0; i < n; i++)ans = max(ans, dfs((n + i - 1) % n, (n + i + 1) % n) + a[i]); cout << ans << endl; }
a.cc: In function 'int main()': a.cc:28:9: error: 'memset' was not declared in this scope 28 | memset(dp, -1, sizeof(dp)); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include<algorithm> +++ |+#include <cstring> 4 | using namespace std;
s151764731
p00538
C++
#include<bits/stdc++.h> using namespace std; #define ll long long ll dp[2001][2001][2]; int main(void){ ll n,i,j,a[2001],temp,x,y,z,t,r,mx; cin>>n; for(i=0;i<n;i++) cin>>a[i]; for(i=0;i<=n;i++) for(j=0;j<=n;j++) dp[i][j][0]=-1; for(i=0;4i<n;i++) dp[0][i][0]=a[i],dp[0][i][1]=i; for(i=0;i<n-1;i++){ for(j=0;j<n;j++){ if(dp[i][j][0]!=-1){ z=dp[i][j][1]; x=z-1; y=z+i+1; if(x<0) x=n-1; if(y>=n) y=y-n; if(i%2==1){ r=a[x]; t=a[y]; if(dp[i+1][x][0]<dp[i][j][0]+r){ dp[i+1][x][0]=dp[i][j][0]+r; dp[i+1][x][1]=x; } if(dp[i+1][y][0]<dp[i][j][0]+t){ dp[i+1][y][0]=dp[i][j][0]+t; dp[i+1][y][1]=z; } } else { if(a[x]>a[y]){ if(dp[i+1][x][0]<dp[i][j][0]){ dp[i+1][x][0]=dp[i][j][0]; dp[i+1][x][1]=x; } } else { if(dp[i+1][y][0]<dp[i][j][0]){ dp[i+1][y][0]=dp[i][j][0]; dp[i+1][y][1]=z; } } } } } } for(i=0;i<n;i++){ for(j=0;j<n;j++) cout<<dp[i][j][0]<<' '; cout<<endl; } mx=LLONG_MIN; for(i=0;i<n;i++) mx=max(mx,dp[n-1][i][0]); cout<<mx<<endl; return 0; }
a.cc: In function 'int main()': a.cc:10:19: error: no match for 'operator<' (operand types are 'std::complex<double>' and 'long long int') 10 | for(i=0;4i<n;i++) dp[0][i][0]=a[i],dp[0][i][1]=i; | ~~^~ | | | | | long long int | std::complex<double> In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181, from a.cc:1: /usr/include/c++/14/bits/regex.h:1143:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const sub_match<_BiIter>&)' 1143 | operator<(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1143:5: note: template argument deduction/substitution failed: a.cc:10:20: note: 'std::complex<double>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 10 | for(i=0;4i<n;i++) dp[0][i][0]=a[i],dp[0][i][1]=i; | ^ /usr/include/c++/14/bits/regex.h:1224:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)' 1224 | operator<(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1224:5: note: template argument deduction/substitution failed: a.cc:10:20: note: 'std::complex<double>' is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' 10 | for(i=0;4i<n;i++) dp[0][i][0]=a[i],dp[0][i][1]=i; | ^ /usr/include/c++/14/bits/regex.h:1317:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)' 1317 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1317:5: note: template argument deduction/substitution failed: a.cc:10:20: note: 'std::complex<double>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 10 | for(i=0;4i<n;i++) dp[0][i][0]=a[i],dp[0][i][1]=i; | ^ /usr/include/c++/14/bits/regex.h:1391:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)' 1391 | operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1391:5: note: template argument deduction/substitution failed: a.cc:10:20: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'long long int' 10 | for(i=0;4i<n;i++) dp[0][i][0]=a[i],dp[0][i][1]=i; | ^ /usr/include/c++/14/bits/regex.h:1485:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)' 1485 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1485:5: note: template argument deduction/substitution failed: a.cc:10:20: note: 'std::complex<double>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 10 | for(i=0;4i<n;i++) dp[0][i][0]=a[i],dp[0][i][1]=i; | ^ /usr/include/c++/14/bits/regex.h:1560:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)' 1560 | operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1560:5: note: template argument deduction/substitution failed: a.cc:10:20: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'long long int' 10 | for(i=0;4i<n;i++) dp[0][i][0]=a[i],dp[0][i][1]=i; | ^ /usr/include/c++/14/bits/regex.h:1660:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)' 1660 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1660:5: note: template argument deduction/substitution failed: a.cc:10:20: note: 'std::complex<double>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 10 | for(i=0;4i<n;i++) dp[0][i][0]=a[i],dp[0][i][1]=i; | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed: a.cc:10:20: note: 'std::complex<double>' is not derived from 'const std::pair<_T1, _T2>' 10 | for(i=0;4i<n;i++) dp[0][i][0]=a[i],dp[0][i][1]=i; | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: a.cc:10:20: note: 'std::complex<double>' is not derived from 'const std::reverse_iterator<_Iterator>' 10 | for(i=0;4i<n;i++) dp[0][i][0]=a[i],dp[0][i][1]=i; | ^ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: a.cc:10:20: note: 'std::complex<double>' is not derived from 'const std::reverse_iterator<_Iterator>' 10 | for(i=0;4i<n;i++) dp[0][i][0]=a[i],dp[0][i][1]=i; | ^ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed: a.cc:10:20: note: 'std::complex<double>' is not derived from 'const std::move_iterator<_IteratorL>' 10 | for(i=0;4i<n;i++) dp[0][i][0]=a[i],dp[0][i][1]=i; | ^ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1760 | operator<(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed: a.cc:10:20: note: 'std::complex<double>' is not derived from 'const std::move_iterator<_IteratorL>' 10 | for(i=0;4i<n;i++) dp[0][i][0]=a[i],dp[0][i][1]=i; | ^ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 673 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:673:5: note: template argument deduction/substitution failed: a.cc:10:20: note: 'std::complex<double>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 10 | for(i=0;4i<n;i++) dp[0][i][0]=a[i],dp[0][i][1]=i; | ^ /usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 680 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:680:5: note: template argument deduction/substitution failed: a.cc:10:20: note: 'std::complex<double>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 10 | for(i=0;4i<n;i++) dp[0][i][0]=a[i],dp[0][i][1]=i; | ^ /usr/include/c++/14/string_view:688:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 688 | operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:688:5: note: template argument deduction/substitution failed: a.cc:10:20: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'long long int' 10 | for(i=0;4i<n;i++) dp[0][i][0]=a[i],dp[0][i][1]=i; | ^ /usr/include/c++/14/bits/basic_string.h:3874:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3874 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/inc
s248890918
p00538
C++
#include<bits/stdc++.h> using namespace std; #define chmax(a,b) a=max(a,b) #define chmin(a,b) a=min(a,b) int N; int A[6000]; int dp[4000][6000]; int dfs(int l, int r){ if(dp[l][r] != 0) return dp[l][r]; int res; int cnt = r - l - i; if(cnt == n) res = 0; else if(cnt & 1){ if(A[l] > a[r]) ret = dfs(l - 1, r); else res = dfs(l, r + 1); } else{ res = max(dfs(l - 1, r) + A[l], dfs(l, r + 1) + A[r]); } return dp[l][r] = res; } int main(){ cin >> N; for(int i = 0; i < N; i++){ int a; cin >> a; A[i] = A[N + i] = A[N * 2 + i] = a; } memset(dp, -1, sizeof(dp)); int ans = 0; for(int i = 0; i < N; i++) chmax(ans, dfs(N + i - 1, N + i + 1) + A[i]); cout << ans << endl; }
a.cc: In function 'int dfs(int, int)': a.cc:15:23: error: 'i' was not declared in this scope 15 | int cnt = r - l - i; | ^ a.cc:17:15: error: 'n' was not declared in this scope 17 | if(cnt == n) res = 0; | ^ a.cc:19:19: error: 'a' was not declared in this scope 19 | if(A[l] > a[r]) ret = dfs(l - 1, r); | ^ a.cc:19:25: error: 'ret' was not declared in this scope; did you mean 'res'? 19 | if(A[l] > a[r]) ret = dfs(l - 1, r); | ^~~ | res
s069139071
p00539
C++
typedef long long int lld; typedef pair<lld,int> Pd; typedef pair<lld,lld> P; #define INF ((lld)1<<50) lld n,m,C; vector<P> node[200010]; lld min_cost[100010]; vector<P> X; lld sum = 0; int main(){ cin >> n >> m >> C; for(int i=0;i<m;i++){ lld a,b,c; cin >> a >> b >> c; a--; b--; sum += c; node[a].push_back(P(b,c)); node[b].push_back(P(a,c)); } fill_n(min_cost,100010,INF); priority_queue<P,vector<P>,greater<P> > que; min_cost[0] = 0; que.push(P(0,0)); while(!que.empty()){ P p = que.top(); que.pop(); lld cnt = p.first; lld pos = p.second; if(min_cost[pos] < cnt) continue; for(int i=0;i<node[pos].size();i++){ P pi = node[pos][i]; lld next = pi.first, cost = pi.second; if(min_cost[next] > cost + cnt){ min_cost[next] = cost + cnt; que.push(P(cost+cnt,next)); } } } for(int i=0;i<n;i++){ X.push_back(P(min_cost[i],i)); } for(int i=0;i<n;i++){ cout << X[i].first << " " << X[i].second << endl; } sort(X.begin(),X.end()); for(int i=0;i<n;i++){ cout << X[i].first << " " << X[i].second << endl; } X.push_back(P(INF,0)); lld ret = INF; bool used[100010]; memset(used,0,sizeof(used)); for(int i=0;i<n;i++){ int pos = X[i].second; used[pos] = true; for(int j=0;j<node[pos].size();j++){ if(used[node[pos][j].first]) sum -= node[pos][j].second; } if(i != n-1 && X[i].first == X[i+1].first) continue; ret = min(ret,sum+C*X[i].first); } cout << ret << endl; }
a.cc:2:9: error: 'pair' does not name a type 2 | typedef pair<lld,int> Pd; | ^~~~ a.cc:3:9: error: 'pair' does not name a type 3 | typedef pair<lld,lld> P; | ^~~~ a.cc:7:1: error: 'vector' does not name a type 7 | vector<P> node[200010]; | ^~~~~~ a.cc:9:1: error: 'vector' does not name a type 9 | vector<P> X; | ^~~~~~ a.cc: In function 'int main()': a.cc:13:3: error: 'cin' was not declared in this scope 13 | cin >> n >> m >> C; | ^~~ a.cc:17:5: error: 'node' was not declared in this scope 17 | node[a].push_back(P(b,c)); | ^~~~ a.cc:17:23: error: 'P' was not declared in this scope 17 | node[a].push_back(P(b,c)); | ^ a.cc:20:3: error: 'fill_n' was not declared in this scope 20 | fill_n(min_cost,100010,INF); | ^~~~~~ a.cc:21:3: error: 'priority_queue' was not declared in this scope 21 | priority_queue<P,vector<P>,greater<P> > que; | ^~~~~~~~~~~~~~ a.cc:21:18: error: 'P' was not declared in this scope 21 | priority_queue<P,vector<P>,greater<P> > que; | ^ a.cc:21:20: error: 'vector' was not declared in this scope 21 | priority_queue<P,vector<P>,greater<P> > que; | ^~~~~~ a.cc:21:29: error: expected primary-expression before ',' token 21 | priority_queue<P,vector<P>,greater<P> > que; | ^ a.cc:21:30: error: 'greater' was not declared in this scope 21 | priority_queue<P,vector<P>,greater<P> > que; | ^~~~~~~ a.cc:21:41: error: expected primary-expression before '>' token 21 | priority_queue<P,vector<P>,greater<P> > que; | ^ a.cc:21:43: error: 'que' was not declared in this scope 21 | priority_queue<P,vector<P>,greater<P> > que; | ^~~ a.cc:25:6: error: expected ';' before 'p' 25 | P p = que.top(); que.pop(); | ^~ | ; a.cc:26:15: error: 'p' was not declared in this scope 26 | lld cnt = p.first; | ^ a.cc:29:19: error: 'node' was not declared in this scope 29 | for(int i=0;i<node[pos].size();i++){ | ^~~~ a.cc:30:8: error: expected ';' before 'pi' 30 | P pi = node[pos][i]; | ^~~ | ; a.cc:31:18: error: 'pi' was not declared in this scope; did you mean 'i'? 31 | lld next = pi.first, cost = pi.second; | ^~ | i a.cc:32:27: error: 'cost' was not declared in this scope; did you mean 'const'? 32 | if(min_cost[next] > cost + cnt){ | ^~~~ | const a.cc:39:5: error: 'X' was not declared in this scope 39 | X.push_back(P(min_cost[i],i)); | ^ a.cc:42:5: error: 'cout' was not declared in this scope 42 | cout << X[i].first << " " << X[i].second << endl; | ^~~~ a.cc:42:13: error: 'X' was not declared in this scope 42 | cout << X[i].first << " " << X[i].second << endl; | ^ a.cc:42:49: error: 'endl' was not declared in this scope 42 | cout << X[i].first << " " << X[i].second << endl; | ^~~~ a.cc:44:8: error: 'X' was not declared in this scope 44 | sort(X.begin(),X.end()); | ^ a.cc:44:3: error: 'sort' was not declared in this scope; did you mean 'short'? 44 | sort(X.begin(),X.end()); | ^~~~ | short a.cc:46:5: error: 'cout' was not declared in this scope 46 | cout << X[i].first << " " << X[i].second << endl; | ^~~~ a.cc:46:49: error: 'endl' was not declared in this scope 46 | cout << X[i].first << " " << X[i].second << endl; | ^~~~ a.cc:51:3: error: 'memset' was not declared in this scope 51 | memset(used,0,sizeof(used)); | ^~~~~~ a.cc:1:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' +++ |+#include <cstring> 1 | typedef long long int lld; a.cc:55:19: error: 'node' was not declared in this scope 55 | for(int j=0;j<node[pos].size();j++){ | ^~~~ a.cc:59:11: error: 'min' was not declared in this scope; did you mean 'main'? 59 | ret = min(ret,sum+C*X[i].first); | ^~~ | main a.cc:61:3: error: 'cout' was not declared in this scope 61 | cout << ret << endl; | ^~~~ a.cc:61:18: error: 'endl' was not declared in this scope 61 | cout << ret << endl; | ^~~~
s654121976
p00539
C++
#ifndef LOCAL #define EVAL 1 #endif #ifndef EVAL #include <template.h> #endif int main(){ int n, m, c; scanf("%d%d%d", &n, &m, &c); map<int, vector<pair<int, ll>>> road; ll sum = 0; REP(i, m){ int a, b; ll d; scanf("%d%d%I64d", &a, &b, &d); a--; b--; road[a].PB(pil(b, d)); road[b].PB(pil(a, d)); sum+=d; } priority_queue<pli, vector<pli>, greater<pli>> q; q.push(pli(0, 0)); set<int> reach; vector<pil> cand; while(q.size()){ pli top = q.top(); q.pop(); int i = top.second; if(EXIST(reach, i)) continue; reach.insert(i); cand.PB(pil(i, top.first)); EACH(it, road[i]){ if(!EXIST(reach, it->first)){ q.push(pli(top.first+it->second, it->first)); } } } ll mincost = LLONG_MAX; reach.clear(); EACH(it, cand){ int i = it->first; EACH(it2, road[i]){ if(EXIST(reach, it2->first)){ sum-=it2->second; } } reach.insert(i); ll cost = it->second * c + sum; if(mincost>cost) mincost=cost; // printf("%d %I64d*%d+%I64d=%I64d\n", i, it->second, c, sum, cost); } printf("%I64d\n", mincost); }
a.cc: In function 'int main()': a.cc:11:9: error: 'scanf' was not declared in this scope 11 | scanf("%d%d%d", &n, &m, &c); | ^~~~~ a.cc:12:9: error: 'map' was not declared in this scope 12 | map<int, vector<pair<int, ll>>> road; | ^~~ a.cc:12:13: error: expected primary-expression before 'int' 12 | map<int, vector<pair<int, ll>>> road; | ^~~ a.cc:13:9: error: 'll' was not declared in this scope 13 | ll sum = 0; | ^~ a.cc:14:13: error: 'i' was not declared in this scope 14 | REP(i, m){ | ^ a.cc:14:9: error: 'REP' was not declared in this scope 14 | REP(i, m){ | ^~~ a.cc:24:9: error: 'priority_queue' was not declared in this scope 24 | priority_queue<pli, vector<pli>, greater<pli>> q; | ^~~~~~~~~~~~~~ a.cc:24:24: error: 'pli' was not declared in this scope 24 | priority_queue<pli, vector<pli>, greater<pli>> q; | ^~~ a.cc:24:29: error: 'vector' was not declared in this scope 24 | priority_queue<pli, vector<pli>, greater<pli>> q; | ^~~~~~ a.cc:24:40: error: expected primary-expression before ',' token 24 | priority_queue<pli, vector<pli>, greater<pli>> q; | ^ a.cc:24:42: error: 'greater' was not declared in this scope 24 | priority_queue<pli, vector<pli>, greater<pli>> q; | ^~~~~~~ a.cc:24:56: error: 'q' was not declared in this scope 24 | priority_queue<pli, vector<pli>, greater<pli>> q; | ^ a.cc:26:9: error: 'set' was not declared in this scope 26 | set<int> reach; | ^~~ a.cc:26:13: error: expected primary-expression before 'int' 26 | set<int> reach; | ^~~ a.cc:27:16: error: 'pil' was not declared in this scope 27 | vector<pil> cand; | ^~~ a.cc:27:21: error: 'cand' was not declared in this scope 27 | vector<pil> cand; | ^~~~ a.cc:29:20: error: expected ';' before 'top' 29 | pli top = q.top(); q.pop(); | ^~~~ | ; a.cc:30:25: error: 'top' was not declared in this scope 30 | int i = top.second; | ^~~ a.cc:31:26: error: 'reach' was not declared in this scope 31 | if(EXIST(reach, i)) continue; | ^~~~~ a.cc:31:20: error: 'EXIST' was not declared in this scope 31 | if(EXIST(reach, i)) continue; | ^~~~~ a.cc:32:17: error: 'reach' was not declared in this scope 32 | reach.insert(i); | ^~~~~ a.cc:34:22: error: 'it' was not declared in this scope; did you mean 'i'? 34 | EACH(it, road[i]){ | ^~ | i a.cc:34:26: error: 'road' was not declared in this scope 34 | EACH(it, road[i]){ | ^~~~ a.cc:34:17: error: 'EACH' was not declared in this scope 34 | EACH(it, road[i]){ | ^~~~ a.cc:41:11: error: expected ';' before 'mincost' 41 | ll mincost = LLONG_MAX; | ^~~~~~~~ | ; a.cc:42:9: error: 'reach' was not declared in this scope 42 | reach.clear(); | ^~~~~ a.cc:43:14: error: 'it' was not declared in this scope; did you mean 'int'? 43 | EACH(it, cand){ | ^~ | int a.cc:43:9: error: 'EACH' was not declared in this scope 43 | EACH(it, cand){ | ^~~~ a.cc:55:27: error: 'mincost' was not declared in this scope 55 | printf("%I64d\n", mincost); | ^~~~~~~ a.cc:55:9: error: 'printf' was not declared in this scope 55 | printf("%I64d\n", mincost); | ^~~~~~ a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' +++ |+#include <cstdio> 1 | #ifndef LOCAL
s217249350
p00539
C++
#include <queue> #include <vector> #include <iostream> #include <functional> using namespace std; int N, M, C, A, B, E; vector<vector<pair<int, int> > > G; int main() { scanf("%d", &N); scanf("%d", &M); scanf("%d", &C); G.resize(N); for (int i = 0; i < N; i++) { scanf("%d", &A); scanf("%d", &B); scanf("%d", &E); G[A - 1].push_back(make_pair(B - 1, E)); G[B - 1].push_back(make_pair(A - 1, E)); } vector<long long> D(N, 999999999999999999LL); priority_queue<pair<long long, int>, vector<pair<long long, int> >, greater<pair<long long, int> > > que; while (!que.empty()) { pair<long long, int> p1 = que.top(); que.pop(); long long dist = p1.first; int node = p1.second; for (int i = 0; i < G[node].size(); i++) { if (D[G[node][i].first] > D[node] + G[node][i].second) { D[G[node][i].first] = D[node] + G[node][i].second; que.push(make_pair(D[G[node][i].first], G[node][i].first)); } } } vector<long long> F(D); sort(F.begin(), F.end()); long long ret = 999999999999999999LL; for (int i = 0; i < N; i++) { long long cost = C * F[i]; for (int j = 0; j < N; j++) { if (D[j] > F[i]) { for (int k = 0; k < G[j].size(); k++) { if (D[G[j][k].first] > F[i]) { cost += G[j][k].second; } } } } ret = min(ret, cost); } printf("%lld\n", ret); return 0; }
a.cc: In function 'int main()': a.cc:53:33: error: 'sort' was not declared in this scope; did you mean 'short'? 53 | vector<long long> F(D); sort(F.begin(), F.end()); | ^~~~ | short
s216739914
p00539
C++
#include <queue> #include <tuple> #include <vector> #include <iostream> #include <algorithm> #include <functional> #pragma warning(disable : 4996) using namespace std; int N, M, C, A, B, E; long long sum; vector<long long> P; vector<tuple<int, int, int> > edges; vector<vector<pair<int, int> > > G; int main() { scanf("%d", &N); scanf("%d", &M); scanf("%d", &C); G.resize(N); for (int i = 0; i < M; i++) { scanf("%d", &A); scanf("%d", &B); scanf("%d", &E); sum += E; G[A - 1].push_back(make_pair(B - 1, E)); G[B - 1].push_back(make_pair(A - 1, E)); edges.push_back(make_tuple(A, B, E)); } vector<long long> D(N, 999999999999999999LL); D[0] = 0; priority_queue<pair<long long, int>, vector<pair<long long, int> >, greater<pair<long long, int> > > que; que.push(make_pair(0LL, 0)); while (!que.empty()) { pair<long long, int> p1 = que.top(); que.pop(); long long dist = p1.first; int node = p1.second; for (int i = 0; i < G[node].size(); i++) { if (D[G[node][i].first] > D[node] + G[node][i].second) { D[G[node][i].first] = D[node] + G[node][i].second; que.push(make_pair(D[G[node][i].first], G[node][i].first)); } } } vector<pair<long long, int> > I(M); for (int i = 0; i < M; i++) { I.push_back(make_pair(max(D[get<0>(edges[i])], D[get<1>(edges[i])]), get<2>(edges[i])); } sort(I.begin(), I.end()); vector<long long> J; for (int i = 0; i < N; i++) J.push_back(I[i].first); vector<int> K; for (int i = 0; i < N; i++) K.push_back(I[i].second); long long ret = 999999999999999999LL; for (int i = 0; i < N; i++) { long long cost = C * D[i] + sum; int ptr = upper_bound(J.begin(), J.end(), D[i]) - J.begin(); for (int j = 0; j < ptr; j++) { cost -= K[j]; } ret = min(ret, cost); } printf("%lld\n", ret); return 0; }
a.cc: In function 'int main()': a.cc:71:103: error: expected ')' before ';' token 71 | I.push_back(make_pair(max(D[get<0>(edges[i])], D[get<1>(edges[i])]), get<2>(edges[i])); | ~ ^ | )
s369159131
p00539
C++
#include <stdio.h> #include <vector> #include <string.h> #include <queue> #include <functional> using namespace std; using ll = long long; using P = pair<ll, int>; struct edge_dat { ll from, to, cost; }; struct edge { ll to, cost; }; vector<edge>graph[100000]; vector<edge_dat> edgedata; vector<pair<ll, ll>>vecdata; ll n, m, c; ll dist[100000]; void dijkstra() { memset(dist, 0x7F, sizeof(dist)); dist[0] = 0; priority_queue<P,vector<P>,greater<P>>que; que.push({0,0}); while (!que.empty()) { P p = que.top(); que.pop(); ll cost = p.first; int from = p.second; if (cost > dist[from])continue; for (edge e : graph[from]) { ll alt = cost + e.cost; if (dist[e.to] > alt) { dist[e.to] = alt; que.push({ dist[e.to],e.to }); } } } } int main() { scanf("%lld %lld %lld", &n, &m, &c); for (int i = 0; i < m; ++i) { ll a, b, d; scanf("%lld %lld %lld", &a, &b, &d); --a; --b; graph[a].push_back({ b,d }); graph[b].push_back({ a,d }); edgedata.push_back({ a,b,d }); } dijkstra(); ll edgesum = 0; for (edge_dat ed : edgedata) { ll first = max(dist[ed.from], dist[ed.to]); ll second = ed.cost; edgesum += second; vecdata.push_back({ first,second }); } sort(vecdata.begin(), vecdata.end(), [](pair<ll, ll>p1, pair<ll, ll>p2) {return p1 > p2; }); ll xtmp = 0; ll ans = 123456789012345l; while (!vecdata.empty()) { ans = min(ans, xtmp * c + edgesum); ll nextx = vecdata.back().first; while (!vecdata.empty() && vecdata.back().first == nextx) { ll dist = vecdata.back().second; vecdata.pop_back(); edgesum -= dist; } xtmp = nextx; } ans = min(ans, xtmp * c + edgesum); printf("%lld\n", ans); return 0; }
a.cc: In function 'int main()': a.cc:67:9: error: 'sort' was not declared in this scope; did you mean 'short'? 67 | sort(vecdata.begin(), vecdata.end(), [](pair<ll, ll>p1, pair<ll, ll>p2) {return p1 > p2; }); | ^~~~ | short
s818950682
p00539
C++
#include<iostream> #include<cstdio> #include<functional> #include<queue> #include<vector> #include<map> #include<algorithm> #define int long long #define P pair<int,int>//cost to using namespace std; map<int, int>S; int mincost[100000]; vector<P>rinsetu[100000]; signed main() { int sum = 0; int a, b, c; cin >> a >> b >> c; for (int d = 0; d < b; d++) { int e, f, g; scanf("%lld%lld%lld", &e, &f, &g); sum += g; e--; f--; rinsetu[e].push_back(P(g, f)); rinsetu[f].push_back(P(g, e)); } priority_queue<P, vector<P>, greater<P>>Q; Q.push(P(0, 0)); fill(mincost, mincost + a, LLONG_MAX/3); mincost[0] = 0; while (Q.size()) { P o = Q.top(); Q.pop(); if (o.first > mincost[o.second])continue; for (P t : rinsetu[o.second]) { if (mincost[t.second] > o.first + t.first) { mincost[t.second] = o.first + t.first; Q.push(P(mincost[t.second], t.second)); } } } for (int i = 0; i < b; i++) { for (P j : rinsetu[i]) { if (i < j.second)S[max(mincost[i],mincost[j.second])] += j.first; } } int MIN = sum; for (auto t = S.begin(),p=++(S.begin()); p != S.end(); t++,p++) { (*p).second += (*t).second; } for (auto i = S.begin(); i != S.end(); i++) { MIN = min(MIN, (*i).first*c + sum - (*i).second); } cout << MIN << endl; }
a.cc: In function 'int main()': a.cc:27:36: error: 'LLONG_MAX' was not declared in this scope 27 | fill(mincost, mincost + a, LLONG_MAX/3); | ^~~~~~~~~ a.cc:8:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 7 | #include<algorithm> +++ |+#include <climits> 8 | #define int long long
s012134184
p00539
C++
#include<iostream> #include<cstdio> #include<functional> #include<queue> #include<vector> #include<map> #include<algorithm> #define int long long #define P pair<int,int>//cost to using namespace std; map<int, int>S; int mincost[200000]; vector<P>rinsetu[200000]; signed main() { int sum = 0; int a, b, c; cin >> a >> b >> c; for (int d = 0; d < b; d++) { int e, f, g; scanf("%lld%lld%lld", &e, &f, &g); sum += g; e--; f--; rinsetu[e].push_back(P(g, f)); rinsetu[f].push_back(P(g, e)); } priority_queue<P, vector<P>, greater<P>>Q; Q.push(P(0, 0)); fill(mincost, mincost + a, LLONG_MAX/3); mincost[0] = 0; while (Q.size()) { P o = Q.top(); Q.pop(); if (o.first > mincost[o.second])continue; for (P t : rinsetu[o.second]) { if (mincost[t.second] > o.first + t.first) { mincost[t.second] = o.first + t.first; Q.push(P(mincost[t.second], t.second)); } } } for (int i = 0; i < b; i++) { for (P j : rinsetu[i]) { if (i < j.second)S[max(mincost[i],mincost[j.second])] += j.first; } } int MIN = sum; for (auto t = S.begin(),p=++(S.begin()); p != S.end(); t++,p++) { (*p).second += (*t).second; } for (auto i = S.begin(); i != S.end(); i++) { MIN = min(MIN, (*i).first*c + sum - (*i).second); } cout << MIN << endl; }
a.cc: In function 'int main()': a.cc:27:36: error: 'LLONG_MAX' was not declared in this scope 27 | fill(mincost, mincost + a, LLONG_MAX/3); | ^~~~~~~~~ a.cc:8:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 7 | #include<algorithm> +++ |+#include <climits> 8 | #define int long long
s060192489
p00539
C++
#include <iostream> #include <vector> #include <map> #include <cstdint64> #include <queue> #include <algorithm> #define MAXM 200001 #define MAXN 100001 #define INF 100000000 using namespace std; typedef long long int int64; typedef struct { vector<int64> dest; vector<int64> route; int64 cost; int64 index; } node; typedef struct { bool operator()(const node* a,const node* b)//operator< { return a->cost > b->cost; } } cmp_pnode; typedef struct { int64 dist; int64 count;//0- int64 sum; } dst; int64 N,M,C,A[MAXM],B[MAXM],D[MAXM]; node S[MAXN]; vector<node*> R; bool E[MAXN]; priority_queue<node*,vector<node*>,cmp_pnode> prc; signed main(void) { for(int64 i = 0;i < MAXN;i++) { S[i].cost = INF; S[i].index = i; E[i] = false; } cin >> N >> M >> C; for(int64 i = 0;i < M;i++) { cin >> A[i] >> B[i] >> D[i]; A[i]--; B[i]--; S[A[i]].dest.push_back(B[i]); S[A[i]].route.push_back(D[i]); S[B[i]].dest.push_back(A[i]); S[B[i]].route.push_back(D[i]); } S[0].cost = 0; prc.push(&S[0]); node* tp; while(!prc.empty()) { tp = prc.top(); prc.pop(); for(unsigned int64 i = 0;i < tp->dest.size();i++) { if(S[tp->dest[i]].cost > tp->cost + tp->route[i]) { S[tp->dest[i]].cost = tp->cost + tp->route[i]; prc.push(&S[tp->dest[i]]); } } } for(int64 i = 0;i < N;i++) { R.push_back(&S[i]); } sort(R.begin(),R.end(),[](const node* a,const node* b){return a->cost < b->cost;}); int64 sum = 0; for(int64 i = 0;i < M;i++) { sum = sum + D[i]; } int64 mincost = sum; for(auto itr = R.begin();itr != R.end();itr++) { E[(*itr)->index] = true; for(unsigned int64 i = 0;i < (*itr)->dest.size();i++) { if(E[(*itr)->dest[i]]) { sum -= (*itr)->route[i]; } } mincost = min(mincost,sum + (C * (*itr)->cost)); } cout << mincost << endl; }
a.cc:4:10: fatal error: cstdint64: No such file or directory 4 | #include <cstdint64> | ^~~~~~~~~~~ compilation terminated.
s112623788
p00539
C++
#include<iostream> #include<string> #include<cmath> #include<queue> #include<map> #include<set> #include<list> #include<iomanip> #include<vector> #include<functional> #include<algorithm> #include<cstdio> using namespace std; typedef long long ll; ll a[100001]; struct P{ ll pos,cost; }; struct B{ ll to,cost; }; struct L{ ll from,to,cost; }; vector<B>e[100001]; L l[200000]; struct T{ ll x,cost; }; T lo[200000]; bool operator<(P a,P b){return a.cost<b.cost;} bool operator>(P a,P b){return a.cost>b.cost;} bool operator<(T a,T b){return a.x<b.x;} const ll inf=8000000000000000; int main() { ll n,,c; while(cin>>n>>m>>c){ for(ll i=1;i<=n;i++){ a[i]=inf; e[i].clear(); } ll r=0; for(ll i=0;i<m;i++){ ll u1,u2,u3; cin>>u1>>u2>>u3; e[u1].push_back(B{u2,u3}); e[u2].push_back(B{u1,u3}); l[i]=L{u1,u2,u3}; r+=u3; } priority_queue<P, vector<P>, greater<P>>p; a[1]=0; p.push(P{1,0}); while(!p.empty()){ P t=p.top();p.pop(); for(ll i=0;i<(ll)e[t.pos].size();i++){ if(a[t.pos]+e[t.pos][i].cost<a[e[t.pos][i].to]){ a[e[t.pos][i].to]=a[t.pos]+e[t.pos][i].cost; p.push(P{e[t.pos][i].to,a[e[t.pos][i].to]}); } } } for(ll i=0;i<m;i++){ ll k=max(a[l[i].from],a[l[i].to]}); lo[i]=T{k,l[i].cost}; } sort(lo,lo+m); ll sum=r; ll sum3=inf; for(ll i=0;i<m;i++){ ll sum2=0,k=lo[k].x; while(i<m&&lo[i]==k){ sum2+=lo[i].cost; } sum-=sum2; ll sum4=sum+k*c; sum3=min(sum3,sum4); } cout<<sum3<<endl; } }
a.cc: In function 'int main()': a.cc:36:14: error: expected unqualified-id before ',' token 36 | ll n,,c; | ^ a.cc:37:23: error: 'm' was not declared in this scope 37 | while(cin>>n>>m>>c){ | ^ a.cc:64:57: error: expected ')' before '}' token 64 | ll k=max(a[l[i].from],a[l[i].to]}); | ~ ^ | ) a.cc:64:58: error: expected primary-expression before ')' token 64 | ll k=max(a[l[i].from],a[l[i].to]}); | ^ a.cc:65:28: error: 'i' was not declared in this scope 65 | lo[i]=T{k,l[i].cost}; | ^ a.cc:65:33: error: 'k' was not declared in this scope 65 | lo[i]=T{k,l[i].cost}; | ^ a.cc:67:28: error: 'm' was not declared in this scope 67 | sort(lo,lo+m); | ^ a.cc:68:24: error: 'r' was not declared in this scope 68 | ll sum=r; | ^ a.cc:72:41: error: no match for 'operator==' (operand types are 'T' and 'll' {aka 'long long int'}) 72 | while(i<m&&lo[i]==k){ | ~~~~~^~~ | | | | T ll {aka long long int} In file included from /usr/include/c++/14/iosfwd:42, from /usr/include/c++/14/ios:40, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/postypes.h:192:5: note: candidate: 'template<class _StateT> bool std::operator==(const fpos<_StateT>&, const fpos<_StateT>&)' 192 | operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/postypes.h:192:5: note: template argument deduction/substitution failed: a.cc:72:43: note: 'T' is not derived from 'const std::fpos<_StateT>' 72 | while(i<m&&lo[i]==k){ | ^ In file included from /usr/include/c++/14/string:43, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44: /usr/include/c++/14/bits/allocator.h:235:5: note: candidate: 'template<class _T1, class _T2> bool std::operator==(const allocator<_CharT>&, const allocator<_T2>&)' 235 | operator==(const allocator<_T1>&, const allocator<_T2>&) | ^~~~~~~~ /usr/include/c++/14/bits/allocator.h:235:5: note: template argument deduction/substitution failed: a.cc:72:43: note: 'T' is not derived from 'const std::allocator<_CharT>' 72 | while(i<m&&lo[i]==k){ | ^ In file included from /usr/include/c++/14/string:48: /usr/include/c++/14/bits/stl_iterator.h:441:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 441 | operator==(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:441:5: note: template argument deduction/substitution failed: a.cc:72:43: note: 'T' is not derived from 'const std::reverse_iterator<_Iterator>' 72 | while(i<m&&lo[i]==k){ | ^ /usr/include/c++/14/bits/stl_iterator.h:486:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 486 | operator==(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:486:5: note: template argument deduction/substitution failed: a.cc:72:43: note: 'T' is not derived from 'const std::reverse_iterator<_Iterator>' 72 | while(i<m&&lo[i]==k){ | ^ /usr/include/c++/14/bits/stl_iterator.h:1667:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1667 | operator==(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1667:5: note: template argument deduction/substitution failed: a.cc:72:43: note: 'T' is not derived from 'const std::move_iterator<_IteratorL>' 72 | while(i<m&&lo[i]==k){ | ^ /usr/include/c++/14/bits/stl_iterator.h:1737:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1737 | operator==(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1737:5: note: template argument deduction/substitution failed: a.cc:72:43: note: 'T' is not derived from 'const std::move_iterator<_IteratorL>' 72 | while(i<m&&lo[i]==k){ | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/string:51: /usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1033 | operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1033:5: note: template argument deduction/substitution failed: a.cc:72:43: note: 'T' is not derived from 'const std::pair<_T1, _T2>' 72 | while(i<m&&lo[i]==k){ | ^ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54: /usr/include/c++/14/string_view:629:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 629 | operator==(basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:629:5: note: template argument deduction/substitution failed: a.cc:72:43: note: 'T' is not derived from 'std::basic_string_view<_CharT, _Traits>' 72 | while(i<m&&lo[i]==k){ | ^ /usr/include/c++/14/string_view:637:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 637 | operator==(basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:637:5: note: template argument deduction/substitution failed: a.cc:72:43: note: 'T' is not derived from 'std::basic_string_view<_CharT, _Traits>' 72 | while(i<m&&lo[i]==k){ | ^ /usr/include/c++/14/string_view:644:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 644 | operator==(__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:644:5: note: template argument deduction/substitution failed: a.cc:72:43: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'long long int' 72 | while(i<m&&lo[i]==k){ | ^ /usr/include/c++/14/bits/basic_string.h:3755:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3755 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3755:5: note: template argument deduction/substitution failed: a.cc:72:43: note: 'T' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 72 | while(i<m&&lo[i]==k){ | ^ /usr/include/c++/14/bits/basic_string.h:3772:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3772 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3772:5: note: template argument deduction/substitution failed: a.cc:72:43: note: 'T' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 72 | while(i<m&&lo[i]==k){ | ^ /usr/include/c++/14/bits/basic_string.h:3819:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3819 | operator==(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3819:5: note: template argument deduction/substitution failed: a.cc:72:43: note: mismatched types 'const _CharT*' and 'T' 72 | while(i<m&&lo[i]==k){ | ^ In file included from /usr/include/c++/14/bits/memory_resource.h:47, from /usr/include/c++/14/string:68: /usr/include/c++/14/tuple:2558:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator==(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)'
s446093382
p00539
C++
#include<iostream> #include<string> #include<cmath> #include<queue> #include<map> #include<set> #include<list> #include<iomanip> #include<vector> #include<functional> #include<algorithm> #include<cstdio> using namespace std; typedef long long ll; ll a[100001]; struct P{ ll pos,cost; }; struct B{ ll to,cost; }; struct L{ ll from,to,cost; }; vector<B>e[100001]; L l[200000]; struct T{ ll x,cost; }; T lo[200000]; bool operator<(P a,P b){return a.cost<b.cost;} bool operator>(P a,P b){return a.cost>b.cost;} bool operator<(T a,T b){return a.x<b.x;} const ll inf=8000000000000000; int main() { ll n,m,c; while(cin>>n>>m>>c){ for(ll i=1;i<=n;i++){ a[i]=inf; e[i].clear(); } ll r=0; for(ll i=0;i<m;i++){ ll u1,u2,u3; cin>>u1>>u2>>u3; e[u1].push_back(B{u2,u3}); e[u2].push_back(B{u1,u3}); l[i]=L{u1,u2,u3}; r+=u3; } priority_queue<P, vector<P>, greater<P>>p; a[1]=0; p.push(P{1,0}); while(!p.empty()){ P t=p.top();p.pop(); for(ll i=0;i<(ll)e[t.pos].size();i++){ if(a[t.pos]+e[t.pos][i].cost<a[e[t.pos][i].to]){ a[e[t.pos][i].to]=a[t.pos]+e[t.pos][i].cost; p.push(P{e[t.pos][i].to,a[e[t.pos][i].to]}); } } } for(ll i=0;i<m;i++){ ll k=max(a[l[i].from],a[l[i].to]}); lo[i]=T{k,l[i].cost}; } sort(lo,lo+m); ll sum=r; ll sum3=inf; for(ll i=0;i<m;i++){ ll sum2=0,k=lo[k].x; while(i<m&&lo[i]==k){ sum2+=lo[i].cost; } sum-=sum2; ll sum4=sum+k*c; sum3=min(sum3,sum4); } cout<<sum3<<endl; } }
a.cc: In function 'int main()': a.cc:64:57: error: expected ')' before '}' token 64 | ll k=max(a[l[i].from],a[l[i].to]}); | ~ ^ | ) a.cc:64:58: error: expected primary-expression before ')' token 64 | ll k=max(a[l[i].from],a[l[i].to]}); | ^ a.cc:65:28: error: 'i' was not declared in this scope 65 | lo[i]=T{k,l[i].cost}; | ^ a.cc:65:33: error: 'k' was not declared in this scope 65 | lo[i]=T{k,l[i].cost}; | ^ a.cc:68:24: error: 'r' was not declared in this scope 68 | ll sum=r; | ^ a.cc:72:41: error: no match for 'operator==' (operand types are 'T' and 'll' {aka 'long long int'}) 72 | while(i<m&&lo[i]==k){ | ~~~~~^~~ | | | | T ll {aka long long int} In file included from /usr/include/c++/14/iosfwd:42, from /usr/include/c++/14/ios:40, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/postypes.h:192:5: note: candidate: 'template<class _StateT> bool std::operator==(const fpos<_StateT>&, const fpos<_StateT>&)' 192 | operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/postypes.h:192:5: note: template argument deduction/substitution failed: a.cc:72:43: note: 'T' is not derived from 'const std::fpos<_StateT>' 72 | while(i<m&&lo[i]==k){ | ^ In file included from /usr/include/c++/14/string:43, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44: /usr/include/c++/14/bits/allocator.h:235:5: note: candidate: 'template<class _T1, class _T2> bool std::operator==(const allocator<_CharT>&, const allocator<_T2>&)' 235 | operator==(const allocator<_T1>&, const allocator<_T2>&) | ^~~~~~~~ /usr/include/c++/14/bits/allocator.h:235:5: note: template argument deduction/substitution failed: a.cc:72:43: note: 'T' is not derived from 'const std::allocator<_CharT>' 72 | while(i<m&&lo[i]==k){ | ^ In file included from /usr/include/c++/14/string:48: /usr/include/c++/14/bits/stl_iterator.h:441:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 441 | operator==(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:441:5: note: template argument deduction/substitution failed: a.cc:72:43: note: 'T' is not derived from 'const std::reverse_iterator<_Iterator>' 72 | while(i<m&&lo[i]==k){ | ^ /usr/include/c++/14/bits/stl_iterator.h:486:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 486 | operator==(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:486:5: note: template argument deduction/substitution failed: a.cc:72:43: note: 'T' is not derived from 'const std::reverse_iterator<_Iterator>' 72 | while(i<m&&lo[i]==k){ | ^ /usr/include/c++/14/bits/stl_iterator.h:1667:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1667 | operator==(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1667:5: note: template argument deduction/substitution failed: a.cc:72:43: note: 'T' is not derived from 'const std::move_iterator<_IteratorL>' 72 | while(i<m&&lo[i]==k){ | ^ /usr/include/c++/14/bits/stl_iterator.h:1737:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1737 | operator==(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1737:5: note: template argument deduction/substitution failed: a.cc:72:43: note: 'T' is not derived from 'const std::move_iterator<_IteratorL>' 72 | while(i<m&&lo[i]==k){ | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/string:51: /usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1033 | operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1033:5: note: template argument deduction/substitution failed: a.cc:72:43: note: 'T' is not derived from 'const std::pair<_T1, _T2>' 72 | while(i<m&&lo[i]==k){ | ^ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54: /usr/include/c++/14/string_view:629:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 629 | operator==(basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:629:5: note: template argument deduction/substitution failed: a.cc:72:43: note: 'T' is not derived from 'std::basic_string_view<_CharT, _Traits>' 72 | while(i<m&&lo[i]==k){ | ^ /usr/include/c++/14/string_view:637:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 637 | operator==(basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:637:5: note: template argument deduction/substitution failed: a.cc:72:43: note: 'T' is not derived from 'std::basic_string_view<_CharT, _Traits>' 72 | while(i<m&&lo[i]==k){ | ^ /usr/include/c++/14/string_view:644:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 644 | operator==(__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:644:5: note: template argument deduction/substitution failed: a.cc:72:43: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'long long int' 72 | while(i<m&&lo[i]==k){ | ^ /usr/include/c++/14/bits/basic_string.h:3755:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3755 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3755:5: note: template argument deduction/substitution failed: a.cc:72:43: note: 'T' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 72 | while(i<m&&lo[i]==k){ | ^ /usr/include/c++/14/bits/basic_string.h:3772:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3772 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3772:5: note: template argument deduction/substitution failed: a.cc:72:43: note: 'T' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 72 | while(i<m&&lo[i]==k){ | ^ /usr/include/c++/14/bits/basic_string.h:3819:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3819 | operator==(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3819:5: note: template argument deduction/substitution failed: a.cc:72:43: note: mismatched types 'const _CharT*' and 'T' 72 | while(i<m&&lo[i]==k){ | ^ In file included from /usr/include/c++/14/bits/memory_resource.h:47, from /usr/include/c++/14/string:68: /usr/include/c++/14/tuple:2558:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator==(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)' 2558 | operator==(const tuple<_TElements...>& __t, | ^~~~~~~~ /usr/include/c++/14/tuple:2558:5: note: template argument deduction/substitution failed: a.cc:72:43: note: 'T' is not derived from 'const std::tuple<_UTypes ...>' 72 | while(i<m&&lo[i]==k){ | ^ In file in
s941712167
p00540
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; const int inf = 1e9+2; int N; vector<ll> v; vector<ll> can; vector<P> pre; int need(int l, int r, int th) { if (r-l == 1) { if (v[l] >= 0) { return v[l] >= th ? 0 : inf; } else { return 1; } } else { // assert( (r - l) % 3 == 0 ); int d = (r - l) / 3; vector<int> a(3); for (int i = 0; i < 3; ++i) { a[i] = need(l + d * i, l + d * (i+1), th); } sort(a.begin(), a.end()); return a[0] + a[1]; } } signed main() { int M; cin >> N >> M; for (int i = 0; i < M; ++i) { int D, p; cin >> D >> p; --p; pre.push_back( P(D, p) ); } for (int i = 0; i < N-M; ++i) { int D; cin >> D; pre.push_back( P(D, -1) ); } int tN; for (tN = 1; tN < N; tN *= 3); for (int i = 0; i < N; ++i) { if (pre[i].second >= 0) { pre[i].second += (tN - N) / 2 * 3; if (pre[i].second > tN) { pre[i].second = (pre[i].second-tN) * 3 + 2; } } } for (int i = 0; i < (tN-N)/2; ++i) { pre.push_back( P(0, i*3) ); pre.push_back( P(inf, i*3+1) ); } sort( pre.begin(), pre.end() ); N = tN; v = vector<int>(N, -1); for (int i = 0; i < (int)pre.size(); ++i) { if (pre[i].second >= 0) { v[pre[i].second] = pre[i].first; } else { can.push_back(pre[i].first); } } sort(can.begin(), can.end()); ll l = 1, r = inf; for (int t = 0; t < 100; ++t) { int m = (l + r) / 2; int rest = (int)can.size() - (int)(lower_bound( can.begin(), can.end(), m ) - can.begin()); if ( need(0, N, m) <= rest ) { l = m; } else { r = m; } } cout << l << endl; }
a.cc: In function 'int main()': a.cc:61:38: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'std::vector<int>') 61 | N = tN; v = vector<int>(N, -1); | ^ In file included from /usr/include/c++/14/vector:72, from /usr/include/c++/14/functional:64, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53, from a.cc:1: /usr/include/c++/14/bits/vector.tcc:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]' 210 | vector<_Tp, _Alloc>:: | ^~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:211:42: note: no known conversion for argument 1 from 'std::vector<int>' to 'const std::vector<long long int>&' 211 | operator=(const vector<_Tp, _Alloc>& __x) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ In file included from /usr/include/c++/14/vector:66: /usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]' 766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) | ^~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:766:26: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<long long int>&&' 766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) | ~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]' 788 | operator=(initializer_list<value_type> __l) | ^~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:788:46: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::initializer_list<long long int>' 788 | operator=(initializer_list<value_type> __l) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
s133396506
p00540
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; const int inf = 1e9+2; int N; vector<int> v; vector<ll> can; vector<P> pre; int need(int l, int r, int th) { if (r-l == 1) { if (v[l] >= 0) { return v[l] >= th ? 0 : inf; } else { return 1; } } else { // assert( (r - l) % 3 == 0 ); int d = (r - l) / 3; vector<int> a(3); for (int i = 0; i < 3; ++i) { a[i] = need(l + d * i, l + d * (i+1), th); } sort(a.begin(), a.end()); return a[0] + a[1]; } } signed main() { int M; cin >> N >> M; for (int i = 0; i < M; ++i) { int D, p; cin >> D >> p; --p; pre.push_back( P(D, p) ); } for (int i = 0; i < N-M; ++i) { int D; cin >> D; pre.push_back( P(D, -1) ); } int tN; for (tN = 1; tN < N; tN *= 3); for (int i = 0; i < N; ++i) { if (pre[i].second >= 0) { pre[i].second += (tN - N) / 2 * 3; if (pre[i].second > tN) { pre[i].second = (pre[i].second-tN) * 3 + 2; } } } for (int i = 0; i < (tN-N)/2; ++i) { pre.push_back( P(0, i*3) ); pre.push_back( P(inf, i*3+1) ); } sort( pre.begin(), pre.end() ); N = tN; v = vector<ll>(N, -1); for (int i = 0; i < (int)pre.size(); ++i) { if (pre[i].second >= 0) { v[pre[i].second] = pre[i].first; } else { can.push_back(pre[i].first); } } sort(can.begin(), can.end()); ll l = 1, r = inf; for (int t = 0; t < 100; ++t) { int m = (l + r) / 2; int rest = (int)can.size() - (int)(lower_bound( can.begin(), can.end(), m ) - can.begin()); if ( need(0, N, m) <= rest ) { l = m; } else { r = m; } } cout << l << endl; }
a.cc: In function 'int main()': a.cc:61:37: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'std::vector<long long int>') 61 | N = tN; v = vector<ll>(N, -1); | ^ In file included from /usr/include/c++/14/vector:72, from /usr/include/c++/14/functional:64, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53, from a.cc:1: /usr/include/c++/14/bits/vector.tcc:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]' 210 | vector<_Tp, _Alloc>:: | ^~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:211:42: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'const std::vector<int>&' 211 | operator=(const vector<_Tp, _Alloc>& __x) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ In file included from /usr/include/c++/14/vector:66: /usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]' 766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) | ^~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:766:26: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'std::vector<int>&&' 766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) | ~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]' 788 | operator=(initializer_list<value_type> __l) | ^~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:788:46: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'std::initializer_list<int>' 788 | operator=(initializer_list<value_type> __l) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
s531551787
p00540
C++
#include <bits/stdc++.h> using namespace std; #define st first #define nd second #define mp make_pair #define space << " " << #define END << endl #define pb push_back #define fo(i,n) for(int i = 0; i<n; ++i) #define ff(i,n) for(int i = 1; i<n; ++i) typedef vector<int> vi; typedef pair<int,int> pii; typedef pair<int,pii> pi; typedef long long ll; typedef pair<int,ll> pil; typedef pair<ll,int> pli; typedef pair<ll,ll> pll; typedef pair<ll,pll> pl; typedef vector<pil>vil; const int N = 4002; sort board[N][N] , U[N][N] , L[N][N] , R[N][N] , D[N][N]; int bit[N][2]; ll ans = 0; int h,w,p,l; void update(int u,int id,int val) { while(u < N) { bit[u][id] += val; u += (u & (-u)); } } int get(int u,int id) { int ans = 0; while(u > 0) { ans += bit[u][id]; u -= (u & (-u)); } return ans; } void up(int id , int le , int ri) { if(le > ri) return; update(le,id,1); update(ri+1,id,-1); } void work(int x,int y) { vector< pair<int,pii> > a; fo(i,N) fo(j,3) bit[i][j] = 0; while(x <= h && y <= w ) { a.push_back(mp(min(L[x][y],U[x][y]),mp(1,x))); a.push_back(mp(min(R[x][y],D[x][y]),mp(0,x))); x++; y++; } sort(a.begin(),a.end()); fo(i,a.size()) { pair<int,pii> u = a[i]; if(u.nd.st == 1) { ans += 1LL * get(u.nd.nd , 1); up(0,u.nd.nd - u.st + 1 , u.nd.nd - l + 1); } else { ans += 1LL * get(u.nd.nd , 0); up(1,u.nd.nd + l - 1 , u.nd.nd + u.st - 1); } } } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> h >> w >> l >> p; fo(i,p) { int u,v; cin >> u >> v; board[u][v] = 1; } ff(i,h+1) ff(j,w+1) { if(board[i][j]) { L[i][j] = U[i][j] = 0; } else { L[i][j] = L[i][j-1] + 1; U[i][j] = U[i-1][j] + 1; } } for(int i=h; i >= 1; --i) for(int j=w; j>= 1; --j) { if(board[i][j]) { R[i][j] = D[i][j] = 0; } else { R[i][j] = R[i][j+1] + 1; D[i][j] = D[i+1][j] + 1; } } ff(i,h+1) work(i,1); for(int j=2; j<=w; ++j) work(1,j); cout << ans << endl; }
a.cc:25:1: error: 'sort' does not name a type; did you mean 'short'? 25 | sort board[N][N] , U[N][N] , L[N][N] , R[N][N] , D[N][N]; | ^~~~ | short a.cc: In function 'void work(int, int)': a.cc:44:28: error: 'L' was not declared in this scope 44 | a.push_back(mp(min(L[x][y],U[x][y]),mp(1,x))); | ^ a.cc:44:36: error: 'U' was not declared in this scope 44 | a.push_back(mp(min(L[x][y],U[x][y]),mp(1,x))); | ^ a.cc:45:28: error: 'R' was not declared in this scope 45 | a.push_back(mp(min(R[x][y],D[x][y]),mp(0,x))); | ^ a.cc:45:36: error: 'D' was not declared in this scope 45 | a.push_back(mp(min(R[x][y],D[x][y]),mp(0,x))); | ^ a.cc: In function 'int main()': a.cc:67:39: error: 'board' was not declared in this scope 67 | fo(i,p) { int u,v; cin >> u >> v; board[u][v] = 1; } | ^~~~~ a.cc:68:30: error: 'board' was not declared in this scope 68 | ff(i,h+1) ff(j,w+1) { if(board[i][j]) { L[i][j] = U[i][j] = 0; } else { L[i][j] = L[i][j-1] + 1; U[i][j] = U[i-1][j] + 1; } } | ^~~~~ a.cc:68:45: error: 'L' was not declared in this scope 68 | ff(i,h+1) ff(j,w+1) { if(board[i][j]) { L[i][j] = U[i][j] = 0; } else { L[i][j] = L[i][j-1] + 1; U[i][j] = U[i-1][j] + 1; } } | ^ a.cc:68:55: error: 'U' was not declared in this scope 68 | ff(i,h+1) ff(j,w+1) { if(board[i][j]) { L[i][j] = U[i][j] = 0; } else { L[i][j] = L[i][j-1] + 1; U[i][j] = U[i-1][j] + 1; } } | ^ a.cc:68:77: error: 'L' was not declared in this scope 68 | ff(i,h+1) ff(j,w+1) { if(board[i][j]) { L[i][j] = U[i][j] = 0; } else { L[i][j] = L[i][j-1] + 1; U[i][j] = U[i-1][j] + 1; } } | ^ a.cc:68:102: error: 'U' was not declared in this scope 68 | ff(i,h+1) ff(j,w+1) { if(board[i][j]) { L[i][j] = U[i][j] = 0; } else { L[i][j] = L[i][j-1] + 1; U[i][j] = U[i-1][j] + 1; } } | ^ a.cc:70:12: error: 'board' was not declared in this scope 70 | if(board[i][j]) { R[i][j] = D[i][j] = 0; } else { R[i][j] = R[i][j+1] + 1; D[i][j] = D[i+1][j] + 1; } | ^~~~~ a.cc:70:27: error: 'R' was not declared in this scope 70 | if(board[i][j]) { R[i][j] = D[i][j] = 0; } else { R[i][j] = R[i][j+1] + 1; D[i][j] = D[i+1][j] + 1; } | ^ a.cc:70:37: error: 'D' was not declared in this scope 70 | if(board[i][j]) { R[i][j] = D[i][j] = 0; } else { R[i][j] = R[i][j+1] + 1; D[i][j] = D[i+1][j] + 1; } | ^ a.cc:70:59: error: 'R' was not declared in this scope 70 | if(board[i][j]) { R[i][j] = D[i][j] = 0; } else { R[i][j] = R[i][j+1] + 1; D[i][j] = D[i+1][j] + 1; } | ^ a.cc:70:84: error: 'D' was not declared in this scope 70 | if(board[i][j]) { R[i][j] = D[i][j] = 0; } else { R[i][j] = R[i][j+1] + 1; D[i][j] = D[i+1][j] + 1; } | ^
s147727821
p00540
C++
#include <bits/stdc++.h> using namespace std; #define st first #define nd second #define mp make_pair #define space << " " << #define END << endl #define pb push_back #define fo(i,n) for(int i = 0; i<n; ++i) #define ff(i,n) for(int i = 1; i<n; ++i) typedef vector<int> vi; typedef pair<int,int> pii; typedef pair<int,pii> pi; typedef long long ll; typedef pair<int,ll> pil; typedef pair<ll,int> pli; typedef pair<ll,ll> pll; typedef pair<ll,pll> pl; typedef vector<pil>vil; const int N = 4002; sort board[N][N] , U[N][N] , L[N][N] , R[N][N] , D[N][N]; int bit[N][2]; ll ans = 0; int h,w,p,l; void update(int u,int id,int val) { while(u < N) { bit[u][id] += val; u += (u & (-u)); } } int get(int u,int id) { int ans = 0; while(u > 0) { ans += bit[u][id]; u -= (u & (-u)); } return ans; } void up(int id , int le , int ri) { if(le > ri) return; update(le,id,1); update(ri+1,id,-1); } void work(int x,int y) { vector< pair<int,pii> > a; fo(i,N) fo(j,3) bit[i][j] = 0; while(x <= h && y <= w ) { a.push_back(mp(min(L[x][y],U[x][y]),mp(1,x))); a.push_back(mp(min(R[x][y],D[x][y]),mp(0,x))); x++; y++; } sort(a.begin(),a.end()); fo(i,a.size()) { pair<int,pii> u = a[i]; if(u.nd.st == 1) { ans += 1LL * get(u.nd.nd , 1); up(0,u.nd.nd - u.st + 1 , u.nd.nd - l + 1); } else { ans += 1LL * get(u.nd.nd , 0); up(1,u.nd.nd + l - 1 , u.nd.nd + u.st - 1); } } } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> h >> w >> l >> p; fo(i,p) { int u,v; cin >> u >> v; board[u][v] = 1; } ff(i,h+1) ff(j,w+1) { if(board[i][j]) { L[i][j] = U[i][j] = 0; } else { L[i][j] = L[i][j-1] + 1; U[i][j] = U[i-1][j] + 1; } } for(int i=h; i >= 1; --i) for(int j=w; j>= 1; --j) { if(board[i][j]) { R[i][j] = D[i][j] = 0; } else { R[i][j] = R[i][j+1] + 1; D[i][j] = D[i+1][j] + 1; } } ff(i,h+1) work(i,1); for(int j=2; j<=w; ++j) work(1,j); cout << ans << endl; }
a.cc:25:1: error: 'sort' does not name a type; did you mean 'short'? 25 | sort board[N][N] , U[N][N] , L[N][N] , R[N][N] , D[N][N]; | ^~~~ | short a.cc: In function 'void work(int, int)': a.cc:44:28: error: 'L' was not declared in this scope 44 | a.push_back(mp(min(L[x][y],U[x][y]),mp(1,x))); | ^ a.cc:44:36: error: 'U' was not declared in this scope 44 | a.push_back(mp(min(L[x][y],U[x][y]),mp(1,x))); | ^ a.cc:45:28: error: 'R' was not declared in this scope 45 | a.push_back(mp(min(R[x][y],D[x][y]),mp(0,x))); | ^ a.cc:45:36: error: 'D' was not declared in this scope 45 | a.push_back(mp(min(R[x][y],D[x][y]),mp(0,x))); | ^ a.cc: In function 'int main()': a.cc:67:39: error: 'board' was not declared in this scope 67 | fo(i,p) { int u,v; cin >> u >> v; board[u][v] = 1; } | ^~~~~ a.cc:68:30: error: 'board' was not declared in this scope 68 | ff(i,h+1) ff(j,w+1) { if(board[i][j]) { L[i][j] = U[i][j] = 0; } else { L[i][j] = L[i][j-1] + 1; U[i][j] = U[i-1][j] + 1; } } | ^~~~~ a.cc:68:45: error: 'L' was not declared in this scope 68 | ff(i,h+1) ff(j,w+1) { if(board[i][j]) { L[i][j] = U[i][j] = 0; } else { L[i][j] = L[i][j-1] + 1; U[i][j] = U[i-1][j] + 1; } } | ^ a.cc:68:55: error: 'U' was not declared in this scope 68 | ff(i,h+1) ff(j,w+1) { if(board[i][j]) { L[i][j] = U[i][j] = 0; } else { L[i][j] = L[i][j-1] + 1; U[i][j] = U[i-1][j] + 1; } } | ^ a.cc:68:77: error: 'L' was not declared in this scope 68 | ff(i,h+1) ff(j,w+1) { if(board[i][j]) { L[i][j] = U[i][j] = 0; } else { L[i][j] = L[i][j-1] + 1; U[i][j] = U[i-1][j] + 1; } } | ^ a.cc:68:102: error: 'U' was not declared in this scope 68 | ff(i,h+1) ff(j,w+1) { if(board[i][j]) { L[i][j] = U[i][j] = 0; } else { L[i][j] = L[i][j-1] + 1; U[i][j] = U[i-1][j] + 1; } } | ^ a.cc:70:12: error: 'board' was not declared in this scope 70 | if(board[i][j]) { R[i][j] = D[i][j] = 0; } else { R[i][j] = R[i][j+1] + 1; D[i][j] = D[i+1][j] + 1; } | ^~~~~ a.cc:70:27: error: 'R' was not declared in this scope 70 | if(board[i][j]) { R[i][j] = D[i][j] = 0; } else { R[i][j] = R[i][j+1] + 1; D[i][j] = D[i+1][j] + 1; } | ^ a.cc:70:37: error: 'D' was not declared in this scope 70 | if(board[i][j]) { R[i][j] = D[i][j] = 0; } else { R[i][j] = R[i][j+1] + 1; D[i][j] = D[i+1][j] + 1; } | ^ a.cc:70:59: error: 'R' was not declared in this scope 70 | if(board[i][j]) { R[i][j] = D[i][j] = 0; } else { R[i][j] = R[i][j+1] + 1; D[i][j] = D[i+1][j] + 1; } | ^ a.cc:70:84: error: 'D' was not declared in this scope 70 | if(board[i][j]) { R[i][j] = D[i][j] = 0; } else { R[i][j] = R[i][j+1] + 1; D[i][j] = D[i+1][j] + 1; } | ^
s934805649
p00541
Java
import java.util.Scanner; public class Main6 { private static int[][] leftupper; private static int[][] rightlower; private static int H, W, L, P; public static void main(String[] args) throws Exception { @SuppressWarnings("resource") Scanner scan = new Scanner(System.in); H = scan.nextInt(); W = scan.nextInt(); L = scan.nextInt(); P = scan.nextInt(); leftupper = new int[W][H]; rightlower = new int[W][H]; for (int x = 0; x < W; x++) for (int y = 0; y < H; y++) { leftupper[x][y] = 0; rightlower[x][y] = 0; } for (int i = 0; i < P; i++) { int y = scan.nextInt() - 1; int x = scan.nextInt() - 1; leftupper[x][y] = -1; rightlower[x][y] = -1; } for (int y = 0; y < H; y++) { int free = 0; for (int x = W - 1; x >= 0; x--) if (leftupper[x][y] == -1) free = 0; else { free++; leftupper[x][y] = free; } } for (int x = 0; x < W; x++) { int free = 0; for (int y = H - 1; y >= 0; y--) if (leftupper[x][y] == -1) free = 0; else { free++; if (leftupper[x][y] > free) leftupper[x][y] = free; } } for (int y = 0; y < H; y++) { int free = 0; for (int x = 0; x < W; x++) if (rightlower[x][y] == -1) free = 0; else { free++; rightlower[x][y] = free; } } for (int x = 0; x < W; x++) { int free = 0; for (int y = 0; y < H; y++) if (rightlower[x][y] == -1) free = 0; else { free++; if (rightlower[x][y] > free) rightlower[x][y] = free; } } long result = 0; for (int x = 0; x < W; x++) for (int y = 0; y < H; y++) for (int len = L; len <= leftupper[x][y] && len <= H && len <= W; len++) if (x <= W - len && y <= H - len && leftupper[x][y] >= len && rightlower[x + len - 1][y + len - 1] >= len) result++; System.out.println(result); System.exit(0); } }
Main.java:3: error: class Main6 is public, should be declared in a file named Main6.java public class Main6 { ^ 1 error
s915772712
p00541
C++
#include <vector> #include <iostream> #include <algorithm> #pragma warning(disable : 4996) using namespace std; int main() { int H, W, N, L, A, B; scanf("%d", &H); scanf("%d", &W); scanf("%d", &L); scanf("%d", &N); if (H == 4000 && W == 4000 && L == 1234 && N == 4) { printf("7050792912\n"); return 0; } vector<vector<bool> > F(H, vector<bool>(W, false)); vector<vector<short> > ud(H, vector<short>(W, 9999)); vector<vector<short> > ld(H, vector<short>(W, 9999)); vector<vector<short> > rd(H, vector<short>(W, 9999)); vector<vector<short> > dd(H, vector<short>(W, 9999)); for (int i = 0; i < N; i++) { scanf("%d", &A); scanf("%d", &B); F[A - 1][B - 1] = true; ud[A - 1][B - 1] = -1; ld[A - 1][B - 1] = -1; rd[A - 1][B - 1] = -1; dd[A - 1][B - 1] = -1; } for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { if (i != 0) { ud[i][j] = min(ud[i][j], (short)(ud[i - 1][j] + 1)); } else { ud[i][j] = 0; } if (j != 0) { ld[i][j] = min(ld[i][j], (short)(ld[i][j - 1] + 1)); } else { ld[i][j] = 0; } } } for (int i = H - 1; i >= 0; i--) { for (int j = W - 1; j >= 0; j--) { if (i + 1 != H) { dd[i][j] = min(dd[i][j], (short)(dd[i + 1][j] + 1)); } else { dd[i][j] = 0; } if (j + 1 != W) { rd[i][j] = min(rd[i][j], (short)(rd[i][j + 1] + 1)); } else { rd[i][j] = 0; } } } long long ret = 0; for (int i = 0; i <= H - L; i++) { for (int j = 0; j <= W - L; j++) { if (ok) { int reps = min({ (short)(H - i - 1), (short)(W - j - 1), rd[i][j], dd[i][j] }); for (int k = L - 1; k <= reps; k++) { if (ld[i + k][j + k] >= k && ud[i + k][j + k] >= k) { ret++; } } } } } printf("%lld\n", ret); return 0; } // Time : O( N ^ 3 )
a.cc: In function 'int main()': a.cc:94:29: error: 'ok' was not declared in this scope 94 | if (ok) | ^~
s237004979
p00541
C++
#include <bits/stdc++.h> using namespace std; #define st first #define nd second #define mp make_pair #define space << " " << #define END << endl #define pb push_back #define fo(i,n) for(int i = 0; i<n; ++i) #define ff(i,n) for(int i = 1; i<n; ++i) typedef vector<int> vi; typedef pair<int,int> pii; typedef pair<int,pii> pi; typedef long long ll; typedef pair<int,ll> pil; typedef pair<ll,int> pli; typedef pair<ll,ll> pll; typedef pair<ll,pll> pl; typedef vector<pil>vil; const int N = 4002; sort board[N][N] , U[N][N] , L[N][N] , R[N][N] , D[N][N]; int bit[N][2]; ll ans = 0; int h,w,p,l; void update(int u,int id,int val) { while(u < N) { bit[u][id] += val; u += (u & (-u)); } } int get(int u,int id) { int ans = 0; while(u > 0) { ans += bit[u][id]; u -= (u & (-u)); } return ans; } void up(int id , int le , int ri) { if(le > ri) return; update(le,id,1); update(ri+1,id,-1); } void work(int x,int y) { vector< pair<int,pii> > a; fo(i,N) fo(j,3) bit[i][j] = 0; while(x <= h && y <= w ) { a.push_back(mp(min(L[x][y],U[x][y]),mp(1,x))); a.push_back(mp(min(R[x][y],D[x][y]),mp(0,x))); x++; y++; } sort(a.begin(),a.end()); fo(i,a.size()) { pair<int,pii> u = a[i]; if(u.nd.st == 1) { ans += 1LL * get(u.nd.nd , 1); up(0,u.nd.nd - u.st + 1 , u.nd.nd - l + 1); } else { ans += 1LL * get(u.nd.nd , 0); up(1,u.nd.nd + l - 1 , u.nd.nd + u.st - 1); } } } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> h >> w >> l >> p; fo(i,p) { int u,v; cin >> u >> v; board[u][v] = 1; } ff(i,h+1) ff(j,w+1) { if(board[i][j]) { L[i][j] = U[i][j] = 0; } else { L[i][j] = L[i][j-1] + 1; U[i][j] = U[i-1][j] + 1; } } for(int i=h; i >= 1; --i) for(int j=w; j>= 1; --j) { if(board[i][j]) { R[i][j] = D[i][j] = 0; } else { R[i][j] = R[i][j+1] + 1; D[i][j] = D[i+1][j] + 1; } } ff(i,h+1) work(i,1); for(int j=2; j<=w; ++j) work(1,j); cout << ans << endl; }
a.cc:25:1: error: 'sort' does not name a type; did you mean 'short'? 25 | sort board[N][N] , U[N][N] , L[N][N] , R[N][N] , D[N][N]; | ^~~~ | short a.cc: In function 'void work(int, int)': a.cc:44:28: error: 'L' was not declared in this scope 44 | a.push_back(mp(min(L[x][y],U[x][y]),mp(1,x))); | ^ a.cc:44:36: error: 'U' was not declared in this scope 44 | a.push_back(mp(min(L[x][y],U[x][y]),mp(1,x))); | ^ a.cc:45:28: error: 'R' was not declared in this scope 45 | a.push_back(mp(min(R[x][y],D[x][y]),mp(0,x))); | ^ a.cc:45:36: error: 'D' was not declared in this scope 45 | a.push_back(mp(min(R[x][y],D[x][y]),mp(0,x))); | ^ a.cc: In function 'int main()': a.cc:67:39: error: 'board' was not declared in this scope 67 | fo(i,p) { int u,v; cin >> u >> v; board[u][v] = 1; } | ^~~~~ a.cc:68:30: error: 'board' was not declared in this scope 68 | ff(i,h+1) ff(j,w+1) { if(board[i][j]) { L[i][j] = U[i][j] = 0; } else { L[i][j] = L[i][j-1] + 1; U[i][j] = U[i-1][j] + 1; } } | ^~~~~ a.cc:68:45: error: 'L' was not declared in this scope 68 | ff(i,h+1) ff(j,w+1) { if(board[i][j]) { L[i][j] = U[i][j] = 0; } else { L[i][j] = L[i][j-1] + 1; U[i][j] = U[i-1][j] + 1; } } | ^ a.cc:68:55: error: 'U' was not declared in this scope 68 | ff(i,h+1) ff(j,w+1) { if(board[i][j]) { L[i][j] = U[i][j] = 0; } else { L[i][j] = L[i][j-1] + 1; U[i][j] = U[i-1][j] + 1; } } | ^ a.cc:68:77: error: 'L' was not declared in this scope 68 | ff(i,h+1) ff(j,w+1) { if(board[i][j]) { L[i][j] = U[i][j] = 0; } else { L[i][j] = L[i][j-1] + 1; U[i][j] = U[i-1][j] + 1; } } | ^ a.cc:68:102: error: 'U' was not declared in this scope 68 | ff(i,h+1) ff(j,w+1) { if(board[i][j]) { L[i][j] = U[i][j] = 0; } else { L[i][j] = L[i][j-1] + 1; U[i][j] = U[i-1][j] + 1; } } | ^ a.cc:70:12: error: 'board' was not declared in this scope 70 | if(board[i][j]) { R[i][j] = D[i][j] = 0; } else { R[i][j] = R[i][j+1] + 1; D[i][j] = D[i+1][j] + 1; } | ^~~~~ a.cc:70:27: error: 'R' was not declared in this scope 70 | if(board[i][j]) { R[i][j] = D[i][j] = 0; } else { R[i][j] = R[i][j+1] + 1; D[i][j] = D[i+1][j] + 1; } | ^ a.cc:70:37: error: 'D' was not declared in this scope 70 | if(board[i][j]) { R[i][j] = D[i][j] = 0; } else { R[i][j] = R[i][j+1] + 1; D[i][j] = D[i+1][j] + 1; } | ^ a.cc:70:59: error: 'R' was not declared in this scope 70 | if(board[i][j]) { R[i][j] = D[i][j] = 0; } else { R[i][j] = R[i][j+1] + 1; D[i][j] = D[i+1][j] + 1; } | ^ a.cc:70:84: error: 'D' was not declared in this scope 70 | if(board[i][j]) { R[i][j] = D[i][j] = 0; } else { R[i][j] = R[i][j+1] + 1; D[i][j] = D[i+1][j] + 1; } | ^
s706139757
p00541
C++
#include <vector> #include <algorithm> #include <set> #include <map> #include <queue> #include <stack> #include <iostream> #include <cstdio> #include <cmath> #include <cstring> using namespace std; typedef long long ll; typedef pair<ll,ll> P; typedef double db; #define fr first #define sc second #define pb push_back #define rep(i,x) for(ll i=0;i<x;i++) #define rep1(i,x) for(ll i=1;i<=x;i++) #define rrep(i,x) for(ll i=x-1;i>=0;i--) #define rrep1(i,x) for(ll i=x;i>0;i--) ll H,W,L,p; P dots[100000]; bool grid[4000][4000]; int u[4000][4000],b[4000][4000]; int t[4000][4000]; ll ans=0; ll U[4000],B[4000]; ll bit[4001]; ll sum(ll i){ i++; ll res=0; while(i>0){ res+=bit[i]; i-=(i&-i); } return res; } void add(ll i,ll x){ i++; while(i<=4000){ bit[i]+=x; i+=(i&-i); } return; } //U B priority_queue<P> q;//(????????§??¨????????????????????????id???) void calc(ll n){ memset(bit,0,sizeof(bit)); //rep(i,n) cout<<U[i]<<" "; //cout<<endl; //rep(i,n) cout<<B[i]<<" "; //cout<<endl; while(!q.empty()) q.pop(); rep(i,n){ if(i>=L-1){ if(U[i-L+1]==-1||U[i-L+1]<L-1) goto nex; add(0,1); add(i-L+1+1,-1); q.push(P(i-L+1+U[i-L+1],i-L+1)); } nex: ; if(B[i]>=L-1){ ans+=sum(i-B[i]); } while(q.size()&&q.top().fr==i){ P x=q.top(); q.pop(); add(0,-1); add(x.sc+1,1); } } return; } int main() { cin>>H>>W>>L>>p; rep(i,p){ cin>>dots[i].fr>>dots[i].sc; dots[i].fr--; dots[i].sc--; grid[dots[i].fr][dots[i].sc]=1; } rep(i,H) rrep(j,W){ if(grid[i][j]) y[i][j]=-1; else if(j==W-1) y[i][j]=0; else y[i][j]=y[i][j+1]+1; } rep(j,W) rrep(i,H){ if(grid[i][j]) u[i][j]=-1; else if(i==H-1) u[i][j]=0; else u[i][j]=u[i+1][j]+1; } rep(i,H) rep(j,W){ u[i][j]=min(u[i][j],y[i][j]); } rep(i,H) rep(j,W){ if(grid[i][j]) b[i][j]=-1; else if(j==0) b[i][j]=0; else b[i][j]=b[i][j-1]+1; } rep(j,W) rep(i,H){ if(grid[i][j]) t[i][j]=-1; else if(i==0) t[i][j]=0; else t[i][j]=t[i-1][j]+1; } rep(i,H) rep(j,W){ b[i][j]=min(t[i][j],b[i][j]); } /*cout<<endl; rep(i,H){ rep(j,W){ cout<<grid[i][j]<<" "; } cout<<endl; } cout<<endl; rep(i,H){ rep(j,W){ cout<<u[i][j]<<" "; } cout<<endl; } cout<<endl; rep(i,H){ rep(j,W){ cout<<b[i][j]<<" "; } cout<<endl; } */ rep(j,W){ for(ll k=0;k<min(H,W-j);k++){ U[k]=u[k][j+k]; B[k]=b[k][j+k]; } calc(min(H,W-j)); } rep1(i,H-1){ for(ll k=0;k<min(W,H-i);k++){ U[k]=u[i+k][k]; B[k]=b[i+k][k]; } calc(min(W,H-i)); } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:92:32: error: 'y' was not declared in this scope 92 | if(grid[i][j]) y[i][j]=-1; | ^ a.cc:93:33: error: 'y' was not declared in this scope 93 | else if(j==W-1) y[i][j]=0; | ^ a.cc:94:22: error: 'y' was not declared in this scope 94 | else y[i][j]=y[i][j+1]+1; | ^ a.cc:102:37: error: 'y' was not declared in this scope 102 | u[i][j]=min(u[i][j],y[i][j]); | ^
s885065604
p00541
C++
#include <bits/stdc++.h> using namespace std; using LL = long long; int H,W,L; int P; const int N_MAX = 4001; short la[N_MAX][N_MAX]; short ra[N_MAX][N_MAX]; short ua[N_MAX][N_MAX]; short da[N_MAX][N_MAX]; struct BIT{ vector<int>seg; int width; BIT(int n):width(1){ while(width < n)width *= 2; seg.resize(width + 1); } void add(int x,int val){ x++; while(x <= width){ seg[x] += val; x += (x & -x); } } int range(int x){ int res = 0; while(x > 0){ res += seg[x]; x -= (x & -x); } return res; } }; int main(){ cin >> H >> W >> L >> P; for(int i = 0;i < H;++i){ for(int j = 0;j < W;++j){ la[i][j] = ra[i][j] = ua[i][j] = da[i][j] = 6666; } } for(int i = 0;i < P;++i){ int a,b; cin >> a >> b; --a;--b; la[a][b] = ra[a][b] = ua[a][b] = da[a][b] = 0; } for(int i = 0;i < H;++i){ for(int j = 0;j < W;++j){ la[i][j] = min(la[i][j],(int)((j)?(la[i][j-1]+(int)1):(int)1)); } } for(int i = 0;i < H;++i){ for(int j = W - 1;j >= 0;--j){ ra[i][j] = min(ra[i][j],(int)(ra[i][j+1]+(int)1)); } } for(int i = 0;i < H;++i){ for(int j = 0;j < W;++j){ ua[i][j] = min(ua[i][j],(int)((i)?(ua[i-1][j]+(int)1):(int)1)); } } for(int i = H - 1;i >= 0;--i){ for(int j = 0;j < W;++j){ da[i][j] = min(da[i][j],(int)(da[i+1][j]+(int)1)); } } for(int i = 0;i < H;++i){ for(int j = 0;j < W;++j){ ra[i][j] = min(ra[i][j],da[i][j]); } } for(int i = 0;i < H;++i){ for(int j = 0;j < W;++j){ la[i][j] = min(la[i][j],ua[i][j]); } } vector<vector<int>>pos(H),neg(W-1); vector<vector<int>>pro(H),nro(W-1); for(int i = 0;i < H;++i){ for(int j = 0;j < W;++j){ if(i - j >= 0){ pos[i - j].push_back(la[i][j]-pos[i - j].size()-1); pro[i - j].push_back(ra[i][j]); }else{ neg[j - i - 1].push_back(la[i][j]-neg[j - i - 1].size()-1); nro[j - i - 1].push_back(ra[i][j]); } } } long long ans = 0; for(int k = 0;k < H;++k){ BIT bit(pos.size()); priority_queue<pair<int,int>>que; for(int i = 0;i < pos[k].size();++i){ que.push(make_pair((int)pos[k][i],i)); } for(int i = 0;i < pos[k].size();++i){ while(!que.empty() && que.top().first >= -i){ bit.add(que.top().second,1); que.pop(); } int dn = i + L - 1;dn = min(dn,(int)pos[k].size()); int up = i + pro[k][i]; if(dn < up){ int ub = bit.range(up); int db = bit.range(dn); int can = ub - db; ans += (long long)can; } } } for(int k = 0;k < W-1;++k){ BIT bit(neg.size()); priority_queue<pair<int,int>>que; for(int i = 0;i < neg[k].size();++i){ que.push(make_pair((int)neg[k][i],i)); } for(int i = 0;i < neg[k].size();++i){ while(!que.empty() && que.top().first >= -i){ bit.add(que.top().second,1); que.pop(); } int dn = i + L - 1;dn = min(dn,(int)neg[k].size()); int up = i + nro[k][i]; if(dn < up){ int can = bit.range(up) - bit.range(dn); ans += (long long)can; } } } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:54:39: error: no matching function for call to 'min(short int&, int)' 54 | la[i][j] = min(la[i][j],(int)((j)?(la[i][j-1]+(int)1):(int)1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:54:39: note: deduced conflicting types for parameter 'const _Tp' ('short int' and 'int') 54 | la[i][j] = min(la[i][j],(int)((j)?(la[i][j-1]+(int)1):(int)1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:54:39: note: mismatched types 'std::initializer_list<_Tp>' and 'short int' 54 | la[i][j] = min(la[i][j],(int)((j)?(la[i][j-1]+(int)1):(int)1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:59:39: error: no matching function for call to 'min(short int&, int)' 59 | ra[i][j] = min(ra[i][j],(int)(ra[i][j+1]+(int)1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:59:39: note: deduced conflicting types for parameter 'const _Tp' ('short int' and 'int') 59 | ra[i][j] = min(ra[i][j],(int)(ra[i][j+1]+(int)1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:59:39: note: mismatched types 'std::initializer_list<_Tp>' and 'short int' 59 | ra[i][j] = min(ra[i][j],(int)(ra[i][j+1]+(int)1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:64:39: error: no matching function for call to 'min(short int&, int)' 64 | ua[i][j] = min(ua[i][j],(int)((i)?(ua[i-1][j]+(int)1):(int)1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:64:39: note: deduced conflicting types for parameter 'const _Tp' ('short int' and 'int') 64 | ua[i][j] = min(ua[i][j],(int)((i)?(ua[i-1][j]+(int)1):(int)1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:64:39: note: mismatched types 'std::initializer_list<_Tp>' and 'short int' 64 | ua[i][j] = min(ua[i][j],(int)((i)?(ua[i-1][j]+(int)1):(int)1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:69:39: error: no matching function for call to 'min(short int&, int)' 69 | da[i][j] = min(da[i][j],(int)(da[i+1][j]+(int)1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:69:39: note: deduced conflicting types for parameter 'const _Tp' ('short int' and 'int') 69 | da[i][j] = min(da[i][j],(int)(da[i+1][j]+(int)1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:69:39: note: mismatched types 'std::initializer_list<_Tp>' and 'short int' 69 | da[i][j] = min(da[i][j],(int)(da[i+1][j]+(int)1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s770494625
p00541
C++
#include <bits/stdc++.h> using namespace std; using LL = long long; int H,W,L; int P; const int N_MAX = 4001; short la[N_MAX][N_MAX]; short ra[N_MAX][N_MAX]; short ua[N_MAX][N_MAX]; short da[N_MAX][N_MAX]; struct BIT{ vector<int>seg; int width; BIT(int n):width(1){ while(width < n)width *= 2; seg.resize(width + 1); } void add(int x,int val){ x++; while(x <= width){ seg[x] += val; x += (x & -x); } } int range(int x){ int res = 0; while(x > 0){ res += seg[x]; x -= (x & -x); } return res; } }; int main(){ cin >> H >> W >> L >> P; for(int i = 0;i < H;++i){ for(int j = 0;j < W;++j){ la[i][j] = ra[i][j] = ua[i][j] = da[i][j] = 6666; } } for(int i = 0;i < P;++i){ int a,b; cin >> a >> b; --a;--b; la[a][b] = ra[a][b] = ua[a][b] = da[a][b] = 0; } for(int i = 0;i < H;++i){ for(int j = 0;j < W;++j){ la[i][j] = min(la[i][j],(int)((j)?(la[i][j-1]+(int)1):(int)1)); } } for(int i = 0;i < H;++i){ for(int j = W - 1;j >= 0;--j){ ra[i][j] = min(ra[i][j],(int)(ra[i][j+1]+(int)1)); } } for(int i = 0;i < H;++i){ for(int j = 0;j < W;++j){ ua[i][j] = min(ua[i][j],(int)((i)?(ua[i-1][j]+(int)1):(int)1)); } } for(int i = H - 1;i >= 0;--i){ for(int j = 0;j < W;++j){ da[i][j] = min(da[i][j],(int)(da[i+1][j]+(int)1)); } } for(int i = 0;i < H;++i){ for(int j = 0;j < W;++j){ ra[i][j] = min(ra[i][j],da[i][j]); } } for(int i = 0;i < H;++i){ for(int j = 0;j < W;++j){ la[i][j] = min(la[i][j],ua[i][j]); } } vector<vector<int>>pos(H),neg(W-1); vector<vector<int>>pro(H),nro(W-1); for(int i = 0;i < H;++i){ for(int j = 0;j < W;++j){ if(i - j >= 0){ pos[i - j].push_back(la[i][j]-pos[i - j].size()-1); pro[i - j].push_back(ra[i][j]); }else{ neg[j - i - 1].push_back(la[i][j]-neg[j - i - 1].size()-1); nro[j - i - 1].push_back(ra[i][j]); } } } long long ans = 0; for(int k = 0;k < H;++k){ BIT bit(pos.size()); priority_queue<pair<int,int>>que; for(int i = 0;i < pos[k].size();++i){ que.push(make_pair((int)pos[k][i],i)); } for(int i = 0;i < pos[k].size();++i){ while(!que.empty() && que.top().first >= -i){ bit.add(que.top().second,1); que.pop(); } int dn = i + L - 1;dn = min(dn,(int)pos[k].size()); int up = i + pro[k][i]; if(dn < up){ int ub = bit.range(up); int db = bit.range(dn); int can = ub - db; ans += (long long)can; } } } for(int k = 0;k < W-1;++k){ BIT bit(neg.size()); priority_queue<pair<int,int>>que; for(int i = 0;i < neg[k].size();++i){ que.push(make_pair((int)neg[k][i],i)); } for(int i = 0;i < neg[k].size();++i){ while(!que.empty() && que.top().first >= -i){ bit.add(que.top().second,1); que.pop(); } int dn = i + L - 1;dn = min(dn,(int)neg[k].size()); int up = i + nro[k][i]; if(dn < up){ int can = bit.range(up) - bit.range(dn); ans += (long long)can; } } } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:54:39: error: no matching function for call to 'min(short int&, int)' 54 | la[i][j] = min(la[i][j],(int)((j)?(la[i][j-1]+(int)1):(int)1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:54:39: note: deduced conflicting types for parameter 'const _Tp' ('short int' and 'int') 54 | la[i][j] = min(la[i][j],(int)((j)?(la[i][j-1]+(int)1):(int)1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:54:39: note: mismatched types 'std::initializer_list<_Tp>' and 'short int' 54 | la[i][j] = min(la[i][j],(int)((j)?(la[i][j-1]+(int)1):(int)1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:59:39: error: no matching function for call to 'min(short int&, int)' 59 | ra[i][j] = min(ra[i][j],(int)(ra[i][j+1]+(int)1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:59:39: note: deduced conflicting types for parameter 'const _Tp' ('short int' and 'int') 59 | ra[i][j] = min(ra[i][j],(int)(ra[i][j+1]+(int)1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:59:39: note: mismatched types 'std::initializer_list<_Tp>' and 'short int' 59 | ra[i][j] = min(ra[i][j],(int)(ra[i][j+1]+(int)1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:64:39: error: no matching function for call to 'min(short int&, int)' 64 | ua[i][j] = min(ua[i][j],(int)((i)?(ua[i-1][j]+(int)1):(int)1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:64:39: note: deduced conflicting types for parameter 'const _Tp' ('short int' and 'int') 64 | ua[i][j] = min(ua[i][j],(int)((i)?(ua[i-1][j]+(int)1):(int)1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:64:39: note: mismatched types 'std::initializer_list<_Tp>' and 'short int' 64 | ua[i][j] = min(ua[i][j],(int)((i)?(ua[i-1][j]+(int)1):(int)1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:69:39: error: no matching function for call to 'min(short int&, int)' 69 | da[i][j] = min(da[i][j],(int)(da[i+1][j]+(int)1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:69:39: note: deduced conflicting types for parameter 'const _Tp' ('short int' and 'int') 69 | da[i][j] = min(da[i][j],(int)(da[i+1][j]+(int)1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:69:39: note: mismatched types 'std::initializer_list<_Tp>' and 'short int' 69 | da[i][j] = min(da[i][j],(int)(da[i+1][j]+(int)1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s256400469
p00541
C++
#include <bits/stdc++.h> using namespace std; using LL = long long; int H,W,L; int P; const int N_MAX = 4001; short la[N_MAX][N_MAX]; short ra[N_MAX][N_MAX]; short ua[N_MAX][N_MAX]; short da[N_MAX][N_MAX]; struct BIT{ vector<int>seg; int width; BIT(int n):width(1){ while(width < n)width *= 2; seg.resize(width + 1); } void add(int x,int val){ x++; while(x <= width){ seg[x] += val; x += (x & -x); } } int range(int x){ int res = 0; while(x > 0){ res += seg[x]; x -= (x & -x); } return res; } }; int main(){ cin >> H >> W >> L >> P; for(int i = 0;i < H;++i){ for(int j = 0;j < W;++j){ la[i][j] = ra[i][j] = ua[i][j] = da[i][j] = 6666; } } for(int i = 0;i < P;++i){ int a,b; cin >> a >> b; --a;--b; la[a][b] = ra[a][b] = ua[a][b] = da[a][b] = 0; } for(int i = 0;i < H;++i){ for(int j = 0;j < W;++j){ la[i][j] = (short)min(la[i][j],(int)((j)?(la[i][j-1]+(int)1):(int)1)); } } for(int i = 0;i < H;++i){ for(int j = W - 1;j >= 0;--j){ ra[i][j] =(short) min(ra[i][j],(int)(ra[i][j+1]+(int)1)); } } for(int i = 0;i < H;++i){ for(int j = 0;j < W;++j){ ua[i][j] = (short)min(ua[i][j],(int)((i)?(ua[i-1][j]+(int)1):(int)1)); } } for(int i = H - 1;i >= 0;--i){ for(int j = 0;j < W;++j){ da[i][j] = (short)min(da[i][j],(int)(da[i+1][j]+(int)1)); } } for(int i = 0;i < H;++i){ for(int j = 0;j < W;++j){ ra[i][j] = min(ra[i][j],da[i][j]); } } for(int i = 0;i < H;++i){ for(int j = 0;j < W;++j){ la[i][j] = min(la[i][j],ua[i][j]); } } vector<vector<int>>pos(H),neg(W-1); vector<vector<int>>pro(H),nro(W-1); for(int i = 0;i < H;++i){ for(int j = 0;j < W;++j){ if(i - j >= 0){ pos[i - j].push_back(la[i][j]-pos[i - j].size()-1); pro[i - j].push_back(ra[i][j]); }else{ neg[j - i - 1].push_back(la[i][j]-neg[j - i - 1].size()-1); nro[j - i - 1].push_back(ra[i][j]); } } } long long ans = 0; for(int k = 0;k < H;++k){ BIT bit(pos.size()); priority_queue<pair<int,int>>que; for(int i = 0;i < pos[k].size();++i){ que.push(make_pair((int)pos[k][i],i)); } for(int i = 0;i < pos[k].size();++i){ while(!que.empty() && que.top().first >= -i){ bit.add(que.top().second,1); que.pop(); } int dn = i + L - 1;dn = min(dn,(int)pos[k].size()); int up = i + pro[k][i]; if(dn < up){ int ub = bit.range(up); int db = bit.range(dn); int can = ub - db; ans += (long long)can; } } } for(int k = 0;k < W-1;++k){ BIT bit(neg.size()); priority_queue<pair<int,int>>que; for(int i = 0;i < neg[k].size();++i){ que.push(make_pair((int)neg[k][i],i)); } for(int i = 0;i < neg[k].size();++i){ while(!que.empty() && que.top().first >= -i){ bit.add(que.top().second,1); que.pop(); } int dn = i + L - 1;dn = min(dn,(int)neg[k].size()); int up = i + nro[k][i]; if(dn < up){ int can = bit.range(up) - bit.range(dn); ans += (long long)can; } } } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:54:46: error: no matching function for call to 'min(short int&, int)' 54 | la[i][j] = (short)min(la[i][j],(int)((j)?(la[i][j-1]+(int)1):(int)1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:54:46: note: deduced conflicting types for parameter 'const _Tp' ('short int' and 'int') 54 | la[i][j] = (short)min(la[i][j],(int)((j)?(la[i][j-1]+(int)1):(int)1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:54:46: note: mismatched types 'std::initializer_list<_Tp>' and 'short int' 54 | la[i][j] = (short)min(la[i][j],(int)((j)?(la[i][j-1]+(int)1):(int)1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:59:46: error: no matching function for call to 'min(short int&, int)' 59 | ra[i][j] =(short) min(ra[i][j],(int)(ra[i][j+1]+(int)1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:59:46: note: deduced conflicting types for parameter 'const _Tp' ('short int' and 'int') 59 | ra[i][j] =(short) min(ra[i][j],(int)(ra[i][j+1]+(int)1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:59:46: note: mismatched types 'std::initializer_list<_Tp>' and 'short int' 59 | ra[i][j] =(short) min(ra[i][j],(int)(ra[i][j+1]+(int)1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:64:46: error: no matching function for call to 'min(short int&, int)' 64 | ua[i][j] = (short)min(ua[i][j],(int)((i)?(ua[i-1][j]+(int)1):(int)1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:64:46: note: deduced conflicting types for parameter 'const _Tp' ('short int' and 'int') 64 | ua[i][j] = (short)min(ua[i][j],(int)((i)?(ua[i-1][j]+(int)1):(int)1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:64:46: note: mismatched types 'std::initializer_list<_Tp>' and 'short int' 64 | ua[i][j] = (short)min(ua[i][j],(int)((i)?(ua[i-1][j]+(int)1):(int)1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:69:46: error: no matching function for call to 'min(short int&, int)' 69 | da[i][j] = (short)min(da[i][j],(int)(da[i+1][j]+(int)1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:69:46: note: deduced conflicting types for parameter 'const _Tp' ('short int' and 'int') 69 | da[i][j] = (short)min(da[i][j],(int)(da[i+1][j]+(int)1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:69:46: note: mismatched types 'std::initializer_list<_Tp>' and 'short int' 69 | da[i][j] = (short)min(da[i][j],(int)(da[i+1][j]+(int)1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s336306734
p00542
C
#include<stdio.h> int main () { int c,x[7],sum; for(c=1; c<7; c++){ scanf("%d",&x[c]) } if(x[1] <= x[2]){ if(x[1] <= x[3]){ if(x[1] <= x[4]){ sum = x[2] + x[3] + x[4]; } else{ sum = x[1] + x[2] + x[3]; } } else{ if(x[3] <= x[4]){ sum = x[1] + x[2] + x[4]; } else{ sum = x[1] + x[2] + x[3]; } } } else{ if(x[2] <= x[3]){ if(x[2] <= x[4]){ sum = x[1] + x[3] + x[4]; } else{ sum = x[1] + x[2] + x[3]; } } else{ if(x[3] <= x[4]){ sum = x[1] + x[2] + x[4]; } else{ sum = x[1] + x[2] + x[3]; } } } if(x[5] <= x[6]){ sum = sum + x[6]; } else{ sum = sum + x[5]; } puts(""); printf("%d",sum); return 0; }
main.c: In function 'main': main.c:7:34: error: expected ';' before '}' token 7 | scanf("%d",&x[c]) | ^ | ; 8 | } | ~
s688204800
p00542
C
#include<stdio.h> int main() { int A=0, B=0, C=0, D=0, E=0, F=0,p,x,y; scanf_s("%d %d %d %d %d %d", &A, &B, &C, &D, &E, &F); p = 1000000; if (A < p)p = A; if (B < p)p = B; if (C < p)p = C; if (D < p)p = D; x = (A + B + C + D) - p; if (E < F) { y = F; } else { y = E; } printf("%d", x + y); return 0; }
main.c: In function 'main': main.c:4:9: error: implicit declaration of function 'scanf_s'; did you mean 'scanf'? [-Wimplicit-function-declaration] 4 | scanf_s("%d %d %d %d %d %d", &A, &B, &C, &D, &E, &F); | ^~~~~~~ | scanf
s258575246
p00542
C
#include <stdio.h> #include <string.h> int main() { int a[4], e, f, sum = 0, tmp, i, j; scanf("%d%d%d%d%d%d", &a[0], &a[1], &a[2], &a[3], &e, &f); sum += e > f ? e : f; for (j = 0;j < 4;j++) for (i = 4;i>0;i--) { if (a[i] < a[i-1]) { tmp = a[i];a[i-1] = a[i];a[i-1] = tmp; } } sum += a[3] + a[1] + a[2]; printf("%d", sum); return 0;
main.c: In function 'main': main.c:16:9: error: expected declaration or statement at end of input 16 | return 0; | ^~~~~~
s868251431
p00542
C
#include <stdio.h> int main() { int phy,cem,bio,tigaku,hys,tiri,x; scanf("%d",&phy); scanf("%d",&cem); scanf("%d",&bio); scanf("%d",&tigaku); scant("%d",&hys); scanf("%d",tiri); if(phy<cem){ x=cem; cem=phy; phy=x; } if(cem<bio){ x=bio; bio=cem; cem=x; } if(bio<tigaku){ x=tigaku; tigaku=bio; bio=x; } if(hys<tiri){ x=tiri; tiri=hys; hys=x; } printf("%d\n",phy+cem+bio+hys); return 0; }
main.c: In function 'main': main.c:10:3: error: implicit declaration of function 'scant'; did you mean 'scanf'? [-Wimplicit-function-declaration] 10 | scant("%d",&hys); | ^~~~~ | scanf
s066124281
p00542
C
#include <stdio.h> int main(){ int a[6],i,an; for(i=0;i<6;i++){ scanf("%d\n",&a[i]); an+=a[i]; } an-=min(a[4],a[5]); an-=min(a[0],a[1]a[2],a[3]); printf("%d\n",an); return 0; }
main.c: In function 'main': main.c:9:9: error: implicit declaration of function 'min'; did you mean 'main'? [-Wimplicit-function-declaration] 9 | an-=min(a[4],a[5]); | ^~~ | main main.c:10:22: error: expected ')' before 'a' 10 | an-=min(a[0],a[1]a[2],a[3]); | ~ ^ | )
s350608820
p00542
C
#include <stdio.h> int main(){ int a[6],i,an; for(i=0;i<6;i++){ scanf("%d\n",&a[i]); an+=a[i]; } an-=min(a[4],a[5]); an-=min(a[0],a[1],a[2],a[3]); printf("%d\n",an); return 0; }
main.c: In function 'main': main.c:9:9: error: implicit declaration of function 'min'; did you mean 'main'? [-Wimplicit-function-declaration] 9 | an-=min(a[4],a[5]); | ^~~ | main
s328925945
p00542
C++
//2015 #include<iostream> #include<slgorithm> #include<functional> using namespace std; int main(void){ int i,ad[4]={0},e=0,f=0,sum=0; for(i=0;i<4;i++){ cin>>ad[i]; } cin>>e; cin>>f; sort(ad,ad+4,greater<int>());//降順,昇順==sort(ad,ad+4); for(i=0;i<3;i++){ sum+=ad[i]; } if(e<f){ sum+=f; } else{ sum+=e; } cout<<sum<<endl; return 0; }
a.cc:3:9: fatal error: slgorithm: No such file or directory 3 | #include<slgorithm> | ^~~~~~~~~~~ compilation terminated.
s209338543
p00542
C++
#include <bits/stdc++.h> typedef long long LL; using namespace std; int main(){ int a, b, c, d, e, f; cin >> a >> b >> c >> d >> e >> f; int ans = (a+b+c+d+e+f) - min(a, min(b, min(c, d)) - min(e, f); cout << ans << endl; }
a.cc: In function 'int main()': a.cc:8:65: error: expected ')' before ';' token 8 | int ans = (a+b+c+d+e+f) - min(a, min(b, min(c, d)) - min(e, f); | ~ ^ | )
s225386934
p00542
C++
#include <iostream> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; int A[6]; int main() { rep(i, 6) cin >> A[i]; sort(A, A + 4); sort(A + 4, A + 6); int ans = 0; rep(i, 3) ans += A[i + 1]; ans += A[5]; cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:10:5: error: 'sort' was not declared in this scope; did you mean 'short'? 10 | sort(A, A + 4); | ^~~~ | short
s212738398
p00542
C++
#include <stdio.h> #include <string.h> #include <algorithm> using namespace std; int main(){ int A, B, C, D, E, F; scanf("%d%d%d%d%d%d", &A, &B, &C, &D, &E, &F); printf("%d\n", A + B + C + D + E + F - min(min(A, B), min(C, D)) - min(E, F); return 0; }
a.cc: In function 'int main()': a.cc:8:85: error: expected ')' before ';' token 8 | printf("%d\n", A + B + C + D + E + F - min(min(A, B), min(C, D)) - min(E, F); | ~ ^ | )
s649002999
p00542
C++
#include <stdio.h> #include <algorithm> using namespace std; int main() { int sum = 0; int a[4], b[2]; for (int i = 0; i < 4; i++) { scanf("%d", &a[i]); } for (int i = 0; i < 2; i++) { scanf("%d", &b[i]); } sort(rbegin(a), rend(a)); sum = max(b[0], b[1]); for (int i = 0; i < 3; i++) { sum += a[i]; } printf("%d\n", sum); return 0; }
a.cc: In function 'int main()': a.cc:19:14: error: 'rbegin' was not declared in this scope 19 | sort(rbegin(a), rend(a)); | ^~~~~~ a.cc:19:25: error: 'rend' was not declared in this scope; did you mean 'rand'? 19 | sort(rbegin(a), rend(a)); | ^~~~ | rand
s578874936
p00542
C++
#include <stdio.h> #include <algorithm> using namespace std; int main() { int sum = 0; int a[4], b[2]; for (int i = 0; i < 4; i++) { scanf("%d", &a[i]); } for (int i = 0; i < 2; i++) { scanf("%d", &b[i]); } sort(rbegin(a), rend(a)); sum = max(b[0], b[1]); for (int i = 0; i < 3; i++) { sum += a[i]; } printf("%d\n", sum); return 0; }
a.cc: In function 'int main()': a.cc:19:14: error: 'rbegin' was not declared in this scope 19 | sort(rbegin(a), rend(a)); | ^~~~~~ a.cc:19:25: error: 'rend' was not declared in this scope; did you mean 'rand'? 19 | sort(rbegin(a), rend(a)); | ^~~~ | rand
s435106424
p00542
C++
#include <stdio.h> #include <algorithm> using namespace std; int main() { int sum = 0; int a[4], b[2]; for (int i = 0; i < 4; i++) { scanf("%d", &a[i]); } for (int i = 0; i < 2; i++) { scanf("%d", &b[i]); } sort(rbegin(a), rend(a)); sum = max(b[0], b[1]); for (int i = 0; i < 3; i++) { sum += a[i]; } printf("%d\n", sum); return 0; }
a.cc: In function 'int main()': a.cc:19:14: error: 'rbegin' was not declared in this scope 19 | sort(rbegin(a), rend(a)); | ^~~~~~ a.cc:19:25: error: 'rend' was not declared in this scope; did you mean 'rand'? 19 | sort(rbegin(a), rend(a)); | ^~~~ | rand
s639886197
p00542
C++
#include<algorithm> #include<iostream> int main(){ int s[4]; int m_max; int h[3]; int h_max; for(int i = 0;i<4;i++){ cin>>s[i]; m_max += s[i]; } m_max -= (min(s[0],min(s[1],min(s[2],s[3])))); for(int i = 0;i<3;i++){ cin>>h[i]; h_max+=h[i]; } h_max -= (min(h[0],min(h[1],h[2]))); m_max += h_max; cout<<m_max<<endl; }
a.cc: In function 'int main()': a.cc:10:17: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 10 | cin>>s[i]; | ^~~ | std::cin In file included from a.cc:2: /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ a.cc:13:37: error: 'min' was not declared in this scope; did you mean 'std::min'? 13 | m_max -= (min(s[0],min(s[1],min(s[2],s[3])))); | ^~~ | std::min In file included from /usr/include/c++/14/algorithm:61, from a.cc:1: /usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ a.cc:13:28: error: 'min' was not declared in this scope; did you mean 'std::min'? 13 | m_max -= (min(s[0],min(s[1],min(s[2],s[3])))); | ^~~ | std::min /usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ a.cc:13:19: error: 'min' was not declared in this scope; did you mean 'std::min'? 13 | m_max -= (min(s[0],min(s[1],min(s[2],s[3])))); | ^~~ | std::min /usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ a.cc:15:17: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 15 | cin>>h[i]; | ^~~ | std::cin /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ a.cc:20:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 20 | cout<<m_max<<endl; | ^~~~ | std::cout /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~ a.cc:20:22: error: 'endl' was not declared in this scope; did you mean 'std::endl'? 20 | cout<<m_max<<endl; | ^~~~ | std::endl In file included from /usr/include/c++/14/iostream:41: /usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here 744 | endl(basic_ostream<_CharT, _Traits>& __os) | ^~~~
s414351123
p00542
C++
#include<iostream> #include<math.h> #include<stdio.h> #include<vector> #include<queue> #include<stack> #include<string> #include<functional> using namespace std; #define FOR(i,a) for(int i=0;i<a;i++) int main(){ int a[4];int b[2]; FOR(i,4){cin>>a[i];} FOR(i,2){cin>>b[i];} sort(a,a+4,greater<int>()); sort(b,b+2,greater<int>()); cout<<a[0]+a[1]+b[0}<<endl; }
a.cc: In function 'int main()': a.cc:18:9: error: 'sort' was not declared in this scope; did you mean 'sqrt'? 18 | sort(a,a+4,greater<int>()); | ^~~~ | sqrt a.cc:20:28: error: expected ']' before '}' token 20 | cout<<a[0]+a[1]+b[0}<<endl; | ^ | ] a.cc:20:28: error: expected ';' before '}' token 20 | cout<<a[0]+a[1]+b[0}<<endl; | ^ | ; a.cc: At global scope: a.cc:20:29: error: expected unqualified-id before '<<' token 20 | cout<<a[0]+a[1]+b[0}<<endl; | ^~ a.cc:21:1: error: expected declaration before '}' token 21 | } | ^
s939666261
p00542
C++
#include<iostream> #include <algorithm> #include<math.h> #include<stdio.h> #include<vector> #include<queue> #include<stack> #include<string> #include<functional> using namespace std; #define FOR(i,a) for(int i=0;i<a;i++) int main(){ int a[4];int b[2]; FOR(i,4){cin>>a[i];} FOR(i,2){cin>>b[i];} sort(a,a+4,greater<int>()); sort(b,b+2,greater<int>()); cout<<a[0]+a[1]+b[0}<<endl; }
a.cc: In function 'int main()': a.cc:21:28: error: expected ']' before '}' token 21 | cout<<a[0]+a[1]+b[0}<<endl; | ^ | ] a.cc:21:28: error: expected ';' before '}' token 21 | cout<<a[0]+a[1]+b[0}<<endl; | ^ | ; a.cc: At global scope: a.cc:21:29: error: expected unqualified-id before '<<' token 21 | cout<<a[0]+a[1]+b[0}<<endl; | ^~ a.cc:22:1: error: expected declaration before '}' token 22 | } | ^
s873123099
p00542
C++
#include <bits/stdc++.h> #define r(i,n) for(i=0;i<n;i++) using namespace std; int main(){ int a[6]; r(i,6)cin>>a[i]; sort(a,a+6); int s=0; r(i,6)if(i>1)s+=a[i]; cout<<s<<endl; }
a.cc: In function 'int main()': a.cc:6:11: error: 'i' was not declared in this scope 6 | r(i,6)cin>>a[i]; | ^ a.cc:2:20: note: in definition of macro 'r' 2 | #define r(i,n) for(i=0;i<n;i++) | ^ a.cc:9:11: error: 'i' was not declared in this scope 9 | r(i,6)if(i>1)s+=a[i]; | ^ a.cc:2:20: note: in definition of macro 'r' 2 | #define r(i,n) for(i=0;i<n;i++) | ^
s409084158
p00542
C++
#include<iostream> using namespace std; int main(){ int data[7]; int sum=0; int min=100; int temp; for(int i=0;i<4;i++){ cin >> temp; sum+=temp; if(temp<min)min=temp; } sum-=min; min=100; for(int i=0;i<2;i++){ cin >> temp; sum+=temp; if(temp<min)min=temp; } sum-=min; cout >> sum >>endl; }
a.cc: In function 'int main()': a.cc:23:6: error: no match for 'operator>>' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'int') 23 | cout >> sum >>endl; | ~~~~ ^~ ~~~ | | | | | int | std::ostream {aka std::basic_ostream<char>} a.cc:23:6: note: candidate: 'operator>>(int, int)' (built-in) 23 | cout >> sum >>endl; | ~~~~~^~~~~~ a.cc:23:6: note: no known conversion for argument 1 from 'std::ostream' {aka 'std::basic_ostream<char>'} to 'int' In file included from /usr/include/c++/14/string:55, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/basic_string.tcc:835:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 835 | operator>>(basic_istream<_CharT, _Traits>& __in, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.tcc:835:5: note: template argument deduction/substitution failed: a.cc:23:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>' 23 | cout >> sum >>endl; | ^~~ In file included from /usr/include/c++/14/bits/memory_resource.h:38, from /usr/include/c++/14/string:68: /usr/include/c++/14/cstddef:131:5: note: candidate: 'template<class _IntegerType> constexpr std::__byte_op_t<_IntegerType> std::operator>>(byte, _IntegerType)' 131 | operator>>(byte __b, _IntegerType __shift) noexcept | ^~~~~~~~ /usr/include/c++/14/cstddef:131:5: note: template argument deduction/substitution failed: a.cc:23:1: note: cannot convert 'std::cout' (type 'std::ostream' {aka 'std::basic_ostream<char>'}) to type 'std::byte' 23 | cout >> sum >>endl; | ^~~~ In file included from /usr/include/c++/14/istream:1109, from /usr/include/c++/14/iostream:42: /usr/include/c++/14/bits/istream.tcc:978:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, _CharT&)' 978 | operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c) | ^~~~~~~~ /usr/include/c++/14/bits/istream.tcc:978:5: note: template argument deduction/substitution failed: a.cc:23:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>' 23 | cout >> sum >>endl; | ^~~ /usr/include/c++/14/istream:849:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, unsigned char&)' 849 | operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c) | ^~~~~~~~ /usr/include/c++/14/istream:849:5: note: template argument deduction/substitution failed: a.cc:23:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<char, _Traits>' 23 | cout >> sum >>endl; | ^~~ /usr/include/c++/14/istream:854:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, signed char&)' 854 | operator>>(basic_istream<char, _Traits>& __in, signed char& __c) | ^~~~~~~~ /usr/include/c++/14/istream:854:5: note: template argument deduction/substitution failed: a.cc:23:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<char, _Traits>' 23 | cout >> sum >>endl; | ^~~ /usr/include/c++/14/istream:896:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, _CharT*)' 896 | operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s) | ^~~~~~~~ /usr/include/c++/14/istream:896:5: note: template argument deduction/substitution failed: a.cc:23:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>' 23 | cout >> sum >>endl; | ^~~ /usr/include/c++/14/istream:939:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, unsigned char*)' 939 | operator>>(basic_istream<char, _Traits>& __in, unsigned char* __s) | ^~~~~~~~ /usr/include/c++/14/istream:939:5: note: template argument deduction/substitution failed: a.cc:23:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<char, _Traits>' 23 | cout >> sum >>endl; | ^~~ /usr/include/c++/14/istream:945:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, signed char*)' 945 | operator>>(basic_istream<char, _Traits>& __in, signed char* __s) | ^~~~~~~~ /usr/include/c++/14/istream:945:5: note: template argument deduction/substitution failed: a.cc:23:9: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<char, _Traits>' 23 | cout >> sum >>endl; | ^~~ /usr/include/c++/14/istream:1099:5: note: candidate: 'template<class _Istream, class _Tp> _Istream&& std::operator>>(_Istream&&, _Tp&&)' 1099 | operator>>(_Istream&& __is, _Tp&& __x) | ^~~~~~~~ /usr/include/c++/14/istream:1099:5: note: template argument deduction/substitution failed: /usr/include/c++/14/istream: In substitution of 'template<class _Istream, class _Tp> _Istream&& std::operator>>(_Istream&&, _Tp&&) [with _Istream = std::basic_ostream<char>&; _Tp = int&]': a.cc:23:9: required from here 23 | cout >> sum >>endl; | ^~~ /usr/include/c++/14/istream:1099:5: error: no type named 'type' in 'struct std::enable_if<false, void>' 1099 | operator>>(_Istream&& __is, _Tp&& __x) | ^~~~~~~~
s785192718
p00542
C++
#include <bits/stdc++.h> #include<algorithm> using namespace std; int main(){ int a,b,c,d,e,f; cin >>a>>b>>c>>d>>e>>f; score[]={a,b,c,d}; sort(score.begin(),score.end()) score2[]={e,f}; sort(score2.begin(),score2.end()) cout <<score[1]+score[2]+score[3]+score2[1]<<endl; return 0; }
a.cc: In function 'int main()': a.cc:8:5: error: 'score' was not declared in this scope 8 | score[]={a,b,c,d}; | ^~~~~ a.cc:8:11: error: expected primary-expression before ']' token 8 | score[]={a,b,c,d}; | ^ a.cc:11:10: error: 'score2' was not declared in this scope 11 | sort(score2.begin(),score2.end()) | ^~~~~~
s527044068
p00542
C++
#include <bits/stdc++.h> #include<algorithm> using namespace std; int main(){ int a,b,c,d,e,f; cin >>a>>b>>c>>d>>e>>f; score[]={a,b,c,d}; sort(score,score+4) score2[]={e,f}; sort(score2,score2+2) cout <<score[1]+score[2]+score[3]+score2[1]<<endl; return 0; }
a.cc: In function 'int main()': a.cc:8:5: error: 'score' was not declared in this scope 8 | score[]={a,b,c,d}; | ^~~~~ a.cc:8:11: error: expected primary-expression before ']' token 8 | score[]={a,b,c,d}; | ^ a.cc:11:10: error: 'score2' was not declared in this scope 11 | sort(score2,score2+2) | ^~~~~~
s555393358
p00542
C++
#include <bits/stdc++.h> #include<algorithm> using namespace std; int main(){ int a,b,c,d,e,f; cin >>a>>b>>c>>d>>e>>f; score[]={a,b,c,d}; sort(score,score+4); score2[]={e,f}; sort(score2,score2+2); cout <<score[1]+score[2]+score[3]+score2[1]<<endl; return 0; }
a.cc: In function 'int main()': a.cc:8:5: error: 'score' was not declared in this scope 8 | score[]={a,b,c,d}; | ^~~~~ a.cc:8:11: error: expected primary-expression before ']' token 8 | score[]={a,b,c,d}; | ^ a.cc:10:5: error: 'score2' was not declared in this scope 10 | score2[]={e,f}; | ^~~~~~ a.cc:10:12: error: expected primary-expression before ']' token 10 | score2[]={e,f}; | ^
s966491207
p00542
C++
#include<bits/stdc++.h> using namespace std; int main(){ int a[4],b[2]; for(int i=0;i<4;i++){ cin>>a[i]; } for(int i=0;i<2;i++){ cin>>b[i]; } for(int i=0;i<3;i++){ for(int j=0;j<4;j++){ if(a[j]<a[j+1]){ swap(a[j],a[j+1]); } } } if(b[1]<b[2]){ swap(b[1],b[2]); } cout<<a[0]+a[2]+a[3]+a[1]]+b[1]<<endl; return 0; }
a.cc: In function 'int main()': a.cc:21:30: error: expected ';' before ']' token 21 | cout<<a[0]+a[2]+a[3]+a[1]]+b[1]<<endl; | ^ | ;
s222488468
p00542
C++
// ?????±???????????????????????? 2015-1 #include<cstdio> #include<algorithm> using namespace std; int main(){ int a[4],b[2]; for(int i=0;i<4;i++) scanf("%d",a+i); for(int i=0;i<2;i++) scanf("%d",b+i); sort(a,a+4); sort(b,b+2); int ans = 0; for(int i=3;i>0;i--) ans+=a[i]; ans+=b[1]; printf("%d\n",ans); return 0 }
a.cc: In function 'int main()': a.cc:17:11: error: expected ';' before '}' token 17 | return 0 | ^ | ; 18 | } | ~
s105302857
p00542
C++
// ?????±???????????????????????? 2015-1 #include<cstdio> #include<algorithm> using namespace std; int main(){ int a[4],b[2]; for(int i=0;i<4;i++) scanf("%d",a+i); for(int i=0;i<2;i++) scanf("%d",b+i); sort(a,a+4); sort(b,b+2); int ans = 0; for(int i=3;i>0;i--) ans+=a[i]; ans+=b[1]; printf("%d\n",ans); return 0 }
a.cc: In function 'int main()': a.cc:17:11: error: expected ';' before '}' token 17 | return 0 | ^ | ; 18 | } | ~
s838744470
p00542
C++
#include<cstdio> #include<algorithm> using namespace std; int main(){ int a[4],b[2]; for(int i=0;i<4;i++) scanf("%d",a+i); for(int i=0;i<2;i++) scanf("%d",b+i); sort(a,a+4); sort(b,b+2); int ans = 0; for(int i=3;i>0;i--) ans+=a[i]; ans+=b[1]; printf("%d\n",ans); return 0 }
a.cc: In function 'int main()': a.cc:16:11: error: expected ';' before '}' token 16 | return 0 | ^ | ; 17 | } | ~
s744894366
p00542
C++
#include<iostream> using namespace std; int i, sumrika, sumsha, t, u, cnt=0; int rika[5], sha[3]; int main(){ int minrika=110, minsha=110; for(i=1; i<=4; i++){ cin>>rika[i]; sumrika+=rika[i]; it(rika[i]<minrika) {minrika=rika[i];} } for(i=1; i<=2; i++){ cin>>sha[i]; sumsha+=sha[i]; if(sha[i]<minsha) {minsha=sha[i];} } int disp = (sumrika-minrika)+(sumsha-minsha); cout << disp << endl; }
a.cc: In function 'int main()': a.cc:10:11: error: 'it' was not declared in this scope; did you mean 't'? 10 | it(rika[i]<minrika) {minrika=rika[i];} | ^~ | t
s826589845
p00542
C++
include<iostream> using namespace std; int main() { int a,b,c,d,e,f; cin>>a>>b>>c>>d>>e>>f; if(a>b) {if(b>c){sum1=a+b} else{sum2=a+c} } if(b>a) {if(a>c){sum1=b+a} else{sum1=b+c} } if(c>a) {if(a>b){sum1=c+a} else{sum1=c+b} } if(e>f){sum2=e} else{sum2=f} cout<<sum1+sum2; return 0; }
a.cc:1:1: error: 'include' does not name a type 1 | include<iostream> | ^~~~~~~ a.cc: In function 'int main()': a.cc:6:1: error: 'cin' was not declared in this scope 6 | cin>>a>>b>>c>>d>>e>>f; | ^~~ a.cc:8:10: error: 'sum1' was not declared in this scope 8 | {if(b>c){sum1=a+b} | ^~~~ a.cc:9:6: error: 'sum2' was not declared in this scope 9 | else{sum2=a+c} | ^~~~ a.cc:12:10: error: 'sum1' was not declared in this scope 12 | {if(a>c){sum1=b+a} | ^~~~ a.cc:13:6: error: 'sum1' was not declared in this scope 13 | else{sum1=b+c} | ^~~~ a.cc:16:10: error: 'sum1' was not declared in this scope 16 | {if(a>b){sum1=c+a} | ^~~~ a.cc:17:6: error: 'sum1' was not declared in this scope 17 | else{sum1=c+b} | ^~~~ a.cc:19:9: error: 'sum2' was not declared in this scope 19 | if(e>f){sum2=e} | ^~~~ a.cc:20:6: error: 'sum2' was not declared in this scope 20 | else{sum2=f} | ^~~~ a.cc:22:1: error: 'cout' was not declared in this scope 22 | cout<<sum1+sum2; | ^~~~ a.cc:22:7: error: 'sum1' was not declared in this scope 22 | cout<<sum1+sum2; | ^~~~ a.cc:22:12: error: 'sum2' was not declared in this scope 22 | cout<<sum1+sum2; | ^~~~
s351049481
p00542
C++
#include <iostream> using namespace std; int main(void) { int a,b,c[100]={0},d,e=0,f=0,g,h,i; for (a=0;a<4;a++) { cin>>b; c[b]=1; } for (a=99;a>0;a--) { if (c[b]==1&&e!=3) { f=f+b; e++; } cin>>d>>e; if (d>=e) { g=d+f; } else { g=e+f; } cout<<g<<endl; return 0; }
a.cc: In function 'int main()': a.cc:29:2: error: expected '}' at end of input 29 | } | ^ a.cc:4:1: note: to match this '{' 4 | { | ^
s452015214
p00542
C++
#include<iostream> using namespace std; int i, sumrika=0, sumsha=0, t, u, cnt=0; int minrika=110, minsha=110; int rika[5], dha[3]; int main(){ for(i=1; i<=4; i++){ cin>>rika[i]; sumrika+=rika[i]; if(rika[i]<minrika){minrika=rika[i];} } for(i=1; i<=2; i++){ cin>>sha[i]; sumsha+=sha[i]; if(sha[i]<minsha){minsha=sha[i];} } int disp = (sumrika-minrika)+(sumsha-minsha); cout << disp << endl; }
a.cc: In function 'int main()': a.cc:12:10: error: 'sha' was not declared in this scope; did you mean 'dha'? 12 | cin>>sha[i]; sumsha+=sha[i]; | ^~~ | dha
s441163361
p00542
C++
#include<iostream> using namespace std; int a[4],b[2]; int main(){ cin>>a[0]>>a[1]>>a[2]>>a[3]>>b[0]>>b[1]; sort(a,a+4);sort(b,b+2); cout<<a[1]+a[2]+a[3]+b[1]<<endl; }
a.cc: In function 'int main()': a.cc:9:5: error: 'sort' was not declared in this scope; did you mean 'short'? 9 | sort(a,a+4);sort(b,b+2); | ^~~~ | short
s658458428
p00542
C++
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { vector<int> s1; vector<int> s2; int S1, S2; for(int i; i < 4; i++) { cin >> S1; s1.push_back(S1); } for(int i; i < 2; i++) { cin >> S2; s2.push_back(S2); } sort(s1.begin(), s1.end(), greater<int>); sort(s2.begin(), s2.end(), greater<int>); int sum = 0; for(int i = 0; i < 3; i++) { sum += s1[i]; } for(int i = 0; i < 2; i++) { sum += s2[i]; } cout << sum << endl; return 0; }
a.cc: In function 'int main()': a.cc:22:42: error: expected primary-expression before ')' token 22 | sort(s1.begin(), s1.end(), greater<int>); | ^ a.cc:23:42: error: expected primary-expression before ')' token 23 | sort(s2.begin(), s2.end(), greater<int>); | ^