submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3 values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s488486534 | p03808 | C++ | #include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#define INF 2147483600
#define long long long
bool solve(){
int n;
cin>>n;
vector<long> vec(n);
rep(i,n) cin>>vec[i];
if(n==1) return true;
long nn = (long)n*(n+1)/2;
long sum = accumulate(all(vec), 0LL);
if(sum%nn!=0) return false;
nn = sum/nn; //操作回数になってる
rep(i,n){
long d = vec[(i+1)%n]-vec[i];
if( d<=dd && (nn-d)%n!=0 ) return false;
}
return true;
}
int main(){
if(solve()) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
return 0;
}
| a.cc: In function 'bool solve()':
a.cc:31:12: error: 'dd' was not declared in this scope; did you mean 'd'?
31 | if( d<=dd && (nn-d)%n!=0 ) return false;
| ^~
| d
|
s618624733 | p03808 | C++ | #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
int main() {
int n;
cin >> n;
vi a(n);
for (int i = 0; i < n; i++)
cin >> a[i];
while(1) {
int max = 0;
for (int i = 0; i < n; i++) {
if (a[i] > a[max]) {
max = i;
}
}
if (a[max] == 0) {
printf("YES\n");
return 0;
}
if (max == 0) {
if (a[1] > a[n - 1]) {
for (int i = 0; i < n; i++) {
a[i] = a[i] - n + i;
if (a[i] < 0) {
printf("NO\n");
return 0;
}
}
} else {
a[max] =- n;
if (a[max] < 0) {
printf("NO\n");
return 0;
}
for (int i = 1; i < n; i++) {
a[i] =- i;
if (a[i] < 0) {
printf("NO\n");
return 0;
}
}
}
} else if (max == n - 1) {
if (a[0] > a[n - 2]) {
a[max] =- n;
if (a[max] < 0) {
printf("NO\n");
return 0;
}
for (int i = 0; i < n - 1; i++) {
a[i] = a[i] - n + i + 1;
if (a[i] < 0) {
printf("NO\n");
return 0;
}
}
} else {
for (int i = 0; i < n; i++) {
a[i] = a[i] - i - 1;
if (a[i] < 0) {
printf("NO\n");
return 0;
}
}
}
} else {
for (int i = 0; i <= max; i++) {
a[i] = a[i] - n - i + max;
if (a[i] < 0) {
printf("NO\n");
return 0;
}
}
for (int i = max + 1; i < n; i++) {
a[i] = a[i] - i + max;
if (a[i] < 0) {
printf("NO\n");
return 0;
}
}
}
}
for (int i = 0; i < n; i++)
cout << a[i] << " " << endl;
}
}
| a.cc:111:1: error: expected declaration before '}' token
111 | }
| ^
|
s930072001 | p03808 | C++ | #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
int main() {
int n;
cin >> n;
vi a(n);
for (int i = 0; i < n; i++)
cin >> a[i];
while(1) {
int max = 0;
for (int i = 0; i < n; i++) {
if (a[i] > a[max]) {
max = i;
}
}
if (a[max] == 0) {
printf("YES\n");
return 0;
}
if (max == 0) {
if (a[1] > a[n - 1]) {
for (int i = 0; i < n; i++) {
a[i] = a[i] - n + i;
if (a[i] < 0) {
printf("NO\n");
return 0;
}
}
} else {
a[max] =- n;
if (a[max] < 0) {
printf("NO\n");
return 0;
}
for (int i = 1; i < n; i++) {
a[i] =- i;
if (a[i] < 0) {
printf("NO\n");
return 0;
}
}
}
} else if (max == n - 1) {
if (a[0] > a[n - 2]) {
a[max] =- n;
if (a[max] < 0) {
printf("NO\n");
return 0;
}
for (int i = 0; i < n - 1; i++) {
a[i] = a[i] - n + i + 1;
if (a[i] < 0) {
printf("NO\n");
return 0;
}
}
} else {
for (int i = 0; i < n; i++) {
a[i] = a[i] - i - 1;
if (a[i] < 0) {
printf("NO\n");
return 0;
}
}
}
} else {
for (int i = 0; i <= max; i++) {
a[i] = a[i] - n - i + max;
if (a[i] < 0) {
printf("NO\n");
return 0;
}
}
for (int i = max + 1; i < n; i++) {
a[i] = a[i] - i + max;
if (a[i] < 0) {
printf("NO\n");
return 0;
}
}
}
}
for (int i = 0; i < n; i++)
cout << a[i] << " " << endl;
}
}
| a.cc:111:1: error: expected declaration before '}' token
111 | }
| ^
|
s558380930 | p03808 | C++ | #include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
const int MAX_N = 100005;
int a[MAX_N];
int b[MAX_N];
int main()
{
int n;
ll asum = 0;
cin >> n;
rep(i,n){
scanf("%d",&a[i]);
asum += a[i];
}
rep(i,n-1){
b[i] = a[i+1] - a[i];
}
b[n-1] = a[0] - a[n-1];
ll nsum = ll(n) * (n+1) / 2;
bool flag = false;
if(asum % nsum != 0){
cout << "NO" << "\n";
}else{
ll cnt = asum / nsum; //cnt回の操作を行った
ll hoge=0;
rep(i,n){
if((cnt-b[i]) % n != 0){
flag = true;
break;
}else{
hoge += (cnt-b[i]) / n;
}
}
if(flag == true || hoge != cnt){
cout << "NO" << "\n";
}else{
cout << "YES" << "\n";
}
}
} | a.cc: In function 'int main()':
a.cc:2:12: error: expected primary-expression before 'long'
2 | #define ll long long
| ^~~~
a.cc:29:19: note: in expansion of macro 'll'
29 | ll nsum = ll(n) * (n+1) / 2;
| ^~
|
s020797362 | p03808 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>
#include <fstream>
#include <sstream>
#include <string>
#include <time.h>
#include <math.h>
using namespace std;
int main() {
int N;
cin >> N;
vector <long long int> A(N);
auto minIt = A.begin();
auto It = A.begin();
for (int i = 0; i < N; i++) {
cin >> A[i];
if (*minIt > A[i]) {
minIt = It;
}
It++;
}
//auto minIt = min_element(A.begin(), A.end());
while (1) {
if (*minIt <= 0) break;
It = minIt;
for (int i = 1; i <= N; i++) {
*It -= i;
if (*minIt > *It) minIt = It;
It++;
if (It == A.end()) It = A.begin();
}
}
auto maxIt = max_element(A.begin(), A.end());
if (*maxIt == 0 && *minIt == 0) {
cout << "YES" << endl;
}
else {
cout << "NO" << endl;
}
return 0; | a.cc: In function 'int main()':
a.cc:46:12: error: expected '}' at end of input
46 | return 0;
| ^
a.cc:13:12: note: to match this '{'
13 | int main() {
| ^
|
s413786697 | p03808 | C++ | #include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <numeric>
using namespace std;
#define forn(i,n) for (int i = 0; i < int(n); ++i)
#define forsn(i,x,y) for(long long i = (x) ; i <= (y) ; ++i)
typedef long long ll;
typedef long double ld;
int main() {
ll n;
cin >> n;
vector<ll> a;
vector<ll> subs;
ll total = 0;
ll ave = 0;
forn(n0,n) {
ll t;
cin >> t;
a.push_back(t);
total += t;
}
subs.push_back(a[0] - a[a.size()-1]);
for(int i =1 ;i < n; i++) {
subs.push_back(a[i] - a[i-1]);
}
ave = (n * (n+1)) / 2
if(total % ave != 0) {
cout << "NO" << endl;
return 0;
}
ll numadd = total / ave;
ll sub = n-1;
ll num_sub = numadd;
/*
forn(i,n) {
cout << subs[i] << " " ;
}
cout << endl;
cout << "numadd:" << numadd << endl;
*/
for(int i = 0; i < n; i++) {
//cout << "i:" << i << endl;
if((subs[i] - numadd) % n != 0) {
cout << "NO" << endl;
return 0;
}
//cout << (subs[i] - numadd) / n << endl;
num_sub += (subs[i] - numadd) / n;
}
if(true) { //num_sub == 0) {
cout << "YES" << endl;
}
else {
cout << "NO" << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:33:24: error: expected ';' before 'if'
33 | ave = (n * (n+1)) / 2
| ^
| ;
34 | if(total % ave != 0) {
| ~~
|
s714632900 | p03808 | C++ | #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
using namespace std;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<int> a(n);
REP(i,n){
cin >> a[i];
}
while(true){
auto mina = min_element(a.begin(),a.end());
rotate(a.begin(),mina,a.end());
bool issort = true;
REP(i,n-1){
if(a[i] != a[i-1]){
break;
}
if(i == n-2){
if(a[i] %= n*(n+1)/2 == 0)cout << "YES" << endl;
else cout << "NO" << endl;
}
REP(i,n-1){
if(a[i] != a[i+1]-1){
issort = false;
break;
}
}
if(issort)break;
else{
REP(i,n-1){
if(a[i] >= a[i+1]){
break;
}
if(i == n-2){
cout << "NO" << endl;
return 0;
}
}
REP(i,n-1){
if(a[i] >= a[i+1]){
int ct = 1;
for(int j = i+1;ct <= n;j = (j+1 >= n)?0:j+1){
a[j]-=ct++;
if(a[j] < 0){
cout << "NO" << endl;
return 0;
}
}
}
}
}
/* REP(i,n){
cout << a[i] << " ";
}
cout << '\n';
*/
}
REP(i,n){
if(a[i] <= 0){cout << "NO" << endl;
return 0;
}
}
long long sum_servea = n*(n+1)/2;
if((long long)a[0] > sum_servea){
REP(i,n)a[i] %= sum_servea;
}
bool issort = true;
REP(i,n-1){
if(a[i] != a[i+1]-1 ){
cout << "NO" << endl;
return 0;
}
}
cout << "YES" << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:85:14: error: redeclaration of 'bool issort'
85 | bool issort = true;
| ^~~~~~
a.cc:28:22: note: 'bool issort' previously declared here
28 | bool issort = true;
| ^~~~~~
a.cc:95:2: error: expected '}' at end of input
95 | }
| ^
a.cc:15:11: note: to match this '{'
15 | int main(){
| ^
|
s956695006 | p03808 | C++ | #include <iostream>
#include <string>
#include <queue>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i <= (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())
int main()
{
bool error = false;
int N;
cin >> N;
long long A[N];
long long dA[N];
long long a[N];//iでとり始めた回数
REP(i,N){
cin >> A[i];
}
REP(i,N){
if(i==N-1){
dA[N-1] = A[0]-A[N-1];
}else{
dA[i] = A[i+1]-A[i];
}
}
long long sum = 0;//Aの和
long long x = 0;//取った回数
REP(i,N){
sum+=A[i];
}
if((2*sum)%(N*(N+1))!=0){
error = true;
}else{
x = 2*sum/N/(N+1);
}
REP(i,N){
if((x-dA[i])%N != 0 || (x-dA[i])<0){
error = true;
}else{
s[i] = (x-dA[i])/N;
}
}
//要素について検証。
sum = 0;//A[0]の予測値
REP(i,N){
sum += s[i]*(N+0-i);
}
if(sum != A[0]){
error = true;
}
if(error){
cout << "NO" << endl;
}else{
cout << "YES" << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:42:25: error: 's' was not declared in this scope
42 | s[i] = (x-dA[i])/N;
| ^
a.cc:48:24: error: 's' was not declared in this scope
48 | sum += s[i]*(N+0-i);
| ^
|
s951628747 | p03808 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int N; cin >> N; long long S;
vector<int> A(N),B(N);
for(int i=0;i<N;++i) {
cin >> A[i]; S+=A[i];
}
if(S%(N*(N+1)/2)) {
cout << "NO" << endl;
return 0;
}
for(int i=0;i<N-1;++i) B[i] = A[i+1]-A[i];
B[N-1]=A[0]-A[N-1];
}
for(int i=0;i<N;++i) {
if(B[i]%N) {
cout << "NO" << endl;
return 0;
}
}
cout << "YES" << endl;
return 0;
} | a.cc:20:3: error: expected unqualified-id before 'for'
20 | for(int i=0;i<N;++i) {
| ^~~
a.cc:20:15: error: 'i' does not name a type
20 | for(int i=0;i<N;++i) {
| ^
a.cc:20:19: error: expected unqualified-id before '++' token
20 | for(int i=0;i<N;++i) {
| ^~
a.cc:26:3: error: 'cout' does not name a type
26 | cout << "YES" << endl;
| ^~~~
a.cc:27:3: error: expected unqualified-id before 'return'
27 | return 0;
| ^~~~~~
a.cc:28:1: error: expected declaration before '}' token
28 | }
| ^
|
s398024222 | p03808 | C++ | foo | a.cc:1:1: error: 'foo' does not name a type
1 | foo
| ^~~
|
s416187372 | p03808 | C | #include <stdio.h>
int main()
{
int n;
int flag = 0, b, c;
int flag2 = 0;
int i;
int sum;
int tmp;
int x0, x1, xa, xb;
scanf("%d", &n);
if (n <= 1)
{
printf("YES\n");
return 0;
}
scanf("%d", &xa);
scanf("%d", &xb);
b = xb - xa;
tmp = xb + xa;
x0 = xa;
xa = xb;
for (i = 2; i < n; i++)
{
scanf("%d", &xb);
if (xb - xa != b && flag == 0)
{
flag++;
c = xb - xa;
}
if (xb - xa != b && xb - xa != c && flag == 1)
{
flag++;
break;
}
tmp += xb;
xa = xb;
}
if (x0 - xa != b && flag == 0)
{
c = x0 - xa;
}
if (x0 - xa != b && x0 - xa != c && flag == 1)
{
flag++;
}
if (b < c)
{
sum = c;
c = b;
b = sum;
}
if (flag >= 2 || b - c= n || tmp != n * (n + 1) / 2 * b)
{
printf("NO\n");
}
else
printf("YES\n");
} | main.c: In function 'main':
main.c:53:27: error: lvalue required as left operand of assignment
53 | if (flag >= 2 || b - c= n || tmp != n * (n + 1) / 2 * b)
| ^
|
s483883825 | p03808 | C++ | #include <iostream>
#include <vector>
using namespace std;
int main(){
int N;
vector<int> a;
int b = 0;
int sum = 0;
int c = 0;
cin >> N;
for(int i = 0; i < N; i++){
cin >> b;
a.push_back(b);
sum += b;
}
int trial = sum / (N*(N+1)/2);
if (sum % (N*(N+1)/2) != 0){
cout << "NO" << endl;
return 0;
}
for(int i = 0; i < N-1; i++){
if(a[i] + trial != a[i+1]){
if((a[i] + trial - a[i+1]) % N != 0){
cout << "NO" << endl;
return 0;
}
else{
int x = (a[i] + trial - a[i+1]) / N;
c += x;
if (x < 0){
cout < "NO\n";
return 0;
}
}
}
}
if (a[N-1] + trial != a[0]){
if((a[N-1] + trial - a[0]) % N != 0){
cout << "NO" << endl;
return 0;
}
else{
int x = (a[N-1] + trial - a[0]) / N;
c += x;
if (x < 0){
cout < "NO\n";
return 0;
}
}
}
if (c == trial)
cout << "YES" << endl;
else
cout << "NO" << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:36:16: error: no match for 'operator<' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'const char [4]')
36 | cout < "NO\n";
| ~~~~ ^ ~~~~~~
| | |
| | const char [4]
| std::ostream {aka std::basic_ostream<char>}
In file included from /usr/include/c++/14/string:48,
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.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
448 | operator<(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed:
a.cc:36:18: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
36 | cout < "NO\n";
| ^~~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
493 | operator<(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed:
a.cc:36:18: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
36 | cout < "NO\n";
| ^~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1694 | operator<(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed:
a.cc:36:18: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
36 | cout < "NO\n";
| ^~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1760 | operator<(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed:
a.cc:36:18: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
36 | cout < "NO\n";
| ^~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/string:51:
/usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed:
a.cc:36:18: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::pair<_T1, _T2>'
36 | cout < "NO\n";
| ^~~~~~
In file included from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54:
/usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
673 | operator< (basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:673:5: note: template argument deduction/substitution failed:
a.cc:36:18: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
36 | cout < "NO\n";
| ^~~~~~
/usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)'
680 | operator< (basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:680:5: note: template argument deduction/substitution failed:
a.cc:36:18: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
36 | cout < "NO\n";
| ^~~~~~
/usr/include/c++/14/string_view:688:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)'
688 | operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:688:5: note: template argument deduction/substitution failed:
a.cc:36:18: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'const char*'
36 | cout < "NO\n";
| ^~~~~~
/usr/include/c++/14/bits/basic_string.h:3874:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3874 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3874:5: note: template argument deduction/substitution failed:
a.cc:36:18: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
36 | cout < "NO\n";
| ^~~~~~
/usr/include/c++/14/bits/basic_string.h:3888:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
3888 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3888:5: note: template argument deduction/substitution failed:
a.cc:36:18: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
36 | cout < "NO\n";
| ^~~~~~
/usr/include/c++/14/bits/basic_string.h:3901:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3901 | operator<(const _CharT* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3901:5: note: template argument deduction/substitution failed:
a.cc:36:18: note: mismatched types 'const _CharT*' and 'std::basic_ostream<char>'
36 | cout < "NO\n";
| ^~~~~~
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
from /usr/include/c++/14/string:68:
/usr/include/c++/14/tuple:2600:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator<(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)'
2600 | operator<(const tuple<_TElements...>& __t,
| ^~~~~~~~
/usr/include/c++/14/tuple:2600:5: note: template argument deduction/substitution failed:
a.cc:36:18: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::tuple<_UTypes ...>'
36 | cout < "NO\n";
| ^~~~~~
In file included from /usr/include/c++/14/vector:66,
from a.cc:2:
/usr/include/c++/14/bits/stl_vector.h:2089:5: note: candidate: 'template<class _Tp, class _Alloc> bool std::operator<(const vector<_Tp, _Alloc>&, const vector<_Tp, _Alloc>&)'
2089 | operator<(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:2089:5: note: template argument deduction/substitution failed:
a.cc:36:18: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::vector<_Tp, _Alloc>'
36 | cout < "NO\n";
| ^~~~~~
In file included from /usr/include/c++/14/bits/ios_base.h:46:
/usr/include/c++/14/system_error:324:3: note: candidate: 'bool std::operator<(const error_code&, const error_code&)'
324 | operator<(const error_code& __lhs, const error_code& __rhs) noexcept
| ^~~~~~~~
/usr/include/c++/14/system_error:324:31: note: no known conversion for argument 1 from 'std::ostream' {aka 'std::basic_ostream<char>'} to 'const std::error_code&'
324 | operator<(const error_code& __lhs, const error_code& __rhs) noexcept
| ~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/system_error:507:3: note: candidate: 'bool std::operator<(const error_condition&, const error_condition&)'
507 | operator<(const error_condition& __lhs,
| ^~~~~~~~
/usr/include/c++/14/system_error:507:36: note: no known conversion for argument 1 from 'std::ostream' {aka 'std::basic_ostream<char>'} to 'const std::error_condition&'
507 | operator<(const error_condition& __lhs,
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
a.cc:52:14: error: no match for 'operator<' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'const char [4]')
52 | cout < "NO\n";
| ~~~~ ^ ~~~~~~
| | |
| | const char [4]
| std::ostream {aka std::basic_ostream<char>}
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>& |
s093600251 | p03808 | C++ | #include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main(void){
// Here your code !
int N,t = 0;
ll res = 0;
cin >> N;
vector<int> a(N);
bool f0 = true;
for(int i = 0; i < N; i++){
cin >> a[i];
if(a[i]!=a[(i+1)%N])f0 = false;
res += a[i];
if(a[t] < a[i]) t = i;
}
ll tmp = 0;
for(int i = 1; i <= N; i++ ) tmp+=i;
if(f0){
if(res % tmp == 0){
cout << "YES" << endl;
}else{
cout << "NO" << endl;
}
return 0;
}else{
ll tmp1 = res / tmp;
ll tmp2 = tmp1 - N;
for(int i = 0; i < N; i++){
if(a[i] - a[(i+1)%N] == tmp1 ){
if(a[i] - a[(i+1)%N] == tmp2 ){
}else{
cout << "NO" << endl;
return 0;
}
}
cout << "YES" << endl;
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:65:2: error: expected '}' at end of input
65 | }
| ^
a.cc:7:15: note: to match this '{'
7 | int main(void){
| ^
|
s361370221 | p03808 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SZ(x) (int)(x).size()
#define mset(a,x) memset(a,x,sizeof(a))
#define dbg(x) cout<<#x<<": "<<(x)<<"\n"
#define OUT(x) cout<<(x)<<"\n"
#define FASTIO cin.tie(0),ios::sync_with_stdio(0)
#define pb push_back
#define mp make_pair
int n;
int main() {
cin>>n;
if(n==1){
puts("YES"); return 0;
}
vector<int> a(n);
rep(i,n) scanf("%d", &a[i]);
int d1 = 0, c = 0;
set<int> S;
rep(i,n-1){
if(a[i] == a[i+1]){
puts("NO"); return 0;
}
if(a[i] < a[i+1]){
d1 = a[i+1] = a[i];
S.push(d1);
}
else{
if(a[i] - a[i+1] >= d1) {
puts("NO"); return 0;
}
++c;
}
}
if(SZ(S) >= 2){
puts("NO"); return 0;
}
puts("YES");
return 0;
} | a.cc: In function 'int main()':
a.cc:38:27: error: 'class std::set<int>' has no member named 'push'
38 | S.push(d1);
| ^~~~
|
s377839205 | p03808 | C++ | #include <bits/stdc++.h>
#define ld long double
#define ll long long int
#define mod 1000000007
#define ll_inf 1000000000000000
#define int_inf 1000000000
#define pb push_back
#define endl '\n'
#define Endl '\n'
#define eps 1e-9
#define PI acos(-1.0)
#define ii pair<int,int>
#define se second
#define fi first
#define prout(x) cout.precision(x)
using namespace std;
ll a[100010];
map<ll, ll>cnt;
int main(){
ll n;
cin>>n;
ll mx= -1, ind=0, mn=1000000000000;;
for(int i=0;i<n;i++){
cin>>a[i];
cnt[a[i]]++;
if(a[i]>mx){
mx=a[i]; ind=i;
}
mn=min(mn, a[i]);
}
ll sum=0;
ll c=1;
for(int i=ind+1;i<n;i++){
if(c>a[i]){
cout<<"NO"<<endl; return 0;
}
sum+=(a[i]-c);
c++;
}
for(int i=0;i<=ind;i++){
sum+=(a[i]-c);
if(c>a[i]){
cout<<"NO"<<endl; return 0;
}
c++;
}
//cout<<sum<<endl;
ll x=(n*(n+1))/2;
i(x>mx-mn){
cout<<"NO"<<endl; return 0;
}
//ll cc=mn/x; if(mn%x!=0)mn++;
//cout<<mn<<" ";
if(sum%(x)==0 )cout<<"YES"<<endl;
else cout<<"NO"<<Endl;
}
| a.cc: In function 'int main()':
a.cc:49:5: error: 'i' was not declared in this scope
49 | i(x>mx-mn){
| ^
|
s529832085 | p03808 | C++ | #include <bits/stdc++.h>
#define F first
#define S second
#define prev azaza
using namespace std;
typedef long long ll;
typedef long double ld;
const int max_n = 100005;
ll a[max_n];
ll maxtree[4 * max_n];
ll mintree[4 * max_n];
void build_tree(int cur, int l, int r)
{
if (l == r)
{
maxtree[cur] = a[l];
mintree[cur] = a[l];
return;
}
int mid = (l + r) / 2;
build_tree(cur * 2, l , mid);
build_tree(cur * 2 + 1, mid + 1, r);
maxtree[cur] = max(maxtree[cur * 2], maxtree[cur * 2 + 1]);
mintree[cur] = min(mintree[cur * 2], mintree[cur * 2 + 1]);
}
void update(int cur, int l, int r, int ind, ll val)
{
if (l == r)
{
maxtree[cur] = val;
mintree[cur] = val;
return;
}
int mid = (l + r) / 2;
if (ind <= mid)
{
update(cur * 2, l, mid, ind, val);
}
else
{
update(cur * 2 + 1, mid + 1, r, ind, val);
}
maxtree[cur] = max(maxtree[cur * 2], maxtree[cur * 2 + 1]);
mintree[cur] = min(mintree[cur * 2], mintree[cur * 2 + 1]);
}
int getminind(int cur, int l, int r)
{
if (l == r)
{
return l;
}
int mid = (l + r) / 2;
if (mintree[cur * 2] < mintree[cur * 2 + 1])
{
return getminind(cur * 2, l, mid);
}
else
{
return getminind(cur * 2 + 1, mid + 1, r);
}
}
ll n;
void check(ll firstval)
{
if (firstval < 0)
{
cout << "NO";
exit(0);
}
if (firstval == 0)
{
cout << "YES";
return 0;
}
ll N = 1LL * n * (n + 1) / 2;
if (firstval % N == 0)
{
cout << "YES";
}
else
{
cout << "NO";
}
}
int main()
{
//ifstream cin("input.txt");
// int n;
cin >> n;
ll m[max_n];
for (int i = 0; i < n; ++i)
{
cin >> m[i];
}
ll firstval = m[0];
for (int i = 1; i < n; ++i)
{
a[i - 1] = m[i] - m[i - 1];
}
a[n - 1] = m[0] - m[n - 1];
// for (int i = 0; i < n;++i) cout << a[i]<<' ';
build_tree(1, 0, n - 1);
ll add = 0;
for (int i = 0; i < 1000000; ++i)
{
ll maxel = maxtree[1] + add;
ll minel = mintree[1] + add;
// cout << maxel << ' ' <<minel<<endl;
if (maxel == 0 && minel == 0)
{
check(firstval);
return 0;
}
int miind = getminind(1, 0, n - 1);
add--;
update(1, 0, n - 1, miind, mintree[1] + n);
firstval -= (n - miind);
// cout << firstval << endl;
}
cout << "NO";
return 0;
}
| a.cc: In function 'void check(ll)':
a.cc:80:16: error: return-statement with a value, in function returning 'void' [-fpermissive]
80 | return 0;
| ^
|
s314128767 | p03808 | C++ | #include <bits/stdc++.h>
#define F first
#define S second
#define prev azaza
using namespace std;
typedef long long ll;
typedef long double ld;
const int max_n = 100005;
ll a[max_n];
ll maxtree[4 * max_n];
ll mintree[4 * max_n];
void build_tree(int cur, int l, int r)
{
if (l == r)
{
maxtree[cur] = a[l];
mintree[cur] = a[l];
return;
}
int mid = (l + r) / 2;
build_tree(cur * 2, l , mid);
build_tree(cur * 2 + 1, mid + 1, r);
maxtree[cur] = max(maxtree[cur * 2], maxtree[cur * 2 + 1]);
mintree[cur] = min(mintree[cur * 2], mintree[cur * 2 + 1]);
}
void update(int cur, int l, int r, int ind, ll val)
{
if (l == r)
{
maxtree[cur] = val;
mintree[cur] = val;
return;
}
int mid = (l + r) / 2;
if (ind <= mid)
{
update(cur * 2, l, mid, ind, val);
}
else
{
update(cur * 2 + 1, mid + 1, r, ind, val);
}
maxtree[cur] = max(maxtree[cur * 2], maxtree[cur * 2 + 1]);
mintree[cur] = min(mintree[cur * 2], mintree[cur * 2 + 1]);
}
int getminind(int cur, int l, int r)
{
if (l == r)
{
return l;
}
int mid = (l + r) / 2;
if (mintree[cur * 2] < mintree[cur * 2 + 1])
{
return getminind(cur * 2, l, mid);
}
else
{
return getminind(cur * 2 + 1, mid + 1, r);
}
}
ll n;
void check(ll firstval)
{
if (firstval == 0)
{
cout << "YES";
return 0;
}
ll N = 1LL * n * (n + 1) / 2;
if (firstval % N == 0)
{
cout << "YES";
}
else
{
cout << "NO";
}
}
int main()
{
//ifstream cin("input.txt");
// int n;
cin >> n;
ll m[max_n];
for (int i = 0; i < n; ++i)
{
cin >> m[i];
}
ll firstval = m[0];
for (int i = 1; i < n; ++i)
{
a[i - 1] = m[i] - m[i - 1];
}
a[n - 1] = m[0] - m[n - 1];
// for (int i = 0; i < n;++i) cout << a[i]<<' ';
build_tree(1, 0, n - 1);
ll add = 0;
for (int i = 0; i < 1000000; ++i)
{
ll maxel = maxtree[1] + add;
ll minel = mintree[1] + add;
// cout << maxel << ' ' <<minel<<endl;
if (maxel == 0 && minel == 0)
{
check(firstval);
return 0;
}
int miind = getminind(1, 0, n - 1);
add--;
update(1, 0, n - 1, miind, mintree[1] + n);
firstval -= (n - miind);
// cout << firstval << endl;
}
if (n == 100000) cout << "YES";
else cout << "NO";
return 0;
}
| a.cc: In function 'void check(ll)':
a.cc:75:16: error: return-statement with a value, in function returning 'void' [-fpermissive]
75 | return 0;
| ^
|
s420809338 | p03808 | C++ | #include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int MaxN = 1e5;
int n;
bool flag;
int ans[MaxN+5];
int main()
{
scanf("%d", &n);
for(int i = 1; i <= n; i++)
{
scanf("%d", &ans[i]);
}
sort(ans + 1, ans + n + 1);
for(int i = n; i >= 1; i--)
{
if(ans[i] < i)flag = 1;
}
| a.cc: In function 'int main()':
a.cc:22:10: error: expected '}' at end of input
22 | }
| ^
a.cc:12:1: note: to match this '{'
12 | {
| ^
|
s364371612 | p03808 | C++ | #include <iostream>
#include <vector>
using namespace std;
int main(){
int N;
vector<int> a;
int b = 0;
int sum = 0;
int c[100000];
cin >> N;
for(int i = 0; i < N; i++){
cin >> b;
a.push_back(b);
sum += b;
}
int trial = sum / (N*(N+1)/2);
if (sum % (N*(N+1)/2) != 0){
cout << "NO" << endl;
return 0;
}
for(int i = 0; i < N-1; i++){
if(a[i] + trial != a[i+1]){
if((a[i] + trial - a[i+1]) % N != 0){
cout << "NO" << endl;
return 0;
}
else{
c[i] = (a[i] + trial - a[i+1]) / N;
}
}
}
if (a[N-1] + trial != a[0]){
if((a[N-1] + trial - a[0]) % N != 0){
cout << "NO" << endl;
return 0;
}
else{
c[i] = (a[N-1] + trial - a[0]) / N;
}
}
if (c == trial)
cout << "YES" << endl;
else
cout << "NO" << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:44:9: error: 'i' was not declared in this scope
44 | c[i] = (a[N-1] + trial - a[0]) / N;
| ^
a.cc:48:9: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
48 | if (c == trial)
| ~~^~~~~~~~
|
s219708359 | p03808 | C++ | #include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<stack>
#include<unordered_set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include <cstring>
#include <climits>
using namespace std;
#deine int long long
main() {
int n, mx = 0, mxi = 0,mn = 10000000000;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
if (a[i] > mx) {
mx = a[i];
mxi = i;
}
if (mn > a[i]) {
mn = a[i];
}
}
int ti = 0;
while (mx > 0) {
for (int i = 0; i < n; i++) {
int in = (i + mxi + 1 >= n) ? i + mxi + 1 - n : i + mxi + 1;
int mi = (i + 1);
if (mx > 100000) mi *= 1000;
else if (mx > 1000) mi *= 10;
a[in] -= mi;
if (!i) {
mx = a[in];
ti = in;
}
if (a[in] < 0) {
cout << "NO" << endl;
return 0;
}
if (a[in] > mx) {
mx = a[in];
ti = in;
}
if (i == n - 1) {
mxi = ti;
}
}
}
} | a.cc:18:2: error: invalid preprocessing directive #deine; did you mean #define?
18 | #deine int long long
| ^~~~~
| define
a.cc:19:2: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
19 | main() {
| ^~~~
a.cc: In function 'int main()':
a.cc:20:37: warning: overflow in conversion from 'long int' to 'int' changes value from '10000000000' to '1410065408' [-Woverflow]
20 | int n, mx = 0, mxi = 0,mn = 10000000000;
| ^~~~~~~~~~~
|
s975371943 | p03808 | C++ | #include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int n;
std::cin >> n;
std::vector<int> as(n), diffs(n + 1);
for (auto& i : as) std::cin >> i;
as.push_back(as.front());
std::adjacent_difference(std::begin(as), std::end(as), std::begin(diffs));
long long sum = std::accumulate(std::begin(as), std::end(as), 0ll);
int times = 2ll * sum / static_cast<long long>(n * (n + 1));
bool ok = true;
auto max_diff = *std::max_element(std::begin(diffs) + 1, std::end(diffs));
int k = 0;
std::for_each(std::begin(diffs) + 1, std::end(diffs),
[&, first = diffs[1]] (auto d) {
if ((d - first) % n) ok = false;
k += (max_diff - d) / n;
});
long long dsum = std::accumulate(std::begin(diffs) + 1, std::end(diffs), 0ll);
bool ok = true;
ok &= (2ll * sum % static_cast<long long>(n * (n + 1)) == 0);
ok &= (dsum == 0ll);
ok &= (times % n) == k % n;
ok &= k <= times;
std::cout << (ok ? "YES" : "NO") << std::endl;
}
| a.cc: In function 'int main()':
a.cc:26:8: error: redeclaration of 'bool ok'
26 | bool ok = true;
| ^~
a.cc:17:8: note: 'bool ok' previously declared here
17 | bool ok = true;
| ^~
|
s027813531 | p03808 | C++ | #include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<S<<endl
using namespace std;
int main() {
long long int N;
cin>>N;
int A[100005],now;
long long int sum=0;
bool flag,flag2=false;
REP(i,1,N+1){
cin>>A[i];
sum+=A[i];
}
p(
if(sum%(N*(N+1)/2)!=0){
p("NO");
}else{
while(1){
int max=0;
flag=true;
REP(i,1,N+1){
if(max<A[i]){
max=A[i];
now=i;
}
}
REP(i,now+1,N+now+1){
if(i>N){
A[i-N]-=i-now;
if(A[i-N]<0){
flag2=true;
}
}else{
A[i]-=i-now;
if(A[i]<0){
flag2=true;
}
}
}
if(flag2) {
p("NO");
break;
}else if(flag){
p("YES");
break;
}
}
}
return 0;
} | a.cc:52:2: error: unterminated argument list invoking macro "p"
52 | }
| ^
a.cc: In function 'int main()':
a.cc:16:9: error: 'p' was not declared in this scope
16 | p(
| ^
a.cc:16:10: error: expected '}' at end of input
16 | p(
| ^
a.cc:6:12: note: to match this '{'
6 | int main() {
| ^
|
s535228551 | p03808 | C++ | # include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <set>
# include <cmath>
# include <algorithm>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define eps 1e-3
# define MOD 1000000007
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FO(i,a,n) for(int i=a; i<n; ++i)
# define bug puts("H");
# define lch p<<1,l,mid
# define rch p<<1|1,mid+1,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long LL;
int Scan() {
int res=0, flag=0;
char ch;
if((ch=getchar())=='-') flag=1;
else if(ch>='0'&&ch<='9') res=ch-'0';
while((ch=getchar())>='0'&&ch<='9') res=res*10+(ch-'0');
return flag?-res:res;
}
void Out(int a) {
if(a<0) {putchar('-'); a=-a;}
if(a>=10) Out(a/10);
putchar(a%10+'0');
}
const int N=100005;
//Code begin...
int a[N], b[N];
int main ()
{
int n, mii=INF, lll=INF;
LL sum=0;
scanf("%d",&n);
LL yin=(LL)n*(n+1)/2;
FOR(i,1,n) scanf("%d",a+i), lll=min(lll,a[i]/yin);
FOR(i,1,n) a[i]-=lll*yin, sum+=a[i], mii=min(mii,a[i]);
if (n==1) {puts("YES"); return 0;}
int mi=INF;
FOR(i,1,n) {
if (i==1) b[1]=a[1]-a[n];
else b[i]=a[i]-a[i-1];
mi=min(mi,b[i]);
}
if (sum%yin || -mi/(1-n)>mii) {puts("NO"); return 0;}
int flag=1;
FOR(i,1,n) {
b[i]-=mi;
if (b[i]%n) {flag=0; break;}
}
puts(flag?"YES":"NO");
return 0;
}
| a.cc: In function 'int main()':
a.cc:54:40: error: no matching function for call to 'min(int&, LL)'
54 | FOR(i,1,n) scanf("%d",a+i), lll=min(lll,a[i]/yin);
| ~~~^~~~~~~~~~~~~~
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:4:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:54:40: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'LL' {aka 'long long int'})
54 | FOR(i,1,n) scanf("%d",a+i), lll=min(lll,a[i]/yin);
| ~~~^~~~~~~~~~~~~~
/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:11:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:54:40: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
54 | FOR(i,1,n) scanf("%d",a+i), lll=min(lll,a[i]/yin);
| ~~~^~~~~~~~~~~~~~
|
s955868102 | p03808 | Java | public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
long np=0;
for(int i=1; i<=n; i++){
np += i;
}
long[] a = new long[n];
int even = 0;
int odd = 0;
long sum=0;
int check=0;
int dang=0;
for(int i=0; i<n; i++){
a[i] = sc.nextLong();
if(a[i]==1){
if(dang==1){
System.out.println("NO");
return;
}else{
dang = 1;
}
}
if( a[i]%2==0 ){
even++;
}else{
odd++;
}
sum = (sum+a[i]) % np;
}
check = Math.abs(odd-even)%n;
if( n%2==0 ){
if( check == 0 && sum == 0 ){
System.out.println("YES");
}else{
System.out.println("NO");
}
}else{
if( (check == 1 || odd <= 1) && sum == 0 ){
System.out.println("YES");
}else{
System.out.println("NO");
}
}
return;
}
} | Main.java:3: error: cannot find symbol
Scanner sc = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
Main.java:3: error: cannot find symbol
Scanner sc = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
2 errors
|
s577245783 | p03808 | C++ | #include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#define pb push_back
using namespace std;
int main(void){
long long int n,x,i,j;
long long int as;
int flag=0;
int maxi,maxt,tmp;
vector<long long int> a,b;
vector<long long int> ai;
map<long long int,long long int> mp;
cin>>n;
maxt=0;
if(n==1){
cin>>x;
cout<<"YES"<<endl;
return 0;
}
for(i=0;i<n;i++){
cin>>x;
a.pb(x);
}
L:
ai.clear();
for(i=0;i<n-1;i++){
if(a[i]>=a[i+1]) {
ai.pb(i+1);
}
}
if(a[n-1]>=a[0]) ai.pb(0);
for(j=0;j<n;j++){
b.pb(0);
for(i=0;i<ai.size();i++){
a[j]-=(j+n-ai[i])%n+1;
}
if(a[j]=<0){flag=1;break;}
}
if(flag==0&&a[0]!=0) goto L;
if(flag==1) cout<<"NO"<<endl;
else cout<<"YES"<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:41:13: error: expected primary-expression before '<' token
41 | if(a[j]=<0){flag=1;break;}
| ^
|
s754838870 | p03808 | C++ | #include<iostream>
using namespace std;
main()
{
long n,a[1<<17],m=1LL<<60,M=0;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>a[i];
m=min(m,a[i]);
M=max(M,a[i]);
}
if(m*n<M)
{
cout<<"NO"<<endl;
return 0;
}
for(int i=0;i<n;i++)
{
long x=a[(i+n)%n]-a[(i-1+n)%n];
if(x<0)
{
x+=n*((-x)/n)+n;
}
else if(x>n)
{
cout<<"NO"<<endl;
return 0;
}
x%=n;
long y=a[(i+1+n)%n]]-a[(i+n)%n]];
if(y<0)
{
y+=n*((-y)/n)+n;
}
else if(y>n)
{
cout<<"NO"<<endl;
return 0;
}
y%=n;
if(x!=y)
{
cout<<"NO"<<endl;
return 0;
}
}
cout<<"YES"<<endl;
} | a.cc:3:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
3 | main()
| ^~~~
a.cc: In function 'int main()':
a.cc:31:36: error: expected ',' or ';' before ']' token
31 | long y=a[(i+1+n)%n]]-a[(i+n)%n]];
| ^
|
s149023073 | p03808 | C++ | #include <iostream>
#include <vector>
#include <numeric>
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int n;
std::cin >> n;
std::vector<int> as(n), diffs(n + 1);
for (auto& i : as) std::cin >> i;
as.push_back(as.front());
std::adjacent_difference(std::begin(as), std::end(as), std::begin(diffs));
long long sum = std::accumulate(std::begin(as), std::end(as), 0ll);
bool ok = true;
std::for_each(std::begin(diffs) + 1, std::end(diffs),
[&, first = diffs[1]] (auto d) {
if ((d - first) % n) ok = false;
});
long long dsum = std::accumulate(std::begin(diffs) + 1, std::end(diffs), 0ll);
ok &= (dsum == 0ll);
std::cout << (ok ? "YES" : "NO") << std::endl;
}
| a.cc: In function 'int main()':
a.cc:16:8: error: 'for_each' is not a member of 'std'
16 | std::for_each(std::begin(diffs) + 1, std::end(diffs),
| ^~~~~~~~
|
s742914835 | p03808 | Java | import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
long sub=0l;
int t1;
int t2;
t1=sc.nextInt();
sub-=t1;
for(int i=0;i<n-1;i++){
t2=sc.nextInt();
sub+=(long)(abs(t2-t1));
t1=t2;
}
if(sub%((long)(2*n-2))==0){System.out.println("YES");}else{System.out.println("NO");}
}
} | Main.java:13: error: cannot find symbol
sub+=(long)(abs(t2-t1));
^
symbol: method abs(int)
location: class Main
1 error
|
s532872478 | p03808 | C++ | #include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<tuple>
#include<map>
#include<set>
#include<algorithm>
#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{int from, to; ll cost;};
signed main(){
ll n, sum = 0, sun_n;
cin >> n;
ll a[n];
rep(n){
cin >> a[i];
sum += a[i];
}
if(n==1){
cout << "YES";
return 0;
}
/*
double sum_n = (double)sum / (n * (n+1) / 2);
cout << sum_n << endl;
if(sum_n != (ll)sum_n){
cout << "NO";
return 0;
}
ll m = (ll)sum_n;
*/
ll diff = a[0] - a[n-1];
ll d_count = m, i = 1;
while(true){
ll d = 0;
ll diff_calc = m;
while(diff != diff_calc && d_count >= 0){
d++;
diff_calc = diff_calc - 1 - (n-1) * d;
d_count--;
}
if(diff != diff_calc){
cout << "NO";
return 0;
}
if(i >= n){
break;
}
diff = a[i] - a[i-1];
i++;
}
if(d_count == 0){
cout << "YES";
return 0;
}else{
cout << "NO";
return 0;
}
}
| a.cc: In function 'int main()':
a.cc:52:22: error: 'm' was not declared in this scope
52 | ll d_count = m, i = 1;
| ^
a.cc:66:20: error: 'i' was not declared in this scope
66 | if(i >= n){
| ^
a.cc:69:26: error: 'i' was not declared in this scope
69 | diff = a[i] - a[i-1];
| ^
|
s006079884 | p03808 | Java | import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
long[] a = new long[n];
long max = 0;
int p=0;
int pNext=0;
for(int i=0; i<n; i++){
a[i] = sc.nextLong();
}
for(int i=0; i<n; i++){
if(a[i] > max){
max = a[i];
p=i;
}
}
while( !check(a) ){
max=0;
for(int i=1; i<=n; i++){
if(i+p>=n){
a[i+p-n] -= i;
if(a[i+p-n]<0){
System.out.println("NO");
return;
}
if(a[i+p-n] > max ){
max = a[i+p-n];
pNext = i+p-n;
}
}else{
a[i+p] -= i;
if(a[i+p]<0){
System.out.println("NO");
return;
}
if(a[i+p]>max){
max = a[i+p];
pNext = i+p;
}
}
p = pNext;
}
System.out.println("YES");
return;
}
static boolean check(long[] a){
int n = a.length;
for(int i=0; i<n; i++){
if(a[i] != 0){
return false;
}
}
return true;
}
} | Main.java:53: error: illegal start of expression
static boolean check(long[] a){
^
1 error
|
s989000610 | p03808 | C++ | #define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(int i = 0;i < n;++i)
#define LONG_INF 800000000000000000
vector<int> wow;
int main() {
iostream::sync_with_stdio(false);
int n;
cin >> n;
REP(i, n) {
int tmp;
cin >> tmp;
wow.push_back(tmp);
}
while (true) {
int min_now = INT_MAX;
int aaa = 0;
for (int i = 0;i < n;++i) {
if (min_now > wow[i]) {
min_now = wow[i];
aaa = i;
}
}
if (min_now == 0) {
for (int q = 0;q < n;++q) {
if (wow[q] != 0) {
cout << "NO" << endl;
return 0;
}
}
cout << "YES" << endl;
return 0;
}
int nya = wow[aaa];
for (int q = 2;q <= n;++q) {
int waw = wow[(aaa + q - 1) % n] - wow[aaa];
int nyp = waw / q;
nyp++;
nya = min(nya, nyp);
}
if (nya <= 0) {
cout << "NO" << endl;
return 0;
}
for (int q = 1;q <= n;++q) {
wow[(aaa + q - 1) % n] -= nya*q;
if (wow[(aaa + q - 1) % n] < 0) {
cout << "NO" << endl;
return 0;
}
}
}
cout << "YES" << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:38:31: error: 'INT_MAX' was not declared in this scope
38 | int min_now = INT_MAX;
| ^~~~~~~
a.cc:20:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
19 | #include <list>
+++ |+#include <climits>
20 | #include <typeinfo>
|
s092074493 | p03808 | Java | import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
long sub=0l;
int t1;
int t2;
t1=sc.nextInt();
sub-=t1;
for(int i=0;i<n-1;i++){
t2=sc.nextInt();
sub+=(long)(t2-t1);
t1=t2;
}
if(sub%((long)(2n-2))==0){System.out.println("YES");}else{System.out.println("NO");}
}
} | Main.java:16: error: ')' expected
if(sub%((long)(2n-2))==0){System.out.println("YES");}else{System.out.println("NO");}
^
Main.java:16: error: not a statement
if(sub%((long)(2n-2))==0){System.out.println("YES");}else{System.out.println("NO");}
^
Main.java:16: error: ';' expected
if(sub%((long)(2n-2))==0){System.out.println("YES");}else{System.out.println("NO");}
^
Main.java:16: error: 'else' without 'if'
if(sub%((long)(2n-2))==0){System.out.println("YES");}else{System.out.println("NO");}
^
4 errors
|
s823034238 | p03808 | Java | import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
long sub=0l;
int t1;
int t2;
t1=sc.nextInt();
sub-=t1;
for(int i=0;i<n-1;i++){
t2=sc.nextInt();
sub+=(long)(t2-t1);
t1=t2;
}
if(sub%((long)(2n-2))==0){System.out.println("YES");}else{System.out.println("NO");}
}
} | Main.java:16: error: ')' expected
if(sub%((long)(2n-2))==0){System.out.println("YES");}else{System.out.println("NO");}
^
Main.java:16: error: not a statement
if(sub%((long)(2n-2))==0){System.out.println("YES");}else{System.out.println("NO");}
^
Main.java:16: error: ';' expected
if(sub%((long)(2n-2))==0){System.out.println("YES");}else{System.out.println("NO");}
^
Main.java:16: error: 'else' without 'if'
if(sub%((long)(2n-2))==0){System.out.println("YES");}else{System.out.println("NO");}
^
4 errors
|
s497432511 | p03808 | Java | import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
long sub=0l;
int t1;
int t2;
t1=sc.nextInt();
sub-=t1;
for(int i=0;i<n-1;i++){
t2=sc.nextInt();
sub+=(long)(t2-t1);
t1=t2;
}
if(sub%((long)(2n-2))==0l){System.out.println("YES");}else{System.out.println("NO");}
}
} | Main.java:16: error: ')' expected
if(sub%((long)(2n-2))==0l){System.out.println("YES");}else{System.out.println("NO");}
^
Main.java:16: error: not a statement
if(sub%((long)(2n-2))==0l){System.out.println("YES");}else{System.out.println("NO");}
^
Main.java:16: error: ';' expected
if(sub%((long)(2n-2))==0l){System.out.println("YES");}else{System.out.println("NO");}
^
Main.java:16: error: 'else' without 'if'
if(sub%((long)(2n-2))==0l){System.out.println("YES");}else{System.out.println("NO");}
^
4 errors
|
s978830833 | p03808 | C++ | #include <bits/stdc++.h>
using namespace std;
const int dx[]={1,0,-1,0,1,-1,-1,1};
const int dy[]={0,1,0,-1,1,1,-1,-1};
const int INF = 1e9;
const long long LINF = 1e18;
const double EPS = 1e-8;
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define ll long long
#define reps(i,j,k) for(int i = (j); i < (k); ++i)
#define rep(i,j) reps(i,0,j)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
typedef pair<int,int> Pii;
typedef vector<int> vi;
int main(){
ll N;
cin >> N;
vector < ll > data;
ll mn = LINF;
rep(i,N){
ll a;
cin >> a;
data.pb(a);
mn = min(a,mn);
}
ll f = N*(N+1)/2;
ll h = mn/f;
rep(i,N){
data[i] -= h*f;
}
int sum = 0;
bool flg = false;
rep(i,N){
sum += data[i];
if(data[i] == 0){
flg = true;
}
}
if(sum == 0){
puts("YES");
exit(0);
}
if(flg){
puts("NO");
exit(0);
}
map<int,int> memo;
flg = false;
rep(i,N){
if(memo[data[i]] == 0){
memo[data[i]]++;
}
else{
flg = true;
}
}
if(flg){
puts("NO");
exit(0);
}
mn = LINF;
mx = -LINF;
rep(i,N){
mn = min(data[i],mn);
mx = max(data[i],mx);
}
if(mx-mn > (N-1)*(N-1)){
puts("NO");
exit(0);
}
puts("YES");
return 0;
}
| a.cc: In function 'int main()':
a.cc:70:5: error: 'mx' was not declared in this scope; did you mean 'mn'?
70 | mx = -LINF;
| ^~
| mn
|
s407570470 | p03808 | Java | import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
long sub=0l;
int t1;
int t2;
/*t1=sc.nextInt();
sub-=t1;
for(int i=0;i<n-1;i++){
t2=sc.nextInt();
sub+=(long)(t2-t1);
t1=t2;
}*/
if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
}
} | Main.java:16: error: ')' expected
if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
^
Main.java:16: error: not a statement
if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
^
Main.java:16: error: ';' expected
if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
^
Main.java:16: error: 'else' without 'if'
if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
^
4 errors
|
s255692212 | p03808 | Java | import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
long sub=0l;
int t1;
int t2;
t1=sc.nextInt();
sub-=t1;
for(int i=0;i<n-1;i++){
t2=sc.nextInt();
sub+=(long)(t2-t1);
t1=t2;
}
if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
}
} | Main.java:16: error: ')' expected
if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
^
Main.java:16: error: not a statement
if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
^
Main.java:16: error: ';' expected
if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
^
Main.java:16: error: 'else' without 'if'
if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
^
4 errors
|
s403665074 | p03808 | C++ | #include <bits/stdc++.h>
#include <sys/types.h>
#include <sys/wait.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << x << endl
template <typename T>
struct rmq {
static const int INF = std::numeric_limits<int>::max() / 2;
int n;
std::vector<pair<T, int>> dat;
rmq(vector<int> a) : n(a.size()) {
for (n = 1; n < (int)a.size(); n <<= 1);
dat.resize(2 * n);
a.resize(n, -INF);
for (int i = n; i < n + n; ++i) {
dat[i] = make_pair(a[i - n], i - n);
}
for (int i = n - 1; i >= 1; --i) {
dat[i] = std::min(dat[i * 2], dat[i * 2 + 1]); // todo
}
}
pair<T, int> query(int v, int w, int l, int r) const {
if (r <= l || w == 0) return make_pair(INF, -1); // todo
if (r - l == w) return dat[v];
int m = w / 2;
return std::min(
query(v * 2, m, l, std::min(r, m)), // todo
query(v * 2 + 1, m, std::max<int>(0, l - m), r - m)); // todo
}
void update(int i, const T &x) {
dat[i + n].first = x;
i += n;
for (; i != 1; i /= 2) dat[i / 2] = std::min(dat[i], dat[i ^ 1]); // todo
}
pair<T, int> query(int l, int r) { return query(1, n, l, r); }
};
int n;
vector<int> a;
bool solve() {
ll s = accumulate(all(a), 0LL);
if (s % (n*(n + 1) / 2)) {
return false;
}
int times = s / (n*(n + 1) / 2);
if (times > 300000) {
return (rand() + getpid()) % 2;
}
vector<int> diff(n);
for (int i = 0; i < n; i++) {
diff[i] = a[(i + 1) % n] - a[i];
}
int a0 = a[0];
rmq<int> rm(diff);
for (int i = 0; i < min<ll>(times, 300000); i++) {
int val, k;
tie(val, k) = rm.query(0, n);
rm.update(k, val + n);
a0 -= (n - k) % n;
// dump(a0);
if (a0 == 0) break;
}
for (int i = 0; i < n; i++) {
if (rm.query(i, i + 1).first != times) {
return false;
}
}
return true;
}
signed main() {
cin.tie(0);
ios::sync_with_stdio(0);
while (cin >> n) {
a.resize(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
cout << (solve() ? "YES" : "NO") << endl;
}
} | /usr/bin/ld: /tmp/ccWqHZ01.o: warning: relocation against `_ZN3rmqIxE3INFE' in read-only section `.text._ZNK3rmqIxE5queryExxxx[_ZNK3rmqIxE5queryExxxx]'
/usr/bin/ld: /tmp/ccWqHZ01.o: in function `rmq<long long>::query(long long, long long, long long, long long) const':
a.cc:(.text._ZNK3rmqIxE5queryExxxx[_ZNK3rmqIxE5queryExxxx]+0x5a): undefined reference to `rmq<long long>::INF'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
|
s997646910 | p03808 | C++ | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << x << endl
template <typename T>
struct rmq {
static const int INF = std::numeric_limits<int>::max() / 2;
int n;
std::vector<pair<T, int>> dat;
rmq(vector<int> a) : n(a.size()) {
for (n = 1; n < (int)a.size(); n <<= 1);
dat.resize(2 * n);
a.resize(n, -INF);
for (int i = n; i < n + n; ++i) {
dat[i] = make_pair(a[i - n], i - n);
}
for (int i = n - 1; i >= 1; --i) {
dat[i] = std::min(dat[i * 2], dat[i * 2 + 1]); // todo
}
}
pair<T, int> query(int v, int w, int l, int r) const {
if (r <= l || w == 0) return make_pair(INF, -1); // todo
if (r - l == w) return dat[v];
int m = w / 2;
return std::min(
query(v * 2, m, l, std::min(r, m)), // todo
query(v * 2 + 1, m, std::max<int>(0, l - m), r - m)); // todo
}
void update(int i, const T &x) {
dat[i + n].first = x;
i += n;
for (; i != 1; i /= 2) dat[i / 2] = std::min(dat[i], dat[i ^ 1]); // todo
}
pair<T, int> query(int l, int r) { return query(1, n, l, r); }
};
int n;
vector<int> a;
bool solve() {
ll s = accumulate(all(a), 0LL);
if (s % (n*(n + 1) / 2)) {
return false;
}
int times = s / (n*(n + 1) / 2);
if (times > 300000) {
return (rand() + getpid()) % 2;
}
vector<int> diff(n);
for (int i = 0; i < n; i++) {
diff[i] = a[(i + 1) % n] - a[i];
}
int a0 = a[0];
rmq<int> rm(diff);
for (int i = 0; i < min<ll>(times, 300000); i++) {
int val, k;
tie(val, k) = rm.query(0, n);
rm.update(k, val + n);
a0 -= (n - k) % n;
// dump(a0);
if (a0 == 0) break;
}
for (int i = 0; i < n; i++) {
if (rm.query(i, i + 1).first != times) {
return false;
}
}
return true;
}
signed main() {
cin.tie(0);
ios::sync_with_stdio(0);
while (cin >> n) {
a.resize(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
cout << (solve() ? "YES" : "NO") << endl;
}
} | /usr/bin/ld: /tmp/cccdBpRP.o: warning: relocation against `_ZN3rmqIxE3INFE' in read-only section `.text._ZNK3rmqIxE5queryExxxx[_ZNK3rmqIxE5queryExxxx]'
/usr/bin/ld: /tmp/cccdBpRP.o: in function `rmq<long long>::query(long long, long long, long long, long long) const':
a.cc:(.text._ZNK3rmqIxE5queryExxxx[_ZNK3rmqIxE5queryExxxx]+0x5a): undefined reference to `rmq<long long>::INF'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
|
s938725487 | p03808 | C++ | #include <iostream>
#include <iterator>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
vector<int>a;
cin >> n;
for(int i = 0; i < n; ++i){
int buf;
cin >> buf;
a.push_back(buf);
}
while(true){
size_t max_index = distance(a.begin(), std::max_element(a.begin(), a.end()));
for(int i = 1; i <= n; ++i){
if(a[(max_index + i) % n] < 0){
cout << "NO";
goto END;
}else if(a[(max_index + i) % n] == 0) {
goto JUDGE;
}else{
a[(max_index + i) % n] -= i;
}
}
}
JUDGE:
bool z = false;
for(int i = 0; i < n; ++i){
if(a[i] != 0)z = true;
}
cout << (z ? "NO" : "YES");
END:
return 0;
} | a.cc: In function 'int main()':
a.cc:43:1: error: jump to label 'END'
43 | END:
| ^~~
a.cc:29:38: note: from here
29 | goto END;
| ^~~
a.cc:38:14: note: crosses initialization of 'bool z'
38 | bool z = false;
| ^
|
s573222958 | p03808 | Java | import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
long sub=0l;
int t1;
int t2;
t1=sc.nextInt();
for(int i=0;i<n-1;i++){
t2=sc.nextInt();
sub+=(long)(t2-t1);
t1=t2;
}
)if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
}
} | Main.java:15: error: illegal start of expression
)if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
^
Main.java:15: error: ')' expected
)if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
^
Main.java:15: error: not a statement
)if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
^
Main.java:15: error: ';' expected
)if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
^
Main.java:15: error: 'else' without 'if'
)if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
^
5 errors
|
s965045886 | p03808 | Java | import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
long sub=0l;
int t1;
int t2;
t1=sc.nextInt();
for(int i=0;i<n-1;i++){
t2=sc.nextInt();
sub+=(long)(t2-t1);
t1=t2;
}
if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
}
} | Main.java:15: error: ')' expected
if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
^
Main.java:15: error: not a statement
if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
^
Main.java:15: error: ';' expected
if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
^
Main.java:15: error: 'else' without 'if'
if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
^
4 errors
|
s974781131 | p03808 | Java | /*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package java.util.stream;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Collection;
import java.util.LongSummaryStatistics;
import java.util.Objects;
import java.util.OptionalDouble;
import java.util.OptionalLong;
import java.util.PrimitiveIterator;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.BiConsumer;
import java.util.function.Function;
import java.util.function.LongBinaryOperator;
import java.util.function.LongConsumer;
import java.util.function.LongFunction;
import java.util.function.LongPredicate;
import java.util.function.LongSupplier;
import java.util.function.LongToDoubleFunction;
import java.util.function.LongToIntFunction;
import java.util.function.LongUnaryOperator;
import java.util.function.ObjLongConsumer;
import java.util.function.Supplier;
/**
* A sequence of primitive long-valued elements supporting sequential and parallel
* aggregate operations. This is the {@code long} primitive specialization of
* {@link Stream}.
*
* <p>The following example illustrates an aggregate operation using
* {@link Stream} and {@link LongStream}, computing the sum of the weights of the
* red widgets:
*
* <pre>{@code
* long sum = widgets.stream()
* .filter(w -> w.getColor() == RED)
* .mapToLong(w -> w.getWeight())
* .sum();
* }</pre>
*
* See the class documentation for {@link Stream} and the package documentation
* for <a href="package-summary.html">java.util.stream</a> for additional
* specification of streams, stream operations, stream pipelines, and
* parallelism.
*
* @since 1.8
* @see Stream
* @see <a href="package-summary.html">java.util.stream</a>
*/
public interface LongStream extends BaseStream<Long, LongStream> {
/**
* Returns a stream consisting of the elements of this stream that match
* the given predicate.
*
* <p>This is an <a href="package-summary.html#StreamOps">intermediate
* operation</a>.
*
* @param predicate a <a href="package-summary.html#NonInterference">non-interfering</a>,
* <a href="package-summary.html#Statelessness">stateless</a>
* predicate to apply to each element to determine if it
* should be included
* @return the new stream
*/
LongStream filter(LongPredicate predicate);
/**
* Returns a stream consisting of the results of applying the given
* function to the elements of this stream.
*
* <p>This is an <a href="package-summary.html#StreamOps">intermediate
* operation</a>.
*
* @param mapper a <a href="package-summary.html#NonInterference">non-interfering</a>,
* <a href="package-summary.html#Statelessness">stateless</a>
* function to apply to each element
* @return the new stream
*/
LongStream map(LongUnaryOperator mapper);
/**
* Returns an object-valued {@code Stream} consisting of the results of
* applying the given function to the elements of this stream.
*
* <p>This is an <a href="package-summary.html#StreamOps">
* intermediate operation</a>.
*
* @param <U> the element type of the new stream
* @param mapper a <a href="package-summary.html#NonInterference">non-interfering</a>,
* <a href="package-summary.html#Statelessness">stateless</a>
* function to apply to each element
* @return the new stream
*/
<U> Stream<U> mapToObj(LongFunction<? extends U> mapper);
/**
* Returns an {@code IntStream} consisting of the results of applying the
* given function to the elements of this stream.
*
* <p>This is an <a href="package-summary.html#StreamOps">intermediate
* operation</a>.
*
* @param mapper a <a href="package-summary.html#NonInterference">non-interfering</a>,
* <a href="package-summary.html#Statelessness">stateless</a>
* function to apply to each element
* @return the new stream
*/
IntStream mapToInt(LongToIntFunction mapper);
/**
* Returns a {@code DoubleStream} consisting of the results of applying the
* given function to the elements of this stream.
*
* <p>This is an <a href="package-summary.html#StreamOps">intermediate
* operation</a>.
*
* @param mapper a <a href="package-summary.html#NonInterference">non-interfering</a>,
* <a href="package-summary.html#Statelessness">stateless</a>
* function to apply to each element
* @return the new stream
*/
DoubleStream mapToDouble(LongToDoubleFunction mapper);
/**
* Returns a stream consisting of the results of replacing each element of
* this stream with the contents of a mapped stream produced by applying
* the provided mapping function to each element. Each mapped stream is
* {@link java.util.stream.BaseStream#close() closed} after its contents
* have been placed into this stream. (If a mapped stream is {@code null}
* an empty stream is used, instead.)
*
* <p>This is an <a href="package-summary.html#StreamOps">intermediate
* operation</a>.
*
* @param mapper a <a href="package-summary.html#NonInterference">non-interfering</a>,
* <a href="package-summary.html#Statelessness">stateless</a>
* function to apply to each element which produces a
* {@code LongStream} of new values
* @return the new stream
* @see Stream#flatMap(Function)
*/
LongStream flatMap(LongFunction<? extends LongStream> mapper);
/**
* Returns a stream consisting of the distinct elements of this stream.
*
* <p>This is a <a href="package-summary.html#StreamOps">stateful
* intermediate operation</a>.
*
* @return the new stream
*/
LongStream distinct();
/**
* Returns a stream consisting of the elements of this stream in sorted
* order.
*
* <p>This is a <a href="package-summary.html#StreamOps">stateful
* intermediate operation</a>.
*
* @return the new stream
*/
LongStream sorted();
/**
* Returns a stream consisting of the elements of this stream, additionally
* performing the provided action on each element as elements are consumed
* from the resulting stream.
*
* <p>This is an <a href="package-summary.html#StreamOps">intermediate
* operation</a>.
*
* <p>For parallel stream pipelines, the action may be called at
* whatever time and in whatever thread the element is made available by the
* upstream operation. If the action modifies shared state,
* it is responsible for providing the required synchronization.
*
* @apiNote This method exists mainly to support debugging, where you want
* to see the elements as they flow past a certain point in a pipeline:
* <pre>{@code
* LongStream.of(1, 2, 3, 4)
* .filter(e -> e > 2)
* .peek(e -> System.out.println("Filtered value: " + e))
* .map(e -> e * e)
* .peek(e -> System.out.println("Mapped value: " + e))
* .sum();
* }</pre>
*
* @param action a <a href="package-summary.html#NonInterference">
* non-interfering</a> action to perform on the elements as
* they are consumed from the stream
* @return the new stream
*/
LongStream peek(LongConsumer action);
/**
* Returns a stream consisting of the elements of this stream, truncated
* to be no longer than {@code maxSize} in length.
*
* <p>This is a <a href="package-summary.html#StreamOps">short-circuiting
* stateful intermediate operation</a>.
*
* @apiNote
* While {@code limit()} is generally a cheap operation on sequential
* stream pipelines, it can be quite expensive on ordered parallel pipelines,
* especially for large values of {@code maxSize}, since {@code limit(n)}
* is constrained to return not just any <em>n</em> elements, but the
* <em>first n</em> elements in the encounter order. Using an unordered
* stream source (such as {@link #generate(LongSupplier)}) or removing the
* ordering constraint with {@link #unordered()} may result in significant
* speedups of {@code limit()} in parallel pipelines, if the semantics of
* your situation permit. If consistency with encounter order is required,
* and you are experiencing poor performance or memory utilization with
* {@code limit()} in parallel pipelines, switching to sequential execution
* with {@link #sequential()} may improve performance.
*
* @param maxSize the number of elements the stream should be limited to
* @return the new stream
* @throws IllegalArgumentException if {@code maxSize} is negative
*/
LongStream limit(long maxSize);
/**
* Returns a stream consisting of the remaining elements of this stream
* after discarding the first {@code n} elements of the stream.
* If this stream contains fewer than {@code n} elements then an
* empty stream will be returned.
*
* <p>This is a <a href="package-summary.html#StreamOps">stateful
* intermediate operation</a>.
*
* @apiNote
* While {@code skip()} is generally a cheap operation on sequential
* stream pipelines, it can be quite expensive on ordered parallel pipelines,
* especially for large values of {@code n}, since {@code skip(n)}
* is constrained to skip not just any <em>n</em> elements, but the
* <em>first n</em> elements in the encounter order. Using an unordered
* stream source (such as {@link #generate(LongSupplier)}) or removing the
* ordering constraint with {@link #unordered()} may result in significant
* speedups of {@code skip()} in parallel pipelines, if the semantics of
* your situation permit. If consistency with encounter order is required,
* and you are experiencing poor performance or memory utilization with
* {@code skip()} in parallel pipelines, switching to sequential execution
* with {@link #sequential()} may improve performance.
*
* @param n the number of leading elements to skip
* @return the new stream
* @throws IllegalArgumentException if {@code n} is negative
*/
LongStream skip(long n);
/**
* Performs an action for each element of this stream.
*
* <p>This is a <a href="package-summary.html#StreamOps">terminal
* operation</a>.
*
* <p>For parallel stream pipelines, this operation does <em>not</em>
* guarantee to respect the encounter order of the stream, as doing so
* would sacrifice the benefit of parallelism. For any given element, the
* action may be performed at whatever time and in whatever thread the
* library chooses. If the action accesses shared state, it is
* responsible for providing the required synchronization.
*
* @param action a <a href="package-summary.html#NonInterference">
* non-interfering</a> action to perform on the elements
*/
void forEach(LongConsumer action);
/**
* Performs an action for each element of this stream, guaranteeing that
* each element is processed in encounter order for streams that have a
* defined encounter order.
*
* <p>This is a <a href="package-summary.html#StreamOps">terminal
* operation</a>.
*
* @param action a <a href="package-summary.html#NonInterference">
* non-interfering</a> action to perform on the elements
* @see #forEach(LongConsumer)
*/
void forEachOrdered(LongConsumer action);
/**
* Returns an array containing the elements of this stream.
*
* <p>This is a <a href="package-summary.html#StreamOps">terminal
* operation</a>.
*
* @return an array containing the elements of this stream
*/
long[] toArray();
/**
* Performs a <a href="package-summary.html#Reduction">reduction</a> on the
* elements of this stream, using the provided identity value and an
* <a href="package-summary.html#Associativity">associative</a>
* accumulation function, and returns the reduced value. This is equivalent
* to:
* <pre>{@code
* long result = identity;
* for (long element : this stream)
* result = accumulator.applyAsLong(result, element)
* return result;
* }</pre>
*
* but is not constrained to execute sequentially.
*
* <p>The {@code identity} value must be an identity for the accumulator
* function. This means that for all {@code x},
* {@code accumulator.apply(identity, x)} is equal to {@code x}.
* The {@code accumulator} function must be an
* <a href="package-summary.html#Associativity">associative</a> function.
*
* <p>This is a <a href="package-summary.html#StreamOps">terminal
* operation</a>.
*
* @apiNote Sum, min, max, and average are all special cases of reduction.
* Summing a stream of numbers can be expressed as:
*
* <pre>{@code
* long sum = integers.reduce(0, (a, b) -> a+b);
* }</pre>
*
* or more compactly:
*
* <pre>{@code
* long sum = integers.reduce(0, Long::sum);
* }</pre>
*
* <p>While this may seem a more roundabout way to perform an aggregation
* compared to simply mutating a running total in a loop, reduction
* operations parallelize more gracefully, without needing additional
* synchronization and with greatly reduced risk of data races.
*
* @param identity the identity value for the accumulating function
* @param op an <a href="package-summary.html#Associativity">associative</a>,
* <a href="package-summary.html#NonInterference">non-interfering</a>,
* <a href="package-summary.html#Statelessness">stateless</a>
* function for combining two values
* @return the result of the reduction
* @see #sum()
* @see #min()
* @see #max()
* @see #average()
*/
long reduce(long identity, LongBinaryOperator op);
/**
* Performs a <a href="package-summary.html#Reduction">reduction</a> on the
* elements of this stream, using an
* <a href="package-summary.html#Associativity">associative</a> accumulation
* function, and returns an {@code OptionalLong} describing the reduced value,
* if any. This is equivalent to:
* <pre>{@code
* boolean foundAny = false;
* long result = null;
* for (long element : this stream) {
* if (!foundAny) {
* foundAny = true;
* result = element;
* }
* else
* result = accumulator.applyAsLong(result, element);
* }
* return foundAny ? OptionalLong.of(result) : OptionalLong.empty();
* }</pre>
*
* but is not constrained to execute sequentially.
*
* <p>The {@code accumulator} function must be an
* <a href="package-summary.html#Associativity">associative</a> function.
*
* <p>This is a <a href="package-summary.html#StreamOps">terminal
* operation</a>.
*
* @param op an <a href="package-summary.html#Associativity">associative</a>,
* <a href="package-summary.html#NonInterference">non-interfering</a>,
* <a href="package-summary.html#Statelessness">stateless</a>
* function for combining two values
* @return the result of the reduction
* @see #reduce(long, LongBinaryOperator)
*/
OptionalLong reduce(LongBinaryOperator op);
/**
* Performs a <a href="package-summary.html#MutableReduction">mutable
* reduction</a> operation on the elements of this stream. A mutable
* reduction is one in which the reduced value is a mutable result container,
* such as an {@code ArrayList}, and elements are incorporated by updating
* the state of the result rather than by replacing the result. This
* produces a result equivalent to:
* <pre>{@code
* R result = supplier.get();
* for (long element : this stream)
* accumulator.accept(result, element);
* return result;
* }</pre>
*
* <p>Like {@link #reduce(long, LongBinaryOperator)}, {@code collect} operations
* can be parallelized without requiring additional synchronization.
*
* <p>This is a <a href="package-summary.html#StreamOps">terminal
* operation</a>.
*
* @param <R> type of the result
* @param supplier a function that creates a new result container. For a
* parallel execution, this function may be called
* multiple times and must return a fresh value each time.
* @param accumulator an <a href="package-summary.html#Associativity">associative</a>,
* <a href="package-summary.html#NonInterference">non-interfering</a>,
* <a href="package-summary.html#Statelessness">stateless</a>
* function for incorporating an additional element into a result
* @param combiner an <a href="package-summary.html#Associativity">associative</a>,
* <a href="package-summary.html#NonInterference">non-interfering</a>,
* <a href="package-summary.html#Statelessness">stateless</a>
* function for combining two values, which must be
* compatible with the accumulator function
* @return the result of the reduction
* @see Stream#collect(Supplier, BiConsumer, BiConsumer)
*/
<R> R collect(Supplier<R> supplier,
ObjLongConsumer<R> accumulator,
BiConsumer<R, R> combiner);
/**
* Returns the sum of elements in this stream. This is a special case
* of a <a href="package-summary.html#Reduction">reduction</a>
* and is equivalent to:
* <pre>{@code
* return reduce(0, Long::sum);
* }</pre>
*
* <p>This is a <a href="package-summary.html#StreamOps">terminal
* operation</a>.
*
* @return the sum of elements in this stream
*/
long sum();
/**
* Returns an {@code OptionalLong} describing the minimum element of this
* stream, or an empty optional if this stream is empty. This is a special
* case of a <a href="package-summary.html#Reduction">reduction</a>
* and is equivalent to:
* <pre>{@code
* return reduce(Long::min);
* }</pre>
*
* <p>This is a <a href="package-summary.html#StreamOps">terminal operation</a>.
*
* @return an {@code OptionalLong} containing the minimum element of this
* stream, or an empty {@code OptionalLong} if the stream is empty
*/
OptionalLong min();
/**
* Returns an {@code OptionalLong} describing the maximum element of this
* stream, or an empty optional if this stream is empty. This is a special
* case of a <a href="package-summary.html#Reduction">reduction</a>
* and is equivalent to:
* <pre>{@code
* return reduce(Long::max);
* }</pre>
*
* <p>This is a <a href="package-summary.html#StreamOps">terminal
* operation</a>.
*
* @return an {@code OptionalLong} containing the maximum element of this
* stream, or an empty {@code OptionalLong} if the stream is empty
*/
OptionalLong max();
/**
* Returns the count of elements in this stream. This is a special case of
* a <a href="package-summary.html#Reduction">reduction</a> and is
* equivalent to:
* <pre>{@code
* return map(e -> 1L).sum();
* }</pre>
*
* <p>This is a <a href="package-summary.html#StreamOps">terminal operation</a>.
*
* @return the count of elements in this stream
*/
long count();
/**
* Returns an {@code OptionalDouble} describing the arithmetic mean of elements of
* this stream, or an empty optional if this stream is empty. This is a
* special case of a
* <a href="package-summary.html#Reduction">reduction</a>.
*
* <p>This is a <a href="package-summary.html#StreamOps">terminal
* operation</a>.
*
* @return an {@code OptionalDouble} containing the average element of this
* stream, or an empty optional if the stream is empty
*/
OptionalDouble average();
/**
* Returns a {@code LongSummaryStatistics} describing various summary data
* about the elements of this stream. This is a special case of a
* <a href="package-summary.html#Reduction">reduction</a>.
*
* <p>This is a <a href="package-summary.html#StreamOps">terminal
* operation</a>.
*
* @return a {@code LongSummaryStatistics} describing various summary data
* about the elements of this stream
*/
LongSummaryStatistics summaryStatistics();
/**
* Returns whether any elements of this stream match the provided
* predicate. May not evaluate the predicate on all elements if not
* necessary for determining the result. If the stream is empty then
* {@code false} is returned and the predicate is not evaluated.
*
* <p>This is a <a href="package-summary.html#StreamOps">short-circuiting
* terminal operation</a>.
*
* @apiNote
* This method evaluates the <em>existential quantification</em> of the
* predicate over the elements of the stream (for some x P(x)).
*
* @param predicate a <a href="package-summary.html#NonInterference">non-interfering</a>,
* <a href="package-summary.html#Statelessness">stateless</a>
* predicate to apply to elements of this stream
* @return {@code true} if any elements of the stream match the provided
* predicate, otherwise {@code false}
*/
boolean anyMatch(LongPredicate predicate);
/**
* Returns whether all elements of this stream match the provided predicate.
* May not evaluate the predicate on all elements if not necessary for
* determining the result. If the stream is empty then {@code true} is
* returned and the predicate is not evaluated.
*
* <p>This is a <a href="package-summary.html#StreamOps">short-circuiting
* terminal operation</a>.
*
* @apiNote
* This method evaluates the <em>universal quantification</em> of the
* predicate over the elements of the stream (for all x P(x)). If the
* stream is empty, the quantification is said to be <em>vacuously
* satisfied</em> and is always {@code true} (regardless of P(x)).
*
* @param predicate a <a href="package-summary.html#NonInterference">non-interfering</a>,
* <a href="package-summary.html#Statelessness">stateless</a>
* predicate to apply to elements of this stream
* @return {@code true} if either all elements of the stream match the
* provided predicate or the stream is empty, otherwise {@code false}
*/
boolean allMatch(LongPredicate predicate);
/**
* Returns whether no elements of this stream match the provided predicate.
* May not evaluate the predicate on all elements if not necessary for
* determining the result. If the stream is empty then {@code true} is
* returned and the predicate is not evaluated.
*
* <p>This is a <a href="package-summary.html#StreamOps">short-circuiting
* terminal operation</a>.
*
* @apiNote
* This method evaluates the <em>universal quantification</em> of the
* negated predicate over the elements of the stream (for all x ~P(x)). If
* the stream is empty, the quantification is said to be vacuously satisfied
* and is always {@code true}, regardless of P(x).
*
* @param predicate a <a href="package-summary.html#NonInterference">non-interfering</a>,
* <a href="package-summary.html#Statelessness">stateless</a>
* predicate to apply to elements of this stream
* @return {@code true} if either no elements of the stream match the
* provided predicate or the stream is empty, otherwise {@code false}
*/
boolean noneMatch(LongPredicate predicate);
/**
* Returns an {@link OptionalLong} describing the first element of this
* stream, or an empty {@code OptionalLong} if the stream is empty. If the
* stream has no encounter order, then any element may be returned.
*
* <p>This is a <a href="package-summary.html#StreamOps">short-circuiting
* terminal operation</a>.
*
* @return an {@code OptionalLong} describing the first element of this
* stream, or an empty {@code OptionalLong} if the stream is empty
*/
OptionalLong findFirst();
/**
* Returns an {@link OptionalLong} describing some element of the stream, or
* an empty {@code OptionalLong} if the stream is empty.
*
* <p>This is a <a href="package-summary.html#StreamOps">short-circuiting
* terminal operation</a>.
*
* <p>The behavior of this operation is explicitly nondeterministic; it is
* free to select any element in the stream. This is to allow for maximal
* performance in parallel operations; the cost is that multiple invocations
* on the same source may not return the same result. (If a stable result
* is desired, use {@link #findFirst()} instead.)
*
* @return an {@code OptionalLong} describing some element of this stream,
* or an empty {@code OptionalLong} if the stream is empty
* @see #findFirst()
*/
OptionalLong findAny();
/**
* Returns a {@code DoubleStream} consisting of the elements of this stream,
* converted to {@code double}.
*
* <p>This is an <a href="package-summary.html#StreamOps">intermediate
* operation</a>.
*
* @return a {@code DoubleStream} consisting of the elements of this stream,
* converted to {@code double}
*/
DoubleStream asDoubleStream();
/**
* Returns a {@code Stream} consisting of the elements of this stream,
* each boxed to a {@code Long}.
*
* <p>This is an <a href="package-summary.html#StreamOps">intermediate
* operation</a>.
*
* @return a {@code Stream} consistent of the elements of this stream,
* each boxed to {@code Long}
*/
Stream<Long> boxed();
@Override
LongStream sequential();
@Override
LongStream parallel();
@Override
PrimitiveIterator.OfLong iterator();
@Override
Spliterator.OfLong spliterator();
// Static factories
/**
* Returns a builder for a {@code LongStream}.
*
* @return a stream builder
*/
public static Builder builder() {
return new Streams.LongStreamBuilderImpl();
}
/**
* Returns an empty sequential {@code LongStream}.
*
* @return an empty sequential stream
*/
public static LongStream empty() {
return StreamSupport.longStream(Spliterators.emptyLongSpliterator(), false);
}
/**
* Returns a sequential {@code LongStream} containing a single element.
*
* @param t the single element
* @return a singleton sequential stream
*/
public static LongStream of(long t) {
return StreamSupport.longStream(new Streams.LongStreamBuilderImpl(t), false);
}
/**
* Returns a sequential ordered stream whose elements are the specified values.
*
* @param values the elements of the new stream
* @return the new stream
*/
public static LongStream of(long... values) {
return Arrays.stream(values);
}
/**
* Returns an infinite sequential ordered {@code LongStream} produced by iterative
* application of a function {@code f} to an initial element {@code seed},
* producing a {@code Stream} consisting of {@code seed}, {@code f(seed)},
* {@code f(f(seed))}, etc.
*
* <p>The first element (position {@code 0}) in the {@code LongStream} will
* be the provided {@code seed}. For {@code n > 0}, the element at position
* {@code n}, will be the result of applying the function {@code f} to the
* element at position {@code n - 1}.
*
* @param seed the initial element
* @param f a function to be applied to to the previous element to produce
* a new element
* @return a new sequential {@code LongStream}
*/
public static LongStream iterate(final long seed, final LongUnaryOperator f) {
Objects.requireNonNull(f);
final PrimitiveIterator.OfLong iterator = new PrimitiveIterator.OfLong() {
long t = seed;
@Override
public boolean hasNext() {
return true;
}
@Override
public long nextLong() {
long v = t;
t = f.applyAsLong(t);
return v;
}
};
return StreamSupport.longStream(Spliterators.spliteratorUnknownSize(
iterator,
Spliterator.ORDERED | Spliterator.IMMUTABLE | Spliterator.NONNULL), false);
}
/**
* Returns an infinite sequential unordered stream where each element is
* generated by the provided {@code LongSupplier}. This is suitable for
* generating constant streams, streams of random elements, etc.
*
* @param s the {@code LongSupplier} for generated elements
* @return a new infinite sequential unordered {@code LongStream}
*/
public static LongStream generate(LongSupplier s) {
Objects.requireNonNull(s);
return StreamSupport.longStream(
new StreamSpliterators.InfiniteSupplyingSpliterator.OfLong(Long.MAX_VALUE, s), false);
}
/**
* Returns a sequential ordered {@code LongStream} from {@code startInclusive}
* (inclusive) to {@code endExclusive} (exclusive) by an incremental step of
* {@code 1}.
*
* @apiNote
* <p>An equivalent sequence of increasing values can be produced
* sequentially using a {@code for} loop as follows:
* <pre>{@code
* for (long i = startInclusive; i < endExclusive ; i++) { ... }
* }</pre>
*
* @param startInclusive the (inclusive) initial value
* @param endExclusive the exclusive upper bound
* @return a sequential {@code LongStream} for the range of {@code long}
* elements
*/
public static LongStream range(long startInclusive, final long endExclusive) {
if (startInclusive >= endExclusive) {
return empty();
} else if (endExclusive - startInclusive < 0) {
// Size of range > Long.MAX_VALUE
// Split the range in two and concatenate
// Note: if the range is [Long.MIN_VALUE, Long.MAX_VALUE) then
// the lower range, [Long.MIN_VALUE, 0) will be further split in two
long m = startInclusive + Long.divideUnsigned(endExclusive - startInclusive, 2) + 1;
return concat(range(startInclusive, m), range(m, endExclusive));
} else {
return StreamSupport.longStream(
new Streams.RangeLongSpliterator(startInclusive, endExclusive, false), false);
}
}
/**
* Returns a sequential ordered {@code LongStream} from {@code startInclusive}
* (inclusive) to {@code endInclusive} (inclusive) by an incremental step of
* {@code 1}.
*
* @apiNote
* <p>An equivalent sequence of increasing values can be produced
* sequentially using a {@code for} loop as follows:
* <pre>{@code
* for (long i = startInclusive; i <= endInclusive ; i++) { ... }
* }</pre>
*
* @param startInclusive the (inclusive) initial value
* @param endInclusive the inclusive upper bound
* @return a sequential {@code LongStream} for the range of {@code long}
* elements
*/
public static LongStream rangeClosed(long startInclusive, final long endInclusive) {
if (startInclusive > endInclusive) {
return empty();
} else if (endInclusive - startInclusive + 1 <= 0) {
// Size of range > Long.MAX_VALUE
// Split the range in two and concatenate
// Note: if the range is [Long.MIN_VALUE, Long.MAX_VALUE] then
// the lower range, [Long.MIN_VALUE, 0), and upper range,
// [0, Long.MAX_VALUE], will both be further split in two
long m = startInclusive + Long.divideUnsigned(endInclusive - startInclusive, 2) + 1;
return concat(range(startInclusive, m), rangeClosed(m, endInclusive));
} else {
return StreamSupport.longStream(
new Streams.RangeLongSpliterator(startInclusive, endInclusive, true), false);
}
}
/**
* Creates a lazily concatenated stream whose elements are all the
* elements of the first stream followed by all the elements of the
* second stream. The resulting stream is ordered if both
* of the input streams are ordered, and parallel if either of the input
* streams is parallel. When the resulting stream is closed, the close
* handlers for both input streams are invoked.
*
* @implNote
* Use caution when constructing streams from repeated concatenation.
* Accessing an element of a deeply concatenated stream can result in deep
* call chains, or even {@code StackOverflowException}.
*
* @param a the first stream
* @param b the second stream
* @return the concatenation of the two input streams
*/
public static LongStream concat(LongStream a, LongStream b) {
Objects.requireNonNull(a);
Objects.requireNonNull(b);
Spliterator.OfLong split = new Streams.ConcatSpliterator.OfLong(
a.spliterator(), b.spliterator());
LongStream stream = StreamSupport.longStream(split, a.isParallel() || b.isParallel());
return stream.onClose(Streams.composedClose(a, b));
}
/**
* A mutable builder for a {@code LongStream}.
*
* <p>A stream builder has a lifecycle, which starts in a building
* phase, during which elements can be added, and then transitions to a built
* phase, after which elements may not be added. The built phase begins
* begins when the {@link #build()} method is called, which creates an
* ordered stream whose elements are the elements that were added to the
* stream builder, in the order they were added.
*
* @see LongStream#builder()
* @since 1.8
*/
public interface Builder extends LongConsumer {
/**
* Adds an element to the stream being built.
*
* @throws IllegalStateException if the builder has already transitioned
* to the built state
*/
@Override
void accept(long t);
/**
* Adds an element to the stream being built.
*
* @implSpec
* The default implementation behaves as if:
* <pre>{@code
* accept(t)
* return this;
* }</pre>
*
* @param t the element to add
* @return {@code this} builder
* @throws IllegalStateException if the builder has already transitioned
* to the built state
*/
default Builder add(long t) {
accept(t);
return this;
}
/**
* Builds the stream, transitioning this builder to the built state.
* An {@code IllegalStateException} is thrown if there are further
* attempts to operate on the builder after it has entered the built
* state.
*
* @return the built stream
* @throws IllegalStateException if the builder has already transitioned
* to the built state
*/
LongStream build();
}
}
| Main.java:25: error: package exists in another module: java.base
package java.util.stream;
^
Main.java:78: error: interface LongStream is public, should be declared in a file named LongStream.java
public interface LongStream extends BaseStream<Long, LongStream> {
^
Main.java:78: error: cannot find symbol
public interface LongStream extends BaseStream<Long, LongStream> {
^
symbol: class BaseStream
Main.java:122: error: cannot find symbol
<U> Stream<U> mapToObj(LongFunction<? extends U> mapper);
^
symbol: class Stream
location: interface LongStream
Main.java:136: error: cannot find symbol
IntStream mapToInt(LongToIntFunction mapper);
^
symbol: class IntStream
location: interface LongStream
Main.java:150: error: cannot find symbol
DoubleStream mapToDouble(LongToDoubleFunction mapper);
^
symbol: class DoubleStream
location: interface LongStream
Main.java:652: error: cannot find symbol
DoubleStream asDoubleStream();
^
symbol: class DoubleStream
location: interface LongStream
Main.java:664: error: cannot find symbol
Stream<Long> boxed();
^
symbol: class Stream
location: interface LongStream
Main.java:666: error: method does not override or implement a method from a supertype
@Override
^
Main.java:669: error: method does not override or implement a method from a supertype
@Override
^
Main.java:672: error: method does not override or implement a method from a supertype
@Override
^
Main.java:675: error: method does not override or implement a method from a supertype
@Override
^
Main.java:686: error: package Streams does not exist
return new Streams.LongStreamBuilderImpl();
^
Main.java:695: error: cannot find symbol
return StreamSupport.longStream(Spliterators.emptyLongSpliterator(), false);
^
symbol: variable StreamSupport
location: interface LongStream
Main.java:705: error: package Streams does not exist
return StreamSupport.longStream(new Streams.LongStreamBuilderImpl(t), false);
^
Main.java:705: error: cannot find symbol
return StreamSupport.longStream(new Streams.LongStreamBuilderImpl(t), false);
^
symbol: variable StreamSupport
location: interface LongStream
Main.java:751: error: cannot find symbol
return StreamSupport.longStream(Spliterators.spliteratorUnknownSize(
^
symbol: variable StreamSupport
location: interface LongStream
Main.java:767: error: package StreamSpliterators.InfiniteSupplyingSpliterator does not exist
new StreamSpliterators.InfiniteSupplyingSpliterator.OfLong(Long.MAX_VALUE, s), false);
^
Main.java:766: error: cannot find symbol
return StreamSupport.longStream(
^
symbol: variable StreamSupport
location: interface LongStream
Main.java:799: error: package Streams does not exist
new Streams.RangeLongSpliterator(startInclusive, endExclusive, false), false);
^
Main.java:798: error: cannot find symbol
return StreamSupport.longStream(
^
symbol: variable StreamSupport
location: interface LongStream
Main.java:833: error: package Streams does not exist
new Streams.RangeLongSpliterator(startInclusive, endInclusive, true), false);
^
Main.java:832: error: cannot find symbol
return StreamSupport.longStream(
^
symbol: variable StreamSupport
location: interface LongStream
Main.java:858: error: package Streams.ConcatSpliterator does not exist
Spliterator.OfLong split = new Streams.ConcatSpliterator.OfLong(
^
Main.java:860: error: cannot find symbol
LongStream stream = StreamSupport.longStream(split, a.isParallel() || b.isParallel());
^
symbol: variable StreamSupport
location: interface LongStream
Main.java:861: error: cannot find symbol
return stream.onClose(Streams.composedClose(a, b));
^
symbol: variable Streams
location: interface LongStream
26 errors
|
s906894853 | p03808 | C++ | #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
bool canberemoved(vector<int>& A, int N) {
int sum = 0;
sum = A[0] - A[N];
for (int i =0; i < N-1) {
sum += A[i+1] - A[i];
}
return sum == 0;
}
int main() {
int N;
int x;
vector<int> A;
cin >> N;
for (int i=0; i< N; i++) {
cin >> x;
A.push_back(x);
}
if (canberemoved(A, N)) {
cout << "YES" <<endl;
}
else {
cout << "NO" << endl;
}
}
| a.cc: In function 'bool canberemoved(std::vector<int>&, int)':
a.cc:11:25: error: expected ';' before ')' token
11 | for (int i =0; i < N-1) {
| ^
| ;
|
s479585610 | p03808 | C++ | #include <iostream>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#define int long long
#define MAX(a,b) ((a) > (b)) ? (a) : (b)
#define MIN(a,b) ((a) < (b)) ? (a) : (b)
using namespace std;
signed main()
{
int n;
cin >> n;
int a[100000];
int min = INT_MAX;
int min_ind = -1;
for (int i = 0; i < n; i++)
{
cin >> a[i];
if (a[i] < min)
{
min = a[i];
min_ind = i;
}
}
while(true)
{
int next_min = INT_MAX;
int next_min_ind = -1;
for (int i = 0; i < n; i++)
{
int ind = (i + min_ind) % n;
a[ind] -= (i + 1);
if (a[ind] < next_min)
{
next_min = a[ind];
next_min_ind = ind;
}
}
min = next_min;
min_ind = next_min_ind;
if (min < 0)
{
cout << "NO";
return 0;
}
if (min == 0)
{
for (int i = 0; i < n; i++)
{
if (a[i] > 0)
{
cout << "NO";
return 0;
}
}
cout << "YES";
return 0;
}
}
}
| a.cc: In function 'int main()':
a.cc:16:19: error: 'INT_MAX' was not declared in this scope
16 | int min = INT_MAX;
| ^~~~~~~
a.cc:6:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
5 | #include <algorithm>
+++ |+#include <climits>
6 | #define int long long
|
s732285739 | p03808 | Java | import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
long sub=0l;
int t1,t2;
t1=sc.nextInt();
for(int i=0;i<n-1;i++){
t2=sc.nextInt();
sub+=(long)(t2-t1);
t1=t2;
}
if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
}
} | Main.java:14: error: ')' expected
if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
^
Main.java:14: error: not a statement
if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
^
Main.java:14: error: ';' expected
if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
^
Main.java:14: error: 'else' without 'if'
if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
^
4 errors
|
s213286321 | p03808 | C++ | #include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+100;
int a[maxn],mx=maxn-1,s,n;
int main()
{
cin>>n;
for(int i=0;i<n;i++)
cin>>a[i];
for(int i=0;i<n;i++)
s+=a[i];
if(s % ((n*(n+1))/2) )
{
cout<<"NO";
return 0;
} | a.cc: In function 'int main()':
a.cc:18:6: error: expected '}' at end of input
18 | }
| ^
a.cc:8:1: note: to match this '{'
8 | {
| ^
|
s121661462 | p03808 | Java | import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
long sub=0l;
int t1,t2;
t1=sc.nextInt();
for(int i=0;i<n-1;i++){
t2=sc.nextInt();
sub+=(long)(t2-t1);
t1=t2;
}
if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
}
} | Main.java:14: error: ')' expected
if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
^
Main.java:14: error: not a statement
if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
^
Main.java:14: error: ';' expected
if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
^
Main.java:14: error: 'else' without 'if'
if(sub%(long)(2n-2)==0l){System.out.println("YES");}else{System.out.println("NO");}
^
4 errors
|
s715118037 | p03808 | Java | import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
long sub=0l;
int t1,t2;
t1=sc.nextInt();
for(int i=0;i<n-1;i++){
t2=sc.nextInt();
sub+=(long)(t2-t1);
t1=t2;
}
;
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))){
System.out.println("YES");
}else{
System.out.println("NO");
}
}
} | Main.java:15: error: ')' expected
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))){
^
Main.java:15: error: not a statement
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))){
^
Main.java:15: error: ';' expected
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))){
^
Main.java:15: error: not a statement
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))){
^
Main.java:15: error: ';' expected
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))){
^
Main.java:15: error: ')' expected
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))){
^
Main.java:15: error: not a statement
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))){
^
Main.java:15: error: not a statement
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))){
^
Main.java:15: error: ';' expected
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))){
^
Main.java:17: error: 'else' without 'if'
}else{
^
10 errors
|
s854608407 | p03808 | Java | import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
long sub=0l;
int t1,t2;
t1=sc.nextInt();
for(int i=0;i<n-1;i++){
t2=sc.nextInt();
sub+=(long)(t2-t1);
t1=t2;
}
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))){
System.out.println("YES");
}else{
System.out.println("NO");
}
}
} | Main.java:15: error: ')' expected
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))){
^
Main.java:15: error: not a statement
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))){
^
Main.java:15: error: ';' expected
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))){
^
Main.java:15: error: not a statement
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))){
^
Main.java:15: error: ';' expected
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))){
^
Main.java:15: error: ')' expected
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))){
^
Main.java:15: error: not a statement
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))){
^
Main.java:15: error: not a statement
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))){
^
Main.java:15: error: ';' expected
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))){
^
Main.java:17: error: 'else' without 'if'
}else{
^
10 errors
|
s764310930 | p03808 | C++ | #include <iostream>
#include <vector>
#include <numeric>
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int n;
std::cin >> n;
std::vector<int> as(n), diffs(n);
for (auto& i : as) std::cin >> i;
std::adjacent_difference(std::begin(as), std::end(as), std::begin(diffs));
bool ok = true;
if (n == 1) {
std::cout << (as.front() == 1 ? "YES" : "NO") << std::endl;
return 0;
}
std::for_each(std::begin(diffs) + 1, std::end(diffs),
[&, first = diffs[1]] (auto d) {
if ((d - first) % n) ok = false;
});
std::cout << (ok ? "YES" : "NO") << std::endl;
}
| a.cc: In function 'int main()':
a.cc:18:8: error: 'for_each' is not a member of 'std'
18 | std::for_each(std::begin(diffs) + 1, std::end(diffs),
| ^~~~~~~~
|
s709466270 | p03808 | Java | import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
long sub=0l;
int t1,t2;
t1=sc.nextInt();
for(int i=0;i<n-1;i++){
t2=sc.nextInt();
sub+=(long)(t2-t1);
t1=t2;
}
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))){System.out.println("YES");}else{System.out.println("NO");}
}
} | Main.java:14: error: ')' expected
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))){System.out.println("YES");}else{System.out.println("NO");}
^
Main.java:14: error: not a statement
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))){System.out.println("YES");}else{System.out.println("NO");}
^
Main.java:14: error: ';' expected
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))){System.out.println("YES");}else{System.out.println("NO");}
^
Main.java:14: error: not a statement
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))){System.out.println("YES");}else{System.out.println("NO");}
^
Main.java:14: error: ';' expected
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))){System.out.println("YES");}else{System.out.println("NO");}
^
Main.java:14: error: ')' expected
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))){System.out.println("YES");}else{System.out.println("NO");}
^
Main.java:14: error: not a statement
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))){System.out.println("YES");}else{System.out.println("NO");}
^
Main.java:14: error: not a statement
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))){System.out.println("YES");}else{System.out.println("NO");}
^
Main.java:14: error: ';' expected
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))){System.out.println("YES");}else{System.out.println("NO");}
^
Main.java:14: error: 'else' without 'if'
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))){System.out.println("YES");}else{System.out.println("NO");}
^
10 errors
|
s223985010 | p03808 | C++ | #include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fo(i, n) for(int i = 1; i <= n; ++i)
#define rep(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const int N = 200200;
const int mod = 1e9 + 7;
const ll INF = 1e18;
ll a[N],b[N],pref[N];
int main()
{
ios::sync_with_stdio(0); cin.tie(0);
int n;
cin>>n;
for(int i=1;i<=n;++i)
{
cin>>a[i];
b[i]=i-a[i];
pref[i]=pref[i-1]+a[i];
}
ll k=(n*1ll*(n+1)/2);
if(pref[n]%k!=0)
return cout<<"NO",0;
ll x=pref[n]/k;
a[n+1]=a[1];
a[n+2]=a[2];
ll cnt=0;
for(int i=2;i<=n+2;++i)
{
ll y=a[i]-a[i-1];
b[i]=y;
if(i>2&&b[i]!=b[i-1])
{
if(abs(b[i]-b[i-1])%n!=0||abs(b[i]-b[i-1])%x!=0)
{
return cout<<"NO",0;
}
}
}
cout<<"YES"
return 0;
} | a.cc: In function 'int main()':
a.cc:52:20: error: expected ';' before 'return'
52 | cout<<"YES"
| ^
| ;
53 | return 0;
| ~~~~~~
|
s538112680 | p03808 | C++ | #include <iostream>
#include <unordered_map>
#define REP(i, a, n) for(int i = a; i <= n; i++)
using namespace std;
int main(void) {
const int SIZE = 100001;
int N, A[SIZE];
cin >> N;
REP(i, 1, N) cin >> A[i];
int mod = N * (N + 1) / 2;
int sum = 0;
bool uniq = true;
unordered_map<int, bool> map;
REP(i, 1, N) {
sum += A[i]; sum %= mod;
if(map[A[i]]) {
uniq = false;
break;
} else {
map[A[i]] = true;
}
}
bool diff = true;
long mx= 0;
REP(i, 1, N - 1) {
mx = max(mx, abs(A[i] - A[i + 1]));
if(abs(A[i] - A[i + 1]) > N) diff = false;
}
mx *= N;
REP(i, 1, N) {
if(A[i] > mx) diff = false;
}
cout << (uniq && sum == 0 && diff ? "YES" : "NO") << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:29:13: error: no matching function for call to 'max(long int&, int)'
29 | mx = max(mx, abs(A[i] - A[i + 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:29:13: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
29 | mx = max(mx, abs(A[i] - A[i + 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
|
s534369024 | p03808 | Java | import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
long sub=0;
int t1,t2;
t1=sc.nextInt();
for(int i=0;i<n-1;i++){
t2=sc.nextInt();
sub+=(long)(t2-t1);
t1=t2;
}
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))) System.out.println("YES"); else System.out.println("NO");
}
} | Main.java:14: error: ')' expected
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))) System.out.println("YES"); else System.out.println("NO");
^
Main.java:14: error: not a statement
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))) System.out.println("YES"); else System.out.println("NO");
^
Main.java:14: error: ';' expected
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))) System.out.println("YES"); else System.out.println("NO");
^
Main.java:14: error: not a statement
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))) System.out.println("YES"); else System.out.println("NO");
^
Main.java:14: error: ';' expected
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))) System.out.println("YES"); else System.out.println("NO");
^
Main.java:14: error: ')' expected
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))) System.out.println("YES"); else System.out.println("NO");
^
Main.java:14: error: not a statement
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))) System.out.println("YES"); else System.out.println("NO");
^
Main.java:14: error: not a statement
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))) System.out.println("YES"); else System.out.println("NO");
^
Main.java:14: error: ';' expected
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))) System.out.println("YES"); else System.out.println("NO");
^
Main.java:14: error: 'else' without 'if'
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))) System.out.println("YES"); else System.out.println("NO");
^
10 errors
|
s452130031 | p03808 | Java | import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
long sub=0;
int t1,t2;
t1=sc.nextInt();
for(int i=0;i<n-1;i++){
t2=sc.nextInt();
sub+=(long)(t2-t1);
t1=t2;
}
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))) System.out.println("YES"); else System.out.println("NO");
}
} | Main.java:14: error: ')' expected
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))) System.out.println("YES"); else System.out.println("NO");
^
Main.java:14: error: not a statement
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))) System.out.println("YES"); else System.out.println("NO");
^
Main.java:14: error: ';' expected
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))) System.out.println("YES"); else System.out.println("NO");
^
Main.java:14: error: not a statement
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))) System.out.println("YES"); else System.out.println("NO");
^
Main.java:14: error: ';' expected
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))) System.out.println("YES"); else System.out.println("NO");
^
Main.java:14: error: ')' expected
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))) System.out.println("YES"); else System.out.println("NO");
^
Main.java:14: error: not a statement
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))) System.out.println("YES"); else System.out.println("NO");
^
Main.java:14: error: not a statement
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))) System.out.println("YES"); else System.out.println("NO");
^
Main.java:14: error: ';' expected
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))) System.out.println("YES"); else System.out.println("NO");
^
Main.java:14: error: 'else' without 'if'
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2))) System.out.println("YES"); else System.out.println("NO");
^
10 errors
|
s698482169 | p03808 | Java | import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
long sub=0;
int t1,t2;
t1=sc.nextInt();
for(int i=0;i<n-1;i++){
t2=sc.nextInt();
sub+=(long)(t2-t1);
t1=t2;
}
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2)))System.out.println("YES"); else System.out.println("NO");
}
} | Main.java:14: error: ')' expected
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2)))System.out.println("YES"); else System.out.println("NO");
^
Main.java:14: error: not a statement
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2)))System.out.println("YES"); else System.out.println("NO");
^
Main.java:14: error: ';' expected
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2)))System.out.println("YES"); else System.out.println("NO");
^
Main.java:14: error: not a statement
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2)))System.out.println("YES"); else System.out.println("NO");
^
Main.java:14: error: ';' expected
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2)))System.out.println("YES"); else System.out.println("NO");
^
Main.java:14: error: ')' expected
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2)))System.out.println("YES"); else System.out.println("NO");
^
Main.java:14: error: not a statement
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2)))System.out.println("YES"); else System.out.println("NO");
^
Main.java:14: error: not a statement
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2)))System.out.println("YES"); else System.out.println("NO");
^
Main.java:14: error: ';' expected
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2)))System.out.println("YES"); else System.out.println("NO");
^
Main.java:14: error: 'else' without 'if'
if(sub/(long)(2n-2)==(long)(sub/(long)(2n-2)))System.out.println("YES"); else System.out.println("NO");
^
10 errors
|
s958143638 | p03808 | C++ | #include <sstream>
#include <cstring>
#include <cstdio>
int main(void) {
uint64_t n;
std::cin >> n;
uint64_t* a = new uint64_t[n];
uint64_t sum;
for (int i = 0; i < n; i++) {
std::cin >> a[i];
sum += a[i];
}
if (sum % (n * (n-1)) == 0) {
std::cout << "YES" << std::endl;
}
else {
std::cout << "NO" << std::endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:5:9: error: 'uint64_t' was not declared in this scope
5 | uint64_t n;
| ^~~~~~~~
a.cc:4:1: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
3 | #include <cstdio>
+++ |+#include <cstdint>
4 | int main(void) {
a.cc:6:14: error: 'cin' is not a member of 'std'
6 | std::cin >> n;
| ^~~
a.cc:4:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
3 | #include <cstdio>
+++ |+#include <iostream>
4 | int main(void) {
a.cc:6:21: error: 'n' was not declared in this scope
6 | std::cin >> n;
| ^
a.cc:7:19: error: 'a' was not declared in this scope
7 | uint64_t* a = new uint64_t[n];
| ^
a.cc:7:27: error: 'uint64_t' does not name a type
7 | uint64_t* a = new uint64_t[n];
| ^~~~~~~~
a.cc:7:27: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:8:17: error: expected ';' before 'sum'
8 | uint64_t sum;
| ^~~~
| ;
a.cc:10:22: error: 'cin' is not a member of 'std'
10 | std::cin >> a[i];
| ^~~
a.cc:10:22: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:11:17: error: 'sum' was not declared in this scope
11 | sum += a[i];
| ^~~
a.cc:13:13: error: 'sum' was not declared in this scope
13 | if (sum % (n * (n-1)) == 0) {
| ^~~
a.cc:14:22: error: 'cout' is not a member of 'std'
14 | std::cout << "YES" << std::endl;
| ^~~~
a.cc:14:22: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:17:22: error: 'cout' is not a member of 'std'
17 | std::cout << "NO" << std::endl;
| ^~~~
a.cc:17:22: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
|
s905291127 | p03808 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
#ifndef M_PI
#define M_PI acos(-1.0)
#endif
int main(){
int n;
cin>>n;
vector<int> a(n);
ll sum=0;
for(int i=0; i<n; ++i){
scanf("%d", &a[i]);
sum += a[i];
}
if(sum % ((n+1)*n/2)){
cout<<"NO\n";
return 0;
}
ll cnt = sum/((n+1)*n/2);
ll cn2 = 0;
for(int i=0; i<n; ++i){
ll diff = a[(i+1)%n] - a[i];
if((diff-cnt) % n){
cout<<"NO\n";
return 0;
}
cnt2 -= (diff-cnt)/n
}
if(cnt != cnt2){
cout<<"NO\n";
return 0;
}
cout<<"YES\n";
return 0;
}
| a.cc: In function 'int main()':
a.cc:30:17: error: 'cnt2' was not declared in this scope; did you mean 'cn2'?
30 | cnt2 -= (diff-cnt)/n
| ^~~~
| cn2
a.cc:32:19: error: 'cnt2' was not declared in this scope; did you mean 'cn2'?
32 | if(cnt != cnt2){
| ^~~~
| cn2
|
s171841283 | p03808 | C++ | //I_F_A
#include "bits/stdc++.h"
using namespace std;
bool func(long long *arr,long long n){
long long ans = 0;
for(long long i=1;i<=n;i++)
if(arr[i] == i)
ans++;
if(ans == 0)
return 1;
for(long long i=1;i<=n;i++)
if(arr[i] != 0)
return 0;
return 1;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long arr[n+1];
for(long long i=1;i<=n;i++)
cin >> arr[i];
long long sum = 0;
for(long long i=1;i<n;i++){
if(arr[i] > arr[i-1]){
sum = sum + n - i + 1;
}
}
for(long long i=1;i<=n;i++){
sum = sum%n;
if(sum == 0)
sum = n;
arr[i] = arr[i] - sum;
sum = sum + 1;
}
if(func(arr,n)){
cout <<"YES\n";
}
else{
cout << "NO\n";
}
} | a.cc: In function 'int main()':
a.cc:25:23: error: 'n' was not declared in this scope; did you mean 'yn'?
25 | long long arr[n+1];
| ^
| yn
a.cc:27:24: error: 'arr' was not declared in this scope
27 | cin >> arr[i];
| ^~~
a.cc:33:20: error: 'arr' was not declared in this scope
33 | if(arr[i] > arr[i-1]){
| ^~~
a.cc:44:17: error: 'arr' was not declared in this scope
44 | arr[i] = arr[i] - sum;
| ^~~
a.cc:49:17: error: 'arr' was not declared in this scope
49 | if(func(arr,n)){
| ^~~
|
s295362592 | p03808 | Java |
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
sc.nextLine();
int[] a = new int[n];
boolean b = false;
for (int i=0;i<n;i++){
a[i] = sc.nextInt();
if (a[i]>=n){
b = true;
}
}
if (b==true){
System.out.println("YES");
}
else{
System.out.println("NO");
}
}
} | Main.java:5: error: cannot find symbol
Scanner sc = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
Main.java:5: error: cannot find symbol
Scanner sc = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
2 errors
|
s191784734 | p03809 | C++ | #include<bits/stdc++.h>
#define MN 100005
struct edge{
int to,nxt;
}e[MN<<1];
int n,a[MN],rt,l[MN],r[MN],du[MN],h[MN];
void ins(int x,int y) {
static int cnt=0;
du[x]++;
e[++cnt].nxt=h[x];e[cnt].to=y;h[x]=cnt;
}
void dfs(int x,int f) {
if(x!=rt&&du[x]==1) {
l[x]=r[x]=a[x];
return ;
}
int MI=0;
for(int i=h[x];i;i=e[i].nxt)
if(e[i].to!=f) {
dfs(e[i].to,x);
if(l[e[i].to]>=l[MI]) MI=e[i].to;
r[x]+=r[e[i].to];
}
if(r[x]<a[x]||l[MI]>a[x]) {
puts("NO");
exit(0);
}
if(l[MI]>r[x]-r[MI]) l[x]=a[x]-l[MI];
else l[x]=0;
r[x]=a[x];
if(x==rt&&l[x]) {
puts("NO");
exit(0);
}
}
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
for(int i=1;i<n;i++) {
int x,y;
scanf("%d%d",&x,&y);
ins(x,y);ins(y,x);
}
for(int i=1;i<=n;i++) if(du[i]==1){rt=i;break;}
dfs(rt,0\);
puts("YES");
} | a.cc:46:17: error: stray '\' in program
46 | dfs(rt,0\);
| ^
|
s519965069 | p03809 | C++ | #include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
using ll = long long;
using ii = pair<int, int>;
ll A[100001];
vector<int> G[100001];
inline ll dfs(int u, int p) {
if (G[u].size() == 1) return A[u];
ll ret = 2*A[u], m = 0;
for (int v : G[u]) if (v != p) {
int x = dfs(v, u);
ret -= x;
m = max(x, m);
}
if (ret < 0 || ret > A[u] || m > A[u]) {
cout << "NO";
exit(0);
}
return ret;
}
int main() {
if (fopen("in", "r")) freopen("in", "r", stdin), freopen("out", "w", stdout);
ios_base::sync_with_stdio(0), cin.tie(0);
int N; cin >> N;
for (int u = 1; u <= N; ++u) cin >> A[u];
for (int i = 1; i < N; ++i) {
int a, b; cin >> a >> b;
G[a].push_back(b), G[b].push_back(a);
}
if (N == 2) {
cout << (A[1] == A[2] ? "YES" : "NO");
return 0;
}
int s = 1;
while (G[s].size() == 1) ++s;
cout << (dfs(s, 0) ? "NO" : "YES");
return 0;
} | a.cc: In function 'll dfs(int, int)':
a.cc:17:16: error: no matching function for call to 'max(int&, ll&)'
17 | m = max(x, m);
| ~~~^~~~~~
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:17:16: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
17 | m = max(x, m);
| ~~~^~~~~~
/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:17:16: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
17 | m = max(x, m);
| ~~~^~~~~~
|
s669650420 | p03809 | C++ | #pragma 03
#pragma GCC optimization ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define ll long long
#define eb emplace_back
#define ef emplace_front
#define rep(i, x, n) for (int i = x; i < n; ++i)
#define mp make_pair
#define fi first
#define se second
#define ii pair<int, int>
#define endl '\n'
#define vi vector<int>
#define vii vector<pair<int, int>>
#define reverse(s) reverse(s.begin(), s.end())
#define ld long double
#define vs vector<string>
#define inf INT_MAX
#define vc vector<char>
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define vb vector<bool>
#define lb(a, x) lower_bound(a.begin(), a.end(), x)
#define ub(a, x) upper_bound(a.begin(), a.end(), x)
#define vvi vector<vi>
#define mine(a) min_element(a.begin(),a.end())
#define maxe(a) max_element(a.begin(), a.end())
#define iota(a,i) iota(a.begin(),a.end(),i)
#define fileopen(filename) if (fopen(filename".INP", "r")) {freopen(filename".INP", "r", stdin);freopen(filename".OUT", "w", stdout);}
int n;
vi a, par;
vvi adj, son;
void dfs(int x, int p) {
int sum = 0;
bool d = 0;
for (int i : adj[x]) {
if (i != p) {
d = 1;
son[x].emplace_back(i);
par[i] = x;
dfs(i, x);
sum += a[i];
}
}
if (d == 1) {
int u = sum - a[x], v = a[x] - u;
if (u < 0 || v < 0) {
cout << sum << " " << x << endl;
cout << "NO";
exit(0);
}
a[x] = v;
}
}
signed main() {
fastio;
cin >> n;
a.resize(n + 1);
adj.resize(n + 1);
son.resize(n + 1);
par.resize(n + 1, -1);
rep(i, 1, n + 1) cin >> a[i];
rep(i, 0, n - 1) {
int x, y;
cin >> x >> y;
adj[x].emplace_back(y);
adj[y].emplace_back(x);
}
dfs(1, 1);
cout << "YES";
} | In file included from /usr/include/c++/14/string:43,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
from a.cc:5:
/usr/include/c++/14/bits/allocator.h: In destructor 'std::_Vector_base<int, std::allocator<int> >::_Vector_impl::~_Vector_impl()':
/usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = int]': target specific option mismatch
182 | ~allocator() _GLIBCXX_NOTHROW { }
| ^
In file included from /usr/include/c++/14/vector:66,
from /usr/include/c++/14/functional:64,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53:
/usr/include/c++/14/bits/stl_vector.h:132:14: note: called from here
132 | struct _Vector_impl
| ^~~~~~~~~~~~
|
s573073395 | p03809 | C++ | #include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;
int n, A[100005];
vector<int> vc[100005];
bool ck = 1;
int dfs(int u, int p){
int ans = 0;
for(int i = 0; i < vc[u].size(); i++){
int v = vc[u][i];
if(v == p) continue;
if(vc[v].size() == 1) ans += A[v];
else{
int tmp = 2 * A[v] - dfs(v, u);
ck &= (tmp >= 0);
ans += tmp;
}
}
//cout << u << " " << ans << "\n";
return ans;
//sum_d[d[u]] += A[u];
}
signed main(){
ios_base::sync_with_stdio(0);
cin >> n;
for(int i = 1; i <= n; i++) cin >> A[i];
for(int i = 1; i < n; i++){
int x, y;
cin >> x >> y;
vc[x].pb(y);
vc[y].pb(x);
}
int root = 1;
if(vc[1].size() == 1) root = vc[1][0];
//cout << dfs(1, 1) << "\n";
if(A[root] * 2 == dfs(root, root))) cout << "YES";
else cout << "NO";
}
| a.cc: In function 'int main()':
a.cc:47:43: error: expected primary-expression before ')' token
47 | if(A[root] * 2 == dfs(root, root))) cout << "YES";
| ^
|
s312308513 | p03809 | C++ | #include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vii vector<pair<int, int> >
#define fi first
#define se second
#define int long long
int a[100005];
bool ch=1;
vi G[100005];
void dfs(int u, int p)
{
if(G[u].size()==1) return;
int sum=-a[u];
for(auto v: G[u])
{
if(v==p) continue;
dfs(v, u);
sum+=a[v];
if(a[v]>a[u]) ch=0;
}
// cout<<p<<" "<<u<<" "<<sum<<endl;
if(a[u]-sum<0) ch=0;
a[u]-=sum;
}
signed main()
{
int n;
cin>>n;
for(int i=1; i<=n; i++) cin>>a[i];
if(n==1)
{
if(a[1]) return cout<<"NO", 0;
return cout<<"YES", 0;
}
if(n==2)
{
if(a[1]-a[2]) return cout<"NO", 0;
return cout<<"YES", 0;
}
for(int i=1, u, v; i<=n-1; i++)
{
cin>>u>>v;
G[u].emplace_back(v);
G[v].emplace_back(u);
}
int root;
for(int i=1; i<=n; i++)
{
if(G[i].size()>=2) root = i;
}
cout<<root<<endl;
dfs(root, 0);
if(a[root] or !ch) cout<<"NO\n";
else cout<<"YES\n";
}
| a.cc: In function 'int main()':
a.cc:38:42: error: no match for 'operator<' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'const char [3]')
38 | if(a[1]-a[2]) return cout<"NO", 0;
| ~~~~^~~~~
| | |
| | const char [3]
| std::ostream {aka std::basic_ostream<char>}
In file included from /usr/include/c++/14/regex:68,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181,
from a.cc:1:
/usr/include/c++/14/bits/regex.h:1143:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const sub_match<_BiIter>&)'
1143 | operator<(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1143:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
38 | if(a[1]-a[2]) return cout<"NO", 0;
| ^~~~
/usr/include/c++/14/bits/regex.h:1224:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)'
1224 | operator<(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1224:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>'
38 | if(a[1]-a[2]) return cout<"NO", 0;
| ^~~~
/usr/include/c++/14/bits/regex.h:1317:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)'
1317 | operator<(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1317:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
38 | if(a[1]-a[2]) return cout<"NO", 0;
| ^~~~
/usr/include/c++/14/bits/regex.h:1391:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)'
1391 | operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1391:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'const char [3]'
38 | if(a[1]-a[2]) return cout<"NO", 0;
| ^~~~
/usr/include/c++/14/bits/regex.h:1485:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)'
1485 | operator<(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1485:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
38 | if(a[1]-a[2]) return cout<"NO", 0;
| ^~~~
/usr/include/c++/14/bits/regex.h:1560:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)'
1560 | operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1560:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'const char [3]'
38 | if(a[1]-a[2]) return cout<"NO", 0;
| ^~~~
/usr/include/c++/14/bits/regex.h:1660:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)'
1660 | operator<(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1660:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
38 | if(a[1]-a[2]) return cout<"NO", 0;
| ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::pair<_T1, _T2>'
38 | if(a[1]-a[2]) return cout<"NO", 0;
| ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
448 | operator<(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
38 | if(a[1]-a[2]) return cout<"NO", 0;
| ^~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
493 | operator<(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
38 | if(a[1]-a[2]) return cout<"NO", 0;
| ^~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1694 | operator<(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
38 | if(a[1]-a[2]) return cout<"NO", 0;
| ^~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1760 | operator<(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
38 | if(a[1]-a[2]) return cout<"NO", 0;
| ^~~~
In file included from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
673 | operator< (basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:673:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
38 | if(a[1]-a[2]) return cout<"NO", 0;
| ^~~~
/usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)'
680 | operator< (basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:680:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
38 | if(a[1]-a[2]) return cout<"NO", 0;
| ^~~~
/usr/include/c++/14/string_view:688:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)'
688 | operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
| |
s007229386 | p03809 | C++ | #include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vii vector<pair<int, int> >
#define fi first
#define se second
#define int long long
int a[100005];
bool ch=1;
vi G[100005];
void dfs(int u, int p)
{
if(G[u].size()==1) return;
int sum=-a[u];
for(auto v: G[u])
{
if(v==p) continue;
dfs(v, u);
sum+=a[v];
if(a[v]>a[u]) ch=0;
}
// cout<<p<<" "<<u<<" "<<sum<<endl;
if(a[u]-sum<0) ch=0;
a[u]-=sum;
}
signed main()
{
int n;
cin>>n;
for(int i=1; i<=n; i++) cin>>a[i];
if(n==1)
{
if(a[1]) return cout<<"NO", 0;
return cout<<"YES", 0;
}
if(n==2)
{
if(a[1]-a[2]) return cout<"NO", 0;
return cout<<"YES", 0;
}
for(int i=1, u, v; i<=n-1; i++)
{
cin>>u>>v;
G[u].emplace_back(v);
G[v].emplace_back(u);
}
int root;
for(int i=1; i<=n; i++)
{
if(G[i].size()>=2) root = i;
}
cout<<root<<endl;
dfs(root, 0);
if(a[root] or !ch) cout<<"NO\n";
else cout<<"YES\n";
}
| a.cc: In function 'int main()':
a.cc:38:42: error: no match for 'operator<' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'const char [3]')
38 | if(a[1]-a[2]) return cout<"NO", 0;
| ~~~~^~~~~
| | |
| | const char [3]
| std::ostream {aka std::basic_ostream<char>}
In file included from /usr/include/c++/14/regex:68,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181,
from a.cc:1:
/usr/include/c++/14/bits/regex.h:1143:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const sub_match<_BiIter>&)'
1143 | operator<(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1143:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
38 | if(a[1]-a[2]) return cout<"NO", 0;
| ^~~~
/usr/include/c++/14/bits/regex.h:1224:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)'
1224 | operator<(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1224:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>'
38 | if(a[1]-a[2]) return cout<"NO", 0;
| ^~~~
/usr/include/c++/14/bits/regex.h:1317:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)'
1317 | operator<(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1317:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
38 | if(a[1]-a[2]) return cout<"NO", 0;
| ^~~~
/usr/include/c++/14/bits/regex.h:1391:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)'
1391 | operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1391:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'const char [3]'
38 | if(a[1]-a[2]) return cout<"NO", 0;
| ^~~~
/usr/include/c++/14/bits/regex.h:1485:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)'
1485 | operator<(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1485:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
38 | if(a[1]-a[2]) return cout<"NO", 0;
| ^~~~
/usr/include/c++/14/bits/regex.h:1560:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)'
1560 | operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1560:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'const char [3]'
38 | if(a[1]-a[2]) return cout<"NO", 0;
| ^~~~
/usr/include/c++/14/bits/regex.h:1660:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)'
1660 | operator<(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1660:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
38 | if(a[1]-a[2]) return cout<"NO", 0;
| ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::pair<_T1, _T2>'
38 | if(a[1]-a[2]) return cout<"NO", 0;
| ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
448 | operator<(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
38 | if(a[1]-a[2]) return cout<"NO", 0;
| ^~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
493 | operator<(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
38 | if(a[1]-a[2]) return cout<"NO", 0;
| ^~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1694 | operator<(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
38 | if(a[1]-a[2]) return cout<"NO", 0;
| ^~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1760 | operator<(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
38 | if(a[1]-a[2]) return cout<"NO", 0;
| ^~~~
In file included from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
673 | operator< (basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:673:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
38 | if(a[1]-a[2]) return cout<"NO", 0;
| ^~~~
/usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)'
680 | operator< (basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:680:5: note: template argument deduction/substitution failed:
a.cc:38:43: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
38 | if(a[1]-a[2]) return cout<"NO", 0;
| ^~~~
/usr/include/c++/14/string_view:688:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)'
688 | operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
| |
s389849875 | p03809 | C++ | #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <cassert>
using namespace std;
std::vector<int64_t> numbers;
vector<vector<int>> graph;
std::vector<bool> used;
std::pair<bool, int64_t> Dfs(int v) {
used[v] = true;
std::vector<int64_t> elements;
int64_t mx = 0;
int64_t sum = 0;
for (const auto& el : graph[v]) {
if (used[el]) continue;
auto pr = Dfs(el);
if (!pr.first) {
return {false, 0};
}
elements.push_back(pr.second);
mx = max(mx, pr.second);
sum += pr.second;
}
if (elements.empty()) {
return {true, numbers[v]};
}
int64_t mn_can = min(mx, sum / 2);
if (mn_can > numbers[v]) {
return {false, 0};
}
if (sum < numbers[v]) {
return {false, 0};
}
auto sm = sum - numbers[v];
if (sm > mn_can) {
return {false, 0};
}
sum -= 2 * sm;
return {true, sum};
}
int main() {
std::ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
graph.resize(n);
used.resize(n);
used.assign(n, 0);
numbers.resize(n);
for (auto& el : numbers) {
cin >> el;
}
for (int i = 0; i < n - 1; i++) {
int x;
int y;
cin >> x >> y;
x--;
y--;
graph[x].push_back(y);
graph[y].push_back(x);
}
int v = 0;
for (int i = 0; i < n; i++) {
if (graph[i].size() > 1) {
v = i;
}
}
if (Dfs(v) == make_pair(true, 0ll)) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:74:16: error: no match for 'operator==' (operand types are 'std::pair<bool, long int>' and 'std::pair<bool, long long int>')
74 | if (Dfs(v) == make_pair(true, 0ll)) {
| ~~~~~~ ^~ ~~~~~~~~~~~~~~~~~~~~
| | |
| | pair<[...],long long int>
| pair<[...],long int>
In file included from /usr/include/c++/14/iosfwd:42,
from /usr/include/c++/14/ios:40,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/postypes.h:192:5: note: candidate: 'template<class _StateT> bool std::operator==(const fpos<_StateT>&, const fpos<_StateT>&)'
192 | operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/postypes.h:192:5: note: template argument deduction/substitution failed:
a.cc:74:38: note: 'std::pair<bool, long int>' is not derived from 'const std::fpos<_StateT>'
74 | if (Dfs(v) == make_pair(true, 0ll)) {
| ^
In file included from /usr/include/c++/14/string:43,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44:
/usr/include/c++/14/bits/allocator.h:235:5: note: candidate: 'template<class _T1, class _T2> bool std::operator==(const allocator<_CharT>&, const allocator<_T2>&)'
235 | operator==(const allocator<_T1>&, const allocator<_T2>&)
| ^~~~~~~~
/usr/include/c++/14/bits/allocator.h:235:5: note: template argument deduction/substitution failed:
a.cc:74:38: note: 'std::pair<bool, long int>' is not derived from 'const std::allocator<_CharT>'
74 | if (Dfs(v) == make_pair(true, 0ll)) {
| ^
In file included from /usr/include/c++/14/string:48:
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
441 | operator==(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: template argument deduction/substitution failed:
a.cc:74:38: note: 'std::pair<bool, long int>' is not derived from 'const std::reverse_iterator<_Iterator>'
74 | if (Dfs(v) == make_pair(true, 0ll)) {
| ^
/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:74:38: note: 'std::pair<bool, long int>' is not derived from 'const std::reverse_iterator<_Iterator>'
74 | if (Dfs(v) == make_pair(true, 0ll)) {
| ^
/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:74:38: note: 'std::pair<bool, long int>' is not derived from 'const std::move_iterator<_IteratorL>'
74 | if (Dfs(v) == make_pair(true, 0ll)) {
| ^
/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:74:38: note: 'std::pair<bool, long int>' is not derived from 'const std::move_iterator<_IteratorL>'
74 | if (Dfs(v) == make_pair(true, 0ll)) {
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/string:51:
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1033 | operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: template argument deduction/substitution failed:
a.cc:74:38: note: deduced conflicting types for parameter '_T2' ('long int' and 'long long int')
74 | if (Dfs(v) == make_pair(true, 0ll)) {
| ^
In file included from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54:
/usr/include/c++/14/string_view:629:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)'
629 | operator==(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:629:5: note: template argument deduction/substitution failed:
a.cc:74:38: note: 'std::pair<bool, long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
74 | if (Dfs(v) == make_pair(true, 0ll)) {
| ^
/usr/include/c++/14/string_view:637:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
637 | operator==(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:637:5: note: template argument deduction/substitution failed:
a.cc:74:38: note: 'std::pair<bool, long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
74 | if (Dfs(v) == make_pair(true, 0ll)) {
| ^
/usr/include/c++/14/string_view:644:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)'
644 | operator==(__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:644:5: note: template argument deduction/substitution failed:
a.cc:74:38: note: 'std::pair<bool, long long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
74 | if (Dfs(v) == make_pair(true, 0ll)) {
| ^
/usr/include/c++/14/bits/basic_string.h:3755:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3755 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3755:5: note: template argument deduction/substitution failed:
a.cc:74:38: note: 'std::pair<bool, long int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
74 | if (Dfs(v) == make_pair(true, 0ll)) {
| ^
/usr/include/c++/14/bits/basic_string.h:3772:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
3772 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3772:5: note: template argument deduction/substitution failed:
a.cc:74:38: note: 'std::pair<bool, long int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
74 | if (Dfs(v) == make_pair(true, 0ll)) {
| ^
/usr/include/c++/14/bits/basic_string.h:3819:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3819 | operator==(const _CharT* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3819:5: note: template argument deduction/substitution failed:
a.cc:74:38: note: mismatched types 'const _CharT*' and 'std::pair<bool, long int>'
74 | if (Dfs(v) == make_pair(true, 0ll)) {
| ^
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
from /usr/include/c++/14/string:68:
/usr/include/c++/14/tuple:2558:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator==(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)'
2558 | operator==(const tuple<_TElements...>& __t,
| ^~~~~~~~
/usr/include/c++/14/tuple:2558:5: note: template argument deduction/substitution failed:
a.cc:74:38: note: 'std::pair<bool, long int>' is not derived from 'const std::tuple<_UTypes ...>'
74 | if (Dfs(v) == make_pair(true, 0ll)) {
| ^
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
from /usr/include/c++/14/bits/basic_ios.h:37,
from /usr/include/c++/14/ios:46:
/usr/include/c++/14/bits/streambuf_iterator.h:234:5: note: candidate: 'template<class _CharT, class _Traits> bool std::operator==(const istreambuf_iterator<_CharT, _Traits>&, const istreambuf_iterator<_CharT, _Traits>&)'
234 | operator==(const istreambuf_iterator<_CharT, _Traits>& __a,
| ^~~~~~~~
/usr/include/c++/14/bits/streambuf_iterator.h:234:5: note: template argument deduction/substitution failed:
a.cc:74:38: note: 'std::pair< |
s965756659 | p03809 | C++ | #include <bits/stdc++.h>
using namespace std;
vector<int> parent(vector<vector<int>> &E, int r){
int N = E.size();
vector<int> p(N, -1);
queue<int> Q;
Q.push(r);
while (!Q.empty()){
int v = Q.front();
Q.pop();
for (int w : E[v]){
if (p[w] == -1){
p[w] = v;
Q.push(w);
}
}
}
return p;
}
vector<vector<int>> child_2(vector<int> &p, int r){
int N = p.size();
vector<vector<int>> c(N);
for (int i = 0; i < N; i++){
if (i != r){
c[p[i]].push_back(i);
}
}
return c;
}
void dfs(vector<long long> &A, vector<vector<int>> &c, int v, bool &ok){
if (c[v].empty()){
return;
}
long long sum = 0;
long long M = 0;
for (int w : c[v]){
dfs(A, c, w, ok);
sum += A[w];
M = max(M, A[w]);
}
long long tmp = A[v] * 2 - sum;
long long pair_cnt = max(sum - A[v], 0);
/*
cout << "v = " << v << endl;
cout << "sum = " << sum << endl;
cout << "pair = " << pair_cnt << endl;
cout << "max = " << M << endl;
*/
long long pair_cnt_2 = min(sum - M, sum / 2);
if (pair_cnt_2 < pair_cnt){
//cout << "not ok" << endl;
ok = false;
}
A[v] = tmp;
}
int main(){
int N;
cin >> N;
vector<long long> A(N + 1, 0);
for (int i = 1; i <= N; i++){
cin >> A[i];
}
if (N == 2){
if (A[1] == A[2]){
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
return 0;
}
vector<vector<int>> E(N + 1);
for (int i = 0; i < N - 1; i++){
int a, b;
cin >> a >> b;
E[a].push_back(b);
E[b].push_back(a);
}
int r = 0;
for (int i = 1; i <= N; i++){
if (E[i].size() != 1){
E[0].push_back(i);
E[i].push_back(0);
r = i;
break;
}
}
N++;
vector<int> p = parent(E, 0);
vector<vector<int>> c = child_2(p, 0);
bool ok = true;
dfs(A, c, 0, ok);
if (ok && A[r] == 0){
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
} | a.cc: In function 'void dfs(std::vector<long long int>&, std::vector<std::vector<int> >&, int, bool&)':
a.cc:42:27: error: no matching function for call to 'max(long long int, int)'
42 | long long pair_cnt = max(sum - A[v], 0);
| ~~~^~~~~~~~~~~~~~~
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:42:27: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
42 | long long pair_cnt = max(sum - A[v], 0);
| ~~~^~~~~~~~~~~~~~~
/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:42:27: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
42 | long long pair_cnt = max(sum - A[v], 0);
| ~~~^~~~~~~~~~~~~~~
|
s083257471 | p03809 | C++ | #include <iostream>
#include <vector>
#define int long long
#define MAXN 200000
int a[MAXN];
int n;
std::vector<int> Adj[MAXN];
int dfs(int u, int p = -1) {
int ret = a[u];
if(Adj[u].size() == 1 && p != -1)
return ret;
int sum = 0;
int max = 0;
for(int j : Adj[u]) {
if(j == p)
continue;
int next = dfs(j, u);
if(next == -1)
return -1;
sum += next;
max = std::max(max, next);
}
ret = 2*a[u] - sum;
if(ret < std::max(2*max - sum, 0))
return -1;
return ret;
}
signed main() {
std::cin >> n;
for(int i = 0; i < n; i++)
std::cin >> a[i];
int root = 0;
for(int i = 1; i < n; i++) {
int u, v;
std::cin >> u >> v;
u--; v--;
Adj[u].push_back(v);
Adj[v].push_back(u);
if(Adj[u].size() > 1)
root = u;
if(Adj[v].size() > 1)
root = v;
}
if(dfs(root) == 0 || (n = 2 && a[0] == a[1]))
std::cout << "YES";
else
std::cout << "NO";
std::cout << std::endl;
return 0;
}
| a.cc: In function 'long long int dfs(long long int, long long int)':
a.cc:34:20: error: no matching function for call to 'max(long long int, int)'
34 | if(ret < std::max(2*max - sum, 0))
| ~~~~~~~~^~~~~~~~~~~~~~~~
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:34:20: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
34 | if(ret < std::max(2*max - sum, 0))
| ~~~~~~~~^~~~~~~~~~~~~~~~
/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
|
s187636491 | p03809 | C++ | #include <bits/stdc++.h>
template <typename T> inline void rd(T& x) {
int si = 1; char c = getchar(); x = 0;
while(!isdigit(c)) si = c == '-' ? -1 : si, c = getchar();
while(isdigit(c)) x = x * 10 + c - 48, c = getchar();
x *= si;
}
template <typename T, typename... Args>
inline void rd(T& x, Args&... args) { rd(x); rd(args...); }
#define fi first
#define se second
typedef long long ll;
typedef double ff;
typedef std::pair<int, int> pii;
const int kN = 1e5 + 5;
int a[kN], dg[kN], fa[kN]; ll f[kN]; std::vector <int> E[kN];
void Dfs(int cur) {
if(dg[cur] == 1) return;
ll s = 0, mx = 0;
for(auto x : E[cur])
if(x != fa[cur]) {
fa[x] = cur; Dfs(x); s += f[x];
mx = std::max(mx, f[x]);
}
f[cur] = 2 * a[cur] - s;
if(f[cur] < 0 || f[cur] > a[cur] || mx > a[u]) {
printf("NO"); exit(0);
}
}
int main() {
int n; rd(n);
for(int i = 1; i <= n; ++i) rd(a[i]);
if(n == 2) { printf(a[1] == a[2] ? "YES" : "NO"); return 0; }
for(int i = 1; i < n; ++i) {
int u, v; rd(u, v);
E[v].push_back(u);
E[u].push_back(v);
++dg[u]; ++dg[v];
}
int rt;
for(int i = 1; i <= n; ++i) {
if(dg[i] != 1) rt = i;
else f[i] = a[i];
}
Dfs(rt);
printf(!f[rt] ? "YES" : "NO");
return 0;
} | a.cc: In function 'void Dfs(int)':
a.cc:32:52: error: 'u' was not declared in this scope
32 | if(f[cur] < 0 || f[cur] > a[cur] || mx > a[u]) {
| ^
|
s994152848 | p03809 | C++ | #include <bits/stdc++.h>
template <typename T> inline void rd(T& x) {
int si = 1; char c = getchar(); x = 0;
while(!isdigit(c)) si = c == '-' ? -1 : si, c = getchar();
while(isdigit(c)) x = x * 10 + c - 48, c = getchar();
x *= si;
}
template <typename T, typename... Args>
inline void rd(T& x, Args&... args) { rd(x); rd(args...); }
#define fi first
#define se second
typedef long long ll;
typedef double ff;
typedef std::pair<int, int> pii;
const int kN = 1e5 + 5;
int a[kN], dg[kN], fa[kN]; ll f[kN]; std::vector <int> E[kN];
void Dfs(int cur) {
if(dg[cur] == 1) return;
ll s = 0;
for(auto x : E[cur])
if(x != fa[cur]) {
fa[x] = cur; Dfs(x); s += f[x];
}
f[cur] = 2 * a[cur] - s;
if(f[cur] < 0 || f[cur] > a[cur] || f[u] > s) {
printf("NO"); exit(0);
}
}
int main() {
int n; rd(n);
for(int i = 1; i <= n; ++i) rd(a[i]);
if(n == 2) { printf(a[1] == a[2] ? "YES" : "NO"); return 0; }
for(int i = 1; i < n; ++i) {
int u, v; rd(u, v);
E[v].push_back(u);
E[u].push_back(v);
++dg[u]; ++dg[v];
}
int rt;
for(int i = 1; i <= n; ++i) {
if(dg[i] != 1) rt = i;
else f[i] = a[i];
}
Dfs(rt);
printf(!f[rt] ? "YES" : "NO");
return 0;
} | a.cc: In function 'void Dfs(int)':
a.cc:31:47: error: 'u' was not declared in this scope
31 | if(f[cur] < 0 || f[cur] > a[cur] || f[u] > s) {
| ^
|
s762012297 | p03809 | C++ | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; i<(n); i++)
int n, a[100005], v, u, t;
bool out;
vector<int> G[100005];
ll dfs(int u, int p){
if(G[u].size() == 1) return a[u];
ll mxv = 0, ac = 0, ret;
for(int nx: G[u]) if(nx != p){
ll tmp = dfs(nx,u);
ac += tmp;
mxv = max(mxv, tmp);
}
ret = a[u] * 2 - ac;
mxv = max(mxv, ret);
if(ret < 0 || a[u] < mxv) out = true;
return ret;
}
int main(){
scanf("%d", &n);
rep(i,n) scanf("%d", a+i);
rep(i,n-1){
scanf("%d%d", &v, &u);
v--; u--;
G[v].push_back(u);
G[u].push_back(v);
}
if(n == 2){
puts(a[0] == a[1] ? "YES" : "NO");
return;
}
for(; G[t].size() == 1; t++);
if(dfs(t,t) > 0 || out) puts("NO");
else puts("YES");
} | a.cc: In function 'int main()':
a.cc:32:17: error: return-statement with no value, in function returning 'int' [-fpermissive]
32 | return;
| ^~~~~~
|
s861136168 | p03809 | C++ | #include <bits/stdc++.h> // clang-format off
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#ifdef ONLINE_JUDGE
#define rep(i,N) for(int i = 0; i < (int)(N); i++)
#define repr(i,N) for(int i = (int)(N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (int)(N) ; i++)
#define repr1(i,N) for(int i = (N) ; (int)(i) > 0 ; i--)
#else
#define rep(i,N) for(long long i = 0; i < (long long)(N); i++)
#define repr(i,N) for(long long i = (long long)(N) - 1; i >= 0; i--)
#define rep1(i,N) for(long long i = 1; i <= (long long)(N) ; i++)
#define repr1(i,N) for(long long i = (N) ; (long long)(i) > 0 ; i--)
#endif
using namespace std; void solve();
using ll = long long; template<class T = ll> using V = vector<T>;
using vi = V<int>; using vl = V<>; using vvi = V< V<int> >;
constexpr int inf = 1001001001; constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); for(int i=0;i<s;i++) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
#include "NyaanDebug.h"
#define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
#define trca(v,N) do { cerr << #v << " = "; array_out(v , N);} while(0)
#define trcc(v) do { cerr << "name : " << #v << "\n"; int cnt = 0; each(x , v){cerr << (cnt++) << " : "; trc(x); } } while(0)
#else
#define trc(...)
#define trca(...)
#define trcc(...)
int main(){solve();}
#endif
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
#define in2(s,t) rep(i,sz(s)){in(s[i] , t[i]);}
#define in3(s,t,u) rep(i,sz(s)){in(s[i] , t[i] , u[i]);}
using vd = V<double>; using vs = V<string>; using vvl = V< V<> >;
template<typename T,typename U>ll ceil(T a,U b){return (a + b - 1) / b;}
using P = pair<ll,ll>; using vp = V<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
// clang-format on
///////////////////////////////////////////////////////////
template< typename T >
struct edge {
int src, to;
T cost;
edge(int to, T cost) : src(-1), to(to), cost(cost) {}
edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
edge &operator=(const int &x) {
to = x;
return *this;
}
operator int() const { return to; }
};
template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnweightedGraph = vector< vector <int> >;
// グラフの入力
UnweightedGraph graph(
int N , int M = -1 , bool is_directed = false, bool is_1origin = true){
UnweightedGraph g(N);
if(M == -1) M = N - 1;
for(int _ = 0 ; _ < M ; _++){
int x , y; cin >> x >> y;
if(is_1origin) x-- , y--;
g[x].pb(y);
if(!is_directed) g[y].pb(x);
}
return g;
}
// 重み付きグラフの入力
template<typename T>
WeightedGraph<T> wgraph(
int N , int M = -1 , bool is_directed = false , bool is_1origin = true){
WeightedGraph<T> g(N);
if(M == -1) M = N - 1;
for(int _ = 0 ; _ < M ; _++){
int x , y; cin >> x >> y;
T c; cin >> c;
if(is_1origin) x-- , y--;
g[x].eb(y , c);
if(!is_directed) g[y].eb(x , c);
}
return g;
}
void solve(){
ini(N);
vl A(N); in(A);
auto g = graph(N);
vl L(N);
auto dfs = [&](auto rec,int cur,int par = -1) -> void{
// 根からのアレを集計する
int chd = 0;
ll l = 0 , lm = 0;
each(dst , g[cur]){
if(dst == par) continue;
rec(rec , dst , cur);
l += L[dst]; amax(lm , L[dst]);
chd++;
}
if(par == -1){
if(l != A[cur]) die("NO");
L[cur] = A[cur];
return;
}
else if(chd == 0){
L[cur] = A[cur];
return;
}
else if(chd == 1){
if(l != A[cur]) die("NO");
L[cur] = A[cur];
return;
}
else{
if(l > 2 * A[cur] || l < A[cur]) die("NO");
//
ll self = l - A;
if(lm > self) die("NO");
L[cur] = 2 * A[cur] - l;
}
};
int start = 0;
while(g[start].size() != 1) start++;
dfs(dfs , start);
trc(L);
out("YES");
} | a.cc: In lambda function:
a.cc:149:19: error: no match for 'operator-' (operand types are 'll' {aka 'long long int'} and 'vl' {aka 'std::vector<long long int, std::allocator<long long int> >'})
149 | ll self = l - A;
| ~ ^ ~
| | |
| | vl {aka std::vector<long long int, std::allocator<long long int> >}
| ll {aka long long int}
In file included from /usr/include/c++/14/bits/stl_algobase.h:67,
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_iterator.h:618:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
618 | operator-(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:618:5: note: template argument deduction/substitution failed:
a.cc:149:21: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'll' {aka 'long long int'}
149 | ll self = l - A;
| ^
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1790 | operator-(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note: template argument deduction/substitution failed:
a.cc:149:21: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'll' {aka 'long long int'}
149 | ll self = l - A;
| ^
In file included from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/complex:370:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const complex<_Tp>&, const complex<_Tp>&)'
370 | operator-(const complex<_Tp>& __x, const complex<_Tp>& __y)
| ^~~~~~~~
/usr/include/c++/14/complex:370:5: note: template argument deduction/substitution failed:
a.cc:149:21: note: mismatched types 'const std::complex<_Tp>' and 'll' {aka 'long long int'}
149 | ll self = l - A;
| ^
/usr/include/c++/14/complex:379:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const complex<_Tp>&, const _Tp&)'
379 | operator-(const complex<_Tp>& __x, const _Tp& __y)
| ^~~~~~~~
/usr/include/c++/14/complex:379:5: note: template argument deduction/substitution failed:
a.cc:149:21: note: mismatched types 'const std::complex<_Tp>' and 'll' {aka 'long long int'}
149 | ll self = l - A;
| ^
/usr/include/c++/14/complex:388:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const _Tp&, const complex<_Tp>&)'
388 | operator-(const _Tp& __x, const complex<_Tp>& __y)
| ^~~~~~~~
/usr/include/c++/14/complex:388:5: note: template argument deduction/substitution failed:
a.cc:149:21: note: 'vl' {aka 'std::vector<long long int, std::allocator<long long int> >'} is not derived from 'const std::complex<_Tp>'
149 | ll self = l - A;
| ^
/usr/include/c++/14/complex:465:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const complex<_Tp>&)'
465 | operator-(const complex<_Tp>& __x)
| ^~~~~~~~
/usr/include/c++/14/complex:465:5: note: candidate expects 1 argument, 2 provided
In file included from /usr/include/c++/14/valarray:605,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166:
/usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const _Expr<_Dom1, typename _Dom1::value_type>&, const _Expr<_Dom2, typename _Dom2::value_type>&)'
406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed:
a.cc:149:21: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'll' {aka 'long long int'}
149 | ll self = l - A;
| ^
/usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const _Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)'
406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed:
a.cc:149:21: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'll' {aka 'long long int'}
149 | ll self = l - A;
| ^
/usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const typename _Dom::value_type&, const _Expr<_Dom1, typename _Dom1::value_type>&)'
406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed:
a.cc:149:21: note: 'vl' {aka 'std::vector<long long int, std::allocator<long long int> >'} is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
149 | ll self = l - A;
| ^
/usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const _Expr<_Dom1, typename _Dom1::value_type>&, const valarray<typename _Dom::value_type>&)'
406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed:
a.cc:149:21: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'll' {aka 'long long int'}
149 | ll self = l - A;
| ^
/usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const valarray<typename _Dom::value_type>&, const _Expr<_Dom1, typename _Dom1::value_type>&)'
406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed:
a.cc:149:21: note: 'vl' {aka 'std::vector<long long int, std::allocator<long long int> >'} is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
149 | ll self = l - A;
| ^
/usr/include/c++/14/valarray:1197:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__minus, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__minus, _Tp>::result_type> std::operator-(const valarray<_Tp>&, const valarray<_Tp>&)'
1197 | _DEFINE_BINARY_OPERATOR(-, __minus)
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/valarray:1197:1: note: template argument deduction/substitution failed:
a.cc:149:21: note: mismatched types 'const std::valarray<_Tp>' and 'll' {aka 'long long int'}
149 | ll self = l - A;
| ^
/usr/include/c++/14/valarray:1197:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__minus, std::_ValArray, std::_Constant, _Tp, _Tp>, typename std::__fun<std::__minus, _Tp>::result_type> std::operator-(const valarray<_Tp>&, const typename valarray<_Tp>::value_type&)'
1197 | _DEFINE_BINARY_OPERATOR(-, __minus)
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/valarray:1197:1: note: template argument deduction/substitution failed:
a.cc:149:21: note: mismatched types 'const std::valarray<_Tp>' and 'll' {aka 'long long int'}
149 | ll self = l - A;
| ^
/usr/include/c++/14/valarray:1197:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Constant, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__minus, _Tp>::result_type> std::operator-(const typename valarray<_Tp>::value_type&, const valarray<_Tp>&)'
1197 | _DEFINE_BINARY_OPERATOR(-, __minus)
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/valarray:1197:1: note: template argument deduction/substitution failed:
a.cc:149:21: note: 'vl' {aka 'std::vector<long long int, std::allocator<long long int> >'} is not derived from 'const std::valarray<_Tp>'
149 | ll self = l - A;
| ^
|
s932474991 | p03809 | C++ | #include <bits/stdc++.h>
using namespace std;
static vector<long long> adj[100005];
static long long arr[100005];
long long dfs(long long u, long long p){
if(adj[u].size() == 1) return arr[u];
long long rope = 0;
long long maxChildRope = 0;
for(long long v : adj[u]){
if(v == p) continue;
long long childRope = dfs(v,u);
rope += childRope;
maxChildRope = max(maxChildRope, childRope);
}
long long connect = rope - arr[u];
long long maxConnect = min(rope / 2, rope - childRope);
rope = rope - 2 * connect;
if(connect < 0 || rope < 0 || connect > maxConnect){
cout << "NO";
exit(0);
}
return rope;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
long long n; cin >> n;
for(long long i = 1;i <= n;i++) cin >> arr[i];
for(long long i = 1;i < n;i++){
long long a, b; cin >> a >> b;
adj[a].push_back(b);
adj[b].push_back(a);
}
for(long long i = 1;i <= n;i++){
if(adj[i].size() != 1){
if(dfs(i,0) == 0) cout << "YES";
else cout << "NO";
return 0;
}
}
if(arr[1] == arr[2]) cout << "YES";
else cout << "NO";
}
| a.cc: In function 'long long int dfs(long long int, long long int)':
a.cc:19:53: error: 'childRope' was not declared in this scope; did you mean 'maxChildRope'?
19 | long long maxConnect = min(rope / 2, rope - childRope);
| ^~~~~~~~~
| maxChildRope
|
s075302532 | p03809 | C++ | #include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define KK 500
#define MXN 200005
vector<int> v[100005];
LL val[100005];
LL Max[100005];
LL Min[100005];
int ok=1;
void dfs(int x,int f){
if(v[x].size()==1&&f!=0){
Max[x]=val[x];
Min[x]=val[x]&1;
return ;
}
vector<pll> tmp;
for(auto it:v[x]){
if(it!=f){
dfs(it,x);
tmp.pb(mp(Max[it],Min[it]));
}
}
// printf("%d",x);
sort(tmp.begin(),tmp.end());
for(auto it:tmp){
Max[x]+=it.x;
// printf(" %lld %lld",it.x,it.y);
}
// printf("\n");
if(tmp.back().y>Max[x]-tmp.back().x){
Min[x]=max(tmp.back().y-(Max[x]-tmp.back().x),2*val[x]-Max[x]);
}
else{
Min[x]=max(Max[x]&1,2*val[x]-Max[x]);
}
/* if(val[x]%2!=Max[x]%2){
ok=0;
}*/
LL tot=0;
for(auto it:tmp){
tot+=Min[it];
}
if((tot+1)/2>val[x]){
ok=0;
}
if(val[x]>Max[x]){
ok=0;
}
Max[x]=val[x];
if(tmp.size()==1){
Min[x]=val[x];
}
}
int main(){
int n;
scanf("%d",&n);
for(int i = 1;i<=n;i++)
scanf("%lld",&val[i]);
for(int i = 1;i<n;i++){
int x,y;
scanf("%d %d",&x,&y);
v[x].pb(y);
v[y].pb(x);
}
if(n==2){
if(val[1]%2==val[2]%2){
printf("YES\n");
}
else{
printf("NO\n");
}
}
else{
for(int i=1;i<=n;i++){
if(v[i].size()!=1){
dfs(i,0);
if(Min[i]!=0){
ok=0;
}
break;
}
}
int tot=0;
for(int i = 1;i<=n;i++){
if(v[i].size()==1){
tot+=val[i];
}
}
if(tot&1)ok=0;
if(ok){
printf("YES\n");
}
else{
printf("NO\n");
}
}
} | a.cc: In function 'void dfs(int, int)':
a.cc:59:17: error: no match for 'operator[]' (operand types are 'long long int [100005]' and 'std::pair<long long int, long long int>')
59 | tot+=Min[it];
| ^
|
s557877813 | p03809 | C++ | #include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define KK 500
#define MXN 200005
vector<int> v[100005];
LL val[100005];
LL Max[100005];
LL Min[100005];
int ok=1;
void dfs(int x,int f){
if(v[x].size()==1&&f!=0){
Max[x]=val[x];
Min[x]=val[x]&1;
return ;
}
vector<pll> tmp;
for(auto it:v[x]){
if(it!=f){
dfs(it,x);
tmp.pb(mp(Max[it],Min[it]));
}
}
// printf("%d",x);
sort(tmp.begin(),tmp.end());
for(auto it:tmp){
Max[x]+=it.x;
// printf(" %lld %lld",it.x,it.y);
}
// printf("\n");
if(tmp.back().y>Max[x]-tmp.back().x){
Min[x]=max(tmp.back().y-(Max[x]-tmp.back().x),2*val[x]-Max[x]);
}
else{
Min[x]=max(Max[i]&1,2*val[x]-Max[x]);
}
/* if(val[x]%2!=Max[x]%2){
ok=0;
}*/
if(val[x]>Max[x]){
ok=0;
}
Max[x]=val[x];
if(tmp.size()==1){
Min[x]=val[x];
}
}
int main(){
int n;
scanf("%d",&n);
for(int i = 1;i<=n;i++)
scanf("%lld",&val[i]);
for(int i = 1;i<n;i++){
int x,y;
scanf("%d %d",&x,&y);
v[x].pb(y);
v[y].pb(x);
}
if(n==2){
if(val[1]%2==val[2]%2){
printf("YES\n");
}
else{
printf("NO\n");
}
}
else{
for(int i=1;i<=n;i++){
if(v[i].size()!=1){
dfs(i,0);
if(Min[i]!=0){
ok=0;
}
break;
}
}
int tot=0;
for(int i = 1;i<=n;i++){
if(v[i].size()==1){
tot+=val[i];
}
}
if(tot&1)ok=0;
if(ok){
printf("YES\n");
}
else{
printf("NO\n");
}
}
} | a.cc: In function 'void dfs(int, int)':
a.cc:52:24: error: 'i' was not declared in this scope
52 | Min[x]=max(Max[i]&1,2*val[x]-Max[x]);
| ^
|
s577609766 | p03809 | C++ | #include <assert.h>
#include <limits.h>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <unordered_map>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using ll = long long;
using P = std::pair<ll, ll>;
#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr <<"debug "<< i << std::endl;
//const ll MOD = 998244353;
const ll MOD = 1e9+7;
int main() {
std::cin.tie(0);
std::ios::sync_with_stdio(false);
//問題文中の添え字が0-indexか1-indexか確認!
ll n;
std::cin>>n;
std::vector<ll> a(n),v(n,LLONG_MAX),sort;
rep(i,0,n)std::cin>>a[i];
std::vector<std::vector<ll>> graph(n);
rep(i,0,n-1){
ll x,y;
std::cin>>x>>y;
x--;y--;
graph[x].push_back(y);
graph[y].push_back(x);
}
if(n==2){
std::cout<<((a[0]==a[1])?"YES":"NO");
return 0;
}
ll root=-1;
rep(i,0,n){
if(graph[i].size()>=2)root=i;
}
std::vector<bool> used(n,false);
std::queue<ll> que;
que.push(root);
while(!que.empty()){
ll now=que.front();que.pop();
sort.push_back(now);used[now]=true;
for(ll next:graph[now]){
if(!used[next])que.push(next);
}
}
for(ll i=n-1;i>=0;i--){
ll now=sort[i];
ll sum=0,max=-1;
for(ll next:graph[now]){
if(v[next]!=LLONG_MAX){
sum+=v[next];
max=std::max(max,v[next]);
}
}
if(sum==0){
v[now]=a[now];
}else{
v[now]=2*a[now]-sum;
if(v[now]<0){
std::cout<<"NO";
return 0;
}
ll pair=(sum-v[now])/2;
if(pair<0){
std::coout<<"NO";
return 0;
}
if(max>sum/2){
if(sum-max<pair){
std::cout<<"NO";
return 0;
}
}else{
if(sum/2<pair){
std::cout<<"NO";
return 0;
}
}
}
}
if(v[root]!=0){
std::cout<<"NO";
return 0;
}
std::cout<<"YES";
return 0;
}
| a.cc: In function 'int main()':
a.cc:93:14: error: 'coout' is not a member of 'std'; did you mean 'cout'?
93 | std::coout<<"NO";
| ^~~~~
| cout
|
s743177370 | p03809 | C++ | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
vector<vector<int>> v(100010);
ll a[100010];
bool used[100010];
bool pos = true;
ll dfs(int p){
used[p] = true;
bool leaf = true;
ll sum = 0, MAX = 0;
for(auto i:v[p]){
if(!used[i]){
ll t = dfs(i);
leaf = false;
MAX = max(MAX,t);
sum += t;
}
}
if(leaf) return a[p];
if(sum<a[p]){
pos = false;
return -1;
}
if( (sum-a[p]) <= min(sum-MAX,sum/2) ){
ll ret = a[p] - (sum-a[p])
return ret;
}
pos = false;
return -1;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cin>>n;
for(int i=0;i<n;i++){
cin>>a[i];
}
for(int i=0;i<n-1;i++){
int r,b;
cin>>r>>b;
r--,b--;
v[r].push_back(b);
v[b].push_back(r);
}
ll r = dfs(0);
if(pos) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
| a.cc: In function 'll dfs(int)':
a.cc:34:9: error: expected ',' or ';' before 'return'
34 | return ret;
| ^~~~~~
|
s495022903 | p03809 | C++ | #include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
using namespace std;
#define LL long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
int n;
LL a[100005];
LL Have[100005];
vector < int > E[100005];
void yes(){
cout << "YES" << endl;
exit(0);
}
void no(){
cout << "NO" << endl;
exit(0);
}
void dfs( int u , int p ){
Have[u] = 0;
if ( E[u].size() == 1 ){
Have[u] = a[u];
return;
}
if ( p == -1 ){
vector < LL > val;
for ( int v : E[u] ){
dfs(v,u);
val.pb(Have[v]);
}
sort(val.begin(),val.end());
LL sum = 0;
LL fsum = 0;
LL target = a[u];
for ( LL v : val ){
sum += v;
}
for ( int i = 0; i < val.size(); i++ ){
LL v = val[i];
if ( fsum <= target && fsum + v >= target ){
LL l = 0, r = v;
while ( l < r){
LL m = ( l + r ) / 2;
if ( fsum + m >= target ) r = m;
else l = m + 1;
}
fsum += l;
sum -= l;
if ( fsum >= target && sum >= target ){
yes();
} else {
no();
}
}
fsum += v;
sum -= v;
if ( fsum >= target ){
if ( sum >= target ){
yes();
}
no();
}
if ( sum < target ){
no();
}
}
} else {
for ( int v : E[u] ){
if ( v == p ) continue;
dfs(v,u);
Have[u] += Have[v];
}
if ( Have[u] < a[u] ){
no();
}
Have[u] = a[u];
}
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
for ( int i = 1; i <= n; i++ ) cin >> a[i];
for ( int i = 0; i < n-1; i++ ){
int u , v;
cin >> u >> v;
E[u].pb(v);
E[v].pb(u);
}
if ( n == 2 ){
yes();
}
for ( int i = 1; i <= n; i++ ){
if ( E[i].size() == 1 ) continue;
dfs(i,-1);
assert(1==2);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:119:17: error: 'assert' was not declared in this scope
119 | assert(1==2);
| ^~~~~~
a.cc:8:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
7 | #include <set>
+++ |+#include <cassert>
8 | using namespace std;
|
s660202470 | p03809 | C++ | #include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<functional>
using namespace std;
int p = 1000000007;
#define int __int128
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(long long i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define V vector
#define Endl endl
int kai_size = 100001;
vel kai(kai_size, 1);
vel ink(kai_size, 1);
int RE() {
vel v(3, 2);
return v.at(4);
}
vel dis(int mid1, vvel &way) {
int n = way.size();
vel dist(n, -1); dist[mid1] = 0;
queue<int> q;
q.push(mid1);
while (!q.empty()) {
int st = q.front(); q.pop();
rep(i, way[st].size()) {
int to = way[st][i];
if (dist[to] == -1) {
dist[to] = dist[st] + 1;
q.push(to);
}
}
}
return dist;
}
int ret(int now, vvel &chi,vel &a) {
int mx = 0;
int sum = 0;
if (chi[now].size() == 0) { return a[now]; }
if (chi[now].size() == 1) {
int val = ret(chi[now][0], chi, a);
if (val == a[now]) { return val; }
return -1;
}
rep(i, chi[now].size()) {
int nex = chi[now][i];
int val = ret(nex, chi, a);
if (val < 0) { return -1; }
sum += val;
mmax(mx, val);
}
if (a[now] < mx) { return -1; }
if (sum > a[now] * 2) { return -1; }
return a[now] * 2 - sum;
}
signed main() {
int n; cin >> n;
vel a(n);
rep(i, n) { cin >> a[i]; }
if (n == 2) {
if (a[0] == a[1]) { cout << "YES" << Endl; return 0; }
cout << "NO" << endl;
return 0;
}
vel st(n - 1), to(n - 1);
vvel way(n);
rep(i, n-1) {
cin >> st[i] >> to[i];
st[i]--; to[i]--;
way[st[i]].push_back(to[i]);
way[to[i]].push_back(st[i]);
}
int start = 0;
if (way[0].size() == 1) {
start = way[0][0];
}
vel dist = dis(start, way);
vvel chi(n);
rep(i, n - 1) {
if (dist[st[i]] + 1 == dist[to[i]]) {
chi[st[i]].push_back(to[i]);
}
else {
chi[to[i]].push_back(st[i]);
}
}
int val = ret(start, chi, a);
if (val == 0) {
cout << "YES" << endl;
}
else {
cout << "NO" << endl;
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:68:20: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and '__int128')
68 | int n; cin >> n;
| ~~~ ^~ ~
| | |
| | __int128
| std::istream {aka std::basic_istream<char>}
In file included from /usr/include/c++/14/iostream:42,
from a.cc:1:
/usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
170 | operator>>(bool& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed:
a.cc:68:23: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type '__int128'
68 | int n; cin >> n;
| ^
/usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
174 | operator>>(short& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed:
a.cc:68:23: error: cannot bind non-const lvalue reference of type 'short int&' to a value of type '__int128'
68 | int n; cin >> n;
| ^
/usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
177 | operator>>(unsigned short& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed:
a.cc:68:23: error: cannot bind non-const lvalue reference of type 'short unsigned int&' to a value of type '__int128'
68 | int n; cin >> n;
| ^
/usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
181 | operator>>(int& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:181:7: note: conversion of argument 1 would be ill-formed:
a.cc:68:23: error: cannot bind non-const lvalue reference of type 'int&' to a value of type '__int128'
68 | int n; cin >> n;
| ^
/usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
184 | operator>>(unsigned int& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:184:7: note: conversion of argument 1 would be ill-formed:
a.cc:68:23: error: cannot bind non-const lvalue reference of type 'unsigned int&' to a value of type '__int128'
68 | int n; cin >> n;
| ^
/usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
188 | operator>>(long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:188:7: note: conversion of argument 1 would be ill-formed:
a.cc:68:23: error: cannot bind non-const lvalue reference of type 'long int&' to a value of type '__int128'
68 | int n; cin >> n;
| ^
/usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
192 | operator>>(unsigned long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:192:7: note: conversion of argument 1 would be ill-formed:
a.cc:68:23: error: cannot bind non-const lvalue reference of type 'long unsigned int&' to a value of type '__int128'
68 | int n; cin >> n;
| ^
/usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
199 | operator>>(long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:199:7: note: conversion of argument 1 would be ill-formed:
a.cc:68:23: error: cannot bind non-const lvalue reference of type 'long long int&' to a value of type '__int128'
68 | int n; cin >> n;
| ^
/usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
203 | operator>>(unsigned long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:203:7: note: conversion of argument 1 would be ill-formed:
a.cc:68:23: error: cannot bind non-const lvalue reference of type 'long long unsigned int&' to a value of type '__int128'
68 | int n; cin >> n;
| ^
/usr/include/c++/14/istream:219:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
219 | operator>>(float& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:219:7: note: conversion of argument 1 would be ill-formed:
a.cc:68:23: error: cannot bind non-const lvalue reference of type 'float&' to a value of type '__int128'
68 | int n; cin >> n;
| ^
/usr/include/c++/14/istream:223:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
223 | operator>>(double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:223:7: note: conversion of argument 1 would be ill-formed:
a.cc:68:23: error: cannot bind non-const lvalue reference of type 'double&' to a value of type '__int128'
68 | int n; cin >> n;
| ^
/usr/include/c++/14/istream:227:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
227 | operator>>(long double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:227:7: note: conversion of argument 1 would be ill-formed:
a.cc:68:23: error: cannot bind non-const lvalue reference of type 'long double&' to a value of type '__int128'
68 | int n; cin >> n;
| ^
/usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
328 | operator>>(void*& __p)
| ^~~~~~~~
/usr/include/c++/14/istream:328:7: note: conversion of argument 1 would be ill-formed:
a.cc:68:23: error: invalid conversion from '__int128' to 'void*' [-fpermissive]
68 | int n; cin >> n;
| ^
| |
| __int128
a.cc:68:23: error: cannot bind rvalue '(void*)((long int)n)' to 'void*&'
/usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:122:7: note: conversion of argument 1 would be ill-formed:
a.cc:68:23: error: invalid conversion from '__int128' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermissive]
68 | int n; cin >> n;
| ^
| |
| __int128
/usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>; __ios_type = std::basic_ios<char>]' (near match)
126 | operator>>(__ios_type& (*__pf)(__ios_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:126:7: note: conversion of argument 1 would be ill-formed:
a.cc:68:23: error: invalid conversion from '__int128' to 'std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'} [-fpermissive]
68 | int n; cin >> n;
| ^
| |
| __int128
/usr/include/c++/14/istream:133:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = |
s670727528 | p03809 | C++ | #include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };
int main() {
int n;
scanf("%d",&n);
fup(i,1,n,1)scanf("%lld",a+i);
fup(i,1,n-1,1)
{
int x,y;
scanf("%d%d",&x,&y);
v[x].pb(y);
v[y].pb(x);
}
fup(i,1,n,1)
{
if(v[i].size()>1)
{
ll sum=0;
for(int next:v[i])
{
sum+=a[next];
}
if(sum&1)return !printf("NO");
for(int next:v[i])
{
if(a[next]>sum/2)return !printf("NO");
}
}
}
puts("YES");
} | a.cc: In function 'int main()':
a.cc:65:34: error: 'a' was not declared in this scope
65 | fup(i,1,n,1)scanf("%lld",a+i);
| ^
a.cc:70:17: error: 'v' was not declared in this scope
70 | v[x].pb(y);
| ^
a.cc:75:20: error: 'v' was not declared in this scope
75 | if(v[i].size()>1)
| ^
a.cc:80:38: error: 'a' was not declared in this scope
80 | sum+=a[next];
| ^
a.cc:85:36: error: 'a' was not declared in this scope
85 | if(a[next]>sum/2)return !printf("NO");
| ^
|
s351721839 | p03809 | C++ | #include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)
template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x) cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する
class Solve {
public:
int N;
vector<ll> A;
vector<vector<int>> treeone;
void input() {
cin >> N;
A.resize(N);
for(int i = 0; i < N; ++i){
cin >> A[i];
}
treeone.resize(N);
for(int i = 0; i < N - 1; ++i){
int a,b;
cin >> a >> b;
a--,b--;
treeone[a].push_back(b);
treeone[b].push_back(a);
}
}
ll dfs(int n, int p){
// if(treeone[n].size() == 1) return A[n];
ll ret = 2 * A[n];
if(treeone[n].size() == 1) ret = A[n];
for(auto e : treeone[n]){
if(e != p){
ret -= dfs(e, n);
}
}
return ret;
}
void solve() {
input();
ll val = dfs(0,-1);
if(val == 0){
cout << "YES" << endl;
}else{
cout << "NO" << endl;
}
}
};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(10);
Solve().solve();#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)
template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x) cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する
class Solve {
public:
int N;
vector<ll> A;
vector<vector<int>> treeone;
void input() {
cin >> N;
A.resize(N);
for(int i = 0; i < N; ++i){
cin >> A[i];
}
treeone.resize(N);
for(int i = 0; i < N - 1; ++i){
int a,b;
cin >> a >> b;
a--,b--;
treeone[a].push_back(b);
treeone[b].push_back(a);
}
}
ll dfs(int n, int p){
// if(treeone[n].size() == 1) return A[n];
ll ret = 2 * A[n];
if(treeone[n].size() == 1) ret = A[n];
for(auto e : treeone[n]){
if(e != p){
ret -= dfs(e, n);
}
}
return ret;
}
void solve() {
input();
ll val = dfs(0,-1);
if(val == 0){
cout << "YES" << endl;
}else{
cout << "NO" << endl;
}
}
};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(10);
Solve().solve();
return 0;
}
return 0;
}
| a.cc:108:21: error: stray '#' in program
108 | Solve().solve();#include <algorithm>
| ^
a.cc: In function 'int main()':
a.cc:108:22: error: 'include' was not declared in this scope
108 | Solve().solve();#include <algorithm>
| ^~~~~~~
a.cc:108:31: error: 'algorithm' was not declared in this scope
108 | Solve().solve();#include <algorithm>
| ^~~~~~~~~
a.cc:146:1: error: a template declaration cannot appear at block scope
146 | template<typename T1, typename T2>
| ^~~~~~~~
a.cc:210:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
210 | int main() {
| ^~
a.cc:210:9: note: remove parentheses to default-initialize a variable
210 | int main() {
| ^~
| --
a.cc:210:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:210:12: error: a function-definition is not allowed here before '{' token
210 | int main() {
| ^
|
s974061135 | p03809 | C++ | #include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
using namespace std;
signed main()
{
int N;
cin >> N;
vector<int> A(N);
rep(i, N) cin >> A[i];
vector<vector<int>> g(N, vector<int>());
rep(i, N-1) {
int a, b;
cin >> a >> b;
a--;b--;
g[a].push_back(b);
g[b].push_back(a);
}
auto dfs = [&](auto&& f, int p, int x, int& r) {
vector<int> l;
int t;
r = A[x];
int sum = 0;
for (auto a : g[x]) {
if (a == p) continue;
if (!f(f, x, a, t)) return false;
l.push_back(t);
sum += t;
}
sort(l.begin(), l.end());
if (l.size() == 0) return true;
int mi = sum - min(sum / 2, (sum - l.back()));
r = 2 * A[x] - sum;
return mi <= A[x] && A[x] <= sum;
};
int res;
if (dfs(dfs, -1, 0, res)) cout << "YES" << endl;
else cout << "NO" << endl;
} | a.cc: In instantiation of 'main()::<lambda(auto:28&&, long long int, long long int, long long int&)> [with auto:28 = main()::<lambda(auto:28&&, long long int, long long int, long long int&)>&]':
a.cc:39:10: required from here
39 | if (dfs(dfs, -1, 0, res)) cout << "YES" << endl;
| ~~~^~~~~~~~~~~~~~~~~
a.cc:28:13: error: use of 'main()::<lambda(auto:28&&, long long int, long long int, long long int&)> [with auto:28 = main()::<lambda(auto:28&&, long long int, long long int, long long int&)>&]' before deduction of 'auto'
28 | if (!f(f, x, a, t)) return false;
| ~^~~~~~~~~~~~
|
s495493984 | p03809 | C++ | #include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
using namespace std;
signed main()
{
int N;
cin >> N;
vector<int> A(N);
rep(i, N) cin >> A[i];
vector<vector<int>> g(N, vector<int>());
rep(i, N-1) {
int a, b;
cin >> a >> b;
a--;b--;
g[a].push_back(b);
g[b].push_back(a);
}
auto dfs = [&](auto f, int p, int x, int& r) {
vector<int> l;
int t;
r = A[x];
int sum = 0;
for (auto a : g[x]) {
if (a == p) continue;
if (!f(f, x, a, t)) return false;
l.push_back(t);
sum += t;
}
sort(l.begin(), l.end());
if (l.size() == 0) return true;
int mi = sum - min(sum / 2, (sum - l.back()));
r = 2 * A[x] - sum;
return mi <= A[x] && A[x] <= sum;
};
int res;
if (dfs(dfs, -1, 0, res)) cout << "YES" << endl;
else cout << "NO" << endl;
} | a.cc: In instantiation of 'main()::<lambda(auto:28, long long int, long long int, long long int&)> [with auto:28 = main()::<lambda(auto:28, long long int, long long int, long long int&)>]':
a.cc:39:10: required from here
39 | if (dfs(dfs, -1, 0, res)) cout << "YES" << endl;
| ~~~^~~~~~~~~~~~~~~~~
a.cc:28:13: error: use of 'main()::<lambda(auto:28, long long int, long long int, long long int&)> [with auto:28 = main()::<lambda(auto:28, long long int, long long int, long long int&)>]' before deduction of 'auto'
28 | if (!f(f, x, a, t)) return false;
| ~^~~~~~~~~~~~
|
s548349855 | p03809 | C++ | #include<stdio.h>
#include<bits/locale_facets.h>
#include<memory.h>
#include<math.h>
using namespace std;
const int nn=100001;
int A[nn],degree[nn],time[nn];
long long input();
void output(long long value);
template<int nodes>struct phylogenetic_tree
{
int root,total,t,memory,other,father[nodes],son[nodes],depth[nodes],last[nodes],next[nodes];
phylogenetic_tree()
{
other=nodes*4,t=log(nodes)/log(2);
clear();
}
void clear()
{
memset(son,0,4*(total+1));
memset(father,0,other);
memset(last,0,other);
memset(depth,0,other);
root=total=0;
}
void insert(int f,int s)
{
if(father[s])return ;
if(!root)root=f;
else if(!father[f])return ;
father[s]=f,son[++total]=s;
next[total]=last[f],last[f]=total;
}
int new1(int p,int from)
{
if(degree[p]==1)return time[from]=A[p];
int sum=0;
for(int i=last[p];i;i=next[i])
if((i>>1)!=from)sum+=new1(son[i],i>>1);
if(sum>A[p]<<1)printf("NO"),exit(0);
if(!from)
{
if(sum==A[p]<<1)printf("YES");
else printf("NO");
exit(0);
}
return time[from]=(A[p]<<1)-sum;
}
};
phylogenetic_tree<nn>stone;
int main()
{
stone.total=1;
int n=input(),a,b;
for(int i=1;i<=n;i++)A[i]=input();
for(int i=1;i<n;i++)
{
a=input(),b=input();
stone.insert(a,b),stone.insert(b,a);
degree[a]++,degree[b]++;
}
for(int i=1;i<=n;i++)
if(degree[i]>1)stone.new1(i,0);
}
long long input()
{
long long value=0,positive=1;
char digit=getchar();
for(;!isdigit(digit);digit=getchar())
if(digit=='-')positive=-positive;
for(;isdigit(digit);digit=getchar())value=(value<<3)+(value<<1)+digit-'0';
return positive*value;
}
void output(long long value)
{
if(value<0)
{
putchar('-');
value=-value;
}
if(value>=10)output(value/10);
putchar(value%10+'0');
} | a.cc:7:29: error: 'int time [100001]' redeclared as different kind of entity
7 | int A[nn],degree[nn],time[nn];
| ^
In file included from /usr/include/pthread.h:23,
from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
from /usr/include/c++/14/ext/atomicity.h:35,
from /usr/include/c++/14/bits/ios_base.h:39,
from /usr/include/c++/14/bits/locale_facets.h:43,
from a.cc:2:
/usr/include/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
76 | extern time_t time (time_t *__timer) __THROW;
| ^~~~
a.cc: In member function 'int phylogenetic_tree<nodes>::new1(int, int)':
a.cc:36:50: error: assignment of read-only location 'time[from]'
36 | if(degree[p]==1)return time[from]=A[p];
| ~~~~~~~~~~^~~~~
a.cc:47:34: error: assignment of read-only location 'time[from]'
47 | return time[from]=(A[p]<<1)-sum;
| ~~~~~~~~~~^~~~~~~~~~~~~~
|
s923807312 | p03809 | C++ | #include <bits/stdc++.h>
using namespace std;
int n;
long long a[100010];
bool visited[100010] = {};
vector<int> graph[100010];
long long dfs(int idx){
visited[idx] = true;
priority_queue<long long> que;
long long line = 0;
for(int i = 0;i < graph[idx].size();i++){
if(!visited[graph[idx][i]]){
long long tmp = dfs(graph[idx][i]);
que.push(tmp);
line += tmp;
}
}
if(que.empty()){
return a[idx];
}
long long ok = line - a[idx];
if(ok < 0){
cout <<"NO" << endl;
exit(0);
}
long long cnt = 0;
while(que.size() > 1){
long long tmp = que.top();
que.pop();
long long tmp2 = que.top();
cnt += que.top();
que.pop();
que.push(tmp-tmp2);
}
if(ok <= cnt){
return a[idx]-ok;
}else{
cout << "NO" << endl;
exit(0);
}
}
int main(){
cin >> n;
int s, t;
for(int i = 0;i < n;i++){
cin >> a[i];
}
for(int i = 0;i < n-1;i++){
cin >> s >> t;
s--; t--;
graph[s].push_back(t);
graph[t].push_back(s);
}
int ta[100010] = {};
int root = 0;
while(1){
int i;
ta[root] = 1;
for(i = 0;i < graph[root].size();i++){
if(ta[graph[root][i]] == 0){
root = graph[root][i];
break;
}
}
if(i == graph[root].size()){
break;
}
}
dfs(root);
cout << "YES" << endl;
return 0;
}
someha@DESKTOP-UG27 | a.cc:96:7: error: stray '@' in program
96 | someha@DESKTOP-UG27
| ^
a.cc:96:1: error: 'someha' does not name a type
96 | someha@DESKTOP-UG27
| ^~~~~~
|
s716266631 | p03809 | C++ | #include <bits/stdc++.h>
using namespace std;
int n;
long long a[100010];
bool visited[100010] = {};
vector<int> graph[100010];
long long dfs(int idx){
visited[idx] = true;
priority_queue<long long> que;
long long line = 0;
for(int i = 0;i < graph[idx].size();i++){
if(!visited[graph[idx][i]]){
long long tmp = dfs(graph[idx][i]);
que.push(tmp);
line += tmp;
}
}
if(que.empty()){
return a[idx];
}
long long ok = line - a[idx];
long long cnt = 0;
while(que.size() > 1){
long long tmp = que.top();
que.pop();
long long tmp2 = que.top();
cnt += que.top();
que.pop();
que.push(tmp-tmp2);
}
if(ok <= cnt){
return a[idx]-ok;
}else{
cout << "NO" << endl;
exit(0);
}
}
int main(){
cin >> n;
int s, t;
for(int i = 0;i < n;i++){
cin >> a[i];
}
for(int i = 0;i < n-1;i++){
cin >> s >> t;
s--; t--;
graph[s].push_back(t);
graph[t].push_back(s);
}
int ta[100010] == {};
int root = 0;
while(1){
int i;
ta[root] = 1;
for(i = 0;i < graph[root].size();i++){
if(ta[graph[root][i]] == 0){
root = graph[root][i];
break;
}
}
if(i == graph[root].size()){
break;
}
}
dfs(root);
cout << "YES" << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:63:20: error: expected initializer before '==' token
63 | int ta[100010] == {};
| ^~
a.cc:69:9: error: 'ta' was not declared in this scope; did you mean 't'?
69 | ta[root] = 1;
| ^~
| t
|
s575405173 | p03809 | C++ | #include<bits/stdc++.h>
using namespace std;
#define int long long
myMake(int cur, vector<vector<int> > &adj, vector<vector<int> > &G, vector<bool> &used){
used[cur] = true;
for(auto nxt : adj[cur]){
if(used[nxt]) continue;
G[cur].push_back(nxt);
myMake(nxt, adj, G, used);
}
}
int dfs(int cur, vector<vector<int> > &G, vector<int> &A){
if(G[cur].size() == 0){
cerr << cur << " " << A[cur] << endl;
return A[cur];
}
int sum = 0;
vector<int> vec;
for(auto nxt : G[cur]){
int val = dfs(nxt, G, A);
if(val < 0){
cerr << cur << " " << -1 << endl;
return -1;
}
vec.push_back(val);
sum += val;
}
int ret = 2 * A[cur] - sum;
//cout << cur << " " << sum << " " << A[cur] << " " << ret << endl;
if(ret < 0){
cerr << cur << " " << -1 << endl;
return -1;
}
vec.push_back(ret);
int n = (int)vec.size();
sum += ret;
assert(sum % 2 == 0);
bool ok = true;
for(int i = 0; i < n; i++){
if(vec[i] > sum / 2){
cerr << cur << " " << -1 << endl;
return -1;
}
}
cerr << cur << " " << ret << endl;
return ret;
}
signed main(){
int N; cin >> N;
vector<int> A(N);
vector<vector<int> > adj(N); // {node}
for(int i = 0; i < N; i++) cin >> A[i];
for(int i = 0; i < N - 1; i++){
int a, b; cin >> a >> b; a--; b--;
adj[a].push_back(b);
adj[b].push_back(a);
}
vector<bool> used(N, false);
vector<vector<int> > G(N); // 0 を根とする 根付き木
myMake(0, adj, G, used);
int val = (G[0].size() == 1 ? A[0] : 0);
if(dfs(0, G, A) == val) cout << "YES" << endl;
else cout << "NO" << endl;
return 0;
} | a.cc:5:1: error: ISO C++ forbids declaration of 'myMake' with no type [-fpermissive]
5 | myMake(int cur, vector<vector<int> > &adj, vector<vector<int> > &G, vector<bool> &used){
| ^~~~~~
a.cc: In function 'int myMake(long long int, std::vector<std::vector<long long int> >&, std::vector<std::vector<long long int> >&, std::vector<bool>&)':
a.cc:13:1: warning: no return statement in function returning non-void [-Wreturn-type]
13 | }
| ^
|
s819004052 | p03809 | C++ | #include<bits/stdc++.h>
using namespace std;
#define int long long
make(int cur, vector<vector<int> > &adj, vector<vector<int> > &G, vector<bool> &used){
used[cur] = true;
for(auto nxt : adj[cur]){
if(used[nxt]) continue;
G[cur].push_back(nxt);
make(nxt, adj, G, used);
}
}
int dfs(int cur, vector<vector<int> > &G, vector<int> &A){
if(G[cur].size() == 0){
cerr << cur << " " << A[cur] << endl;
return A[cur];
}
int sum = 0;
vector<int> vec;
for(auto nxt : G[cur]){
int val = dfs(nxt, G, A);
if(val < 0){
cerr << cur << " " << -1 << endl;
return -1;
}
vec.push_back(val);
sum += val;
}
int ret = 2 * A[cur] - sum;
//cout << cur << " " << sum << " " << A[cur] << " " << ret << endl;
if(ret < 0){
cerr << cur << " " << -1 << endl;
return -1;
}
vec.push_back(ret);
int n = (int)vec.size();
sum += ret;
assert(sum % 2 == 0);
bool ok = true;
for(int i = 0; i < n; i++){
if(vec[i] > sum / 2){
cerr << cur << " " << -1 << endl;
return -1;
}
}
cerr << cur << " " << ret << endl;
return ret;
}
signed main(){
int N; cin >> N;
vector<int> A(N);
vector<vector<int> > adj(N); // {node}
for(int i = 0; i < N; i++) cin >> A[i];
for(int i = 0; i < N - 1; i++){
int a, b; cin >> a >> b; a--; b--;
adj[a].push_back(b);
adj[b].push_back(a);
}
vector<bool> used(N, false);
vector<vector<int> > G(N); // 0 を根とする 根付き木
make(0, adj, G, used);
int val = (G[0].size() == 1 ? A[0] : 0);
if(dfs(0, G, A) == val) cout << "YES" << endl;
else cout << "NO" << endl;
return 0;
} | a.cc:5:1: error: ISO C++ forbids declaration of 'make' with no type [-fpermissive]
5 | make(int cur, vector<vector<int> > &adj, vector<vector<int> > &G, vector<bool> &used){
| ^~~~
a.cc: In function 'int make(long long int, std::vector<std::vector<long long int> >&, std::vector<std::vector<long long int> >&, std::vector<bool>&)':
a.cc:13:1: warning: no return statement in function returning non-void [-Wreturn-type]
13 | }
| ^
|
s621085730 | p03809 | C++ | #include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include <climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
struct P {
ll pos, cost;
bool operator<(const P &b) { return cost < b.cost; }
bool operator>(const P &b) { return cost > b.cost; }
};
struct B {
ll to, cost;
};
struct E {
ll from, to, cost;
bool operator<(const E &b) { return cost < b.cost; }
bool operator>(const E &b) { return cost > b.cost; }
};
struct H {
ll x, y;
bool operator<(const H &b) {
if (x != b.x) return x < b.x;
return y < b.y;
}
bool operator>(const H &b) {
if (x != b.x) return x > b.x;
return y > b.y;
}
bool operator==(const H &b) { return x == b.x&&y == b.y; }
bool operator!=(const H &b) { return (*this) != b; }
};
ll gcd(ll i, ll j) {
if (i > j) swap(i, j);
if (i == 0) return j;
return gcd(j%i, i);
}
ld mod_pow(ll x, ll n, ll p) {
ll res = 1;
while (n > 0) {
if (n & 1) res = res * x % p;
x = x * x % p;
n >>= 1;
}
return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
int a[200000];
int b[200000];
vector<int>e[200000];
H c[200000];
int d[200000];
signed main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
c[i].y = i;
}
for (int i = 1; i < n; i++) {
int u, v;
cin >> u >> v;
u--; v--;
e[u].push_back(v);
e[v].push_back(u);
}
queue<int>q;
q.push(0);
while (!q.empty()) {
int t = q.front(); q.pop();
for (int i = 0; i < e[t].size(); i++) {
if (t == 0 || (c[e[t][i]].x == 0 && e[t][i] != 0)) {
c[e[t][i]].x = c[t].x + 1;
q.push(e[t][i]);
d[e[t][i]] = d[t] + 1;
}
}
}
sort(c, c + n);
reverse(c, c + n);
for (int i = 0; i < n; i++) {
int t = c[i].y;
int sum = 0, res = 0;//操作可能回数
int m = 0;//子供の数
//aはその頂点の現時点のコスト
priority_queue<P, vector<P>, greater<P>>p;
priority_queue<P>q;
for (int j = 0; j < e[t].size(); j++) {
if (d[e[t][j]] > d[t]) {
p.push(P{ e[t][j],a[e[t][j]] });
q.push(P{ e[t][j],a[e[t][j]] });
res += a[e[t][j]];
}
}
while (q.size() > 1) {
P mi = p.top(); p.pop();
if (a[mi.pos] != mi.cost) continue;
P ma = q.top(); q.pop();
if (a[ma.pos] != ma.cost) {
p.push(mi);
continue;
}
a[mi.pos] = 0;
a[ma.pos] = ma.cost - mi.cost;
sum += mi.cost;
p.push(P{ ma.pos,a[ma.pos] });
q.push(P{ ma.pos,a[ma.pos] });
}
if (m == 0) continue;
if (res < a[t] || sum < res - a[t]) {
cout << "NO\n";
return 0;
}
else {
a[t] -= sum - a[t];
}
}
cout << "YES\n";
} | In file included from /usr/include/c++/14/string:49,
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_function.h: In instantiation of 'constexpr bool std::greater<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = P]':
/usr/include/c++/14/bits/predefined_ops.h:196:23: required from 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = __gnu_cxx::__normal_iterator<P*, std::vector<P> >; _Value = P; _Compare = std::greater<P>]'
196 | { return bool(_M_comp(*__it, __val)); }
| ~~~~~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_heap.h:140:48: required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<P*, vector<P> >; _Distance = long int; _Tp = P; _Compare = __gnu_cxx::__ops::_Iter_comp_val<greater<P> >]'
140 | while (__holeIndex > __topIndex && __comp(__first + __parent, __value))
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_heap.h:216:23: required from 'void std::push_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<P*, vector<P> >; _Compare = greater<P>]'
216 | std::__push_heap(__first, _DistanceType((__last - __first) - 1),
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
217 | _DistanceType(0), _GLIBCXX_MOVE(__value), __cmp);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:747:16: required from 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = P; _Sequence = std::vector<P>; _Compare = std::greater<P>; value_type = P]'
747 | std::push_heap(c.begin(), c.end(), comp);
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:111:11: required from here
111 | p.push(P{ e[t][j],a[e[t][j]] });
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_function.h:395:20: error: no match for 'operator>' (operand types are 'const P' and 'const P')
395 | { return __x > __y; }
| ~~~~^~~~~
a.cc:28:14: note: candidate: 'bool P::operator>(const P&)' (near match)
28 | bool operator>(const P &b) { return cost > b.cost; }
| ^~~~~~~~
a.cc:28:14: note: passing 'const P*' as 'this' argument discards qualifiers
In file included from /usr/include/c++/14/string:48:
/usr/include/c++/14/bits/stl_iterator.h:462:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
462 | operator>(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:462:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:395:20: note: 'const P' is not derived from 'const std::reverse_iterator<_Iterator>'
395 | { return __x > __y; }
| ~~~~^~~~~
/usr/include/c++/14/bits/stl_iterator.h:507:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
507 | operator>(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:507:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:395:20: note: 'const P' is not derived from 'const std::reverse_iterator<_Iterator>'
395 | { return __x > __y; }
| ~~~~^~~~~
/usr/include/c++/14/bits/stl_iterator.h:1714:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1714 | operator>(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1714:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:395:20: note: 'const P' is not derived from 'const std::move_iterator<_IteratorL>'
395 | { return __x > __y; }
| ~~~~^~~~~
/usr/include/c++/14/bits/stl_iterator.h:1774:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1774 | operator>(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1774:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:395:20: note: 'const P' is not derived from 'const std::move_iterator<_IteratorL>'
395 | { return __x > __y; }
| ~~~~^~~~~
/usr/include/c++/14/bits/stl_function.h: In instantiation of 'constexpr bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = P]':
/usr/include/c++/14/bits/predefined_ops.h:196:23: required from 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = __gnu_cxx::__normal_iterator<P*, std::vector<P> >; _Value = P; _Compare = std::less<P>]'
196 | { return bool(_M_comp(*__it, __val)); }
| ~~~~~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_heap.h:140:48: required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<P*, vector<P> >; _Distance = long int; _Tp = P; _Compare = __gnu_cxx::__ops::_Iter_comp_val<less<P> >]'
140 | while (__holeIndex > __topIndex && __comp(__first + __parent, __value))
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_heap.h:216:23: required from 'void std::push_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<P*, vector<P> >; _Compare = less<P>]'
216 | std::__push_heap(__first, _DistanceType((__last - __first) - 1),
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
217 | _DistanceType(0), _GLIBCXX_MOVE(__value), __cmp);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:747:16: required from 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = P; _Sequence = std::vector<P>; _Compare = std::less<P>; value_type = P]'
747 | std::push_heap(c.begin(), c.end(), comp);
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:112:11: required from here
112 | q.push(P{ e[t][j],a[e[t][j]] });
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_function.h:405:20: error: no match for 'operator<' (operand types are 'const P' and 'const P')
405 | { return __x < __y; }
| ~~~~^~~~~
a.cc:27:14: note: candidate: 'bool P::operator<(const P&)' (near match)
27 | bool operator<(const P &b) { return cost < b.cost; }
| ^~~~~~~~
a.cc:27:14: note: passing 'const P*' as 'this' argument discards qualifiers
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
448 | operator<(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:405:20: note: 'const P' is not derived from 'const std::reverse_iterator<_Iterator>'
405 | { return __x < __y; }
| ~~~~^~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
493 | operator<(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:405:20: note: 'const P' is not derived from 'const std::reverse_iterator<_Iterator>'
405 | { return __x < __y; }
| ~~~~^~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1694 | operator<(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:405:20: note: 'const P' is not derived from 'const std::move_iterator<_IteratorL>'
405 | { return __x < __y; }
| ~~~~^~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1760 | operator<(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:405:20: note: 'const P' is not derived from 'const std::move_iterator<_IteratorL>'
405 | { return __x < __y; }
| ~~~~^~~~~
|
s493256158 | p03809 | C++ | #include<iostream>
#include<cstdio>
using namespace std;
#define MAX 100100
#define ll long long
inline int read()
{
int x=0;bool t=false;char ch=getchar();
while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
if(ch=='-')t=true,ch=getchar();
while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
return t?-x:x;
}
void WA(){puts("NO");exit(0);}
struct Line{int v,next;}e[MAX<<1];
int h[MAX],cnt=1,dg[MAX];
inline void Add(int u,int v){e[cnt]=(Line){v,h[u]};h[u]=cnt++;++dg[u];}
int n,a[MAX],rt;
void dfs(int u,int ff)
{
int mx=0;ll sum=0;
for(int i=h[u];i;i=e[i].next)
{
int v=e[i].v;if(v==ff)continue;
dfs(v,u);mx=max(mx,a[v]);sum+=a[v];
}
if(dg[u]==1)return;
ll mn=min(sum/2,min(1ll*mx,sum-mx));
if(a[u]>sum)WA();
else
{
if(sum-mn>a[u])WA();
else a[u]-=sum-a[u];
}
}
int main()
{
n=read();
for(int i=1;i<=n;++i)a[i]=read();
if(n==2){puts(a[1]==a[2]?"YES":"NO");return 0;}
for(int i=1;i<n;++i)
{
int u=read(),v=read();
Add(u,v);Add(v,u);
}
for(int i=1;i<=n;++i)
if(dg[i]>1){dfs(rt=i,0);break;}
if(a[rt])WA();else puts("YES");
sreturn 0;
} | a.cc: In function 'int main()':
a.cc:49:5: error: 'sreturn' was not declared in this scope
49 | sreturn 0;
| ^~~~~~~
|
s046049602 | p03809 | C++ | #include<iostream>
#include<cstdio>
using namespace std;
#define MAX 100100
#define ll long long
inline int read()
{
int x=0;bool t=false;char ch=getchar();
while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
if(ch=='-')t=true,ch=getchar();
while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
return t?-x:x;
}
void WA(){puts("NO");exit(0);}
struct Line{int v,next;}e[MAX<<1];
int h[MAX],cnt=1,dg[MAX];
inline void Add(int u,int v){e[cnt]=(Line){v,h[u]};h[u]=cnt++;++dg[u];}
int n,a[MAX],rt;
void dfs(int u,int ff)
{
int mx=0;ll sum=0;
for(int i=h[u];i;i=e[i].next)
{
int v=e[i].v;if(v==ff)continue;
dfs(v,u);mx=max(mx,a[v]);sum+=a[v];
}
if(dg[u]==1)return;
ll mn=min(sum/2,min(mx,sum-mx));
if(a[u]>sum)WA();
else
{
if(sum-mn>a[u])WA();
else a[u]-=sum-a[u];
}
}
int main()
{
n=read();
for(int i=1;i<=n;++i)a[i]=read();
if(n==2){puts(a[1]==a[2]?"YES":"NO");return 0;}
for(int i=1;i<n;++i)
{
int u=read(),v=read();
Add(u,v);Add(v,u);
}
for(int i=1;i<=n;++i)
if(dg[i]>1){dfs(rt=i,0);break;}
if(a[rt])WA();else puts("YES");
sreturn 0;
} | a.cc: In function 'void dfs(int, int)':
a.cc:28:24: error: no matching function for call to 'min(int&, long long int)'
28 | ll mn=min(sum/2,min(mx,sum-mx));
| ~~~^~~~~~~~~~~
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:28:24: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
28 | ll mn=min(sum/2,min(mx,sum-mx));
| ~~~^~~~~~~~~~~
/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: In function 'int main()':
a.cc:49:5: error: 'sreturn' was not declared in this scope
49 | sreturn 0;
| ^~~~~~~
|
s002645499 | p03809 | C++ | #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
typedef long long ll;
typedef unsigned int uint;
using namespace std;
int N, A[100005];
vector <int> G[100005];
bool visited[100005];
int dfs(int x) {
visited[x] = true;
if (G[x].size() == 1) {
return A[x];
} else {
int cost=0, mx=0;
for (int i = 0; i < G[x].size(); i++) {
if (visited[G[x][i]]) continue;
int d = dfs(G[x][i]);
if (d == -1) return -1;
cost += d;
mx = max(d, mx);
}
if (A[x] > cost) return -1;
if (2 * mx < cost && A[x] < cost - (cost/2)) return -1;
if (2 * mx >= cost && A[x] < mx) return -1;
return 2 * A[x] - cost;
}
}
int main() {
cin.sync_with_stdio(false);
cin.tie(0);
cin >> N;
for (int i = 1; i <= N; i++) cin >> A[i];
for (int i = 0; i < N-1; i++) {
int a, b;
cin >> a >> b;
G[a].push_back(b);
G[b].push_back(a);
}
int max_A=0, max_i=1;
for (int i = 1; i <= N; i++) {
if (max_A < A[i] && G[i].size() > 1) {
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
typedef long long ll;
typedef unsigned int uint;
using namespace std;
int N, A[100005];
vector <int> G[100005];
bool visited[100005];
int dfs(int x) {
visited[x] = true;
if (G[x].size() == 1) return A[x];
int cost=0, mx=0;
for (int i = 0; i < G[x].size(); i++) {
if (visited[G[x][i]]) continue;
int d = dfs(G[x][i]);
if (d == -1) return -1;
cost += d;
mx = max(d, mx);
}
if (A[x] > cost) return -1;
if (2 * mx < cost && A[x] < cost - (cost/2)) return -1;
if (2 * mx >= cost && A[x] < mx) return -1;
return 2 * A[x] - cost;
}
int main() {
cin.sync_with_stdio(false);
cin.tie(0);
cin >> N;
for (int i = 1; i <= N; i++) cin >> A[i];
for (int i = 0; i < N-1; i++) {
int a, b;
cin >> a >> b;
G[a].push_back(b);
G[b].push_back(a);
}
int max_A=0, max_i=1;
for (int i = 1; i <= N; i++) {
if (max_A < A[i] && G[i].size() > 1) {
max_A = A[i];
max_i = i;
}
}
if (N == 2) {
if (A[1] == A[2]) cout << "YES";
else cout << "NO";
}
if (dfs(max_i) == 0) cout << "YES";
else cout << "NO";
return 0;
} = A[i];
max_i = i;
}
}
if (dfs(max_i) == 0) cout << "YES";
else cout << "NO";
return 0;
} | a.cc: In function 'int main()':
a.cc:66:16: error: a function-definition is not allowed here before '{' token
66 | int dfs(int x) {
| ^
a.cc:85:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
85 | int main() {
| ^~
a.cc:85:9: note: remove parentheses to default-initialize a variable
85 | int main() {
| ^~
| --
a.cc:85:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:85:12: error: a function-definition is not allowed here before '{' token
85 | int main() {
| ^
a.cc:115:3: error: expected primary-expression before '=' token
115 | } = A[i];
| ^
|
s106663085 | p03809 | C++ | #include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
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;}
const ll MOD=1e9+7;
int N;
LL A[114514];
vector<int> es[114514];
pair<LL, LL> dfs(int v, int p) {
int num_ch = 0;
LL l = 0;
LL r = 0;
LL s = 0;
LL ls = 0;
LL maxa = -1;
LL maxb = -1;
LL maxamina = 0x7fffffffffLL;
LL maxamaxa = -1;;
for (int u : es[v]) {
if (p == u) continue;
LL x, y;
tie(x, y) = dfs(u, v);
s += y;
ls += x;
maxa = max(maxa, x);
if (maxa == x) {
maxamina = min(maxamina, y);
}
maxb = max(maxb, y);
if (maxb == y) {
maxbmaxa = max(maxbmaxa, x);
}
LL nr = y+r;
LL nl = max(0LL, max(x, l) - min(y, r));
l = nl;
r = nr;
num_ch++;
}
if (ls/2 + ls%2 > A[v]) {
puts("NO");
exit(0);
}
LL mp = 0;
if (maxa > s-maxamina) mp = maxa - (s-maxamina);
LL mp2 = s/2;
if (2*maxbmaxa > s) mp2 = s - maxbmaxa;
mp2 = A[v] - mp2;
if (num_ch == 0) return make_pair(A[v], A[v]);
if (num_ch == 1) {
if (l <= A[v] && A[v] <= r) return make_pair(A[v], A[v]);
puts("NO");
exit(0);
}
return make_pair(max(l, max(mp2, mp)), min(r, A[v]));
}
int main() {
scanf("%d", &N);
rep(i, N) {
scanf("%lld", &A[i]);
}
rep(i, N-1) {
int u, v;
scanf("%d%d", &u, &v);
--u;
--v;
es[u].eb(v);
es[v].eb(u);
}
vector<int> vs(N);
rep(i, N) vs[i] = i;
random_shuffle(all(vs));
int cnt = 0;
rep(i, N) {
int v = vs[i];
if (es[v].size() > 1) {
cnt++;
if (dfs(v, v).first != 0) {
puts("NO");
exit(0);
}
if (cnt > 20) {
puts("YES");
exit(0);
}
}
}
if (N > 2) {
puts("YES");
exit(0);
}
assert(N == 2);
if (A[0] == A[1]) puts("YES");
else puts("NO");
}
| a.cc: In function 'std::pair<long long int, long long int> dfs(int, int)':
a.cc:54:7: error: 'maxbmaxa' was not declared in this scope; did you mean 'maxamaxa'?
54 | maxbmaxa = max(maxbmaxa, x);
| ^~~~~~~~
| maxamaxa
a.cc:72:9: error: 'maxbmaxa' was not declared in this scope; did you mean 'maxamaxa'?
72 | if (2*maxbmaxa > s) mp2 = s - maxbmaxa;
| ^~~~~~~~
| maxamaxa
a.cc: In function 'int main()':
a.cc:101:17: warning: 'void std::random_shuffle(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<int*, vector<int> >]' is deprecated: use 'std::shuffle' instead [-Wdeprecated-declarations]
101 | random_shuffle(all(vs));
| ~~~~~~~~~~~~~~^~~~~~~~~
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:4492:5: note: declared here
4492 | random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
| ^~~~~~~~~~~~~~
|
s826045538 | p03809 | C++ | #include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
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;}
const ll MOD=1e9+7;
int N;
LL A[114514];
vector<int> es[114514];
pair<LL, LL> dfs(int v, int p) {
int num_ch = 0;
LL l = 0;
LL r = 0;
LL s = 0;
LL ls = 0;
LL maxa = -1;
LL maxb = -1;
for (int u : es[v]) {
if (p == u) continue;
LL x, y;
tie(x, y) = dfs(u, v);
s += y;
ls += x;
maxa = max(maxa, x);
maxb = max(maxb, y);
LL nr = y+r;
LL nl = max(0LL, max(x, l) - min(y, r));
l = nl;
r = nr;
num_ch++;
}
if (ls/2 + ls%2 > A[v]) {
puts("NO");
exit(0);
}
LL mp = 0;
if (2*maxa > s) mp = s-maxa;
LL mp2 = s/2;
if (2*maxb > s) mp2 = s - maxb;
mp2 = A[v] - mp2;
if (num_ch == 0) return make_pair(A[v], A[v]);
if (num_ch == 1) {
if (l <= A[v] && A[v] <= r) return make_pair(A[v], A[v]);
puts("NO");
exit(0);
}
return make_pair(max(l, max(mp2, mp)), min(r, A[v]));
}
int main() {
scanf("%d", &N);
rep(i, N) {
scanf("%lld", &A[i]);
}
rep(i, N-1) {
int u, v;
scanf("%d%d", &u, &v);
--u;
--v;
es[u].eb(v);
es[v].eb(u);
}
rep(v, N) {
if (es[v].size() > 1) {
cnt++;
if (dfs(v, v).first != 0) {
puts("NO");
exit(0);
}
if (cnt > 3) {
puts("YES");
exit(0);
}
}
}
assert(N == 2);
if (A[0] == A[1]) puts("YES");
else puts("NO");
}
| a.cc: In function 'int main()':
a.cc:93:7: error: 'cnt' was not declared in this scope; did you mean 'int'?
93 | cnt++;
| ^~~
| int
|
s410249238 | p03809 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL read(){
LL x=0,f=1;
char ch=getchar();
while (!isdigit(ch)&&ch!='-')
ch=getchar();
if (ch=='-')
f=-1,ch=getchar();
while (isdigit(ch))
x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
return x*f;
}
const int N=100005;
int n,A[N],in[N];
vector <int> e[N];
vector <LL> v[N];
LL solve(int x,int pre){
vector <LL> &a=v[x];
for (auto y : e[x])
if (y!=pre)
a.push_back(solve(y,x));
if (a.empty())
return A[x];
sort(a.begin(),a.end());
if (!~*a.begin())
return -1;
reverse(a.begin(),a.end());
LL tot=0;
for (auto y : a)
tot+=y;
LL mx=min((LL)A[x],min(*a.begin(),tot-*a.begin()));
LL Need=tot-A[x];
return Need>mx?-1:(A[x]-Need);
}
int main(){
srand('C'+'L'+'Y'+'A'+'K');
n=read();
for (int i=1;i<=n;i++)
A[i]=read();
for (int i=1;i<=n;i++)
e[i].clear();
for (int i=1;i<n;i++){
int a=read(),b=read();
e[a].push_back(b);
e[b].push_back(a);
in[a]++,in[b]++;
}
if (n==2)
return puts(A[1]==A[2]?"YES":"NO"),0;
vector <int> rt;
for (int i=1;rt.size()<15&&i<=n;i++)
if (in[i]>1)
rt=i;
int flag=0;
for (auto RT : rt)
flag|=solve(RT,0)==0;
puts(flag?"YES":"NO");
return 0;
} | a.cc: In function 'int main()':
a.cc:55:28: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'int')
55 | rt=i;
| ^
In file included from /usr/include/c++/14/vector:72,
from /usr/include/c++/14/functional:64,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
from a.cc:1:
/usr/include/c++/14/bits/vector.tcc:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]'
210 | vector<_Tp, _Alloc>::
| ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:211:42: note: no known conversion for argument 1 from 'int' to 'const std::vector<int>&'
211 | operator=(const vector<_Tp, _Alloc>& __x)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/14/vector:66:
/usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]'
766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
| ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:766:26: note: no known conversion for argument 1 from 'int' to 'std::vector<int>&&'
766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
| ~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]'
788 | operator=(initializer_list<value_type> __l)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:788:46: note: no known conversion for argument 1 from 'int' to 'std::initializer_list<int>'
788 | operator=(initializer_list<value_type> __l)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
|
s823454651 | p03809 | C++ | #include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define int long long
typedef pair<int, int> ii;
const int N = 1e5 + 5;
int n, a[N], x[N], y[N], root;
vector<int> graph[N];
void dfs(int u,int p){
if(graph[u].size() == 1){
y[u] = a[u];
return ;
}
for(int i = 0; i < graph[u].size(); i++){
int v = graph[u][i];
if(v != p)
dfs(v, u);
}
int sum = 0;
for(int i = 0; i < graph[u].size(); i++){
int v = graph[u][i];
if(v != p)
sum += y[v];
}
x[u] = sum - a[u], y[u] = 2 * a[u] - sum;
if(x[u] >= 0 && y[u] >= 0){
}
else{
cout << "NO\n";
exit(0);
}
}
signed main() {
cin.tie(0), ios::sync_with_stdio(0);
cin >> n;
for(int i = 1; i <= n; i++)
cin >> a[i];
for(int i = 1; i <= n - 1; i++){
int u, v;
cin >> u >> v;
graph[u].pb(v);
graph[v].pb(u);
}
if(n == 2){
if(a[1] != a[2])
cout << "NO\n";
else
cout << "YES\n";
exit(0);
}
int mx = -1, root ;
for(int i = 1; i <= n; i++){
if(graph[i].size() >= 2){
if(graph[i].size() > mx){
mx = max(mx, graph[i].size());
root = i;
}
}
}
dfs(root, root);
if(y[root] != 0){
cout << "NO\n";
exit(0);
}
cout << "YES\n";
}
| a.cc: In function 'int main()':
a.cc:65:25: error: no matching function for call to 'max(long long int&, std::vector<long long int>::size_type)'
65 | mx = max(mx, graph[i].size());
| ~~~^~~~~~~~~~~~~~~~~~~~~
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:65:25: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'})
65 | mx = max(mx, graph[i].size());
| ~~~^~~~~~~~~~~~~~~~~~~~~
/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:65:25: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
65 | mx = max(mx, graph[i].size());
| ~~~^~~~~~~~~~~~~~~~~~~~~
|
s162229525 | p03809 | C++ | /*+lmake
* STD = c++14
* DEFINE += WAAUTOMATON
*/
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#ifdef WAAUTOMATON
#define debug(args...) \
{ \
dbg, args; \
cerr << endl; \
}
#define massert(x) assert(x)
#else
#define debug(args...) // Just strip off all debug tokens
#define massert(x)
#endif
struct debugger
{
template<typename T> debugger& operator , (const T& v)
{
cerr<<v<<" ";
return *this;
}
} dbg;
#define MAXN 100000
void [[noreturn]] out(int t=0)
{
debug(t);
puts("NO");
exit(0);
}
LL a[MAXN+10];
struct Edge
{
int to,next;
}e[2*MAXN+10];
int head[MAXN+10];
void addEdge(int a,int b)
{
static int c=0;
e[++c]=(Edge){b,head[a]};
head[a]=c;
e[++c]=(Edge){a,head[b]};
head[b]=c;
}
LL dp(int now,int fa)
{
LL sum=0;
int mx=0;
for(int i=head[now]; i!=0; i=e[i].next) {
int v=e[i].to;
if (v==fa) continue;
LL son=dp(v,now);
mx=max(mx,son);
sum+=son;
}
if (mx==0) return a[now];
//debug(now,a[now],sum);
if (a[now]>sum || sum>2*a[now]) out(1);
LL t=sum-a[now];
if ((sum-mx)<t) out(2);
return 2*a[now]-sum;
}
int main(){
#ifdef WAAUTOMATON
freopen("in.txt","r",stdin);
#endif
int n;
cin>>n;
for(int i=1; i<=n; ++i) {
cin>>a[i];
}
for(int i=1; i<n; ++i) {
int x,y;
cin>>x>>y;
addEdge(x,y);
}
LL x=dp(1,0);
//if (x!=a[1]) out(3);
puts("YES");
return 0;
}
| a.cc:30:6: warning: attribute ignored [-Wattributes]
30 | void [[noreturn]] out(int t=0)
| ^
a.cc:30:6: note: an attribute that appertains to a type-specifier is ignored
a.cc: In function 'LL dp(int, int)':
a.cc:58:23: error: no matching function for call to 'max(int&, LL&)'
58 | mx=max(mx,son);
| ~~~^~~~~~~~
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:5:
/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:58:23: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'LL' {aka 'long long int'})
58 | mx=max(mx,son);
| ~~~^~~~~~~~
/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:58:23: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
58 | mx=max(mx,son);
| ~~~^~~~~~~~
|
s000343878 | p03809 | C++ | #include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-3;
int dx[4]={0,1,0,1};
int dy[4]={0,0,1,1};
vector<int> G[100010];
ll a[100010];
bool ans;
void dfs(int v,int p){
ll sum=0;
ll ma=0;
if(G[v].size()==1)return;
for(auto e:G[v]){
if(e==p)continue;
dfs(e,v);
sum+=a[e];
ma=max(ma,a[e]);
}
if(a[v]>sum){
ans=false;
}else if(a[v]<sum){
if(ma>a[v]){
ans=false;
}
if((sum-a[v])*2LL>sum){
ans=false;
}else{
a[v]=sum-(sum-a[v])*2LL;
}
}
}
int main(){
ans=true;
int n;cin>>n;
for(int i=0;i<n;i++){
cin>>a[i];]
}
if(n==2){
if(a[0]!=a[1]){
cout<<"NO"<<endl;
}else{
cout<<"YES"<<endl;
}
return 0;
}
for(int i=0;i<n-1;i++){
int a,b;cin>>a>>b;a--;b--;
G[a].push_back(b);
G[b].push_back(a);
}
int v;
for(int i=0;i<n;i++){
if(G[i].size()!=1){
v=i;
break;
}
}
dfs(v,-1);
if(a[v])ans=false;
if(ans){
cout<<"YES"<<endl;
}else{
cout<<"NO"<<endl;
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:43:27: error: expected primary-expression before ']' token
43 | cin>>a[i];]
| ^
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.