submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3 values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s823089541 | p03940 | C++ | #include <bits/stdc++.h>
#define SZ(x) ((int) (x).size())
using namespace std;
typedef long long i64;
int main() {
#ifdef LOCAL_RUN
freopen("task.in", "r", stdin);
freopen("task.out", "w", stdout);
//freopen("task.err", "w", stderr);
#endif // ONLINE_JUDGE
ios::sync_with_stdio(false);
cin.tie(0);
int n, E, T;
cin >> n >> E >> T;
vector<int> X(n + 1, 0);
for (int i = 1; i <= n; ++i) {
cin >> X[i];
}
vector<int64_t> dp(n + 1, 0);
for (int i = 1; i <= n; ++i) {
dp[i] = 1LL << 62;
for (int j = i - 1; j >= 0; --j) {
dp[i] = min(dp[i], dp[j] + X[j + 1] - X[j] +
3LL * (X[i] - X[j + 1]) + max(0LL, T - 2LL * (X[i] - X[j + 1])));
}
}
int64_t ans = dp[n] + E - X[n];
cout << ans << '\n';
} | a.cc: In function 'int main()':
a.cc:28:24: error: no matching function for call to 'min(__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type&, long long int)'
28 | dp[i] = min(dp[i], dp[j] + X[j + 1] - X[j] +
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
29 | 3LL * (X[i] - X[j + 1]) + max(0LL, T - 2LL * (X[i] - X[j + 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:28:24: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
28 | dp[i] = min(dp[i], dp[j] + X[j + 1] - X[j] +
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
29 | 3LL * (X[i] - X[j + 1]) + max(0LL, T - 2LL * (X[i] - X[j + 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:28:24: note: mismatched types 'std::initializer_list<_Tp>' and 'long int'
28 | dp[i] = min(dp[i], dp[j] + X[j + 1] - X[j] +
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
29 | 3LL * (X[i] - X[j + 1]) + max(0LL, T - 2LL * (X[i] - X[j + 1])));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s376759990 | p03940 | C++ | #include <iostream>
#define NMAX 100000
using namespace std;
int min[NMAX], max[NMAX];
long long c[NMAX], dp[NMAX];
int n;
long long e, t;
long long mxm(long long a, long long b);
int main()
{
cin >> n >> e >> t;
int prec = -1e9, m = 0, cit;
while (n--) {
cin >> cit;
if (cit - prec > t) {
m++;
min[m] = cit;
}
max[m] = cit;
prec = cit;
}
for (int i = 1; i <= m; i++)
c[i] = mxm(2ll * (max[i] - min[i]), t) + max[i] - min[i];
for (int i = 1; i <= m; i++)
dp[i] = dp[i - 1] + c[i] + 1ll * (min[i] - max[i - 1]);
cout << (long long) dp[m] + e - max[m];
return 0;
}
long long mxm(long long a, long long b)
{
if (a > b)
return a;
return b;
}
| a.cc: In function 'int main()':
a.cc:21:25: error: reference to 'min' is ambiguous
21 | min[m] = cit;
| ^~~
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:281:5: note: candidates are: '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:233:5: note: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
a.cc:5:5: note: 'int min [100000]'
5 | int min[NMAX], max[NMAX];
| ^~~
a.cc:23:17: error: reference to 'max' is ambiguous
23 | max[m] = cit;
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: '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:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
a.cc:5:16: note: 'int max [100000]'
5 | int min[NMAX], max[NMAX];
| ^~~
a.cc:28:35: error: reference to 'max' is ambiguous
28 | c[i] = mxm(2ll * (max[i] - min[i]), t) + max[i] - min[i];
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: '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:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
a.cc:5:16: note: 'int max [100000]'
5 | int min[NMAX], max[NMAX];
| ^~~
a.cc:28:44: error: reference to 'min' is ambiguous
28 | c[i] = mxm(2ll * (max[i] - min[i]), t) + max[i] - min[i];
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidates are: '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:233:5: note: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
a.cc:5:5: note: 'int min [100000]'
5 | int min[NMAX], max[NMAX];
| ^~~
a.cc:28:58: error: reference to 'max' is ambiguous
28 | c[i] = mxm(2ll * (max[i] - min[i]), t) + max[i] - min[i];
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: '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:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
a.cc:5:16: note: 'int max [100000]'
5 | int min[NMAX], max[NMAX];
| ^~~
a.cc:28:67: error: reference to 'min' is ambiguous
28 | c[i] = mxm(2ll * (max[i] - min[i]), t) + max[i] - min[i];
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidates are: '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:233:5: note: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
a.cc:5:5: note: 'int min [100000]'
5 | int min[NMAX], max[NMAX];
| ^~~
a.cc:31:51: error: reference to 'min' is ambiguous
31 | dp[i] = dp[i - 1] + c[i] + 1ll * (min[i] - max[i - 1]);
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidates are: '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:233:5: note: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
a.cc:5:5: note: 'int min [100000]'
5 | int min[NMAX], max[NMAX];
| ^~~
a.cc:31:60: error: reference to 'max' is ambiguous
31 | dp[i] = dp[i - 1] + c[i] + 1ll * (min[i] - max[i - 1]);
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: '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:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
a.cc:5:16: note: 'int max [100000]'
5 | int min[NMAX], max[NMAX];
| ^~~
a.cc:33:41: error: reference to 'max' is ambiguous
33 | cout << (long long) dp[m] + e - max[m];
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: '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:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
a.cc:5:16: note: 'int max [100000]'
5 | int min[NMAX], max[NMAX];
| ^~~
|
s702468081 | p03940 | C++ | #include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <bitset>
#include <cassert>
using namespace std;
const int MAXN = 100009;
const long long INF = 1000000000000000000;
struct SegmentTree {
long long tr_min[4 * MAXN];
long long tr_add[4 * MAXN];
int n;
SegmentTree(int n) : n(n) {
memset(tr_min, 0, sizeof(tr_min));
memset(tr_add, 0, sizeof(tr_add));
}
void setVal(int id, long long val) {
setVal(0, 0, n, id, val);
}
void setVal(int v, int vl, int vr, int id, long long val) {
push(v, vl, vr);
if (vl > id || vr <= id) {
return;
}
if (vr - vl == 1) {
tr_min[v] = val;
return;
}
int vm = (vl + vr) / 2;
setVal(2 * v + 1, vl, vm, id, val);
setVal(2 * v + 2, vm, vr, id, val);
tr_min[v] = min(tr_min[2 * v + 1], tr_min[2 * v + 2]);
}
void addTree(int l, int r, long long val) {
if (l > r)
return;
addTree(0, 0, n, l, r + 1, val);
}
long long getMin(int l, int r) {
return getMax(0, 0, n, l, r + 1);
}
void push(int v, int vl, int vr) {
tr_min[v] += tr_add[v];
if (vr - vl > 1) {
tr_add[2 * v + 1] += tr_add[v];
tr_add[2 * v + 2] += tr_add[v];
}
tr_add[v] = 0;
}
void addTree(int v, int vl, int vr, int l, int r, long long val) {
push(v, vl, vr);
if (vl >= r || l >= vr) {
return;
}
if (vl >= l && vr <= r) {
tr_add[v] += val;
push(v, vl, vr);
return;
}
int vm = (vl + vr) / 2;
addTree(2 * v + 1, vl, vm, l, r, val);
addTree(2 * v + 2, vm, vr, l, r, val);
tr_min[v] = min(tr_min[2 * v + 1], tr_min[2 * v + 2]);
}
long long getMax(int v, int vl, int vr, int l, int r) {
push(v, vl, vr);
if (vl >= r || l >= vr) {
return INF;
}
if (vl >= l && vr <= r) {
return tr_min[v];
}
int vm = (vl + vr) / 2;
long long max1 = getMax(2 * v + 1, vl, vm, l, r);
long long max2 = getMax(2 * v + 2, vm, vr, l, r);
return min(max1, max2);
}
};
long long x[MAXN];
long long f[MAXN];
int main() {
int n, e, t;
cin >> n >> e >> t;
for (int i = 1; i <= n; ++i)
cin >> x[i];
x[0] = 0;
f[0] = 0;
SegmentTree tree(n);
tree.addTree(0, 0, x[1] - x[0] + t);
int idt = 0;
for (int i = 1; i <= n; ++i) {
f[i] = tree.getMin(0, i - 1);
if (i == n)
break;
int pidt = idt;
while ((x[i + 1] - x[idt + 1]) * 2 > t) {
tree.setVal(idt, x[i + 1] - x[idt] + (x[i + 1] - x[idt + 1]) * 2);
++idt;
}
tree.setVal(i, f[i] + x[i + 1] - x[i] + t);
tree.addTree(idt, i - 1, x[i + 1] - x[i]);
tree.addTree(0, pidt - 1, 3 * (x[i + 1] - x[i]));
}
long long ans = f[n] + e - x[n];
cout << ans << endl;
} | a.cc: In constructor 'SegmentTree::SegmentTree(int)':
a.cc:21:9: error: 'memset' was not declared in this scope
21 | memset(tr_min, 0, sizeof(tr_min));
| ^~~~~~
a.cc:9:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
8 | #include <cassert>
+++ |+#include <cstring>
9 |
|
s081435502 | p03940 | C++ | #include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <functional>
#include <set>
#include <ctime>
#include <random>
#include <chrono>
#include <cassert>
#include <tuple>
#include <utility>
using namespace std;
namespace {
using Integer = long long; //__int128;
template<class T, class S> istream& operator >> (istream& is, pair<T,S>& p){return is >> p.first >> p.second;}
template<class T> istream& operator >> (istream& is, vector<T>& vec){for(T& val: vec) is >> val; return is;}
template<class T> istream& operator , (istream& is, T& val){ return is >> val;}
template<class T, class S> ostream& operator << (ostream& os, const pair<T,S>& p){return os << p.first << " " << p.second;}
template<class T> ostream& operator << (ostream& os, const vector<T>& vec){for(size_t i=0; i<vec.size(); i++) os << vec[i] << (i==vec.size()-1?"":" "); return os;}
template<class T> ostream& operator , (ostream& os, const T& val){ return os << " " << val;}
template<class H> void print(const H& head){ cout << head; }
template<class H, class ... T> void print(const H& head, const T& ... tail){ cout << head << " "; print(tail...); }
template<class ... T> void println(const T& ... values){ print(values...); cout << endl; }
template<class H> void eprint(const H& head){ cerr << head; }
template<class H, class ... T> void eprint(const H& head, const T& ... tail){ cerr << head << " "; eprint(tail...); }
template<class ... T> void eprintln(const T& ... values){ eprint(values...); cerr << endl; }
class range{ Integer start_, end_, step_; public: struct range_iterator{ Integer val, step_; range_iterator(Integer v, Integer step) : val(v), step_(step) {} Integer operator * (){return val;} void operator ++ (){val += step_;} bool operator != (range_iterator& x){return step_ > 0 ? val < x.val : val > x.val;} }; range(Integer len) : start_(0), end_(len), step_(1) {} range(Integer start, Integer end) : start_(start), end_(end), step_(1) {} range(Integer start, Integer end, Integer step) : start_(start), end_(end), step_(step) {} range_iterator begin(){ return range_iterator(start_, step_); } range_iterator end(){ return range_iterator( end_, step_); } };
inline string operator "" _s (const char* str, size_t size){ return move(string(str)); }
constexpr Integer my_pow(Integer x, Integer k, Integer z=1){return k==0 ? z : k==1 ? z*x : (k&1) ? my_pow(x*x,k>>1,z*x) : my_pow(x*x,k>>1,z);}
constexpr Integer my_pow_mod(Integer x, Integer k, Integer M, Integer z=1){return k==0 ? z%M : k==1 ? z*x%M : (k&1) ? my_pow_mod(x*x%M,k>>1,M,z*x%M) : my_pow_mod(x*x%M,k>>1,M,z);}
constexpr unsigned long long operator "" _ten (unsigned long long value){ return my_pow(10,value); }
inline int k_bit(Integer x, int k){return (x>>k)&1;} //0-indexed
mt19937 mt(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count());
template<class T> string join(const vector<T>& v, const string& sep){ stringstream ss; for(size_t i=0; i<v.size(); i++){ if(i>0) ss << sep; ss << v[i]; } return ss.str(); }
inline string operator * (string s, int k){ string ret; while(k){ if(k&1) ret += s; s += s; k >>= 1; } return ret; }
}
constexpr long long mod = 9_ten + 7;
class starry_sky_tree{
public:
static const int MAX_SIZE = 1 << 17; //segment tree のサイズ。 2^17 ≒ 1.3 * 10^5
using Int = long long;
Int segMin[2 * MAX_SIZE - 1], segAdd[2 * MAX_SIZE - 1];
starry_sky_tree(){
fill(segMin, segMin + 2*MAX_SIZE-1, 0);
fill(segAdd, segAdd + 2*MAX_SIZE-1, 0);
}
//区間[a, b)に値xを加算する.
void add(int a, int b, Int x, int k = 0, int l = 0, int r = MAX_SIZE)
{
if (r <= a || b <= l) return; //もし交差しない区間であれば終える.
if (a <= l && r <= b){ //もし今みている区間[l, r)が[a, b)に完全に内包されていれば
segAdd[k] += x; //区間[l, r)にkを加算する.
return;
}
add(a, b, x, k * 2 + 1, l, (l + r) / 2); //子の区間に(必要があれば)xを加算する.
add(a, b, x, k * 2 + 2, (l + r) / 2, r); //〃
//親の区間の最小値は, 子の区間の最小値 + 自分に一様に加算されている値 である.一様に加算される値は更新しなくて良い.
segMin[k] = min(segMin[k * 2 + 1] + segAdd[k * 2 + 1], segMin[k * 2 + 2] + segAdd[k * 2 + 2]);
}
Int getMin(int a, int b, int k = 0, int l = 0, int r = MAX_SIZE)
{
if (r <= a || b <= l) return (LLONG_MAX);
if (a <= l && r <= b) return (segMin[k] + segAdd[k]); //完全に内包されていれば,その区間の最小値を返す.
Int left = getMin(a, b, k * 2 + 1, l, (l + r) / 2); //子の区間の最小値を求める.
Int right = getMin(a, b, k * 2 + 2, (l + r) / 2, r); //子の区間の最小値を求める
return (min(left, right) + segAdd[k]); //親の区間の最小値は, 子の区間の最小値 + 自分に一様に加算されている値 である (大切なので2回書きました!!)
}
};
int main(){
int n;
long long e,t;
cin >> n,e,t;
//assert(n<=2000);
vector<long long> x(n);
cin >> x;
x.push_back(e);
x.push_back(1ll<<57);
starry_sky_tree a, b;
vector<long long> dp(n+1, 1ll<<57);
dp[0] = 0;
for(int i=0, j=0; i<n; i++){
while(j<i && t < 2*(x[i] - x[j]) ){
j++;
}
if(j) dp[i+1] = min(dp[i+1], a.getMin(0, j));
dp[i+1] = min(dp[i+1], t+ b.getMin(j, i+1));
a.add(0,i+1, 2*(x[i+1]-x[i]));
b.add(i+1, i+2, dp[i+1]);
}
println(dp[n] + e);
//eprintln(join(dp, " "));
return 0;
}
| a.cc: In member function 'starry_sky_tree::Int starry_sky_tree::getMin(int, int, int, int, int)':
a.cc:85:35: error: 'LLONG_MAX' was not declared in this scope
85 | if (r <= a || b <= l) return (LLONG_MAX);
| ^~~~~~~~~
a.cc:18:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
17 | #include <utility>
+++ |+#include <climits>
18 | using namespace std;
|
s990307341 | p03940 | C++ | #include <string>
#include <iostream>
#include <vector>
using namespace std;
int main(){
long long int N, E, T, tot = 0;
cin >> N >> E >> T;
long long int x[N];
for(int i; i<N; i++){
tot += min(2*T+x[i+1]-x[i], 2*(x[i+1]-x[i])+ max(0, T-(x[i+1]-x[i])) + max(0, T-2*(x[i+1]-x[i]));
}
tot+=x[0]+(E-x[N-1]);
cout << tot << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:13:53: error: no matching function for call to 'max(int, long long int)'
13 | tot += min(2*T+x[i+1]-x[i], 2*(x[i+1]-x[i])+ max(0, T-(x[i+1]-x[i])) + max(0, T-2*(x[i+1]-x[i]));
| ~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
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:13:53: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
13 | tot += min(2*T+x[i+1]-x[i], 2*(x[i+1]-x[i])+ max(0, T-(x[i+1]-x[i])) + max(0, T-2*(x[i+1]-x[i]));
| ~~~^~~~~~~~~~~~~~~~~~~~
/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
a.cc:13:79: error: no matching function for call to 'max(int, long long int)'
13 | tot += min(2*T+x[i+1]-x[i], 2*(x[i+1]-x[i])+ max(0, T-(x[i+1]-x[i])) + max(0, T-2*(x[i+1]-x[i]));
| ~~~^~~~~~~~~~~~~~~~~~~~~~
/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:13:79: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
13 | tot += min(2*T+x[i+1]-x[i], 2*(x[i+1]-x[i])+ max(0, T-(x[i+1]-x[i])) + max(0, T-2*(x[i+1]-x[i]));
| ~~~^~~~~~~~~~~~~~~~~~~~~~
/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
|
s756416651 | p03940 | Java | Int();
t = in.nextInt();
x = new int[n];
for (int i = 0; i < n; ++i)
x[i] = in.nextInt();
if (n == 1) {
out.println(e + t);
return;
}
long ans = x[0];
int idx = 0;
while (idx < n - 1) {
long cnt = 2;
int nxt = idx;
long temp = (x[nxt] - x[idx]) + cnt * t;
while (nxt < n && (long) Math.max(t, 2 * (x[nxt] - x[idx])) + (x[nxt] - x[idx]) < (x[nxt] - x[idx]) + cnt * t) {
temp = (long) Math.max(t, 2 * (x[nxt] - x[idx])) + (x[nxt] - x[idx]);
++nxt;
++cnt;
}
ans += temp;
if (nxt < n)
ans += x[nxt] - x[nxt - 1];
if (nxt == n - 1)
ans += t;
idx = nxt;
}
ans += e - x[n - 1];
out.println(ans);
}
}
static class InputReader {
public BufferedReader reader;
public StringTokenizer tokenizer;
public InputReader(InputStream stream) {
reader = new BufferedReader(new InputStreamReader(stream));
tokenizer = null;
}
public String next() {
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(reader.readLine());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
}
public String nextLine() {
try {
return reader.readLine();
} catch(IOException e) {
throw new RuntimeException(e);
}
}
public int nextInt() {
return Integer.parseInt(next());
}
public long nextLong() {
return Long.parseLong(next());
}
public double nextDouble() {
return Double.parseDouble(next());
}
public boolean hasInput() {
try {
if (tokenizer != null && tokenizer.hasMoreTokens()) {
return true;
}
reader.mark(1);
int ch = reader.read();
if (ch != -1) {
reader.reset();
return true;
}
return false;
} catch(IOException e) {
throw new RuntimeException(e);
}
}
}
}
| Main.java:1: error: class, interface, enum, or record expected
Int();
^
Main.java:2: error: class, interface, enum, or record expected
t = in.nextInt();
^
Main.java:3: error: class, interface, enum, or record expected
x = new int[n];
^
Main.java:4: error: class, interface, enum, or record expected
for (int i = 0; i < n; ++i)
^
Main.java:4: error: class, interface, enum, or record expected
for (int i = 0; i < n; ++i)
^
Main.java:4: error: class, interface, enum, or record expected
for (int i = 0; i < n; ++i)
^
Main.java:6: error: class, interface, enum, or record expected
if (n == 1) {
^
Main.java:8: error: class, interface, enum, or record expected
return;
^
Main.java:9: error: class, interface, enum, or record expected
}
^
Main.java:11: error: unnamed classes are a preview feature and are disabled by default.
int idx = 0;
^
(use --enable-preview to enable unnamed classes)
Main.java:12: error: class, interface, enum, or record expected
while (idx < n - 1) {
^
Main.java:16: error: class, interface, enum, or record expected
while (nxt < n && (long) Math.max(t, 2 * (x[nxt] - x[idx])) + (x[nxt] - x[idx]) < (x[nxt] - x[idx]) + cnt * t) {
^
Main.java:18: error: class, interface, enum, or record expected
++nxt;
^
Main.java:19: error: class, interface, enum, or record expected
++cnt;
^
Main.java:20: error: class, interface, enum, or record expected
}
^
Main.java:22: error: class, interface, enum, or record expected
if (nxt < n)
^
Main.java:24: error: class, interface, enum, or record expected
if (nxt == n - 1)
^
Main.java:26: error: class, interface, enum, or record expected
idx = nxt;
^
Main.java:27: error: class, interface, enum, or record expected
}
^
Main.java:29: error: class, interface, enum, or record expected
out.println(ans);
^
Main.java:30: error: class, interface, enum, or record expected
}
^
Main.java:92: error: class, interface, enum, or record expected
}
^
22 errors
|
s167239524 | p03940 | C++ | #include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }
const ll INF = 1e15;
int main(){
ll N, E, T;
ll x[100005]={};
cin >> N >> E >> T;
rep(i,N) cin >> x[i];
x[N] = E;
N = min(N, 2000);
ll dp[2][100005]={};
rep(i,N){
Fill( dp[(i+1)%2], INF );
ll dist = x[i+1] - x[i];
rep(j,i+1){
chmin( dp[(i+1)%2][j], dp[i%2][j] + dist );
ll back = (x[i] - x[j]) * 2;
ll t = max( back, T );
chmin( dp[(i+1)%2][i+1], dp[i%2][j] + t + dist );
}
//rep(j,N+1) cout << dp[(i+1)%2][j] << " "; cout << endl;
}
ll ans = dp[N%2][N] + x[0];// + E-x[N-1];
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:31:16: error: no matching function for call to 'min(ll&, int)'
31 | N = min(N, 2000);
| ~~~^~~~~~~~~
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:31:16: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
31 | N = min(N, 2000);
| ~~~^~~~~~~~~
/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:5:
/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:31:16: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
31 | N = min(N, 2000);
| ~~~^~~~~~~~~
|
s115643119 | p03940 | C++ | #include <bits/stdc++.h>
using namespace std;
void chmin(int64_t &x, int64_t y) {
if (x > y) x = y;
}
int64_t dp[2020][2020];
int main() {
int n;
int64_t T, E;
cin >> n >> E >> T;
vector<long long> x(n);
for (int i = 0; i < n; i++) scanf("%lld", &x[i]);
vector<int64_t> d(n), ds(n + 1);
for (int i = 0; i < n - 1; i++) d[i] = x[i + 1] - x[i];
for (int i = 0; i < n; i++) ds[i + 1] = ds[i] + d[i];
if (n > 2000) return 0;
fill_n(*dp, 2020 * 2020, 1e17);
dp[0][0] = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j <= i; j++) {
// wait
if (j == 0) {
chmin(dp[i + 1][0], dp[i][j] + T + d[i]);
}
// return
if (j > 0) {
int64_t dist = ds[i] - ds[i - j];
chmin(dp[i + 1][0], dp[i][j] + d[i] + max(0LL, T - 2 * dist) + dist * 2);
}
// ignore
if (i < n - 1) {
chmin(dp[i + 1][j + 1], dp[i][j] + d[i]);
}
}
}
int64_t ans = dp[n][0] + x[0] + (E - x[n - 1]);
cout << ans << endl;
}
| a.cc: In function 'int main()':
a.cc:35:58: error: no matching function for call to 'max(long long int, int64_t)'
35 | chmin(dp[i + 1][0], dp[i][j] + d[i] + max(0LL, T - 2 * dist) + dist * 2);
| ~~~^~~~~~~~~~~~~~~~~~~
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: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:35:58: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int64_t' {aka 'long int'})
35 | chmin(dp[i + 1][0], dp[i][j] + d[i] + max(0LL, T - 2 * dist) + dist * 2);
| ~~~^~~~~~~~~~~~~~~~~~~
/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:
/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:35:58: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
35 | chmin(dp[i + 1][0], dp[i][j] + d[i] + max(0LL, T - 2 * dist) + dist * 2);
| ~~~^~~~~~~~~~~~~~~~~~~
|
s000222803 | p03940 | C++ | #include <bits/stdc++.h>
using namespace std;
void chmin(int64_t &x, int64_t y) {
if (x > y) x = y;
}
int64_t dp[2020][2020];
int main() {
int n;
int64_t T, E;
cin >> n >> E >> T;
vector<int64_t> x(n);
for (int i = 0; i < n; i++) scanf("%I64d", &x[i]);
vector<int64_t> d(n), ds(n + 1);
for (int i = 0; i < n - 1; i++) d[i] = x[i + 1] - x[i];
for (int i = 0; i < n; i++) ds[i + 1] = ds[i] + d[i];
if (n > 2000) return 0;
fill_n(*dp, 2020 * 2020, 1e17);
dp[0][0] = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j <= i; j++) {
// wait
if (j == 0) {
chmin(dp[i + 1][0], dp[i][j] + T + d[i]);
}
// return
if (j > 0) {
int64_t dist = ds[i] - ds[i - j];
chmin(dp[i + 1][0], dp[i][j] + d[i] + max(0LL, T - 2 * dist) + dist * 2);
}
// ignore
if (i < n - 1) {
chmin(dp[i + 1][j + 1], dp[i][j] + d[i]);
}
}
}
int64_t ans = dp[n][0] + x[0] + (E - x[n - 1]);
cout << ans << endl;
}
| a.cc: In function 'int main()':
a.cc:35:58: error: no matching function for call to 'max(long long int, int64_t)'
35 | chmin(dp[i + 1][0], dp[i][j] + d[i] + max(0LL, T - 2 * dist) + dist * 2);
| ~~~^~~~~~~~~~~~~~~~~~~
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: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:35:58: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int64_t' {aka 'long int'})
35 | chmin(dp[i + 1][0], dp[i][j] + d[i] + max(0LL, T - 2 * dist) + dist * 2);
| ~~~^~~~~~~~~~~~~~~~~~~
/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:
/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:35:58: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
35 | chmin(dp[i + 1][0], dp[i][j] + d[i] + max(0LL, T - 2 * dist) + dist * 2);
| ~~~^~~~~~~~~~~~~~~~~~~
|
s399442094 | p03940 | C++ | #include <bits/stdc++.h>
using namespace std;
void chmin(int64_t &x, int64_t y) {
if (x > y) x = y;
}
int64_t dp[2020][2020];
int main() {
int n;
int64_t T, E;
cin >> n >> E >> T;
vector<int64_t> x(n);
for (int i = 0; i < n; i++) scanf("%lld", &x[i]);
vector<int64_t> d(n), ds(n + 1);
for (int i = 0; i < n - 1; i++) d[i] = x[i + 1] - x[i];
for (int i = 0; i < n; i++) ds[i + 1] = ds[i] + d[i];
if (n > 2000) return 0;
fill_n(*dp, 2020 * 2020, 1e17);
dp[0][0] = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j <= i; j++) {
// wait
if (j == 0) {
chmin(dp[i + 1][0], dp[i][j] + T + d[i]);
}
// return
if (j > 0) {
int64_t dist = ds[i] - ds[i - j];
chmin(dp[i + 1][0], dp[i][j] + d[i] + max(0LL, T - 2 * dist) + dist * 2);
}
// ignore
if (i < n - 1) {
chmin(dp[i + 1][j + 1], dp[i][j] + d[i]);
}
}
}
int64_t ans = dp[n][0] + x[0] + (E - x[n - 1]);
cout << ans << endl;
}
| a.cc: In function 'int main()':
a.cc:35:58: error: no matching function for call to 'max(long long int, int64_t)'
35 | chmin(dp[i + 1][0], dp[i][j] + d[i] + max(0LL, T - 2 * dist) + dist * 2);
| ~~~^~~~~~~~~~~~~~~~~~~
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: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:35:58: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int64_t' {aka 'long int'})
35 | chmin(dp[i + 1][0], dp[i][j] + d[i] + max(0LL, T - 2 * dist) + dist * 2);
| ~~~^~~~~~~~~~~~~~~~~~~
/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:
/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:35:58: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
35 | chmin(dp[i + 1][0], dp[i][j] + d[i] + max(0LL, T - 2 * dist) + dist * 2);
| ~~~^~~~~~~~~~~~~~~~~~~
|
s234166920 | p03941 | C++ | #include <bits/stdc++.h>
const int MAXN = 131083;
typedef long long LL;
typedef std::pair<LL, LL> pi;
typedef std::vector<pi> vec;
int son[MAXN][2], val[MAXN][2], n;
LL mid;
vec dfs(int u) {
if (!son[u][0]) return vec({pi(0, 0)});
vec lhs = dfs(son[u][0]), rhs = dfs(son[u][1]), r1, r2, r3, r4;
for (auto & t : lhs) t.first += val[u][0], t.second += val[u][0];
for (auto & t : rhs) t.first += val[u][1], t.second += val[u][1];
if (lhs.size() > rhs.size()) std::swap(lhs, rhs);
const int rs = rhs.size();
int cur1 = 0, cur2 = rs - 1;
for (auto t : lhs) {
while (cur1 < rs && rhs[cur1].second + t.first > mid) ++cur1;
while (cur2 >= 0 && rhs[cur2].first + t.second > mid) --cur2;
if (cur1 < rs) r1.emplace_back(rhs[cur1].first, t.second);
if (cur2 >= 0) r2.emplace_back(t.first, rhs[cur2].second);
}
std::reverse(r1.begin(), r1.end());
std::merge(r1.begin(), r1.end(), r2.begin(), r2.end(), std::back_inserter(r3));
for (auto t : r3) if (r4.empty() || t.second < r4.back().second) r4.push_back(t);
return r4;
}
int main() {
std::ios_base::sync_with_stdio(false), std::cin.tie(0);
std::cin >> n; LL r = 0;
for (int i = 2, t; i <= n; ++i) {
std::cin >> t;
int at = !!son[t][0];
std::cin >> val[t][at]; r += val[t][at];
son[t][at] = i;
}
LL ans = -1;
for (LL l = 0; l <= r; mid = l + r >> 1, !dfs(1).empty()
? (ans = mid, r = mid - 1) : l = mid + 1);
std::cout << ans << std::endl;
return 0;
}
#include <bits/stdc++.h>
const int MAXN = 131083;
typedef long long LL;
typedef std::pair<LL, LL> pi;
typedef std::vector<pi> vec;
int son[MAXN][2], val[MAXN][2], n;
LL mid;
vec dfs(int u) {
if (!son[u][0]) return vec({pi(0, 0)});
vec lhs = dfs(son[u][0]), rhs = dfs(son[u][1]), r1, r2, r3, r4;
for (auto & t : lhs) t.first += val[u][0], t.second += val[u][0];
for (auto & t : rhs) t.first += val[u][1], t.second += val[u][1];
if (lhs.size() > rhs.size()) std::swap(lhs, rhs);
const int rs = rhs.size();
int cur1 = 0, cur2 = rs - 1;
for (auto t : lhs) {
while (cur1 < rs && rhs[cur1].second + t.first > mid) ++cur1;
while (cur2 >= 0 && rhs[cur2].first + t.second > mid) --cur2;
if (cur1 < rs) r1.emplace_back(rhs[cur1].first, t.second);
if (cur2 >= 0) r2.emplace_back(t.first, rhs[cur2].second);
}
std::reverse(r1.begin(), r1.end());
std::merge(r1.begin(), r1.end(), r2.begin(), r2.end(), std::back_inserter(r3));
for (auto t : r3) if (r4.empty() || t.second < r4.back().second) r4.push_back(t);
return r4;
}
int main() {
std::ios_base::sync_with_stdio(false), std::cin.tie(0);
std::cin >> n; LL r = 0;
for (int i = 2, t; i <= n; ++i) {
std::cin >> t;
int at = !!son[t][0];
std::cin >> val[t][at]; r += val[t][at];
son[t][at] = i;
}
LL ans = -1;
for (LL l = 0; l <= r; mid = l + r >> 1, !dfs(1).empty()
? (ans = mid, r = mid - 1) : l = mid + 1);
std::cout << ans << std::endl;
return 0;
}
| a.cc:46:11: error: redefinition of 'const int MAXN'
46 | const int MAXN = 131083;
| ^~~~
a.cc:3:11: note: 'const int MAXN' previously defined here
3 | const int MAXN = 131083;
| ^~~~
a.cc:50:5: error: redefinition of 'int son [131083][2]'
50 | int son[MAXN][2], val[MAXN][2], n;
| ^~~
a.cc:7:5: note: 'int son [131083][2]' previously declared here
7 | int son[MAXN][2], val[MAXN][2], n;
| ^~~
a.cc:50:19: error: redefinition of 'int val [131083][2]'
50 | int son[MAXN][2], val[MAXN][2], n;
| ^~~
a.cc:7:19: note: 'int val [131083][2]' previously declared here
7 | int son[MAXN][2], val[MAXN][2], n;
| ^~~
a.cc:50:33: error: redefinition of 'int n'
50 | int son[MAXN][2], val[MAXN][2], n;
| ^
a.cc:7:33: note: 'int n' previously declared here
7 | int son[MAXN][2], val[MAXN][2], n;
| ^
a.cc:51:4: error: redefinition of 'LL mid'
51 | LL mid;
| ^~~
a.cc:8:4: note: 'LL mid' previously declared here
8 | LL mid;
| ^~~
a.cc:53:5: error: redefinition of 'vec dfs(int)'
53 | vec dfs(int u) {
| ^~~
a.cc:10:5: note: 'vec dfs(int)' previously defined here
10 | vec dfs(int u) {
| ^~~
a.cc:72:5: error: redefinition of 'int main()'
72 | int main() {
| ^~~~
a.cc:29:5: note: 'int main()' previously defined here
29 | int main() {
| ^~~~
|
s772597627 | p03941 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct star{int to,nxt,w;}a[1000010];
int head[1000010],cnt,n,fa[1000010],siz[1000010];
ll dis[1000010],a1,a2,b1,b2;
void add(int u,int v,int w){
cnt++;
a[cnt].to=v,a[cnt].nxt=head[u],a[cnt].w=w,head[u]=cnt;
}
struct data{
long long a,b;
bool operator <(data X) const{
if(X.a!=a)return a<X.a;
return b<X.b;
}
};
vector<data>X[1000010];
vector<data>v;
ll l,r,mid;
int ef(int l1,int l2,int x,int y){
if(l2==0)return l2;
int ll=0,rr=l2-1;
while(ll<rr-1){
int md=(ll+rr)>>1;
a2=X[y][md].a,b2=X[y][md].b;
if(b1+a2+dis[x]+dis[y]<=mid)ll=md;
else rr=md;
}
a2=X[y][rr].a,b2=X[y][rr].b;
if(b1+a2+dis[x]+dis[y]<=mid)return rr;
a2=X[y][ll].a,b2=X[y][ll].b;
if(b1+a2+dis[x]+dis[y]<=mid)return ll;
else return l2;
}
void update(int u){
int x=0,y=0;
for(int i=head[u];i;i=a[i].nxt){
int to=a[i].to;
if(to==fa[u])continue;
if(x==0)x=a[i].to;
else y=a[i].to;
}
if(siz[x]>siz[y])swap(x,y);
v.clear();
for(int i=0;i<X[x].size();i++){
a1=X[x][i].a,b1=X[x][i].b;
if(ef(X[x].size(),X[y].size(),x,y)>=X[y].size())continue;
long long aaa=a1+dis[x],bbb=b2+dis[y];
data xx;xx.a=aaa;xx.b=bbb;
v.push_back((data){xx});
aaa=b2+dis[y],bbb=a1+dis[x];
xx.a=aaa;xx.b=bbb;
v.push_back((data){xx});
}
sort(v.begin(),v.end());
int len=v.size();
long long maxx=1000000000000000000;
for(int i=0;i<len;i++)
if(v[i].b<maxx)X[u].push_back(v[i]),maxx=v[i].b;
}
void dfs(int u,int f){
int fl=0;
for(int i=head[u];i;i=a[i].nxt){
int to=a[i].to;
if(to==f)continue;
dis[to]=a[i].w;
dfs(to,u);
fl++;
if(fl==2)update(u);
}
if(fl==0) X[u].push_back((data){0,0});
}
void deal_first(int u,int f){
siz[u]=1;
for(int i=head[u];i;i=a[i].nxt){
int to=a[i].to;
if(to==f)continue;
fa[to]=u;
deal_first(to,u);
siz[u]+=siz[to];
}
}
int check(){
dfs(1,0);
return X[1].size()>0;
}
int main(){
scanf("%d",&n);
for(int i=2,fa,val;i<=n;i++){
scanf("%d%d",&fa,&val);
add(fa,i,val);add(i,fa,val);r+=val;
}
deal_first(1,0);
while(l<r-1){
mid=(l+r)>>1;
for(int i=1;i<=n;i++)X[i].clear();
if(check())r=mid;
else l=mid;
}
mid=l;
if(check())cout<<l<<endl;
else cout<<r<<endl;
}
| a.cc:18:12: error: template argument 1 is invalid
18 | vector<data>X[1000010];
| ^
a.cc:18:12: error: template argument 2 is invalid
a.cc:19:12: error: template argument 1 is invalid
19 | vector<data>v;
| ^
a.cc:19:12: error: template argument 2 is invalid
a.cc: In function 'int ef(int, int, int, int)':
a.cc:26:16: error: invalid types 'int[int]' for array subscript
26 | a2=X[y][md].a,b2=X[y][md].b;
| ^
a.cc:26:30: error: invalid types 'int[int]' for array subscript
26 | a2=X[y][md].a,b2=X[y][md].b;
| ^
a.cc:30:12: error: invalid types 'int[int]' for array subscript
30 | a2=X[y][rr].a,b2=X[y][rr].b;
| ^
a.cc:30:26: error: invalid types 'int[int]' for array subscript
30 | a2=X[y][rr].a,b2=X[y][rr].b;
| ^
a.cc:32:12: error: invalid types 'int[int]' for array subscript
32 | a2=X[y][ll].a,b2=X[y][ll].b;
| ^
a.cc:32:26: error: invalid types 'int[int]' for array subscript
32 | a2=X[y][ll].a,b2=X[y][ll].b;
| ^
a.cc: In function 'void update(int)':
a.cc:45:7: error: request for member 'clear' in 'v', which is of non-class type 'int'
45 | v.clear();
| ^~~~~
a.cc:46:24: error: request for member 'size' in 'X[x]', which is of non-class type 'int'
46 | for(int i=0;i<X[x].size();i++){
| ^~~~
a.cc:47:16: error: invalid types 'int[int]' for array subscript
47 | a1=X[x][i].a,b1=X[x][i].b;
| ^
a.cc:47:29: error: invalid types 'int[int]' for array subscript
47 | a1=X[x][i].a,b1=X[x][i].b;
| ^
a.cc:48:20: error: request for member 'size' in 'X[x]', which is of non-class type 'int'
48 | if(ef(X[x].size(),X[y].size(),x,y)>=X[y].size())continue;
| ^~~~
a.cc:48:32: error: request for member 'size' in 'X[y]', which is of non-class type 'int'
48 | if(ef(X[x].size(),X[y].size(),x,y)>=X[y].size())continue;
| ^~~~
a.cc:48:50: error: request for member 'size' in 'X[y]', which is of non-class type 'int'
48 | if(ef(X[x].size(),X[y].size(),x,y)>=X[y].size())continue;
| ^~~~
a.cc:50:9: error: reference to 'data' is ambiguous
50 | data xx;xx.a=aaa;xx.b=bbb;
| ^~~~
In file included from /usr/include/c++/14/string:53,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:11:8: note: 'struct data'
11 | struct data{
| ^~~~
a.cc:50:17: error: 'xx' was not declared in this scope; did you mean 'x'?
50 | data xx;xx.a=aaa;xx.b=bbb;
| ^~
| x
a.cc:51:11: error: request for member 'push_back' in 'v', which is of non-class type 'int'
51 | v.push_back((data){xx});
| ^~~~~~~~~
a.cc:51:22: error: reference to 'data' is ambiguous
51 | v.push_back((data){xx});
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:11:8: note: 'struct data'
11 | struct data{
| ^~~~
a.cc:54:11: error: request for member 'push_back' in 'v', which is of non-class type 'int'
54 | v.push_back((data){xx});
| ^~~~~~~~~
a.cc:54:22: error: reference to 'data' is ambiguous
54 | v.push_back((data){xx});
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:11:8: note: 'struct data'
11 | struct data{
| ^~~~
a.cc:56:12: error: request for member 'begin' in 'v', which is of non-class type 'int'
56 | sort(v.begin(),v.end());
| ^~~~~
a.cc:56:22: error: request for member 'end' in 'v', which is of non-class type 'int'
56 | sort(v.begin(),v.end());
| ^~~
a.cc:57:15: error: request for member 'size' in 'v', which is of non-class type 'int'
57 | int len=v.size();
| ^~~~
a.cc:60:13: error: invalid types 'int[int]' for array subscript
60 | if(v[i].b<maxx)X[u].push_back(v[i]),maxx=v[i].b;
| ^
a.cc:60:29: error: request for member 'push_back' in 'X[u]', which is of non-class type 'int'
60 | if(v[i].b<maxx)X[u].push_back(v[i]),maxx=v[i].b;
| ^~~~~~~~~
a.cc:60:40: error: invalid types 'int[int]' for array subscript
60 | if(v[i].b<maxx)X[u].push_back(v[i]),maxx=v[i].b;
| ^
a.cc:60:51: error: invalid types 'int[int]' for array subscript
60 | if(v[i].b<maxx)X[u].push_back(v[i]),maxx=v[i].b;
| ^
a.cc: In function 'void dfs(int, int)':
a.cc:72:20: error: request for member 'push_back' in 'X[u]', which is of non-class type 'int'
72 | if(fl==0) X[u].push_back((data){0,0});
| ^~~~~~~~~
a.cc:72:31: error: reference to 'data' is ambiguous
72 | if(fl==0) X[u].push_back((data){0,0});
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:11:8: note: 'struct data'
11 | struct data{
| ^~~~
a.cc: In function 'int check()':
a.cc:86:17: error: request for member 'size' in 'X[1]', which is of non-class type 'int'
86 | return X[1].size()>0;
| ^~~~
a.cc: In function 'int main()':
a.cc:97:35: error: request for member 'clear' in 'X[i]', which is of non-class type 'int'
97 | for(int i=1;i<=n;i++)X[i].clear();
| ^~~~~
|
s073839841 | p03941 | C++ | #include<bits/stdc++.h>
#define N 131075
#define INF 0x7fffffff
using namespace std;
struct edge
{
int a,b;
};
bool operator < (edge a,edge b)
{
if(a.a==b.a)return a.b<b.b;
return a.a<b.a;
}
int n,sum;
int cnt,head[N],to[N<<1],w[N<<1],nxt[N<<1];
int ch[N][2],pre[N],size[N];
vector<edge>g[N],o;
void adde(int u,int v,int wi)
{
to[++cnt]=v;
w[cnt]=wi;
nxt[cnt]=head[u];
head[u]=cnt;
}
void dfs(int u,int fa)
{
int tot=0;
size[u]=1;
for(int i=head[u];i;i=nxt[i])
{
if(to[i]!=fa)
{
ch[u][tot++]=to[i];
pre[to[i]]=w[i];
dfs(to[i],u);
size[u]+=size[to[i]];
}
}
}
bool get(int a,int b,int x,int b1,int &a2,int &b2)
{
int l=0,r=g[b].size()-1;
while(l<r-1)
{
int mid=(l+r)>>1;
a2=g[b][mid].a,b2=g[b][mid].b;
if(b1+pre[a]+pre[b]+a2<=x)l=mid;
else r
.0=mid;
}
a2=g[b][r].a,b2=g[b][r].b;
if(b1+pre[a]+pre[b]+a2<=x)return true;
a2=g[b][l].a,b2=g[b][l].b;
if(b1+pre[a]+pre[b]+a2<=x)return true;
return false;
}
void merge(int u,int x)
{
if(ch[u][0])
{
int a=ch[u][0],b=ch[u][1];
merge(a,x),merge(b,x);
o.clear();
if(size[a]>size[b])swap(a,b);
if(!g[a].size()||!g[b].size())
return;
for(int i=0;i<g[a].size();i++)
{
int a1=g[a][i].a,b1=g[a][i].b,a2,b2;
if(!get(a,b,x,b1,a2,b2))
return;
o.push_back((edge){a1+pre[a],b2+pre[b]});
o.push_back((edge){b2+pre[b],a1+pre[a]});
}
sort(o.begin(),o.end());
int minn=INF;
for(int i=0;i<o.size();i++)
{
if(o[i].b<minn)
{
minn=o[i].b;
g[u].push_back(o[i]);
}
}
}
else g[u].push_back((edge){0,0});
}
bool check(int x)
{
for(int i=1;i<=n;i++)
g[i].clear();
merge(1,x);
return g[1].size()>0;
}
int main()
{
scanf("%d",&n);
for(int i=1;i<n;i++)
{
int a,v;
scanf("%d%d",&a,&v);
adde(i+1,a,v),adde(a,i+1,v);
sum+=v;
}
dfs(1,0);
int l=0,r=sum,ans;
while(l<r-1)
{
int mid=(l+r)>>1;
if(check(mid))r=mid;
else l=mid;
}
if(check(l)) ans=l;
else ans=r;
printf("%d\n",ans);
return 0;
} | a.cc: In function 'void dfs(int, int)':
a.cc:36:9: error: reference to 'size' is ambiguous
36 | size[u]=1;
| ^~~~
In file included from /usr/include/c++/14/string:53,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
from a.cc:1:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:21:21: note: 'int size [131075]'
21 | int ch[N][2],pre[N],size[N];
| ^~~~
a.cc:44:25: error: reference to 'size' is ambiguous
44 | size[u]+=size[to[i]];
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:21:21: note: 'int size [131075]'
21 | int ch[N][2],pre[N],size[N];
| ^~~~
a.cc:44:34: error: reference to 'size' is ambiguous
44 | size[u]+=size[to[i]];
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:21:21: note: 'int size [131075]'
21 | int ch[N][2],pre[N],size[N];
| ^~~~
a.cc: In function 'bool get(int, int, int, int, int&, int&)':
a.cc:57:23: error: expected ';' before numeric constant
57 | else r
| ^
| ;
58 | .0=mid;
| ~~
a.cc: In function 'void merge(int, int)':
a.cc:74:20: error: reference to 'size' is ambiguous
74 | if(size[a]>size[b])swap(a,b);
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:21:21: note: 'int size [131075]'
21 | int ch[N][2],pre[N],size[N];
| ^~~~
a.cc:74:28: error: reference to 'size' is ambiguous
74 | if(size[a]>size[b])swap(a,b);
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:21:21: note: 'int size [131075]'
21 | int ch[N][2],pre[N],size[N];
| ^~~~
|
s682602542 | p03941 | C++ | #include <iostream>
#include <vector>
using namespace std;
#define x first
#define y second
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T,typename F>T bsl(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){h=m-1;r=m;}else{l=m+1;}}return r;}
vector<vector<pll>> E;
vector<pll> solve(int u, ll T) {
if (E[u].empty()) {
return {{0LL,0LL}};
} else {
auto A = solve(E[u][0].x, T);
auto B = solve(E[u][1].x, T);
for (auto &a: A) { a.x += E[u][0].y; a.y += E[u][0].y; }
for (auto &b: B) { b.x += E[u][1].y; b.y += E[u][1].y; }
vector<pll> Ans;
for (int t = 0; t < 2; ++t) {
int i = 0, j = B.size()-1;
for (pll a: A) {
while (i < B.size() && B[i].y + a.x > T) ++i;
while (j >= 0 && B[j].x + a.x > T) --j;
if (i != B.size()) Ans.emplace_back(min(a.y,B[i].x),max(a.y,B[i].x));
if (j >= 0) Ans.emplace_back(min(a.y,B[i].y),max(a.y,B[i].y));
}
for (pll&a:A) swap(a.x, a.y);
reverse(A.begin(),A.end());
}
sort(Ans.begin(),Ans.end());
vector<pll> F;
for (pll ans: Ans) if (F.empty() || F.back().y > ans.y) F.push_back(ans);
return F;
}
}
int main() {
ios_base::sync_with_stdio(false);
int N; cin >> N;
E.resize(N);
for (int i = 1; i < N; ++i) {
int p, c; cin >> p >> c;
--p;
E[p].push_back({i,c});
}
// solve(0, 4LL);
//return 0;
cout << bsl(0LL, 18000000000LL, [](ll v) {
auto s = solve(0, v);
//cout << v << ' ' << s.empty() << endl;
return !s.empty();
}) << endl;
}
| a.cc: In function 'std::vector<std::pair<long long int, long long int> > solve(int, ll)':
a.cc:36:13: error: 'reverse' was not declared in this scope
36 | reverse(A.begin(),A.end());
| ^~~~~~~
a.cc:39:9: error: 'sort' was not declared in this scope; did you mean 'short'?
39 | sort(Ans.begin(),Ans.end());
| ^~~~
| short
|
s385633787 | p03941 | C++ | あ#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;
typedef long long LL;
typedef vector<int> VI;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
putchar('\n');
}
const int MAXN = 140111;
int N;
int P[MAXN], X[MAXN];
pair<int, int> C[MAXN];
vector<pair<LL, LL> > V[MAXN];
LL mid;
vector<pair<LL, LL> > line(int a, int b) {
vector<pair<LL, LL> > ret;
int j = V[b].size()-1;
REP (i, V[a].size()) {
LL a_cst = V[a][i].second + X[a];
while (j >= 0 && a_cst + V[b][j].first + X[b] > mid) j--;
if (j >= 0) {
a_cst = V[a][i].first + X[a];
LL b_cst = V[b][j].second + X[b];
if (ret.empty() || ret.back().second > b_cst)
ret.emplace_back(a_cst, b_cst);
}
}
return ret;
}
bool ok() {
for (int v=N; v--;) {
if (C[v].first == -1) {
if (V[v].empty()) V[v].emplace_back(0, 0);
} else {
V[v].clear();
int l = C[v].first, r = C[v].second;
vector<pair<LL, LL> > lv = line(l, r);
vector<pair<LL, LL> > rv = line(r, l);
int i = 0, j = 0;
while (i < (int)lv.size() || j < (int)rv.size()) {
pair<LL, LL> key;
if (j == (int)rv.size()) {
key = lv[i++];
} else if (i == (int)lv.size()) {
key = rv[j++];
} else if (lv[i].first < rv[j].first || (lv[i].first == rv[j].first && lv[i].second < rv[j].second)) {
key = lv[i++];
} else {
key = rv[j++];
}
if (V[v].empty() ||
(V[v].back().first < key.first && V[v].back().second > key.second)) {
V[v].push_back(key);
}
}
if (V[v].empty()) return false;
}
}
return true;
}
void MAIN() {
scanf("%d", &N);
REP (i, N) C[i].first = C[i].second = -1;
REP (i, N-1) {
int a, x;
scanf("%d%d", &a, &x);
a--;
P[i+1] = a;
X[i+1] = x;
if (C[a].first == -1) C[a].first = i+1;
else C[a].second = i+1;
}
LL lo = -1, hi = (1LL<<40)-1;
while (hi - lo > 1) {
mid = (lo + hi) / 2;
(ok()? hi: lo) = mid;
}
printf("%lld\n", hi);
}
int main() {
int TC = 1;
// scanf("%d", &TC);
REP (tc, TC) MAIN();
return 0;
}
| a.cc:1:3: error: stray '#' in program
1 | あ#include<stdio.h>
| ^
a.cc:1:1: error: '\U00003042' does not name a type
1 | あ#include<stdio.h>
| ^~
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:2:
/usr/include/c++/14/bits/postypes.h:68:11: error: 'ptrdiff_t' does not name a type
68 | typedef ptrdiff_t streamsize; // Signed integral type
| ^~~~~~~~~
/usr/include/c++/14/bits/postypes.h:41:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
40 | #include <cwchar> // For mbstate_t
+++ |+#include <cstddef>
41 |
In file included from /usr/include/c++/14/bits/exception_ptr.h:38,
from /usr/include/c++/14/exception:166,
from /usr/include/c++/14/ios:41:
/usr/include/c++/14/new:131:26: error: declaration of 'operator new' as non-function
131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~~~
/usr/include/c++/14/new:131:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~
In file included from /usr/include/wchar.h:35,
from /usr/include/c++/14/cwchar:44,
from /usr/include/c++/14/bits/postypes.h:40:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:132:41: error: attributes after parenthesized initializer ignored [-fpermissive]
132 | __attribute__((__externally_visible__));
| ^
/usr/include/c++/14/new:133:26: error: declaration of 'operator new []' as non-function
133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~~~
/usr/include/c++/14/new:133:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:134:41: error: attributes after parenthesized initializer ignored [-fpermissive]
134 | __attribute__((__externally_visible__));
| ^
/usr/include/c++/14/new:140:29: error: 'std::size_t' has not been declared
140 | void operator delete(void*, std::size_t) _GLIBCXX_USE_NOEXCEPT
| ^~~
/usr/include/c++/14/new:142:31: error: 'std::size_t' has not been declared
142 | void operator delete[](void*, std::size_t) _GLIBCXX_USE_NOEXCEPT
| ^~~
/usr/include/c++/14/new:145:26: error: declaration of 'operator new' as non-function
145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~~~
/usr/include/c++/14/new:145:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:145:52: error: expected primary-expression before 'const'
145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~
/usr/include/c++/14/new:147:26: error: declaration of 'operator new []' as non-function
147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~~~
/usr/include/c++/14/new:147:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:147:54: error: expected primary-expression before 'const'
147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~
/usr/include/c++/14/new:154:26: error: declaration of 'operator new' as non-function
154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t)
| ^~~~~~~~
/usr/include/c++/14/new:154:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:154:68: error: expected primary-expression before ')' token
154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t)
| ^
/usr/include/c++/14/new:155:73: error: attributes after parenthesized initializer ignored [-fpermissive]
155 | __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__));
| ^
/usr/include/c++/14/new:156:26: error: declaration of 'operator new' as non-function
156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~~~~
/usr/include/c++/14/new:156:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:156:68: error: expected primary-expression before ',' token
156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
| ^
/usr/include/c++/14/new:156:70: error: expected primary-expression before 'const'
156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~
/usr/include/c++/14/new:162:26: error: declaration of 'operator new []' as non-function
162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t)
| ^~~~~~~~
/usr/include/c++/14/new:162:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:162:70: error: expected primary-expression before ')' token
162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t)
| ^
/usr/include/c++/14/new:163:73: error: attributes after parenthesized initializer ignored [-fpermissive]
163 | __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__));
| ^
/usr/include/c++/14/new:164:26: error: declaration of 'operator new []' as non-function
164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~~~~
/usr/include/c++/14/new:164:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:164:70: error: expected primary-expression before ',' token
164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
| ^
/usr/include/c++/14/new:164:72: error: expected primary-expression before 'const'
164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~
/usr/include/c++/14/new:171:29: error: 'std::size_t' has not been declared
171 | void operator delete(void*, std::size_t, std::align_val_t)
| ^~~
/usr/include/c++/14/new:173:31: error: 'std::size_t' has not been declared
173 | void operator delete[](void*, std::size_t, std::align_val_t)
| ^~~
/usr/include/c++/14/new:179:33: error: declaration of 'operator new' as non-function
179 | _GLIBCXX_NODISCARD inline void* operator new(std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~~~
/usr/include/c++/14/new:179:51: er |
s597179221 | p03941 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int RLEN=1<<18|1;
inline char nc() {
static char ibuf[RLEN],*ib,*ob;
(ib==ob) && (ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
return (ib==ob) ? -1 : *ib++;
}
inline int rd() {
char ch=nc(); int i=0,f=1;
while(!isdigit(ch)) {if(ch=='-')f=-1; ch=nc();}
while(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=nc();}
return i*f;
}
const int N=2e5+50;
vector <pLL> edge[N];
vector <pLL> f[N];
vector <pLL> tl, tr;
LL lim;
inline void inc(int x,const pLL &t) {
if(f[x].size() && f[x].back()<=t) return;
while(f[x].size() && f[x].back().second>=t.second) f[x].pop_back();
f[x].push_back(t);
}
inline bool dfs(int x,int fa) {
f[x].clear();
if(edge[x].size()==1) {f[x].push_back(pLL(0,0)); return true;}
LL lc,rc,disl,disr; int fir=0;
for(int e=edge[x].size()-1;e>=0;e--) {
int v=edge[x][e].first; if(v==fa) continue;
if(!dfs(v,x)) return false;
if(!fir) fir=1, lc=v, disl=edge[x][e].second;
else rc=v, disr=edge[x][e].second;
}
tl.clear(), tr.clear(); LL lim2=lim-disl-disr;
if(lim2<0) return false;
for(int p1=0,p2=0;p2<f[rc].size();p2++) {
while(p1<f[lc].size() && f[lc][p1].first+f[rc][p2].second>lim2) ++p1;
if(p1==f[lc].size()) break;
tl.push_back(pLL(f[rc][p2].first+disr,f[lc][p1].second+disl));
}
for(int p1=0,p2=0;p1<f[lc].size();p1++) {
while(p2<f[rc].size() && f[lc][p1].second+f[rc][p2].first>lim2) ++p2;
if(p2==f[rc].size()) break;
tr.push_back(pLL(f[lc][p1].first+disl,f[rc][p2].second+disr));
}
int pl=0, pr=0;
while(pl<tl.size() && pr<tr.size()) {
if(tl[pl].first>tr[pr].first) inc(x,tl[pl++]);
else inc(x,tr[pr++]);
}
while(pl<tl.size()) inc(x,tl[pl++]);
while(pr<tr.size()) inc(x,tr[pr++]);
return f[x].size()>0;
}
inline bool check(LL v) { lim=v; return dfs(1,0);}
int main() {
int n=rd();
for(int i=2;i<=n;i++) {
int x=rd(), w=rd();
edge[x].push_back(pLL(i,w));
edge[i].push_back(pLL(x,w));
}
LL l=0, r=1e12, ans=0;
while(l<=r) {
LL mid=(l+r)>>1;
if(check(mid)) ans=mid, r=mid-1;
else l=mid+1;
} cout<<ans;
} | a.cc:19:9: error: 'pLL' was not declared in this scope; did you mean 'LL'?
19 | vector <pLL> edge[N];
| ^~~
| LL
a.cc:19:12: error: template argument 1 is invalid
19 | vector <pLL> edge[N];
| ^
a.cc:19:12: error: template argument 2 is invalid
a.cc:20:9: error: 'pLL' was not declared in this scope; did you mean 'LL'?
20 | vector <pLL> f[N];
| ^~~
| LL
a.cc:20:12: error: template argument 1 is invalid
20 | vector <pLL> f[N];
| ^
a.cc:20:12: error: template argument 2 is invalid
a.cc:21:9: error: 'pLL' was not declared in this scope; did you mean 'LL'?
21 | vector <pLL> tl, tr;
| ^~~
| LL
a.cc:21:12: error: template argument 1 is invalid
21 | vector <pLL> tl, tr;
| ^
a.cc:21:12: error: template argument 2 is invalid
a.cc:23:29: error: 'pLL' does not name a type; did you mean 'LL'?
23 | inline void inc(int x,const pLL &t) {
| ^~~
| LL
a.cc: In function 'void inc(int, const int&)':
a.cc:24:13: error: request for member 'size' in 'f[x]', which is of non-class type 'int'
24 | if(f[x].size() && f[x].back()<=t) return;
| ^~~~
a.cc:24:28: error: request for member 'back' in 'f[x]', which is of non-class type 'int'
24 | if(f[x].size() && f[x].back()<=t) return;
| ^~~~
a.cc:25:16: error: request for member 'size' in 'f[x]', which is of non-class type 'int'
25 | while(f[x].size() && f[x].back().second>=t.second) f[x].pop_back();
| ^~~~
a.cc:25:31: error: request for member 'back' in 'f[x]', which is of non-class type 'int'
25 | while(f[x].size() && f[x].back().second>=t.second) f[x].pop_back();
| ^~~~
a.cc:25:48: error: request for member 'second' in 't', which is of non-class type 'const int'
25 | while(f[x].size() && f[x].back().second>=t.second) f[x].pop_back();
| ^~~~~~
a.cc:25:61: error: request for member 'pop_back' in 'f[x]', which is of non-class type 'int'
25 | while(f[x].size() && f[x].back().second>=t.second) f[x].pop_back();
| ^~~~~~~~
a.cc:26:10: error: request for member 'push_back' in 'f[x]', which is of non-class type 'int'
26 | f[x].push_back(t);
| ^~~~~~~~~
a.cc: In function 'bool dfs(int, int)':
a.cc:29:10: error: request for member 'clear' in 'f[x]', which is of non-class type 'int'
29 | f[x].clear();
| ^~~~~
a.cc:30:16: error: request for member 'size' in 'edge[x]', which is of non-class type 'int'
30 | if(edge[x].size()==1) {f[x].push_back(pLL(0,0)); return true;}
| ^~~~
a.cc:30:33: error: request for member 'push_back' in 'f[x]', which is of non-class type 'int'
30 | if(edge[x].size()==1) {f[x].push_back(pLL(0,0)); return true;}
| ^~~~~~~~~
a.cc:30:43: error: 'pLL' was not declared in this scope; did you mean 'LL'?
30 | if(edge[x].size()==1) {f[x].push_back(pLL(0,0)); return true;}
| ^~~
| LL
a.cc:32:23: error: request for member 'size' in 'edge[x]', which is of non-class type 'int'
32 | for(int e=edge[x].size()-1;e>=0;e--) {
| ^~~~
a.cc:33:22: error: invalid types 'int[int]' for array subscript
33 | int v=edge[x][e].first; if(v==fa) continue;
| ^
a.cc:35:43: error: invalid types 'int[int]' for array subscript
35 | if(!fir) fir=1, lc=v, disl=edge[x][e].second;
| ^
a.cc:36:32: error: invalid types 'int[int]' for array subscript
36 | else rc=v, disr=edge[x][e].second;
| ^
a.cc:38:8: error: request for member 'clear' in 'tl', which is of non-class type 'int'
38 | tl.clear(), tr.clear(); LL lim2=lim-disl-disr;
| ^~~~~
a.cc:38:20: error: request for member 'clear' in 'tr', which is of non-class type 'int'
38 | tl.clear(), tr.clear(); LL lim2=lim-disl-disr;
| ^~~~~
a.cc:40:32: error: request for member 'size' in 'f[rc]', which is of non-class type 'int'
40 | for(int p1=0,p2=0;p2<f[rc].size();p2++) {
| ^~~~
a.cc:41:24: error: request for member 'size' in 'f[lc]', which is of non-class type 'int'
41 | while(p1<f[lc].size() && f[lc][p1].first+f[rc][p2].second>lim2) ++p1;
| ^~~~
a.cc:41:39: error: invalid types 'int[int]' for array subscript
41 | while(p1<f[lc].size() && f[lc][p1].first+f[rc][p2].second>lim2) ++p1;
| ^
a.cc:41:55: error: invalid types 'int[int]' for array subscript
41 | while(p1<f[lc].size() && f[lc][p1].first+f[rc][p2].second>lim2) ++p1;
| ^
a.cc:42:22: error: request for member 'size' in 'f[lc]', which is of non-class type 'int'
42 | if(p1==f[lc].size()) break;
| ^~~~
a.cc:43:12: error: request for member 'push_back' in 'tl', which is of non-class type 'int'
43 | tl.push_back(pLL(f[rc][p2].first+disr,f[lc][p1].second+disl));
| ^~~~~~~~~
a.cc:43:31: error: invalid types 'int[int]' for array subscript
43 | tl.push_back(pLL(f[rc][p2].first+disr,f[lc][p1].second+disl));
| ^
a.cc:43:52: error: invalid types 'int[int]' for array subscript
43 | tl.push_back(pLL(f[rc][p2].first+disr,f[lc][p1].second+disl));
| ^
a.cc:43:22: error: 'pLL' was not declared in this scope; did you mean 'LL'?
43 | tl.push_back(pLL(f[rc][p2].first+disr,f[lc][p1].second+disl));
| ^~~
| LL
a.cc:45:32: error: request for member 'size' in 'f[lc]', which is of non-class type 'int'
45 | for(int p1=0,p2=0;p1<f[lc].size();p1++) {
| ^~~~
a.cc:46:24: error: request for member 'size' in 'f[rc]', which is of non-class type 'int'
46 | while(p2<f[rc].size() && f[lc][p1].second+f[rc][p2].first>lim2) ++p2;
| ^~~~
a.cc:46:39: error: invalid types 'int[int]' for array subscript
46 | while(p2<f[rc].size() && f[lc][p1].second+f[rc][p2].first>lim2) ++p2;
| ^
a.cc:46:56: error: invalid types 'int[int]' for array subscript
46 | while(p2<f[rc].size() && f[lc][p1].second+f[rc][p2].first>lim2) ++p2;
| ^
a.cc:47:22: error: request for member 'size' in 'f[rc]', which is of non-class type 'int'
47 | if(p2==f[rc].size()) break;
| ^~~~
a.cc:48:12: error: request for member 'push_back' in 'tr', which is of non-class type 'int'
48 | tr.push_back(pLL(f[lc][p1].first+disl,f[rc][p2].second+disr));
| ^~~~~~~~~
a.cc:48:31: error: invalid types 'int[int]' for array subscript
48 | tr.push_back(pLL(f[lc][p1].first+disl,f[rc][p2].second+disr));
| ^
a.cc:48:52: error: invalid types 'int[int]' for array subscript
48 | tr.push_back(pLL(f[lc][p1].first+disl,f[rc][p2].second+disr));
| ^
a.cc:48:22: error: 'pLL' was not declared in this scope; did you mean 'LL'?
48 | tr.push_back(pLL(f[lc][p1].first+disl,f[rc][p2].second+disr));
| ^~~
| LL
a.cc:51:17: error: request for member 'size' in 'tl', which is of non-class type 'int'
51 | while(pl<tl.size() && pr<tr.size()) {
| ^~~~
a.cc:51:33: error: request for member 'size' in 'tr', which is of non-class type 'int'
51 | while(pl<tl.size() && pr<tr.size()) {
| ^~~~
a.cc:52:14: error: invalid types 'int[int]' for array subscript
52 | if(tl[pl].first>tr[pr].first) inc(x,tl[pl++]);
| ^
a.cc:52:27: error: invalid types 'int[int]' for array subscript
52 | if(tl[pl].first>tr[pr].first) inc(x,tl[pl++]);
| ^
a.cc:52:47: error: invalid types 'int[int]' for array subscript
52 | if(tl[pl].first>tr[pr].first) inc(x,tl[pl++]);
| ^
a.cc:53:22: error: invalid types 'int[int]' for array subscript
53 | else inc(x,tr[pr++]);
| ^
a.cc:55:17: error: request for member 'size' in 'tl', which is of non-class type 'int'
55 | while(pl<tl.size()) inc(x,tl[pl++]);
| ^~~~
a.cc:55:33: error: invalid types 'int[int]' for array subscript
55 | while(pl<tl.size()) inc(x,tl[pl++]);
| ^
a.cc:56:17: error: request for member 'size' in 'tr', which is of non-class type 'int'
56 | while(pr<tr.size()) inc(x,tr[pr++]);
| ^~~~
a.cc:56:33: error: invalid types 'int[int]' for array subscript
56 | while(pr<tr.size()) inc(x,tr[pr++]);
| ^
a.cc:57:17: error: request for member 'size' in 'f[x]', which is of non-class type 'int'
57 | return f[x].size()>0;
| ^~~~
a.cc: In function 'int main()':
a.cc:64:17: error: request for member 'push_back' in 'edge[x]', which is of non-class type 'int'
64 | edge[x].push_back(pLL(i,w));
| ^~~~~~~~~
a.cc:64:27: error: 'pLL' was not declared in this scope; did you mean 'LL'?
64 | edge[x].push_back(pLL(i,w));
| ^~~
| LL
a.cc:65:17: error: request for member 'push_back' in 'edge[i]', which is of non-class type 'int'
65 | ed |
s815306877 | p03941 | C++ | #include<cstdio>
#include<algorithm>
#include<vector>
#define maxn 131080
#define LL long long
using namespace std;
typedef pair<LL,LL> PLL;
int n,fa[maxn];
vector<PLL> f[maxn];
struct node { int v,w; node *nxt; } edge[maxn],*head[maxn],*ncnt;
void addedge(int u,int v,int w)
{
ncnt++;
ncnt->v=v,ncnt->w=w,ncnt->nxt=head[u];
head[u]=ncnt;
}
/*#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<pr> vec;
#define x first
#define y second
const int N=131100;
int n,fa[N];
vec g[N],f[N];
ll mid,mv[N];
inline bool cmpx(pr a,pr b){return a.x<b.x;}
inline bool cmpy(pr a,pr b){return a.y<b.y;}
inline void work(vec &ls,vec &rs,vec &f)
{
if(ls.size()>rs.size())swap(ls,rs);
int el=ls.size(),er=rs.size();
sort(ls.begin(),ls.end(),cmpy);
sort(rs.begin(),rs.end(),cmpx);
mv[0]=rs[0].y;
for(int i=1;i<er;i++) mv[i]=min(mv[i-1],rs[i].y);
for(int i=0,j=er-1;i<el;i++)
{
while(j>=0 && ls[i].y+rs[j].x>mid)j--;
if(j>=0)f.push_back(pr(ls[i].x,mv[j]));
}
sort(ls.begin(),ls.end(),cmpx);
sort(rs.begin(),rs.end(),cmpy);
mv[0]=rs[0].x;
for(int i=1;i<er;i++) mv[i]=min(mv[i-1],rs[i].x);
for(int i=0,j=er-1;i<el;i++)
{
while(j>=0 && ls[i].x+rs[j].y>mid)j--;
if(j>=0)f.push_back(pr(mv[j],ls[i].y));
}
}
inline void dfs(int u)
{
if(!f[u].empty())f[u].clear();
if(g[u].empty())
{
f[u].push_back(pr(0,0));
return;
}
for(int i=0,e=g[u].size();i<e;i++)
dfs(g[u][i].x);
vec &ls=f[g[u][0].x];
for(int i=0,e=ls.size(),c=g[u][0].y;i<e;i++)
ls[i].x+=c,ls[i].y+=c;
vec &rs=f[g[u][1].x];
for(int i=0,e=rs.size(),c=g[u][1].y;i<e;i++)
rs[i].x+=c,rs[i].y+=c;
work(ls,rs,f[u]);
ls.clear();
rs.clear();
}*/
void dfs(int u)
{
f[u].clear();
if(!head[u]) { f[u].push_back(PLL(0,0)); return; }
for(node *p=head[u];p;p=p->nxt) dfs(p->v);
vector<PLL> &ls=f[head[u]->v];
for(int i=0,siz=f[head[u]->v])
}
LL BS()
{
LL l=0,r=(LL)1e10;
while(l+1<r)
{
int mid=(l+r)/2; dfs(1,mid);
if(f[1].empty()) l=mid;
else r=mid;
}
return r;
}
int main()
{
freopen("travel.in","r",stdin);
freopen("travel.out","w",stdout);
ncnt=&edge[0];
scanf("%d",&n);
for(int i=2;i<=n;i++)
{
int w;
scanf("%d%d",&fa[i],&w);
addedge(fa[i],i,w);
}
printf("%lld\n",BS());
} | a.cc: In function 'void dfs(int)':
a.cc:79:37: error: cannot convert 'std::vector<std::pair<long long int, long long int> >' to 'int' in initialization
79 | for(int i=0,siz=f[head[u]->v])
| ~~~~~~~~~~~~^
| |
| std::vector<std::pair<long long int, long long int> >
a.cc:79:38: error: expected ';' before ')' token
79 | for(int i=0,siz=f[head[u]->v])
| ^
| ;
a.cc:79:38: error: expected primary-expression before ')' token
a.cc:79:38: error: expected ';' before ')' token
79 | for(int i=0,siz=f[head[u]->v])
| ^
| ;
a.cc:80:1: error: expected primary-expression before '}' token
80 | }
| ^
a.cc: In function 'long long int BS()':
a.cc:86:37: error: too many arguments to function 'void dfs(int)'
86 | int mid=(l+r)/2; dfs(1,mid);
| ~~~^~~~~~~
a.cc:73:6: note: declared here
73 | void dfs(int u)
| ^~~
|
s239949126 | p03941 | C++ | #include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#define ll long long
using namespace std;
const int N=2*(1e5)+10;
struct Pr{
ll in,out;
Pr(){}
Pr(ll x,ll y){in=x; out=y;}
};
int h[N],ch[N][2],dis[N][2];
ll rec[N];
vector<Pr> f[N];
int n,tot;
ll sum,Mx;
bool cmp1(Pr x,Pr y){return x.in<y.in;}
bool cmp2(Pr x,Pr y){return x.out<y.out;}
void merge(int x){
int lch=ch[x][0],rch=ch[x][1];
if (f[lch].size()>f[rch].size()) swap(lch,rch);
int lsz=f[lch].size(),rsz=f[rch].size();
sort(f[lch].begin(),f[lch].end(),cmp2);
sort(f[rch].begin(),f[rch].end(),cmp1);
rec[0]=f[rch][0].out;
for (int i=1;i<rsz;++i) rec[i]=min(rec[i-1],f[rch][i].out);
for (int i=0,j=rsz-1;i<lsz;++i){
while (j>=0&&f[lch][i].out+f[rch][j].in>Mx) --j;
if (j>=0) f[x].push_back(Pr(f[lch][i].in,rec[j]));
}
sort(f[lch].begin(),f[lch].end(),cmp1);
sort(f[rch].begin(),f[rch].end(),cmp2);
rec[0]=f[rch][0].in;
for (int i=1;i<rsz;++i) rec[i]=min(rec[i-1],f[rch][i].in);
for (int i=0,j=rsz-1;i<lsz;++i){
while (j>=0&&f[rch][j].out+f[lch][i].in>Mx) --j;
if (j>=0) f[x].push_back(Pr(rec[j],f[lch][i].out));
}
}
void dfs(int x){
int u,sz;
f[x].clear();
if (ch[x][0]==0&&ch[x][1]==0){
f[x].push_back(Pr(0,0));
return;
}
dfs(ch[x][0]);
dfs(ch[x][1]);
sz=f[ch[x][0]].size();
for (int i=0;i<sz;++i)
f[ch[x][0]][i].in+=dis[x][0],f[ch[x][0]][i].out+=dis[x][0];
sz=f[ch[x][1]].size();
for (int i=0;i<sz;++i)
f[ch[x][1]][i].in+=dis[x][1],f[ch[x][1]][i].out+=dis[x][1];
merge(x);
}
bool check(ll x){
Mx=x;
dfs(1);
return f[1].size()>0;
}
void solve(){
ll l=0,r=sum,mid,ans=0;
while (l<=r){
mid=l+r>>1;
if (check(mid)) ans=mid,r=mid-1;
else l=mid+1;
}
printf("%lld\n",ans);
}
int read(){
int ret=0; char ch=getchar();
while (ch<'0'||ch>'9') ch=getchar();
while ('0'<=ch&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
return ret;
}
int main(){
#ifndef ONLINE_JUDGE
//freopen("a.in","r",stdin);
#endif
int x,y;
n=read();
memset(h,-1,sizeof(h));
tot=0; sum=0;
for (int i=1;i<n;++i){
x=read(); y=read();
if (ch[x][0]) ch[x][1]=i+1,dis[x][1]=y;
else ch[x][0]=i+1,dis[x][0]=y;
sum+=y;
}
solve();
}
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#define ll long long
using namespace std;
const int N=2*(1e5)+10;
struct Pr{
ll in,out;
Pr(){}
Pr(int x,int y){in=x; out=y;}
};
int h[N],ch[N][2],dis[N][2];
ll rec[N];
vector<Pr> f[N];
int n,tot;
ll sum,Mx;
bool cmp1(Pr x,Pr y){return x.in<y.in;}
bool cmp2(Pr x,Pr y){return x.out<y.out;}
void merge(int x){
int lch=ch[x][0],rch=ch[x][1];
if (f[lch].size()>f[rch].size()) swap(lch,rch);
int lsz=f[lch].size(),rsz=f[rch].size();
sort(f[lch].begin(),f[lch].end(),cmp2);
sort(f[rch].begin(),f[rch].end(),cmp1);
rec[0]=f[rch][0].out;
for (int i=1;i<rsz;++i) rec[i]=min(rec[i-1],f[rch][i].out);
for (int i=0,j=rsz-1;i<lsz;++i){
while (j>=0&&f[lch][i].out+f[rch][j].in>Mx) --j;
if (j>=0) f[x].push_back(Pr(f[lch][i].in,rec[j]));
}
sort(f[lch].begin(),f[lch].end(),cmp1);
sort(f[rch].begin(),f[rch].end(),cmp2);
rec[0]=f[rch][0].in;
for (int i=1;i<rsz;++i) rec[i]=min(rec[i-1],f[rch][i].in);
for (int i=0,j=rsz-1;i<lsz;++i){
while (j>=0&&f[rch][j].out+f[lch][i].in>Mx) --j;
if (j>=0) f[x].push_back(Pr(rec[j],f[lch][i].out));
}
}
void dfs(int x){
int u,sz;
f[x].clear();
if (ch[x][0]==0&&ch[x][1]==0){
f[x].push_back(Pr(0,0));
return;
}
dfs(ch[x][0]);
dfs(ch[x][1]);
sz=f[ch[x][0]].size();
for (int i=0;i<sz;++i)
f[ch[x][0]][i].in+=dis[x][0],f[ch[x][0]][i].out+=dis[x][0];
sz=f[ch[x][1]].size();
for (int i=0;i<sz;++i)
f[ch[x][1]][i].in+=dis[x][1],f[ch[x][1]][i].out+=dis[x][1];
merge(x);
}
bool check(ll x){
Mx=x;
dfs(1);
return f[1].size()>0;
}
void solve(){
ll l=0,r=sum,mid,ans=0;
while (l<=r){
mid=l+r>>1;
if (check(mid)) ans=mid,r=mid-1;
else l=mid+1;
}
printf("%lld\n",ans);
}
int read(){
int ret=0; char ch=getchar();
while (ch<'0'||ch>'9') ch=getchar();
while ('0'<=ch&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
return ret;
}
int main(){
#ifndef ONLINE_JUDGE
//freopen("a.in","r",stdin);
#endif
int x,y;
n=read();
memset(h,-1,sizeof(h));
tot=0; sum=0;
for (int i=1;i<n;++i){
x=read(); y=read();
if (ch[x][0]) ch[x][1]=i+1,dis[x][1]=y;
else ch[x][0]=i+1,dis[x][0]=y;
sum+=y;
}
solve();
}
| a.cc:105:11: error: redefinition of 'const int N'
105 | const int N=2*(1e5)+10;
| ^
a.cc:8:11: note: 'const int N' previously defined here
8 | const int N=2*(1e5)+10;
| ^
a.cc:106:8: error: redefinition of 'struct Pr'
106 | struct Pr{
| ^~
a.cc:9:8: note: previous definition of 'struct Pr'
9 | struct Pr{
| ^~
a.cc:111:5: error: redefinition of 'int h [200010]'
111 | int h[N],ch[N][2],dis[N][2];
| ^
a.cc:14:5: note: 'int h [200010]' previously declared here
14 | int h[N],ch[N][2],dis[N][2];
| ^
a.cc:111:10: error: redefinition of 'int ch [200010][2]'
111 | int h[N],ch[N][2],dis[N][2];
| ^~
a.cc:14:10: note: 'int ch [200010][2]' previously declared here
14 | int h[N],ch[N][2],dis[N][2];
| ^~
a.cc:111:19: error: redefinition of 'int dis [200010][2]'
111 | int h[N],ch[N][2],dis[N][2];
| ^~~
a.cc:14:19: note: 'int dis [200010][2]' previously declared here
14 | int h[N],ch[N][2],dis[N][2];
| ^~~
a.cc:112:4: error: redefinition of 'long long int rec [200010]'
112 | ll rec[N];
| ^~~
a.cc:15:4: note: 'long long int rec [200010]' previously declared here
15 | ll rec[N];
| ^~~
a.cc:113:12: error: redefinition of 'std::vector<Pr> f [200010]'
113 | vector<Pr> f[N];
| ^
a.cc:16:12: note: 'std::vector<Pr> f [200010]' previously declared here
16 | vector<Pr> f[N];
| ^
a.cc:114:5: error: redefinition of 'int n'
114 | int n,tot;
| ^
a.cc:17:5: note: 'int n' previously declared here
17 | int n,tot;
| ^
a.cc:114:7: error: redefinition of 'int tot'
114 | int n,tot;
| ^~~
a.cc:17:7: note: 'int tot' previously declared here
17 | int n,tot;
| ^~~
a.cc:115:4: error: redefinition of 'long long int sum'
115 | ll sum,Mx;
| ^~~
a.cc:18:4: note: 'long long int sum' previously declared here
18 | ll sum,Mx;
| ^~~
a.cc:115:8: error: redefinition of 'long long int Mx'
115 | ll sum,Mx;
| ^~
a.cc:18:8: note: 'long long int Mx' previously declared here
18 | ll sum,Mx;
| ^~
a.cc:116:6: error: redefinition of 'bool cmp1(Pr, Pr)'
116 | bool cmp1(Pr x,Pr y){return x.in<y.in;}
| ^~~~
a.cc:19:6: note: 'bool cmp1(Pr, Pr)' previously defined here
19 | bool cmp1(Pr x,Pr y){return x.in<y.in;}
| ^~~~
a.cc:117:6: error: redefinition of 'bool cmp2(Pr, Pr)'
117 | bool cmp2(Pr x,Pr y){return x.out<y.out;}
| ^~~~
a.cc:20:6: note: 'bool cmp2(Pr, Pr)' previously defined here
20 | bool cmp2(Pr x,Pr y){return x.out<y.out;}
| ^~~~
a.cc:118:6: error: redefinition of 'void merge(int)'
118 | void merge(int x){
| ^~~~~
a.cc:21:6: note: 'void merge(int)' previously defined here
21 | void merge(int x){
| ^~~~~
a.cc:141:6: error: redefinition of 'void dfs(int)'
141 | void dfs(int x){
| ^~~
a.cc:44:6: note: 'void dfs(int)' previously defined here
44 | void dfs(int x){
| ^~~
a.cc:158:6: error: redefinition of 'bool check(long long int)'
158 | bool check(ll x){
| ^~~~~
a.cc:61:6: note: 'bool check(long long int)' previously defined here
61 | bool check(ll x){
| ^~~~~
a.cc:163:6: error: redefinition of 'void solve()'
163 | void solve(){
| ^~~~~
a.cc:66:6: note: 'void solve()' previously defined here
66 | void solve(){
| ^~~~~
a.cc:172:5: error: redefinition of 'int read()'
172 | int read(){
| ^~~~
a.cc:75:5: note: 'int read()' previously defined here
75 | int read(){
| ^~~~
a.cc:179:5: error: redefinition of 'int main()'
179 | int main(){
| ^~~~
a.cc:82:5: note: 'int main()' previously defined here
82 | int main(){
| ^~~~
|
s128694098 | p03941 | C++ | cities numbered 1 through N, which are connected by N−1 bidirectional roads. In terms of graph theory, there is a unique simple path connecting every pair of cities. That is, the N cities form a tree. Besides, if we view city 1 as the root of this tree, the tree will be a full binary tree (a tree is a full binary tree if and only if every non-leaf vertex in the tree has exactly two children). Roads are numbered 1 through N−1. The i-th road connects city i+1 and city ai. When you pass through road i, the toll you should pay is vi (if vi is 0
, it indicates the road does not require a toll).
A company in city 1
will give each employee a family travel and cover a large part of the tolls incurred. Each employee can design the travel by themselves. That is, which cities he/she wants to visit in each day and which city to stay at each night. However, there are some constraints. More details are as follows:
The travel must start and end at city 1
. If there are m leaves in the tree formed by the cities, then the number of days in the travel must be m+1
. At the end of each day, except for the last day, the employee must stay at some hotel in a leaf city. During the whole travel, the employee must stay at all leaf cities exactly once.
During the whole travel, all roads of the country must be passed through exactly twice.
The amount that the employee must pay for tolls by him/herself is the maximum total toll incurred in a single day during the travel, except the first day and the last day. The remaining tolls will be covered by the company.
Shik, as an employee of this company, has only one hope for his travel. He hopes that the amount he must pay for tolls by himself will be as small as possible. Please help Shik to design the travel which satisfies his hope.
Constraints
2<N<131,072
1≤ai≤i for all i
0≤vi≤131,072
vi
is an integer
The given tree is a full binary tree
Input
The input is given from Standard Input in the following format:
N
a1 v1
a2 v2
:
aN−1 vN−1
1
2
3
4
5
Output
Print an integer denoting the minimum amount Shik must pay by himself for tolls incurred during the travel.
Sample Input 1
7
1 1
1 1
2 1
2 1
3 1
3 1
1
2
3
4
5
6
7
Sample Output 1
4
1
There are 4 leaves in the tree formed by the cities (cities 4, 5, 6, and 7), so the travel must be 5 days long. There are 4!=24 possible arrangements of the leaf cities to stay during the travel, but some of them are invalid. For example, (4,5,6,7) and (6,7,5,4) are valid orders, but (5,6,7,4) is invalid because the route passes 4 times through the road connecting city 1 and city 2. The figure below shows the routes of the travel for these arrangements.
pic1
For all valid orders, day 3 is the day with the maximum total incurred toll of 4, passing through 4 roads.
Sample Input 2
9
1 2
1 2
3 2
3 2
5 2
5 2
7 2
7 2
1
2
3
4
5
6
7
8
9
Sample Output 2
6
1
The following figure shows the route of the travel for one possible arrangement of the stayed cities for the solution. Note that the tolls incurred in the first day and the last day are always covered by the company.
pic2
Sample Input 3
15
1 2
1 5
3 3
4 3
4 3
6 5
5 4
5 3
6 3
3 2
11 5
11 3
13 2
13 1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Sample Output 3
15
1
Sample Input 4
3
1 0
1 0
1
2
3
Sample Output 4
0
1
想到方法却不会证明复杂度系列……
神题一道.jpg
思路:
考虑先二分答案,那么现在问题变成了判定合法性。
只要咱们可以构建出一个合法的,且除了第一条和最后一条路径外,没有一条路径边权超过当前二分答案的方案,即可说明其合法性。
那么,考虑如何证明这样方案的存在性:
由于一条边经过次数不超过2,可以很容易发现这样的事实:一旦你进入了某棵子树,只有走完了里面的所有叶子结点,才可以出去。
那么考虑维护一种二元组,形如(a,b)u
,代表以当前节点u为根节点的子树中,入边的长度为a,出边的长度为b
,且这棵子树内部存在至少一条合法路径满足权值小于等于二分的答案,的一种方案。
于是每个节点均可以使用vector
存储若干个方案,可以很轻松的转移:
(a,b)u=(a,i)ch[0]+(j,b)ch[1](i+j<=ans)
注意二元组的 a,b
可以互换。
然而可以发现根节点的方案数将会等于爆搜搜到的方案数。
考虑优化状态数,可以发现对于每个a
,只会需求最小的一个合法的b配对,同理b
也是这样。
那么,分割线下为本蒟蒻未想到的部分……
考虑启发式合并,可以发现statecount(u)<=2∗min(statecount(ch[0]),statecount(ch[1]))
,因为咱们总是可以选取较小的那一边,此时每个a和b最多只会贡献一种新方案。
于是状态数变成O(nlogn),复杂度是十分正确的O(nlognlogv)
。
于是做完了~
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
int x=0;char ch=getchar();
while(ch<'0'|| ch>'9')ch=getchar();
while('0'<=ch && ch<='9')x=x*10+(ch^48),ch=getchar();
return x;
}
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<pr> vec;
#define x first
#define y second
const int N=131100;
int n,fa[N];
vec g[N],f[N];
ll mid,mv[N];
inline bool cmpx(pr a,pr b){return a.x<b.x;}
inline bool cmpy(pr a,pr b){return a.y<b.y;}
inline void work(vec &ls,vec &rs,vec &f)
{
if(ls.size()>rs.size())swap(ls,rs);
int el=ls.size(),er=rs.size();
sort(ls.begin(),ls.end(),cmpy);
sort(rs.begin(),rs.end(),cmpx);
mv[0]=rs[0].y;
for(int i=1;i<er;i++)
mv[i]=min(mv[i-1],rs[i].y);
for(int i=0,j=er-1;i<el;i++)
{
while(j>=0 && ls[i].y+rs[j].x>mid)j--;
if(j>=0)f.push_back(pr(ls[i].x,mv[j]));
}
sort(ls.begin(),ls.end(),cmpx);
sort(rs.begin(),rs.end(),cmpy);
mv[0]=rs[0].x;
for(int i=1;i<er;i++)
mv[i]=min(mv[i-1],rs[i].x);
for(int i=0,j=er-1;i<el;i++)
{
while(j>=0 && ls[i].x+rs[j].y>mid)j--;
if(j>=0)f.push_back(pr(mv[j],ls[i].y));
}
}
inline void dfs(int u)
{
if(!f[u].empty())f[u].clear();
if(g[u].empty())
{
f[u].push_back(pr(0,0));
return;
}
for(int i=0,e=g[u].size();i<e;i++)
dfs(g[u][i].x);
vec &ls=f[g[u][0].x];
for(int i=0,e=ls.size(),c=g[u][0].y;i<e;i++)
ls[i].x+=c,ls[i].y+=c;
vec &rs=f[g[u][1].x];
for(int i=0,e=rs.size(),c=g[u][1].y;i<e;i++)
rs[i].x+=c,rs[i].y+=c;
work(ls,rs,f[u]);
ls.clear();
rs.clear();
}
int main()
{
n=read();
for(int i=2,a;i<=n;i++)
{
fa[i]=read();
g[fa[i]].push_back(pr(i,read()));
}
ll l=0,r=1e10,ans=1e10;
while(l<=r)
{
mid=l+r>>1;
dfs(1);
if(f[1].empty())
l=mid+1;
else
r=mid-1,ans=mid;
}
printf("%lld\n",ans);
return 0;
} | a.cc:1:54: error: extended character − is not valid in an identifier
1 | cities numbered 1 through N, which are connected by N−1 bidirectional roads. In terms of graph theory, there is a unique simple path connecting every pair of cities. That is, the N cities form a tree. Besides, if we view city 1 as the root of this tree, the tree will be a full binary tree (a tree is a full binary tree if and only if every non-leaf vertex in the tree has exactly two children). Roads are numbered 1 through N−1. The i-th road connects city i+1 and city ai. When you pass through road i, the toll you should pay is vi (if vi is 0
| ^
a.cc:1:427: error: extended character − is not valid in an identifier
1 | cities numbered 1 through N, which are connected by N−1 bidirectional roads. In terms of graph theory, there is a unique simple path connecting every pair of cities. That is, the N cities form a tree. Besides, if we view city 1 as the root of this tree, the tree will be a full binary tree (a tree is a full binary tree if and only if every non-leaf vertex in the tree has exactly two children). Roads are numbered 1 through N−1. The i-th road connects city i+1 and city ai. When you pass through road i, the toll you should pay is vi (if vi is 0
| ^
a.cc:23:1: error: extended character ≤ is not valid in an identifier
23 | 1≤ai≤i for all i
| ^
a.cc:23:1: error: extended character ≤ is not valid in an identifier
a.cc:24:1: error: extended character ≤ is not valid in an identifier
24 | 0≤vi≤131,072
| ^
a.cc:24:1: error: extended character ≤ is not valid in an identifier
a.cc:37:1: error: extended character − is not valid in an identifier
37 | aN−1 vN−1
| ^
a.cc:37:6: error: extended character − is not valid in an identifier
37 | aN−1 vN−1
| ^
a.cc:163:1: error: extended character … is not valid in an identifier
163 | 想到方法却不会证明复杂度系列……
| ^
a.cc:163:1: error: extended character … is not valid in an identifier
a.cc:167:1: error: extended character 。 is not valid in an identifier
167 | 考虑先二分答案,那么现在问题变成了判定合法性。
| ^
a.cc:168:1: error: extended character 。 is not valid in an identifier
168 | 只要咱们可以构建出一个合法的,且除了第一条和最后一条路径外,没有一条路径边权超过当前二分答案的方案,即可说明其合法性。
| ^
a.cc:171:53: error: extended character 。 is not valid in an identifier
171 | 由于一条边经过次数不超过2,可以很容易发现这样的事实:一旦你进入了某棵子树,只有走完了里面的所有叶子结点,才可以出去。
| ^
a.cc:176:1: error: extended character 。 is not valid in an identifier
176 | ,且这棵子树内部存在至少一条合法路径满足权值小于等于二分的答案,的一种方案。
| ^
a.cc:183:1: error: extended character 。 is not valid in an identifier
183 | 可以互换。
| ^
a.cc:185:1: error: extended character 。 is not valid in an identifier
185 | 然而可以发现根节点的方案数将会等于爆搜搜到的方案数。
| ^
a.cc:189:1: error: extended character 。 is not valid in an identifier
189 | 也是这样。
| ^
a.cc:191:1: error: extended character … is not valid in an identifier
191 | 那么,分割线下为本蒟蒻未想到的部分……
| ^
a.cc:191:1: error: extended character … is not valid in an identifier
a.cc:193:40: error: extended character ∗ is not valid in an identifier
193 | 考虑启发式合并,可以发现statecount(u)<=2∗min(statecount(ch[0]),statecount(ch[1]))
| ^
a.cc:194:1: error: extended character 。 is not valid in an identifier
194 | ,因为咱们总是可以选取较小的那一边,此时每个a和b最多只会贡献一种新方案。
| ^
a.cc:197:1: error: extended character 。 is not valid in an identifier
197 | 。
| ^
a.cc:1:2: error: 'cities' does not name a type
1 | cities numbered 1 through N, which are connected by N−1 bidirectional roads. In terms of graph theory, there is a unique simple path connecting every pair of cities. That is, the N cities form a tree. Besides, if we view city 1 as the root of this tree, the tree will be a full binary tree (a tree is a full binary tree if and only if every non-leaf vertex in the tree has exactly two children). Roads are numbered 1 through N−1. The i-th road connects city i+1 and city ai. When you pass through road i, the toll you should pay is vi (if vi is 0
| ^~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:62,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:201:
/usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity
164 | __is_null_pointer(std::nullptr_t)
| ^
/usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)'
159 | __is_null_pointer(_Type)
| ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'?
164 | __is_null_pointer(std::nullptr_t)
| ^~~~~~~~~
In file included from /usr/include/c++/14/cstddef:50,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:41:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here
443 | typedef decltype(nullptr) nullptr_t;
| ^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'?
666 | struct is_null_pointer<std::nullptr_t>
| ^~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here
443 | typedef decltype(nullptr) nullptr_t;
| ^~~~~~~~~
/usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid
666 | struct is_null_pointer<std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid
670 | struct is_null_pointer<const std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid
674 | struct is_null_pointer<volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid
678 | struct is_null_pointer<const volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^
/usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1438 | : public integral_constant<std::size_t, 0> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid
1438 | : public integral_constant<std::size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared
1440 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope
1441 | struct rank<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid
1441 | struct rank<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1442:65: note: invalid template |
s751957558 | p03941 | C++ | #include<bits/stdc++.h>
using namespace std;
inline int read()
{
int x=0;char ch=getchar();
while(ch<'0'|| ch>'9')ch=getchar();
while('0'<=ch && ch<='9')x=x*10+(ch^48),ch=getchar();
return x;
}
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<pr> vec;
#define x first
#define y second
const int N=131100;
int n,fa[N];
vec g[N],f[N];
ll mid,mv[N];
inline bool cmpx(pr a,pr b){return a.x<b.x;}
inline bool cmpy(pr a,pr b){return a.y<b.y;}
inline void work(vec &ls,vec &rs,vec &f)
{
if(ls.size()>rs.size())swap(ls,rs);
int el=ls.size(),er=rs.size();
sort(ls.begin(),ls.end(),cmpy);
sort(rs.begin(),rs.end(),cmpx);Q
mv[0]=rs[0].y;
for(int i=1;i<er;i++)
mv[i]=min(mv[i-1],rs[i].y);
for(int i=0,j=er-1;i<el;i++)
{
while(j>=0 && ls[i].y+rs[j].x>mid)j--;
if(j>=0)f.push_back(pr(ls[i].x,mv[j]));
}
sort(ls.begin(),ls.end(),cmpx);
sort(rs.begin(),rs.end(),cmpy);
mv[0]=rs[0].x;
for(int i=1;i<er;i++)
mv[i]=min(mv[i-1],rs[i].x);
for(int i=0,j=er-1;i<el;i++)
{
while(j>=0 && ls[i].x+rs[j].y>mid)j--;
if(j>=0)f.push_back(pr(mv[j],ls[i].y));
}
}
inline void dfs(int u)
{
if(!f[u].empty())f[u].clear();
if(g[u].empty())
{
f[u].push_back(pr(0,0));
return;
}
for(int i=0,e=g[u].size();i<e;i++)
dfs(g[u][i].x);
vec &ls=f[g[u][0].x];
for(int i=0,e=ls.size(),c=g[u][0].y;i<e;i++)
ls[i].x+=c,ls[i].y+=c;
vec &rs=f[g[u][1].x];
for(int i=0,e=rs.size(),c=g[u][1].y;i<e;i++)
rs[i].x+=c,rs[i].y+=c;
cout<<ls.size()<<" "<<rs.size()<<endl;
work(ls,rs,f[u]);
ls.clear();
rs.clear();
}
int main()
{
n=read();
for(int i=2,a;i<=n;i++)
{
fa[i]=read();
g[fa[i]].push_back(pr(i,read()));
}
ll l=0,r=1e10,ans=1e10;
while(l<=r)
{
mid=l+r>>1;
cout<<l<<" "<<r<<" "<<mid<<endl;
dfs(1);
if(f[1].empty())
l=mid+1;
else
r=mid-1,ans=mid;
}
printf("%lld\n",ans);
return 0;
} | a.cc: In function 'void work(vec&, vec&, vec&)':
a.cc:33:36: error: 'Q' was not declared in this scope
33 | sort(rs.begin(),rs.end(),cmpx);Q
| ^
|
s661011302 | p03941 | C++ | sdsadsadsa | a.cc:1:1: error: 'sdsadsadsa' does not name a type
1 | sdsadsadsa
| ^~~~~~~~~~
|
s286002843 | p03941 | C++ | #include<bits/stdc++.h>
#define rep(i,a,b) for (int i=(a); i<=(b); ++i)
#define per(i,a,b) for (int i=(a); i>=(b); --i)
#define REP(i,a) for (int i=0; i<(a); ++i)
#define PER(i,a) for (int i=int(a)-1; i>=0; --i)
using namespace std;
typedef long long LL;
const int maxn = 150005;
struct node { LL x, y; } f[maxn], g[maxn];
int l[maxn], r[maxn], v[maxn], n, fa;
vector<node> a[maxn];
LL L, R, mid;
inline bool operator < (node a, node b) {
return a.x < b.x || a.x == b.x && a.y < b.y;
}
void merge(vector<node> &a, vector<node> &b, vector<node> &c, LL limit) {
int n = 0, m = 0, cur = 0, p = 1, q = 1;
REP (i, a.size()) {
while (cur + 1 < b.size() && a[i].y + b[cur+1].x <= limit) cur++;
if (cur < b.size() && a[i].y + b[cur].x <= limit) f[++n] = (node){a[i].x, b[cur].y};
}
cur = int(b.size())-1;
PER (i, a.size()) {
while (cur - 1 >= 0 && a[i].x + b[cur-1].y <= limit) cur--;
if (cur >= 0 && a[i].x + b[cur].y <= limit) g[++m] = (node){b[cur].x, a[i].y};
}
rep (i, 1, m/2) swap(g[i], g[m+1-i]);
while (p <= n || q <= m) {
if (p <= n && (q > m || f[p] < g[q])) c.push_back(f[p]);
else c.push_back(g[q]);
while (p <= n && (c.back().x == f[p].x || c.back().y <= f[p].y) p++;
while (q <= m && (c.back().x == g[q].x || c.back().y <= g[q].y) q++;
}
}
bool check(LL limit) {
// printf("======= %lld =======\n", limit);
per (i, n, 1) {
a[i].clear();
if (!l[i]) {
a[i].push_back((node){v[i], v[i]});
continue;
}
if (a[l[i]].size() < a[r[i]].size())
merge(a[l[i]], a[r[i]], a[i], limit);
else
merge(a[r[i]], a[l[i]], a[i], limit);
if (a[i].empty()) return 0;
REP (j, a[i].size())
a[i][j].x += v[i], a[i][j].y += v[i];
// printf("%d ", i);
// REP (j, a[i].size())
// printf("(%d,%d) ", a[i][j].x, a[i][j].y);
// puts("");
}
return 1;
}
int main() {
scanf("%d", &n);
rep (i, 2, n) {
scanf("%d%d", &fa, &v[i]);
if (!l[fa]) l[fa] = i;
else r[fa] = i;
}
L = 0; R = 1LL << 34;
while (L < R) {
mid = (L + R) >> 1;
if (check(mid)) R = mid;
else L = mid + 1;
}
printf("%lld\n", L);
return 0;
} | a.cc: In function 'void merge(std::vector<node>&, std::vector<node>&, std::vector<node>&, LL)':
a.cc:34:80: error: expected ')' before 'p'
34 | while (p <= n && (c.back().x == f[p].x || c.back().y <= f[p].y) p++;
| ~ ^~
| )
a.cc:35:80: error: expected ')' before 'q'
35 | while (q <= m && (c.back().x == g[q].x || c.back().y <= g[q].y) q++;
| ~ ^~
| )
|
s241953388 | p03941 | C++ | #include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int MAXN = 2e5 + 10;
long long oo = 100000000000007ll;
class Edges{
public:
int next , to , v;
};
Edges edge[MAXN];
int fa[MAXN] , first[MAXN];
int n , te = 0 , ans = 0;
void add(int s , int t , int v){
++ te;
edge[te].to = t;
edge[te].next = first[s];
edge[te].v = v;
first[s] = te;
}
long long work(int now){
long long maxn = 0 , t = oo;
for(int e = first[now] ; e ; e = edge[e].next){
int to = edge[e].to;
long long ret = work(to);
maxn += ret + edge[e].v;
t = min(ret + edge[e].v , t);
}
ans = max(ans , maxn);
if(t == oo) t = 0;
return t;
}
int main(){
ios::sync_with_stdio(0);
cin >> n;
for(int i = 2 ; i <= n ; ++ i){
int a , v;
cin >> a >> v;
add(a , i , v);
}
work(1);
cout << ans << endl;
return 0;
} | a.cc: In function 'long long int work(int)':
a.cc:32:18: error: no matching function for call to 'max(int&, long long int&)'
32 | ans = max(ans , maxn);
| ~~~^~~~~~~~~~~~
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:32:18: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
32 | ans = max(ans , maxn);
| ~~~^~~~~~~~~~~~
/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
|
s374995327 | p03941 | C++ | #include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int MAXN = 2e5 + 10;
long long oo = 100000000000007ll;
class Edges{
public:
int next , to , v;
};
Edges edge[MAXN];
int fa[MAXN] , first[MAXN];
int n , te = 0 , ans = 0;
void add(int s , int t , int v){
++ te;
edge[te].to = t;
edge[te].next = first[s];
edge[te].v = v;
first[s] = te;
}
long long work(int now){
long long maxn = 0 , t = oo;
for(int e = first[now] ; e ; e = edge[e].next){
int to = edge[e].to , ret = work(to);
maxn += ret + edge[e].v;
t = min(ret + edge[e].v , t);
}
ans = max(ans , maxn);
if(t == oo) t = 0;
return t;
}
int main(){
ios::sync_with_stdio(0);
cin >> n;
for(int i = 2 ; i <= n ; ++ i){
int a , v;
cin >> a >> v;
add(a , i , v);
}
work(1);
cout << ans << endl;
return 0;
} | a.cc: In function 'long long int work(int)':
a.cc:29:24: error: no matching function for call to 'min(int, long long int&)'
29 | t = min(ret + edge[e].v , t);
| ~~~^~~~~~~~~~~~~~~~~~~~~
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:29:24: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
29 | t = min(ret + edge[e].v , t);
| ~~~^~~~~~~~~~~~~~~~~~~~~
/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
a.cc:31:18: error: no matching function for call to 'max(int&, long long int&)'
31 | ans = max(ans , maxn);
| ~~~^~~~~~~~~~~~
/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:31:18: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
31 | ans = max(ans , maxn);
| ~~~^~~~~~~~~~~~
/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
|
s356462451 | p03941 | C++ | #include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
using namespace std;
static const int INF = 0x3f3f3f3f;
int main() {
int n;
scanf("%d", &n);
vector<vector<pair<int, int>>> g(n), dp(n);
for (int i = 1; i < n; i ++) {
int a, v;
scanf("%d%d", &a, &v);
a --;
g[a].emplace_back(v, i);
}
function<void (int, int)> dfs = [&](int u, int x) {
if (g[u].size() == 0) return;
pair<int, int> a = g[u][0], b = g[u][1];
dfs(a.second, x);
dfs(b.second, x);
int l = a.first + b.first;
vector<pair<int, int>> v;
if (dp[a.second].size() > dp[b.second].size()) swap(a, b);
for (int i = 0, j = 0; i < dp[a.second].size(); i ++) {
while (j < dp[b.second].size() && dp[b.second][j].first + dp[a.second][i].second + l <= x) j ++;
if (j != 0) {
v.emplace_back(dp[a.second][i].first + a.first, dp[b.second][j - 1].second + b.first);
}
}
for (int i = 0, j = 0; i < dp[a.second].size(); i ++) {
while (j < dp[b.second].size() && dp[b.second][j].second + dp[a.second][i].first + l > x) j ++;
if (j != dp[b.second].size()) {
v.emplace_back(dp[b.second][j].first + b.first, dp[a.second][i].second + a.first);
}
}
sort(v.begin(), v.end());
int now = INF;
for (int i = 0; i < v.size(); i ++) {
if (i > 0 && v[i].first == v[i - 1].first) continue;
if (now > v[i].second) {
dp[u].push_back(v[i]);
now = v[i].second;
}
}
};
function<bool (int)> check = [&](int x) {
for (int i = 0; i < n; i ++) if (g[i].size() == 0) dp[i].emplace_back(0, 0);
dfs(0, x);
int ok = dp[0].size();
for (int i = 0; i < n; i ++) dp[i].clear();
return ok != 0;
};
int lb = 0, ub = 1e9, ans = -1;
while (lb <= ub) {
int mid = (lb + ub) / 2;
if (check(mid)) ans = mid, ub = mid - 1;
else lb = mid + 1;
}
printf("%d\n", ans);
return 0;
}
| a.cc: In function 'int main()':
a.cc:22:9: error: 'function' was not declared in this scope
22 | function<void (int, int)> dfs = [&](int u, int x) {
| ^~~~~~~~
a.cc:8:1: note: 'std::function' is defined in header '<functional>'; this is probably fixable by adding '#include <functional>'
7 | #include <set>
+++ |+#include <functional>
8 | using namespace std;
a.cc:22:32: error: expression list treated as compound expression in functional cast [-fpermissive]
22 | function<void (int, int)> dfs = [&](int u, int x) {
| ^
a.cc:22:18: error: expected primary-expression before 'void'
22 | function<void (int, int)> dfs = [&](int u, int x) {
| ^~~~
a.cc:52:18: error: expected primary-expression before 'bool'
52 | function<bool (int)> check = [&](int x) {
| ^~~~
a.cc:62:21: error: 'check' was not declared in this scope
62 | if (check(mid)) ans = mid, ub = mid - 1;
| ^~~~~
|
s792615022 | p03941 | C++ | #include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
const int maxn = 2e5;
int n, son[maxn][2], len[maxn];
long long ans;
typedef pair<long long, long long> Pair;
vector<Pair> set[maxn];
void Combine(vector<Pair> &s, int u, int v) {
s.clear();
if (u.empty()) {
return;
}
for (int i = 0, j = 0; i < set[u].size(); ++i) {
if (len[u] + len[v] + set[u][i].second + set[v][j].first > ans) {
continue;
}
while (j + 1 < set[v].size() &&
len[u] + len[v] + set[u][i].second + set[v][j + 1].first <= ans) {
++j;
}
s.push_back(Pair(len[u] + set[u][i].first, len[v] + set[v][j].second));
}
int m = s.size();
for (int i = set[u].size() - 1, j = set[v].size() - 1; i >= 0; --i) {
if (len[u] + len[v] + set[v][j].second + set[u][i].first > ans) {
continue;
}
while (j > 0 &&
len[u] + len[v] + set[v][j - 1].second + set[u][i].first <= ans) {
--j;
}
s.push_back(Pair(len[v] + set[v][j].first, len[u] + set[u][i].second));
}
inplace_merge(s.begin(), s.begin() + m, s.end());
m = 0;
for (int i = 0; i < s.size(); ++i) {
if (i == 0 || s[i].second < s[i - 1].second) {
s[m++] = s[i];
}
}
s.resize(m);
}
bool Check(void) {
for (int i = n - 1; i >= 0; --i) {
if (son[i][0] == -1) {
set[i] = {Pair(0, 0)};
} else {
int &u = son[i][0], &v = son[i][1];
if (set[u].size() > set[v].size()) {
swap(u, v);
}
Combine(set[i], u, v);
}
}
return set[0].size();
}
int main(void) {
scanf("%d", &n);
memset(son, -1, sizeof son);
for (int i = 1; i < n; ++i) {
int par;
scanf("%d%d", &par, len + i);
--par;
swap(son[par][0], son[par][1]);
son[par][0] = i;
}
long long low = 0, high = (long long)maxn * maxn;
while (low < high) {
long long mid = low + high >> 1;
ans = mid;
if (Check()) {
high = mid;
} else {
low = mid + 1;
}
}
printf("%lld\n", low);
return 0;
}
| a.cc: In function 'void Combine(std::vector<std::pair<long long int, long long int> >&, int, int)':
a.cc:16:9: error: request for member 'empty' in 'u', which is of non-class type 'int'
16 | if (u.empty()) {
| ^~~~~
|
s523367612 | p03941 | C++ | #include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<vector>
using namespace std;
typedef long long s64;
const int ONE = 1000005;
const int INF = 2147483640;
int get()
{
int res = 1, Q = 1; char c;
while( (c = getchar()) < 48 || c > 57)
if(c == '-') Q = -1;
if(Q) res = c - 48;
while( (c = getchar()) >= 48 && c <= 57)
res = res * 10 + c - 48;
return res * Q;
}
struct power
{
s64 a, b;
bool operator <(power A) const
{
if(A.a != a) return a < A.a;
return b < A.b;
}
};
vector <power> A[ONE], R;
int n;
int x, y;
s64 l, r, K;
int next[ONE], first[ONE], go[ONE], w[ONE], tot;
int size[ONE], times[ONE], fat[ONE];
void Add(int u, int v, int z)
{
next[++tot] = first[u], first[u] = tot, go[tot] = v, w[tot] = z;
next[++tot] = first[v], first[v] = tot, go[tot] = u, w[tot] = z;
}
int dist[ONE];
int len_x, len_y;
s64 a1, b1, a2, b2;
int Find()
{
if(len_y == 0) return len_y;
int l = 0, r = len_y - 1;
while(l < r - 1)
{
int mid = l + r >> 1;
a2 = A[y][mid].a, b2 = A[y][mid].b;
if(b1 + a2 + dist[x] + dist[y] <= K) l = mid;
else r = mid;
}
a2 = A[y][r].a, b2 = A[y][r].b; if(b1 + a2 + dist[x] + dist[y] <= K) return r;
a2 = A[y][l].a, b2 = A[y][l].b; if(b1 + a2 + dist[x] + dist[y] <= K) return l;
return len_y;
}
void Update(int u)
{
x = 0, y = 0;
for(int e = first[u]; e; e = next[e])
if(go[e] != fat[u])
if(!x) x = go[e]; else y = go[e];
if(size[x] > size[y]) swap(x, y);
// cout<<"FKFKFKFK===="<<u<<" "<<x<<" "<<y<<endl;
len_x = A[x].size(), len_y = A[y].size();
R.clear();
for(int i = 0; i < len_x; i++)
{
a1 = A[x][i].a, b1 = A[x][i].b;
int id = Find();
if(id >= len_y) continue;
// cout<<y<<" "<<len_y<<" "<<id<<endl;
// cout<<u<<"======"<<dist[x]<<","<<b2+dist[y]<<endl;
R.push_back((power){a1 + dist[x], b2 + dist[y]});
R.push_back((power){b2 + dist[y], a1 + dist[x]});
}
// cout<<"FKFKFKFK===="<<u<<" "<<x<<" "<<y<<endl;
sort(R.begin(), R.end());
int len = R.size(), maxx = INF;
/* cout<<u<<":"<<endl;
for(int i = 0; i < len; i++)
cout<<R[i].a<<" "<<R[i].b<<endl;
*/
for(int i = 0; i < len; i++)
if(R[i].b < maxx)
{
if(i != 0 && R[i - 1].a == R[i].a) continue;
A[u].push_back((power){R[i].a, R[i].b}), maxx = R[i].b;
// cout<<R[i].a<<" "<<R[i].b<<endl;
}
}
void Dfs(int u, int father)
{
size[u] = 1, times[u] = 0;
int pd = 1;
for(int e = first[u]; e; e = next[e])
{
int v = go[e];
if(v == father) continue;
pd = 0, fat[v] = u, dist[v] = w[e];
Dfs(v, u);
size[u] += size[v], times[u]++;
if(times[u] == 2) Update(u);
}
if(pd) A[u].push_back((power){0, 0});
}
int Check()
{
for(int i = 1; i <= n; i++)
A[i].clear();
Dfs(1, 0);
/* for(int i = 1; i <= n; i++)
{
cout<<i<<": "<<A[i].size()<<endl;
for(int j = 0; j < A[i].size(); j++)
cout<<A[i][j].a<<" "<<A[i][j].b<<endl;
cout<<endl;
}
*/
return A[1].size() > 0;
}
int main()
{
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
n = get();
for(int i = 2; i <= n; i++)
{
x = get(), y = get();
Add(i, x, y), r += y;
}
while(l < r - 1)
{
K = l + r >> 1;
if(Check()) r = K;
else l = K;
}
K = l;
if(Check()) printf("%d", l);
else printf("%d", r);
} | a.cc: In function 'void Add(int, int, int)':
a.cc:45:17: error: reference to 'next' is ambiguous
45 | next[++tot] = first[u], first[u] = tot, go[tot] = v, w[tot] = z;
| ^~~~
In file included from /usr/include/c++/14/string:47,
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_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:40:5: note: 'int next [1000005]'
40 | int next[ONE], first[ONE], go[ONE], w[ONE], tot;
| ^~~~
a.cc:46:17: error: reference to 'next' is ambiguous
46 | next[++tot] = first[v], first[v] = tot, go[tot] = u, w[tot] = z;
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:40:5: note: 'int next [1000005]'
40 | int next[ONE], first[ONE], go[ONE], w[ONE], tot;
| ^~~~
a.cc: In function 'void Update(int)':
a.cc:72:46: error: reference to 'next' is ambiguous
72 | for(int e = first[u]; e; e = next[e])
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:40:5: note: 'int next [1000005]'
40 | int next[ONE], first[ONE], go[ONE], w[ONE], tot;
| ^~~~
a.cc:76:20: error: reference to 'size' is ambiguous
76 | if(size[x] > size[y]) swap(x, y);
| ^~~~
In file included from /usr/include/c++/14/string:53:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:41:5: note: 'int size [1000005]'
41 | int size[ONE], times[ONE], fat[ONE];
| ^~~~
a.cc:76:30: error: reference to 'size' is ambiguous
76 | if(size[x] > size[y]) swap(x, y);
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:41:5: note: 'int size [1000005]'
41 | int size[ONE], times[ONE], fat[ONE];
| ^~~~
a.cc: In function 'void Dfs(int, int)':
a.cc:112:17: error: reference to 'size' is ambiguous
112 | size[u] = 1, times[u] = 0;
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:41:5: note: 'int size [1000005]'
41 | int size[ONE], times[ONE], fat[ONE];
| ^~~~
a.cc:114:46: error: reference to 'next' is ambiguous
114 | for(int e = first[u]; e; e = next[e])
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:40:5: note: 'int next [1000005]'
40 | int next[ONE], first[ONE], go[ONE], w[ONE], tot;
| ^~~~
a.cc:120:25: error: reference to 'size' is ambiguous
120 | size[u] += size[v], times[u]++;
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:41:5: note: 'int size [1000005]'
41 | int size[ONE], times[ONE], fat[ONE];
| ^~~~
a.cc:120:36: error: reference to 'size' is ambiguous
120 | size[u] += size[v], times[u]++;
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:41:5: note: 'int size [1000005]'
41 | int size[ONE], times[ONE], fat[ONE];
| ^~~~
|
s992281896 | p03941 | C++ | #include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>
#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if
#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;
typedef vector<pair<ll,ll> > Vp;
int IN(){
int c,f,x;
while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}
const int N=140000+19;
struct Edge{
int y,z,nxt;
} E[N*2];
int las[N];
int n,cnt,x;
Vp F[N];
ll l,r,mid;
void Add_Edge(int x,int y,int z){
E[cnt]=(Edge){y,z,las[x]};las[x]=cnt++;
}
Vp Merge(Vp A,Vp B){
Vp res,ans;
int c=-1;
For(i,0,A.size()){
for (;c+1<B.size()&&A[i].se+B[c+1].fi<=mid;c++);
if (c>=0) res.pb(mp(A[i].fi,B[c].se));
}
c=-1;
For(i,0,B.size()){
for (;c+1<A.size()&&B[i].se+A[c+1].fi<=mid;c++);
if (c>=0) res.pb(mp(B[i].fi,A[c].se));
}
sort(res.begin(),res.end());
For(i,0,res.size()){
//if (res[i].fi>mid||res[i].se>mid) continue;
if (!ans.empty()&&res[i].se>=ans.back().se) continue;
ans.pb(res[i]);
}
return ans;
}
void dfs(int x){
if (las[x]==-1){
F[x]={mp(0,0)};
return;
}
int len[2],to[2],c=0;
for (int i=las[x],y;~i;i=E[i].nxt){
to[c]=E[i].y;
dfs(to[c]);
len[c++]=E[i].z;
}
For(i,0,2) For(j,0,F[to[i]].size()){
F[to[i]][j].fi+=len[i];
F[to[i]][j].se+=len[i];
}
F[x7
1 1
1 1
2 1
2 1
3 1
3 1]=Merge(F[to[0]],F[to[1]]);
}
int main(){
//freopen("048.txt","r",stdin);
memset(las,-1,sizeof(las));
n=IN();
For(i,2,n+1){
x=IN();
Add_Edge(x,i,IN());
}
l=0,r=131072ll*n;
while (l<=r){
mid=(l+r)/2;
dfs(1);
if (!F[1].empty()) r=mid-1;else l=mid+1;
}
cout<<r+1<<endl;
} | a.cc: In function 'void dfs(int)':
a.cc:87:11: error: 'x7' was not declared in this scope; did you mean 'x'?
87 | F[x7
| ^~
| x
a.cc:87:13: error: expected ']' before numeric constant
87 | F[x7
| ^
| ]
88 | 1 1
| ~
|
s438129101 | p03941 | C++ | #include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)
#define pb push_back
#define x first
#define y second
#define mp make_pair
using namespace std;
const int N = 132000;
typedef long long LL;
typedef pair<LL, LL> PII;
int lc[N], rc[N];
int val[N], fa[N], n;
vector<PII> c[N];
LL lim;
bool cmp(PII u, PII v){
return u.x < v.x;
}
bool DFS(int o){
if(!lc[o]){
c[o].pb(mp(val[o], val[o]));
return true;
}
if(!DFS(lc[o])) return false;
if(!DFS(rc[o])) return false;
if(c[lc[o]].size() > c[rc[o]].size()) swap(lc[o], rc[o]);
int u = lc[o], v = rc[o];
int m = c[v].size(), p = m - 1;
for(PII i : c[u]){
while(p >= 0 && i.x + c[v][p].x > lim) --p;
if(p < 0) break;
//printf("%lld %lld %d\n", i.x, c[v][p].x, p);
c[o].pb(mp(i.y, c[v][p].y)), c[o].pb(mp(c[v][p].y, i.y));
}
sort(c[o].begin(), c[o].end(), cmp);
if(!c[o].size()) return false;
//printf("%d:\n", o);
for(PII& i : c[o]){
i.x += val[o], i.y += val[o];
// printf("%lld %lld\n", i.x, i.y);
}
return true;
}
int main(){
scanf("%d", &n);
For(i, 2, n){
scanf("%d%d", &fa[i], &val[i]);
if(lc[fa[i]]) rc[fa[i]] = i;
else lc[fa[i]] = i;
}
LL L = 0, R = 1ll << 35;
while(L < R){
lim = (L + R) >> 1;
For(i, 1, n) c[i].clear();
//printf("------\n%lld\n", lim);
if(DFS(1)) R = lim;
else L = lim + 1;
}
printf("%lld\n", L);
return 0;
} | a.cc:23:1: error: 'vector' does not name a type
23 | vector<PII> c[N];
| ^~~~~~
a.cc: In function 'bool DFS(int)':
a.cc:32:17: error: 'c' was not declared in this scope
32 | c[o].pb(mp(val[o], val[o]));
| ^
a.cc:38:12: error: 'c' was not declared in this scope
38 | if(c[lc[o]].size() > c[rc[o]].size()) swap(lc[o], rc[o]);
| ^
a.cc:41:17: error: 'c' was not declared in this scope
41 | int m = c[v].size(), p = m - 1;
| ^
a.cc:43:23: error: 'p' was not declared in this scope
43 | while(p >= 0 && i.x + c[v][p].x > lim) --p;
| ^
a.cc:44:20: error: 'p' was not declared in this scope
44 | if(p < 0) break;
| ^
a.cc:46:38: error: 'p' was not declared in this scope
46 | c[o].pb(mp(i.y, c[v][p].y)), c[o].pb(mp(c[v][p].y, i.y));
| ^
a.cc: In function 'int main()':
a.cc:70:30: error: 'c' was not declared in this scope
70 | For(i, 1, n) c[i].clear();
| ^
|
s427375156 | p03941 | C++ | #include <bits/stdc++.h>
#define int ll
#define N 210010
#define ls c[rt][0]
#define rs c[rt][1]
#define lw w[rt][0]
#define rw w[rt][1]
using namespace std;
typedef long long ll;
inline int read()
{
int x=0,f=1; char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
return x*f;
}
struct node{ll x,y;};
int n,c[N][2],w[N][2],tmp1,tmp2;
vector <node> V[N];
node tt1[N],tt2[N];
inline void Insert(int x,node d)
{
int i=V[x].size()-1;
if(V[x].empty()) { V[x].push_back(d); return ;}
if(V[x][i].y<=d.y) return ;
while(i>=0&&V[x][i].x>=d.x) i--,V[x].pop_back();
V[x].push_back(d);
}
bool check(int rt,ll tar)
{
V[rt].clear();
if(!ls){Insert(rt,(node){0,0}); return 1;}
int ck=check(ls,tar)|check(rs,tar);
if(!ck) return ck; tmp1=0; tmp2=0;
int ll=V[ls].size()-1,rr=V[rs].size()-1;
for(int i=ll,j=rr;i>=0;i--)
{
while(j>=0&&V[ls][i].x+V[rs][j].y+lw+rw>tar) j--;
if(j>=0) tt1[++tmp1]=(node){V[ls][i].x+lw,V[rs][j].y+rw};
}
for(int i=rr,j=ll;i>=0;i--)
{
while(j>=0&&V[rs][i].x+V[ls][j].y+lw+rw>tar) j--;
if(j>=0) tt2[++tmp2]=(node){V[rs][i].x+rw,V[ls][j].y+lw};
}
for(int i=1,j=tmp1;i<=j;i++,j--) swap(tt1[i],tt1[j]);
for(int i=1,j=tmp2;i<=j;i++,j--) swap(tt2[i],tt2[j]);
int i=1,j=1; while(i<=tmp1&&j<=tmp2)
{
if(tt1[i].x<tt2[j].x) Insert(rt,tt1[i]),i++;
else Insert(rt,tt2[j]),j++;
} while(i<=tmp1) Insert(rt,tt1[i]),i++;
while(j<=tmp2) Insert(rt,tt2[j]),j++;
return !V[rt].empty();
}
signed main()
{
//freopen("read.in","r",stdin);
n=read(); for(int i=2;i<=n;i++)
{
int rt=read(),y=read();
if(!ls) ls=i,lw=y; else rs=i,rw=y;
}
ll l=0, r=1000000000000ll, ans=0;
while(l<=r)
{
ll mid=(l+r)>>1;// mid=14;
if(check(1,mid)) ans=mid,r=mid-1;
else l=mid+1;
}cout << ans << endl; return 0;
} | a.cc: In function 'bool check(ll, ll)':
a.cc:37:17: error: expected ';' before 'i'
37 | for(int i=ll,j=rr;i>=0;i--)
| ^
a.cc:37:27: error: 'i' was not declared in this scope
37 | for(int i=ll,j=rr;i>=0;i--)
| ^
a.cc:39:23: error: 'j' was not declared in this scope
39 | while(j>=0&&V[ls][i].x+V[rs][j].y+lw+rw>tar) j--;
| ^
a.cc:40:20: error: 'j' was not declared in this scope
40 | if(j>=0) tt1[++tmp1]=(node){V[ls][i].x+lw,V[rs][j].y+rw};
| ^
a.cc:42:17: error: expected ';' before 'i'
42 | for(int i=rr,j=ll;i>=0;i--)
| ^
a.cc:42:27: error: 'i' was not declared in this scope
42 | for(int i=rr,j=ll;i>=0;i--)
| ^
a.cc:44:23: error: 'j' was not declared in this scope
44 | while(j>=0&&V[rs][i].x+V[ls][j].y+lw+rw>tar) j--;
| ^
a.cc:45:20: error: 'j' was not declared in this scope
45 | if(j>=0) tt2[++tmp2]=(node){V[rs][i].x+rw,V[ls][j].y+lw};
| ^
a.cc:47:17: error: expected ';' before 'i'
47 | for(int i=1,j=tmp1;i<=j;i++,j--) swap(tt1[i],tt1[j]);
| ^
a.cc:47:28: error: 'i' was not declared in this scope
47 | for(int i=1,j=tmp1;i<=j;i++,j--) swap(tt1[i],tt1[j]);
| ^
a.cc:47:31: error: 'j' was not declared in this scope
47 | for(int i=1,j=tmp1;i<=j;i++,j--) swap(tt1[i],tt1[j]);
| ^
a.cc:48:17: error: expected ';' before 'i'
48 | for(int i=1,j=tmp2;i<=j;i++,j--) swap(tt2[i],tt2[j]);
| ^
a.cc:48:28: error: 'i' was not declared in this scope
48 | for(int i=1,j=tmp2;i<=j;i++,j--) swap(tt2[i],tt2[j]);
| ^
a.cc:48:31: error: 'j' was not declared in this scope
48 | for(int i=1,j=tmp2;i<=j;i++,j--) swap(tt2[i],tt2[j]);
| ^
a.cc:49:13: error: expected ';' before 'i'
49 | int i=1,j=1; while(i<=tmp1&&j<=tmp2)
| ^
a.cc:49:28: error: 'i' was not declared in this scope
49 | int i=1,j=1; while(i<=tmp1&&j<=tmp2)
| ^
a.cc:49:37: error: 'j' was not declared in this scope
49 | int i=1,j=1; while(i<=tmp1&&j<=tmp2)
| ^
a.cc:53:17: error: 'i' was not declared in this scope
53 | } while(i<=tmp1) Insert(rt,tt1[i]),i++;
| ^
a.cc:54:17: error: 'j' was not declared in this scope
54 | while(j<=tmp2) Insert(rt,tt2[j]),j++;
| ^
|
s809684299 | p03941 | C++ | #include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
typedef pair<ll,ll> P;
int N;
const int MN=1<<17;
int ch[MN][2],co[MN],sz[MN];
vector<P> vp[MN];
vector<P> tmp1,tmp2,tmp;
vector<P> norm(vector<P>& vc){
vector<P> ret;
for(P p:vc){
if(ret.empty() || ret.back().sc!=p.sc) ret.pb(p);
}
return ret;
}
bool can(ll X){
rep(i,N) vp[i].clear();
for(int v=N-1;v>=0;v--){
if(ch[v][0]==-1){
sz[v]=1;
vp[v].pb(P(co[v],co[v]));
}else{
tmp1.clear();tmp2.clear();
int a=ch[v][0],b=ch[v][1];
if(sz[a]>sz[b]) swap(a,b);
int j=0;
int A = vp[a].size();
rep(i,A){
P p=vp[a][i];
ll left=X-p.sc;
while(j<B && vp[b][j].fs<=left) j++;
if(j==0) continue;
ll l=p.fs+co[v],r=vp[b][j-1].sc+co[v];
if(v==0) return 1;
tmp1.pb(P(l,r));
}
tmp1=norm(tmp1);
int K=tmp1.size();
tmp2.assign(K,P(0,0));
rep(i,K){
P p=tmp1[i];
tmp2[K-1-i]=P(p.sc,p.fs);
}
tmp.assign(2*K,P(0,0));
merge(all(tmp1),all(tmp2),tmp.begin());
ll mn=1e18;
rep(i,2*K){
P p=tmp[i];
ll l=p.fs,r=p.sc;
chmin(mn,r);
if(i==2*K-1 || tmp[i].fs!=tmp[i+1].fs) vp[v].pb(P(l,mn));
}
tmp=vp[v];
vp[v].clear();
K=tmp.size();
rep(i,K){
if(i==K-1||tmp[i].sc!=tmp[i+1].sc) vp[v].pb(tmp[i]);
}
}
if(vp[v].empty()) return 0;
}
return 1;
}
int main(){
cin>>N;
rep(i,N) rep(j,2) ch[i][j]=-1;
rep(i,N-1){
int a,v;
cin>>a>>v;
a--;
if(ch[a][0]==-1){
ch[a][0]=i+1;
}else{
ch[a][1]=i+1;
}
co[i+1]=v;
}
ll ub=131072*40,lb=-1;
while(ub-lb>1){
ll m=(ub+lb)/2;
if(can(m)) ub=m;
else lb=m;
}
cout<<ub<<endl;
}
| a.cc: In function 'bool can(ll)':
a.cc:44:41: error: 'B' was not declared in this scope
44 | while(j<B && vp[b][j].fs<=left) j++;
| ^
|
s233060920 | p03941 | C++ | #include <bits/stdc++.h>
#define LL long long
#define INF 0x7FFFFFFF//or 0x3f3f3f3f ? -Wall
using namespace std;
template<class T> inline
void read(T& x) {
int f = 1; x = 0;
char ch = getchar();
while (ch < '0' || ch > '9') {if (ch == '-') f = -1; ch = getchar();}
while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
x *= f;
}
/*============ Header Template ============*/
const int N = 150000 + 5;
struct node {
LL a, b;
node(LL _a = 0, LL _b = 0) {a = _a, b = _b;}
bool operator < (const node &T) {
if (a == T.a) return b < T.b;
return a < T.a;
}
};
int n; LL V;
std::vector<LL> w[N];
std::vector<int> v[N];
std::vector<node> S[N];
void dfs(int x) {
//printf("%d\n", x);
S[x].clear();
if (!v[x].size()) {S[x].push_back(node(0, 0)); return;}
int k = v[x][0], l = v[x][1];
LL vk = w[x][0], vl = w[x][1];
dfs(k); dfs(l);
if (S[k].size() > S[l].size()) swap(k, l), swap(vk, vl);
if (!S[k].size()) return;
for (int i = 0, j = 0; i < S[k].size(); i++) {
LL a = S[k][i].a, b = S[k][i].b;
while (j + 1 < S[l].size() && b + S[l][j + 1].a + vk + vl <= V) j++;
if (b + S[l][j].a + vk + vl <= V) S[x].push_back(node(a + vk, S[l][j].b + vl));
}
for (int i = 0, j = S[l].size() - 1; i < S[k].size(); i++) {
LL a = S[k][i].a, b = S[k][i].b;
while (j && a + S[l][j - 1].b + vk + vl <= V) j--;
if (a + S[l][j].b + vk + vl <= V) S[x].push_back(node(S[l][j].a + vl, b + vk));
}
sort(S[x].begin(), S[x].end());
}
int check(LL val) {
V = val; dfs(1);
return S[1].size() ? 1 : 0;
}
int main() {
//freopen("d.in", "r", stdin);
read(n);
LL l = 0, r = 0, ans;
LL x, y;
for (int i = 2; i <= n; i++) {
read(x), read(y);
v[x].push_back(i);
w[x].push_back(y);
r += y;
}
check
while (l <= r) {
LL m = (l + r) >> 1;
if (check(m)) {
ans = m;
r = m - 1;
} else l = m + 1;
}
while (1);
printf("%lld\n", ans);
return 0;
} | a.cc: In function 'int main()':
a.cc:72:14: error: expected ';' before 'while'
72 | check
| ^
| ;
73 | while (l <= r) {
| ~~~~~
|
s813132981 | p03941 | C++ | //============================================================================
// Author : Sun YaoFeng
//============================================================================
//#pragma comment(linker, "/STACK:100240000,100240000")
//#include <cstdio>
//#include <cstdlib>
//#include <cstring>
//#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define DB double
#define lf else if
#define I64 long long
#define Rd() (rand()<<15|rand())
#define For(i,a,b) for(int i=a,lim=b;i<=lim;i++)
#define Rep(i,a,b) for(int i=a,lim=b;i>=lim;i--)
#define fi first
#define se second
#define MK make_pair
#define PA pair<I64, I64>
//#define min(a,b) ((a)<(b)?(a):(b))
//#define max(a,b) ((a)<(b)?(b):(a))
#define CH (ch=getchar())
int IN() {
int x= 0, f= 0, ch;
for (; CH < '0' || ch > '9';) f= (ch == '-');
for (; ch >= '0' && ch <= '9'; CH) x= x*10 + ch -'0';
return f? -x : x;
}
#define n 150005
int N, A[n][2], B[n][2];
vector<PA> S[n];
bool DFS(int i, I64 Mid) {
if (! A[i][0]) {
S[i].push_back(MK(0, 0));
return 1;
}
int j= A[i][0], k= A[i][1];
if (! DFS(j, Mid)) return 0;
if (! DFS(k, Mid)) return 0;
For(u, 0, S[j].size()-1) S[j][u]= MK(S[j][u].fi + B[i][0], S[j][u].se + B[i][0]);
For(v, 0, S[k].size()-1) S[k][v]= MK(S[k][v].fi + B[i][1], S[k][v].se + B[i][1]);
static vector<PA> H1, H2, G;
H1.clear();
H2.clear();
G.clear();
for (int u= 0, v= 0; u < S[j].size(); u++) {
for (; v < S[k].size() && S[j][u].se + S[k][v].fi <= Mid; v++);
if (v && S[j][u].se + S[k][v-1].fi <= Mid) H1.push_back(MK(S[j][u].fi, S[k][v-1].se));
}
for (int u= 0, v= 0; u < S[j].size(); u++) {
for (; v < S[k].size() && S[k][v].se + S[j][u].fi > Mid; v++);
if (v == S[k].size()) break;
H2.push_back(MK(S[k][v].fi, S[j][u].se));
}
for (int u= 0, v= 0; u < H1.size() || v < H2.size(); ) {
if (u == H1.size()) G.push_back(H2[v++]);
lf (v == H2.size()) G.push_back(H1[u++]);
lf (H1[u].fi < H2[v].fi) G.push_back(H1[u++]);
else G.push_back(H2[v++]);
}
for (int u= 0; u < G.size(); u++)
if (S[i].size() == 0 || G[u].se < S[i][S[i].size()-1].se) S[i].push_back(G[u]);
/* puts("------");
printf("%d\n", i);
For(t, 1, H1.size()) printf("(%d , %d) ", H1[t-1].fi, H1[t-1].se);
puts("");
For(t, 1, H2.size()) printf("(%d , %d) ", H2[t-1].fi, H2[t-1].se);
puts(""); */
return S[i].size() > 0;
}
int main(int argc, char* argv[]){
N= IN();
For(i, 2, N) {
int j= IN(), v= IN();
if (! A[j][0]) A[j][0]= i, B[j][0]= v;
else A[j][1]= i, B[j][1]= v;
}
I64 l= 1-, r= 1ll << 35;
for (; l+1 < r;) {
I64 Mid= (l + r) >> 1;
For(i, 1, N) S[i].clear();
if (DFS(1, Mid)) r= Mid;
else l= Mid;
}
cout << r << endl;
// printf("%d\n", DFS(1, 6));
return 0;
} | a.cc: In function 'int main(int, char**)':
a.cc:103:26: error: expected primary-expression before ',' token
103 | I64 l= 1-, r= 1ll << 35;
| ^
a.cc:104:30: error: 'r' was not declared in this scope
104 | for (; l+1 < r;) {
| ^
a.cc:112:25: error: 'r' was not declared in this scope
112 | cout << r << endl;
| ^
|
s407367124 | p03942 | C++ | #include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e6;
int n,s[N+1],t[N+1];
int hea=1,tai,que[N+2];
int res;
void input(int x[])
{
static char str[N+2];
scanf("%s",str+1);
for(int i=1;i<=n;++i) {
x[i]=str[i]-'a';
}
return;
}
bool check0()
{
for(int i=1;i<=n;++i) {
if(s[i]!=t[i]) {
return false;
}
}
return true;
}
int main()
{
scanf("%d",&n);
input(s);
input(t);
if(check0()) {
puts("0")
return 0;
}
for(int spos=n,tpos=n;tpos;--tpos) {
while((tpos>1)&&(t[tpos-1]==t[tpos])) {
--tpos;
}
while(spos&&((spos>tpos)||(s[spos]!=t[tpos]))) {
--spos;
}
if(!spos) {
puts("-1");
return 0;
}
while((hea<=tai)&&(que[hea]-(tai-hea+1)+1>tpos)) {
++hea;
}
que[++tai]=spos;
res=max(res,tai-hea+1);
}
++res;
printf("%d\n",res);
return 0;
}
| a.cc: In function 'int main()':
a.cc:33:26: error: expected ';' before 'return'
33 | puts("0")
| ^
| ;
34 | return 0;
| ~~~~~~
|
s127283305 | p03942 | C++ | #include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <cstring>
#incl ude <map>
using namespace std;
const int MAXN = 1000005;
char S[MAXN], T[MAXN];
int n, q[MAXN], head = 1, tail;
signed main () {
scanf("%d%s%s", &n, S+1, T+1);
if(strcmp(S+1, T+1) == 0) { puts("0"); return 0; }
int ans = 0;
for(int i = n, j = n; i >= 1; --i) {
if(T[i] == T[i-1]) continue;
j = min(j, i);
for(; j && S[j] != T[i]; --j);
if(!j) { puts("-1"); return 0; }
while(head <= tail && q[head] - (tail-head+1) + 1 > i) ++head;
q[++tail] = j;
if(i != pos) ans = max(ans, tail-head+1);
}
printf("%d\n", ans+1);
} | a.cc:6:2: error: invalid preprocessing directive #incl; did you mean #include?
6 | #incl ude <map>
| ^~~~
| include
a.cc: In function 'int main()':
a.cc:22:25: error: 'pos' was not declared in this scope
22 | if(i != pos) ans = max(ans, tail-head+1);
| ^~~
|
s447478439 | p03942 | C++ | #include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <deque>
#include <map>
#include <set>
#include <complex>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#define ft first
#define sc second
#define pb push_back
#define len(v) (int)v.size()
#define int ll
using namespace std;
typedef long long ll;
typedef long double ld;
signed main() {
#ifdef PC
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
string s, t;
cin >> s >> t;
map<char, int> was;
vector<int> r(n + 1, -1);
vector<pair<int, int>> have;
for (char c = 'a'; c <= 'z'; c++)
was[c] = -1;
int uk = n;
for (int i = n - 1; i >= 0; i--) {
if(uk > i)
uk--;
while(uk >= 0 && s[uk] != t[i])
uk--;
if(uk == -1) {
cout << -1;
return 0;
}
r[uk] = max(r[uk], i);
}
// for (int i = 0; i < n; i++) {
// while(uk <= i && s[uk] != t[i])
// uk++;
// if(uk > i) {
// cout << -1;
// return -1;
// }
// r[uk] = i;
// }
// for (int i = 0; i < n; i++) {
// was[s[i]] = i;
// if(was[t[i]] == -1) {
// cout << -1;
// return 0;
// }
// r[was[t[i]]] = i;
// }
for (int i = 0; i < n; i++) {
if(r[i] == -1)
continue;
have.pb({i, r[i]});
}
int lr = -1, rr = -1, cnt = 1;
int ans = 0;
for (int i = 0; i < len(have); i++) {
if(have[i].sc - have[i].ft > 1)
ans = max(ans, 1);
if(rr < have[i].ft) {
if(cnt != 1)
ans = 2;
lr = have[i].ft, rr = have[i].sc, cnt = 1;
continue;
}
if(rr > have[i].sc) {
cout << -1;
return 0;
}
lr = have[i].ft, rr = have[i].sc, cnt++;
}
if(cnt != 1)
ans = max(cnt, ans);
cout << ans << endl;
} | a.cc: In function 'int main()':
a.cc:82:26: error: no matching function for call to 'max(ll&, int)'
82 | ans = max(ans, 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:82:26: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
82 | ans = max(ans, 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:4:
/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:82:26: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
82 | ans = max(ans, 1);
| ~~~^~~~~~~~
|
s437028036 | p03942 | C++ | #include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
using namespace std;
char s[1000005],t[1000005];
queue <int> Q;
int n;
bool check()
{
for(int i=1;i<=n;i++)if(s[i]!=t[i])return 0;
return 1;
}
int main()
{
scanf("%d",&n);
scanf("%s%s",s+1,t+1);
if(check()){printf("0\n");return 0;}
int head=1,tail=0;
int posi=n;
int ans=0;
for(int i=n;i>=1;i--)
{
if(t[i]==t[i-1])continue;
posi=min(posi,i);
while(posi&&t[i]!=s[posi])posi--;
if(!posi){printf("-1\n");return 0;}
while(!Q.empty())
{
if((int)Q.front()-(int)Q,size()>=i)Q.pop();
else break;
}
Q.push(posi);
if(i!=posi)ans=max(ans,(int)Q.size());
}
printf("%d\n",ans+1);
return 0;
} | a.cc: In function 'int main()':
a.cc:34:43: error: invalid cast from type 'std::queue<int>' to type 'int'
34 | if((int)Q.front()-(int)Q,size()>=i)Q.pop();
| ^~~~~~
a.cc:34:54: error: no matching function for call to 'size()'
34 | if((int)Q.front()-(int)Q,size()>=i)Q.pop();
| ~~~~^~
In file included from /usr/include/c++/14/string:53,
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:5:
/usr/include/c++/14/bits/range_access.h:262:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/range_access.h:272:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidate expects 1 argument, 0 provided
|
s479290170 | p03942 | C++ | //実装が重そうな問題はある程度考えてから書く
//初期化を忘れずに(特に二分探索とか)
//コーナーケースを考えて(特に場合分けとか)
//不可解すぎるバグは配列外参照(配列の長さ)を検討
#include "bits/stdc++.h"
#define YES "YES"
#define Yes "Yes"
#define NO "NO"
#define No "No"
#define YESNO(x) OUT(three(x,YES,NO))
#define YesNo(x) OUT(three(x,Yes,No))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b) for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define rep REP
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b-1,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB emplace_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define int long long
#define zero 0LL
#define all ALL
#define pb PB
using namespace std;
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef long long LL;
typedef LL ll;
typedef double ld;
typedef LL ut;
const LL INF = 1LL << 60;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<ppr, Vppr ,greater<ppr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
int dx[] = { 0,1,0,-1,1,1,-1,-1,0 }, dy[] = { 1,0,-1,0,1,-1,1,-1,0 };
const int SIZE1 =2e6 + 1000;
const int SIZE2 = 2010;
const int SIZE3 = 22;
const int SIZE = SIZE1;
const LL p = 7 + 1e9;const long double EPS = 1e-7;
ut N, M, K, X, L, Y,H,W,Q,D;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE], nums[SIZE], maps[SIZE2][SIZE2], answer = zero;
LL A[SIZE], B[SIZE],I[SIZE];
string s, t;
LL solve() {
cin >> N;
cin >> s >> t;
int now = N - 1;
LL ans = 0;
RREP(i, N) {
now = min(now, i);
while (now>=0 and s[now] != t[i]) now--;
if (now < 0) return -1;
A[i] = now;
B[i] =abs(i - now)>0;
if (i + 1 < N and A[i] == A[i + 1]) {
if (abs(i - now) > 0) MX(B[i], last-1);
}
else {
if(i!=now)
B[i] = max<LL>(abs(i - now)>0, B[i + 1] + 1);
}
MX(ans, B[i]);
}
return ans;
}
signed main() {
ios_base::sync_with_stdio(false);
cout << fixed << setprecision(10);
cout << solve() << endl;
// cin >> N;
return 0;
} | a.cc: In function 'LL solve()':
a.cc:81:56: error: 'last' was not declared in this scope
81 | if (abs(i - now) > 0) MX(B[i], last-1);
| ^~~~
|
s390968566 | p03942 | C++ | ERROR: type should be string, got "https://agc007.//waz\n#include <bits/stdc++.h>\n \nusing namespace std;\n \n#define mp make_pair\n#define pb push_back\n#define fi first\n#define se second\n#define ALL(x) (x).begin(), (x).end()\n#define SZ(x) ((int)((x).size()))\n \ntypedef pair<int, int> PII;\ntypedef vector<int> VI;\ntypedef long long int64;\ntypedef unsigned int uint;\ntypedef unsigned long long uint64;\n \n#define gi(x) ((x) = F())\n#define gii(x, y) (gi(x), gi(y))\n#define giii(x, y, z) (gii(x, y), gi(z))\n \nint F()\n{\n char ch;\n int x, a;\n while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');\n if (ch == '-') ch = getchar(), a = -1;\n else a = 1;\n x = ch - '0';\n while (ch = getchar(), ch >= '0' && ch <= '9')\n x = (x << 1) + (x << 3) + ch - '0';\n return a * x;\n}\n \nconst int N = 1e6 + 10;\n \nint n;\n \nchar s[N], t[N];\n \nint q[N];\nint id[N];\nint main()\n{\t\n int l = 1, r = 0;\n gi(n);\n scanf(\"%s\", s + 1);\n scanf(\"%s\", t + 1);\n if (!strcmp(s + 1, t + 1))\n {\n puts(\"0\");\n return 0;\n }\n int ans = 0;\n for (int i = n, j = n; i; --i)\n {\t\n \t if (t[i] == t[i - 1]);\n else\n {\t\n j = min(j, i);\n while (j && t[i] != s[j]) --j;\n if (!j) return puts(\"-1\"), 0;\n id[j+1]++;id[i+1]--;\n }\n\t}\n\tint Ans=0;\n\tfor(int i=1;i<=n;i++)id[i]+=id[i-1],Ans=max(Ans,id[i]);\n printf(\"%d\\n\", Ans+1);\n return 0;\n\t}\n\n\ncontest.atcoder.jp/tasks/agc007_f" | a.cc:1:1: error: 'https' does not name a type
1 | https://agc007.//waz
| ^~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:62,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:2:
/usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity
164 | __is_null_pointer(std::nullptr_t)
| ^
/usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)'
159 | __is_null_pointer(_Type)
| ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'?
164 | __is_null_pointer(std::nullptr_t)
| ^~~~~~~~~
In file included from /usr/include/c++/14/cstddef:50,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:41:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here
443 | typedef decltype(nullptr) nullptr_t;
| ^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'?
666 | struct is_null_pointer<std::nullptr_t>
| ^~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here
443 | typedef decltype(nullptr) nullptr_t;
| ^~~~~~~~~
/usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid
666 | struct is_null_pointer<std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid
670 | struct is_null_pointer<const std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid
674 | struct is_null_pointer<volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid
678 | struct is_null_pointer<const volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^
/usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1438 | : public integral_constant<std::size_t, 0> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid
1438 | : public integral_constant<std::size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared
1440 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope
1441 | struct rank<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid
1441 | struct rank<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared
2086 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope
2087 | struct remove_extent<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid
2087 | struct remove_extent<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared
2099 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope
2100 | struct remove_all_extents<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid
2100 | struct remove_all_extents<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared
2171 | template<std::size_t _Len>
| ^~~
/usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope
2176 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^~~~
/usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^
/usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope
2202 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope
2203 | struct __attribute__((__aligned__((_Align)))) { } __align;
| ^~~~~~
In file included from /usr/include/c++/14/bits/stl_tempbuf.h:59,
from /usr/include/c++/14/bits/stl_algo.h:69,
from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/new:131:26: error: declaration of 'operator new' as non-function
131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~~~
/usr/include/c++/14/new:131:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:132:41: error: attributes after parenthesized initializer ignored [-fpermissive]
132 | __attribute__((__externally_visible__));
| ^
/usr/include/c++/14/new:133:26: error: declaration of 'operator new []' as non-function
133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~~~
/usr/include/c++/14/new:133:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:134:41: error: attributes after parenthesized initializer ignored [-fpermissive]
134 | __attribute__((__externally_visible__));
| |
s599934229 | p03942 | C++ | #include<cstdio>
#include<iostream>
#include<cstring>
#include<queue>
#define RG register
using namespace std;
const int N=1e6+10;
int n,ans;
char st[N],ed[N];
queue<int> pn;
inline int mi(int a,int b){return a<b ? a : b;}
inline int mx(int a,int b){return a>b ? a : b;}
int main()
{
// freopen("Shik and Copying String.in","r",stdin);
//freopen(".out","w",stdout);
scanf("%d%s%s",&n,st+1,ed+1);
if(!strcmp(s+1,t+1)) return printf("-1\n"), 0;
for(int i=n,j=n;i;i--)
{
if(ed[i]==ed[i-1]) continue;
j=mi(i,j);
while(ed[i]!=st[j] && j) j--;
if(!j) return printf("-1\n"), 0;
while(!pn.empty())
{
if((int)pn.front()-(int)pn.size()>=i) pn.pop();
else break;
}
pn.push(j);
if(i!=j) ans=mx(ans,(int)pn.size());
}
printf("%d\n",ans+1);
//fclose(stdin); fclose(stdout);
return 0;
}
| a.cc: In function 'int main()':
a.cc:18:20: error: 's' was not declared in this scope; did you mean 'st'?
18 | if(!strcmp(s+1,t+1)) return printf("-1\n"), 0;
| ^
| st
a.cc:18:24: error: 't' was not declared in this scope; did you mean 'tm'?
18 | if(!strcmp(s+1,t+1)) return printf("-1\n"), 0;
| ^
| tm
|
s759941528 | p03942 | C++ | w#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 1; i <= (n); i ++)
#define re0(i, n) for (int i = 0; i < (int) n; i ++)
#define travel(i, u) for (int i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;
typedef long long LL;
template<typename tp> inline void read(tp &x) {
x = 0; char c = getchar(); int f = 0;
for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
if (f) x = -x;
}
const int N = 1e6 + 233;
int n, ans, tot;
char s[N], t[N];
set <int> alive, rest, S[33];
inline int getfirst(int p) {
int ch = t[p];
auto it = S[ch].upper_bound(p);
if (it == S[ch].begin()) {
cout << "-1\n";
exit(0);
}
return *--it;
}
inline void del(int l, int r) {
while (true) {
auto it = rest.lower_bound(l);
if (it == rest.end())
return ;
if (*it > r)
return ;
S[s[*it]].erase(*it);
rest.erase(it);
}
}
main(void) {
read(n); scanf("%s%s", s + 1, t + 1);
rep (i, n) s[i] -= 'a', t[i] -= 'a';
rep (i, n) {
rest.insert(i);
S[s[i]].insert(i);
}
rep (i, n) {
while (i < n && t[i] == t[i + 1])
++ i;
alive.insert(i);
}
int mx = n + 1;
while (alive.size()) {
auto it = alive.lower_bound(mx);
if (it == alive.begin()) {
mx = n + 1;
if (tot) ++ ans;
tot = 0;
continue;
}
-- it;
int p = *it;
// cout << "mx = " << mx << "p = " << p << " qaq\n";
int pre = p;
while (p > 1 && t[p] == t[p - 1]) -- p;
int S = getfirst(p); del(S, pre); mx = S;
if (S == pre) {}
else ++ tot;
// cout << p << " " << pre << " " << tot << " xx\n";
// cout << "S = " << S << "\n";
alive.erase(pre);
}
if (tot) ++ ans;
cout << ans << "\n";
}
| a.cc:1:2: error: stray '#' in program
1 | w#include <bits/stdc++.h>
| ^
a.cc:1:1: error: 'w' does not name a type
1 | w#include <bits/stdc++.h>
| ^
a.cc: In function 'void read(tp&)':
a.cc:12:19: error: there are no arguments to 'getchar' that depend on a template parameter, so a declaration of 'getchar' must be available [-fpermissive]
12 | x = 0; char c = getchar(); int f = 0;
| ^~~~~~~
a.cc:12:19: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
a.cc:13:49: error: there are no arguments to 'getchar' that depend on a template parameter, so a declaration of 'getchar' must be available [-fpermissive]
13 | for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
| ^~~~~~~
a.cc:14:71: error: there are no arguments to 'getchar' that depend on a template parameter, so a declaration of 'getchar' must be available [-fpermissive]
14 | for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
| ^~~~~~~
a.cc: At global scope:
a.cc:20:1: error: 'set' does not name a type
20 | set <int> alive, rest, S[33];
| ^~~
a.cc: In function 'long long int getfirst(long long int)':
a.cc:24:13: error: 'S' was not declared in this scope
24 | auto it = S[ch].upper_bound(p);
| ^
a.cc:26:5: error: 'cout' was not declared in this scope
26 | cout << "-1\n";
| ^~~~
a.cc:27:5: error: 'exit' was not declared in this scope
27 | exit(0);
| ^~~~
a.cc:1:1: note: 'exit' is defined in header '<cstdlib>'; this is probably fixable by adding '#include <cstdlib>'
+++ |+#include <cstdlib>
1 | w#include <bits/stdc++.h>
a.cc: In function 'void del(long long int, long long int)':
a.cc:34:15: error: 'rest' was not declared in this scope
34 | auto it = rest.lower_bound(l);
| ^~~~
a.cc:39:5: error: 'S' was not declared in this scope
39 | S[s[*it]].erase(*it);
| ^
a.cc: At global scope:
a.cc:44:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
44 | main(void) {
| ^~~~
a.cc: In function 'int main()':
a.cc:45:12: error: 'scanf' was not declared in this scope
45 | read(n); scanf("%s%s", s + 1, t + 1);
| ^~~~~
a.cc:48:5: error: 'rest' was not declared in this scope
48 | rest.insert(i);
| ^~~~
a.cc:49:5: error: 'S' was not declared in this scope
49 | S[s[i]].insert(i);
| ^
a.cc:54:5: error: 'alive' was not declared in this scope
54 | alive.insert(i);
| ^~~~~
a.cc:57:10: error: 'alive' was not declared in this scope
57 | while (alive.size()) {
| ^~~~~
a.cc:78:3: error: 'cout' was not declared in this scope
78 | cout << ans << "\n";
| ^~~~
a.cc: In instantiation of 'void read(tp&) [with tp = long long int]':
a.cc:45:7: required from here
45 | read(n); scanf("%s%s", s + 1, t + 1);
| ~~~~^~~
a.cc:12:26: error: 'getchar' was not declared in this scope
12 | x = 0; char c = getchar(); int f = 0;
| ~~~~~~~^~
a.cc:1:1: note: 'getchar' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
+++ |+#include <cstdio>
1 | w#include <bits/stdc++.h>
|
s655185119 | p03942 | C++ | #include <bits/stdc++.h>
using namespace std;
const int N=1000005;
int n,m;
int b[N],tb=0,a[N];
int st[N],top=0;
char S[N],T[N];
int main(){
scanf("%d%s%s",&n,S+1,T+1);
T[0]=T[1]-1;
for (int i=1;i<=n;i++)
if (T[i]!=T[i-1])
b[++tb]=i;
ta=tb;
for (int i=n;i>=1;i--)
if (i<=b[ta]&&S[i]==T[b[ta]])
a[ta--]=i;
m=tb;
if (ta>0)
return puts("-1"),0;
return 0;
} | a.cc: In function 'int main()':
a.cc:14:9: error: 'ta' was not declared in this scope; did you mean 'tm'?
14 | ta=tb;
| ^~
| tm
|
s926373386 | p03942 | C++ | #include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAX = 30, INF = 1e9, MAXN = 1e6 + 10;
int mn[MAX];
vector <int> index[MAX];
bitset <MAX> b, flag;
bool cmp(int a, int b) {
return mn[a] < mn[b];
}
int h[MAX];
int32_t main () {
ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
string s, t;
int n;
cin >>n >> s >> t;
for (int i = 0; i < MAX; ++i)
mn[i] = INF;
bool zero = true;
for (int i = 0; i < n; ++i) {
if (s[i] != t[i])
zero = false;
if (mn[s[i] - 'a'] == INF)
mn[s[i] - 'a'] = i;
if (mn[t[i] - 'a'] == INF)
return cout << -1, 0;
}
if (zero)
return cout << 0, 0;
for (int i = n - 1; i >= 0; --i) {
b[t[i] - 'a'] = true;
int now = s[i] - 'a';
if (b[now])
index[now].push_back(i);
}
vector <int> vctr;
for (int i = 0; i < MAX; ++i)
if (b[i])
vctr.push_back(i);
sort(vctr.begin(), vctr.end());
int mx =0;
for (auto i : vctr) {
// cout << i << ':';
if (index[i].empty())
continue;
h[i] = INF;
for (auto j : index[i]) {
if (s[j] == t[j])
h[i] = 0;
// cout << j << ' ';
h[i] = min(h[i], h[t[j] - 'a'] + 1);
}
mx = max(mx, h[i]);
}
cout<< mx + 1;
return 0;
} | a.cc:6:23: error: 'std::vector<long long int> index [30]' redeclared as different kind of entity
6 | vector <int> index[MAX];
| ^
In file included from /usr/include/string.h:462,
from /usr/include/c++/14/cstring:43,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
from a.cc:1:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
50 | extern const char *index (const char *__s, int __c)
| ^~~~~
a.cc: In function 'int32_t main()':
a.cc:34:18: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript
34 | index[now].push_back(i);
| ^
a.cc:44:18: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript
44 | if (index[i].empty())
| ^
a.cc:47:28: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript
47 | for (auto j : index[i]) {
| ^
|
s796443423 | p03942 | C++ | #include<bits/stdc++.h>
#define N 1000006
using namespace std;
char s0[N],t[N];
int n;
int val[N],match[N],end[N];
int main(){
scanf("%d%s%s",&n,s0+1,t+1);
for(int i=1,p=0,last,lleter;i<=n;i++)
if(t[i]!=t[i-1]){
last=-1;end[i]=i;lleter=i;
while(p+1<=i) p++,last=t[i]==s0[p]? p:last;
if(last!=-1) match[i]=last;
else return puts("-1"),0;
}else end[lleter]=i;
int shift=0,add=0,ans=0,p=0;
for(int i=1;i<=n;i++)
if(match[i]==end[i]){
continue;
}else if(match[i]!=0){
shift++;add++;val[end[i]+1-shift]--;
for(int j=p+1-shift;j<= match[i]-shift;j++) val[j]+=val[j-1];
p=match[i]-shift;
ans=max(ans,val[p]+add);
}
cout<<ans<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:11:21: error: reference to 'end' is ambiguous
11 | last=-1;end[i]=i;lleter=i;
| ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166,
from a.cc:1:
/usr/include/c++/14/valarray:1265:5: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
1265 | end(const valarray<_Tp>& __va) noexcept
| ^~~
/usr/include/c++/14/valarray:1249:5: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
1249 | end(valarray<_Tp>& __va) noexcept
| ^~~
In file included from /usr/include/c++/14/string:53,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
106 | end(_Tp (&__arr)[_Nm]) noexcept
| ^~~
/usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
85 | end(const _Container& __cont) -> decltype(__cont.end())
| ^~~
/usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
74 | end(_Container& __cont) -> decltype(__cont.end())
| ^~~
In file included from /usr/include/c++/14/bits/algorithmfwd.h:39,
from /usr/include/c++/14/bits/stl_algo.h:59,
from /usr/include/c++/14/algorithm:61,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
99 | end(initializer_list<_Tp> __ils) noexcept
| ^~~
a.cc:6:21: note: 'int end [1000006]'
6 | int val[N],match[N],end[N];
| ^~~
a.cc:15:15: error: reference to 'end' is ambiguous
15 | }else end[lleter]=i;
| ^~~
/usr/include/c++/14/valarray:1265:5: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
1265 | end(const valarray<_Tp>& __va) noexcept
| ^~~
/usr/include/c++/14/valarray:1249:5: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
1249 | end(valarray<_Tp>& __va) noexcept
| ^~~
/usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
106 | end(_Tp (&__arr)[_Nm]) noexcept
| ^~~
/usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
85 | end(const _Container& __cont) -> decltype(__cont.end())
| ^~~
/usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
74 | end(_Container& __cont) -> decltype(__cont.end())
| ^~~
/usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
99 | end(initializer_list<_Tp> __ils) noexcept
| ^~~
a.cc:6:21: note: 'int end [1000006]'
6 | int val[N],match[N],end[N];
| ^~~
a.cc:18:22: error: reference to 'end' is ambiguous
18 | if(match[i]==end[i]){
| ^~~
/usr/include/c++/14/valarray:1265:5: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
1265 | end(const valarray<_Tp>& __va) noexcept
| ^~~
/usr/include/c++/14/valarray:1249:5: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
1249 | end(valarray<_Tp>& __va) noexcept
| ^~~
/usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
106 | end(_Tp (&__arr)[_Nm]) noexcept
| ^~~
/usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
85 | end(const _Container& __cont) -> decltype(__cont.end())
| ^~~
/usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
74 | end(_Container& __cont) -> decltype(__cont.end())
| ^~~
/usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
99 | end(initializer_list<_Tp> __ils) noexcept
| ^~~
a.cc:6:21: note: 'int end [1000006]'
6 | int val[N],match[N],end[N];
| ^~~
a.cc:21:31: error: reference to 'end' is ambiguous
21 | shift++;add++;val[end[i]+1-shift]--;
| ^~~
/usr/include/c++/14/valarray:1265:5: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
1265 | end(const valarray<_Tp>& __va) noexcept
| ^~~
/usr/include/c++/14/valarray:1249:5: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
1249 | end(valarray<_Tp>& __va) noexcept
| ^~~
/usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
106 | end(_Tp (&__arr)[_Nm]) noexcept
| ^~~
/usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
85 | end(const _Container& __cont) -> decltype(__cont.end())
| ^~~
/usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
74 | end(_Container& __cont) -> decltype(__cont.end())
| ^~~
/usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
99 | end(initializer_list<_Tp> __ils) noexcept
| ^~~
a.cc:6:21: note: 'int end [1000006]'
6 | int val[N],match[N],end[N];
| ^~~
|
s163785387 | p03942 | C++ | #include<bits/stdc++.h>
using namespace std;
int n,lst[1000100][26],gg[1000100];
char s[1000100],t[1000100];
struct treaps
{
int son[1201000][2],size[1201000],num[1201000],tag[1201000],rd[1200100],tt;
void update(int s){size[s]=size[son[s][0]]+size[son[s][1]]+1;}
int build(int n)
{
if (n==0) return 0;
int s=++tt;size[s]=1;rd[s]=rand();
n--;
son[s][0]=build(n/2);son[s][1]=build(n-n/2);
update(s);
return s;
}
void pushdown(int s)
{
if (son[s][0]) {tag[son[s][0]]+=tag[s];num[son[s][0]]+=tag[s];}
if (son[s][1]) {tag[son[s][1]]+=tag[s];num[son[s][1]]+=tag[s];}
tag[s]=0;
}
void addtag(int s) {tag[s]++;num[s]++;}
int merge(int s,int t)
{
if (!s) return t;
if (!t) return s;
pushdown(s);pushdown(t);
if (rd[s]>rd[t]) {son[s][1]=merge(son[s][1],t);update(s);return s;}
else {son[t][0]=merge(s,son[t][0]);update(t);return t;}
}
pair<int,int> split(int s,int k)
{
if (!s) return pair<int,int>(0,0);
pushdown(s);
if (size[son[s][0]]>=k)
{
pair<int,int> ls=split(son[s][0],k);
son[s][0]=ls.second;update(s);
return pair<int,int>(ls.first,s);
}
pair<int,int> ls=split(son[s][1],k-size[son[s][0]]-1);
son[s][1]=ls.first;update(s);
return pair<int,int>(s,ls.second);
}
int findkth(int s,int k)
{
pushdown(s);
if (size[son[s][0]]>=k) return findkth(son[s][0],k);
if (size[son[s][0]]+1==k) return num[s];
return findkth(son[s][1],k-(size[son[s][0]]+1));
}
}treap;
int main()
{
//freopen("in.txt","r",stdin);
scanf("%d\n",&n);
gets(s+1);gets(t+1);
bool err=false;
for (int i=1;i<=n;i++)
{
for (int j=0;j<26;j++) lst[i][j]=lst[i-1][j];
lst[i][s[i]-'a']=i;
if (s[i]!=t[i]) err=true;
}
if (err==false) {printf("0\n");return 0;}
int root=treap.build(n),ans=1,rem=n;
for (int i=n;i>=1;i--) if (t[i]!=t[i-1])
{
//for (int j=1;j<=i;j++) cout<<treap.findkth(root,j)<<' ';cout<<endl;
int w=treap.findkth(root,i);
if ((w!=0)||(s[i]!=t[i])) ans=max(ans,w+2);
int d=lst[min(i-(w!=0),rem)][t[i]-'a'];rem=d-1;
if (d==0) {printf("-1\n");return 0;}
pair<int,int> p=treap.split(root,d-1);
pair<int,int> q=treap.split(p.second,1);
treap.addtag(q.second);
root=treap.merge(p.first,q.second);
}
printf("%d\n",ans);
} | a.cc: In function 'int main()':
a.cc:61:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
61 | gets(s+1);gets(t+1);
| ^~~~
| getw
|
s901396758 | p03942 | C++ | #include<bits/stdc++.h>
using namespace std;
int n,lst[1000100][26],gg[1000100];
char s[1000100],t[1000100];
struct treaps
{
int son[1201000][2],size[1201000],num[1201000],tag[1201000],rd[1200100],tt;
void update(int s){size[s]=size[son[s][0]]+size[son[s][1]]+1;}
int build(int n)
{
if (n==0) return 0;
int s=++tt;size[s]=1;rd[s]=rand();
n--;
son[s][0]=build(n/2);son[s][1]=build(n-n/2);
update(s);
return s;
}
void pushdown(int s)
{
if (son[s][0]) {tag[son[s][0]]+=tag[s];num[son[s][0]]+=tag[s];}
if (son[s][1]) {tag[son[s][1]]+=tag[s];num[son[s][1]]+=tag[s];}
tag[s]=0;
}
void addtag(int s) {tag[s]++;num[s]++;}
int merge(int s,int t)
{
if (!s) return t;
if (!t) return s;
pushdown(s);pushdown(t);
if (rd[s]>rd[t]) {son[s][1]=merge(son[s][1],t);update(s);return s;}
else {son[t][0]=merge(s,son[t][0]);update(t);return t;}
}
pair<int,int> split(int s,int k)
{
if (!s) return pair<int,int>(0,0);
pushdown(s);
if (size[son[s][0]]>=k)
{
pair<int,int> ls=split(son[s][0],k);
son[s][0]=ls.second;update(s);
return pair<int,int>(ls.first,s);
}
pair<int,int> ls=split(son[s][1],k-size[son[s][0]]-1);
son[s][1]=ls.first;update(s);
return pair<int,int>(s,ls.second);
}
int findkth(int s,int k)
{
pushdown(s);
if (size[son[s][0]]>=k) return findkth(son[s][0],k);
if (size[son[s][0]]+1==k) return num[s];
return findkth(son[s][1],k-(size[son[s][0]]+1));
}
}treap;
int main()
{
//freopen("in.txt","r",stdin);
scanf("%d\n",&n);
gets(s+1);gets(t+1);
bool err=false;
for (int i=1;i<=n;i++)
{
for (int j=0;j<26;j++) lst[i][j]=lst[i-1][j];
lst[i][s[i]-'a']=i;
if (s[i]!=t[i]) err=true;
}
if (err==false) {printf("0\n");return 0;}
int root=treap.build(n),ans=1,rem=n;
for (int i=n;i>=1;i--) if (t[i]!=t[i-1])
{
//for (int j=1;j<=i;j++) cout<<treap.findkth(root,j)<<' ';cout<<endl;
int w=treap.findkth(root,i);
if ((w!=0)||(s[i]!=t[i])) ans=max(ans,w+2);
int d=lst[min(i-(w!=0),rem)][t[i]-'a'];rem=d-1;
if (d==0) {printf("-1\n");return 0;}
pair<int,int> p=treap.split(root,d-1);
pair<int,int> q=treap.split(p.second,1);
treap.addtag(q.second);
root=treap.merge(p.first,q.second);
}
printf("%d\n",ans);
} | a.cc: In function 'int main()':
a.cc:61:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
61 | gets(s+1);gets(t+1);
| ^~~~
| getw
|
s536913446 | p03942 | C++ | #include<bits/stdc++.h>
using namespace std;
int n,lst[1000100],gg[1000100];
char s[1000100],t[1000100];
struct treaps
{
int son[1001000][2],size[1001000],num[1001000],tag[1001000],rd[1000100],tt;
int build(int n)
{
if (n==0) return 0;
int s=++tt;size[s]=1;rd[s]=rand();
if (n==1) return s;
n--;
son[s][0]=build(n/2);son[s][1]=build(n-n/2);
update(s);
return s;
}
void pushdown(int s)
{
if (son[s][0]) {tag[son[s][0]]+=tag[s];num[son[s][0]]+=tag[s];}
if (son[s][1]) {tag[son[s][1]]+=tag[s];num[son[s][1]]+=tag[s];}
tag[s]=0;
}
void update(int s){size[s]=size[son[s][0]]+size[son[s][1]]+1;}
void addtag(int s) {tag[s]++;num[s]++;}
int merge(int s,int t)
{
if (!s) return t;
if (!t) return s;
pushdown(s);pushdown(t);
if (rd[s]>rd[t]) {son[s][1]=merge(son[s][1],t);update(s);return s;}
else {son[t][0]=merge(s,son[t][0]);update(t);return t;}
}
pair<int,int> split(int s,int k)
{
if (!s) return pair<int,int>(0,0);
pushdown(s);
if (size[son[s][0]]>=k)
{
pair<int,int> ls=split(son[s][0],k);
son[s][0]=ls.second;update(s);
return pair<int,int>(ls.first,s);
}
pair<int,int> ls=split(son[s][1],k-size[son[s][0]]-1);
son[s][1]=ls.first;update(s);
return pair<int,int>(s,ls.second);
}
int findkth(int s,int k)
{
pushdown(s);
if (size[son[s][0]]>=k) return findkth(son[s][0],k);
if (size[son[s][0]]+1==k) return num[s];
return findkth(son[s][1],k-(size[son[s][0]]+1));
}
}treap;
int p[1000100];
int main()
{
scanf("%d\n%s\n%s\n",&n,s+1,t+1);
bool err=false;
for (int i=1;i<=n;i++)
{
gg[i]=p[t[i]];
p[s[i]]=i;
if (!p[t[i]]) {printf("-1\n");return 0;}
lst[i]=p[t[i]];if (lst[i]!=i) err=true;
}
if (err==false) {printf("0\n");return 0;}
int root=treap.build(n);int ans=0;
for (int i=n;i>=1;i--) if (t[i]!=t[i-1])
{
//for (int j=1;j<=i;j++) cout<<treap.findkth(root,j)<<' ';cout<<endl;
int w=treap.findkth(root,i);
ans=max(ans,w);
//if (w)
{
if (gg[i]==0) {printf("-1\n");return 0;}
pair<int,int> p=treap.split(root,gg[i]-1);
pair<int,int> q=treap.split(p.second,1);
treap.addtag(q.second);
root=treap.merge(p.first,q.second);
}
else
{
}
}
printf("%d\n",ans+2);
} | a.cc: In function 'int main()':
a.cc:84:17: error: expected '}' before 'else'
84 | else
| ^~~~
a.cc:72:9: note: to match this '{'
72 | {
| ^
a.cc: At global scope:
a.cc:88:15: error: expected constructor, destructor, or type conversion before '(' token
88 | printf("%d\n",ans+2);
| ^
a.cc:89:1: error: expected declaration before '}' token
89 | }
| ^
|
s670334683 | p03942 | C++ | #include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
const int MAXN = 1000005;
int n, tot;
char a[MAXN], b[MAXN];
int end[MAXN], fr[MAXN];
void chk_same() {
for (int i = 1; i <= n; i++)
if (a[i] != b[i])
return;
puts("0"), exit(0);
}
int main() {
scanf("%d %s %s", &n, a + 1, b + 1), chk_same();
for (int i = 1; i <= n; i++)
if (b[i] != b[i - 1])
end[tot++] = i - 1;
end[tot] = n;
int p = n + 1, ans = 0;
for (int i = tot; i; i--) {
p = min(p, end[i - 1] + 1);
while (p && a[p] != b[end[i]])
p--;
if (!p) {
puts("-1");
return 0;
}
fr[i] = p;
}
for (int i = p = 1; i <= tot; i++) {
while (p < tot && fr[p + 1] - (p - i + 1) < end[i])
p++;
ans = max(ans, p - i + 1);
}
printf("%d", ans);
return 0;
}
| a.cc: In function 'int main()':
a.cc:21:13: error: reference to 'end' is ambiguous
21 | end[tot++] = i - 1;
| ^~~
In file included from /usr/include/c++/14/bits/algorithmfwd.h:39,
from /usr/include/c++/14/bits/stl_algo.h:59,
from /usr/include/c++/14/algorithm:61,
from a.cc:2:
/usr/include/c++/14/initializer_list:99:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
99 | end(initializer_list<_Tp> __ils) noexcept
| ^~~
a.cc:8:5: note: 'int end [1000005]'
8 | int end[MAXN], fr[MAXN];
| ^~~
a.cc:22:5: error: reference to 'end' is ambiguous
22 | end[tot] = n;
| ^~~
/usr/include/c++/14/initializer_list:99:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
99 | end(initializer_list<_Tp> __ils) noexcept
| ^~~
a.cc:8:5: note: 'int end [1000005]'
8 | int end[MAXN], fr[MAXN];
| ^~~
a.cc:25:20: error: reference to 'end' is ambiguous
25 | p = min(p, end[i - 1] + 1);
| ^~~
/usr/include/c++/14/initializer_list:99:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
99 | end(initializer_list<_Tp> __ils) noexcept
| ^~~
a.cc:8:5: note: 'int end [1000005]'
8 | int end[MAXN], fr[MAXN];
| ^~~
a.cc:26:31: error: reference to 'end' is ambiguous
26 | while (p && a[p] != b[end[i]])
| ^~~
/usr/include/c++/14/initializer_list:99:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
99 | end(initializer_list<_Tp> __ils) noexcept
| ^~~
a.cc:8:5: note: 'int end [1000005]'
8 | int end[MAXN], fr[MAXN];
| ^~~
a.cc:35:53: error: reference to 'end' is ambiguous
35 | while (p < tot && fr[p + 1] - (p - i + 1) < end[i])
| ^~~
/usr/include/c++/14/initializer_list:99:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
99 | end(initializer_list<_Tp> __ils) noexcept
| ^~~
a.cc:8:5: note: 'int end [1000005]'
8 | int end[MAXN], fr[MAXN];
| ^~~
|
s143239424 | p03942 | C++ | #include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
char s[1000010],t[1000010];
int n;
int next[26][1000001];
int L[1000001],R[1000001],cnt;
int main(){
scanf("%d%s",&n,s+1);
for(int i=1;i<=n;i++){
for(int j=0;j<26;j++)
next[j][i]=next[j][i-1];
next[s[i]-'a'][i]=i;
}
scanf("%s",t+1);
if(strcmp(s+1,t+1)==0){
printf("0\n");
return 0;
}
int pt=n,r=n;
while(pt>=1){
int z=t[pt]-'a';
cnt++;
R[cnt]=pt;
while(pt>=1&&t[pt]-'a'==z)pt--;
int x=next[z][min(r,pt+1)];
L[cnt]=x;
if(x==0){
printf("-1\n");
return 0;
}
r=x-1;
}
int ans=0,tmp=1,smg=0,msmg=0;
for(int i=2;i<=cnt;i++)
if(R[i]>=L[i-1]){
tmp++;
if(L[i-1]-L[i]==R[i-1]-R[i])smg++;
else {msmg=max(msmg,smg);smg=0;}
}
else{
msmg=max(msmg,smg);
ans=max(ans,min(tmp,2)+msmg-(msmg==tmp-1));tmp=1;msmg=0;smg=0;
}
msmg=max(msmg,smg);
ans=max(ans,min(tmp,2)+msmg-(msmg==tmp-1));
printf("%d\n",ans);
return 0;
} | a.cc: In function 'int main()':
a.cc:13:17: error: reference to 'next' is ambiguous
13 | next[j][i]=next[j][i-1];
| ^~~~
In file included from /usr/include/c++/14/string:47,
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:3:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:7:5: note: 'int next [26][1000001]'
7 | int next[26][1000001];
| ^~~~
a.cc:13:28: error: reference to 'next' is ambiguous
13 | next[j][i]=next[j][i-1];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:7:5: note: 'int next [26][1000001]'
7 | int next[26][1000001];
| ^~~~
a.cc:14:17: error: reference to 'next' is ambiguous
14 | next[s[i]-'a'][i]=i;
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:7:5: note: 'int next [26][1000001]'
7 | int next[26][1000001];
| ^~~~
a.cc:27:23: error: reference to 'next' is ambiguous
27 | int x=next[z][min(r,pt+1)];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:7:5: note: 'int next [26][1000001]'
7 | int next[26][1000001];
| ^~~~
|
s306306556 | p03942 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
int N;
string S,T;
int tar[1010101];
int ma;
deque<int> D;
int H[1010100];
void solve() {
int i,j,k,l,r,x,y; string s;
cin>>N>>S>>T;
if(S==T) return _P("0\n");
MINUS(rev);
MINUS(tar);
int R=N-1;
for(i=N-1;i>=0;i--) if(i==0 || T[i]!=T[i-1]) {
R=min(i,R);
while(R>=0 && T[i]!=S[R]) R--;
if(R<0) return _P("-1\n");
tar[i]=R;
R--;
}
for(i=N-1;i>=0;i--) if(tar[i]>=0 && tar[i]!=i) {
int cur=H[i]+1;
for(j=i;j>=tar[i];j--) {
x = H[j];
H[j]=cur;
cur=x+1;
}
}
cout<<*max_element(H,H+N)<<endl;
}
int main(int argc,char** argv){
string s;int i;
if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
FOR(i,argc-1) s+=argv[i+1],s+='\n';
FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
solve(); return 0;
}
| a.cc: In function 'void solve()':
a.cc:31:15: error: 'rev' was not declared in this scope
31 | MINUS(rev);
| ^~~
a.cc:12:25: note: in definition of macro 'MINUS'
12 | #define MINUS(a) memset(a,0xff,sizeof(a))
| ^
|
s042126459 | p03942 | C++ | #include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int N=1000010;
char s[N],t[N];
int head[130],next[N];
int main()
{
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int n;scanf("%d",&n);
scanf("%s",s+1);scanf("%s",t+1);
for (int i=1;i<=n;i++)
{
next[i]=head[s[i]];head[s[i]]=i;
}
int pre=n+1,ans=0,tmp=0;char ch;
for (int i=n;i;i--)
{
char x;
if (i<pre) tmp=0;
if (i>=pre) x=ch; else x=s[i];
if (x==t[i]) continue;x=t[i];
tmp++;ans=max(ans,tmp);
while (head[x]>=i||head[x]>=pre) head[x]=next[head[x]];
if (!head[x]) {puts("-1");return 0;}
pre=head[x];ch=x;
}
printf("%d\n",ans);
return 0;
}
| a.cc: In function 'int main()':
a.cc:21:17: error: reference to 'next' is ambiguous
21 | next[i]=head[s[i]];head[s[i]]=i;
| ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
from /usr/include/c++/14/bits/specfun.h:43,
from /usr/include/c++/14/cmath:3906,
from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:11:15: note: 'int next [1000010]'
11 | int head[130],next[N];
| ^~~~
a.cc:31:58: error: reference to 'next' is ambiguous
31 | while (head[x]>=i||head[x]>=pre) head[x]=next[head[x]];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:11:15: note: 'int next [1000010]'
11 | int head[130],next[N];
| ^~~~
|
s766576255 | p03943 | C++ | #include<bits/stdc++.h>
using namespace std;
vector<int>vec;
set<int>st;
int main()
{
int i,j,n,t,a,b,c;
string s,s1,s2;
cin>>a>>b>>c;
if(a+b==c||a+c==b||b+c==a)
cout"Yes"<<"\n";
else
cout<<"No"<<"\n";
return 0;
}
| a.cc: In function 'int main()':
a.cc:11:13: error: expected ';' before string constant
11 | cout"Yes"<<"\n";
| ^~~~~
| ;
|
s717190631 | p03943 | Java | import java . util.*;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int []x ={ input.nextInt(), input.nextInt(), input.nextInt()};
for (int i = 0; i < x.length; i++) {
Arrays.sort(x);
}
if (x[2]==x[1]+x[0]){
System.out.println("yes");
System.out.println(" Give the pack with" +x[2] +"candies to one student, and give the two packs with"+ x[0]+" and "
+x[1]+" candies to the other. Then, each gets " +x[2]+" candies");}
System.out.println("no");
System.out.println("In this case, the student who gets the pack with" +x[2]+
"candies always has more candies than the other Note that every pack must be given to one of them."); | Main.java:16: error: reached end of file while parsing
"candies always has more candies than the other Note that every pack must be given to one of them.");
^
1 error
|
s266295577 | p03943 | Java | import java.util.Scanner;
public class FightingOverCandies {
public void main(String[] args) {
Scanner in = new Scanner(System.in);
int a, b, c;
a = in.nextInt();
b = in.nextInt();
c = in.nextInt();
if (a == b + c)
System.out.println("yes");
else if (b == a + c)
System.out.println("yes");
else if (c == b + a)
System.out.println("yes");
else
System.out.println("no");
in.close();
}
}
| Main.java:3: error: class FightingOverCandies is public, should be declared in a file named FightingOverCandies.java
public class FightingOverCandies {
^
1 error
|
s102651564 | p03943 | Java | import java.util.Scanner;
public class FightingOverCandies {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int a, b, c;
a = in.nextInt();
b = in.nextInt();
c = in.nextInt();
if (a == b + c)
System.out.println("yes");
else if (b == a + c)
System.out.println("yes");
else if (c == b + a)
System.out.println("yes");
else
System.out.println("no");
in.close();
}
} | Main.java:3: error: class FightingOverCandies is public, should be declared in a file named FightingOverCandies.java
public class FightingOverCandies {
^
1 error
|
s807637643 | p03943 | Java | import java.util.Scanner;
public class FightingOverCandies {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int a, b, c;
System.out.println("enter candies quantity as: ");
a = in.nextInt();
b = in.nextInt();
c = in.nextInt();
if (a == b + c)
System.out.println("yes");
else if (b == a + c)
System.out.println("yes");
else if (c == b + a)
System.out.println("yes");
else
System.out.println("no");
in.close();
}
}
| Main.java:3: error: class FightingOverCandies is public, should be declared in a file named FightingOverCandies.java
public class FightingOverCandies {
^
1 error
|
s586597456 | p03943 | Java | import java.util.Scanner;
public class main {
public main(String[] args) {
Scanner in = new Scanner(System.in);
int a, b, c;
System.out.println("enter candies quantity as: ");
a = in.nextInt();
b = in.nextInt();
c = in.nextInt();
if (a == b + c)
System.out.println("yes");
else if (b == a + c)
System.out.println("yes");
else if (c == b + a)
System.out.println("yes");
else
System.out.println("no");
}
}
| Main.java:3: error: class main is public, should be declared in a file named main.java
public class main {
^
1 error
|
s469160729 | p03943 | Java | public class main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int a, b, c;
System.out.println("enter candies quantity as: ");
a = in.nextInt();
b = in.nextInt();
c = in.nextInt();
if (a == b + c)
System.out.println("yes");
else if (b == a + c)
System.out.println("yes");
else if (c == b + a)
System.out.println("yes");
else
System.out.println("no");
}
} | Main.java:1: error: class main is public, should be declared in a file named main.java
public class main {
^
Main.java:3: error: cannot find symbol
Scanner in = new Scanner(System.in);
^
symbol: class Scanner
location: class main
Main.java:3: error: cannot find symbol
Scanner in = new Scanner(System.in);
^
symbol: class Scanner
location: class main
3 errors
|
s942003016 | p03943 | Java | import java.util.Scanner;
public class main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int a, b, c;
System.out.println("enter candies quantity as: ");
a = in.nextInt();
b = in.nextInt();
c = in.nextInt();
if (a == b + c)
System.out.println("yes");
else if (b == a + c)
System.out.println("yes");
else if (c == b + a)
System.out.println("yes");
else
System.out.println("no");
}
} | Main.java:3: error: class main is public, should be declared in a file named main.java
public class main {
^
1 error
|
s188118757 | p03943 | Java | package Comp;
import java.util.Scanner;
public class FightingOverCandies {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int a, b, c;
System.out.println("enter candies quantity as: ");
a = in.nextInt();
b = in.nextInt();
c = in.nextInt();
if (a == b + c)
System.out.println("yes");
else if (b == a + c)
System.out.println("yes");
else if (c == b + a)
System.out.println("yes");
else
System.out.println("no");
}
}
| Main.java:5: error: class FightingOverCandies is public, should be declared in a file named FightingOverCandies.java
public class FightingOverCandies {
^
1 error
|
s155724222 | p03943 | Java | public class FightingOverCandies {
public static void main(String[] args) {
Scanner in = new Scanner (System.in);
int a,b,c ;
System.out.println("enter candies quantity as: ");
a=in.nextInt();
b=in.nextInt();
c=in.nextInt();
if(a==b+c)
System.out.println("yes");
else if (b==a+c)
System.out.println("yes");
else if (c==b+a)
System.out.println("yes");
else
System.out.println("no");
}
} | Main.java:1: error: class FightingOverCandies is public, should be declared in a file named FightingOverCandies.java
public class FightingOverCandies {
^
Main.java:3: error: cannot find symbol
Scanner in = new Scanner (System.in);
^
symbol: class Scanner
location: class FightingOverCandies
Main.java:3: error: cannot find symbol
Scanner in = new Scanner (System.in);
^
symbol: class Scanner
location: class FightingOverCandies
3 errors
|
s159939529 | p03943 | Java | package Comp;
import java.util.Scanner;
public class FightingOverCandies {
public static void main(String[] args) {
Scanner in = new Scanner (System.in);
int a,b,c ;
System.out.println("enter candies quantity as: ");
a=in.nextInt();
b=in.nextInt();
c=in.nextInt();
if(a==b+c)
System.out.println("yes");
else if (b==a+c)
System.out.println("yes");
else if (c==b+a)
System.out.println("yes");
else
System.out.println("no");
}
}
| Main.java:5: error: class FightingOverCandies is public, should be declared in a file named FightingOverCandies.java
public class FightingOverCandies {
^
1 error
|
s545512430 | p03943 | Java | Scanner in = new Scanner (System.in);
int a,b,c ;
System.out.println("enter candies quantity as: ");
a=in.nextInt();
b=in.nextInt();
c=in.nextInt();
if(a==b+c)
System.out.println("yes");
else if (b==a+c)
System.out.println("yes");
else if (c==b+a)
System.out.println("yes");
else
System.out.println("no");
} | Main.java:1: error: unnamed classes are a preview feature and are disabled by default.
Scanner in = new Scanner (System.in);
^
(use --enable-preview to enable unnamed classes)
Main.java:2: error: class, interface, enum, or record expected
int a,b,c ;
^
Main.java:3: error: class, interface, enum, or record expected
System.out.println("enter candies quantity as: ");
^
Main.java:4: error: class, interface, enum, or record expected
a=in.nextInt();
^
Main.java:5: error: class, interface, enum, or record expected
b=in.nextInt();
^
Main.java:6: error: class, interface, enum, or record expected
c=in.nextInt();
^
Main.java:7: error: class, interface, enum, or record expected
if(a==b+c)
^
Main.java:9: error: class, interface, enum, or record expected
else if (b==a+c)
^
Main.java:11: error: class, interface, enum, or record expected
else if (c==b+a)
^
Main.java:13: error: class, interface, enum, or record expected
else
^
Main.java:19: error: class, interface, enum, or record expected
}
^
11 errors
|
s098643395 | p03943 | Java | import java.util.Scanner;
public class FightingOverCandies {
public static void main(String[] args) {
Scanner in = new Scanner (System.in);
int a,b,c ;
System.out.println("enter candies quantity as: ");
a=in.nextInt();
b=in.nextInt();
c=in.nextInt();
if(a==b+c)
System.out.println("yes");
else if (b==a+c)
System.out.println("yes");
else if (c==b+a)
System.out.println("yes");
else
System.out.println("no");
}
} | Main.java:3: error: class FightingOverCandies is public, should be declared in a file named FightingOverCandies.java
public class FightingOverCandies {
^
1 error
|
s956606198 | p03943 | C++ | #include <iostream>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
if (a + c != b)
cout << "No" << "\n";
else if (a + b != c)
cout << "No" << "\n";
else if (b + c <!= a)
cout << "No" << "\n";
else
cout << "Yes" << "\n";
} | a.cc: In function 'int main()':
a.cc:10:25: error: expected primary-expression before '!=' token
10 | else if (b + c <!= a)
| ^~
|
s146143318 | p03943 | C++ | #include <iostream>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
if (a + c > b &|| a + c < b)
cout << "No" << "\n";
else if (a + b > c || a + b < c)
cout << "No" << "\n";
else if (b + c < a || b + c > a)
cout << "No" << "\n";
else
cout << "Yes" << "\n";
} | a.cc: In function 'int main()':
a.cc:6:24: error: expected primary-expression before '||' token
6 | if (a + c > b &|| a + c < b)
| ^~
|
s199515787 | p03943 | C++ | #include <iostream>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
if (a + c > b && a + c < b)
cout << "Np" << "\n";
else if (a + b > c && a + b < c)
cout << "Np" << "\n";
else if (b + c < a && b + c > a)
cout << "Np" << "\n";
else
cout << "Yes << "\n";"
} | a.cc:13:34: error: stray '\' in program
13 | cout << "Yes << "\n";"
| ^
a.cc: In function 'int main()':
a.cc:13:34: error: expected ';' before 'n'
13 | cout << "Yes << "\n";"
| ^~
| ;
|
s517085473 | p03943 | C++ | #include <iostream>
#include <algorithm>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
int max = max(a, max(b, c));
if ((a + b + c) / 2 <= max)
cout << "No" << "\n";
else
cout << "Yes" << "\n";
} | a.cc: In function 'int main()':
a.cc:7:29: error: 'max' cannot be used as a function
7 | int max = max(a, max(b, c));
| ~~~^~~~~~
a.cc:7:35: error: 'max' cannot be used as a function
7 | int max = max(a, max(b, c));
| ^
|
s980456936 | p03943 | C++ | #include <iostream>
#include <cmath>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
int max = max(a, max(b, c));
if ((a + b + c) / 2 <= max)
cout << "No" << "\n";
else
cout << "Yes" << "\n";
} | a.cc: In function 'int main()':
a.cc:7:29: error: 'max' cannot be used as a function
7 | int max = max(a, max(b, c));
| ~~~^~~~~~
a.cc:7:35: error: 'max' cannot be used as a function
7 | int max = max(a, max(b, c));
| ^
|
s038172607 | p03943 | C++ | #include <iostream>
#include <cmath>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
int max = max(a, b, c);
if ((a + b + c) / 2 <= max)
cout << "No" << "\n";
else
cout << "Yes" << "\n";
} | a.cc: In function 'int main()':
a.cc:7:22: error: 'max' cannot be used as a function
7 | int max = max(a, b, c);
| ~~~^~~~~~~~~
|
s959939315 | p03943 | C++ | #include<iostream>
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
bool flag=false;
if((a+b)==c)flag=ture;
if((b+c)==a)flag=true;
if((c+a)==b)flag=true;
if(flag)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:9:20: error: 'ture' was not declared in this scope
9 | if((a+b)==c)flag=ture;
| ^~~~
|
s542597647 | p03943 | Java | import java.util.*;
import static java.lang.System.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
int = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
if((a + b == c) || (a + c == b) ){
out.println("Yes");
}else if(b + c == a){
out.println("Yes");
}else{
out.println("No");
}
}
} | Main.java:7: error: not a statement
int = sc.nextInt();
^
Main.java:7: error: ';' expected
int = sc.nextInt();
^
2 errors
|
s594109955 | p03943 | C++ | #include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
#define PI 3.141592653589793
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).end()
template<class T>inline bool chmax(T& a,T b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if (a>b){a=b;return 1;}return 0;}
const ll INF = 1LL << 60;
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
struct edge{//グラフに使うヤツ
ll from,to,cost;
};
typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
if (a%b==0)return(b);
else return(gcd(b,a%b));
}
int main() {
ll a[3];
cin >> a[0] >> a[1] >> a[2];
sort(a,a+3);
if (a[0]+a[1]==a[2]){
cout << #include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
#define PI 3.141592653589793
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).end()
template<class T>inline bool chmax(T& a,T b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if (a>b){a=b;return 1;}return 0;}
const ll INF = 1LL << 60;
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
struct edge{//グラフに使うヤツ
ll from,to,cost;
};
typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
if (a%b==0)return(b);
else return(gcd(b,a%b));
}
int main() {
ll a[3];
cin >> a[0] >> a[1] >> a[2];
sort(a,a+3);
if (a[0]+a[1]==a[2]){
cout << "Yes" << endl;
}else{
cout << "No" << endl;
}
return 0;
}
"Yes" << endl;
}else{
cout << "No" << endl;
}
return 0;
}
| a.cc:33:17: error: stray '#' in program
33 | cout << #include <bits/stdc++.h>
| ^
a.cc: In function 'int main()':
a.cc:33:18: error: 'include' was not declared in this scope
33 | cout << #include <bits/stdc++.h>
| ^~~~~~~
a.cc:33:27: error: 'bits' was not declared in this scope
33 | cout << #include <bits/stdc++.h>
| ^~~~
a.cc:33:32: error: 'stdc' was not declared in this scope; did you mean 'std'?
33 | cout << #include <bits/stdc++.h>
| ^~~~
| std
a.cc:35:1: error: expected primary-expression before 'using'
35 | using namespace std;
| ^~~~~
a.cc:42:1: error: a template declaration cannot appear at block scope
42 | template<class T>inline bool chmax(T& a,T b){if (a<b){a=b;return 1;}return 0;}
| ^~~~~~~~
a.cc:55:18: error: a function-definition is not allowed here before '{' token
55 | ll gcd(ll a,ll b){
| ^
a.cc:60:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
60 | int main() {
| ^~
a.cc:60:9: note: remove parentheses to default-initialize a variable
60 | int main() {
| ^~
| --
a.cc:60:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:60:12: error: a function-definition is not allowed here before '{' token
60 | int main() {
| ^
a.cc:71:7: error: invalid operands of types 'const char [4]' and '<unresolved overloaded function type>' to binary 'operator<<'
71 | "Yes" << endl;
| ~~~~~~^~~~~~~
|
s190986793 | p03943 | C++ | #include <bits/stdc++.h>
using namespace std;
int main () {
ios_base::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
vector<int> c(3);
for(int i = 0; i < N; ++i)
cin >> c[i];
sort(c.begin(), c.end());
cout << (c[2] != c[1] + c[0] ? "No": "Yes") << '\n';
return 0;
}
| a.cc: In function 'int main()':
a.cc:11:24: error: 'N' was not declared in this scope
11 | for(int i = 0; i < N; ++i)
| ^
|
s463906110 | p03943 | C++ | #include <bits/stdc++.h>
#define arep(a,i,n) for(ll i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(ll i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(ll i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;
int main(){
int a[3];
cinf(a,3);
sort(a,3);
if(a[0]+a[1]==a[2])
cout << "Yes" << endl;
else
cout << "No" << endl;
} | a.cc: In function 'int main()':
a.cc:15:13: error: no matching function for call to 'sort(int [3], int)'
15 | sort(a,3);
| ~~~~^~~~~
In file included from /usr/include/c++/14/algorithm:61,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:4762:5: note: candidate: 'template<class _RAIter> void std::sort(_RAIter, _RAIter)'
4762 | sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
| ^~~~
/usr/include/c++/14/bits/stl_algo.h:4762:5: note: template argument deduction/substitution failed:
a.cc:15:13: note: deduced conflicting types for parameter '_RAIter' ('int*' and 'int')
15 | sort(a,3);
| ~~~~^~~~~
/usr/include/c++/14/bits/stl_algo.h:4793:5: note: candidate: 'template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)'
4793 | sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
| ^~~~
/usr/include/c++/14/bits/stl_algo.h:4793:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare)'
292 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note: candidate expects 4 arguments, 2 provided
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator)'
296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: candidate expects 3 arguments, 2 provided
|
s953327679 | p03943 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
// Your
int a,b,c, max;
cin >> a >> b >> c;
max = max(a,(b,c));
min = (a+b+c)-max;
if(max = min){
cout <<"Yes" << endl;
}
else
{
cout << "No" << endl;
}
}
| a.cc: In function 'int main()':
a.cc:11:14: error: 'max' cannot be used as a function
11 | max = max(a,(b,c));
| ~~~^~~~~~~~~
a.cc:12:19: error: overloaded function with no contextual type information
12 | min = (a+b+c)-max;
| ^~~
a.cc:15:14: error: cannot resolve overloaded function 'min' based on conversion to type 'int'
15 | if(max = min){
| ^~~
|
s635527892 | p03943 | C | #include <stdio.h>
int main(void)
{
int a,b,c,ab,bc,ac;
scanf("%d%d%d",&a,&b,&c);
ab=a+b;
ac=a+c;
bc=b+c;
if(ab==c || ac==b || bc=a)printf("Yes");
else printf("No");
return 0;
}
| main.c: In function 'main':
main.c:10:32: error: lvalue required as left operand of assignment
10 | if(ab==c || ac==b || bc=a)printf("Yes");
| ^
|
s360566580 | p03943 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};
int main(){
ll a, b, c;
cin >> a >> b >> c;
ll mx = ({a, b, c});
ll sum = a+b+c;
if(mx == (sum - mx)) cout << "Yes" << endl;
else cout << "No" << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:19:20: error: expected ';' before '}' token
19 | ll mx = ({a, b, c});
| ^
| ;
|
s988310869 | p03943 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};
int main(){
ll a, b, c;
ll mx = ({a, b, c});
ll sum = a+b+c;
if(mx == (sum - mx)) cout << "Yes" << endl;
else cout << "No" << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:18:20: error: expected ';' before '}' token
18 | ll mx = ({a, b, c});
| ^
| ;
|
s194120001 | p03943 | C++ | #include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c;
cin >> a >> b >> c;
if(a+b==c||a+c==b||b+c==a){
cout << "Yes" << endl;
}
else{
cout << "No" << endl
}
} | a.cc: In function 'int main()':
a.cc:10:25: error: expected ';' before '}' token
10 | cout << "No" << endl
| ^
| ;
11 | }
| ~
|
s753755439 | p03943 | C++ | #include <iostream>
using namespace std;
int main(){
int a,b,c;
cina>>b>>c;
if (a+b==c||b+c==a||c+a==b){
cout<<"Yes";
}
else{
cout<<"No";
}
}
| a.cc: In function 'int main()':
a.cc:5:5: error: 'cina' was not declared in this scope
5 | cina>>b>>c;
| ^~~~
|
s497514880 | p03943 | C++ | #include <iostream>
using namespace std;
int main(){
int a,b,c;
cina>>b>>c;
if (a+b=c||b+c=a||c+a=b){
cout<<"Yes";
}
else{
cout<<"No";
}
}
| a.cc: In function 'int main()':
a.cc:5:5: error: 'cina' was not declared in this scope
5 | cina>>b>>c;
| ^~~~
a.cc:6:21: error: lvalue required as left operand of assignment
6 | if (a+b=c||b+c=a||c+a=b){
| ~^~~~~
|
s011398002 | p03943 | C++ | #include<iostream>
using namespace std;
int main(){
int a, b, c;
cin >> a >> b >> c;
if(a + b = c or a + c = b or b + c = a){
cout << "Yes" << '\n';
}else{
cout << "No" << '\n';
}
} | a.cc: In function 'int main()':
a.cc:6:29: error: lvalue required as left operand of assignment
6 | if(a + b = c or a + c = b or b + c = a){
| ~~^~~~~~~~
|
s153632920 | p03943 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
if (a == b + c || b = c + a || c = a + b) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
} | a.cc: In function 'int main()':
a.cc:8:31: error: lvalue required as left operand of assignment
8 | if (a == b + c || b = c + a || c = a + b) {
| ~~~~~~^~~~
|
s620730242 | p03943 | C++ | #include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
cout << ( a+b+c-max{(a,b,c)}==max{(a,b,c)} ? "Yes" : "No" ) <<endl;
} | a.cc: In function 'int main()':
a.cc:7:18: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator-'
7 | cout << ( a+b+c-max{(a,b,c)}==max{(a,b,c)} ? "Yes" : "No" ) <<endl;
| ~~~~~^~~~
a.cc:7:22: error: expected ')' before '{' token
7 | cout << ( a+b+c-max{(a,b,c)}==max{(a,b,c)} ? "Yes" : "No" ) <<endl;
| ~ ^
| )
a.cc:7:46: error: expected primary-expression before '?' token
7 | cout << ( a+b+c-max{(a,b,c)}==max{(a,b,c)} ? "Yes" : "No" ) <<endl;
| ^
|
s874897807 | p03943 | C++ | #include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
cout << ( a+b+c-max({a,b,c})==max({a,b,c)} ? "Yes" : "No" ) <<endl;
} | a.cc: In function 'int main()':
a.cc:7:43: error: expected '}' before ')' token
7 | cout << ( a+b+c-max({a,b,c})==max({a,b,c)} ? "Yes" : "No" ) <<endl;
| ~ ^
a.cc:7:44: error: expected ')' before '}' token
7 | cout << ( a+b+c-max({a,b,c})==max({a,b,c)} ? "Yes" : "No" ) <<endl;
| ~ ^
| )
a.cc:7:44: error: expected ';' before '}' token
7 | cout << ( a+b+c-max({a,b,c})==max({a,b,c)} ? "Yes" : "No" ) <<endl;
| ^
| ;
a.cc: At global scope:
a.cc:7:46: error: expected unqualified-id before '?' token
7 | cout << ( a+b+c-max({a,b,c})==max({a,b,c)} ? "Yes" : "No" ) <<endl;
| ^
a.cc:8:1: error: expected declaration before '}' token
8 | }
| ^
|
s849507075 | p03943 | Java | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int a = scanner.nextInt();
int b = scanner.nextInt();
int c = scanner.nextInt();
// どれかが残り二つの合計値になっていたらYes
if(a == b + c || b == c + a || c = a + b) {
System.out.println("Yes");
// さもなくばNo
} else {
System.out.println("No");
}
}
} | Main.java:12: error: bad operand types for binary operator '||'
if(a == b + c || b == c + a || c = a + b) {
^
first type: boolean
second type: int
1 error
|
s812324225 | p03943 | Java | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int a = scanner.nextInt();
int b = scanner.nextInt();
int c = scanner.nextInt();
// どれかが残りの二つの合計になっていたらYes
if(a == b + c || b = a + c || c = a + b) {
System.out.println("Yes");
// さもなくば、No
} else {
System.out.println("No");
}
}
} | Main.java:12: error: bad operand types for binary operator '||'
if(a == b + c || b = a + c || c = a + b) {
^
first type: boolean
second type: int
Main.java:12: error: bad operand types for binary operator '||'
if(a == b + c || b = a + c || c = a + b) {
^
first type: int
second type: int
2 errors
|
s384498445 | p03943 | C++ | /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
| |
s444001136 | p03943 | C++ | #include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
int to;
int weight;
Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<int>>;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1};
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int a, b, c;
cin >> a >> b >> c;
cout << a + b + c %2 == 0 ? "Yes" : "No" << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:28:24: error: no match for 'operator==' (operand types are 'std::basic_ostream<char>' and 'int')
28 | cout << a + b + c %2 == 0 ? "Yes" : "No" << endl;
| ~~~~~~~~~~~~~~~~~~~~ ^~ ~
| | |
| | int
| std::basic_ostream<char>
a.cc:28:24: note: candidate: 'operator==(int, int)' (built-in)
28 | cout << a + b + c %2 == 0 ? "Yes" : "No" << endl;
| ~~~~~~~~~~~~~~~~~~~~~^~~~
a.cc:28:24: note: no known conversion for argument 1 from 'std::basic_ostream<char>' to 'int'
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:1103:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const sub_match<_BiIter>&)'
1103 | operator==(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1103:5: note: template argument deduction/substitution failed:
a.cc:28:27: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
28 | cout << a + b + c %2 == 0 ? "Yes" : "No" << endl;
| ^
/usr/include/c++/14/bits/regex.h:1199: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>&)'
1199 | operator==(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1199:5: note: template argument deduction/substitution failed:
a.cc:28:27: note: 'std::basic_ostream<char>' is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>'
28 | cout << a + b + c %2 == 0 ? "Yes" : "No" << endl;
| ^
/usr/include/c++/14/bits/regex.h:1274: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>&)'
1274 | operator==(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1274:5: note: template argument deduction/substitution failed:
a.cc:28:27: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
28 | cout << a + b + c %2 == 0 ? "Yes" : "No" << endl;
| ^
/usr/include/c++/14/bits/regex.h:1366:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)'
1366 | operator==(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1366:5: note: template argument deduction/substitution failed:
a.cc:28:27: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int'
28 | cout << a + b + c %2 == 0 ? "Yes" : "No" << endl;
| ^
/usr/include/c++/14/bits/regex.h:1441:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)'
1441 | operator==(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1441:5: note: template argument deduction/substitution failed:
a.cc:28:27: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
28 | cout << a + b + c %2 == 0 ? "Yes" : "No" << endl;
| ^
/usr/include/c++/14/bits/regex.h:1534:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)'
1534 | operator==(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1534:5: note: template argument deduction/substitution failed:
a.cc:28:27: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int'
28 | cout << a + b + c %2 == 0 ? "Yes" : "No" << endl;
| ^
/usr/include/c++/14/bits/regex.h:1613:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)'
1613 | operator==(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1613:5: note: template argument deduction/substitution failed:
a.cc:28:27: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
28 | cout << a + b + c %2 == 0 ? "Yes" : "No" << endl;
| ^
/usr/include/c++/14/bits/regex.h:2186:5: note: candidate: 'template<class _Bi_iter, class _Alloc> bool std::__cxx11::operator==(const match_results<_BiIter, _Alloc>&, const match_results<_BiIter, _Alloc>&)'
2186 | operator==(const match_results<_Bi_iter, _Alloc>& __m1,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:2186:5: note: template argument deduction/substitution failed:
a.cc:28:27: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::match_results<_BiIter, _Alloc>'
28 | cout << a + b + c %2 == 0 ? "Yes" : "No" << endl;
| ^
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: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:28:27: note: 'std::basic_ostream<char>' is not derived from 'const std::pair<_T1, _T2>'
28 | cout << a + b + c %2 == 0 ? "Yes" : "No" << endl;
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/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:28:27: note: 'std::basic_ostream<char>' is not derived from 'const std::reverse_iterator<_Iterator>'
28 | cout << a + b + c %2 == 0 ? "Yes" : "No" << endl;
| ^
/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:28:27: note: 'std::basic_ostream<char>' is not derived from 'const std::reverse_iterator<_Iterator>'
28 | cout << a + b + c %2 == 0 ? "Yes" : "No" << endl;
| ^
/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:28:27: note: 'std::basic_ostream<char>' is not derived from 'const std::move_iterator<_IteratorL>'
28 | cout << a + b + c %2 == 0 ? "Yes" : "No" << endl;
| ^
/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:28:27: note: 'std::basic_ostream<char>' is not derived from 'const std::move_iterator<_IteratorL>'
28 | cout << a + b + c %2 == 0 ? "Yes" : "No" << endl;
| ^
In file included from /usr/include/c++/14/bits/char_traits.h:42,
from /usr/include/c++/14/string:42,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/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:28:27: note: 'std::basic_ostream<char>' is not derived from 'const std::fpos<_StateT>'
28 | cout << a + b + c %2 == 0 ? "Yes" : "No" << endl;
| ^
In file included from /usr/include/c++/14/string:43:
/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:28:27: note: 'std::basic_ostream<char>' is not derived from 'const std::allocator<_CharT>'
28 | cout << a + b + c %2 == 0 ? "Yes" : "No" << endl;
| ^
In file included from /usr/include/c++/14/bits/basic_string.h:47,
from / |
s601506770 | p03943 | Java | import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
// 整数の入力
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
if(a + b == c){
System.out.println(Yes);
}else if(a + c == b){
System.out.println(Yes);
}else if(b + c == a){
System.out.println(Yes);
}else{
System.out.println(No);
}
}
} | Main.java:10: error: cannot find symbol
System.out.println(Yes);
^
symbol: variable Yes
location: class Main
Main.java:12: error: cannot find symbol
System.out.println(Yes);
^
symbol: variable Yes
location: class Main
Main.java:14: error: cannot find symbol
System.out.println(Yes);
^
symbol: variable Yes
location: class Main
Main.java:16: error: cannot find symbol
System.out.println(No);
^
symbol: variable No
location: class Main
4 errors
|
s173871307 | p03943 | Java | import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
// 整数の取得
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
if(a=b+c){
System.out.println("Yes");
}else if(b=a+c){
System.out.println("Yes");
}else if(c=a+b){
System.out.println("Yes");
}else{
System.out.println("No");
}
}
}
| Main.java:11: error: incompatible types: int cannot be converted to boolean
if(a=b+c){
^
Main.java:13: error: incompatible types: int cannot be converted to boolean
}else if(b=a+c){
^
Main.java:15: error: incompatible types: int cannot be converted to boolean
}else if(c=a+b){
^
3 errors
|
s460418312 | p03943 | C++ | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD 1000000007
#define ll long long int
#define pair <ll, ll> pi
#define vector <ll> vi
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define SQ(a) (a) * (a)
#define ordered_set tree<ll, null_type, greater_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> //greater_equal<ll> or less<ll>
// find_by_key() order_of_key()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
/*bool comp(string a, string b) {
if (a.size() != b.size()) return a.size() < b.size();
return a < b;
}*/
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
//freopen('input.txt', 'r', stdin);
//freopen('output.txt', 'w', stdout);
ll i, j, k, n, m, b, d, t, ans = 0,a,x,y;
cin>>a>>b>>c;
if(a+b==c){
cout<<"Yes"<<endl;
}
else if(a+c==b){
cout<<"Yes"<<endl;
}
else if(b+c==a){
cout<<"Yes"<<endl;
}
else{
cout<<"No"<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:31:16: error: 'c' was not declared in this scope
31 | cin>>a>>b>>c;
| ^
|
s487600013 | p03943 | C++ | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<int,string>;
int main() {
int a,b,c;
cin >> a >> b >> c;
if(a+b == c || b+c == a || c+a==b) xout << "Yes" << endl;
else cout << "No" << endl ;
} | a.cc: In function 'int main()':
a.cc:10:36: error: 'xout' was not declared in this scope
10 | if(a+b == c || b+c == a || c+a==b) xout << "Yes" << endl;
| ^~~~
|
s738826550 | p03943 | C++ | #include <bits/stdc++.h>
using namespace std;
signed main(){
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
if(a + b + c = 2 * max(a, max(b, c))){
printf("Yes\n");
}
else{
printf("No\n");
}
return 0;
} | a.cc: In function 'int main()':
a.cc:7:18: error: lvalue required as left operand of assignment
7 | if(a + b + c = 2 * max(a, max(b, c))){
| ~~~~~~^~~
|
s865004959 | p03943 | C++ | #include <bits/stdc++.h>
using namespace std;
signed main(){
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
if(a + b + c = 2 * max({a, b, c})){
printf("Yes\n");
}
else{
printf("No\n");
}
return 0;
} | a.cc: In function 'int main()':
a.cc:7:18: error: lvalue required as left operand of assignment
7 | if(a + b + c = 2 * max({a, b, c})){
| ~~~~~~^~~
|
s764347162 | p03943 | C | #include <stdio.h>
int main(){
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
if(a+b==c)
printf("Yes");
else if(c+b==a)
printf("Yes");
else if(a+c==b)
printf("Yes");
else
printf("No")
return 0;
} | main.c: In function 'main':
main.c:14:15: error: expected ';' before 'return'
14 | printf("No")
| ^
| ;
......
19 | return 0;
| ~~~~~~
|
s061850853 | p03943 | C++ | #include<bits/stdc++.h>
using namespace std;
int main()
{
string a,b,c;
cin>>a>>b>>c;
if(a[0]==b[1]||a[0]==c[2]||b[1]==c[2]){
cout<<"No"<<endl;
}
else{
cout<<"Yes"<<endl;
} | a.cc: In function 'int main()':
a.cc:16:2: error: expected '}' at end of input
16 | }
| ^
a.cc:5:1: note: to match this '{'
5 | {
| ^
|
s357527469 | p03943 | Java | import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int num1 = sc.nextInt();
int num2 = sc.nextInt();
int num3 = sc.nextInt();
if((num1 + num2 + num3)%2 == 0){
System.out.println("Yes");
}else{
System.out.println("No");
}
} | Main.java:17: error: reached end of file while parsing
}
^
1 error
|
s725265897 | p03943 | C++ | Crawling of this problem failed or hasn't finished | a.cc:1:40: warning: missing terminating ' character
1 | Crawling of this problem failed or hasn't finished
| ^
a.cc:1:40: error: missing terminating ' character
1 | Crawling of this problem failed or hasn't finished
| ^~~~~~~~~~~
a.cc:1:1: error: 'Crawling' does not name a type
1 | Crawling of this problem failed or hasn't finished
| ^~~~~~~~
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.