submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s100676728
p03948
C++
#include <bits/stdc++.h> #include<iostream> #include<cstdio> #include<vector> #include<queue> #include<map> #include<cstring> #include<string> #include <math.h> #include<algorithm> // #include <boost/multiprecision/cpp_int.hpp> #include<functional> #define int long long #define inf 1000000007 #define pa pair<int,int> #define ll long long #define pal pair<ll,ll> #define ppa pair<int,pa> #define mp make_pair #define EPS (1e-10) #define equals(a,b) (fabs((a)-(b))<EPS) using namespace std; class Point{ public: double x,y; Point(double x=0,double y=0):x(x),y(y) {} Point operator + (Point p) {return Point(x+p.x,y+p.y);} Point operator - (Point p) {return Point(x-p.x,y-p.y);} Point operator * (double a) {return Point(x*a,y*a);} Point operator / (double a) {return Point(x/a,y/a);} double absv() {return sqrt(norm());} double norm() {return x*x+y*y;} bool operator < (const Point &p) const{ return x != p.x ? x<p.x: y<p.y; } bool operator == (const Point &p) const{ return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS; } }; typedef Point Vector; struct Segment{ Point p1,p2; }; double hen(Vector a){ if(fabs(a.x)<EPS && a.y>0) return acos(0); else if(fabs(a.x)<EPS && a.y<0) return 3*acos(0); else if(fabs(a.y)<EPS && a.x<0) return 2*acos(0); else if(fabs(a.y)<EPS && a.x>0) return 0.0; else if(a.y>0) return acos(a.x/a.absv()); else return 2*acos(0)+acos(-a.x/a.absv()); } double dot(Vector a,Vector b){ return a.x*b.x+a.y*b.y; } double cross(Vector a,Vector b){ return a.x*b.y-a.y*b.x; } //----------------kokomade temple------------ int n,m,k,x,t; int N=262144; int q[100002]={0}; int qq[100002]={0}; pa sgt[530000]; pa minis(int i,int j ){ if(i==j) return sgt[i]; else if(i%2==1){ pa z=minis(i+1,j); if(sgt[i].first>z.first)return sgt[i] ; else return z; } else if(j%2==0) { pa z=minis(i,j-1); if(sgt[j].first>z.first)return sgt[j] ; else return z; } else return minis(i/2,j/2); } pa sgtmin(int i ,int j) { return minis(i+N,j+N); } void upd(int x,int y){ x+=N; sgt[x].first=y; sgt[x].second=x; x=x/2; while(x != 0){ if(sgt[2*x+1].first>sgt[2*x].first){ sgt[x]=sgt[2*x+1]; } else sgt[x]=sgt[2*x]; x=x/2; } } signed main(){ cin>>n>>t; for(int i=N;i<2*N;i++) sgt[i]=make_pair(0,i-N); for(int i=N;i<N+n;i++){ cin>>x; use[x]=1; sgt[i].first=x; } for(int i=N-1;i>0;i--){ if(sgt[2*i].first<sgt[2*i+1].first) sgt[i]=sgt[2*i+1]; else sgt[i]=sgt[2*i]; } int ma=0; vector<pa> ve; for(int i=0;i<n;i++){ m=sgtmin(i+1,N-1).first; m -= sgt[N+i].first; int z=sgtmin(i+1,N-1).second; if(m>ma){ ve.clear(); ve.push_back(mp(i,z)); } else if(m==ma){ ve.push_back(mp(i,z)); } ma=max(ma,m); } for(int i=0;i<ve.size();i++){ // cout<<ve[i].first<<" "<<ve[i].second<<endl; ve[i].first++; ve[i].second++; // cout<<ve[i].first<<" "<<ve[i].second<<endl; q[ve[i].first]=ve[i].second; qq[ve[i].second]=ve[i].first; } // for(int i=0;i<10;i++) cout<<" "<<q[i]<<" "<<qq[i]<<endl; int ans=0; for(int i=0;i<100002;i++){ int num; if(q[i]!=0 && qq[i]==0){ int e=i; num=0; while(num<3){ // cout<<e<<endl; e=q[e]; // cout<<e<<endl; num++; // cout<<"qe= "<<q[e]<<endl; if(q[e]==0) break; } ans += num*(num+1)/2; } // ans += num*(num+1)/2; } cout<<ans<<endl; // printf("%.10f\n",ans); return 0; }
a.cc: In function 'int main()': a.cc:117:17: error: 'use' was not declared in this scope 117 | use[x]=1; | ^~~
s267265634
p03948
C++
3 2 100 50 200
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 3 2 | ^
s147597477
p03948
C++
#include <bits/stdc++.h> //#include <boost/functional/hash.hpp> //example: unordered_set< pair<int,int>,boost::hash< std::pair<int, int> > > used; //priority_queue< pair<int,pair<int,int> >, vector<pair<int,pair<int,int>>>, greater<pair<int,pair<int,int> > > > pqueue; //cost, vertex(行き先) using namespace std; #define MODULE 1000000007 #define MP make_pair #define ALL(v) (v).begin(),(v).end() #define fi first #define se second template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;} template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;} template<typename A, size_t N, typename T> inline void Fill(A (&array)[N], const T &val){ //usage: int dp[10][10]; Fill(dp,INF); std::fill( (T*)array, (T*)(array+N), val ); } typedef pair<int, int> P; typedef long long LL; const int INF = INT_MAX / 2; //int_max->2*e+9 LLの時はLLONG_MAX /*const int MAXN = 100001; struct edge { edge(int to, int cost) : to(to), cost(cost) {} int to, cost; }; vector<edge> graph[MAXN]; int dx[4] = {-1, 0, 1, 0}; int dy[4] = {0, -1, 0, 1};*/ //-----Template--------- LL n,t; LL a[100001]; LL maxA=INF; LL maxDiff=INF; LL count=0; int main(){ ios::sync_with_stdio(false); //cout<< fixed << setprecision(10); cin>>n>>t; for (int i = 0; i < n; ++i) { cin>>a[i]; } if(n==1){ cout<<1<<endl; return 0; } maxA=a[n-1]; for (int i = n-2; i >=0 ; --i) { if(maxDiff<(maxA-a[i])){ count=1; maxDiff=maxA-a[i]; }else if(maxDiff==(maxA-a[i])){ count++; } if(maxA<a[i]){ maxA=a[i]; } } cout<<count<<endl; }
a.cc: In function 'int main()': a.cc:52:13: error: reference to 'count' is ambiguous 52 | count=1; | ^~~~~ In file included from /usr/include/c++/14/algorithm:86, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)' 101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value); | ^~~~~ In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:4025:5: note: 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)' 4025 | count(_InputIterator __first, _InputIterator __last, const _Tp& __value) | ^~~~~ a.cc:38:4: note: 'LL count' 38 | LL count=0; | ^~~~~ a.cc:55:13: error: reference to 'count' is ambiguous 55 | count++; | ^~~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)' 101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value); | ^~~~~ /usr/include/c++/14/bits/stl_algo.h:4025:5: note: 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)' 4025 | count(_InputIterator __first, _InputIterator __last, const _Tp& __value) | ^~~~~ a.cc:38:4: note: 'LL count' 38 | LL count=0; | ^~~~~ a.cc:62:11: error: reference to 'count' is ambiguous 62 | cout<<count<<endl; | ^~~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)' 101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value); | ^~~~~ /usr/include/c++/14/bits/stl_algo.h:4025:5: note: 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)' 4025 | count(_InputIterator __first, _InputIterator __last, const _Tp& __value) | ^~~~~ a.cc:38:4: note: 'LL count' 38 | LL count=0; | ^~~~~
s202134194
p03948
C++
#include <iostream> using namespace std; int town[100000]; int dis[100000]; int max=0; int price=0; int N; int apple; int ans; int main() { cin >> N >> apple; for (int i = 0; i < N; i++) { cin >> town[i]; } for (int i = N - 1; i >= 0; i--) { dis[i] = max - town[i]; if (max < town[i])max = town[i]; } dis[N - 1] = 0; for (int i = 0; i < N; i++) { if (price < dis[i])price = dis[i]; } for (int i = 0; i < N; i++) { if (dis[i] == price)ans++; } cout << ans << "\n"; return 0; }
a.cc: In function 'int main()': a.cc:18:26: error: reference to 'max' is ambiguous 18 | dis[i] = max - town[i]; | ^~~ 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:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:6:5: note: 'int max' 6 | int max=0; | ^~~ a.cc:19:21: error: reference to 'max' is ambiguous 19 | if (max < town[i])max = town[i]; | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:6:5: note: 'int max' 6 | int max=0; | ^~~ a.cc:19:35: error: reference to 'max' is ambiguous 19 | if (max < town[i])max = town[i]; | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:6:5: note: 'int max' 6 | int max=0; | ^~~
s863737547
p03949
C++
from collections import defaultdict, deque, Counter from heapq import heappush, heappop, heapify import math import bisect import random from itertools import permutations, accumulate, combinations, product import sys import string from bisect import bisect_left, bisect_right from math import factorial, ceil, floor, cos, radians, pi, sin from operator import mul from functools import reduce from operator import mul mod = 10 ** 9 + 7 sys.setrecursionlimit(2147483647) INF = 10 ** 13 def LI(): return list(map(int, sys.stdin.buffer.readline().split())) def I(): return int(sys.stdin.buffer.readline()) def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split() def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8') def IR(n): return [I() for i in range(n)] def LIR(n): return [LI() for i in range(n)] def SR(n): return [S() for i in range(n)] def LSR(n): return [LS() for i in range(n)] def SRL(n): return [list(S()) for i in range(n)] def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)] n = I() G = [[] for _ in range(n)] for _ in range(n - 1): a, b = LI() G[a - 1] += [b - 1] G[b - 1] += [a - 1] cond = [(-INF, INF) for _ in range(n)] k = I() for _ in range(k): v, p = LI() cond[v - 1] = (p, p) ans = [0] * n visited = [0] * n def f(u): visited[u] = 1 max_ret = cond[u][1] min_ret = cond[u][0] u_flg = max_ret % 2 if max_ret == min_ret else -1 for v in G[u]: if visited[v]: continue x, y, flg = f(v) if flg != -1 and u_flg == flg: print("No") exit() max_ret = min(max_ret, y + 1) min_ret = max(min_ret, x - 1) if min_ret > max_ret: print("No") exit() cond[u] = (max_ret, min_ret) return min_ret, max_ret, u_flg f(0) print("Yes") visited = [0] * n ans = [-1] * n ans[0] = cond[0][0] def f2(u): visited[u] = 1 for v in G[u]: if visited[v]: continue ans[v] = ans[u] + 1 if cond[v][0] <= ans[u] + 1 <= cond[v][1] else ans[u] - 1 f2(v) f2(0) print(*ans, sep="\n")
a.cc:20:62: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes 20 | def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split() | ^~~~~~~ a.cc:21:61: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes 21 | def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8') | ^~~~~~~ a.cc:1:1: error: 'from' does not name a type 1 | from collections import defaultdict, deque, Counter | ^~~~
s286212340
p03949
C++
#define ONLINE_JUDGE #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll> vl; typedef vector<vl> vvl; typedef pair<ll,ll> pl; typedef vector<pl> vp; const ll INF=1001001001; const ll LINF=1001001001001001001; const ll D4[]={0,1,0,-1,0}; const ll D8[]={0,1,1,0,-1,-1,1,-1,0}; #define _overload3(_1,_2,_3,name,...) name #define _rep2(i,n) for(ll i=0;i<(n);++i) #define _rep3(i,a,b) for(ll i=(a);i<(b);++i) #define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__) #define _repe2(i,n) for(ll i=0;i<=(n);++i) #define _repe3(i,a,b) for(ll i=(a);i<=(b);++i) #define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__) #define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--) #define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--) #define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__) #define all(x) (x).begin(),(x).end() template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;} template<class T> bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;} template<class T> using pq=priority_queue<T,vector<T>,greater<T>>; const string YES = "Yes"; const string NO = "No"; ll N; vl A; vl B; ll K; vl V; vl P; void solve(); int main(){ cin.tie(0); ios::sync_with_stdio(0); cin >> N; A = vl(N-1); B = vl(N-1); for(int i = 0; i < N-1; ++i){ cin >> A[i]; cin >> B[i]; } cin >> K; V = vl(K); P = vl(K); for(int i = 0; i < K; ++i){ cin >> V[i]; cin >> P[i]; } solve(); } // 1 ≦ N ≦ 10^5 // 1 ≦ K ≦ N // 1 ≦ A_i, B_i ≦ N (1 ≦ i ≦ N - 1) // 1 ≦ V_j ≦ N (1 ≦ j ≦ K) (21:18, 制約の誤記を修正) // 0 ≦ P_j ≦ 10^6 (1 ≦ j ≦ K) // 与えられるグラフは木になることが保証される // V_j はすべて相異なる vvl g; vl a,mx,mi,ans; void dfs2(ll x=0,ll p=0){ for(ll to:g[x]){ if(to==p)continue; if(ans[to]!=-1){ if(ans[to]<mi[to]||mx[to]<ans[to])){ cout<<NO<<endl; exit(0); } continue; } if(mi[to]<=ans[x]+1&&ans[x]+1<=mx[to])ans[to]=ans[x]+1; else if(mi[to]<=ans[x]-1&&ans[x]-1<=mx[to])ans[to]=ans[x]-1; else { cout<<NO<<endl; exit(0); } dfs2(to,x); } } void dfs(ll x=0,ll p=-1){ for(ll to:g[x]){ if(to==p)continue; dfs(to,x); chmin(mx[x],mx[to]+1); chmax(mi[x],mi[to]-1); } if(a[x]==-1&&x!=0)return; if(a[x]!=-1){ ans[x]=a[x]; mx[x]=mi[x]=a[x]; }else{ ans[x]=mx[x]; } dfs2(x,p); } // ll N, vl A, vl B, ll K, vl V, vl P // 残りのすべての頂点に書き込む整数を工夫することで木が条件を満たすようにできるならば Yes を、できないならば No を出力せよ。 // 条件を満たせる場合、追加で N 行出力せよ。このうちの v (1 ≦ v ≦ N) 行目には、頂点 v に書かれる整数を出力せよ。条件を満たすような整数の書き込み方が複数ある場合、そのうちいずれかひとつを出力すればよい。 void solve(){ g.resize(N); rep(i,N-1){ g[A[i]-1].push_back(B[i]-1); g[B[i]-1].push_back(A[i]-1); } mx.resize(N,INF); mi.resize(N,0); a.resize(N,-1); ans.resize(N,-1); rep(i,K)a[V[i]-1]=P[i]; dfs(); cout<<YES<<endl; rep(i,N)cout<<ans[i]<<endl; }
a.cc: In function 'void dfs2(ll, ll)': a.cc:77:47: error: expected primary-expression before ')' token 77 | if(ans[to]<mi[to]||mx[to]<ans[to])){ | ^
s199966547
p03949
C++
#include <bits/stdc++.h> using namespace std; const long long N = 100010; vector<long long> g[N]; long long a[N]; void ini() { for(long long i = 0; i < N; i++) { a[i] = -1; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; //cin >> t; while(t--) { ini(); long long n; cin >> n; for(long long i = 1; i < n; i++) { long long v, u; cin >> v >> u; g[v].push_back(u); g[u].push_back(v); } long long k, root; cin >> k; priority_queue<pair<long long, long long>, vector<pair<long long, long long> >, greater<pair<long long, long long> > >pq; for(long long i = 1; i <= k; i++) { long long idx, x; cin >> idx >> x; a[idx] = x; pq.push({x, idx}); } while(!pq.empty()) { pair<long long, long long> p = pq.top(); pq.pop(); long long x = p.first, y = p.second; for(long long i = 0; i < g[y].size(); i++) { if(a[i] == -1) { a[i] = x + 1; pq.push({x + 1, i}); } else if(a[z] != 0) { if(abs(a[i] - x) != 1) { cout << "No" << endl; return 0; } } } } cout << "Yes" << endl;; for(long long i = 1; i <= n; i++){ cout << a[i] << endl; } } return 0; }
a.cc: In function 'int main()': a.cc:48:27: error: 'z' was not declared in this scope 48 | else if(a[z] != 0) { | ^
s871264193
p03949
C++
#include<iostream> #include<vector> #include<algorithm> #include<string> #include<queue> using namespace std; #define int long long const int INF = (1e18); const int MOD = 1000000007; signed main(){ // cin.tie(0); // ios::sync_with_stdio(false); bool flag = true; int N, K; vector<int> dis; vector<vector<int>> tree; vector<pair<int,int>> P; priority_queue<pair<pair<int,int>,pair<int,int>>,vector<pair<pair<int,int>,pair<int,int>>>, greater<pair<pair<int,int>,pair<int,int>>>> Q; priority_queue<pair<int,int>,vector<pair<int,int>>, greater<pair<int,int>>> Q2; cin>>N; tree.resize(N); P.resize(N, {INF,INF}); dis.resize(N,INF); for(int i = 0; i < N-1; i++){ int a, b; cin>>a>>b; a--, b--; tree[a].push_back(b); tree[b].push_back(a); } cin>>K; for(int i = 0; i < K; i++){ int v, p; cin>>v>>p; v--; dis[v] = p; P[v] = {p,p}; Q.push({{0,v},{p,p}}); Q2.push({p,v}); } while(Q2.size()){ pair<int,int> p = Q2.top(); Q2.pop(); int now = p.second, d = p.first; // cout<<"d "<<d<<" now "<<now<<endl; if(dis[now] < d) continue; // cout<<"{}{} "<<endl; for(int next : tree[now]){ if(dis[next] > d + 1) { dis[next] = d + 1; // cout<<"d + 1 "<<d+1<<" next "<<next<<endl; Q2.push({d+1,next}); } } } for(int i = 0; i < N; i++){ P[i] = {dis[i], dis[i]}; } // cout<<"Z"<<endl; for(int i = 0; i < N; i++){ for(int node : tree[i]){ if(abs(dis[i] - dis[node]) != 1) { flag = false; } } if(P[i] != dis[i]) flag = false; } if(flag == false) { cout<<"No"<<endl; return 0; } cout<<"Yes"<<endl; for(int i = 0; i < N; i++){ cout<<P[i].first<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:83:19: error: no match for 'operator!=' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}) 83 | if(P[i] != dis[i]) flag = false; 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:197:5: note: candidate: 'template<class _StateT> bool std::operator!=(const fpos<_StateT>&, const fpos<_StateT>&)' 197 | operator!=(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/postypes.h:197:5: note: template argument deduction/substitution failed: a.cc:83:27: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} is not derived from 'const std::fpos<_StateT>' 83 | if(P[i] != dis[i]) flag = false; | ^ 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:243:5: note: candidate: 'template<class _T1, class _T2> bool std::operator!=(const allocator<_CharT>&, const allocator<_T2>&)' 243 | operator!=(const allocator<_T1>&, const allocator<_T2>&) | ^~~~~~~~ /usr/include/c++/14/bits/allocator.h:243:5: note: template argument deduction/substitution failed: a.cc:83:27: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} is not derived from 'const std::allocator<_CharT>' 83 | if(P[i] != dis[i]) flag = false; | ^ In file included from /usr/include/c++/14/string:48: /usr/include/c++/14/bits/stl_iterator.h:455:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 455 | operator!=(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:455:5: note: template argument deduction/substitution failed: a.cc:83:27: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} is not derived from 'const std::reverse_iterator<_Iterator>' 83 | if(P[i] != dis[i]) flag = false; | ^ /usr/include/c++/14/bits/stl_iterator.h:500:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 500 | operator!=(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:500:5: note: template argument deduction/substitution failed: a.cc:83:27: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} is not derived from 'const std::reverse_iterator<_Iterator>' 83 | if(P[i] != dis[i]) flag = false; | ^ /usr/include/c++/14/bits/stl_iterator.h:1686:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1686 | operator!=(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1686:5: note: template argument deduction/substitution failed: a.cc:83:27: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} is not derived from 'const std::move_iterator<_IteratorL>' 83 | if(P[i] != dis[i]) flag = false; | ^ /usr/include/c++/14/bits/stl_iterator.h:1753:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1753 | operator!=(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1753:5: note: template argument deduction/substitution failed: a.cc:83:27: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} is not derived from 'const std::move_iterator<_IteratorL>' 83 | if(P[i] != dis[i]) flag = false; | ^ 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:1052:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator!=(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1052 | operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1052:5: note: template argument deduction/substitution failed: a.cc:83:27: note: mismatched types 'const std::pair<_T1, _T2>' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} 83 | if(P[i] != dis[i]) flag = false; | ^ 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:651:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 651 | operator!=(basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:651:5: note: template argument deduction/substitution failed: a.cc:83:27: note: 'std::pair<long long int, long long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 83 | if(P[i] != dis[i]) flag = false; | ^ /usr/include/c++/14/string_view:658: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> >)' 658 | operator!=(basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:658:5: note: template argument deduction/substitution failed: a.cc:83:27: note: 'std::pair<long long int, long long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 83 | if(P[i] != dis[i]) flag = false; | ^ /usr/include/c++/14/string_view:666: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>)' 666 | operator!=(__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:666:5: note: template argument deduction/substitution failed: a.cc:83:27: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'long long int' 83 | if(P[i] != dis[i]) flag = false; | ^ /usr/include/c++/14/bits/basic_string.h:3833: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>&)' 3833 | operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3833:5: note: template argument deduction/substitution failed: a.cc:83:27: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 83 | if(P[i] != dis[i]) flag = false; | ^ /usr/include/c++/14/bits/basic_string.h:3847:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3847 | operator!=(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3847:5: note: template argument deduction/substitution failed: a.cc:83:27: note: mismatched types 'const _CharT*' and 'std::pair<long long int, long long int>' 83 | if(P[i] != dis[i]) flag = false; | ^ /usr/include/c++/14/bits/basic_string.h:3860:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3860 | operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3860:5: note: template argument deduction/substitution failed: a.cc:83:27: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 83 | if(P[i] != dis[i]) flag = false; | ^ In file in
s590793812
p03949
C++
void dfsr(int now,int p){ ll ma = ans[now] + 1; ll mi = ans[now] - 1; fore(x, E[now]) { if (x != p) { if ((rec[now].first <= mi) && (mi <= rec[now].second))ans[x] = mi; else ans[x] = ma; dfsr(x, now); } } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; for (int i = 0; i < N-1; i++) { int a, b; cin >> a >> b; a--, b--; E[a].pb(b); E[b].pb(a); } int K; cin >> K; for (int i = 0; i < K; i++) { int v, p; cin >> v >> p; v--; num[v] = p; parity[v] = p % 2; } dfs(0,-1); ans[0] = rec[0].first; dfsr(0,-1); puts("Yes"); for (int i = 0; i < N; i++)puts(ans[i]); return 0; }
a.cc: In function 'void dfsr(int, int)': a.cc:3:9: error: 'll' was not declared in this scope 3 | ll ma = ans[now] + 1; | ^~ a.cc:4:11: error: expected ';' before 'mi' 4 | ll mi = ans[now] - 1; | ^~~ | ; a.cc:5:14: error: 'x' was not declared in this scope 5 | fore(x, E[now]) { | ^ a.cc:5:17: error: 'E' was not declared in this scope 5 | fore(x, E[now]) { | ^ a.cc:5:9: error: 'fore' was not declared in this scope 5 | fore(x, E[now]) { | ^~~~ a.cc: In function 'int main()': a.cc:15:9: error: 'ios' has not been declared 15 | ios::sync_with_stdio(false); | ^~~ a.cc:16:9: error: 'cin' was not declared in this scope 16 | cin.tie(nullptr); | ^~~ a.cc:24:17: error: 'E' was not declared in this scope 24 | E[a].pb(b); | ^ a.cc:33:17: error: 'num' was not declared in this scope; did you mean 'enum'? 33 | num[v] = p; | ^~~ | enum a.cc:34:17: error: 'parity' was not declared in this scope 34 | parity[v] = p % 2; | ^~~~~~ a.cc:37:9: error: 'dfs' was not declared in this scope; did you mean 'dfsr'? 37 | dfs(0,-1); | ^~~ | dfsr a.cc:38:9: error: 'ans' was not declared in this scope 38 | ans[0] = rec[0].first; | ^~~ a.cc:38:18: error: 'rec' was not declared in this scope 38 | ans[0] = rec[0].first; | ^~~ a.cc:40:9: error: 'puts' was not declared in this scope 40 | puts("Yes"); | ^~~~
s511775350
p03949
C++
#include <bits/stdc++.h> #define pb push_back #define int long long #define mp make_pair #define inf 1000000007 #define ll long long using namespace std; struct edge{int to,cap,rev;}; vector<int> nex[114514]; int mi[114514],ma[114514],st; int col[114514]; int used[114514]; int ans[114514]; int used2[114514]; bool fl = true; pair<int,int> dfs(int s){ used[s]=1; for(int i=0;i<nex[s].size();i++){ int nx = nex[s][i]; if(used[nx]==0){ pair<int,int> P = dfs(nx); int lef = max(P.first-1,0LL); int rig = P.second+1; ma[s] = min(ma[s],rig); mi[s] = max(mi[s],lef); } } //cout<<2<<endl; return mp(mi[s],ma[s]); } signed main(){ int n; cin>>n; for(int i=0;i<n-1;i++){ int x,y; cin>>x>>y; nex[x].pb(y); nex[y].pb(x); } for(int i=1;i<=n;i++){ mi[i]=0; ma[i]=inf; } int m; cin>>m; for(int i=0;i<m;i++){ int v,p; cin>>v>>p; mi[v] = p; ma[v] = p; col[v] = 2 - p%2; if(st == 0)st = v; } queue<int> que; que.push(st); while(!que.empty()){ int idx = que.front(); que.pop(); for(int i=0;i<nex[idx].size();i++){ int nx = nex[idx][i]; if( col[nx] == 0){ col[nx] = 3 -col[idx]; que.push(nx); } else if(col[idx] + col[nx] != 3){ cout<<"No"<<endl; return 0; } } //cout<<1<<endl; } pair<int,int> tmp = dfs(st); if(fl == false){ cout<<"No"<<endl; return 0; } for(int i=0;i<=n;i++){ ans[i]=-1; } while(!que.empty()){que.pop();} que.push(st); ans[st]=mi[st]; used2[st]=1; while(!que.empty()){ int idx = que.front(); que.pop(); for(int i=0;i<nex[idx].size();i++){ int nx = nex[idx][i]; if(used2[nx] == 0){ used2[nx]=1; if(mi[nx] <= ans[idx]-1 && ans[idx]-1 <= ma[nx]){ ans[nx] = ans[idx]-1; } else if(mi[nx] <= ans[idx]+1 && ans[idx]+1 <= ma[nx]){ ans[nx] = ans[idx]+1; } if(ans[nx] == -1){ cout<<"No"<<endl; return 0; } que.push(nx); } } } for(int i=1;i<=n;i++){ if(ans[i]==-1){ cout<<"No"<<endl; return 0; } cout<<"Yes"<<endl; for(int i=1;i<=n;i++){ cout<<ans[i]<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:114:2: error: expected '}' at end of input 114 | } | ^ a.cc:31:14: note: to match this '{' 31 | signed main(){ | ^
s996426122
p03949
C++
#include <bits/stdc++.h> #define pb push_back #define int long long #define mp make_pair #define inf 1000000007 #define ll long long using namespace std; struct edge{int to,cap,rev;}; vector<int> nex[114514]; int mi[114514],ma[114514],st; int col[114514]; int used[114514]; int ans[114514]; int used2[114514]; bool fl = true; pair<int,int> dfs(int s){ used[s]=1; for(int i=0;i<nex[s].size();i++){ int nx = nex[s][i]; if(used[nx]==0){ pair<int,int> P = dfs(nx); int lef = max(P.first-1,0LL); int rig = P.second+1; ma[s] = min(ma[s],rig); mi[s] = max(mi[s],lef); } } //cout<<2<<endl; return mp(mi[s],ma[s]); } signed main(){ int n; cin>>n; for(int i=0;i<n-1;i++){ int x,y; cin>>x>>y; nex[x].pb(y); nex[y].pb(x); } for(int i=1;i<=n;i++){ mi[i]=0; ma[i]=inf; } int m; cin>>m; for(int i=0;i<m;i++){ int v,p; cin>>v>>p; mi[v] = p; ma[v] = p; col[v] = 2 - p%2; if(st == 0)st = v; } queue<int> que; que.push(st); while(!que.empty()){ int idx = que.front(); que.pop(); for(int i=0;i<nex[idx].size();i++){ int nx = nex[idx][i]; if( col[nx] == 0){ col[nx] = 3 -col[idx]; que.push(nx); } else if(col[idx] + col[nx] != 3){ cout<<"No"<<endl; return 0; } } //cout<<1<<endl; } pair<int,int> tmp = dfs(st); if(fl == false){ cout<<"No"<<endl; return 0; } for(int i=0;i<=n;i++){ ans[i]=-1; } while(!que.empty()){que.pop();} que.push(st); ans[st]=mi[st]; used2[st]=1; while(!que.empty()){ int idx = que.front(); que.pop(); for(int i=0;i<nex[idx].size();i++){ int nx = nex[idx][i]; if(used2[nx] == 0){ used2[nx]=1; if(mi[nx] <= ans[idx]-1 && ans[idx]-1 <= ma[nx]){ ans[nx] = ans[idx]-1; } else if(mi[nx] <= ans[idx]+1 && ans[idx]+1 <= ma[nx]){ ans[nx] = ans[idx]+1; } if(ans[nx] == -1){ cout<<"No"<<endl; return 0; } que.push(nx); } } } for(int i=1;i<=n;i++){ if(ans[i]==-1){ cout<<<"No"<<endl; return 0; } } cout<<"Yes"<<endl; for(int i=1;i<=n;i++){ cout<<ans[i]<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:105:31: error: expected primary-expression before '<' token 105 | cout<<<"No"<<endl; | ^ a.cc:105:36: error: invalid operands of types 'const char [3]' and '<unresolved overloaded function type>' to binary 'operator<<' 105 | cout<<<"No"<<endl; | ~~~~^~~~~~
s158995863
p03949
C++
#include <bits/stdc++.h> using namespace std; #define X first #define Y second #define pb push_back typedef pair<int, int> ii; typedef long long ll; const int maxn = 1e5+5; vector<int> adj[maxn]; int has[maxn]; bool flex[maxn]; int pari[maxn]; int lb[maxn], rb[maxn]; int ans[maxn]; int n, k; bool solve(int u, int p) { // printf("solving %d\n", u); for(int v : adj[u]) { if(v == p) continue; if(!solve(v, u)) return false; } lb[u] = -1e9, rb[u] = 1e9; bool allflex = true; pari[u] = -1; for(int v : adj[u]) { if(v == p) continue; if(flex[v]) continue; allflex = false; if(pari[v] != -1 && pari[u] == -1) { pari[u] = 1-pari[v]; } else if(pari[v] != -1 && pari[u] == pari[v]) return false; lb[u] = max(lb[u], lb[v]-1); rb[u] = min(rb[u], rb[v]+1); } // printf("fin %d: [%d, %d] (%d)\n", u, lb[u], rb[u], pari[u]); if(lb[u]> rb[u]) return false; if(has[u] != -1) { if(!(lb[u]<= has[u] && has[u]<= rb[u])) return false; if(pari[u] != -1 && has[u]%2 != pari[u]) return false; lb[u] = rb[u] = has[u]; return true; } if(allflex) flex[u] = true; return true; } void recon(int u, int p) { if(p) { if(lb[u]<= ans[p]-1 && ans[p]-1<= rb[u]) ans[u] = ans[p]-1; else if(lb[u]<= ans[p]+1 && ans[p]+1<= rb[u]) ans[u] = ans[p]+1; else assert(false); } for(int v : adj[u]) { if(v == p) continue; recon(v, u); } } int main() { scanf("%d", &n); for(int i = 1; i<= n-1; i++) { int u, v; scanf("%d %d", &u, &v); adj[u].pb(v); adj[v].pb(u); } for(int i = 1; i<= n; i++) has[u] = -1; scanf("%d", &k); for(int i = 1; i<= k; i++) { int v, p; scanf("%d %d", &v, &p); has[v] = p; } if(!solve(1, 0)) { puts("No"); return 0; } ans[1] = lb[1]; recon(1, 0); puts("Yes"); for(int i = 1; i<= n; i++) printf("%d\n", ans[i]); }
a.cc: In function 'int main()': a.cc:83:40: error: 'u' was not declared in this scope 83 | for(int i = 1; i<= n; i++) has[u] = -1; | ^
s373189576
p03949
C++
#include <bits/stdc++.h> using namespace std; #define X first #define Y second #define pb push_back typedef pair<int, int> ii; typedef long long ll; const int maxn = 1e5+5; vector<int> adj[maxn]; int has[maxn]; bool flex[maxn]; int pari[maxn]; int lb[maxn], rb[maxn]; int ans[maxn]; int n, k; bool solve(int u, int p) { // printf("solving %d\n", u); for(int v : adj[u]) { if(v == p) continue; if(!solve(v, u)) return false; } lb[u] = -1e9, rb[u] = 1e9; bool allflex = true; pari[u] = -1; for(int v : adj[u]) { if(v == p) continue; if(flex(v)) continue; allflex = false; if(pari[v] != -1 && pari[u] == -1) { pari[u] = 1-pari[v]; } else if(pari[v] != -1 && pari[u] == pari[v]) return false; lb[u] = max(lb[u], lb[v]-1); rb[u] = min(rb[u], rb[v]+1); } // printf("fin %d: [%d, %d] (%d)\n", u, lb[u], rb[u], pari[u]); if(lb[u]> rb[u]) return false; if(has[u]) { if(!(lb[u]<= has[u] && has[u]<= rb[u])) return false; if(pari[u] != -1 && has[u]%2 != pari[u]) return false; lb[u] = rb[u] = has[u]; return true; } if(allflex) flex[u] = true; return true; } void recon(int u, int p) { if(p) { if(lb[u]<= ans[p]-1 && ans[p]-1<= rb[u]) ans[u] = ans[p]-1; else if(lb[u]<= ans[p]+1 && ans[p]+1<= rb[u]) ans[u] = ans[p]+1; else assert(false); } for(int v : adj[u]) { if(v == p) continue; recon(v, u); } } int main() { scanf("%d", &n); for(int i = 1; i<= n-1; i++) { int u, v; scanf("%d %d", &u, &v); adj[u].pb(v); adj[v].pb(u); } scanf("%d", &k); for(int i = 1; i<= k; i++) { int v, p; scanf("%d %d", &v, &p); has[v] = p; } if(!solve(1, 0)) { puts("No"); return 0; } ans[1] = lb[1]; recon(1, 0); puts("Yes"); for(int i = 1; i<= n; i++) printf("%d\n", ans[i]); }
a.cc: In function 'bool solve(int, int)': a.cc:37:24: error: 'flex' cannot be used as a function 37 | if(flex(v)) continue; | ~~~~^~~
s903137004
p03949
C++
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(ll (i) = (0);(i) < (n);++i) #define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i) #define PB push_back #define EB emplace_back #define MP make_pair #define FI first #define SE second #define SHOW1d(v,n) {REP(W,n)cerr << v[W] << ' ';cerr << endl << endl;} #define SHOW2d(v,i,j) {REP(aaa,i){REP(bbb,j)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;} #define ALL(v) v.begin(),v.end() #define Decimal fixed<<setprecision(20) #define INF 1000000000 #define LLINF 1000000000000000000LL #define MOD 1000000007 typedef long long ll; typedef pair<ll,ll> P; vector<vector<int>> v(111111); ll mpL[111111]; ll mpR[111111]; bool visited[111111] void dfs(int node, int pre,ll LL, ll RR){ //cout << node << " " << LL << " " << RR << endl; if(visited[node] && node != pre && mpL[node] >= LL && mpR[node] <= RR)return; visited[node] = true; mpL[node] = max(mpL[node], LL); mpR[node] = min(mpR[node], RR); if(mpL[node] > mpR[node])return; REP(i,v[node].size()){ if(v[node][i] == pre)continue; dfs(v[node][i], node, mpL[node] - 1, mpR[node] + 1); } } int main(){ int n;cin >> n; REP(i,n-1){ int a,b;cin >> a >> b; a--;b--; v[a].PB(b); v[b].PB(a); } REP(i,111111){ mpL[i] = -LLINF; mpR[i] = LLINF; } int k;cin >> k; vector<P> que; REP(i,k){ ll a,b;cin >> a >> b;a--; que.EB(a,b); mpL[a] = b; mpR[a] = b; } REP(i,k)dfs(que[i].FI, que[i].FI, que[i].SE, que[i].SE); bool flag = true; REP(i,n)if(mpL[i] > mpR[i])flag = false; if(!flag){ cout << "No" << endl; } else { cout << "Yes" << endl; REP(i,n)cout << mpR[i] << endl; } return 0; }
a.cc:28:1: error: expected initializer before 'void' 28 | void dfs(int node, int pre,ll LL, ll RR){ | ^~~~ a.cc: In function 'int main()': a.cc:64:17: error: 'dfs' was not declared in this scope; did you mean 'ffs'? 64 | REP(i,k)dfs(que[i].FI, que[i].FI, que[i].SE, que[i].SE); | ^~~ | ffs
s056035508
p03949
C++
#include <iostream> #include <fstream> #include <cstdio> #include <cassert> #include <complex> #include <cmath> #include <algorithm> #include <vector> #include <string> #include <cstdlib> #include <cstring> #include <iomanip> #include <numeric> #include <sstream> #include <ctime> #include <cctype> #include <set> #include <map> #include <queue> #include <bitset> #include <deque> #include <stack> #include <memory.h> using namespace std; typedef long long ll; #define mp make_pair vector<int> nei[100100]; priority_queue <pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > pq; int num[100005],ans=0;; bool dfs(int now, int par){ for(int i=0;i<nei[now].size();i++){ cout<<nei[now][i]<<endl; if(nei[now][i]==par){ continue; } if(abs(num[nei[now]]-num[nei[now][i])!=1){ return false; } if(!dfs(nei[now][i],now)){ return false; } } return true; } int main(){ int n; cin>>n; for(int i=0;i<n-1;i++){ int a,b; cin>>a>>b; a--,b--; nei[a].push_back(b); nei[b].push_back(a); } int m; cin>>m; memset(num,-1,sizeof(num)); for(int i=0;i<m;i++){ int a,val; cin>>a>>val; a--; num[a]=val; pq.push(mp(val,a)); } while(!pq.empty()){ pair<int,int> p=pq.top(); pq.pop(); int v=p.second; for(int i=0;i<nei[i].size();i++){ if(num[nei[v][i]]==-1){ num[nei[v][i]]=num[v]+1; pq.push(mp(num[nei[v][i]],nei[v][i])); } } } if(!dfs(0,-1)){ cout<<"No"; } else{ cout<<"Yes"<<endl; for(int i=0;i<n;i++){ cout<<num[i]<<endl; } } return 0; }
a.cc: In function 'bool dfs(int, int)': a.cc:36:27: error: no match for 'operator[]' (operand types are 'int [100005]' and 'std::vector<int>') 36 | if(abs(num[nei[now]]-num[nei[now][i])!=1){ | ^ a.cc:36:53: error: expected ']' before ')' token 36 | if(abs(num[nei[now]]-num[nei[now][i])!=1){ | ^ | ]
s305727754
p03949
C++
#include <iostream> #include <fstream> #include <cstdio> #include <cassert> #include <complex> #include <cmath> #include <algorithm> #include <vector> #include <string> #include <cstdlib> #include <cstring> #include <iomanip> #include <numeric> #include <sstream> #include <ctime> #include <cctype> #include <set> #include <map> #include <queue> #include <bitset> #include <deque> #include <stack> #include <memory.h> using namespace std; typedef long long ll; #define mp make_pair vector<int> a[100100]; priority_queue <pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > pq; int tag[100100],ans=0;; bool dfs(int now, int par){ for(int i=0;i<a[i].size();i++){ if(a[now][i]==par){ continue; } if(abs(tag[(-tag[a[now][i]])])!=1){ return false; } if(!dfs(a[now][i],now)){ return false; } } return true; } int main(){ int n; cin>>n; for(int i=0;i<n-1;i++){ int v,g; cin>>v>>g; v--,g--; a[v].push_back(g); a[g].push_back(v); } int m; cin>>m; memset(tag,-1,sizeof(tag)); for(int i=0;i<m;i++){ int v,g; cin>>v>>g; v--; tag[v]=g; pq.push(mp(g,v)); } while(!pq.empty()){ pair<int,int> p=pq.top(); pq.pop(); int v=p.second; for(int i=0;i<a[i].size();i++){ if(tag[a[v][i]]==-1){ tag[a[v][i]]=tag[v]+1; pq.push(mp(tag[a[v][i]],a[v][i])); } } } if(!dfs(0,-1)){ cout<<"No"; } else{ cout<<"Yes"<<endl; for(int i=0;i<n;i++){ cout<<tag[i]<<endl; } } return 0
a.cc: In function 'int main()': a.cc:84:17: error: expected ';' at end of input 84 | return 0 | ^ | ; a.cc:84:17: error: expected '}' at end of input a.cc:44:11: note: to match this '{' 44 | int main(){ | ^
s046221413
p03949
C++
#include <iostream> #include <fstream> #include <cstdio> #include <cassert> #include <complex> #include <cmath> #include <algorithm> #include <vector> #include <string> #include <cstdlib> #include <cstring> #include <iomanip> #include <numeric> #include <sstream> #include <ctime> #include <cctype> #include <set> #include <map> #include <queue> #include <bitset> #include <deque> #include <stack> #include <memory.h> using namespace std; typedef long long ll; #define mp make_pair vector<int> a[100100]; priority_queue<pair<int, int>,vector<pair<int, int> >,greater<pair<int, int> > > pq; int tag[100100]; bool dfs(int now, int par){ for(int i=0;i<a.size();i++){ if(a[now][i] == par) continue; if(abs(tag[-tag[a[now][i]]) != 1){ return false; } if(!dfs(a[now][i], now)){ return false; } } return true; } int main(){ int n; cin >> n; for(int i=0;i<n-1;i++){ int v, g; cin>>v>>g; v--, g--; a[v].push_back(g); a[g].push_back(v); } int m; cin>>m; memset(tag,-1,sizeof(tag)); for(int i=0;i<m;i++){ int v,g; cin>>v>>g; v--; tag[v]=g; pq.push(mp(g,v)); } while(!pq.empty()){ pair<int, int> p = pq.top(); pq.pop(); int v=p.second; for(int i=0;i<a.size();i++){ if(tag[a[v][i]] == -1){ tag[a[v][i]] = tag[v]+1; pq.push(mp(tag[a[v][i]],a[v][i])); } } } if(!dfs(0, -1)){ cout<<"No"; } else{ cout<<"Yes"<<endl; for(int i=0;i<n;i++){ cout<<tag[i]<<endl; } } return 0; }
a.cc: In function 'bool dfs(int, int)': a.cc:31:25: error: request for member 'size' in 'a', which is of non-class type 'std::vector<int> [100100]' 31 | for(int i=0;i<a.size();i++){ | ^~~~ a.cc:33:43: error: expected ']' before ')' token 33 | if(abs(tag[-tag[a[now][i]]) != 1){ | ^ | ] a.cc: In function 'int main()': a.cc:66:33: error: request for member 'size' in 'a', which is of non-class type 'std::vector<int> [100100]' 66 | for(int i=0;i<a.size();i++){ | ^~~~
s113688200
p03949
C++
#include <iostream> #include <fstream> #include <cstdio> #include <cassert> #include <complex> #include <cmath> #include <algorithm> #include <vector> #include <string> #include <cstdlib> #include <cstring> #include <iomanip> #include <numeric> #include <sstream> #include <ctime> #include <cctype> #include <set> #include <map> #include <queue> #include <bitset> #include <deque> #include <stack> #include <memory.h> using namespace std; typedef long long ll; #define mp make_pair vector<int> a[100100]; priority_queue<pair<int, int>,vector<pair<int, int> >,greater<pair<int, int> > > pq; int tag[100100]; bool dfs(int now, int par){ for(int i=0;i<a.size();i++){ if(a[now][i] == par) continue; if(abs(tag[-tag[a[now][i]]) != 1){ return false; } if(!dfs(a[now][i], now)){ return false; } } return true; } int main(){ int n; cin >> n; for(int i=0;i<n-1;i++){ int v, g; cin>>v>>g; v--, g--; a[v].push_back(g); a[g].push_back(v); } int m; cin>>m; memset(tag,-1,sizeof(tag)); for(int i=0;i<m;i++){ int v,g; cin>>v>>g; v--; tag[v]=g; pq.push(mp(g,v)); } while(!pq.empty()){ pair<int, int> p = pq.top(); pq.pop(); int v=p.second; for(int i=0;i<a.size();i++){ if(tag[a[v][i]] == -1){ tag[a[v][i]] = tag[v]+1; pq.push(mp(tag[a[v][i]],a[v][i])); } } } if(!dfs(0, -1)){ cout<<"No"; } else{ cout<<"Yes"<<endl; for(int i=0;i<n;i++){ cout<<tag[i]<<endl; } } return 0; }
a.cc: In function 'bool dfs(int, int)': a.cc:31:25: error: request for member 'size' in 'a', which is of non-class type 'std::vector<int> [100100]' 31 | for(int i=0;i<a.size();i++){ | ^~~~ a.cc:33:43: error: expected ']' before ')' token 33 | if(abs(tag[-tag[a[now][i]]) != 1){ | ^ | ] a.cc: In function 'int main()': a.cc:66:33: error: request for member 'size' in 'a', which is of non-class type 'std::vector<int> [100100]' 66 | for(int i=0;i<a.size();i++){ | ^~~~
s846850980
p03949
C++
#include <cstdio> #include <queue> #include <vector> #include <algorithm> #include <iostream> using namespace std; const int SIZE=100005; const int INF=100000005; vector<int> mp[SIZE]; int id[SIZE],L[SIZE],R[SIZE]; bool ok=true; void solve(int v,int p){ if(id[v]==-1){ L[v]=-INF; R[v]=INF; } else{ L[v]=R[v]=id[v]; } for(int i=0;i<mp[v].size();i++){ int to=mp[v][i]; if(to==p) continue; solve(to,v); if(L[to]<-INF/2) continue; if(!(L[v]<-INF/2)){ if(L[to]%2==L[v]%2){ ok=false; return; } } L[v]=max(L[to]-1,L[v]); R[v]=min(R[to]+1,R[v]); if(L[v]>R[v]){ ok=false; return; } } } void make(int v,int p){ for(int i=0;i<mp[v].size();i++){ int to=mp[v][i]; if(to==p) continue; if(id[to]==-1){ if(L[to]<=id[v]+1 && id[v]+1<=R[to]){ id[to]=id[v]+1; else id[to]=id[v]-1; } } make(to,v); } } int main(){ int n,k; scanf("%d",&n); for(int i=0;i<n-1;i++){ int a,b; scanf("%d%d",&a,&b); a--; b--; mp[a].push_back(b); mp[b].push_back(a); id[i]=-1; } id[n-1]=-1; scanf("%d",&k); for(int i=0;i<k;i++){ int v,p; scanf("%d%d",&v,&p); v--; id[v]=p; } solve(0,-1); if(!ok) puts("No"); else{ puts("Yes"); id[0]=L[0]; make(0,-1); for(int i=0;i<n;i++){ printf("%d\n",id[i]); } } return 0; }
a.cc: In function 'void make(int, int)': a.cc:49:33: error: expected '}' before 'else' 49 | id[to]=id[v]+1; else id[to]=id[v]-1; | ^~~~ a.cc:48:49: note: to match this '{' 48 | if(L[to]<=id[v]+1 && id[v]+1<=R[to]){ | ^ a.cc:52:14: error: 'to' was not declared in this scope; did you mean 'tm'? 52 | make(to,v); | ^~ | tm a.cc: At global scope: a.cc:54:1: error: expected declaration before '}' token 54 | } | ^
s169135922
p03949
C++
#include<bits/stdc++.h> #pragma comment(linker, "/STACK:16000000") #define PI 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679 #define ii pair<int,int> using namespace std; const int inf=0x3f3f3f3f; const long long inf2=0x3f3f3f3f3f3f3f3f; const double eps=1e-6; const int mod=1000000007; int n,k; vector<int> nei[100005]; int d[100005]; priority_queue<pii, vector<pii>, greater<pii> > pq; int a[100005]; int b[100005]; int main(){ memset(d,-1,sizeof(d)); scanf("%d",&n); for(int i=0;i<n-1;++i){ scanf("%d%d",&a[i],&b[i]); --a[i],--b[i]; nei[a[i]].push_back(b[i]); nei[b[i]].push_back(a[i]); } scanf("%d",&k); for(int i=0;i<k;++i){ int v,p; scanf("%d%d",&v,&p); --v; d[v]=p; pq.push(pii(p,v)); } while(!pq.empty()){ pii p=pq.top(); pq.pop(); int v=p.second; for(int i=0;i<nei[v].size();++i){ int u=nei[v][i]; if(d[u]==-1){ d[u]=d[v]+1; pq.push(pii(d[u],u)); } } } for(int i=0;i<n-1;++i){ if(abs(d[a[i]]-d[b[i]])!=1)byebye("No"); } puts("Yes"); for(int i=0;i<n;++i)printf("%d\n",d[i]); return 0; }
a.cc:13:16: error: 'pii' was not declared in this scope; did you mean 'ii'? 13 | priority_queue<pii, vector<pii>, greater<pii> > pq; | ^~~ | ii a.cc:13:28: error: 'pii' was not declared in this scope; did you mean 'ii'? 13 | priority_queue<pii, vector<pii>, greater<pii> > pq; | ^~~ | ii a.cc:13:31: error: template argument 1 is invalid 13 | priority_queue<pii, vector<pii>, greater<pii> > pq; | ^ a.cc:13:31: error: template argument 2 is invalid a.cc:13:42: error: 'pii' was not declared in this scope; did you mean 'ii'? 13 | priority_queue<pii, vector<pii>, greater<pii> > pq; | ^~~ | ii a.cc:13:45: error: template argument 1 is invalid 13 | priority_queue<pii, vector<pii>, greater<pii> > pq; | ^ a.cc:13:47: error: template argument 1 is invalid 13 | priority_queue<pii, vector<pii>, greater<pii> > pq; | ^ a.cc:13:47: error: template argument 2 is invalid a.cc:13:47: error: template argument 3 is invalid a.cc: In function 'int main()': a.cc:31:20: error: request for member 'push' in 'pq', which is of non-class type 'int' 31 | pq.push(pii(p,v)); | ^~~~ a.cc:31:25: error: 'pii' was not declared in this scope; did you mean 'ii'? 31 | pq.push(pii(p,v)); | ^~~ | ii a.cc:33:19: error: request for member 'empty' in 'pq', which is of non-class type 'int' 33 | while(!pq.empty()){ | ^~~~~ a.cc:34:17: error: 'pii' was not declared in this scope; did you mean 'ii'? 34 | pii p=pq.top(); | ^~~ | ii a.cc:35:20: error: request for member 'pop' in 'pq', which is of non-class type 'int' 35 | pq.pop(); | ^~~ a.cc:36:23: error: 'p' was not declared in this scope 36 | int v=p.second; | ^ a.cc:41:36: error: request for member 'push' in 'pq', which is of non-class type 'int' 41 | pq.push(pii(d[u],u)); | ^~~~ a.cc:46:44: error: 'byebye' was not declared in this scope 46 | if(abs(d[a[i]]-d[b[i]])!=1)byebye("No"); | ^~~~~~
s484782377
p03949
C++
#include<bits/stdc++.h> using namespace std; priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > >q; int ans[100003]; vector<int>v[100003]; int main(){ memset(ans,-1,sizeof(ans)); int n,a,b,k; cin>>n; for(int i=1;i<n;i++) { cin>>a>>b; a--;b--; v[a].push_back(b); v[b].push_back(a); } cin>>k; for(int i=0;i<k;i++) { int p,x; cin>>p>>x; p--; ans[p]=x; q.push(make_pair(p,x)); } while(!q.empty()){ pair<int,int>tmp=q.top(); tmp.first=-tmp.first; q.pop(); for(int i=0;i<tmp.second.size();i++) if(ans[tmp.second[i]]==-1) { ans[tmp.second[i]]=ans[tmp.first]+1; q.push(make_pair(-tmp.second[i],v[tmp.second[i]])); } } for(int i=0;i<n;i++) for(int j=0;j<v[i].size();j++) if(fabs(ans[i]-ans[v[i][j]])!=1) { cout<<"No"; return 0; } cout<<"Yes"<<endl; for(int i=0;i<n;i++) cout<<ans[i]<<endl; }
a.cc: In function 'int main()': a.cc:30:42: error: request for member 'size' in 'tmp.std::pair<int, int>::second', which is of non-class type 'int' 30 | for(int i=0;i<tmp.second.size();i++) | ^~~~ a.cc:31:42: error: invalid types 'int[int]' for array subscript 31 | if(ans[tmp.second[i]]==-1) | ^ a.cc:33:47: error: invalid types 'int[int]' for array subscript 33 | ans[tmp.second[i]]=ans[tmp.first]+1; | ^ a.cc:34:61: error: invalid types 'int[int]' for array subscript 34 | q.push(make_pair(-tmp.second[i],v[tmp.second[i]])); | ^ a.cc:34:77: error: invalid types 'int[int]' for array subscript 34 | q.push(make_pair(-tmp.second[i],v[tmp.second[i]])); | ^
s259693554
p03949
C++
/* _ooOoo_ o8888888o 88" . "88 (| -_- |) O\ = /O ____/`---'\____ .' \\| |// `. / \\||| : |||// \ / _||||| -:- |||||- \ | | \\\ - /// | | | \_| ''\---/'' | | \ .-\__ `-` ___/-. / ___`. .' /--.--\ `. . ___ ."" '< `.___\_<|>_/___.' >'"". | | : `- \`.;`\ _ /`;.`/ - ` : | | \ \ `-. \_ __\ /__ _/ .-` / / ======`-.____`-.___\_____/___.-`____.-'====== `=---=' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ·ð׿±£ÓÓ ÓÀÎÞBUG */ //use readint! #pragma GCC optimize(1) #pragma G++ optimize(1) #pragma GCC optimize(2) #pragma G++ optimize(2) #pragma GCC optimize(3) #pragma G++ optimize(3) #pragma GCC optimize(4) #pragma G++ optimize(4) #pragma GCC optimize(5) #pragma G++ optimize(5) #pragma GCC optimize(6) #pragma G++ optimize(6) #pragma GCC optimize(7) #pragma G++ optimize(7) #pragma GCC optimize(8) #pragma G++ optimize(8) #pragma GCC optimize(9) #pragma G++ optimize(9) #pragma GCC optimize("-funsafe-loop-optimizations") #pragma GCC optimize("-funroll-loops") #pragma GCC optimize("-fwhole-program") #pragma GCC optimize("Ofast,no-stack-protector") #pragma GCC optimize("-fthread-jumps") #pragma GCC optimize("-falign-functions") #pragma GCC optimize("-falign-jumps") #pragma GCC optimize("-falign-loops") #pragma GCC optimize("-falign-labels") #pragma GCC optimize("-fcaller-saves") #pragma GCC optimize("-fcrossjumping") #pragma GCC optimize("-fcse-follow-jumps") #pragma GCC optimize("-fcse-skip-blocks") #pragma GCC optimize("-fdelete-null-pointer-checks") #pragma GCC optimize("-fdevirtualize") #pragma GCC optimize("-fexpensive-optimizations") #pragma GCC optimize("-fgcse") #pragma GCC optimize("-fgcse-lm") #pragma GCC optimize("-fhoist-adjacent-loads") #pragma GCC optimize("-finline-small-functions") #pragma GCC optimize("-findirect-inlining") #pragma GCC optimize("-fipa-sra") #pragma GCC optimize("-foptimize-sibling-calls") #pragma GCC optimize("-fpartial-inlining") #pragma GCC optimize("-fpeephole2") #pragma GCC optimize("-freorder-blocks") #pragma GCC optimize("-freorder-functions") #pragma GCC optimize("-frerun-cse-after-loop") #pragma GCC optimize("-fsched-interblock") #pragma GCC optimize("-fsched-spec") #pragma GCC optimize("-fschedule-insns") #pragma GCC optimize("-fschedule-insns2") #pragma GCC optimize("-fstrict-aliasing") #pragma GCC optimize("-fstrict-overflow") #pragma GCC optimize("-ftree-switch-conversion") #pragma GCC optimize("-ftree-tail-merge") #pragma GCC optimize("-ftree-pre") #pragma GCC optimize("-ftree-vrp") #include<map> #include<iostream> #include<iomanip> //#include<conio.h> #include<algorithm> #include<vector> #include<set> #include<cmath> #include<stdio.h> #include<fstream> #include<assert.h> #include<time.h> #include<queue> #include<deque> #include<stack> #include<list> //#include<windows.h> #include<sstream> #include<string.h> #define mp make_pair #define ll long long #define all(v) v.begin(),v.end() #define memset(a,b) memset(a,b,sizeof(a)) using namespace std; const int INF=2147483647; const double PI=3.1415926535897932384626; const int maxn=10005; struct bign{ int d[maxn], len; inline void clean() { while(len > 1 && !d[len-1]) len--; } inline bign() { memset(d, 0); len=1; } inline bign(int num) { *this=num; } inline bign(char* num) { *this=num; } inline bign operator=(const char* num){ memset(d, 0); len=strlen(num); for(int i=0; i<len; i++) d[i]=num[len-1-i] - '0'; clean(); return *this; } inline bign operator=(int num){ char s[20]; sprintf(s, "%d", num); *this=s; return *this; } inline bign operator + (const bign& b){ bign c=*this; int i; for (i=0; i<b.len; i++){ c.d[i] +=b.d[i]; if (c.d[i] > 9) c.d[i]%=10, c.d[i+1]++; } while (c.d[i] > 9) c.d[i++]%=10, c.d[i]++; c.len=max(len, b.len); if (c.d[i] && c.len<=i) c.len=i+1; return c; } inline bign operator - (const bign& b){ bign c=*this; int i; for (i=0; i<b.len; i++){ c.d[i] -=b.d[i]; if (c.d[i]<0) c.d[i]+=10, c.d[i+1]--; } while (c.d[i]<0) c.d[i++]+=10, c.d[i]--; for(i=c.len-1;i>0;i--) if(c.d[i]!=0) break; c.len=i+1; // c.clean(); return c; } inline bign operator * (const bign& b)const{ int i, j; bign c; c.len=len + b.len; for(j=0; j<b.len; j++) for(i=0; i<len; i++) c.d[i+j] +=d[i] * b.d[j]; for(i=0; i<c.len-1; i++) c.d[i+1] +=c.d[i]/10, c.d[i] %=10; c.clean(); return c; } inline bign operator / (const bign& b){ int i, j; bign c=*this, a=0; for (i=len - 1; i >=0; i--) { a=a*10 + d[i]; for (j=0; j<10; j++) if (a<b*(j+1)) break; c.d[i]=j; a=a - b*j; } c.clean(); return c; } inline bign operator % (const bign& b){ int i, j; bign a=0; for (i=len-1;i>=0;i--){ a=a*10 + d[i]; for (j=0; j<10; j++) if (a<b*(j+1)) break; a=a - b*j; } return a; } inline bign operator += (const bign& b){ *this=*this + b; return *this; } inline bign operator *= (const bign& b){ *this=*this * b; return *this; } inline bign operator -= (const bign& b){ *this=*this - b; return *this; } inline bign operator /= (const bign& b){ *this=*this / b; return *this; } inline bool operator < (const bign& b) const{ if(len !=b.len) return len<b.len; for(int i=len-1; i >=0; i--) if(d[i] !=b.d[i]) return d[i]<b.d[i]; return false; } inline bool operator >(const bign& b) const{return b<*this;} inline bool operator<=(const bign& b) const{return !(b<*this);} inline bool operator>=(const bign& b) const{return !(*this<b);} inline bool operator!=(const bign& b) const{return b<*this || *this<b;} inline bool operator==(const bign& b) const{return !(b<*this) && !(b > *this);} inline string str() const{ char s[maxn]={}; for(int i=0; i<len; i++) s[len-1-i]=d[i]+'0'; return s; } }; inline istream& operator >>(istream& in, bign& x) { string s; in>>s; x=s.c_str(); return in; } inline ostream& operator << (ostream& out, const bign& x) { out<<x.str(); return out; } inline void write(ll x){ if(x<0) putchar('-'),x=-x; if(x>9) write(x/10); putchar(x%10+'0'); } inline int pt(int a[],int l,int r){ int p,i,j; p=a[l]; i=l; j=r+1; for(;;){ while(a[++i]<p) if(i>=r) break; while(a[--j]>p) if(j<=l) break; if(i>=j) break; else swap(a[i],a[j]); } if(j==l) return j; swap(a[l],a[j]); return j; } inline void q_sort(int a[],int l,int r){ int q; if(r>l){ q=pt(a,l,r); q_sort(a,l,q-1); q_sort(a,q+1,r); } } inline void write(int x){ if(x<0) putchar('-'),x=-x; if(x>9) write(x/10); putchar(x%10+'0'); } inline void rd(long long &val){ long long x=0; int f=1; char ch=getchar(); while((ch<'0'||ch>'9')&&ch!='-') ch=getchar(); if(ch=='-'){ f=-1; ch=getchar(); } while(ch>='0'&&ch<='9'){ x=x*10+ch-'0'; ch=getchar(); } val=x*f; } inline void rd(int &val){ int x=0; int f=1; char ch=getchar(); while((ch<'0'||ch>'9')&&ch!='-') ch=getchar(); if(ch=='-'){ f=-1; ch=getchar(); } while(ch>='0'&&ch<='9'){ x=x*10+ch-'0'; ch=getchar(); } val=x*f; } inline void _write(int x){ write(x); putchar(' '); } inline void print(int x){ write(x); putchar('\n'); } inline void _write(ll x){ write(x); putchar(' '); } inline void print(ll x){ write(x); putchar('\n'); } struct PII{ int first,second; PII(){} PII(int f, int s): first(f),second(s){} inline bool operator <(const PII& x)const{ if(first!=x.first) return first<x.first; return second<x.second; } inline bool operator ==(const PII& x)const{ return first==x.first and second==x.second; } inline bool operator >(const PII& x)const{ if(first!=x.first) return first>x.first; return second>x.second; } inline bool operator !=(const PII& x)const{ return first!=x.first and second!=x.second; } }; ofstream out; ifstream in; inline string itos(int x){ string rt=""; while(x) rt=(char)(x%10+'0')+rt,x/=10; return rt; } clock_t __stt; inline void TStart(){__stt=clock();} inline void TReport(){printf("\nTaken Time : %.3lf sec\n",(double)(clock()-__stt)/CLOCKS_PER_SEC);} int low[100005],up[100005],col[100005],n,k; vector<int> v[100005]; int odd[100005]; int base_col; bool use[100005]; vector<int> _v; inline void dfs(int x){ // cerr<<"XXX: "<<x<<endl; int i,tx,ty,t; for(i=0;i<v[x].size();++i){ t=v[x][i]; tx=low[x]-1; ty=up[x]+1; if(max(tx,low[t])>min(ty,up[t])){ puts("No"); exit(0); } if(0tx>=low[t] and ty<=up[t]){ low[t]=tx; up[t]=ty; dfs(t); }else continue; } } inline void check(int x,int dist){ if(use[x]) return; if(~odd[x]){ if((base_col+dist)&1!=odd[x]){ // cerr<<"AFDSFSDGG: "<<base_col<<' '<<dist<<' '<<x<<endl; puts("No"); exit(0); } } use[x]=1; for(int i=0;i<v[x].size();++i) check(v[x][i],dist+1); } inline void go(int x){ if(use[x]) return; use[x]=1; col[x]=up[x]; for(int i=0;i<v[x].size();++i) go(v[x][i]); } int main(){ // ios_base::sync_with_stdio(false); int i,j; #ifdef LOCAL TStart(); #endif rd(n); int x,y; for(i=0;i<n-1;++i){ rd(x),rd(y); --x,--y; v[x].push_back(y); v[y].push_back(x); } rd(k); int t; memset(odd,-1); for(i=0;i<n;++i) low[i]=-INF,up[i]=INF; for(i=0;i<k;++i){ rd(x),rd(y); --x; col[x]=y; low[x]=up[x]=y; t=x; _v.push_back(x); odd[x]=y&1; } // cerr<<"\n"; // for(i=0;i<n;++i) cerr<<odd[i]<<' '; // cerr<<'\n'; base_col=odd[t]; check(t,0); for(i=0;i<_v.size();++i) dfs(_v[i]); // for(i=0;i<n;++i) cout<<i<<" : ",_write(low[i]),print(up[i]); puts("Yes"); memset(use,0); go(t); for(i=0;i<n;++i) print(col[i]); // putchar('\n'); #ifdef LOCAL TReport(); #endif }
a.cc:42:51: warning: bad option '-funsafe-loop-optimizations' to pragma 'optimize' [-Wpragmas] 42 | #pragma GCC optimize("-funsafe-loop-optimizations") | ^ a.cc:44:39: warning: bad option '-fwhole-program' to pragma 'optimize' [-Wpragmas] 44 | #pragma GCC optimize("-fwhole-program") | ^ a.cc:54:41: warning: bad option '-fcse-skip-blocks' to pragma 'optimize' [-Wpragmas] 54 | #pragma GCC optimize("-fcse-skip-blocks") | ^ a.cc:75:41: warning: bad option '-fstrict-overflow' to pragma 'optimize' [-Wpragmas] 75 | #pragma GCC optimize("-fstrict-overflow") | ^ a.cc:109:23: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes] 109 | inline void clean() { while(len > 1 && !d[len-1]) len--; } | ^ a.cc:109:23: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes] a.cc:109:23: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes] a.cc:109:23: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes] a.cc:110:17: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes] 110 | inline bign() { memset(d, 0); len=1; } | ^ a.cc:110:17: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes] a.cc:110:17: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes] a.cc:110:17: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes] a.cc:111:24: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes] 111 | inline bign(int num) { *this=num; } | ^ a.cc:111:24: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes] a.cc:111:24: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes] a.cc:111:24: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes] a.cc:112:26: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes] 112 | inline bign(char* num) { *this=num; } | ^ a.cc:112:26: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes] a.cc:112:26: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes] a.cc:112:26: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes] a.cc:113:42: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes] 113 | inline bign operator=(const char* num){ | ^ a.cc:113:42: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes] a.cc:113:42: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes] a.cc:113:42: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes] a.cc:119:34: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes] 119 | inline bign operator=(int num){ | ^ a.cc:119:34: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes] a.cc:119:34: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes] a.cc:119:34: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes] a.cc:124:42: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes] 124 | inline bign operator + (const bign& b){ | ^ a.cc:124:42: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes] a.cc:124:42: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes] a.cc:124:42: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes] a.cc:135:46: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes] 135 | inline bign operator - (const bign& b){ | ^ a.cc:135:46: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes] a.cc:135:46: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes] a.cc:135:46: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes] a.cc:147:43: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes] 147 | inline bign operator * (const bign& b)const{ | ^~~~~ a.cc:147:43: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes] a.cc:147:43: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes] a.cc:147:43: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes] a.cc:156:42: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes] 156 | inline bign operator / (const bign& b){ | ^ a.cc:156:42: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes] a.cc:156:42: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes] a.cc:156:42: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes] a.cc:169:42: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes] 169 | inline bign operator % (const bign& b){ | ^ a.cc:169:42: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes] a.cc:169:42: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes] a.cc:169:42: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes] a.cc:179:43: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes] 179 | inline bign operator += (const bign& b){ | ^ a.cc:179:43: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes] a.cc:179:43: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes] a.cc:179:43: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes] a.cc:183:43: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes] 183 | inline bign operator *= (const bign& b){ | ^ a.cc:183:43: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes] a.cc:183:43: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes] a.cc:183:43: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes] a.cc:187:47: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes] 187 | inline bign operator -= (const bign& b){ | ^ a.cc:187:47: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes] a.cc:187:47: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes] a.cc:187:47: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes] a.cc:191:47: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes] 191 | inline bign operator /= (const bign& b){ | ^ a.cc:191:47: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes] a.cc:191:47: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes] a.cc:191:47: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes] a.cc:195:44: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes] 195 | inline bool operator < (const bign& b) const{ | ^~~~~ a.cc:195:44: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes] a.cc:195:44: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes] a.cc:195:44: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes] a.cc:201:43: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes] 201 | inline bool operator >(const bign& b) const{return b<*this;} | ^~~~~ a.cc:201:43: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes] a.cc:201:43: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes] a.cc:201:43: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes] a.cc:202:43: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes] 202 | inline bool operator<=(const bign& b) const{return !(b<*this);} | ^~~~~ a.cc:202:43: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes] a.cc:202:43: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes] a.cc:202:43: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes] a.cc:203:43: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes] 203 | inline bool operator>=(const bign& b) const{return !(*this<b);} | ^~~~~ a.cc:203:43: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes] a.cc:203:43: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes] a.cc:203:43: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes] a.cc:204:43: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes] 204 | inline bool operator!=(const bign& b) const{return b<*this || *this<b;} | ^~~~~ a.cc:204:43: warning: bad option '-fwhole-program' to attribute 'op
s656677080
p03949
C++
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> P; int v[100010],p[100010],lb[100010],ub[100010]; vector<int> G[100010]; bool f=false; //根からDFS //範囲を決定していく void dfs(int i,int pr,int l,int r){ if(p[i]!=-1){ if(p[i]%2!=l%2||p[i]<l||p[i]>r){ f=true; return; } } for(auto& e:G[i]){ if(pr==e)continue; dfs(e,i,l-1,r+1); if(p[e]!=-1){ lb[i]=max(l,p[e]-1); ub[i]=min(r,p[e]+1); } } if(lb[i]>ub[i]){ f=true; retutn; } p[i]=lb[i]; } int main(){ int n;cin>>n; 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 k;cin>>k; fill(p,p+n+1,-1); fill(lb,lb+n+1,-1); fill(ub,ub+n+1,INF); for(int i=0;i<k;i++){ cin>>v[i]; cin>>p[v[i]]; } dfs(v[0],-1,p[v[0]],p[v[0]]); if(f){ cout<<"No"<<endl; return 0; } cout<<"Yes"<<endl; } #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> P; int v[100010],p[100010],lb[100010],ub[100010]; vector<int> G[100010]; bool f=false; //根からDFS //範囲を決定していく void dfs(int i,int pr,int l,int r){ if(p[i]!=-1){ if(p[i]%2!=l%2||p[i]<l||p[i]>r){ f=true; return; } } for(auto& e:G[i]){ if(pr==e)continue; dfs(e,i,l-1,r+1); if(p[e]!=-1){ lb[i]=max(l,p[e]-1); ub[i]=min(r,p[e]+1); } } if(lb[i]>ub[i]){ f=true; retutn; } p[i]=lb[i]; } int main(){ int n;cin>>n; 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 k;cin>>k; fill(p,p+n+1,-1); fill(lb,lb+n+1,-1); fill(ub,ub+n+1,INF); for(int i=0;i<k;i++){ cin>>v[i]; cin>>p[v[i]]; } dfs(v[0],-1,p[v[0]],p[v[0]]); if(f){ cout<<"No"<<endl; return 0; } cout<<"Yes"<<endl; }
a.cc: In function 'void dfs(int, int, int, int)': a.cc:27:17: error: 'retutn' was not declared in this scope 27 | retutn; | ^~~~~~ a.cc: In function 'int main()': a.cc:41:24: error: 'INF' was not declared in this scope 41 | fill(ub,ub+n+1,INF); | ^~~ a.cc: At global scope: a.cc:58:5: error: redefinition of 'int v [100010]' 58 | int v[100010],p[100010],lb[100010],ub[100010]; | ^ a.cc:5:5: note: 'int v [100010]' previously declared here 5 | int v[100010],p[100010],lb[100010],ub[100010]; | ^ a.cc:58:15: error: redefinition of 'int p [100010]' 58 | int v[100010],p[100010],lb[100010],ub[100010]; | ^ a.cc:5:15: note: 'int p [100010]' previously declared here 5 | int v[100010],p[100010],lb[100010],ub[100010]; | ^ a.cc:58:25: error: redefinition of 'int lb [100010]' 58 | int v[100010],p[100010],lb[100010],ub[100010]; | ^~ a.cc:5:25: note: 'int lb [100010]' previously declared here 5 | int v[100010],p[100010],lb[100010],ub[100010]; | ^~ a.cc:58:36: error: redefinition of 'int ub [100010]' 58 | int v[100010],p[100010],lb[100010],ub[100010]; | ^~ a.cc:5:36: note: 'int ub [100010]' previously declared here 5 | int v[100010],p[100010],lb[100010],ub[100010]; | ^~ a.cc:59:13: error: redefinition of 'std::vector<int> G [100010]' 59 | vector<int> G[100010]; | ^ a.cc:6:13: note: 'std::vector<int> G [100010]' previously declared here 6 | vector<int> G[100010]; | ^ a.cc:60:6: error: redefinition of 'bool f' 60 | bool f=false; | ^ a.cc:7:6: note: 'bool f' previously defined here 7 | bool f=false; | ^ a.cc:63:6: error: redefinition of 'void dfs(int, int, int, int)' 63 | void dfs(int i,int pr,int l,int r){ | ^~~ a.cc:10:6: note: 'void dfs(int, int, int, int)' previously defined here 10 | void dfs(int i,int pr,int l,int r){ | ^~~ a.cc: In function 'void dfs(int, int, int, int)': a.cc:80:17: error: 'retutn' was not declared in this scope 80 | retutn; | ^~~~~~ a.cc: At global scope: a.cc:84:5: error: redefinition of 'int main()' 84 | int main(){ | ^~~~ a.cc:31:5: note: 'int main()' previously defined here 31 | int main(){ | ^~~~ a.cc: In function 'int main()': a.cc:94:24: error: 'INF' was not declared in this scope 94 | fill(ub,ub+n+1,INF); | ^~~
s506838807
p03949
C++
#include<iomanip> #include<limits> #include<thread> #include<utility> #include<iostream> #include<string> #include<algorithm> #include<set> #include<map> #include<vector> #include<stack> #include<queue> #include<cmath> #include<math.h> #include<numeric> #include<cassert> #include<random> #include<deque> #include<chrono> #include<unordered_map> #include<list> #include<fstream> using namespace std; typedef unsigned long long int ull; typedef long long int ll; typedef pair<ll,ll> pll; typedef pair<int,int> pi; typedef pair<double,double> pd; const ll E=1e18+7; #define F first #define S second #define MK make_pair const ll MOD=1000000007; ll n; vector<pll> v; vector<vector<ll>> e; vector<pll> D; vector<pair<bool,ll>> de; pair<bool,pll> dfs(ll where,ll parent,pll lmt,bool F){ if(de[where].F){ if(de[where].S%2!=F?1:0){return {false,{0,0}};} if(lmt.F<de[where].S || lmt.S>de[where].S){return {false,{0,0}};} lmt={de[where].S,de[where].S}; } for(int i=0;i<e[where].size();i++){ ll to=e[where][i]; if(to==parent){continue;} pair<bool,pll> ret=dfs(to,where,{lmt.F+1,lmt.S-1},!F); lmt.F=min(lmt.F,ret.S.F); lmt.S=max(lmt.S,ret.S.S); if(lmt.F<lmt.S || !ret.F){return {false,{0,0}};} } v[where].F=lmt.F; v[where].S=lmt.S; lmt.F++; lmt.S--; return {true,lmt}; } vector<int> color; void dfsC(ll where){ for(int i=0;i<e[where].size();i++){ ll to=e[where][i]; if(color[to]==-1){ color[to]=color[where]==1?0:1; dfsC(to); } } } int main(){ cin>>n; e.resize(n); v.resize(n); de.resize(n,{false,-1}); color.resize(n,-1); for(int i=0;i<n-1;i++){ ll u,v; cin>>u>>v; u--; v--; e[u].push_back(v); e[v].push_back(u); } ll k; cin>>k; D.resize(k); for(int i=0;i<k;i++){ cin>>D[i].F>>D[i].S; --D[i].F; de[D[i].F]={true,D[i].S}; } if(k==0){cout<<"Yes"<<endl; return 0;} color[D[0].F]=D[0].S%2; dfsC(D[0].F); for(int i=0;i<k;i++){ if(color[D[i].F]!=D[i].S%2){cout<<"No"<<endl; return 0} } if(!dfs(D[0].F,-1,{D[0].S,D[0].S},D[0].S%2).F){cout<<"No"<<endl; return 0;} cout<<"Yes"<<endl; for(int i=0;i<n;i++){ cout<<v[i].F<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:99:63: error: expected ';' before '}' token 99 | if(color[D[i].F]!=D[i].S%2){cout<<"No"<<endl; return 0} | ^ | ;
s415248554
p03949
C++
#include<cmath> #include<vector> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; void Read(int &p) { p=0; char c=getchar(); while(c<'0'||c>'9') c=getchar(); while(c>='0'&&c<='9') p=p*10+c-'0',c=getchar(); } const int MAXN=102018; int N,k,root,u,v,val[MAXN],eoro[MAXN]; bool vis[MAXN],ol[MAXN]; vector<int> G[MAXN]; vector<int> C[MAXN]; bool build_tree(int p) { vis[p]=1; for(unsigned int i=0;i<G[p].size();i++) { int t=G[p][i]; if(!vis[t]) { C[p].push_back(t); if(eoro[t]!=-1 && eoro[t]==eoro[p]) return 1; eoro[t]=(eoro[p]+1)%2; bool o=build_tree(t); if(o) return 1; } } return 0; } bool ed; void draw(int p) { if(ed) return; if(C[p].size()==0) { bool cnt=0; for(int i=1;i<=N && !cnt;i++) if(val[i]==-1) cnt=1; if(!cnt) { for(int i=1;i<=N;i++) printf("%d\n",val[i]); ed=1; } return ; } for(unsigned int i=0;i<C[p].size() && !ed;i++) { int t=C[p][i]; if(ol[t]) { if(val[t]-val[p]>1 || val[p]-val[t]>1) { if(ol[p]) ed=1,puts("No"); return ; } else draw(t); continue; } val[t]=val[p]+1,draw(t), if(val[t]>=1) val[t]=val[p]-1,draw(t); } if(ed) return ; } int main() { memset(eoro,-1,sizeof eoro); memset(val,-1,sizeof val); Read(N); for(int i=2;i<=N;i++) Read(u),Read(v),G[u].push_back(v),G[v].push_back(u); Read(k); Read(root),Read(val[root]),eoro[root]=val[root]%2,ol[root]=1; for(int i=2;i<=k;i++) Read(u),Read(v),val[u]=v,eoro[u]=v%2,ol[u]=1; if(build_tree(root)) ed=1,puts("No"); else draw(root); if(!ed) puts("No"); }
a.cc: In function 'void draw(int)': a.cc:74:17: error: expected primary-expression before 'if' 74 | if(val[t]>=1) val[t]=val[p]-1,draw(t); | ^~
s985461950
p03949
C++
#include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<algorithm> #include<cmath> #include<vector> #include<queue> #include<set> #include<map> #define ll long long #define inf 1e9 #define eps 1e-10 #define mod 9901 #define mkp make_pair using namespace std; int i,j,k,m,s,t,n,ans1,ans2,n1,nn,m1,mx; int read() { int x=0,f=1;char ch=getchar(); while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=getchar();} while (ch>='0'&&ch<='9') {x=x*10+ch-'0';ch=getchar();} return x*f; } int kabs(int a) { if (a<0) return -a; return a; } void add(int &x,int y) { x+=y; if (x>=mod) x-=mod; } void dec(int &x,int y) { x-=y; if (x<0) x+=mod; } int bo,first[101000],next[201000],zhi[201000],a[101000],p[101000],l1[101000],r1[101000]; void insert(int u,int v) { next[++m1]=first[u]; first[u]=m1; zhi[m1]=v; } void dfs(int x,int fa) { if (!bo) return; int k,v,bo2=0; for (k=first[x];k;k=next[k]) { v=zhi[k]; if (v==fa) continue; dfs(v,x); p[x]|=p[v]; } if (!bo) return; if (!p[x]) return; if (a[x]!=-1) bo2=1,l1[x]=r1[x]=a[x]; for (k=first[x];k;k=next[k]) { v=zhi[k]; if (v==fa) continue; if (!p[v]) continue; if (!bo2) { bo2=1; l1[x]=l1[v]-1; r1[x]=r1[v]+1; } else { if (l1[x]%2!=(l1[v]-1)%2) {bo=0;return;} l1[x]=max(l1[x],l1[v]-1); r1[x]=min(r1[x],r1[v]+1); if (l1[x]>r1[x]) {bo=0;return;} } } } void solve(int x,int fa) { int k,v; if (x==1) a[x]=l1[x]; else if (!p[x]||(a[fa]+1>=l1[x]&&a[fa]+1<=r1[x])) a[x]=a[fa]+1; else a[x]=a[fa]-1; for (k=first[x];k;k=next[k]) { v=zhi[k]; if (v==fa) continue; solve(v,x); } } int main() { scanf("%d",&n); for (i=1;i<n;i++) scanf("%d%d",&s,&t),insert(s,t),insert(t,s); scanf("%d",&m); memset(a,-1,sizeof(a)); for (i=1;i<=m;i++) scanf("%d%d",&s,&t),a[s]=t,p[s]=1; bo=1; dfs(1,0); if (!bo) { puts("NO"); return 0; } solve(1,0); puts("YES"); for (i=1;i<=n;i++) printf("%d\n",a[i]); }
a.cc: In function 'void insert(int, int)': a.cc:43:9: error: reference to 'next' is ambiguous 43 | next[++m1]=first[u]; | ^~~~ In file included from /usr/include/c++/14/string:47, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:40:22: note: 'int next [201000]' 40 | int bo,first[101000],next[201000],zhi[201000],a[101000],p[101000],l1[101000],r1[101000]; | ^~~~ a.cc: In function 'void dfs(int, int)': a.cc:51:29: error: reference to 'next' is ambiguous 51 | for (k=first[x];k;k=next[k]) | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:40:22: note: 'int next [201000]' 40 | int bo,first[101000],next[201000],zhi[201000],a[101000],p[101000],l1[101000],r1[101000]; | ^~~~ a.cc:62:29: error: reference to 'next' is ambiguous 62 | for (k=first[x];k;k=next[k]) | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:40:22: note: 'int next [201000]' 40 | int bo,first[101000],next[201000],zhi[201000],a[101000],p[101000],l1[101000],r1[101000]; | ^~~~ a.cc: In function 'void solve(int, int)': a.cc:86:29: error: reference to 'next' is ambiguous 86 | for (k=first[x];k;k=next[k]) | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:40:22: note: 'int next [201000]' 40 | int bo,first[101000],next[201000],zhi[201000],a[101000],p[101000],l1[101000],r1[101000]; | ^~~~
s519519797
p03949
C++
#include <vector> #include <cstdlib> #include <utility> #include <algorithm> const int N = 1e5 + 10, INF = 1e7; int n, rt, f[N], p[N], k; std::vector<int> to[N], c[N]; std::pair<int, int> r[N]; bool o1, o2, d[N], h[N]; std::pair<int, int> merge(std::pair<int, int> a, std::pair<int, int> b) { return std::make_pair(std::max(a.first, b.first), std::min(a.second, b.second)); } void build(int cur) { for (int i : to[cur]) if (i != f[cur]) { c[cur].push_back(i); f[i] = cur; d[i] = !d[cur]; build(i); } } void dfs(int cur) { if (cur != rt) r[cur] = merge(r[cur], std::make_pair(r[f[cur]].first - 1, r[f[cur]].second + 1)); for (int i : c[cur]) { dfs(i); r[cur] = merge(r[cur], std::make_pair(r[i].first - 1, r[i].second + 1)); } } void query(int cur) { p[cur] = r[cur].first; if (cur != rt && p[cur] == p[f[cur]]) p[cur]++; for (int i : c[cur]) { r[i] = merge(r[i], std::make_pair(p[cur] - 1, p[cur] + 1)); query(i); } } int main() { scanf("%d", &n); rt = rand() % 100000000 + 1; rt = rt % n + 1; for (int i = 1; i < n; i++) { static int t1, t2; scanf("%d%d", &t1, &t2); to[t1].push_back(t2); to[t2].push_back(t1); } build(rt); for (int i = 1; i <= n; i++) r[i] = std::make_pair(-INF, INF); scanf("%d", &k); for (int i = 1; i <= k; i++) { static int t1, t2; scanf("%d%d", &t1, &t2); h[t1] = true; p[t1] = t2; r[t1] = std::make_pair(t2, t2); ((d[t1] ^ (t2 & 1)) ? o1 : o2) = true; } if (o1 && o2) { puts("No"); return 0; } dfs(rt); if (r[rt].first <= r[rt].second) { puts("Yes"); query(rt); for (int i = 1; i <= n; i++) printf("%d\n", p[i]); } else { puts("No"); } return 0; }
a.cc: In function 'int main()': a.cc:46:5: error: 'scanf' was not declared in this scope 46 | scanf("%d", &n); | ^~~~~ a.cc:68:9: error: 'puts' was not declared in this scope 68 | puts("No"); | ^~~~ a.cc:74:9: error: 'puts' was not declared in this scope 74 | puts("Yes"); | ^~~~ a.cc:77:13: error: 'printf' was not declared in this scope 77 | printf("%d\n", p[i]); | ^~~~~~ a.cc:5:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' 4 | #include <algorithm> +++ |+#include <cstdio> 5 | a.cc:79:9: error: 'puts' was not declared in this scope 79 | puts("No"); | ^~~~
s492836188
p03949
C++
#include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<algorithm> #include<cmath> #include<vector> #include<queue> #include<set> #include<map> #define ll long long #define inf 1e9 #define eps 1e-10 #define mod 9901 #define mkp make_pair using namespace std; int i,j,k,m,s,t,n,ans1,ans2,n1,nn,m1,mx; int read() { int x=0,f=1;char ch=getchar(); while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=getchar();} while (ch>='0'&&ch<='9') {x=x*10+ch-'0';ch=getchar();} return x*f; } int kabs(int a) { if (a<0) return -a; return a; } void add(int &x,int y) { x+=y; if (x>=mod) x-=mod; } void dec(int &x,int y) { x-=y; if (x<0) x+=mod; } int bo,first[101000],next[201000],zhi[201000],a[101000],p[101000],l1[101000],r1[101000]; void insert(int u,int v) { next[++m1]=first[u]; first[u]=m1; zhi[m1]=v; } void dfs(int x,int fa) { if (!bo) return; int k,v,bo2=0; for (k=first[x];k;k=next[k]) { v=zhi[k]; if (v==fa) continue; dfs(v,x); p[x]|=p[v]; } if (!bo) return; if (!p[x]) return; if (a[x]!=-1) bo2=1,l1[x]=r1[x]=a[x]; for (k=first[x];k;k=next[k]) { v=zhi[k]; if (v==fa) continue; if (!p[v]) continue; if (!bo2) { bo2=1; l1[x]=l1[v]-1; r1[x]=r1[v]+1; } else { if (l1[x]%2!=(l1[v]-1)%2) {bo=0;return;} l1[x]=max(l1[x],l1[v]-1); r1[x]=min(r1[x],r1[v]+1); if (l1[x]>r1[x]) {bo=0;return;} } } } void solve(int x,int fa) { int k,v; if (x==1) a[x]=l1[x]; else if (!p[x]||(a[fa]+1>=l1[x]&&a[fa]+1<=r1[x])) a[x]=a[fa]+1; else a[x]=a[fa]-1; for (k=first[x];k;k=next[k]) { v=zhi[k]; if (v==fa) continue; solve(v,x); } } int main() { scanf("%d",&n); for (i=1;i<n;i++) scanf("%d%d",&s,&t),insert(s,t),insert(t,s); scanf("%d",&m); memset(a,-1,sizeof(a)); for (i=1;i<=m;i++) scanf("%d%d",&s,&t),a[s]=t,p[s]=1; bo=1; dfs(1,0); if (!bo) { puts("NO"); return 0; } solve(1,0); puts("YES"); for (i=1;i<=n;i++) printf("%d\n",a[i]); }
a.cc: In function 'void insert(int, int)': a.cc:43:9: error: reference to 'next' is ambiguous 43 | next[++m1]=first[u]; | ^~~~ In file included from /usr/include/c++/14/string:47, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:40:22: note: 'int next [201000]' 40 | int bo,first[101000],next[201000],zhi[201000],a[101000],p[101000],l1[101000],r1[101000]; | ^~~~ a.cc: In function 'void dfs(int, int)': a.cc:51:29: error: reference to 'next' is ambiguous 51 | for (k=first[x];k;k=next[k]) | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:40:22: note: 'int next [201000]' 40 | int bo,first[101000],next[201000],zhi[201000],a[101000],p[101000],l1[101000],r1[101000]; | ^~~~ a.cc:62:29: error: reference to 'next' is ambiguous 62 | for (k=first[x];k;k=next[k]) | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:40:22: note: 'int next [201000]' 40 | int bo,first[101000],next[201000],zhi[201000],a[101000],p[101000],l1[101000],r1[101000]; | ^~~~ a.cc: In function 'void solve(int, int)': a.cc:86:29: error: reference to 'next' is ambiguous 86 | for (k=first[x];k;k=next[k]) | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:40:22: note: 'int next [201000]' 40 | int bo,first[101000],next[201000],zhi[201000],a[101000],p[101000],l1[101000],r1[101000]; | ^~~~
s993404628
p03949
C++
#include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<algorithm> #include<cmath> #include<vector> #include<queue> #include<set> #include<map> #define ll long long #define inf 1e9 #define eps 1e-10 #define mod 9901 #define mkp make_pair using namespace std; int i,j,k,m,s,t,n,ans1,ans2,n1,nn,m1,mx; int read() { int x=0,f=1;char ch=getchar(); while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=getchar();} while (ch>='0'&&ch<='9') {x=x*10+ch-'0';ch=getchar();} return x*f; } int kabs(int a) { if (a<0) return -a; return a; } void add(int &x,int y) { x+=y; if (x>=mod) x-=mod; } void dec(int &x,int y) { x-=y; if (x<0) x+=mod; } int bo,first[101000],net[201000],zhi[201000],a[101000],p[101000],l1[101000],r1[101000]; void insert(int u,int v) { net[++m1]=first[u]; first[u]=m1; zhi[m1]=v; } void dfs(int x,int fa) { if (!bo) return; int k,v,bo2=0; for (k=first[x];k;k=net[k]) { v=zhi[k]; if (v==fa) continue; dfs(v,x); p[x]|=p[v]; } if (a[x]!=-1) p[x]=1; if (!bo) return; if (!p[x]) return; if (a[x]!=-1) bo2=1,l1[x]=r1[x]=a[x]; for (k=first[x];k;k=net[k]) { v=zhi[k]; if (v==fa) continue; if (!p[v]) continue; if (!bo2) { bo2=1; l1[x]=l1[v]-1; r1[x]=r1[v]+1; } else { if (l1[v]-1>r) {bo=0;return;} if (r1[v]+1<l) {bo=0;return;} if (l1[x]%2!=(l1[v]-1)%2) {bo=0;return;} l1[x]=max(l1[x],l1[v]-1); r1[x]=min(r1[x],r1[v]+1); if (l1[x]>r1[x]) {bo=0;return;} } } } void solve(int x,int fa) { int k,v; if (x==1) a[x]=l1[x]; else if (!p[x]||(a[fa]+1>=l1[x]&&a[fa]+1<=r1[x])) a[x]=a[fa]+1; else a[x]=a[fa]-1; for (k=first[x];k;k=net[k]) { v=zhi[k]; if (v==fa) continue; solve(v,x); } } int main() { scanf("%d",&n); for (i=1;i<n;i++) scanf("%d%d",&s,&t),insert(s,t),insert(t,s); scanf("%d",&m); memset(a,-1,sizeof(a)); for (i=1;i<=m;i++) scanf("%d%d",&s,&t),a[s]=t,p[s]=1; bo=1; dfs(1,0); if (!bo) { puts("NO"); return 0; } solve(1,0); puts("YES"); for (i=1;i<=n;i++) printf("%d\n",a[i]); }
a.cc: In function 'void dfs(int, int)': a.cc:75:37: error: 'r' was not declared in this scope 75 | if (l1[v]-1>r) {bo=0;return;} | ^ a.cc:76:37: error: 'l' was not declared in this scope 76 | if (r1[v]+1<l) {bo=0;return;} | ^
s149169726
p03949
C++
#include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<algorithm> #include<cmath> #include<vector> #include<queue> #include<set> #include<map> #define ll long long #define inf 1e9 #define eps 1e-10 #define mod 9901 #define mkp make_pair using namespace std; int i,j,k,m,s,t,n,ans1,ans2,n1,nn,m1,mx; int read() { int x=0,f=1;char ch=getchar(); while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=getchar();} while (ch>='0'&&ch<='9') {x=x*10+ch-'0';ch=getchar();} return x*f; } int kabs(int a) { if (a<0) return -a; return a; } void add(int &x,int y) { x+=y; if (x>=mod) x-=mod; } void dec(int &x,int y) { x-=y; if (x<0) x+=mod; } int bo,first[101000],next[201000],zhi[201000],a[101000],p[101000],l1[101000],r1[101000]; void insert(int u,int v) { next[++m1]=first[u]; first[u]=m1; zhi[m1]=v; } void dfs(int x,int fa) { if (!bo) return; int k,v,bo2=0; for (k=first[x];k;k=next[k]) { v=zhi[k]; if (v==fa) continue; dfs(v,x); p[x]|=p[v]; } if (!bo) return; if (!p[x]) return; if (a[x]!=-1) bo2=1,l1[x]=r1[x]=a[x]; for (k=first[x];k;k=next[k]) { v=zhi[k]; if (v==fa) continue; if (!p[v]) continue; if (!bo2) { bo2=1; l1[x]=l1[v]-1; r1[x]=r1[v]+1; } else { if (l1[x]%2!=(l1[v]-1)%2) {bo=0;return;} l1[x]=max(l1[x],l1[v]-1); r1[x]=min(r1[x],r1[v]+1); if (l1[x]>r1[x]) {bo=0;return;} } } } void solve(int x,int fa) { int k,v; if (x==1) a[x]=l1[x]; else if (!p[x]||(a[fa]+1>=l1[x]&&a[fa]+1<=r1[x])) a[x]=a[fa]+1; else a[x]=a[fa]-1; for (k=first[x];k;k=next[k]) { v=zhi[k]; if (v==fa) continue; solve(v,x); } } int main() { scanf("%d",&n); for (i=1;i<n;i++) scanf("%d%d",&s,&t),insert(s,t),insert(t,s); scanf("%d",&m); memset(a,-1,sizeof(a)); for (i=1;i<=m;i++) scanf("%d%d",&s,&t),a[s]=t,p[s]=1; bo=1; dfs(1,0); if (!bo) { puts("NO"); return 0; } solve(1,0); puts("YES"); for (i=1;i<=n;i++) printf("%d\n",a[i]); }
a.cc: In function 'void insert(int, int)': a.cc:43:9: error: reference to 'next' is ambiguous 43 | next[++m1]=first[u]; | ^~~~ In file included from /usr/include/c++/14/string:47, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:40:22: note: 'int next [201000]' 40 | int bo,first[101000],next[201000],zhi[201000],a[101000],p[101000],l1[101000],r1[101000]; | ^~~~ a.cc: In function 'void dfs(int, int)': a.cc:51:29: error: reference to 'next' is ambiguous 51 | for (k=first[x];k;k=next[k]) | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:40:22: note: 'int next [201000]' 40 | int bo,first[101000],next[201000],zhi[201000],a[101000],p[101000],l1[101000],r1[101000]; | ^~~~ a.cc:62:29: error: reference to 'next' is ambiguous 62 | for (k=first[x];k;k=next[k]) | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:40:22: note: 'int next [201000]' 40 | int bo,first[101000],next[201000],zhi[201000],a[101000],p[101000],l1[101000],r1[101000]; | ^~~~ a.cc: In function 'void solve(int, int)': a.cc:86:29: error: reference to 'next' is ambiguous 86 | for (k=first[x];k;k=next[k]) | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:40:22: note: 'int next [201000]' 40 | int bo,first[101000],next[201000],zhi[201000],a[101000],p[101000],l1[101000],r1[101000]; | ^~~~
s671458103
p03949
C++
#include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<algorithm> #include<cmath> #include<vector> #include<queue> #include<set> #include<map> #define ll long long #define inf 1e9 #define eps 1e-10 #define mod 9901 #define mkp make_pair using namespace std; int i,j,k,m,s,t,n,ans1,ans2,n1,nn,m1,mx; int read() { int x=0,f=1;char ch=getchar(); while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=getchar();} while (ch>='0'&&ch<='9') {x=x*10+ch-'0';ch=getchar();} return x*f; } int kabs(int a) { if (a<0) return -a; return a; } void add(int &x,int y) { x+=y; if (x>=mod) x-=mod; } void dec(int &x,int y) { x-=y; if (x<0) x+=mod; } int bo,first[101000],next[201000],zhi[201000],a[101000],p[101000],l1[101000],r1[101000]; void insert(int u,int v) { next[++m1]=first[u]; first[u]=m1; zhi[m1]=v; } void dfs(int x,int fa) { if (!bo) return; int k,v,bo2=0; for (k=first[x];k;k=next[k]) { v=zhi[k]; if (v==fa) continue; dfs(v,x); p[x]|=p[v]; } if (!bo) return; if (!p[x]) return; if (a[x]!=-1) bo2=1,l1[x]=r1[x]=a[x]; for (k=first[x];k;k=next[k]) { v=zhi[k]; if (v==fa) continue; if (!p[v]) continue; if (!bo2) { bo2=1; l1[x]=l1[v]-1; r1[x]=r1[v]+1; } else { if (l1[x]%2!=(l1[v]-1)%2) {bo=0;return;} l1[x]=max(l1[x],l1[v]-1); r1[x]=min(r1[x],r1[v]+1); if (l1[x]>r1[x]) {bo=0;return;} } } } void solve(int x,int fa) { int k,v; if (x==1) a[x]=l1[x]; else if (!p[x]||(a[fa]+1>=l1[x]&&a[fa]+1<=r1[x])) a[x]=a[fa]+1; else a[x]=a[fa]-1; for (k=first[x];k;k=next[k]) { v=zhi[k]; if (v==fa) continue; solve(v,x); } } int main() { scanf("%d",&n); for (i=1;i<n;i++) scanf("%d%d",&s,&t),insert(s,t),insert(t,s); scanf("%d",&m); memset(a,-1,sizeof(a)); for (i=1;i<=m;i++) scanf("%d%d",&s,&t),a[s]=t,p[s]=1; bo=1; dfs(1,0); if (!bo) { puts("NO"); return 0; } solve(1,0); puts("YES"); for (i=1;i<=n;i++) printf("%d\n",a[i]); }
a.cc: In function 'void insert(int, int)': a.cc:43:9: error: reference to 'next' is ambiguous 43 | next[++m1]=first[u]; | ^~~~ In file included from /usr/include/c++/14/string:47, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:40:22: note: 'int next [201000]' 40 | int bo,first[101000],next[201000],zhi[201000],a[101000],p[101000],l1[101000],r1[101000]; | ^~~~ a.cc: In function 'void dfs(int, int)': a.cc:51:29: error: reference to 'next' is ambiguous 51 | for (k=first[x];k;k=next[k]) | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:40:22: note: 'int next [201000]' 40 | int bo,first[101000],next[201000],zhi[201000],a[101000],p[101000],l1[101000],r1[101000]; | ^~~~ a.cc:62:29: error: reference to 'next' is ambiguous 62 | for (k=first[x];k;k=next[k]) | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:40:22: note: 'int next [201000]' 40 | int bo,first[101000],next[201000],zhi[201000],a[101000],p[101000],l1[101000],r1[101000]; | ^~~~ a.cc: In function 'void solve(int, int)': a.cc:86:29: error: reference to 'next' is ambiguous 86 | for (k=first[x];k;k=next[k]) | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:40:22: note: 'int next [201000]' 40 | int bo,first[101000],next[201000],zhi[201000],a[101000],p[101000],l1[101000],r1[101000]; | ^~~~
s600318214
p03949
C++
#include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<algorithm> #include<cmath> #include<vector> #include<queue> #include<set> #include<map> #define ll long long #define inf 1e9 #define eps 1e-10 #define mod 9901 #define mkp make_pair using namespace std; int i,j,k,m,s,t,n,ans1,ans2,n1,nn,m1,mx; int read() { int x=0,f=1;char ch=getchar(); while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=getchar();} while (ch>='0'&&ch<='9') {x=x*10+ch-'0';ch=getchar();} return x*f; } int kabs(int a) { if (a<0) return -a; return a; } void add(int &x,int y) { x+=y; if (x>=mod) x-=mod; } void dec(int &x,int y) { x-=y; if (x<0) x+=mod; } int bo,first[101000],next[201000],zhi[201000],a[101000],p[101000],l1[101000],r1[101000]; void insert(int u,int v) { next[++m1]=first[u]; first[u]=m1; zhi[m1]=v; } void dfs(int x,int fa) { if (!bo) return; int k,v,bo2=0; for (k=first[x];k;k=next[k]) { v=zhi[k]; if (v==fa) continue; dfs(v,x); p[x]|=p[v]; } if (!bo) return; if (!p[x]) return; if (a[x]!=-1) bo2=1,l1[x]=r1[x]=a[x]; for (k=first[x];k;k=next[k]) { v=zhi[k]; if (v==fa) continue; if (!p[v]) continue; if (!bo2) { bo2=1; l1[x]=l1[v]-1; r1[x]=r1[v]+1; } else { if (l1[x]%2!=(l1[v]-1)%2) {bo=0;return;} l1[x]=max(l1[x],l1[v]-1); r1[x]=min(r1[x],r1[v]+1); if (l1[x]>r1[x]) {bo=0;return;} } } } void solve(int x,int fa) { int k,v; if (x==1) a[x]=l1[x]; else if (!p[x]||(a[fa]+1>=l1[x]&&a[fa]+1<=r1[x])) a[x]=a[fa]+1; else a[x]=a[fa]-1; for (k=first[x];k;k=next[k]) { v=zhi[k]; if (v==fa) continue; solve(v,x); } } int main() { scanf("%d",&n); for (i=1;i<n;i++) scanf("%d%d",&s,&t),insert(s,t),insert(t,s); scanf("%d",&m); memset(a,-1,sizeof(a)); for (i=1;i<=m;i++) scanf("%d%d",&s,&t),a[s]=t,p[s]=1; bo=1; dfs(1,0); if (!bo) { puts("NO"); return 0; } solve(1,0); puts("YES"); for (i=1;i<=n;i++) printf("%d\n",a[i]); }
a.cc: In function 'void insert(int, int)': a.cc:43:9: error: reference to 'next' is ambiguous 43 | next[++m1]=first[u]; | ^~~~ In file included from /usr/include/c++/14/string:47, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:40:22: note: 'int next [201000]' 40 | int bo,first[101000],next[201000],zhi[201000],a[101000],p[101000],l1[101000],r1[101000]; | ^~~~ a.cc: In function 'void dfs(int, int)': a.cc:51:29: error: reference to 'next' is ambiguous 51 | for (k=first[x];k;k=next[k]) | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:40:22: note: 'int next [201000]' 40 | int bo,first[101000],next[201000],zhi[201000],a[101000],p[101000],l1[101000],r1[101000]; | ^~~~ a.cc:62:29: error: reference to 'next' is ambiguous 62 | for (k=first[x];k;k=next[k]) | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:40:22: note: 'int next [201000]' 40 | int bo,first[101000],next[201000],zhi[201000],a[101000],p[101000],l1[101000],r1[101000]; | ^~~~ a.cc: In function 'void solve(int, int)': a.cc:86:29: error: reference to 'next' is ambiguous 86 | for (k=first[x];k;k=next[k]) | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:40:22: note: 'int next [201000]' 40 | int bo,first[101000],next[201000],zhi[201000],a[101000],p[101000],l1[101000],r1[101000]; | ^~~~
s086521184
p03949
C
/* cat <<EOF >mistaken-paste */ #pragma GCC diagnostic ignored "-Wincompatible-pointer-types" #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h> #include <stdbool.h> #include <math.h> #define BIG 2000000007 #define VERYBIG 200000000000007LL #define MOD 1000000007 typedef uint64_t ull; typedef int64_t sll; #define N_MAX 100000 #define M_MAX 100000 #ifdef __cplusplus #include <queue> #include <stack> using namespace std; // I'm NOT gonna use C++ without compro. shit typedef priority_queue<ull, vector<ull>, greater<ull> > upque123; typedef priority_queue<ull, vector<ull> > upque321; typedef priority_queue<sll, vector<sll>, greater<sll> > spque123; typedef priority_queue<sll, vector<sll> > spque321; #endif typedef struct { int32_t a; int32_t b; } hw; typedef struct { sll a; sll b; } hwll; typedef struct { hwll a; hwll b; } linell; typedef struct { ull s; ull t; int32_t c; } struct_a; typedef struct { int32_t from; int32_t to; sll cost; } struct_b; const hw vector8[8] = { {-1, -1}, {-1, 0}, {-1, +1}, { 0, -1}, { 0, +1}, {+1, -1}, {+1, 0}, {+1, +1} }; ull n, m; ull h, w; ull k; ull q; ull vua, vub, vuc, vud, vue, vuf; sll vsa, vsb, vsc, vsd, vse, vsf; long double vra, vrb, vrc; double vda, vdb, vdc; size_t slen; size_t tlen; char ch, dh; // ull a[N_MAX]; // ull a[M_MAX]; sll a[N_MAX]; // ull a[N_MAX][M_MAX]; // ull wall[N_MAX][N_MAX]; // double wall[N_MAX][N_MAX]; // ull b[N_MAX]; // ull b[M_MAX]; // sll b[N_MAX]; // ull b[N_MAX][N_MAX]; // sll b[N_MAX][N_MAX]; // ull c[N_MAX]; // ull c[M_MAX]; sll c[N_MAX]; char s[N_MAX + 1]; char t[N_MAX + 1]; // char s[N_MAX][M_MAX + 1]; // char t[N_MAX][M_MAX + 1]; // ull alphabets[26]; // sll imos[N_MAX + 5]; hwll arr[N_MAX]; // hwll arr[M_MAX]; // hwll arr[N_MAX * M_MAX]; // hw brr[M_MAX]; hwll brr[N_MAX]; // linell arr[N_MAX][N_MAX]; hwll crr[N_MAX]; // ull bitdp[1 << 8]; // ull digitdp[1001][ 3][ 2]; // pos less carry // ull digitdp[1001][ 2]; // pos carry // struct_a arr[N_MAX * 2]; // struct_b brr[M_MAX * 2]; sll dist[N_MAX]; struct_b path[M_MAX * 2]; void swap_adj (ull *a, ull *b) { if (*a != *b) { ull tmp = *b; *b = *a; *a = tmp; } return; } ull divide (ull a, ull b) { ull x = MOD - 2; ull ans = 1; while (x) { if (x & 1) ans = (ans * b) % MOD; b = (b * b) % MOD; x /= 2; } return (a * ans) % MOD; } int32_t digits (ull x) { int32_t i = 1; while (x >= 10) { x /= 10; i++; } return i; } ull umin (ull x, ull y) { return (x < y) ? x : y; } ull umax (ull x, ull y) { return (x > y) ? x : y; } sll smin (sll x, sll y) { return (x < y) ? x : y; } sll smax (sll x, sll y) { return (x > y) ? x : y; } ull gcd (ull x, ull y) { if (x < y) { return gcd(y, x); } else if (y == 0) { return x; } else { return gcd(y, x % y); } } ull bitpow (ull a, ull x, ull modulo) { ull result = 1; while (x) { if (x & 1) { result *= a; result %= modulo; } x /= 2; a = (a * a) % modulo; } return result; } int32_t targetdig (ull x, int32_t index /* 1-indexed */) { // static...? int32_t posmax = digits(x); if (posmax < index) return -1; while (posmax > index) { posmax--; x /= 10; } return x % 10; } int32_t charcomp (const char left, const char right) { if (left < right) { return -1; } else if (left > right) { return +1; } else { return 0; } } int32_t pcharcomp (const void *left, const void *right) { char lval = *(char*)left; char rval = *(char*)right; return charcomp(lval, rval); } int32_t intcomp (const int32_t left, const int32_t right) { if (left < right) { return -1; } else if (left > right) { return +1; } else { return 0; } } int32_t pintcomp (const void *left, const void *right) { int lval = *(int*)left; int rval = *(int*)right; return intcomp(lval, rval); } int32_t ullcomp (const ull left, const ull right) { if (left < right) { return -1; } else if (left > right) { return +1; } else { return 0; } } int32_t pullcomp (const void *left, const void *right) { ull lval = *(ull*)left; ull rval = *(ull*)right; return ullcomp(lval, rval); } int32_t pullrevcomp (const void *left, const void *right) { ull lval = *(ull*)left; ull rval = *(ull*)right; return -ullcomp(lval, rval); } int32_t sllcomp (const sll left, const sll right) { if (left < right) { return -1; } else if (left > right) { return +1; } else { return 0; } } int32_t psllcomp (const void *left, const void *right) { sll lval = *(sll*)left, rval = *(sll*)right; return ullcomp(lval, rval); } int32_t hwllfraccomp (const hwll left, const hwll right) { return ullcomp(left.a * right.b, left.b * right.a); } int32_t phwAcomp (const hw *left, const hw *right) { return intcomp(left->a, right->a); } int32_t phwBcomp (const hw *left, const hw *right) { return intcomp(left->b, right->b); } int32_t phwABcomp (const hw *left, const hw *right) { int32_t x = phwAcomp(left, right); if (x) return x; return phwBcomp(left, right); } int32_t phwllAcomp (const hwll *left, const hwll *right) { return sllcomp(left->a, right->a); } int32_t phwllBcomp (const hwll *left, const hwll *right) { return sllcomp(left->b, right->b); } int32_t phwllABcomp (const void *left, const void *right) { hwll lval = *(hwll*)left, rval = *(hwll*)right; int32_t x = sllcomp(lval.a, rval.a); if (x) return x; return sllcomp(lval.b, rval.b); } int32_t phwllrAcBcomp (const hwll *left, const hwll *right) { int32_t x = -phwllAcomp(left, right); if (x) return x; return phwllBcomp(left, right); } int32_t phwllBAcomp (const hwll *left, const hwll *right) { int32_t x = phwllBcomp(left, right); if (x) return x; return phwllAcomp(left, right); } int32_t pstrAcomp (const struct_a *left, const struct_a *right) { int32_t x; if (x = ullcomp(left->t, right->t)) return x; if (x = ullcomp(left->s, right->s)) return x; if (x = intcomp(left->c, right->c)) return x; return 0; } int32_t bitlet (char c) { return (1 << (c - 'a')); } ull ullabs (ull a, ull b) { if (a >= b) { return a - b; } else { return b - a; } } sll sllabs (sll a, sll b) { if (a >= b) { return a - b; } else { return b - a; } } sll nibutanlobo (bool (*func)(sll arg), sll ok, sll ng) { while (sllabs(ok, ng) > 1) { sll med = (ok + ng) / 2; if (func(med)) { ok = med; } else { ng = med; } // printf("debug: [%lld %lld)\n", ok, ng); } if (!func(ok)) return ok * 2 - ng; return ok; } bool nextrouteint (int32_t arr[], int32_t n) { int32_t i = n - 1; int32_t j, x; while (i > 0 && arr[i - 1] > arr[i]) i--; if (i == 0) return false; x = n; for (j = i; j < n; j++) { if (arr[j] < arr[i - 1]) continue; if (x == n || arr[x] > arr[j]) x = j; } arr[i - 1] ^= arr[x]; arr[x] ^= arr[i - 1]; arr[i - 1] ^= arr[x]; qsort(&arr[i], n - i, sizeof(int32_t), pintcomp); return true; } bool nextrouteull (ull arr[], int32_t n) { int32_t i = n - 1; int32_t j, x; while (i > 0 && arr[i - 1] > arr[i]) i--; if (i == 0) return false; x = n; for (j = i; j < n; j++) { if (arr[j] < arr[i - 1]) continue; if (x == n || arr[x] > arr[j]) x = j; } arr[i - 1] ^= arr[x]; arr[x] ^= arr[i - 1]; arr[i - 1] ^= arr[x]; qsort(&arr[i], n - i, sizeof(ull), pintcomp); return true; } void printUquotient (ull left, ull right) { const int32_t digits = 20; printf("%llu.", left / right); left %= right; for (int32_t i = 0; i < digits; i++) { left *= 10; printf("%1d", left / right); left %= right; } puts(""); return; } void printSquotient (sll left, sll right) { if (left * right < 0) putchar('-'); printUquotient(sllabs(left, 0), sllabs(right, 0)); return; } int bitcount (ull n) { int result = 0; while (n) { if (n & 1) result++; n /= 2; } return result; } #ifdef __cplusplus typedef struct { int32_t to; sll cost; } edge; typedef pair<sll, int32_t> P; std::vector<edge> g[N_MAX]; void dijk_init (ull n, struct_b arr[]) { edge x; for (int32_t i = 0; i < n; i++) { x.to = arr[i].to; x.cost = arr[i].cost; g[arr[i].from].push_back(x); } } void dijk_distinit (int s, sll distance[], ull n) { for (int32_t i = 0; i < n; i++) { distance[i] = BIG; } distance[s] = 0; return; } bool dijkstra (int s, sll distance[]) { priority_queue<P, std::vector<P>, greater<P> > que; // (最短距離, 頂点番号) que.push(P(distance[s], s)); bool ischanged = false; while (!que.empty()) { P p = que.top(); que.pop(); sll v = p.second; if (distance[v] < p.first) continue; int32_t maxsize = g[v].size(); for (int32_t i = 0; i < maxsize; i++) { edge e = g[v][i]; if (distance[e.to] > distance[v] + e.cost) { distance[e.to] = distance[v] + e.cost; ischanged = true; que.push(P(distance[e.to], e.to)); } } } return ischanged; } #endif // ull dp[N_MAX]; // sll dp[N_MAX]; // bool dp[N_MAX + 1]; // bool dp[N_MAX + 1][M_MAX + 1]; // ull bitsetdp[M_MAX + 1]; int32_t dp[N_MAX]; // ull dp[N_MAX + 1][M_MAX + 1]; // ull dp[N_MAX * N_MAX]; // double dp[N_MAX]; // ull dp[N_MAX][N_MAX][N_MAX]; // double dp[N_MAX][70][40][30]; // ull dq[N_MAX]; // ull dq[N_MAX + 1][M_MAX + 1]; // sll dq[N_MAX]; // bool dq[N_MAX]; // bool dq1[N_MAX][N_MAX]; // bool dq2[N_MAX][N_MAX]; // double dq[N_MAX]; // hwll dp[N_MAX + 1][N_MAX + 1]; // struct_a dp[N_MAX + 1][N_MAX + 1]; // ull dr[N_MAX]; // ull ds[N_MAX]; // ull sumdp[N_MAX]; // ull dp1[50][M_MAX + 1]; // ull dp2[M_MAX + 1][N_MAX]; double distance (sll x1, sll y1, sll x2, sll y2) { double xdist2, ydist2, origindist, dist; xdist2 = (x1 - x2) * (x1 - x2); ydist2 = (y1 - y2) * (y1 - y2); return sqrt(xdist2 + ydist2); } ull func (ull limityear) { return (limityear / 400) - (limityear / 100) + (limityear / 4); } ull solve () { sll i, j, ki, l; ull result = 0; // sll result = 0; ull maybe = 0; // sll maybe = 0; // double result = 0; ull sum = 0; // sll sum = 0; ull item; ull *dpcell; // qsortの際には"p"ullcompを使う for (i = 0; i < n; i++) { brr[i].a = -BIG; brr[i].b = BIG; } scanf("%llu", &k); for (i = 0; i < k; i++) { int v; sll p; scanf("%d%lld", &v, &p); --v; brr[v].a = brr[v].b = p; } for (i = 0; i < n - 1; i++) { path[i * 2].from = path[i * 2 + 1].to = arr[i].a; path[i * 2].to = path[i * 2 + 1].from = arr[i].b; path[i * 2].cost = path[i * 2 + 1].cost = 1; } dijk_init(n * 2 - 2, path); dijk_distinit(0, dist, n); dijkstra(0, dist); for (i = 0; i < n; i++) { crr[i].a = dist[i]; crr[i].b = i; } qsort(crr, n, sizeof(hwll), phwllABcomp); for (i = n - 1; i > 0; i--) { int index = crr[i].b; int parent; for (j = g[index].size() - 1; j >= 0; j--) { int to = g[index][j].to; // printf(" g[%d][%lld].to: %d (dist[%d]: %lld, dist[%d]: %lld)\n", index, j, to, to, dist[to], index, dist[index]); if (dist[to] < dist[index]) { parent = to; dp[index] = parent; break; } } if (brr[index].b != BIG) { sll minval = brr[index].a - 1; sll maxval = brr[index].b + 1; // printf("dq[%d]: %d\n", index, dp[index]); if (brr[parent].b != BIG) { if (brr[parent].b < minval) goto fail; if (brr[parent].a > maxval) goto fail; if (sllabs(brr[parent].a + minval, 0) % 2) goto fail; } brr[parent].a = smax(brr[parent].a, minval); brr[parent].b = smin(brr[parent].b, maxval); } } for (i = 0; i < n; i++) { int index = crr[i].b; int parent = dp[index]; if (i == 0) { a[index] = brr[index].a; continue; } if (a[parent] - 1 < brr[index].a) { a[index] = a[parent] + 1; } else { a[index] = a[parent] - 1; } } puts("Yes"); for (i = 0; i < n; i++) { printf("%lld\n", a[i]); } // printf("%llu\n", result); // printf("%.12lf\n", result); // puts(s); return 0; success: // puts("YES"); // puts("Yes"); // printf("%llu\n", result); puts("Alice"); return 0; fail: // puts("NO"); puts("No"); // puts("0"); // puts("-1"); // puts("-1 -1 -1"); // puts("Borys"); return 1; } int32_t main (void) { int32_t i, j; int32_t x, y; // scanf("%lf", &vda); // scanf("%lld%lld%lld%lld", &vsa, &vsb, &vsc, &vsd); // scanf("%llu%llu%llu", &vua, &vub, &vuc); // scanf("%llu%llu", &h, &w); scanf("%llu", &n, &m); // scanf("%*llu"); // scanf("%llu%llu", &k, &m, &n); // scanf("%llu%llu", &vua, &vub, &vuc, &vud, &vue); // scanf("%llu%llu%llu", &vsa, &vsb, &vsc); // scanf("%s", s); // scanf("%s", t); // scanf("%llu", &vua); for (i = 0; i < n - 1; i++) { scanf("%llu", &arr[i].a); scanf("%llu", &arr[i].b); // a[i]--; arr[i].a--; arr[i].b--; } // scanf("%llu", &q); // for (i = 0; i < q; i++) { // // scanf("%s%s", s, t); // // solve(); // } // for (i = 0; i < m; i++) { // scanf("%llu", &b[i]); // // b[i]--; // } // for (i = 0; i < k; i++) { // scanf("%d", &dp[i]); // dp[i]--; // } // for (i = 0; i < n; i++) { // scanf("%s", s[i]); // } // for (i = 0; i < m; i++) { // scanf("%s", t[i]); // } // for (i = 0; i < h; i++) { // scanf("%s", s[i]); // } // for (i = 0; i < n; i++) { // scanf("%llu%llu%llu", &a[i], &b[i], &c[i]); // c[i]--; // } // for (i = 0; i < m; i++) { // scanf("%llu%llu", &arr[i].a, &arr[i].b); // arr[i].a--; // arr[i].b--; // } // for (i = 0; i < n; i++) { // for (j = 0; j < m; j++) { // scanf("%llu", &a[i][j]); // a[i][j]--; // } // } solve(); // for (i = 0; i < n; i++) { // // scanf("%llu%llu", &vua, &vub); // scanf("%s%s", s, t); // // scanf("%f%f%f", &vda, &vdb, &vdc); // // scanf("%s", s); // solve(); // } // while (scanf("%llu%llu", &n, &k), n + k) { // for (i = 0; i < n; i++) { // scanf("%llu", &a[i]); // } // solve(); // } return 0; }
main.c: In function 'solve': main.c:567:9: error: implicit declaration of function 'dijk_init' [-Wimplicit-function-declaration] 567 | dijk_init(n * 2 - 2, path); | ^~~~~~~~~ main.c:568:9: error: implicit declaration of function 'dijk_distinit' [-Wimplicit-function-declaration] 568 | dijk_distinit(0, dist, n); | ^~~~~~~~~~~~~ main.c:569:9: error: implicit declaration of function 'dijkstra' [-Wimplicit-function-declaration] 569 | dijkstra(0, dist); | ^~~~~~~~ main.c:580:26: error: 'g' undeclared (first use in this function) 580 | for (j = g[index].size() - 1; j >= 0; j--) { | ^ main.c:580:26: note: each undeclared identifier is reported only once for each function it appears in
s944565399
p03949
C++
#include <iostream> #include <cstdio> #include <algorithm> #include <string> #include <vector> #include <map> #include <set> using namespace std; static const int INF = 0x3f3f3f3f; int main() { int n; scanf("%d", &n); vector<vector<int>> g(n); for (int i = 0; i < n - 1; i ++) { int a, b; scanf("%d%d", &a, &b); a --, b --; g[a].push_back(b); g[b].push_back(a); } int k; scanf("%d", &k); vector<int> val(n, INF); while (k --) { int v, p; scanf("%d%d", &v, &p); v --; val[v] = p; } vector<pair<int, int>> seg(n); function<bool (int, int)> dfs = [&](int u, int prev) { vector<pair<int, int>> segs; for (auto v : g[u]) if (v != prev) { if (!dfs(v, u)) return false; if (seg[v].first != INF) { segs.push_back(make_pair(seg[v].first - 1, seg[v].second + 1)); } } if (segs.empty()) { if (val[u] != INF) { seg[u] = make_pair(val[u], val[u]); } else { seg[u] = make_pair(INF, INF); } return true; } int l = 0, r = INF; for (int i = 0; i < segs.size(); i ++) { l = max(l, segs[i].first); r = min(r, segs[i].second); } if (val[u] != INF) { if (val[u] < l || r < val[u]) { return false; } else { l = val[u], r = val[u]; } } if (l > r) { return false; } seg[u] = make_pair(l, r); return true; }; if (!dfs(0, -1)) { return !printf("No\n"); } printf("Yes\n"); vector<int> ans(n, INF); function<void (int, int)> decide = [&](int u, int prev) { for (auto v : g[u]) if (v != prev) { if (seg[v].first > INF / 2) { ans[v] = ans[u] + 1; } else { ans[v] = seg[v].first; } decide(v, u); } }; ans[0] = seg[0].first; decide(0, -1); for (int i = 0; i < n; i ++) { printf("%d\n", ans[i]); } return 0; }
a.cc: In function 'int main()': a.cc:33:9: error: 'function' was not declared in this scope 33 | function<bool (int, int)> dfs = [&](int u, int prev) { | ^~~~~~~~ a.cc:8:1: note: 'std::function' is defined in header '<functional>'; this is probably fixable by adding '#include <functional>' 7 | #include <set> +++ |+#include <functional> 8 | using namespace std; a.cc:33:32: error: expression list treated as compound expression in functional cast [-fpermissive] 33 | function<bool (int, int)> dfs = [&](int u, int prev) { | ^ a.cc:33:18: error: expected primary-expression before 'bool' 33 | function<bool (int, int)> dfs = [&](int u, int prev) { | ^~~~ a.cc:67:14: error: 'dfs' was not declared in this scope 67 | if (!dfs(0, -1)) { | ^~~ a.cc:72:32: error: expression list treated as compound expression in functional cast [-fpermissive] 72 | function<void (int, int)> decide = [&](int u, int prev) { | ^ a.cc:72:18: error: expected primary-expression before 'void' 72 | function<void (int, int)> decide = [&](int u, int prev) { | ^~~~ a.cc:83:9: error: 'decide' was not declared in this scope 83 | decide(0, -1); | ^~~~~~
s137360654
p03949
C++
#include<iostream> #include<string> #include<algorithm> #include<cstdio> #include<cstring> #include<cstdlib> #include<cmath> #include<vector> using namespace std; typedef long long s64; const int ONE = 200005; const int INF = ONE; int get() { int res = 1, Q = 1; char c; while( (c = getchar()) < 48 || c > 57) if(c == '-') Q = -1; if(Q) res = c - 48; while( (c = getchar()) >= 48 && c <= 57) res = res * 10 + c - 48; return res * Q; } struct power { int l, r; }val[ONE]; int n, k; int x, y; int next[ONE], first[ONE], go[ONE], tot; void Add(int u, int v) { next[++tot] = first[u], first[u] = tot, go[tot] = v; next[++tot] = first[v], first[v] = tot, go[tot] = u; } void dfs1(int u, int father) { for(int e = first[u]; e; e = next[e]) { int v = go[e]; if(v == father) continue; dfs1(v, u); val[u].l = max(val[u].l, val[v].l - 1); val[u].r = min(val[u].r, val[v].r + 1); if(val[u].l > val[u].r) {printf("No"); exit(0);} } } int A[ONE]; void dfs2(int u, int father) { if(u != 1) if(val[u].l <= A[father] - 1 && A[father] - 1 <= val[u].r) A[u] = A[father] - 1; else if(val[u].l <= A[father] + 1 && A[father] + 1 <= val[u].r) A[u] = A[father] + 1; else if(val[u].l <= A[father] && A[father] <= val[u].r) A[u] = A[father]; for(int e = first[u]; e; e = next[e]) { int v = go[e]; if(v == father) continue; dfs2(v, u); } } int main() { n = get(); for(int i = 1; i < n; i++) x = get(), y = get(), Add(x, y); for(int i = 1; i <= n; i++) val[i] = (power){0, INF}; k = get(); for(int i = 1; i <= k; i++) x = get(), y = get(), val[x] = (power){y, y}; dfs1(1, 0); A[1] = (val[1].l + val[1].r) / 2; dfs2(1, 0); printf("Yes\n"); for(int i = 1; i <= n; i++) printf("%d\n", A[i]); }
a.cc: In function 'void Add(int, int)': a.cc:37:17: error: reference to 'next' is ambiguous 37 | next[++tot] = first[u], first[u] = tot, go[tot] = v; | ^~~~ In file included from /usr/include/c++/14/string:47, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:33:5: note: 'int next [200005]' 33 | int next[ONE], first[ONE], go[ONE], tot; | ^~~~ a.cc:38:17: error: reference to 'next' is ambiguous 38 | next[++tot] = first[v], first[v] = tot, go[tot] = u; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:33:5: note: 'int next [200005]' 33 | int next[ONE], first[ONE], go[ONE], tot; | ^~~~ a.cc: In function 'void dfs1(int, int)': a.cc:43:46: error: reference to 'next' is ambiguous 43 | for(int e = first[u]; e; e = next[e]) | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:33:5: note: 'int next [200005]' 33 | int next[ONE], first[ONE], go[ONE], tot; | ^~~~ a.cc: In function 'void dfs2(int, int)': a.cc:64:46: error: reference to 'next' is ambiguous 64 | for(int e = first[u]; e; e = next[e]) | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:33:5: note: 'int next [200005]' 33 | int next[ONE], first[ONE], go[ONE], tot; | ^~~~
s053860104
p03949
C++
#include<bits/stdc++.h> using namespace std; #define N 1111116 #define inf 1111111116 int n,x[N],y[N],p[N],next[N],f[N]; priority_queue<pair<int,int> > q; int read(){ int x=0,f=1;char ch=getchar(); for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-f; for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0'; return x*f; } int main(){ n=read(); for (int i=1;i<=n-1;i++){ x[2*i-1]=y[2*i]=read(); y[2*i-1]=x[2*i]=read(); next[2*i-1]=p[x[2*i-1]];p[x[2*i-1]]=2*i-1; next[2*i]=p[x[2*i]];p[x[2*i]]=2*i; } fill(f+1,f+n+1,-inf); for (int k=read();k;k--){ int x=read(),y=read(); f[x]=y;q.push(make_pair(y,x)); } while (!q.empty()){ int t=p[q.top().second];q.pop(); for (;t;t=next[t]) if (f[y[t]]==-inf){ f[y[t]]=f[x[t]]-1; q.push(make_pair(f[y[t]],y[t])); } } for (int i=1;i<=2*n-2;i++) if (abs(f[x[i]]-f[y[i]])!=1){ printf("No\n");return 0; } printf("Yes\n"); for (int i=1;i<=n;i++) printf("%d\n",f[i]); return 0; }
a.cc: In function 'int main()': a.cc:21:17: error: reference to 'next' is ambiguous 21 | next[2*i-1]=p[x[2*i-1]];p[x[2*i-1]]=2*i-1; | ^~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:66, 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_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:6:22: note: 'int next [1111116]' 6 | int n,x[N],y[N],p[N],next[N],f[N]; | ^~~~ a.cc:22:17: error: reference to 'next' is ambiguous 22 | next[2*i]=p[x[2*i]];p[x[2*i]]=2*i; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:6:22: note: 'int next [1111116]' 6 | int n,x[N],y[N],p[N],next[N],f[N]; | ^~~~ a.cc:31:27: error: reference to 'next' is ambiguous 31 | for (;t;t=next[t]) | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:6:22: note: 'int next [1111116]' 6 | int n,x[N],y[N],p[N],next[N],f[N]; | ^~~~
s338568336
p03949
C++
#include <string> #include <sstream> #include <iostream> template<class T> struct Range { T inf_m; T sup_m; bool inf_inclusive_m; bool sup_inclusive_m; static Range Empty_range(); void Reduce(); public: static bool Equal(const Range& left, const Range& right); //static bool compare(const Range& left, const Range& right); Range(); Range(const T& inf, const T& sup, bool inf_inclusive = true, bool sup_inclusive = false); Range(const std::pair<T, T>& pair, bool inf_inclusive = true, bool sup_inclusive = false); // T, Tでなくてもいい Range(const Range& other); Range& operator=(const Range& other); Range& operator&=(const Range& other); bool Is_empty() const; std::string To_string() const; T Width() const; bool Has(const T& point) const; bool Includes(const Range& other) const; }; template<class T> bool operator==(const Range<T>& left, const Range<T>& right); template<class T> bool operator!=(const Range<T>& left, const Range<T>& right); template<class T> const Range<T> operator&(const Range<T>& left, const Range<T>& right); template<class T> std::ostream& operator<<(std::ostream& ost, const Range<T>& range); /* ここを Range(0, 0) とすると無限ループなので注意 */ template<class T> inline Range<T> Range<T>::Empty_range() { return Range(); } /* 空集合であったら [0, 0) の基本形に直す */ template<class T> inline void Range<T>::Reduce() { if (Is_empty()) { *this = Empty_range(); } } template<class T> inline bool Range<T>::Equal(const Range& left, const Range& right) { return inf_m == other.inf_m && sup_m == other.sup_m && inf_inclusive_m == other.inf_inclusive_m && sup_inclusive_m == other.sup_inclusive_m; } template<class T> inline Range<T>::Range() :inf_m(0), sup_m(0), inf_inclusive_m(true), sup_inclusive_m(false) { } template<class T> inline Range<T>::Range(const T& inf, const T& sup, bool inf_inclusive, bool sup_inclusive) : inf_m(inf), sup_m(sup), inf_inclusive_m(inf_inclusive), sup_inclusive_m(sup_inclusive) { Reduce(); } template<class T> inline Range<T>::Range(const std::pair<T, T>& pair, bool inf_inclusive, bool sup_inclusive) : inf_m(pair.first), sup_m(pair.second), inf_inclusive_m(inf_inclusive), sup_inclusive_m(sup_inclusive) { Reduce(); } template<class T> inline Range<T>::Range(const Range& other) : inf_m(other.inf_m), sup_m(other.sup_m), inf_inclusive_m(other.inf_inclusive_m), sup_inclusive_m(other.sup_inclusive_m) { } template<class T> inline Range<T>& Range<T>::operator=(const Range& other) { inf_m = other.inf_m; sup_m = other.sup_m; inf_inclusive_m = other.inf_inclusive_m; sup_inclusive_m = other.sup_inclusive_m; return *this; } template<class T> inline Range<T>& Range<T>::operator&=(const Range& other) { if (inf_m < other.inf_m || (inf_m == other.inf_m && !other.inf_inclusive_m)) { inf_m = other.inf_m; inf_inclusive_m = other.inf_inclusive_m; } if (sup_m > other.sup_m || (sup_m == other.sup_m && !other.sup_inclusive_m)) { sup_m = other.sup_m; sup_inclusive_m = other.sup_inclusive_m; } Reduce(); return *this; } template<class T> inline bool Range<T>::Is_empty() const { return inf_m > sup_m || (inf_m == sup_m && (!inf_inclusive_m || !sup_inclusive_m)); } template<class T> inline std::string Range<T>::To_string() const { if (Is_empty()) return "(Empty)"; std::ostringstream sst; sst << (inf_inclusive_m ? '[' : '(') << inf_m << ", " << sup_m << (sup_inclusive_m ? ']' : ')'); return sst.str(); } template<class T> inline T Range<T>::Width() const { return sup_m - inf_m; } template<class T> inline bool Range<T>::Has(const T& point) const { return (inf_inclusive_m ? point >= inf_m : point > inf_m) && (sup_inclusive_m ? point <= sup_m : point < sup_m); } /* other == (*this) & other の判定でもいいかも */ /* 逆の判定も使いたい */ template<class T> inline bool Range<T>::Includes(const Range& other) const { if (other.Is_empty()) return true; return (inf_inclusive_m || !other.inf_inclusive_m ? other.inf_m >= inf_m : other.inf_m > inf_m) && (sup_inclusive_m || !other.sup_inclusive_m ? other.sup_m <= sup_m : other.sup_m < sup_m); } template<class T> inline bool operator==(const Range<T>& left, const Range<T>& right) { return Range<T>::Equal(left, right); } template<class T> inline bool operator!=(const Range<T>& left, const Range<T>& right) { return !Range<T>::Equal(left, right); } template<class T> inline const Range<T> operator&(const Range<T>& left, const Range<T>& right) { Range<T> ret(left); ret &= right; return ret; } template<class T> inline std::ostream& operator<<(std::ostream& ost, const Range<T>& range) { ost << range.To_string(); return ost; } typedef Range<int> RangeInt; #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <string> #include <vector> #include <list> #include <utility> #include <algorithm> #include <functional> #include <cmath> #include <stack> #include <queue> #include <set> #include <map> #include <iomanip> #include <sstream> #include <numeric> #include <bitset> #include <limits> using namespace std; typedef long long LL; typedef unsigned long long ULL; typedef pair<LL, LL> PP; #define REP(i,a,n) for(int i = (a); i < (int)(n); ++i) #define REPM(i,n,a) for(int i = ((n) - 1); i >= (a); --i) #define FLOAT setprecision(16) #define INSIDE(i,j,H,W) ((i) >= 0 && (i) < (H) && (j) >= 0 && (j) < (W)) #define YesNo(b) (b ? "Yes" : "No") #define YESNO(b) (b ? "YES" : "NO") const int INF = 0x3FFFFFFF; const LL INFLL = 0x3FFFFFFF3FFFFFFF; const double INFD = 1.0e+308; const double EPS = 1.0e-9; template <class T, class U> istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; } template <class T, class U> ostream& operator<<(ostream& ost, pair<T, U>& right) { return ost << right.first << ' ' << right.second; } template <class T, class TCompatible, size_t N> void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); } template <class T, class TCompatible, size_t M, size_t N> void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); } // all_of #if 1234567891 #include <array> #include <unordered_set> #include <unordered_map> template<typename T> using PriorityQ = priority_queue<T, vector<T>, greater<T> >; // コスト小を優先 #endif #if _DEBUG #include "IntMod.h" #include "Union_Find.h" #include "Graph.h" #include "Range.h" #endif int P[100000]; vector<int> G[100000]; int N, K; RangeInt R[100000]; int ans[100000]; bool ok = true; RangeInt dfs(int i, int from) { RangeInt ret = (P[i] == -1 ? RangeInt(-INF, INF) : RangeInt(P[i], P[i], true, true)); for (auto to : G[i]) { if (to == from) continue; ret &= dfs(to, i); } if (ret.Is_empty()) ok = false; R[i] = ret; ret.inf_m--; ret.sup_m++; return ret; } void dfs2(int i, int from) { if(from == -1){ ans[i] = R[i].inf_m; } else { if (P[i] != -1) { if (P[i] != ans[from] + 1 && P[i] != ans[from] - 1) { ok = false; return; } ans[i] = P[i]; return; } if (R[i].Has(ans[from] - 1)) { ans[i] = ans[from] - 1; } else { ans[i] = ans[from] + 1; } } for (auto to : G[i]) { if (to == from) continue; dfs2(to, i); } } int main() { cin >> N; REP(i, 0, N - 1) { int a, b; cin >> a >> b; --a; --b; G[a].push_back(b); G[b].push_back(a); } cin >> K; Fill(P, -1); REP(i, 0, K) { int v, p; cin >> v >> p; --v; P[v] = p; } dfs(0, -1); if (ok) { dfs2(0, -1); } cout << YesNo(ok) << endl; if (ok) { REP(i, 0, N) { cout << ans[i] << endl; } } return 0; }
a.cc: In static member function 'static bool Range<T>::Equal(const Range<T>&, const Range<T>&)': a.cc:61:16: error: invalid use of member 'Range<T>::inf_m' in static member function 61 | return inf_m == other.inf_m | ^~~~~ a.cc:8:11: note: declared here 8 | T inf_m; | ^~~~~ a.cc:61:25: error: 'other' was not declared in this scope 61 | return inf_m == other.inf_m | ^~~~~ a.cc:62:20: error: invalid use of member 'Range<T>::sup_m' in static member function 62 | && sup_m == other.sup_m | ^~~~~ a.cc:9:11: note: declared here 9 | T sup_m; | ^~~~~ a.cc:63:20: error: invalid use of member 'Range<T>::inf_inclusive_m' in static member function 63 | && inf_inclusive_m == other.inf_inclusive_m | ^~~~~~~~~~~~~~~ a.cc:10:14: note: declared here 10 | bool inf_inclusive_m; | ^~~~~~~~~~~~~~~ a.cc:64:20: error: invalid use of member 'Range<T>::sup_inclusive_m' in static member function 64 | && sup_inclusive_m == other.sup_inclusive_m; | ^~~~~~~~~~~~~~~ a.cc:11:14: note: declared here 11 | bool sup_inclusive_m; | ^~~~~~~~~~~~~~~
s806475758
p03949
C++
#include <cstdio> #include <algorithm> #include <cstdlib> #include <utility> typedef long long ll; typedef std::pair<int, int> pii; #define mp std::make_pair int n, k, ans[100005]; bool vis[100005]; int head[100005], next[100005 << 1], to[100005 << 1], ed = 0; int deg[100005]; void AddEdge(int u, int v) { next[++ed] = head[u]; head[u] = ed; to[ed] = v; } pii dp[100005]; pii DP(int now, int fa, bool odd, int L, int R) { if (vis[now]) { if (ans[now] < L || ans[now] > R || (ans[now] & 1) != odd) { puts("No"); exit(0); } L = R = ans[now]; } pii tmp; for (int i = head[now]; i; i = next[i]) { if (to[i] == fa) continue; tmp = DP(to[i], now, odd ^ 1, L - 1, R + 1); L = std::max(L, tmp.first - 1); R = std::min(R, tmp.second + 1); if (L > R) { puts("No"); exit(0); } } return dp[now] = mp(L, R); } void DFS(int now, int fa, bool odd) { ans[now] = dp[now].first + (dp[now].first & 1 != odd); for (int i = head[now]; i; i = next[i]) { if (to[i] == fa) continue; DFS(to[i], now); } } int main() { scanf("%d", &n); for (int u, v, i = 1; i < n; ++i) { scanf("%d%d", &u, &v); AddEdge(u, v); AddEdge(v, u); ++deg[u]; ++deg[v]; } scanf("%d", &k); int v, p; for (int i = 1; i <= k; ++i) { scanf("%d%d", &v, &p); ans[v] = p; vis[v] = 1; } DP(v, 0, p & 1, p, p); DFS(v, 0, p & 1); puts("Yes"); for (int i = 1; i <= n; ++i) printf("%d\n", ans[i]); return 0; }
a.cc: In function 'void DFS(int, int, bool)': a.cc:46:20: error: too few arguments to function 'void DFS(int, int, bool)' 46 | DFS(to[i], now); | ~~~^~~~~~~~~~~~ a.cc:42:6: note: declared here 42 | void DFS(int now, int fa, bool odd) { | ^~~
s915265229
p03949
C++
#include <cstdio> #include <algorithm> #include <cstdlib> #include <utility> typedef long long ll; typedef std::pair<int, int> pii; #define mp std::make_pair int n, k, ans[100005]; bool vis[100005]; int head[100005], next[100005 << 1], to[100005 << 1], ed = 0; int deg[100005]; void AddEdge(int u, int v) { next[++ed] = head[u]; head[u] = ed; to[ed] = v; } pii dp[100005]; pii DP(int now, int fa, bool odd, int L, int R) { if (vis[now]) { if (ans[now] < L || ans[now] > R || (ans[now] & 1) != odd) { puts("No"); exit(0); } L = R = ans[now]; } pii tmp; for (int i = head[now]; i; i = next[i]) { if (to[i] == fa) continue; tmp = DP(to[i], now, odd ^ 1, L - 1, R + 1); L = std::max(L, tmp.first - 1); R = std::min(R, tmp.second + 1); if (L > R) { puts("No"); exit(0); } } return dp[now] = mp(L, R); } void DFS(int now, int fa) { ans[now] = dp[now].first; for (int i = head[now]; i; i = next[i]) { if (to[i] == fa) continue; DFS(to[i], now); } } int main() { scanf("%d", &n); for (int u, v, i = 1; i < n; ++i) { scanf("%d%d", &u, &v); AddEdge(u, v); AddEdge(v, u); ++deg[u]; ++deg[v]; } scanf("%d", &k); int v, p; for (int i = 1; i <= k; ++i) { scanf("%d%d", &v, &p); ans[v] = p; vis[v] = 1; } DP(v, 0, p & 1, p, p); DFS(v, 0, p, p); puts("Yes"); for (int i = 1; i <= n; ++i) printf("%d\n", ans[i]); return 0; }
a.cc: In function 'int main()': a.cc:67:12: error: too many arguments to function 'void DFS(int, int)' 67 | DFS(v, 0, p, p); | ~~~^~~~~~~~~~~~ a.cc:42:6: note: declared here 42 | void DFS(int now, int fa) { | ^~~
s864544362
p03949
C++
#include<iostream> #include<cstdio> #include<vector> #include<cstdlib> #include<queue> using namespace std; int n,k; int dist[100010]; bool vis[100010]; int ans[100010]; vector<pair<int,int> >v[100010]; void dij(int st) { for(int i=1;i<=n;i++)dist[i]=1e9; priority_queue<pair<int,int> , vector<pair<int,int> > ,greater<pair<int,int> > >q; q.push(make_pair(0,0)); memset(vis,false,sizeof(vis)); int s=n+1; while(s--) { while(!q.empty() && (vis[q.top().second] || dist[q.top().second]!=q.top().first))q.pop(); int x=q.top().second; q.pop(); vis[x]=true; for(int i=0;i<v[x].size();i++) { int y=v[x][i].first,w=v[x][i].second; if(vis[y])continue; if(dist[x]+w<dist[y]) { dist[y]=dist[x]+w; q.push(make_pair(dist[y],y)); } } } } int main() { scanf("%d",&n); for(int i=1;i<n;i++) { int x,y; scanf("%d%d",&x,&y); v[x].push_back(make_pair(y,1)); v[y].push_back(make_pair(x,1)); } for(int i=1;i<=n;i++)ans[i]=-1; scanf("%d",&k); for(int i=1;i<=k;i++) { int x,y; scanf("%d%d",&x,&y); v[0].push_back(make_pair(x,y)); ans[x]=y; } dij(0); for(int i=1;i<=n;i++) { if(ans[i]!=-1 && ans[i]!=dist[i]) { printf("No"); return 0; } ans[i]=dist[i]; } puts("Yes"); for(int i=1;i<=n;i++) { printf("%d\n",ans[i]); } return 0; }
a.cc: In function 'void dij(int)': a.cc:17:9: error: 'memset' was not declared in this scope 17 | memset(vis,false,sizeof(vis)); | ^~~~~~ a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 5 | #include<queue> +++ |+#include <cstring> 6 | using namespace std;
s952199760
p03949
C++
#include<cstdio> #include<utility> #include<cstring> #include<vector> #include<string> using namespace std; typedef pair < int , int > pii; template < typename T > T MAX(T a,T b){ return a<b?b:a; } template < typename T > T MIN(T a,T b){ return a<b?a:b; } template < typename T > T ABS(T a){ return a>0?a:-a; } int n,rank[100005],val[100005],fa[100005],mv[100005],m,dlt[100005],base=-1; bool mark[100005];// 0:-1 1:+1 vector < int > G[100005]; inline int enc(int v,int rk){ if(v==1e9) return 1e9; //printf("%d \t%d\n",v,rk); if(base!=-1 && ((v+rk+base)&1)){ printf("No"); exit(0); } else if(base==-1){ if((v+rk)&1) base=1; else base=0; } return ((v+rk+base)>>1); } inline int dec(int v,int rk){ return (v<<1)-rk; } void dfs(int ver,int f){ fa[ver]=f; if(f>=0)rank[ver]=rank[f]+1; int xb; mv[ver]=enc(val[ver],rank[ver]); for(xb=0;xb<G[ver].size();xb++){ if(G[ver][xb]==f) continue; dfs(G[ver][xb],ver); mv[ver]=MIN(mv[G[ver][xb]],mv[ver]); } if(mv[ver]>0){ mark[ver]=1; // printf("Go %d\n",ver+1); mv[ver]--; } } void getdlt(int ver,int f){ //printf("Getting dlt %d\n",ver); if(f>=0){ // printf("%d\n",mark[ver]); if(mark[ver]) dlt[ver]=dlt[f]+1; else dlt[ver]=dlt[f]-1; } else dlt[ver]=0; int xb; for(xb=0;xb<G[ver].size();xb++){ // printf("atp %d\n",G[ver][xb]+1); if(G[ver][xb]!=f) getdlt(G[ver][xb],ver); } } int main(){ scanf("%d",&n); int xb,x2,a,b; fill(val,val+100005,1e9); for(xb=0;xb<n-1;xb++){ scanf("%d%d",&a,&b); a--; b--; G[a].push_back(b); G[b].push_back(a); } scanf("%d",&m); for(xb=0;xb<m;xb++){ scanf("%d%d",&a,&b); val[a-1]=b; } dfs(0,-1); if(mv[0]<1e8){ getdlt(0,-1); //for(xb=0;xb<n;xb++) printf("\t%d %d\n",xb+1,dlt[xb]); int v0=-1e9; for(xb=0;xb<n;xb++) { if(val[xb]!=1e9){ if(v0!=-1e9 && v0!=val[xb]-dlt[xb]){ printf("No"); return 0; } v0=val[xb]-dlt[xb]; } } printf("Yes\n"); for(xb=0;xb<n;xb++) printf("%d\n",dlt[xb]+v0); } else{ printf("Yes\n"); getdlt(0,-1); for(xb=0;xb<n;xb++) printf("%d\n",dlt[xb]); } return 0; }
a.cc: In function 'void dfs(int, int)': a.cc:37:17: error: reference to 'rank' is ambiguous 37 | if(f>=0)rank[ver]=rank[f]+1; | ^~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/utility:69, from a.cc:2: /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:17:7: note: 'int rank [100005]' 17 | int n,rank[100005],val[100005],fa[100005],mv[100005],m,dlt[100005],base=-1; | ^~~~ a.cc:37:27: error: reference to 'rank' is ambiguous 37 | if(f>=0)rank[ver]=rank[f]+1; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:17:7: note: 'int rank [100005]' 17 | int n,rank[100005],val[100005],fa[100005],mv[100005],m,dlt[100005],base=-1; | ^~~~ a.cc:39:30: error: reference to 'rank' is ambiguous 39 | mv[ver]=enc(val[ver],rank[ver]); | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:17:7: note: 'int rank [100005]' 17 | int n,rank[100005],val[100005],fa[100005],mv[100005],m,dlt[100005],base=-1; | ^~~~
s083278983
p03949
C++
#include<stdio.h> #include<string> #include<math.h> #include<stdlib.h> #include<set> #include<bitset> #include<map> #include<vector> #include<string.h> #include<algorithm> #include<iostream> #include<queue> #include<deque> #include<stack> using namespace std; const int INF=12345678; const int N=100005; bool end=false; int n,m,fir; vector<int> nei[N]; int vert[N]; bool check(){ for(int i=1;i<=n;i++) if(vert[i]==INF) return false; return true; } void dfs(int x){ for(int i=0;i<nei[x].size();i++){ int now=nei[x][i]; if(vert[now]!=INF){ if(vert[now]-vert[x]==1) continue; if(vert[x]-vert[now]==1) continue; return; } vert[now]=vert[x]+1; dfs(now); if(end) return; vert[now]=vert[x]-1; dfs(now); if(end) return; vert[now]=INF; } if(check()){ cout<<"Yes"<<endl; for(int i=1;i<=n;i++) cout<<vert[i]<<endl; end=true; } } int main(){ cin>>n; for(int i=0;i<n-1;i++){ int x,y; cin>>x>>y; nei[x].push_back(y); nei[y].push_back(x); } cin>>m; for(int i=1;i<=n;i++) vert[i]=INF; for(int i=0;i<m;i++){ int x,y; cin>>x>>y; vert[x]=y; if(!fir) fir=x; } dfs(fir); if(!end) cout<<"No"<<endl; return 0; }
a.cc: In function 'void dfs(int)': a.cc:39:20: error: reference to 'end' is ambiguous 39 | if(end) return; | ^~~ In file included from /usr/include/c++/14/string:53, from a.cc:2: /usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ In file included from /usr/include/c++/14/bits/range_access.h:36: /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:19:6: note: 'bool end' 19 | bool end=false; | ^~~ a.cc:42:20: error: reference to 'end' is ambiguous 42 | if(end) return; | ^~~ /usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:19:6: note: 'bool end' 19 | bool end=false; | ^~~ a.cc:48:17: error: reference to 'end' is ambiguous 48 | end=true; | ^~~ /usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:19:6: note: 'bool end' 19 | bool end=false; | ^~~ a.cc: In function 'int main()': a.cc:69:13: error: reference to 'end' is ambiguous 69 | if(!end) cout<<"No"<<endl; | ^~~ /usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ a.cc:19:6: note: 'bool end' 19 | bool end=false; | ^~~
s990509619
p03949
C++
// This amazing code is by Eric Sunli Chen. #include <algorithm> #include <bitset> #include <cmath> #include <cstring> #include <cstdio> #include <cstdlib> #include <ctime> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <utility> #include <vector> using namespace std; template<typename T> void get_int(T &x) { char t=getchar(); bool neg=false; x=0; for(; (t>'9'||t<'0')&&t!='-'; t=getchar()); if(t=='-')neg=true,t=getchar(); for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0'; if(neg)x=-x; } template<typename T> void print_int(T x) { if(x<0)putchar('-'),x=-x; short a[20]= {},sz=0; while(x>0)a[sz++]=x%10,x/=10; if(sz==0)putchar('0'); for(int i=sz-1; i>=0; i--)putchar('0'+a[i]); } #define ff first #define ss second #define pb push_back #define mp make_pair #define get1(a) get_int(a) #define get2(a,b) get1(a),get1(b) #define get3(a,b,c) get1(a),get2(b,c) #define printendl(a) print_int(a),puts("") typedef long long LL; typedef unsigned long long uLL; typedef pair<int,int> pii; const int inf=0x3f3f3f3f; const LL Linf=1ll<<61; const double pi=acos(-1.0); vector<int> g[100111]; int n,k,a[100111],mn[100111],root; bool add[100111]; void dfs(int x,int f=0,int d=0) { mn[x]=inf; for(int i=0;i<(int)g[x].size();i++) if(g[x][i]!=f) { dfs(g[x][i],x,d+1); mn[x]=min(mn[x],mn[g[x][i]]); } if(a[x]&&(a[x]+d<a[root]||a[x]-d>a[root]||(a[root]-a[x]+d)%2==1)) { puts("No"); exit(0); } mn[x]=min(mn[x],(a[x]-a[root]+d)/2); } void dfs2(int x,int f=0,int v=0,int d=0) { int val=a[root]-d+2*v; if(a[x]&&a[x]!=val) { puts("No"); exit(0); } else a[x]=val; for(int i=0;i<(int)g[x].size();i++) if(g[x][i]!=f) { if(mn[g[x][i]]-v>0)add[g[x][i]]=1; dfs2(g[x][i],x,v+add[g[x][i]],d+1); } } int main() { get1(n); for(int i=1,u,v;i<n;i++) { get2(u,v); g[u].pb(v); g[v].pb(u); } get1(k); for(int i=1,x,y;i<=k;i++) { get2(x,y); root=x; a[x]=y; } dfs(root); dfs2(root); puts("Yes"); for(int i=1;i<=n;i++)printendl(a[i]);
a.cc: In function 'int main()': a.cc:105:46: error: expected '}' at end of input 105 | for(int i=1;i<=n;i++)printendl(a[i]); | ^ a.cc:87:1: note: to match this '{' 87 | { | ^
s599287665
p03949
C++
#include <iostream> #include <cstdio> #include <vector> #define _USE_MATH_DEFINES #include <math.h> #include <cstring> #include <numeric> #include <algorithm> #include <stdlib.h> #include <functional> #include <string> #include <array> #include <map> #include <queue> #include <limits.h> #include <set> #include <stack> #include <random> #include <complex> #include <unordered_map> #include <nmmintrin.h> #include <chrono> #define rep(i,s,n) for(int i = (s); (n) > i; i++) #define REP(i,n) rep(i,0,n) #define RANGE(x,a,b) ((a) <= (x) && (x) <= (b)) #define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b)) #define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d)) #define PW(x) ((x)*(x)) #define ALL(x) (x).begin(), (x).end() #define MODU 1000000007 #define bitcheck(a,b) ((a >> b) & 1) #define bitset(a,b) ( a |= (1 << b)) #define bitunset(a,b) (a &= ~(1 << b)) #define MP(a,b) make_pair((a),(b)) #define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second)) #define pritnf printf #define scnaf scanf #define itn int #ifdef _MSC_VER #define __builtin_popcount _mm_popcnt_u32 #define __builtin_popcountll _mm_popcnt_u64 #endif using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a%b); } template<typename A, size_t N, typename T> void Fill(A(&array)[N], const T &val) { std::fill((T*)array, (T*)(array + N), val); } class Graph { public: int vn; int sumcost = 0; vector<vector<pii>> g; Graph(int n) { vn = n; g.resize(n); } virtual void con(int a, int b, int w) = 0; int getWeight(int f, int t) { auto itr = lower_bound(ALL(g[f]), make_pair(t, INT_MIN)); if (itr != g[f].end()) return itr->second; return INT_MIN; } int Costsum() { return sumcost; } void scan(int edcount, bool oindexed, bool w) { REP(i, edcount) { int a, b, c = 1; scanf("%d %d", &a, &b); if (w)scanf("%d", &c); con(a - oindexed, b - oindexed, c); } } }; class BiDGraph : public Graph {//無向 public: BiDGraph(int n) : Graph(n) {} void con(int a, int b, int w = 1) { g[a].push_back({ b,w }); g[b].push_back({ a, w }); sumcost++; } }; signed main() { int n; cin >> n; BiDGraph g(n); REP(i, n-1) { int a, b; scanf("%d %d", &a, &b); g.con(a - 1, b - 1); } vector<int> depth(n),par(n); function<void(int, int)> dfs = [&](int c, int p) { par[c] = p; depth[c] = p == -1 ? 0 : depth[p] + 1; for (auto itr : g.g[c]) if (itr.first != p) dfs(itr.first, c); }; dfs(0, -1); vector<pii> num(n, {INT_MAX, INT_MAX}); vector<int> ev(n, -1); int m; cin >> m; vector<int> in(n), ot(n); priority_queue<pii>> pq; REP(i, m) { int a, b; scanf("%d %d", &a, &b); --a; num[a] = { b,b }; pq.push(MP(depth[a], a)); ev[a] = b % 2; in[a]++; } while (pq.size()) { auto cur = pq.top(); pq.pop(); ot[cur.second]++; if (cur.second == 0) continue; if (num[par[cur.second]] == MP(INT_MAX, INT_MAX)) { num[par[cur.second]] = MP(num[cur.second].first - 1, num[cur.second].second + 1); } else { int cl = num[cur.second].first - 1, cr = num[cur.second].second + 1, l = num[par[cur.second]].first, r = num[par[cur.second]].second; num[par[cur.second]] = { max(cl,l), min(cr,r) }; if (num[par[cur.second]].first > num[par[cur.second]].second) { printf("No\n"); return 0; } } if (ev[par[cur.second]] != -1) { if (ev[par[cur.second]] != (1 - ev[cur.second])) { printf("No\n"); return 0; } } ev[par[cur.second]] = 1 - ev[cur.second]; if (par[cur.second] != 0 && in[cur.second] == ot[cur.second]) { pq.push(MP(depth[par[cur.second]], par[cur.second])); in[par[cur.second]]++; } } printf("Yes\n"); vector<int> out(n); function<void(int, int)> ans = [&](int c, int p) { if (p == -1) out[c] = num[c].first; else out[c] = num[c].first <= (out[p]-1) ? out[p]-1 : out[p]+1; for (auto itr : g.g[c]) { if(itr.first != p) ans(itr.first, c); } }; ans(0, -1); for (auto itr : out) printf("%d\n", itr); return 0; }
a.cc: In function 'int main()': a.cc:122:27: error: expected unqualified-id before '>' token 122 | priority_queue<pii>> pq; | ^~ a.cc:128:17: error: 'pq' was not declared in this scope 128 | pq.push(MP(depth[a], a)); | ^~ a.cc:134:16: error: 'pq' was not declared in this scope 134 | while (pq.size()) { | ^~ a.cc:148:57: error: 'l' was not declared in this scope; did you mean 'cl'? 148 | num[par[cur.second]] = { max(cl,l), min(cr,r) }; | ^ | cl a.cc:148:65: error: 'cr' was not declared in this scope; did you mean 'cl'? 148 | num[par[cur.second]] = { max(cl,l), min(cr,r) }; | ^~ | cl a.cc:148:68: error: 'r' was not declared in this scope 148 | num[par[cur.second]] = { max(cl,l), min(cr,r) }; | ^
s353266268
p03949
C++
#include<bits/stdc++.h> #define N 111111 #define M 222222 #define P 10001000 using namespace std; int T,n,m,i,x,y,tot,S,fir[N],la[M],ne[M],V[N],L[N],R[N],AN[N];char s[N];bool ff,v[N]; void ins(int x,int y){la[++tot]=y;ne[tot]=fir[x];fir[x]=tot;} void dfs1(int x,int fa){ int lv=-1e9,rv=1e9; if(v[x])lv=rv=V[x]; for(int i=fir[x];i;i=ne[i])if(la[i]!=fa){ dfs1(la[i],x); lv=max(lv,L[la[i]]-1); rv=min(rv,R[la[i]]+1); } if(lv>rv)ff=1; if(!v[x])L[x]=lv,R[x]=rv;else{ if(V[x]<lv||V[x]>rv)ff=1; } } void dfs2(int x,int fa){ int lv=L[x],rv=R[x]; if(fa)lv=max(lv,L[fa]-1),rv=min(rv,R[fa]+1); for(int i=fir[x];i;i=ne[i])if(la[i]!=fa){ dfs2(la[i],x); } if(lv>rv)ff=1; if(!v[x])L[x]=lv,R[x]=rv;else{ if(V[x]<lv||V[x]>rv)ff=1; } } int change(int x,int y){ x--; int w=(y-x+1)/2; return x+w*2; } int gg(int x,int y){ x++; int w=(x-y+1)/2; return x-w*2; } int to(int l1,int r1,int l2,int r2){ if(l1-1<=l2)return change(l1,l2); if(r1+1>=r2)return gg(r1,r2); } void getans(int x,int fa){ int o,i,lv,rv; if(v[x]){ if(!fa||(AN[fa]-1==V[x]||AN[fa]+1==V[x]))AN[x]=V[x];else ff=1; } else{ if(AN[fa]-1>=L[x]&&AN[fa]-1<=R[x])AN[x]=AN[fa]-1; else if(AN[fa]+1>=L[x]&&AN[fa]+1<=R[x])AN[x]=AN[fa]+1; else ff=1; } for(i=fir[x];i;i=ne[i])if(la[i]!=fa)getans(la[i],x,w^1); } void check(int x,int fa){ if(fa)if(AN[fa]+1!=AN[x]&&AN[fa]-1!=AN[x])ff=1; for(int i=fir[x];i;i=ne[i])if(la[i]!=fa)check(la[i],x); } int main(){ for(scanf("%d",&n),i=1;i<n;i++)scanf("%d%d",&x,&y),ins(x,y),ins(y,x); for(scanf("%d",&m),i=1;i<=m;i++)scanf("%d%d",&x,&y),v[x]=1,V[x]=y,S=x; if(!m)v[1]=1,V[1]=1,S=1; dfs1(1,0);dfs2(1,0); getans(S,0); if(ff)return puts("No"),0; check(S,0); if(ff)return puts("No"),0; puts("YES"); for(i=1;i<=n;i++)printf("%d\n",AN[i]); }
a.cc: In function 'void getans(int, int)': a.cc:56:60: error: 'w' was not declared in this scope 56 | for(i=fir[x];i;i=ne[i])if(la[i]!=fa)getans(la[i],x,w^1); | ^ a.cc: In function 'int to(int, int, int, int)': a.cc:45:1: warning: control reaches end of non-void function [-Wreturn-type] 45 | } | ^
s715297604
p03949
C++
#include <algorithm> #include <iostream> #include <cstring> #include <climits> #include <cstdio> using namespace std; #define Set(a, b) memset(a, b, sizeof a) const int N = 2e5 + 10; const int Inf = INT_MAX / 2; int n, m, a[N]; int tms, en[N], next[N], to[N]; void Link(int u, int v) { to[++tms] = v; next[tms] = en[u]; en[u] = tms; } int fa[N], b[N], c[N]; void Dfs(int u) { if (~a[u]) c[u] = (b[u] - a[u]) / 2; else c[u] = Inf; for (int p = en[u]; p; p = next[p]) { int v = to[p]; if (!fa[v]) { fa[v] = u; b[v] = b[u] + 1; Dfs(v); } } if (~fa[u]) c[fa[u]] = min(c[fa[u]], c[u]); } void Dfs(int u, int lst) { if ((~a[u] && a[u] != b[u] - lst * 2) || (a[u] == -1 && lst < c[u])) ++lst; b[u] -= lst * 2; for (int p = en[u]; p; p = next[p]) { int v = to[p]; if (fa[v] == u) Dfs(v, lst); } } int main() { scanf("%d", &n); for (int i = 1; i < n; ++i) { int u, v; scanf("%d %d", &u, &v); Link(u, v), Link(v, u); } scanf("%d", &m); int rt; Set(a, 255); for (int i = 1; i <= m; ++i) { int u, v; scanf("%d %d", &u, &v); a[u] = v; rt = u; } fa[rt] = -1; b[rt] = a[rt]; Dfs(rt); Dfs(rt, 0); bool flag = 1; for (int i = 1; i <= n; ++i) if (~a[i] && a[i] != b[i]) { flag = 0; break; } if (!flag) puts("No"); else { puts("Yes"); for (int i = 1; i <= n; ++i) printf("%d\n", b[i]); } return 0; }
a.cc: In function 'void Link(int, int)': a.cc:19:9: error: reference to 'next' is ambiguous 19 | next[tms] = en[u]; | ^~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:66, from /usr/include/c++/14/algorithm:60, from a.cc:1: /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:15:17: note: 'int next [200010]' 15 | int tms, en[N], next[N], to[N]; | ^~~~ a.cc: In function 'void Dfs(int)': a.cc:30:36: error: reference to 'next' is ambiguous 30 | for (int p = en[u]; p; p = next[p]) { | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:15:17: note: 'int next [200010]' 15 | int tms, en[N], next[N], to[N]; | ^~~~ a.cc: In function 'void Dfs(int, int)': a.cc:46:36: error: reference to 'next' is ambiguous 46 | for (int p = en[u]; p; p = next[p]) { | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:15:17: note: 'int next [200010]' 15 | int tms, en[N], next[N], to[N]; | ^~~~
s162766371
p03949
C++
#include<bits/stdc++.h> #define N 111111 #define M 222222 #define P 10001000 using namespace std; int T,n,m,i,x,y,tot,S,fir[N],la[M],ne[M],V[N],L[N],R[N],AN[N];char s[N];bool ff,v[N]; void ins(int x,int y){la[++tot]=y;ne[tot]=fir[x];fir[x]=tot;} void dfs1(int x,int fa){ int lv=-1e9,rv=1e9; if(v[x])lv=rv=V[x]; for(int i=fir[x];i;i=ne[i])if(la[i]!=fa){ dfs1(la[i],x); lv=max(lv,L[la[i]]-1); rv=min(rv,R[la[i]]+1); } if(lv>rv)ff=1; if(!v[x])L[x]=lv,R[x]=rv;else{ if(V[x]<lv||V[x]>rv)ff=1; } } void dfs2(int x,int fa){ int lv=L[x],rv=R[x]; if(fa)lv=max(lv,L[fa]-1),rv=min(rv,R[fa]+1); for(int i=fir[x];i;i=ne[i])if(la[i]!=fa){ dfs2(la[i],x); } if(lv>rv)ff=1; if(!v[x])L[x]=lv,R[x]=rv;else{ if(V[x]<lv||V[x]>rv)ff=1; } } int change(int x,int y){ x--; int w=(y-x+1)/2; return x+w*2; } int gg(int x,int y){ x++; int w=(x-y+1)/2; return x-w*2; } int to(int l1,int r1,int l2,int r2){ if(l1-1<=l2)return change(l1,l2); if(r1+1>=r2)return gg(r1,r2); } void getans(int x,int fa){ int o,i,lv,rv; if(v[x]){ if(!fa||(AN[fa]-1==V[x]||AN[fa]+1==V[x]))AN[x]=V[x];else ff=1; } else{ if(AN[fa]-1>=L[x]&&AN[fa]-1<=R[x])AN[x]=AN[fa]-1; else if(AN[fa]+1>=L[x]&&AN[fa]+1<=R[x])AN[x]=AN[fa]+1; else ff=1; } for(i=fir[x];i;i=ne[i])if(la[i]!=fa)getans(la[i],x,w^1); } void check(int x,int fa){ if(fa)if(AN[fa]+1!=AN[x]&&AN[fa]-1!=AN[x])ff=1; for(int i=fir[x];i;i=ne[i])if(la[i]!=fa)check(la[i],x); } int main(){ for(scanf("%d",&n),i=1;i<n;i++)scanf("%d%d",&x,&y),ins(x,y),ins(y,x); for(scanf("%d",&m),i=1;i<=m;i++)scanf("%d%d",&x,&y),v[x]=1,V[x]=y,S=x; if(!m)v[1]=1,V[1]=1,S=1; dfs1(1,0);dfs2(1,0); getans(S,0); if(ff)return puts("No"),0; check(S,0); if(ff)return puts("No"),0; puts("YES"); for(i=1;i<=n;i++)printf("%d\n",AN[i]); }
a.cc: In function 'void getans(int, int)': a.cc:56:60: error: 'w' was not declared in this scope 56 | for(i=fir[x];i;i=ne[i])if(la[i]!=fa)getans(la[i],x,w^1); | ^ a.cc: In function 'int to(int, int, int, int)': a.cc:45:1: warning: control reaches end of non-void function [-Wreturn-type] 45 | } | ^
s336068045
p03949
C++
#include <cstdio> #include <iostream> #include <cassert> #include <vector> #include <queue> #include <stack> #include <algorithm> #define REP(i, n) for(int i = 0; i < (int)(n); ++i) using namespace std; int nNode; int vs[100000+10]; int parity[100000+10]; int lbs[100000+10]; int ubs[100000+10]; vector<int> g[100000+10]; bool go(int u, int p) { REP(i, g[u].size()) { int v = g[u][i]; if(v == p) continue; if(!go(v, u)) return false; } if(lbs[u] > ubs[u] || parity[u] == 0) { // 無理 return false; } if(lbs[u] == ubs[u] && (parity[u] & (1 << (lbs[u] % 2))) == 0) { return false; } if(p >= 0) { REP(i, 2) { if((parity[u] & (1 << i)) == 0) { parity[p] &= ~(1 << !i); } } lbs[p] = max(lbs[p], lbs[u]-1); ubs[p] = min(ubs[p], ubs[u]+1); } return true; } void go2(int u, int p) { int value; if(p < 0) { value = lbs[u]; if((parity[u] & (1 << (value%2))) == 0) { ++value; } } else { value = lbs[parent]-1; if(value < lbs[u]) { value += 2; } } lbs[u] = ubs[u] = value; REP(i, g[u].size()) { int v = g[u][i]; if(v == p) continue; go2(v, u); } } int main(void) { scanf("%d", &nNode); REP(i, nNode-1) { int a, b; scanf("%d%d", &a, &b); --a; --b; g[a].push_back(b); g[b].push_back(a); } REP(i, nNode) { parity[i] = 3; lbs[i] = 0; ubs[i] = 1000000; } int nInit; scanf("%d", &nInit); REP(i, nInit) { int v, p; scanf("%d%d", &v, &p); --v; lbs[v] = ubs[v] = p; parity[v] = 1 << (p % 2); } bool ok = go(0, -1); if(ok) { puts("Yes"); go2(0); REP(i, nNode) { assert(lbs[i] == ubs[i]); printf("%d\n", lbs[i]); } } else { puts("No"); } return 0; }
a.cc: In function 'void go2(int, int)': a.cc:53:17: error: 'parent' was not declared in this scope 53 | value = lbs[parent]-1; | ^~~~~~ a.cc: In function 'int main()': a.cc:96:8: error: too few arguments to function 'void go2(int, int)' 96 | go2(0); | ~~~^~~ a.cc:45:6: note: declared here 45 | void go2(int u, int p) { | ^~~
s026313145
p03949
C++
#include<cstdio> #include<cstring> #include<vector> using namespace std; int N, K; vector<int> e[100000], v[100000]; /*eは辺のメモ、vは整数min + iが書かれている頂点はどこかのメモ*/ int a[100000],vp[100000],P[100000];/*aは実際に書かれている整数のメモ*/ int min; int main() { int i,j,k,v1,v2; scanf("%d", &N); for (i = 0; i < N - 1; i++) { scanf("%d %d", &v1, &v2); e[v1 - 1].push_back(v2 - 1); e[v2 - 1].push_back(v1 - 1); } for (i = 0; i < N; i++) { a[i] = -1; } scanf("%d", &K); min = 1000000; for (i = 0; i < K; i++) { scanf("%d %d", &vp[i], &P[i]); if (min > P[i]) { min = P[i]; } } for (i = 0; i < K; i++) { if (P[i] - min >= N) { printf("No\n"); return 0; } a[vp[i] - 1] = P[i]; v[P[i] - min].push_back(vp[i] - 1); } for (i = 0; i < N; i++) { for (int j : v[i]) {/*整数min + iが書かれたすべての頂点jについて、*/ for (int k : e[j]) {/*jと隣接するすべての頂点について、*/ if (a[k] == -1) { a[k] = min + i + 1; v[i + 1].push_back(k); } else if ((a[k] != min + i + 1) && (a[k] != min + i - 1)) { printf("No\n"); return 0; } } } } printf("Yes\n"); for (i = 0; i < N; i++) { printf("%d\n", a[i]); } return 0; }
a.cc: In function 'int main()': a.cc:29:9: error: reference to 'min' is ambiguous 29 | min = 1000000; | ^~~ In file included from /usr/include/c++/14/vector:62, from a.cc:4: /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:10:5: note: 'int min' 10 | int min; | ^~~ a.cc:32:21: error: reference to 'min' is ambiguous 32 | if (min > P[i]) { min = P[i]; } | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:10:5: note: 'int min' 10 | int min; | ^~~ a.cc:32:35: error: reference to 'min' is ambiguous 32 | if (min > P[i]) { min = P[i]; } | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:10:5: note: 'int min' 10 | int min; | ^~~ a.cc:36:28: error: reference to 'min' is ambiguous 36 | if (P[i] - min >= N) { printf("No\n"); return 0; } | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:10:5: note: 'int min' 10 | int min; | ^~~ a.cc:38:26: error: reference to 'min' is ambiguous 38 | v[P[i] - min].push_back(vp[i] - 1); | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:10:5: note: 'int min' 10 | int min; | ^~~ a.cc:45:48: error: reference to 'min' is ambiguous 45 | a[k] = min + i + 1; | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:10:5: note: 'int min' 10 | int min; | ^~~ a.cc:48:51: error: reference to 'min' is ambiguous 48 | else if ((a[k] != min + i + 1) && (a[k] != min + i - 1)) { | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:10:5: note: 'int min' 10 | int min; | ^~~ a.cc:48:76: error: reference to 'min' is ambiguous 48 | else if ((a[k] != min + i + 1) && (a[k] != min + i - 1)) { | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:10:5: note: 'int min' 10 | int min; | ^~~
s237887832
p03949
C++
#include <string> #include <vector> #include<iostream> #include<cstdio> #include<cstdlib> #include<stack> #include<queue> #include<cmath> #include<algorithm> #include<functional> #include<list> #include<deque> #include<bitset> #include<set> #include<map> #include<unordered_map> #include<unordered_set> #include<cstring> #include<sstream> #include<complex> #include<iomanip> #include<numeric> #include<cassert> #define X first #define Y second #define pb push_back #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 repe(X,Y) for ((X) = 0;(X) < (Y);++(X)) #define peat(X,Y) for (;(X) < (Y);++(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; template<class T> using vv=vector<vector<T>>; template<class T> ostream& operator<<(ostream &os, const vector<T> &t) { os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;} template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";} 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 lb[112345]; int rb[112345]; const int MAX_N=(1<<18); const ll INF=(1ll<<60); int nn=MAX_N; struct Seg{ int mn,ind; Seg(int d=1000000,int i=100000){ mn=d; ind=i; } static Seg e; }; vector<Seg> dat(2*MAX_N); Seg Seg::e=Seg(); Seg operator+(Seg l,Seg r){ if(l.mn>r.mn) swap(l,r); return l; } //ostream& operator<<(ostream &os, const Seg &t) { return os<<"["<<t.mn<<")";} template<class T=Seg> void upd(int k,T a,vector<T> &dat=dat){ k+=dat.size()/2-1; dat[k]=a; while(k>0){ k=(k-1)/2; dat[k]=dat[k*2+1]+dat[k*2+2]; } } //(l,r,0,0,nn) template<class T=Seg> T query(int a,int b,const vector<T> &dat=dat,int k=0,int l=0,int r=-1){ if(r<0) r=dat.size()/2; if(r<=a || b<=l)return T::e; if(a<=l && r<=b) return dat[k]; T lv=query(a,b,dat,k*2+1,l,(l+r)/2) ,rv= query(a,b,dat,k*2+2,(l+r)/2,r); return lv+rv; } pii dfs(vv<int> &g,vector<int> &usd,int v,int p,int l,int r){ MX(lb[v],l); MN(rb[v],r); for(int w:g[v]) if(w!=p){ dfs(g,usd,w,v,lb[v]-1,rb[v]+1); MX(lb[v],lb[w]-1); MN(rb[v],rb[w]+1); } //cout<<v<<pii(lb[v],rb[v])<<endl; return pii(lb[v],rb[v]); } int main(){ ios_base::sync_with_stdio(false); cout<<fixed<<setprecision(0); int n; cin>>n; fill(lb,lb+n,-MOD); fill(rb,rb+n,MOD); vv<int> g(n); rep(i,n-1){ int x,y; cin>>x>>y; --x; --y; g[x].pb(y); g[y].pb(x); } vector<int> vs(n); vector<int> nums(n); int t,poyo; cin>>t; rep(i,t){ int x,y; cin>>x>>y; --x; poyo=x; vs[x]=1; nums[x]=y; MX(lb[x],nums[x]); MN(rb[x],nums[x]); } rep(hoge,2) dfs(g,vs,poyo,-1,nums[poyo],nums[poyo]); rep(i,n) dat[nn-1+i]=Seg(rb[i]-lb[i],i); if(query(0,n).mn<0){ cout<<"No"<<endl; return 0; } rrep(i,nn-1) dat[i]=dat[2*i+1]+dat[2*i+2]; vector<int> f(n); vector<int> re(n); rep(hoge,n){ auto q=query(0,n); if(q.mn<0){ cout<<"No"<<endl; return 0; } int i=q.ind; upd(i,Seg()); f[i]=1; re[i]=lb[i]; for(int v:g[i]) if(!f[v]){ MX(lb[v],re[i]-1); MN(rb[v],re[i]+1); upd(v,Seg(rb[v]-lb[v],v)); } } int f=1; rep(i,n) for(int v:g[i]) if(abs(re[v]-re[i])>1) f=0; if(f){ cout<<"Yes"<<endl; for(int x:re) cout<<x<<endl; }else{ cout<<"No"<<endl; } //cout<<re; return 0; }
a.cc: In function 'int main()': a.cc:155:7: error: conflicting declaration 'int f' 155 | int f=1; | ^ a.cc:137:15: note: previous declaration as 'std::vector<int, std::allocator<int> > f' 137 | vector<int> f(n); | ^ a.cc:156:53: error: no match for 'operator=' (operand types are 'std::vector<int, std::allocator<int> >' and 'int') 156 | rep(i,n) for(int v:g[i]) if(abs(re[v]-re[i])>1) f=0; | ^ In file included from /usr/include/c++/14/vector:72, from a.cc:2: /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, std::allocator<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, std::allocator<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) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ a.cc:157:6: error: could not convert 'f' from 'std::vector<int, std::allocator<int> >' to 'bool' 157 | if(f){ | ^ | | | std::vector<int, std::allocator<int> >
s963440857
p03949
C++
#include<iostream> #include<vector> #include<string> #include<algorithm> #include<map> #include<set> #include<utility> #include<cmath> #include<cstring> #include<queue> #include<stack> #include<cstdio> #include<sstream> #include<iomanip> #define loop(i,a,b) for(int i=a;i<b;i++) #define rep(i,a) loop(i,0,a) #define pb push_back #define mp make_pair #define all(in) in.begin(),in.end() #define shosu(x) fixed<<setprecision(x) using namespace std; //kaewasuretyuui typedef long long ll; typedef pair<int,int> pii; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<pii> vp; typedef vector<vp> vvp; typedef vector<string> vs; typedef vector<double> vd; typedef pair<int,pii> pip; typedef vector<pip>vip; const double PI=acos(-1); const double EPS=1e-8; const int inf=1e8; class DIJ{ public: struct edge{ int to,cost; }; vector<vector<edge> >G; vp in; int n; vi d;//distance DIJ(int size){ n=size; G=vector<vector<edge> >(n); } void add_edge(int a,int b,int c){ edge e={b,c},ee={a,c}; G[a].pb(e); G[b].pb(ee); } void dij(){ d=vi(n,inf); priority_queue<pii>q; rep(i,in.size()){ int a=in[i].first,b=in[i].second q.push(pii(-b,a-1)); d[a-1]=b; } while(!q.empty()){ pii p=q.top(); q.pop(); int pos=p.second,cost=-p.first; if(cost>d[pos])continue; rep(i,G[pos].size()){ edge e=G[pos][i]; int to=e.to; int nowcost=cost+e.cost; if(nowcost<d[to]){ d[to]=nowcost; q.push(pii(-d[to],to)); } } } } void solve(){ rep(i,n-1){ int a,b; cin>>a>>b; a--;b--; add_edge(a,b,1); add_edge(b,a,1); } int m; cin>>m; in=vp(m); rep(i,m)cin>>in[i].first>>in[i].second; dij(); bool h=true; rep(i,n)rep(j,G[i].size()){ int to=G[i][j].to; if(abs(d[i]-d[to])!=G[i][j].cost)h=false; } rep(i,m)if(in[i].second!=d[in.first-1])h=false; if(h){ cout<<"Yes"<<endl; rep(i,n)cout<<d[i]<<endl; }else cout<<"No"<<endl; } }; int main(){ int n; cin>>n; DIJ dij(n); dij.solve(); }
a.cc: In member function 'void DIJ::dij()': a.cc:59:25: error: expected ',' or ';' before 'q' 59 | q.push(pii(-b,a-1)); | ^ a.cc: In member function 'void DIJ::solve()': a.cc:96:47: error: 'vp' {aka 'class std::vector<std::pair<int, int> >'} has no member named 'first' 96 | rep(i,m)if(in[i].second!=d[in.first-1])h=false; | ^~~~~
s871645339
p03949
C++
#include<iostream> #include<vector> #include<string> #include<algorithm> #include<map> #include<set> #include<utility> #include<cmath> #include<cstring> #include<queue> #include<stack> #include<cstdio> #include<sstream> #include<iomanip> #define loop(i,a,b) for(int i=a;i<b;i++) #define rep(i,a) loop(i,0,a) #define pb push_back #define mp make_pair #define all(in) in.begin(),in.end() #define shosu(x) fixed<<setprecision(x) using namespace std; //kaewasuretyuui typedef long long ll; typedef pair<int,int> pii; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<pii> vp; typedef vector<vp> vvp; typedef vector<string> vs; typedef vector<double> vd; typedef pair<int,pii> pip; typedef vector<pip>vip; const double PI=acos(-1); const double EPS=1e-8; const int inf=1e8; class DIJ{ public: struct edge{ int to,cost; }; vector<vector<edge> >G; vp in; int n; vi d;//distance DIJ(int size){ n=size; G=vector<vector<edge> >(n); } void add_edge(int a,int b,int c){ edge e={b,c},ee={a,c}; G[a].pb(e); G[b].pb(ee); } void dij(){ d=vi(n,inf); priority_queue<pii>q; rep(i,m){ int a=in[i].first,b=in[i].second q.push(pii(-b,a-1)); d[a-1]=b; } while(!q.empty()){ pii p=q.top(); q.pop(); int pos=p.second,cost=-p.first; if(cost>d[pos])continue; rep(i,G[pos].size()){ edge e=G[pos][i]; int to=e.to; int nowcost=cost+e.cost; if(nowcost<d[to]){ d[to]=nowcost; q.push(pii(-d[to],to)); } } } } void solve(){ rep(i,n-1){ int a,b; cin>>a>>b; a--;b--; add_edge(a,b,1); add_edge(b,a,1); } int m; cin>>m; in=vp(m); rep(i,m)cin>>in[i].first>>in[i].second; dij(); bool h=true; rep(i,n)rep(j,G[i].size()){ int to=G[i][j].to; if(abs(d[i]-d[to])!=G[i][j].cost)h=false; } rep(i,m)if(in[i].second!=d[in.first-1])h=false; if(h){ cout<<"Yes"<<endl; rep(i,n)cout<<d[i]<<endl; }else cout<<"No"<<endl; } }; int main(){ int n; cin>>n; DIJ dij(n); dij.solve(); }
a.cc: In member function 'void DIJ::dij()': a.cc:57:23: error: 'm' was not declared in this scope; did you mean 'tm'? 57 | rep(i,m){ | ^ a.cc:15:35: note: in definition of macro 'loop' 15 | #define loop(i,a,b) for(int i=a;i<b;i++) | ^ a.cc:57:17: note: in expansion of macro 'rep' 57 | rep(i,m){ | ^~~ a.cc:59:25: error: expected ',' or ';' before 'q' 59 | q.push(pii(-b,a-1)); | ^ a.cc: In member function 'void DIJ::solve()': a.cc:96:47: error: 'vp' {aka 'class std::vector<std::pair<int, int> >'} has no member named 'first' 96 | rep(i,m)if(in[i].second!=d[in.first-1])h=false; | ^~~~~
s030508752
p03949
C++
5 1 2 3 1 4 3 3 5 2 2 6 5 7
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 5 | ^
s703371033
p03949
C++
w#include <bits/stdc++.h> using namespace std; bool chmax(int &a, int b) {if (a < b) { a = b; return true; } else return false; } bool chmin(int &a, int b) {if (a > b) { a = b; return true; } else return false; } const int MAX = 110000; int N; vector<int> tree[MAX]; int K; int P[MAX]; int lo[MAX], hi[MAX]; int res[MAX]; bool dfs(int v, int p) { bool can = true; lo[v] = hi[v] = P[v]; for (int i = 0; i < tree[v].size(); ++i) { int to = tree[v][i]; if (to == p) continue; if (!dfs(to, v)) return false; } for (int i = 0; i < tree[v].size(); ++i) { int to = tree[v][i]; if (to == p) continue; if (lo[to] == -1) continue; int tlo = lo[to] - 1; int thi = hi[to] + 1; if (lo[v] == -1) { lo[v] = tlo; hi[v] = thi; } else { if ( abs(lo[v] - tlo) % 2 != 0 ) return false; chmax(lo[v], tlo); chmin(hi[v], thi); if (lo[v] > hi[v]) return false; } } //cout << v << ": " << lo[v] << ", " << hi[v] << endl; return true; } void reconstruct(int v, int p) { if (p == -1) { if (lo[v] != -1) res[v] = hi[v]; else res[v] = 0; } else { if (lo[v] != -1) res[v] = min(hi[v], res[p]+1); else res[v] = res[p]+1; } for (auto to : tree[v]) { if (to == p) continue; reconstruct(to, v); } } int main() { while (cin >> N) { for (int i = 0; i < MAX; ++i) tree[i].clear(), P[i] = -1; for (int i = 0; i < N-1; ++i) { int a, b; scanf("%d %d", &a, &b); --a, --b; tree[a].push_back(b); tree[b].push_back(a); } cin >> K; for (int i = 0; i < K; ++i) { int v, p; scanf("%d %d", &v, &p); --v; P[v] = p; } bool can = dfs(0, -1); reconstruct(0, -1); if (can) { puts("Yes"); for (int i = 0; i < N; ++i) cout << res[i] << endl; } else puts("No"); } }
a.cc:1:2: error: stray '#' in program 1 | w#include <bits/stdc++.h> | ^ a.cc:1:1: error: 'w' does not name a type 1 | w#include <bits/stdc++.h> | ^ a.cc:9:1: error: 'vector' does not name a type 9 | vector<int> tree[MAX]; | ^~~~~~ a.cc: In function 'bool dfs(int, int)': a.cc:19:23: error: 'tree' was not declared in this scope 19 | for (int i = 0; i < tree[v].size(); ++i) { | ^~~~ a.cc:24:23: error: 'tree' was not declared in this scope 24 | for (int i = 0; i < tree[v].size(); ++i) { | ^~~~ a.cc:35:12: error: 'abs' was not declared in this scope 35 | if ( abs(lo[v] - tlo) % 2 != 0 ) return false; | ^~~ a.cc: In function 'void reconstruct(int, int)': a.cc:51:31: error: 'min' was not declared in this scope 51 | if (lo[v] != -1) res[v] = min(hi[v], res[p]+1); | ^~~ a.cc:54:18: error: 'tree' was not declared in this scope 54 | for (auto to : tree[v]) { | ^~~~ a.cc: In function 'int main()': a.cc:62:10: error: 'cin' was not declared in this scope 62 | while (cin >> N) { | ^~~ a.cc:63:35: error: 'tree' was not declared in this scope 63 | for (int i = 0; i < MAX; ++i) tree[i].clear(), P[i] = -1; | ^~~~ a.cc:66:7: error: 'scanf' was not declared in this scope 66 | scanf("%d %d", &a, &b); | ^~~~~ a.cc:68:7: error: 'tree' was not declared in this scope 68 | tree[a].push_back(b); | ^~~~ a.cc:74:7: error: 'scanf' was not declared in this scope 74 | scanf("%d %d", &v, &p); | ^~~~~ a.cc:82:7: error: 'puts' was not declared in this scope 82 | puts("Yes"); | ^~~~ a.cc:83:35: error: 'cout' was not declared in this scope 83 | for (int i = 0; i < N; ++i) cout << res[i] << endl; | ^~~~ a.cc:83:53: error: 'endl' was not declared in this scope 83 | for (int i = 0; i < N; ++i) cout << res[i] << endl; | ^~~~ a.cc:85:10: error: 'puts' was not declared in this scope 85 | else puts("No"); | ^~~~
s548548076
p03949
C++
#include<bits/stdc++.h> #include<climits> #define FOR(i,a,b) for(int i = (a);i<=(b);i++) #define ROF(i,a,b) for(int i = (a);i>=(b);i--) #define MST(a,x) memset(a,x,sizeof(a)) #define ll long long #define PB push_back #define PH push #define MP make_pair #define FT first #define SD second #define N 100005 #define M 10005 #define INF 1000000007 #define MOD 1000000007 #define MOD2 1000000009 #define eps 1e-7 using namespace std; inline int Max(int a,int b) { return (((b-a)>>(32-1))&(a^b))^b; } inline int Min(int a,int b) { return (((b-a)>>(32-1))&(a^b))^a; } int is_mul_overflow(ll a, ll b) { return LLONG_MAX / a < b; } vector<int>e[N]; pair<int,int>a[N]; int ans[N]; int merge(int x,int y) { if(a[y].FT == -INF)return 1; auto u = MP(a[y].FT-1,a[y].SD+1); //cout<<x<<" "<<y<<" "<<a[x].FT<<" "<<a[x].SD<<" "<<u.FT<<" "<<u.SD<<endl; if(a[x].FT == -INF)a[x] = u; else if((a[x].FT+u.FT)%2)return 0; else if(a[x].FT>u.SD||u.FT>a[x].SD)return 0; else { a[x].FT = max(a[x].FT,u.FT); a[x].SD = min(a[x].SD,u.SD); } return 1; } int dfs(int u,int fa) { int f = 1; for(auto v:e[u]) { if(v == fa)continue; f&=dfs(v,u); f&=merge(u,v); } return f; } void dfs1(int u,int fa,int val) { ans[u] = val; for(auto v:e[u]) { if(v == fa)continue; int x; if((val+1)>=a[v].FT&&(val+1)<=a[v].SD&&(val+1+a[v].FT)%2 == 0)x = val+1; else if((val-1)>=a[v].FT&&(val-1)<=a[v].SD&&(val-1+a[v].FT)%2 == 0)x = val-1; else x = val-1; dfs1(v,u,x); } } int main() { int size = 256 << 20; // 256MB char *p = (char*)malloc(size) + size; __asm__("movl %0, %%esp\n" :: "r"(p)); cin.tie(0); ios::sync_with_stdio(false); //freopen("binary_02.txt","r",stdin); //freopen("binary_01_out.txt","w",stdout); int n,m; while(cin>>n) { FOR(i,1,n)e[i].clear(); FOR(i,1,n)a[i] = MP(-INF,-INF); FOR(i,1,n-1) { int x,y; cin>>x>>y; e[x].PB(y); e[y].PB(x); } cin>>m; FOR(i,1,m) { int x,y; cin>>x>>y; a[x] = MP(y,y); } int f = dfs(1,-1); // FOR(i,1,n)cout<<i<<" i "<<a[i].FT<<" "<<a[i].SD<<endl; if(!f)cout<<"No"<<endl; else { cout<<"Yes"<<endl; dfs1(1,-1,a[1].FT); FOR(i,1,n)cout<<ans[i]<<endl; } } return 0; }
a.cc: Assembler messages: a.cc:77: Error: operand type mismatch for `mov'
s104647179
p03949
C++
// test #include<bits/stdc++.h> using namespace std; #define REP(i,a,b) for(i=a;i<b;i++) #define rep(i,n) REP(i,0,n) #define mygc(c) (c)=getchar_unlocked() #define mypc(c) putchar_unlocked(c) #define ll long long #define ull unsigned ll void reader(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);} void reader(ll *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);} void reader(double *x){scanf("%lf",x);} int reader(char c[]){int i,s=0;for(;;){mygc(i);if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF) break;}c[s++]=i;for(;;){mygc(i);if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF) break;c[s++]=i;}c[s]='\0';return s;} template <class T, class S> void reader(T *x, S *y){reader(x);reader(y);} template <class T, class S, class U> void reader(T *x, S *y, U *z){reader(x);reader(y);reader(z);} template <class T, class S, class U, class V> void reader(T *x, S *y, U *z, V *w){reader(x);reader(y);reader(z);reader(w);} void writer(int x, char c){int s=0,m=0;char f[10];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);} void writer(ll x, char c){int s=0,m=0;char f[20];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);} void writer(double x, char c){printf("%.15f",x);mypc(c);} void writer(const char c[]){int i;for(i=0;c[i]!='\0';i++)mypc(c[i]);} void writer(const char x[], char c){int i;for(i=0;x[i]!='\0';i++)mypc(x[i]);mypc(c);} template<class T> void writerLn(T x){writer(x,'\n');} template<class T, class S> void writerLn(T x, S y){writer(x,' ');writer(y,'\n');} template<class T, class S, class U> void writerLn(T x, S y, U z){writer(x,' ');writer(y,' ');writer(z,'\n');} template<class T> void writerArr(T x[], int n){int i;if(!n){mypc('\n');return;}rep(i,n-1)writer(x[i],' ');writer(x[n-1],'\n');} #define incID(i, l, r) for(int i = (l) ; i < (r); i++) #define incII(i, l, r) for(int i = (l) ; i <= (r); i++) #define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--) #define decII(i, l, r) for(int i = (r) ; i >= (l); i--) #define inc( i, n) incID(i, 0, n) #define inc1(i, n) incII(i, 1, n) #define dec( i, n) decID(i, 0, n) #define dec1(i, n) decII(i, 1, n) template<typename T> bool setmin(T &a, T b) { if(a <= b) { return false; } else { a = b; return true; } } template<typename T> bool setmax(T &a, T b) { if(b <= a) { return false; } else { a = b; return true; } } // ---- ---- int n, k; bool ans = true; std::vector<int> vec[100000]; bool has[100000]; int mi[100000], ma[100000]; void prod(int x, int y) { if(has[y]) { if(has[x] && abs(mi[x] - mi[y]) % 2 == 0) { ans = false; } if(has[x]) { mi[x] = max(mi[x], mi[y] - 1); ma[x] = min(ma[x], ma[y] + 1); } else { mi[x] = mi[y] - 1; ma[x] = ma[y] + 1; } if(mi[x] > ma[x]) { ans = false; } has[x] = true; } } void dfs(int node, int pre) { if(pre != -1) { prod(node, pre); } for(auto && i : vec[node]) { if(i != pre) { dfs(i, node); prod(node, i); } } } int main() { // scanf("%d", &n); reader(&n); inc(i, n - 1) { int a, b; // scanf("%d%d", &a, &b); reader(&a, &b); a--; b--; vec[a].push_back(b); vec[b].push_back(a); } // scanf("%d", &k); reader(&k); inc(j, k) { int v, p; // scanf("%d%d", &v, &p); reader(&v, &p); v--; ma[v] = p; mi[v] = p; has[v] = true; } dfs(0, -1); dfs(0, -1); printf("%s\n", ans ? "Yes" : "No"); if(ans) { inc(i, n) { // printf("%d\n", mi[i]); writerLn(mi[i]) } } return 0; }
a.cc: In function 'int main()': a.cc:111:40: error: expected ';' before '}' token 111 | writerLn(mi[i]) | ^ | ; 112 | } | ~
s514386147
p03949
C++
#include <bits/stdc++.h> #include<iostream> #include<cstdio> #include<vector> #include<queue> #include<map> #include<cstring> #include<string> #include <math.h> #include<algorithm> // #include <boost/multiprecision/cpp_int.hpp> #include<functional> #define int long long #define inf 1000000007 #define pa pair<int,int> #define ll long long #define pal pair<ll,ll> #define ppa pair<int,pa> #define mp make_pair #define EPS (1e-10) #define equals(a,b) (fabs((a)-(b))<EPS) using namespace std; class Point{ public: double x,y; Point(double x=0,double y=0):x(x),y(y) {} Point operator + (Point p) {return Point(x+p.x,y+p.y);} Point operator - (Point p) {return Point(x-p.x,y-p.y);} Point operator * (double a) {return Point(x*a,y*a);} Point operator / (double a) {return Point(x/a,y/a);} double absv() {return sqrt(norm());} double norm() {return x*x+y*y;} bool operator < (const Point &p) const{ return x != p.x ? x<p.x: y<p.y; } bool operator == (const Point &p) const{ return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS; } }; typedef Point Vector; struct Segment{ Point p1,p2; }; double hen(Vector a){ if(fabs(a.x)<EPS && a.y>0) return acos(0); else if(fabs(a.x)<EPS && a.y<0) return 3*acos(0); else if(fabs(a.y)<EPS && a.x<0) return 2*acos(0); else if(fabs(a.y)<EPS && a.x>0) return 0.0; else if(a.y>0) return acos(a.x/a.absv()); else return 2*acos(0)+acos(-a.x/a.absv()); } double dot(Vector a,Vector b){ return a.x*b.x+a.y*b.y; } double cross(Vector a,Vector b){ return a.x*b.y-a.y*b.x; } //----------------kokomade temple------------ int n,m,k,x,t,r; vector<int> G[100002]; bool ok=true; vector<int> G2[100002]; int v[100002],sita[100002],ue[100002],w[100002]={0}; int guu[100002]={0}; bool sumi[100002]={0}; void saiki(int u,int mae){ if(mae==0){ guu[u]=v[u]%2; } for(int i=0;i<G[u].size();i++){ if(G[u][i]==mae) continue; guu[G[u][i]]=1-guu[u]; G2[u].push_back(G[u][i]); saiki(G[u][i],u); } } pa xc(int i){ if(sumi[i]==1){ w[i]=1; sita[i]=v[i]; ue[i]=v[i]; return mp(v[i],v[i]); } else if(G2[i].size()==0){ w[i]=1; sita[i]=-inf/10; ue[i]=inf/10; return mp(sita[i],ue[i]); } if(w[i]==1) return mp(sita[i],ue[i]); int lo=-inf/10,ma=inf/10; for(int j=0;j<G2[i].size();j++){ pa z=xc(G2[i][j]); lo=max(lo,z.first); ma=min(ma,z.second); } lo--; ma++; // cout<<" "<<i<<" "<<lo<<" "<<ma<<endl; if(lo>ma) ok=false; sita[i]=lo,ue[i]=ma; w[i]=1; return mp(lo,ma); } void sai(int i){ for(int j=0;j<G2[i].size();j++){ sai(G2[i][j]); } pa z=xc(i); if(z.first>z.second)ok=false; if(sumi[i]){ if(!(z.first<=v[i] && v[i]<= z.second)) { ok=false; return; } } } int ans[100002]; void saikiz(int i,int oya){ if(oya==0){ ans[i]=v[i]; } else{ if(ans[oya]-1>=sita) ans[i]=ans[oya]-1; else ans[i]=ans[oya]+1; } for(int j=0;j<G2[i].size();j++) saikiz(G2[i][j],i); return; } signed main(){ cin>>n; for(int i=1;i<n;i++){ int zz,zzz; cin>>zz>>zzz; G[zz].push_back(zzz); G[zzz].push_back(zz); } int rr; cin>>k; for(int i=1;i<=k;i++){ int zz,zzz; cin>>zz>>zzz; v[zz]=zzz; sumi[zz]=1; sita[zz]=zzz; ue[zz]=zzz; // w[zz]=1; if(i==1) r=zz,rr=zzz, saiki(zz,0); else{ // cout<<zz<<" "<<guu[zz]<<" "<<zzz<<endl; if(guu[zz]!= zzz%2){ cout<<"No"<<endl; return 0; } } } sai(r); if(ok==false){ cout<<"No"<<endl; return 0; } for(int i=1;i<=n;i++){ // cout<<i<<" "<<sita[i]<<" "<<ue[i]<<endl; } saikiz(r,0); cout<<"Yes"<<endl; for(int i=1;i<=n;i++){ cout<<""<<ans[i]<<endl; } // printf("%.10f\n",ans); return 0; }
a.cc: In function 'void saikiz(long long int, long long int)': a.cc:138:30: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 138 | if(ans[oya]-1>=sita) ans[i]=ans[oya]-1; | ~~~~~~~~~~^~~~~~
s551965340
p03949
C++
#include <iostream> #include <vector> using namespace std; const int INF = 1145141919; int n; vector<int> et[100000]; //et[i] = 頂点iから行ける頂点の集合 int num[100000]; //num[i] = 頂点iに書かれている値 (なければINF) pair<int, int> range[100000]; //range[i] = 頂点i以下で矛盾を無くしたいときに頂点iに書ける値の範囲 (閉区間) //開始頂点の番号を返す int input() { int i; cin >> n; for (i = 0; i < n - 1; i++) { int u, v; cin >> u >> v; u--; v--; et[u].push_back(v); et[v].push_back(u); } for (i = 0; i < n; i++) { num[i] = INF; } int k; int ret = -1; cin >> k; for (i = 0; i < k; i++) { int v, p; cin >> v >> p; v--; num[v] = p; ret = v; } return ret; } //偶奇チェック bool dfs(int parent, int v, int mod) { if (num[v] != INF && num[v] % 2 != mod) { return false; } for (int i = 0; i < et[v].size(); i++) { if (et[v][i] == parent) continue; if (!dfs(v, et[v][i], (mod + 1) % 2)) return false; } return true; } //値範囲決め (頂点v以下で矛盾がないようにしたとき, 頂点vに入る値の集合は1つの区間になる) pair<int, int> dfs2(int parent, int v) { pair<int, int> ret = pair<int, int>(-INF, INF); if (num[v] != INF) ret = pair<int, int>(num[v], num[v]); for (int i = 0; i < et[v].size(); i++) { if (et[v][i] == parent) continue; pair<int, int> res = dfs2(v, et[v][i]); ret.first = max(ret.first, res.first - 1); ret.second = min(ret.second, res.second + 1); } return (range[v] = ret); } //値を根から決めていく void dfs3(int parent, int v) { if (parent == -1) { num[v] = range[v].first; } else { if (range[v].first <= num[parent] - 1 && num[parent] - 1 <= range[v].second) { num[v] = num[parent] - 1; } else { num[v] = num[parent] + 1; } } for (int i = 0; i < et[v].size(); i++) { if (parent == et[v][i]) continue; dfs3(v, et[v][i]); } } signed main() { int start = input(); if (!dfs(-1, start, num[start] % 2)) { cout << "No" << endl; return 0; } pair<int, int> res = dfs2(-1, start); if (res.first > res.second) { cout << "No" << endl; return 0; } assert(0); cout << "Yes" << endl; dfs3(-1, start); for (int i = 0; i < n; i++) { cout << num[i] << endl; } return 0; }
a.cc: In function 'int main()': a.cc:79:9: error: 'assert' was not declared in this scope 79 | assert(0); | ^~~~~~ a.cc:3:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>' 2 | #include <vector> +++ |+#include <cassert> 3 | using namespace std;
s402328653
p03949
C++
#include <iostream> #include <list> #include <queue> using namespace std; int N,K; int num[100001]; int bottom[100001]; int top[100001]; int dis[100001]; list<int> connect[100001]; int s, e; int a; queue<int>Q; int main() { cin >> N; for (int i = 0; i < N - 1; i++) { cin >> s >> e; connect[s].push_back(e); connect[e].push_back(s); } for (int i = 1; i <= N; i++) { num[i] = -1; bottom[i] = -1; top[i] = -1; } cin >> K; for (int i = 0; i < K; i++) { cin >> a; cin >> num[a]; bottom[a] = num[a]; top[a] = num[a]; } for (int i = 1; i <= N; i++) { if (num[i] != -1) { for (int j = 1; j <= N; j++) { dis[j] = INT_MAX; } dis[i] = 0; Q.push(i); while (!Q.empty()) { for (auto j = connect[Q.front()].begin(); j != connect[Q.front()].end(); ++j) { if (num[(*j)]==-1) { if ((dis[Q.front()] + 1) < dis[(*j)]) { dis[(*j)] = dis[Q.front()] + 1; if (bottom[(*j)] == -1) { bottom[(*j)] = bottom[i] - dis[(*j)]; if (bottom[(*j) < 0]) { bottom[(*j)] *= -1; bottom[(*j)] = bottom[(*j)] % 2; } top[(*j)] = top[i] + dis[(*j)]; } else { bottom[(*j)] = max(bottom[i] - dis[(*j)], bottom[(*j)]); if (bottom[(*j) < 0]) { bottom[(*j)] *= -1; bottom[(*j)] = bottom[(*j)] % 2; } top[(*j)] = min(top[i] + dis[(*j)], top[(*j)]); if (top[(*j)] < bottom[(*j)]) { cout << "No\n"; return 0; } if (top[(*j)] - bottom[(*j)] % 2 == 0) { cout << "No\n"; return 0; } } Q.push((*j)); } } else { if (abs(num[i] - num[(*j)]) > dis[(*j)]) { cout << "No\n"; return 0; } } } Q.pop(); } } } cout << "Yes\n"; for (int i = 1; i <= N; i++) { cout << bottom[i] << "\n"; } return 0; }
a.cc: In function 'int main()': a.cc:38:42: error: 'INT_MAX' was not declared in this scope 38 | dis[j] = INT_MAX; | ^~~~~~~ a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 3 | #include <queue> +++ |+#include <climits> 4 | using namespace std;
s968514499
p03949
C++
#include <iostream> #include <string> #include <algorithm> #include <functional> #include <vector> #include <stack> #include <queue> #include <set> #include <map> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <cassert> using namespace std; int INF = 1145141919; int n; int parents[100000]; // vector<int> et[100000]; //et[i] = 頂点iから行ける頂点の集合 int num[100000]; //num[i] = 頂点iに書かれている数 (なければINF) //頂点vから書き込みスタート //val…vからdepだけ登った頂点で書き込まれた値, なければINF //戻り値…頂点v以下の部分木で矛盾がないかどうか bool dfs(int parent, int v, int val, int dep) { parents[v] = (parent == -1 ? v : parent); if (val != INF && num[v] != INF) { if (dep < abs(val - num[v]) || abs(val - num[v]) % 2 != dep % 2) return false; //depさかのぼる /*int tmp = dep; int id = v; for (int i = 0; i <= tmp; i++) { num[v] = ; */ } int i; bool ret = true; for (i = 0; i < et[v].size(); i++) { if (et[v][i] == parent) continue; if (num[v] == INF) ret &= dfs(v, et[v][i], val, dep + 1); else ret &= dfs(v, et[v][i], num[v], 1); } return ret; } //探索開始頂点の番号を返す void input() { cin >> n; for (int i = 0; i < n - 1; i++) { int u, v; cin >> u >> v; u--; v--; et[u].push_back(v); et[v].push_back(u); } for (int i = 0; i < n; i++) { num[i] = INF; } int k; cin >> k; for (int i = 0; i < k; i++) { int v, p; cin >> v >> p; v--; num[v] = p; } } signed main() { bool flag = true; for (int i = 0; i < n; i++) { flag &= dfs(-1, i, num[i], 0)) } if (flag) cout << "Yes" << endl; else cout << "No" << endl; for (int i = 0; i < n; i++) { cout << num[i] << endl; } return 0; }
a.cc: In function 'int main()': a.cc:78:46: error: expected ';' before ')' token 78 | flag &= dfs(-1, i, num[i], 0)) | ^ | ;
s726374129
p03949
C++
#include <bits/stdc++.h> #define MAX_N 100000 #define INF 10000000000000ll #define int (long long) using namespace std; using pi = pair<int, int>; vector<int> G[MAX_N]; sined main() { int N, K; bool res = true; cin >> N; vector<pi> val(N, pi(0, INF)); vector<bool> used((N - 1) * 2, false); for (int i = 0, A, B; i < N - 1;i++) { cin >> A >> B; G[A - 1].push_back(B - 1); G[B - 1].push_back(A - 1); } vector<int> zero; cin >> K; for (int i = 0, v; i < K;i++) { cin >> v; cin >> val[v - 1].first; val[v - 1].second = 0; zero.push_back(v - 1); } for (auto &v : zero) { queue<int> q; q.push(v); while (!q.empty()) { int vv = q.front(); q.pop(); for (auto &next : G[vv]) { if (val[next] == pi(0, INF) || ((val[vv].first - val[next].first + val[vv].second + val[next].second) % 2 == 1 && abs(val[vv].first - val[next].first) <= val[vv].second + val[next].second + 1)) { if (val[next] != pi(0, INF) && val[vv].first + val[vv].second + 1 >= val[next].first + val[next].second && val[vv].first - val[vv].second - 1 <= val[next].first - val[next].second) { ; } else { int mx = min(val[vv].first + val[vv].second + 1, val[next].first + val[next].second); int mn = max(val[vv].first - val[vv].second - 1, val[next].first - val[next].second); val[next] = pi((mx + mn) / 2, (mx - mn) / 2); q.push(next); } } else { res = false; break; } } if (!res) { break; } } if (!res) { break; } } if (res) { cout << "Yes" << endl; for (int i = 0; i < N;i++) { cout << val[i].first - val[i].second << endl; } } else { cout << "No" << endl; } return 0; }
a.cc:4:19: error: wrong number of template arguments (1, should be 2) 4 | #define int (long long) | ^~~~ a.cc:6:17: note: in expansion of macro 'int' 6 | using pi = pair<int, int>; | ^~~ 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, from a.cc:1: /usr/include/c++/14/bits/stl_pair.h:89:12: note: provided for 'template<class _T1, class _T2> struct std::pair' 89 | struct pair; | ^~~~ a.cc:4:19: error: template argument 1 is invalid 4 | #define int (long long) | ^~~~ a.cc:8:8: note: in expansion of macro 'int' 8 | vector<int> G[MAX_N]; | ^~~ a.cc:4:19: error: template argument 2 is invalid 4 | #define int (long long) | ^~~~ a.cc:8:8: note: in expansion of macro 'int' 8 | vector<int> G[MAX_N]; | ^~~ a.cc:4:23: error: expected unqualified-id before ')' token 4 | #define int (long long) | ^ a.cc:8:8: note: in expansion of macro 'int' 8 | vector<int> G[MAX_N]; | ^~~ a.cc:10:1: error: 'sined' does not name a type; did you mean 'signed'? 10 | sined main() | ^~~~~ | signed
s836213692
p03949
C++
#include <bits/stdc++.h> #define MAX_N 100000 #define INF 10000000000000ll #define int (long long) using namespace std; using pi = pair<int, int>; vector<int> G[MAX_N]; sined main() { int N, K; bool res = true; cin >> N; vector<pi> val(N, pi(0, INF)); vector<bool> used((N - 1) * 2, false); for (int i = 0, A, B; i < N - 1;i++) { cin >> A >> B; G[A - 1].push_back(B - 1); G[B - 1].push_back(A - 1); } vector<int> zero; cin >> K; for (int i = 0, v; i < K;i++) { cin >> v; cin >> val[v - 1].first; val[v - 1].second = 0; zero.push_back(v - 1); } for (auto &v : zero) { queue<int> q; q.push(v); while (!q.empty()) { int vv = q.front(); q.pop(); for (auto &next : G[vv]) { if (val[next] == pi(0, INF) || ((val[vv].first - val[next].first + val[vv].second + val[next].second) % 2 == 1 && abs(val[vv].first - val[next].first) <= val[vv].second + val[next].second + 1)) { if (val[next] != pi(0, INF) && val[vv].first + val[vv].second + 1 >= val[next].first + val[next].second && val[vv].first - val[vv].second - 1 <= val[next].first - val[next].second) { ; } else { int mx = min(val[vv].first + val[vv].second + 1, val[next].first + val[next].second); int mn = max(val[vv].first - val[vv].second - 1, val[next].first - val[next].second); val[next] = pi((mx + mn) / 2, (mx - mn) / 2); q.push(next); } } else { res = false; break; } } if (!res) { break; } } if (!res) { break; } } if (res) { cout << "Yes" << endl; for (int i = 0; i < N;i++) { cout << val[i].first - val[i].second << endl; } } else { cout << "No" << endl; } return 0; }
a.cc:4:19: error: wrong number of template arguments (1, should be 2) 4 | #define int (long long) | ^~~~ a.cc:6:17: note: in expansion of macro 'int' 6 | using pi = pair<int, int>; | ^~~ 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, from a.cc:1: /usr/include/c++/14/bits/stl_pair.h:89:12: note: provided for 'template<class _T1, class _T2> struct std::pair' 89 | struct pair; | ^~~~ a.cc:4:19: error: template argument 1 is invalid 4 | #define int (long long) | ^~~~ a.cc:8:8: note: in expansion of macro 'int' 8 | vector<int> G[MAX_N]; | ^~~ a.cc:4:19: error: template argument 2 is invalid 4 | #define int (long long) | ^~~~ a.cc:8:8: note: in expansion of macro 'int' 8 | vector<int> G[MAX_N]; | ^~~ a.cc:4:23: error: expected unqualified-id before ')' token 4 | #define int (long long) | ^ a.cc:8:8: note: in expansion of macro 'int' 8 | vector<int> G[MAX_N]; | ^~~ a.cc:10:1: error: 'sined' does not name a type; did you mean 'signed'? 10 | sined main() | ^~~~~ | signed
s883315375
p03949
C++
/* By Snickeen */ #include<bits/stdc++.h> //#pragma comment(linker, "/STACK:102400000,102400000") #include <stdio.h> #include <iostream> #include <iomanip> #include <fstream> #include <string.h> #include <stdlib.h> #include <time.h> #include <limits.h> #include <math.h> #include <algorithm> #include <deque> #include <queue> #include <stack> #include <list> #include <map> #include <set> #include <utility> #include <sstream> #include <complex> #include <string> #include <vector> #include <bitset> #include <functional> using namespace std; typedef long long LL; typedef unsigned long long ULL; typedef double db; typedef long double ldb; #define rep(i,a,b) for(i=a;i<b;i++) #define repu(i,a,b) for(i=a;i<=b;i++) #define repd(i,a,b) for(i=a;i>=b;i--) #define repc(i,a,b,c) for(i=a;i<b;i+=c) #define repcu(i,a,b,c) for(i=a;i<=b;i+=c) #define repcd(i,a,b,c) for(i=a;i>=b;i-=c) #define FIN freopen("input.in","r",stdin) #define FOUT freopen("output.out","w",stdout) #define CC(a) memset(a,0,sizeof(a)) #define MST(a,b) memset(a,b,sizeof(a)) #define PII pair<int,int> #define PLL pair<LL,LL> #define VI vector<int> #define VL vector<LL> #define VII vector<PII > #define VLL vector<PLL > #define all(x) x.begin(),x.end() #define mp make_pair #define pb push_back #define pf push_front #define FF first #define SS second template<typename T>inline void gn(T &x){ x=0;T f=1;char ch=getchar(); while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();} while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();} x*=f; } template<typename T>inline void gt(T x){ if(!x)return; gt(x/10);putchar(x%10+'0'); } const LL MAXN=1e5+10; LL t,n,m,ans,tot; LL MOD=1e9+7,inf=0x1f1f1f1f; db eps=1e-5; LL f[MAXN],dg[MAXN],jo[MAXN]; VL e[MAXN],g[MAXN]; PLL node[MAXN]; queue<PLL> q; PLL x,y; LL bfs(){ LL i,j,k,l,id,u,v; while(q.size()){ x=q.front();q.pop(); l=e[x.FF].size(); y=node[x.FF]; y.FF++;y.SS++; id=((x.SS-1)^1)+1; for(i=0;i<l;i++){ k=e[x.FF][i]; if(jo[k]==jo[x.FF])return 0; if(node[k].FF>y.SS|node[k].SS<y.FF)return 0; jo[k]=id; u=max(node[k].FF,y.FF); v=min(node[k].SS,y.SS); if(u>node[k].FF||v<node[k].SS)q.push({k,id}); } } } int main() { //ios_base::sync_with_stdio(false);cin.tie(0); LL i,j,k,l,r,ca=0,u=0,v=0,w; cin>>n; rep(i,1,n){ cin>>u>>v; e[u].pb(v); e[v].pb(u); d[u]++;d[v]++; } cin>>m; repu(i,1,m){ cin>>u>>v; node[u]={v,v}; f[u]=v&1;jo[u]=f[u]+1; q.push({u,jo[u]}); } k=bfs(); if(!k)return cout<<"No\n",0; cout<<"Yes\n"; for(i=1;i<=n;i++)cout<<node[i].FF<<endl; return 0; }
a.cc: In function 'int main()': a.cc:108:17: error: 'd' was not declared in this scope 108 | d[u]++;d[v]++; | ^ a.cc: In function 'LL bfs()': a.cc:97:1: warning: control reaches end of non-void function [-Wreturn-type] 97 | } | ^
s027554480
p03949
C++
#include<bits/stdc++.h> #define INF (1e9) #define N 100005 using namespace std; typedef pair<int,int> P; int n,a,b,k,v,p,ans[N]; vector<int> e[N]; P minmax[N]; bool flag=true; P rmerge(P A,P B){ return P(max(A.first,B.first),min(A.second,B.second)); } P dfs(int x,int px){ P res=minmax[x]; for(int i=0;i<(int)e[x].size();i++) if(e[x][i]!=px)res=rmerge(res,dfs(e[x][i],x)); return minmax[x]=res; } void dfs2(int x,int px,int v){ if(!flag)return; ans[x]=v; for(int i=0;i<(int)e[x].size();i++){ int nv,nx=e[x][i]; int minv=minmax[nx].first; int maxv=minmax[nx].second; if(nx!=px){ if(minv<=ans[x]+1&&ans[x]+1<=maxv)dfs2(e[x][i],x,ans[x]+1); else if(minv<=ans[x]-1&&ans[x]-1<=maxv)dfs2(e[x][i],x,ans[x]-1); else{ flag=false; break; } } } } int main(){ cin>>n; for(int i=0;i<n-1;i++){ cin>>a>>b; a--; b--; e[a].push_back(b); e[b].push_back(a); } for(int i=0;i<n;i++) ans[i]=-INF; cin>>k; for(int i=0;i<k;i++){ cin>>v>>p; ans[v-1]=p; } for(int i=0;i<n;i++){ minmax[i].first=-INF; minmax[i].second=INF; if(ans[i]!=-INF){ minmax[i].first=ans[i]-1; minmax[i].second=ans[i]+1; } } dfs(0,-1); int f=0; for(int i=0;i<n;i++){ if(ans[i]!=-INF){ dfs2(i,-1,ans[i]); f=1; break; } } if(!f)dfs2(0,-1,0); if(flag){ cout<<"Yes"<<endl; for(int i=0;i<n;i++)cout<<ans[i]<<endl; }else cout<<"No"<<endl; return 0; }
a.cc: In function 'P dfs(int, int)': a.cc:16:9: error: reference to 'minmax' is ambiguous 16 | P res=minmax[x]; | ^~~~~~ 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:3447:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr std::pair<_FIter, _FIter> std::minmax(initializer_list<_Tp>, _Compare)' 3447 | minmax(initializer_list<_Tp> __l, _Compare __comp) | ^~~~~~ /usr/include/c++/14/bits/stl_algo.h:3435:5: note: 'template<class _Tp> constexpr std::pair<_FIter, _FIter> std::minmax(initializer_list<_Tp>)' 3435 | minmax(initializer_list<_Tp> __l) | ^~~~~~ /usr/include/c++/14/bits/stl_algo.h:3309:5: note: 'template<class _Tp, class _Compare> constexpr std::pair<const _Tp&, const _Tp&> std::minmax(const _Tp&, const _Tp&, _Compare)' 3309 | minmax(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~~~~ /usr/include/c++/14/bits/stl_algo.h:3288:5: note: 'template<class _Tp> constexpr std::pair<const _Tp&, const _Tp&> std::minmax(const _Tp&, const _Tp&)' 3288 | minmax(const _Tp& __a, const _Tp& __b) | ^~~~~~ a.cc:8:3: note: 'P minmax [100005]' 8 | P minmax[N]; | ^~~~~~ a.cc:19:10: error: reference to 'minmax' is ambiguous 19 | return minmax[x]=res; | ^~~~~~ /usr/include/c++/14/bits/stl_algo.h:3447:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr std::pair<_FIter, _FIter> std::minmax(initializer_list<_Tp>, _Compare)' 3447 | minmax(initializer_list<_Tp> __l, _Compare __comp) | ^~~~~~ /usr/include/c++/14/bits/stl_algo.h:3435:5: note: 'template<class _Tp> constexpr std::pair<_FIter, _FIter> std::minmax(initializer_list<_Tp>)' 3435 | minmax(initializer_list<_Tp> __l) | ^~~~~~ /usr/include/c++/14/bits/stl_algo.h:3309:5: note: 'template<class _Tp, class _Compare> constexpr std::pair<const _Tp&, const _Tp&> std::minmax(const _Tp&, const _Tp&, _Compare)' 3309 | minmax(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~~~~ /usr/include/c++/14/bits/stl_algo.h:3288:5: note: 'template<class _Tp> constexpr std::pair<const _Tp&, const _Tp&> std::minmax(const _Tp&, const _Tp&)' 3288 | minmax(const _Tp& __a, const _Tp& __b) | ^~~~~~ a.cc:8:3: note: 'P minmax [100005]' 8 | P minmax[N]; | ^~~~~~ a.cc: In function 'void dfs2(int, int, int)': a.cc:27:14: error: reference to 'minmax' is ambiguous 27 | int minv=minmax[nx].first; | ^~~~~~ /usr/include/c++/14/bits/stl_algo.h:3447:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr std::pair<_FIter, _FIter> std::minmax(initializer_list<_Tp>, _Compare)' 3447 | minmax(initializer_list<_Tp> __l, _Compare __comp) | ^~~~~~ /usr/include/c++/14/bits/stl_algo.h:3435:5: note: 'template<class _Tp> constexpr std::pair<_FIter, _FIter> std::minmax(initializer_list<_Tp>)' 3435 | minmax(initializer_list<_Tp> __l) | ^~~~~~ /usr/include/c++/14/bits/stl_algo.h:3309:5: note: 'template<class _Tp, class _Compare> constexpr std::pair<const _Tp&, const _Tp&> std::minmax(const _Tp&, const _Tp&, _Compare)' 3309 | minmax(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~~~~ /usr/include/c++/14/bits/stl_algo.h:3288:5: note: 'template<class _Tp> constexpr std::pair<const _Tp&, const _Tp&> std::minmax(const _Tp&, const _Tp&)' 3288 | minmax(const _Tp& __a, const _Tp& __b) | ^~~~~~ a.cc:8:3: note: 'P minmax [100005]' 8 | P minmax[N]; | ^~~~~~ a.cc:28:14: error: reference to 'minmax' is ambiguous 28 | int maxv=minmax[nx].second; | ^~~~~~ /usr/include/c++/14/bits/stl_algo.h:3447:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr std::pair<_FIter, _FIter> std::minmax(initializer_list<_Tp>, _Compare)' 3447 | minmax(initializer_list<_Tp> __l, _Compare __comp) | ^~~~~~ /usr/include/c++/14/bits/stl_algo.h:3435:5: note: 'template<class _Tp> constexpr std::pair<_FIter, _FIter> std::minmax(initializer_list<_Tp>)' 3435 | minmax(initializer_list<_Tp> __l) | ^~~~~~ /usr/include/c++/14/bits/stl_algo.h:3309:5: note: 'template<class _Tp, class _Compare> constexpr std::pair<const _Tp&, const _Tp&> std::minmax(const _Tp&, const _Tp&, _Compare)' 3309 | minmax(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~~~~ /usr/include/c++/14/bits/stl_algo.h:3288:5: note: 'template<class _Tp> constexpr std::pair<const _Tp&, const _Tp&> std::minmax(const _Tp&, const _Tp&)' 3288 | minmax(const _Tp& __a, const _Tp& __b) | ^~~~~~ a.cc:8:3: note: 'P minmax [100005]' 8 | P minmax[N]; | ^~~~~~ a.cc: In function 'int main()': a.cc:55:5: error: reference to 'minmax' is ambiguous 55 | minmax[i].first=-INF; | ^~~~~~ /usr/include/c++/14/bits/stl_algo.h:3447:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr std::pair<_FIter, _FIter> std::minmax(initializer_list<_Tp>, _Compare)' 3447 | minmax(initializer_list<_Tp> __l, _Compare __comp) | ^~~~~~ /usr/include/c++/14/bits/stl_algo.h:3435:5: note: 'template<class _Tp> constexpr std::pair<_FIter, _FIter> std::minmax(initializer_list<_Tp>)' 3435 | minmax(initializer_list<_Tp> __l) | ^~~~~~ /usr/include/c++/14/bits/stl_algo.h:3309:5: note: 'template<class _Tp, class _Compare> constexpr std::pair<const _Tp&, const _Tp&> std::minmax(const _Tp&, const _Tp&, _Compare)' 3309 | minmax(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~~~~ /usr/include/c++/14/bits/stl_algo.h:3288:5: note: 'template<class _Tp> constexpr std::pair<const _Tp&, const _Tp&> std::minmax(const _Tp&, const _Tp&)' 3288 | minmax(const _Tp& __a, const _Tp& __b) | ^~~~~~ a.cc:8:3: note: 'P minmax [100005]' 8 | P minmax[N]; | ^~~~~~ a.cc:56:5: error: reference to 'minmax' is ambiguous 56 | minmax[i].second=INF; | ^~~~~~ /usr/include/c++/14/bits/stl_algo.h:3447:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr std::pair<_FIter, _FIter> std::minmax(initializer_list<_Tp>, _Compare)' 3447 | minmax(initializer_list<_Tp> __l, _Compare __comp) | ^~~~~~ /usr/include/c++/14/bits/stl_algo.h:3435:5: note: 'template<class _Tp> constexpr std::pair<_FIter, _FIter> std::minmax(initializer_list<_Tp>)' 3435 | minmax(initializer_list<_Tp> __l) | ^~~~~~ /usr/include/c++/14/bits/stl_algo.h:3309:5: note: 'template<class _Tp, class _Compare> constexpr std::pair<const _Tp&, const _Tp&> std::minmax(const _Tp&, const _Tp&, _Compare)' 3309 | minmax(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~~~~ /usr/include/c++/14/bits/stl_algo.h:3288:5: note: 'template<class _Tp> constexpr std::pair<const _Tp&, const _Tp&> std::minmax(const _Tp&, const _Tp&)' 3288 | minmax(const _Tp& __a, const _Tp& __b) | ^~~~~~ a.cc:8:3: note: 'P minmax [100005]' 8 | P minmax[N]; | ^~~~~~ a.cc:58:7: error: reference to 'minmax' is ambiguous 58 | minmax[i].first=ans[i]-1; | ^~~~~~ /usr/include/c++/14/bits/stl_algo.h:3447:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr std::pair<_FIter, _FIter> std::minmax(initializer_list<_Tp>, _Compare)' 3447 | minmax(initializer_list<_Tp> __l, _Compare __comp) | ^~~~~~ /usr/include/c++/14/bits/stl_algo.h:3435:5: note: 'template<class _Tp> constexpr std::pair<_FIter, _FIter> std::minmax(initializer_list<_Tp>)' 3435 | minmax(initializer_list<_Tp> __l) | ^~~~~~ /usr/include/c++/14/bits/stl_algo.h:3309:5: note: 'template<class _Tp, class _Compare> constexpr std::pair<const _Tp&, const _Tp&> std::minmax(const _Tp&, const _Tp&, _Compare)' 3309 | minmax(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~~~~ /usr/include/c++/14/bits/stl_algo.h:3288:5: note: 'template<class _Tp> constexpr std::pair<const _Tp&, const _Tp&> std::minmax(const _Tp&, const _Tp&)' 3288 | minmax(const _Tp& __a, const _Tp& __b) | ^~~~~~ a.cc:8:3: note: 'P minmax [100005]' 8 | P minmax[N]; | ^~~~~~ a.cc:59:7: error: reference to 'minmax' is ambiguous 59 | minmax[i].second=ans[i]+1; | ^~~~~~ /usr/include/c++/14/bits/stl_algo.h:3447:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr std::pair<_FIter, _FIter> std::minmax(initializer_list<_Tp>, _Compare)' 3447 | minmax(initializer_list<_Tp> __l, _Compare __comp) | ^~~~~~ /usr/include/c++/14/bits/stl_algo.h:3435:5: note: 'template<class _Tp> constexpr std::pair<_FIter, _FIter> std::minmax(initializer_list<_Tp>)' 3435 | minmax(initializer_list<_Tp> __l) | ^~~~~~ /usr/include/c++/14/bits/stl_algo.h:3309:5: note: 'template<class _Tp, class _Compare> constexpr std::pair<const _Tp&, const _Tp&> std::minmax(const _Tp&, const _Tp&, _Compare)' 3309 | minmax(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~~~~ /usr/include/c++/14/bits/stl_algo.h:3288:5: note: 'template<class _Tp> constexpr std::pair<const _Tp&, const _Tp&> std::minmax(const _Tp&, const _Tp&)' 3288 | minmax(const _Tp& __a, const _Tp& __b) | ^~~~~~ a.cc:8:3: note: 'P minmax [100005]' 8 | P minmax[N]; | ^~~~~~
s531067381
p03950
C++
#include <bits/stdc++.h> using namespace std; inline void read(int &x) { x = 0; bool flag = 0; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') { flag = 1; } ch = getchar(); } while (isdigit(ch)) { x = x * 10 + ch - 48; ch = getchar(); } if (flag) { x = -x; } } const int N = 300005; int w, h, n, x[N], y[N], ans; int px[N], nx, py[N], ny; struct SegmentTree { int l[N << 2], r[N << 2]; int val[N << 2], lazy[N << 2]; inline void pushup(int p) { val[p] = max(val[p << 1], val[p << 1 | 1]); } void build(int p, int L, int R) { l[p] = L, r[p] = R; val[p] = -py[L] + w; lazy[p] = 0; if (L == R) { return; } int mid = l[p] + r[p] >> 1; build(p << 1, L, mid); build(p << 1 | 1, mid + 1, R); } inline void tag(int p, int v) { val[p] += v; lazy[p] += v; } inline void pushdown(int p) { if (lazy[p]) { tag(p << 1, lazy[p]); tag(p << 1 | 1, lazy[p]); lazy[p] = 0; } } void modify(int p, int L, int R, int v) { if (l[p] >= L && r[p] <= R) { tag(p, v); return; } pushdown(p); int mid = l[p] + r[p] >> 1; if (mid >= L) { modify(p << 1, L, R, v); } if (mid < R) { modify(p << 1 | 1, L, R, v); } pushup(p); } inline int query() { return val[1]; }/ } smt; inline void process() { static int lef[N], rig[N]; smt.build(1, 1, ny); for (int i = 1; i <= ny; ++i) { lef[i] = 0; rig[i] = w; } for (int i = 1; i <= n; ++i) { int X = px[x[i]]; if (X <= w / 2) { lef[y[i]] = max(lef[y[i]], X); } else { rig[y[i]] = min(rig[y[i]], X); } } static int sl[N], sr[N]; int tl = 0, tr = 0; for (int i = 1; i <= ny; ++i) { ans = max(ans, 2 * (py[i] + smt.query())); if (i > 1) { smt.modify(1, sl[tl], i - 1, -lef[i]); } while (tl && lef[sl[tl]] < lef[i]) { smt.modify(1, sl[tl - 1], sl[tl] - 1, lef[sl[tl]] - lef[i]); --tl; } sl[++tl] = i; if (i > 1) { smt.modify(1, sr[tr], i - 1, rig[i] - w); } while (tr && rig[sr[tr]] > rig[i]) { smt.modify(1, sr[tr - 1], sr[tr] - 1, rig[i] - rig[sr[tr]]); --tr; } sr[++tr] = i; } } int main() { scanf("%d%d%d", &w, &h, &n); for (int i = 1; i <= n; ++i) { scanf("%d%d", &x[i], &y[i]); px[++nx] = x[i]; py[++ny] = y[i]; } px[++nx] = 0; px[++nx] = w; py[++ny] = 0; py[++ny] = h; sort(px + 1, px + nx + 1); sort(py + 1, py + ny + 1); nx = unique(px + 1, px + nx + 1) - px - 1; ny = unique(py + 1, py + ny + 1) - py - 1; for (int i = 1; i <= n; ++i) { x[i] = lower_bound(px + 1, px + nx + 1, x[i]) - px; y[i] = lower_bound(py + 1, py + ny + 1, y[i]) - py; } process(); swap(w, h); swap(px, py); swap(nx, ny); swap(x, y); process(); printf("%d\n", ans); return 0; }
a.cc:69:4: error: expected unqualified-id before '/' token 69 | }/ | ^
s224109274
p03950
C++
#include <bits/stdc++.h> using namespace std; typedef pair<int,int> P; typedef pair<int,P> P1; #define fr first #define sc second #define chmax(a,b) a=max(a,b) #define chmin(a,b) a=min(a,b) #define mp1(a,b,c) P1(a,P(b,c)) int RET=0; vector<P1> f(const vector<P> &vec,int W,int H){ //sort(vec.begin(),vec.end()); vector<P1> ret; set<int> S; S.insert(0); S.insert(H); for(P p: vec){ auto itr=S.lower_bound(p.sc); int x=*itr; int y=*--itr; ret.push_back(mp1(y,x,p.fr)); S.insert(p.sc); } auto itr=S.begin(); while(1){ int x=*itr; itr++; if(itr==S.end())break; int y=*itr; ret.push_back(mp1(x,y,W)); } sort(ret.begin(),ret.end()); return ret; } int solve(int W,int H,int N,vector<P> p){ if(RET>=2*(W+H))return 0; if(N==0)return 2*(W+H); vector<P> L,R; int m; if(1){ /*vector<int> X; for(int i=0;i<N;i++){ X.push_back(p[i].fr); } sort(X.begin(),X.end()); X.erase(unique(X.begin(),X.end()),X.end());*/ if(p[0].fr==p[N-1].fr){ int ret=0; vector<int> Y; Y.push_back(0); Y.push_back(H); for(int i=0;i<N;i++){ Y.push_back(p[i].sc); } sort(Y.begin(),Y.end()); for(int i=0;i+1<Y.size();i++){ chmax(ret,Y[i+1]-Y[i]); } chmax(RET,max(2*(H+max(W-p[0].fr,p[0].fr)),2*(ret+W))); return max(2*(H+max(W-p[0].fr,p[0].fr)),2*(ret+W)); } //m=X[(X.size()-1)/2]; //m=p[(p.size()-1)/2].fr; m=W/2; for(int i=0;i<N;i++){ if(p[i].fr<=m){ p[i].fr=m-p[i].fr; L.push_back(p[i]); } else { p[i].fr-=m+1; R.push_back(p[i]); } } } reverse(L.begin(),L.end()); int ret=0; vector<P1> vec[2]={f(L,m,H),f(R,W-m-1,H)}; map<int,int> M[2]; int k[2]={}; while(k[0]<vec[0].size()||k[1]<vec[1].size()){ int t; if(k[0]==vec[0].size())t=1; else if(k[1]==vec[1].size())t=0; else if(vec[0][k[0]].fr<=vec[1][k[1]].fr)t=0; else t=1; P1 pp=vec[t][k[t]]; k[t]++; auto itr=M[1-t].lower_bound(pp.sc.fr); if(itr!=M[1-t].end()){ chmax(ret,2*((pp.sc.fr-pp.fr)+itr->sc+pp.sc.sc)+2); } if(itr!=M[1-t].begin()){ --itr; chmax(ret,2*((itr->fr-pp.fr)+itr->sc+pp.sc.sc)+2); } itr=M[t].lower_bound(pp.sc.fr); while(itr!=M[t].end()&&itr->fr+itr->sc<=pp.sc.fr+pp.sc.sc)M[t].erase(itr++); bool ok=itr==M[t].begin(); if(!ok){ --itr; ok=itr->fr+itr->sc<pp.sc.fr+pp.sc.sc; } if(ok)M[t].insert(pp.sc); } chmax(RET,ret); //chmax(ret,solve(m,H,L.size(),L)); //chmax(ret,solve(W-m-1,H,R.size(),R)); return ret; } int main(){ int w,h,n; vector<P> vec; scanf("%d%d%d",&w,&h,&n); for(int i=0;i<n;i++){ int a,b; scanf("%d%d",&a,&b); vec.push_back(P(a,b)); } sort(vec.begin(),vec.end()); for(int i=0;i+1<vec.size();i++){ chmax(RET,2*(H+vec[i+1].fr-vec[i].fr)); } solve(w,h,n,vec); for(int i=0;i<n;i++){ swap(vec[i].fr,vec[i].sc); } sort(vec.begin(),vec.end()); for(int i=0;i+1<vec.size();i++){ chmax(RET,2*(H+vec[i+1].fr-vec[i].fr)); } solve(h,w,n,vec); cout<<RET<<endl; return 0; /*w=h=100000000; n=10000; for(int i=0;i<n;i++){ int a=rand()%(w+1); int b=rand()%(w+1); vec.push_back(P(a,b)); }*/ sort(vec.begin(),vec.end()); cout<<solve(w,h,n,vec)<<endl; }
a.cc: In function 'int main()': a.cc:126:30: error: 'H' was not declared in this scope 126 | chmax(RET,2*(H+vec[i+1].fr-vec[i].fr)); | ^ a.cc:9:28: note: in definition of macro 'chmax' 9 | #define chmax(a,b) a=max(a,b) | ^ a.cc:134:30: error: 'H' was not declared in this scope 134 | chmax(RET,2*(H+vec[i+1].fr-vec[i].fr)); | ^ a.cc:9:28: note: in definition of macro 'chmax' 9 | #define chmax(a,b) a=max(a,b) | ^
s365086765
p03950
C++
#include<bits/stdc++.h> #define mo 1000000007 #define pi 3.1415926535898 #define eps 1e-9 using namespace std; long long read(){ long long xx=0,flagg=1; char ch=getchar(); while((ch<'0'||ch>'9')&&ch!='-') ch=getchar(); if(ch=='-'){ flagg=-1; ch=getchar(); } while(ch>='0'&&ch<='9'){ xx=xx*10+ch-'0'; ch=getchar(); } return xx*flagg; } void pus(long long xx,long long flagg){ if(xx<0){ putchar('-'); xx=-xx; } if(xx>=10) pus(xx/10,0); putchar(xx%10+'0'); if(flagg==1) putchar(' '); if(flagg==2) putchar('\n'); return; } int w,h,n,i,j,k,yy,ans,a[300005],b[300005],xia,shang,head,tail,zhan[300005]; struct nyh{ int x,y; }o[300005]; bool cmp(nyh u,nyh v){ return u.x<v.x||u.x==v.x&&u.y<v.y; } int maxx(int u,int v){ return u>v?u:v; } int minn(int u,int v){ return u<v?u:v; } void solve(int u,int v){ int mid=((u+v)>>1); if(u==v) return; solve(u,mid); solve(mid+1,v); for(i=mid,xia=0,shang=h;i>=u;i--){ a[i]=xia; b[i]=shang; if(o[i].y>=yy) shang=minn(shang,o[i].y); if(o[i].y<=yy) xia=maxx(xia,o[i].y); } for(i=mid+1,xia=0,shang=h;i<=v;i++){ a[i]=xia; b[i]=shang; if(o[i].y>=yy) shang=minn(shang,o[i].y); if(o[i].y<=yy) xia=maxx(xia,o[i].y); } head=1;tail=0; for(i=mid,j=mid+1;i>=u;i--){ while(j<=v&&a[j]<=a[i]){ while(head<=tail&&b[zhan[tail]]+o[zhan[tail]].x<=b[j]+o[j].x) tail--; tail++; zhan[tail]=j; j++; } while(head<tail&&b[i]+o[zhan[head]].x<=b[zhan[head+1]]+o[zhan[head+1]].x) head++; for(k=0;k<=5&&head+k<=tail) ans=maxx(ans,(o[zhan[head+k]].x-o[i].x+min(b[i],b[zhan[head+k]])-a[i])<<1); } } void work(){ sort(o+1,o+n+1,cmp); yy=(h>>1); o[0].x=0; o[0].y=yy; o[n+1].x=w; o[n+1].y=yy; solve(0,n+1); } int main(){ //freopen("a.in","r",stdin); //freopen("a.out","w",stdout); w=read();h=read();n=read(); for(i=1;i<=n;i++){ o[i].x=read(); o[i].y=read(); } ans=max(w,h)*2+2; work(); swap(w,h); for(i=1;i<=n;i++) swap(o[i].x,o[i].y); work(); pus(ans,2); return 0; }
a.cc: In function 'void solve(int, int)': a.cc:77:35: error: expected ';' before ')' token 77 | for(k=0;k<=5&&head+k<=tail) | ^ | ;
s735985091
p03950
C++
#include <algorithm> #include <cstdio> #include <iostream> #define debug(...) fprintf(stderr, __VA_ARGS__) #define lson u << 1, l, mid #define rson u << 1 | 1, mid + 1, r using namespace std; inline char nc() { // return getchar(); static char buf[100000], *l = buf, *r = buf; return l==r&&(r=(l=buf)+fread(buf,1,100000,stdin),l==r)?EOF:*l++; } template<class T> void read(T &x) { x = 0; int f = 1, ch = nc(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=nc();} while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=nc();} x *= f; } const int inf = 1e9; const int maxn = 3e5 + 10; int W, H, N; int x[maxn], y[maxn]; int p[2]; int xL[maxn]; int xR[maxn]; int h[2][maxn]; namespace seg { int mx[maxn << 2]; int tag[maxn << 2]; inline void change(int u, int d) { mx[u] += d; tag[u] += d; } inline void pushup(int u) { mx[u] = max(mx[u << 1], mx[u << 1 | 1]); } inline void pushdown(int u) { if(tag[u]) { change(u << 1, tag[u]); change(u << 1 | 1, tag[u]); tag[u] = 0; } } void build(int u, int l, int r, int *a) { tag[u] = 0; if(l == r) { mx[u] = -a[l]; return; } int mid = (l + r) >> 1; build(lson, a); build(rson, a); pushup(u); } void update(int u, int l, int r, int ql, int qr, int qv) { if(ql > qr) return; if(l == ql && r == qr) { change(u, qv); return; } int mid = (l + r) >> 1; pushdown(u); if(qr <= mid) update(lson, ql, qr, qv); else if(ql > mid) update(rson, ql, qr, qv); else { update(lson, ql, mid, qv); update(rson, mid + 1, qr, qv); } pushup(u); } } int solve(int W, int H, int *x, int *y, int *Hx, int *Hy, int mid) { static int mn[maxn], mnt; mnt = 0; static int mx[maxn], mxt; mxt = 0; for(int i = 1; i <= H; ++i) xL[i] = 0, xR[i] = Hx[W]; for(int i = 1; i <= N; ++i) { if(x[i] < mid) { xL[y[i]] = max(xL[y[i]], Hx[x[i]]); } else { xR[y[i]] = min(xR[y[i]], Hx[x[i]]); } } int an = Hx[W] + 1; seg :: build(1, 0, H, Hy); for(int i = 1; i <= H; ++i) { an = max(an, Hy[i] + seg :: mx[1]); while(mxt && xL[i] >= xL[mx[mxt]]) { seg :: update(1, 0, H, mx[mxt - 1], mx[mxt] - 1, xL[mx[mxt]]); --mxt; } mx[++mxt] = i; seg :: update(1, 0, H, mx[mxt - 1], i - 1, -xL[i]); while(mnt && xR[i] <= xR[mn[mnt]]) { seg :: update(1, 0, H, mn[mnt - 1], mn[mnt] - 1, -xR[mn[mnt]]); --mnt; } mn[++mnt] = i; seg :: update(1, 0, H, mn[mnt - 1], i - 1, xR[i]); } return an; } int solve() { h[0][++p[0]] = 0, h[0][++p[0]] = W / 2, h[0][++p[0]] = W / 2 + 1, h[0][++p[0]] = W; h[1][++p[1]] = 0, h[1][++p[1]] = H / 2, h[1][++p[1]] = H / 2 + 1, h[1][++p[1]] = H; sort(h[0] + 1, h[0] + p[0] + 1); sort(h[1] + 1, h[1] + p[1] + 1); p[0] = unique(h[0] + 1, h[0] + p[0] + 1) - h[0] - 1; p[1] = unique(h[1] + 1, h[1] + p[1] + 1) - h[1] - 1;1 for(int i = 1; i <= N; ++i) { x[i] = lower_bound(h[0] + 1, h[0] + p[0] + 1, x[i]) - h[0]; y[i] = lower_bound(h[1] + 1, h[1] + p[1] + 1, y[i]) - h[1]; } int an = 0; h[0][0] = h[1][0] = inf; an = max(an, solve(p[0], p[1], x, y, h[0], h[1], lower_bound(h[0] + 1, h[0] + p[0] + 1, W / 2) - h[0])); an = max(an, solve(p[0], p[1], x, y, h[0], h[1], lower_bound(h[0] + 1, h[0] + p[0] + 1, W / 2 + 1) - h[0])); an = max(an, solve(p[1], p[0], y, x, h[1], h[0], lower_bound(h[1] + 1, h[1] + p[1] + 1, H / 2) - h[1])); an = max(an, solve(p[1], p[0], y, x, h[1], h[0], lower_bound(h[1] + 1, h[1] + p[1] + 1, H / 2 + 1) - h[1])); return an << 1; } int main() { read(W), read(H), read(N); for(int i = 1; i <= N; ++i) { read(x[i]), read(y[i]); h[0][++p[0]] = x[i]; h[1][++p[1]] = y[i]; } printf("%d\n", solve()); return 0; }
a.cc: In function 'int solve()': a.cc:109:62: error: expected ';' before 'for' 109 | p[1] = unique(h[1] + 1, h[1] + p[1] + 1) - h[1] - 1;1 | ^ | ; 110 | for(int i = 1; i <= N; ++i) { | ~~~ a.cc:110:24: error: 'i' was not declared in this scope 110 | for(int i = 1; i <= N; ++i) { | ^
s363263381
p03950
C++
#include <bits/stdc++.h> using namespace std; #ifdef DEBUG_MODE #define DBG(n) n; #else #define DBG(n) ; #endif #define REP(i,n) for(ll (i) = (0);(i) < (n);++i) #define PB push_back #define MP make_pair #define FI first #define SE second #define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;} #define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;} #define ALL(v) v.begin(),v.end() #define Decimal fixed<<setprecision(20) #define INF 1000000000 #define LLINF 1000000000000000000LL #define MOD 1000000007 typedef long long ll; typedef pair<pair<ll,ll>,ll> P; ll w,h,n; bool isup[333333]; ll nyan(vector<pair<ll,pair<ll,ll>>> nowA, vector<pair<ll,pair<ll,ll>>> nowB){ ll ret = 0; ll lineA = -1,lineB = -1; deque<pair<ll,ll>> deq; for(ll i = 0;i < nowA.size();i++){ ll nowU = nowA[i].SE.FI; ll nowD = nowA[i].SE.SE; ll nowL = nowA[i].FI; while((ll)lineA < (ll)nowB.size() - 1 && nowB[lineA+1].SE.FI >= nowU && nowB[lineA+1].SE.SE <= nowD)lineA++; if(lineA != -1){ ret = max(ret,nowU - nowD + nowB[lineA].FI - nowL); } lineB = max(lineA,lineB); while((ll)lineB < (ll)nowB.size() - 1 && nowB[lineB+1].SE.SE <= nowD){ while(!deq.empty() && deq.rbegin()->FI < nowB[lineB+1].SE.FI + nowB[lineB+1].FI){ deq.pop_back(); } deq.push_back(MP(nowB[lineB+1].SE.FI + nowB[lineB+1].FI,lineB+1)); lineB++; } while(!deq.empty() && deq[0].SE <= lineA)deq.pop_front(); if(deq.size())ret = max(ret,deq[0].FI - nowL - nowD); //cout << "NYAN " << lineA << " " << lineB << endl; } //cout << "RET " << ret << endl; return ret; } ll seica(vector<P> v1, vector<P> v2, ll U, ll D, ll L, ll R){ ll ret = 0; //cout << v1.size() << " " << v2.size() << " " << U << ' ' << D << " " << L << " " << R << endl; vector<P> vv1; vector<P> vv2; vector<P> vv3; vector<P> vv4; ll mid; REP(i,v2.size()){ if(i < v2.size() / 2){ isup[v2[i].SE] = 0; vv2.PB(v2[i]); } else { isup[v2[i].SE] = 1; vv4.PB(v2[i]); } if(i == v2.size()/2)mid = v2[i].FI.FI; } REP(i,v1.size()){ if(isup[v1[i].SE])vv3.PB(v1[i]); else vv1.PB(v1[i]); } if(vv1.size() > 1)ret = max(ret,seica(vv1, vv2, mid, D, L, R)); if(vv3.size() > 1)ret = max(ret,seica(vv3, vv4, U, mid, L, R)); vv1.clear(); vv3.clear(); REP(i,v1.size()){ if(v[i].FI.FI < (L + R) / 2)vv1.PB(v1[i]); else vv3.PB(v1[i]); } vector<pair<ll,pair<ll,ll>>> nowA; vector<pair<ll,pair<ll,ll>>> nowB; ll uu = U,dd = D; for(int i = vv1.size() - 1;i >= 0;i--){ nowA.PB(MP(vv1[i].FI.FI,MP(uu,dd))); if(vv1[i].FI.SE > mid)uu = min(uu,vv1[i].FI.SE); else if(vv1[i].FI.SE == mid){ if(uu - vv1[i].FI.SE > vv1[i].FI.SE - dd)dd = max(dd,vv1[i].FI.SE); else uu = min(uu,vv1[i].FI.SE); } else dd = max(dd,vv1[i].FI.SE); } nowA.PB(MP(L,MP(uu,dd))); uu = U,dd = D; for(ll i = 0;i < vv3.size();i++){ nowB.PB(MP(vv3[i].FI.FI,MP(uu,dd))); if(vv3[i].FI.SE > mid)uu = min(uu,vv3[i].FI.SE); else if(vv3[i].FI.SE == mid){ if(uu - vv3[i].FI.SE > vv3[i].FI.SE - dd)dd = max(dd,vv3[i].FI.SE); else uu = min(uu,vv3[i].FI.SE); } else dd = max(dd,vv3[i].FI.SE); } nowB.PB(MP(R,MP(uu,dd))); //cout << " IN SEICA " << nowA.size() << " " << nowB.size() << endl; ret = max(ret,nyan(nowA,nowB)); REP(i,nowA.size())nowA[i].FI = R - nowA[i].FI; REP(i,nowB.size())nowB[i].FI = R - nowB[i].FI; ret = max(ret,nyan(nowB,nowA)); return ret; } int main(){ cin >> w >> h >> n; vector<P> v1; vector<P> v2; REP(i, n){ ll a,b;cin >> a >> b; v1.PB(MP(MP(a,b),i)); v2.PB(MP(MP(b,a),i)); } sort(ALL(v1)); sort(ALL(v2)); cout << 2*max(seica(v1,v2,h,0,0,w),seica(v2,v1,w,0,0,h)) << endl; return 0; }
a.cc: In function 'll seica(std::vector<std::pair<std::pair<long long int, long long int>, long long int> >, std::vector<std::pair<std::pair<long long int, long long int>, long long int> >, ll, ll, ll, ll)': a.cc:87:20: error: 'v' was not declared in this scope 87 | if(v[i].FI.FI < (L + R) / 2)vv1.PB(v1[i]); | ^
s579766202
p03950
C++
#include <iostream> #include <fstream> #include <cstdio> #include <cassert> #include <complex> #include <cmath> #include <algorithm> #include <vector> #include <string> #include <cstdlib> #include <cstring> #include <iomanip> #include <numeric> #include <sstream> #include <ctime> #include <cctype> #include <set> #include <map> #include <queue> #include <bitset> #include <deque> #include <stack> #include <memory.h> using namespace std; typedef long long ll; #define mp make_pair vector<int> a[100100]; priority_queue<pair<int, int>,vector<pair<int, int> >,greater<pair<int, int> > > pq; int tag[100100]; bool dfs(int now, int par){ for(int i=0;i<a[i].size();i++){ if(a[now][i] == par) continue; if(abs(tag[-tag[a[now][i]])!=1){ return false; } if(!dfs(a[now][i], now)){ return false; } } return true; } int main(){ int n; cin >> n; for(int i=0;i<n-1;i++){ int v, g; cin>>v>>g; v--, g--; a[v].push_back(g); a[g].push_back(v); } int m; cin>>m; memset(tag,-1,sizeof(tag)); for(int i=0;i<m;i++){ int v,g; cin>>v>>g; v--; tag[v]=g; pq.push(mp(g,v)); } while(!pq.empty()){ pair<int, int> p = pq.top(); pq.pop(); int v=p.second; for(int i=0;i<a[i].size();i++){ if(tag[a[v][i]] == -1){ tag[a[v][i]] = tag[v]+1; pq.push(mp(tag[a[v][i]],a[v][i])); } } } if(!dfs(0, -1)){ cout<<"No"; } else{ cout<<"Yes"<<endl; for(int i=0;i<n;i++){ cout<<tag[i]<<endl; } } return 0; }
a.cc: In function 'bool dfs(int, int)': a.cc:33:43: error: expected ']' before ')' token 33 | if(abs(tag[-tag[a[now][i]])!=1){ | ^ | ]
s791695410
p03950
C++
#include <bits/stdc++.h> using namespace std; #define maxn 1500000 #define int long long #define INF 199999999 int W, H, n, top, top2, S[maxn], S2[maxn]; int ans, mark[maxn], mx[maxn]; int read() { int x = 0, k = 1; char c; c = getchar(); while(c < '0' || c > '9') { if(c == '-') k = -1; c = getchar(); } while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar(); return x * k; } struct node { int x, y; friend bool operator <(const node& a, const node& b) { return a.y < b.y; } }P[maxn]; void Push_Down(int p) { if(!mark[p]) return; mark[p << 1] += mark[p], mark[p << 1 | 1] += mark[p]; mx[p << 1] += mark[p], mx[p << 1 | 1] += mark[p]; mark[p] = 0; } void Update(int p, int l, int r, int L, int R, int x) { if(L > R) return; if(L <= l && R >= r) { mark[p] += x, mx[p] += x; return; } if(L > r || R < l) return; Push_Down(p); int mid = (l + r) >> 1; Update(p << 1, l, mid, L, R, x); Update(p << 1 | 1, mid + 1, r, L, R, x); mx[p] = max(mx[p << 1], mx[p << 1 | 1]); } int Query(int p, int l, int r, int L, int R) { if(L <= l && R >= r) return mx[p]; if(L > r || R < l) return 0; int mid = (l + r) >> 1; Push_Down(p); return max(Query(p << 1, l, mid, L, R), Query(p << 1 | 1, mid + 1, r, L, R)); } void Work() { memset(mx, 0, sizeof(mx)); memset(mark, 0, sizeof(mark)); top = top2 = 0; int mid = W >> 1; for(int i = 1; i <= n; i ++) { if(i > 1) ans = max(ans, (P[i].y + Query(1, 1, n, 1, i - 1)) * 2); Update(1, 1, n, i, i, W - P[i].y); if(P[i].x <= mid) { int last = 0, rec = i; while(top && P[S[top]].x <= P[i].x) { Update(1, 1, n, S[top], rec - 1, -(P[i].x - last)); last = P[S[top]].x, rec = S[top]; top --; } Update(1, 1, n, S[top], rec - 1, -(P[i].x - last)); S[++ top] = i; } else { int last = W, rec = i; while(top2 && P[S2[top2]].x >= P[i].x) { Update(1, 1, n, S2[top2], rec - 1, -(P[i].x - last)); last = P[S2[top2]].x, rec = S2[top2], top2 --; } Update(1, 1, n, S2[top2], rec - 1, -(P[i].x - last)); S2[++ top2] = i; } } } int main() { W = read(), H = read(), n = read(); int X1 = 0, Y1 = 0, X2 = INF, Y2 = INF; for(int i = 1; i <= n; i ++) P[i].x = read(), P[i].y = read(); for(int i = 1; i <= n; i ++) { X1 = max(X1, P[i].x), Y1 = max(Y1, P[i].y); X2 = min(X2, P[i].x), Y2 = min(Y2, P[i].y); } ans = max(ans, (H + max(X2, (W - X1))) * 2); ans = max(ans, (W + max(Y2, (H - Y1))) * 2); sort(P + 1, P + 1 + n); Work(); for(int i = 1; i <= n; i ++) swap(P[i].x, P[i].y); swap(W, H); sort(P + 1, P + 1 + n); Work(); printf("%d\n", ans); return 0; }
cc1plus: error: '::main' must return 'int'
s999372486
p03950
C++
clude<cstdio> #include<algorithm> #include<cstring> #define LL long long #define lc(x) x<<1 #define rc(x) x<<1|1 using namespace std; const int N=3e5+5; int w,h,n,ans,L,R; int mx[N*4],tag[N*4]; struct node{int x,y;node(int _x=0,int _y=0):x(_x),y(_y){};}p[N],a[N],b[N]; int read() { int x=0,f=1;char c=getchar(); while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();} while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();} return x*f; } void modify(int x,int l,int r,int v) { if(L<=l&&r<=R){mx[x]+=v;tag[x]+=v;return;} int mid=(l+r)>>1; if(L<=mid)modify(lc(x),l,mid,v); if(R>mid)modify(rc(x),mid+1,r,v); mx[x]=max(mx[lc(x)],mx[rc(x)])+tag[x]; } bool cmp(node a,node b){return a.x<b.x||(a.x==b.x&&a.y<b.y);} void work() { memset(mx,0,sizeof(mx)); memset(tag,0,sizeof(tag)); sort(p+1,p+n+1,cmp); int l=0,r=0; for(int i=1;i<=n-1;i++) { if(p[i].y<=h/2) { int nxt=i-1; while(l&&a[l].y<p[i].y) { L=a[l].x;R=nxt;nxt=a[l].x-1; modify(1,1,n,a[l].y-p[i].y);l--; } if(nxt!=i-1)a[++l]=node(nxt+1,p[i].y); } else { int nxt=i-1; while(r&&b[r].y>p[i].y) { L=b[r].x;R=nxt;nxt=b[r].x-1; modify(1,1,n,p[i].y-b[r].y);r--; } if(nxt!=i-1)b[++r]=node(nxt+1,p[i].y); } a[++l]=node(i,0);b[++r]=node(i,h); L=i;R=i;modify(1,1,n,h-p[i].x); ans=max(ans,mx[1]+p[i+1].x); } } int main() { w=read();h=read();n=read(); for(int i=1;i<=n;i++)p[i].x=read(),p[i].y=read(); p[++n]=node(0,0);p[++n]=node(w,h);work(); for(int i=1;i<=n;i++)swap(p[i].x,p[i].y); swap(w,h);work(); printf("%d",ans*2); return 0; }
a.cc:1:1: error: 'clude' does not name a type 1 | clude<cstdio> | ^~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:62, from /usr/include/c++/14/algorithm:60, from a.cc:2: /usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity 164 | __is_null_pointer(std::nullptr_t) | ^ /usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)' 159 | __is_null_pointer(_Type) | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std' 164 | __is_null_pointer(std::nullptr_t) | ^~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/type_traits:295:27: error: 'size_t' has not been declared 295 | template <typename _Tp, size_t = sizeof(_Tp)> | ^~~~~~ /usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std' 666 | struct is_null_pointer<std::nullptr_t> | ^~~~~~~~~ /usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid 666 | struct is_null_pointer<std::nullptr_t> | ^ /usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid 670 | struct is_null_pointer<const std::nullptr_t> | ^ /usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid 674 | struct is_null_pointer<volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid 678 | struct is_null_pointer<const volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:984:26: error: 'size_t' has not been declared 984 | template<typename _Tp, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:985:40: error: '_Size' was not declared in this scope 985 | struct __is_array_known_bounds<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:985:46: error: template argument 1 is invalid 985 | struct __is_array_known_bounds<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std' 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^~~~~~ /usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^ /usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std' 1438 | : public integral_constant<std::size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid 1438 | : public integral_constant<std::size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared 1440 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope 1441 | struct rank<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid 1441 | struct rank<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std' 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std' 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1451:32: error: 'size_t' was not declared in this scope 1451 | : public integral_constant<size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:64:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' 63 | #include <bits/version.h> +++ |+#include <cstddef> 64 | /usr/include/c++/14/type_traits:1451:41: error: template argument 1 is invalid 1451 | : public integral_constant<size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1451:41: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1453:26: error: 'size_t' has not been declared 1453 | template<typename _Tp, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:1454:23: error: '_Size' was not declared in this scope 1454 | struct extent<_Tp[_Size], 0> | ^~~~~ /usr/include/c++/14/type_traits:1454:32: error: template argument 1 is invalid 1454 | struct extent<_Tp[_Size], 0> | ^ /usr/include/c++/14/type_traits:1455:32: error: 'size_t' was not declared in this scope 1455 | : public integral_constant<size_t, _Size> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1455:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1455:40: error: '_Size' was not declared in this scope 1455 | : public integral_constant<size_t, _Size> { }; | ^~~~~ /usr/include/c++/14/type_traits:1455:45: error: template argument 1 is invalid 1455 | : public integral_constant<size_t, _Size> { }; | ^ /usr/include/c++/14/type_traits:1455:45: error: template argument 2 is invalid /usr/include/c++/14/type_traits:1457:42: error: 'size_t' has not been declared 1457 | template<typename _Tp, unsigned _Uint, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:1458:23: error: '_Size' was not declared in this scope 1458 | struct extent<_Tp[_Size], _Uint> | ^~~~~ /usr/include/c++/14/type_traits:1458:36: error: template argument 1 is invalid 1458 | struct extent<_Tp[_Size], _Uint> | ^ /usr/include/c++/14/type_traits:1463:32: error: 'size_t' was not declared in this scope 1463 | : public integral_constant<size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1463:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1463:41: error: template argument 1 is invalid 1463 | : public integral_constant<size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1463:41: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1857:26: error: 'size_t' does not name a type 1857 | { static constexpr size_t __size = sizeof(_Tp); }; | ^~~~~~ /usr/include/c++/14/type_traits:1857:26: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1859:14: error: 'size_t' has not been declared 1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)> | ^~~~~~ /usr/include/c++/14/type_traits:1859:48: error: '_Sz' was not declared in this scope 1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)> | ^~~ /usr/include/c++/14/type_traits:1860:14: error: no default argument for '_Tp' 1860 | struct __select; | ^~~~~~~~ /usr/include/c++/14/type_traits:1862:14: error: 'size_t' has not been declared 1862 | template<size_t _Sz, typename _Uint, typename... _UInts> | ^~~~~~ /usr/include/c++/14/type_traits:1863:23: error: '_Sz' was not declared in this scope 1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true> | ^~~ /usr/include/c++/14/type_traits:1863:57: error: template argument 1 is invalid 1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true> | ^ /usr/include/c++/14/type_traits:1866:14: error: 'size_t' has not been declared 1866 | template<size_t _Sz, typename _Uint, typename... _UInts> | ^~~~~~ /usr/include/c++/14/type_traits:1867:23: error: '_Sz' was not declared in this scope 1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false> | ^~~ /usr/include/c++/14/type_traits:1867:58: error: template argument 1 is invalid 1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false> |
s162355353
p03950
C++
#include<set> #include<map> #include<deque> #include<queue> #include<stack> #include<cmath> #include<ctime> #include<bitset> #include<string> #include<vector> #include<cstdio> #include<cstdlib> #include<cstring> #include<climits> #include<complex> #include<iostream> #include<algorithm> #define ll long long using namespace std; inline void up(int &a,const int &b){if(a<b)a=b;} inline void down(int &a,const int &b){if(a>b)a=b;} const int maxn = 310000; int n,w,h; struct point { int x,y; }p[maxn]; inline bool cmpx(const point x,const point y){return x.x<y.x;} inline bool cmpy(const point x,const point y){return x.y<y.y;} struct node { int x,i; friend inline bool operator <(const node a,const node b){return a.x<b.x;} }a[maxn]; int tox[maxn],toy[maxn],idx,idy; void trans() { for(int i=1;i<=n;i++) a[i]=(node){p[i].x,i}; sort(a+1,a+n+1); tox[idx=0]=0; for(int i=1;i<=n;i++) { if(tox[idx]!=a[i].x) tox[++idx]=a[i].x; p[a[i].i].x=idx; } if(tox[idx]!=w) tox[++idx]=w; for(int i=1;i<=n;i++) a[i]=(node){p[i].y,i}; sort(a+1,a+n+1); toy[idy=0]=0; for(int i=1;i<=n;i++) { if(toy[idy]!=a[i].x) toy[++idy]=a[i].x; p[a[i].i].y=idy; } if(toy[idy]!=h) toy[++idy]=h; } struct Segment_Tree { int seg[maxn<<2],flag[maxn<<2]; void init() { memset(seg,0,sizeof seg); memset(flag,0,sizeof flag); } int lx,rx,c; void pushdown(int x) { if(!flag[x]) return; int &fl=flag[x],lc=x<<1,rc=lc|1; seg[lc]+=fl,seg[rc]+=fl; flag[lc]+=fl,flag[rc]+=fl; fl=0; } void upd(const int x,const int l,const int r) { if(rx<l||r<lx) return; if(lx<=l&&r<=rx) { seg[x]+=c;flag[x]+=c;return; } pushdown(x); int mid=l+r>>1; upd(x<<1,l,mid); upd(x<<1|1,mid+1,r); seg[x]=max(seg[x<<1],seg[x<<1|1]); } int query(const int x,const int l,const int r) { if(rx<l||r<lx) return INT_MIN; if(lx<=l&&r<=rx) return seg[x]; pushdown(x); int mid=l+r>>1; return max(query(x<<1,l,mid),query(x<<1|1,mid+1,r)); } }seg; int mid,ans; int tl[maxn],tli[maxn],tpl; int tr[maxn],tri[maxn],tpr; int main() { scanf("%d%d%d",&w,&h,&n); for(int i=1;i<=n;i++) scanf("%d%d",&p[i].x,&p[i].y); trans(); seg.init(); sort(p+1,p+n+1,cmpy); mid=w>>1; tpl=tpr=0; int pos=1; for(int i=1;i<=idy;i++) { seg.lx=seg.rx=i,seg.c=-toy[i-1],seg.upd(1,1,idy); int L=0,R=idx,la; while(pos<=n&&p[pos].y<i) { if(tox[p[pos].x]<=mid) up(L,p[pos].x); else down(R,p[pos].x); pos++; } la=i; while(tl[tpl]<L&&tpl) { seg.lx=tli[tpl],seg.rx=la-1,seg.c=tox[tl[tpl]]-tox[L],seg.upd(1,1,idy); la=tli[tpl--]; } if(la!=i) tl[++tpl]=L,tli[tpl]=la; tl[++tpl]=0,tli[tpl]=i; seg.lx=seg.rx=i,seg.c=mid,seg.upd(1,1,idy); la=i; while(tr[tpr]>R&&tpr) { seg.lx=tri[tpr],seg.rx=la-1,seg.c=tox[R]-tox[tr[tpr]],seg.upd(1,1,idy); la=tri[tpr--]; } if(la!=i) tr[++tpr]=R,tri[tpr]=la; tr[++tpr]=idx,tri[tpr]=i; seg.lx=seg.rx=i,seg.c=w-mid,seg.upd(1,1,idy); seg.lx=1,seg.rx=i; up(ans,seg.query(1,1,idy)+toy[i]); } seg.init(); sort(p+1,p+n+1,cmpy); mid=(w>>1)+1; tpl=tpr=0; int pos=1; for(int i=1;i<=idy;i++) { seg.lx=seg.rx=i,seg.c=-toy[i-1],seg.upd(1,1,idy); int L=0,R=idx,la; while(pos<=n&&p[pos].y<i) { if(tox[p[pos].x]<=mid) up(L,p[pos].x); else down(R,p[pos].x); pos++; } la=i; while(tl[tpl]<L&&tpl) { seg.lx=tli[tpl],seg.rx=la-1,seg.c=tox[tl[tpl]]-tox[L],seg.upd(1,1,idy); la=tli[tpl--]; } if(la!=i) tl[++tpl]=L,tli[tpl]=la; tl[++tpl]=0,tli[tpl]=i; seg.lx=seg.rx=i,seg.c=mid,seg.upd(1,1,idy); la=i; while(tr[tpr]>R&&tpr) { seg.lx=tri[tpr],seg.rx=la-1,seg.c=tox[R]-tox[tr[tpr]],seg.upd(1,1,idy); la=tri[tpr--]; } if(la!=i) tr[++tpr]=R,tri[tpr]=la; tr[++tpr]=idx,tri[tpr]=i; seg.lx=seg.rx=i,seg.c=w-mid,seg.upd(1,1,idy); seg.lx=1,seg.rx=i; up(ans,seg.query(1,1,idy)+toy[i]); } seg.init(); sort(p+1,p+n+1,cmpx); mid=h>>1; tpl=tpr=0; pos=1; for(int i=1;i<=idx;i++) { seg.lx=seg.rx=i,seg.c=-tox[i-1],seg.upd(1,1,idx); int L=0,R=idy,la; while(pos<=n&&p[pos].x<i) { if(tox[p[pos].y]<=mid) up(L,p[pos].y); else down(R,p[pos].y); pos++; } la=i; while(tl[tpl]<L&&tpl) { seg.lx=tli[tpl],seg.rx=la-1,seg.c=toy[tl[tpl]]-toy[L],seg.upd(1,1,idx); la=tli[tpl--]; } if(la!=i) tl[++tpl]=L,tli[tpl]=la; tl[++tpl]=0,tli[tpl]=i; seg.lx=seg.rx=i,seg.c=mid,seg.upd(1,1,idx); la=i; while(tr[tpr]>R&&tpr) { seg.lx=tri[tpr],seg.rx=la-1,seg.c=toy[R]-toy[tr[tpr]],seg.upd(1,1,idx); la=tri[tpr--]; } if(la!=i) tr[++tpr]=R,tri[tpr]=la; tr[++tpr]=idy,tri[tpr]=i; seg.lx=seg.rx=i,seg.c=h-mid,seg.upd(1,1,idx); seg.lx=1,seg.rx=i; up(ans,seg.query(1,1,idx)+tox[i]); } printf("%d\n",ans<<1); return 0; }
a.cc: In function 'int main()': a.cc:140:13: error: redeclaration of 'int pos' 140 | int pos=1; | ^~~ a.cc:104:13: note: 'int pos' previously declared here 104 | int pos=1; | ^~~
s263122858
p03950
C++
#include <cstdio> #include <iostream> #include <cstring> #include <algorithm> #include <cmath> #define N 300010 using namespace std; int W, H, n; int x[N], y[N]; /* struct node { int mx; }tr[N << 2]; void update(int x) { tr[x].mx = max(tr[x << 1].mx, tr[x << 1 | 1].mx); } void build(int a, int b, int x) { tr[x].mx = 0; if (a < b) { int mid = a + b >> 1; build(a, mid, x << 1); build(mid + 1, b, x << 1 | 1); } } void modify(int x, int a, int b, int pos, int ad) { if (a == b) tr[x].mx = ad; int mid = a + b >> 1; if (pos <= mid) modify(x << 1, a, mid, pos, ad); else modify(x << 1 | 1, mid + 1, b, pos, ad); update(x); } int query(int x, int a, int b, int pos) { if (a == b) return tr[x].mx; int mid = l + r >> 1; int res = 0; if (l <= mid) res = max(res, query(x << 1, a, mid, l, r)); if (r > mid) res = max(res, query(x << 1 | 1, mid + 1, b, l, r)); update(x); return res; } */ int data[N]; int ans = 0; double halfW, halfH; bool cmp(const int a, const int b) { return y[a] < y[b]; } int r[N]; int top[2]; int s[2][N]; void solve() { for (int i = 1; i <= n; ++i) r[i] = i; sort(r + 1, r + n + 1, cmp); int min1 = W, max2 = 0; //cout << endl; for (int i = 1; i <= n; ++i) { bool b = x[r[i]] > halfW; //cout << x[r[i]] << ' ' << y[r[i]] << endl; ans = max(ans, (min1 - max2) * 2 + y[r[i]] * 2); //cout << "ans: " << ans << endl; if (b) min1 = min(min1, x[r[i]]); else max2 = max(max2, x[r[i]]); while (top[b] && (x[r[i]] < x[r[s[b][top[b]]]]) == b && x[r[i]] != x[r[s[b][top[b]]]]) { if (top[b ^ 1]) { int p = *lower_bound(s[b ^ 1] + 1, s[b ^ 1] + top[b ^ 1] + 1, s[b][top[b]]); if (p <= top[b ^ 1]) data[s[b][top[b]]] = abs(x[r[s[b][top[b]]]] - x[r[p]]) - y[r[s[b][top[b]]]]; else data[s[b][top[b]]] = (b ? x[r[s[b][top[b]]]] : (W - x[r[s[b][top[b]]]])) - y[r[s[b][top[b]]]]; } else { data[s[b][top[b]]] = (b ? x[r[s[b][top[b]]]] : W - x[r[s[b][top[b]]]]) - y[r[s[b][top[b]]]]; } ans = max(ans, data[top[b]] * 2 + 2 * y[r[i]]); data[s[b][top[b]--]] = 0; } s[b][++top[b]] = i; } ans = max(ans, (min1 - max2) * 2 + H * 2); int p = 0, q = 1, t[2] = {top[p], top[q]}; while (t[p] || t[q]) { if (!t[p] || t[q] && s[p][t[p]] < s[q][t[q]]) swap(p, q); if (t[q] < top[q]) { int pos = s[q][t[q] + 1]; data[s[p][t[p]]] = abs(x[r[s[p][t[p]]]] - x[r[pos]]) - y[r[s[p][t[p]]]]; } else { data[s[p][t[p]]] = (p ? x[r[s[p][t[p]]]] : W - x[r[s[p][t[p]]]]) - y[r[s[p][t[p]]]]; } ans = max(ans, data[s[p][t[p]]] * 2 + H * 2); //cout << "ans: " << ans << ' ' << p << ' ' << x[r[s[p][t[p]]]] << ' ' << s[p][t[p]] << ' ' << data[s[p][t[p]]] << endl; t[p]--; } } int main() { scanf("%d%d%d", &W, &H, &n); halfW = (double)W / 2; halfH = (double)H / 2; for (int i = 1; i <= n; ++i) { scanf("%d%d", &x[i], &y[i]); } memset(data, 0, sizeof(data)); solve(); swap(W, H); swap(halfW, halfH); for (int i = 1; i <= n; ++i) { swap(x[i], y[i]); } memset(data, 0, sizeof(data)); solve(); printf("%d\n", max(ans, 2 * max(W, H) + 2); }
a.cc: In function 'void solve()': a.cc:75:54: error: reference to 'data' is ambiguous 75 | if (p <= top[b ^ 1]) data[s[b][top[b]]] = abs(x[r[s[b][top[b]]]] - x[r[p]]) - y[r[s[b][top[b]]]]; | ^~~~ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:2: /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:48:5: note: 'int data [300010]' 48 | int data[N]; | ^~~~ a.cc:76:38: error: reference to 'data' is ambiguous 76 | else data[s[b][top[b]]] = (b ? x[r[s[b][top[b]]]] : (W - x[r[s[b][top[b]]]])) - y[r[s[b][top[b]]]]; | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:48:5: note: 'int data [300010]' 48 | int data[N]; | ^~~~ a.cc:79:33: error: reference to 'data' is ambiguous 79 | data[s[b][top[b]]] = (b ? x[r[s[b][top[b]]]] : W - x[r[s[b][top[b]]]]) - y[r[s[b][top[b]]]]; | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:48:5: note: 'int data [300010]' 48 | int data[N]; | ^~~~ a.cc:81:40: error: reference to 'data' is ambiguous 81 | ans = max(ans, data[top[b]] * 2 + 2 * y[r[i]]); | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:48:5: note: 'int data [300010]' 48 | int data[N]; | ^~~~ a.cc:82:25: error: reference to 'data' is ambiguous 82 | data[s[b][top[b]--]] = 0; | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:48:5: note: 'int data [300010]' 48 | int data[N]; | ^~~~ a.cc:93:25: error: reference to 'data' is ambiguous 93 | data[s[p][t[p]]] = abs(x[r[s[p][t[p]]]] - x[r[pos]]) - y[r[s[p][t[p]]]]; | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:48:5: note: 'int data [300010]' 48 | int data[N]; | ^~~~ a.cc:96:25: error: reference to 'data' is ambiguous 96 | data[s[p][t[p]]] = (p ? x[r[s[p][t[p]]]] : W - x[r[s[p][t[p]]]]) - y[r[s[p][t[p]]]]; | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:48:5: note: 'int data [300010]' 48 | int data[N]; | ^~~~ a.cc:98:32: error: reference to 'data' is ambiguous 98 | ans = max(ans, data[s[p][t[p]]] * 2 + H * 2); | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:48:5: note: 'int data [300010]' 48 | int data[N]; | ^~~~ a.cc: In function
s334397178
p03950
C++
#include<bits/stdc++.h> #define N 111111 #define M 222222 using namespace std; int A,B,n,x,y,t,i,j,now,an,maxT; struct P{int x,y;}p[N]; multiset<int>S,T; multiset<int>::iterator it,il,ir; bool cmp(P a,P b){return a.x<b.x;} void add(int x){ //printf("ADD %d\n",x); ir=S.upper_bound(x); il=--S.upper_bound(x); //printf("%d %d\n",*ir,*il); T.erase(T.find((*ir)-(*il))); S.insert(x); T.insert(x-(*il)); T.insert((*ir)-x); it=T.end();it--; maxT=*it; } void del(int x){ //printf("DEL %d\n",x); S.erase(S.find(x)); ir=S.upper_bound(x); il=--S.upper_bound(x); T.insert((*ir)-(*il)); T.erase(T.find(x-(*il))); T.erase(T.find((*ir)-x)); it=T.end();it--; maxT=*it; } int main(){ scanf("%d%d%d",&A,&B,&n); an=max(A,B); S.insert(0);S.insert(B);T.insert(B);maxT=B; for(i=1;i<=n;i++){ scanf("%d%d",&x,&y); if(x>0&&x<A&&y>0&&y<B)p[++t]=P{x,y}; }n=t; sort(p+1,p+n+1,cmp); p[0]=P{0,0}; p[n+1]=P{A,0}; for(i=j=1;i<=n+1;i++){ if(j<i)j=i; now=p[j].x-p[i-1].x+maxT; printf("%d %d %d %d %d\n",i,j,now,p[j+1].x-p[i-1].x+maxT,maxT); for(;j<=n;){ now=p[j].x-p[i-1].x+maxT; add(p[j].y); printf("%d %d %d %d %d\n",i,j,now,p[j+1].x-p[i-1].x+maxT,maxT); if(p[j+1].x-p[i-1].x+maxT>now)now=p[j+1].x-p[i-1].x+maxT,j++,puts("??"); else {del(p[j].y);puts("!!");break;} } //printf("%d %d %d\n",i,j,now); an=max(an,now); if(j!=i)del(p[i].y); } printf("%d",an*2);fdsafdasf }
a.cc: In function 'int main()': a.cc:61:27: error: 'fdsafdasf' was not declared in this scope 61 | printf("%d",an*2);fdsafdasf | ^~~~~~~~~
s921250285
p03950
C++
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> PII; const int MM = 1e9 + 7; const double eps = 1e-8; const int MAXN = 2e6 + 10; int n, m; int W, H; struct Pt{ ll x, y; } a[MAXN]; ll ans; void read(){ scanf("%d%d%d", &W, &H, &n); for(int i = 1; i <= n; i++){ scanf("%lld%lld", &a[i].x, &a[i].y); } /* a[++n] = (Pt){0,0}; a[++n] = (Pt){W,H}; a[++n] = (Pt){0,H}; a[++n] = (Pt){W,0};*/ } ll work(){ sort(a+1, a+n+1, [](const Pt&a, const Pt&b){ return a.x==b.x?a.y<b.y:a.x<b.x; }); for(int i = 1; i < n; i++) ans = max(ans, (a[i+1].x-a[i].x)*2+H*2) for(int i = 1; i <= n; i++){ ll l = 0, r = H; for(int j = i + 1; j <= n; j++){ ans = max(ans, (r-l)*2+2*(a[j].x-a[i].x)); if (a[j].y >= a[i].y) r = min(r, a[j].y); if (a[j].y <= a[i].y) l = max(l, a[j].y); if ((r-l+W-a[i].x)*2 <= ans) break; } } } void solve(){ ans = 0; work(); /* for(int i = 1; i <= n; i++) swap(a[i].x, a[i].y); swap(W, H); work();*/ printf("%lld\n", ans); } void printans(){ } int main(){ int T = 1; // cin>>T; while(T--){ read(); solve(); printans(); } return 0; }
a.cc: In function 'll work()': a.cc:39:56: error: expected ';' before 'for' 39 | ans = max(ans, (a[i+1].x-a[i].x)*2+H*2) | ^ | ; 40 | for(int i = 1; i <= n; i++){ | ~~~ a.cc:40:24: error: 'i' was not declared in this scope 40 | for(int i = 1; i <= n; i++){ | ^ a.cc:51:1: warning: no return statement in function returning non-void [-Wreturn-type] 51 | } | ^
s438259414
p03950
C++
compile error #include <bits/stdc++.h> using namespace std; int h; int w; int n; map<int, vector<int> > mp; deque<pair<int,int> > las[300002]; vector<int> ids[300002]; vector<int> v[300002]; int ord; void solve(){ int idx = 0; ord = 0; for (int i = 0; i < 300002; i++){ las[i].clear(); } for (auto it = mp.begin(); it != mp.end(); it++){ idx++; v[idx] = (*it).second; ids[idx].clear(); int rest = 0; v[idx].push_back(0); v[idx].push_back(h); sort(v[idx].begin(), v[idx].end()); for (int i = 0; i < v[idx].size(); i++){ bool f = false; while (rest < v[idx - 1].size() && v[idx - 1][rest] <= v[idx][i]){ if (f == false){ ids[idx].push_back(ids[idx - 1][rest]); } f = true; rest++; } if (f == false){ ids[idx].push_back(ord); ord++; } int ID = ids[idx][i]; long long int las_x = 0; if (las[ID].size()){ las_x = las[ID][0].first; } else{ las[ID].push_back(make_pair(0, v[idx][i])); } las[ID].push_back(make_pair((*it).first,v[idx][i]) ); } for (int i = 0; i+1 < ids[idx].size(); i++){ int now_id = ids[idx][i]; int nex_id = ids[idx][i + 1]; while (las[nex_id].front().second <= las[now_id].back().second){ las[nex_id].pop_front(); } } for (int i = 0; i < v[idx].size(); i++){ } } } int main(){ cin >> h >> w; cin >> n; for (int i = 0; i < n; i++){ int x, y; scanf("%d%d", &x, &y); mp[x].push_back(y); //ids[0].push_back(y); } solve(); return 0; }
a.cc:1:1: error: 'compile' does not name a type 1 | compile error | ^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:62, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:2: /usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity 164 | __is_null_pointer(std::nullptr_t) | ^ /usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)' 159 | __is_null_pointer(_Type) | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'? 164 | __is_null_pointer(std::nullptr_t) | ^~~~~~~~~ In file included from /usr/include/c++/14/cstddef:50, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:41: /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here 443 | typedef decltype(nullptr) nullptr_t; | ^~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'? 666 | struct is_null_pointer<std::nullptr_t> | ^~~~~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here 443 | typedef decltype(nullptr) nullptr_t; | ^~~~~~~~~ /usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid 666 | struct is_null_pointer<std::nullptr_t> | ^ /usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid 670 | struct is_null_pointer<const std::nullptr_t> | ^ /usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid 674 | struct is_null_pointer<volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid 678 | struct is_null_pointer<const volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^ /usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1438 | : public integral_constant<std::size_t, 0> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid 1438 | : public integral_constant<std::size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared 1440 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope 1441 | struct rank<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid 1441 | struct rank<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared 2086 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope 2087 | struct remove_extent<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid 2087 | struct remove_extent<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared 2099 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope 2100 | struct remove_all_extents<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid 2100 | struct remove_all_extents<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared 2171 | template<std::size_t _Len> | ^~~ /usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope 2176 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared 2194 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared 2194 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope 2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^~~~ /usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid 2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^ /usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope 2202 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope 2203 | struct __attribute__((__aligned__((_Align)))) { } __align; | ^~~~~~ In file included from /usr/include/c++/14/bits/stl_tempbuf.h:59, from /usr/include/c++/14/bits/stl_algo.h:69, from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/new:131:26: error: declaration of 'operator new' as non-function 131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~~~ /usr/include/c++/14/new:131:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/new:132:41: error: attributes after parenthesized initializer ignored [-fpermissive] 132 | __attribute__((__externally_visible__)); | ^ /usr/include/c++/14/new:133:26: error: declaration of 'operator new []' as non-function 133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~~~ /usr/include/c++/14/new:133:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/new:134:41: error: attributes after parenthesized initializer ignored [-fpermissive] 134 | __attribute__((__externally_visible__)); |
s783265177
p03951
C++
#include <bits/stdc++.h> using namespace std; #define inf 1072114514 #define llinf 4154118101919364364 #define mod 1000000007 #define pi 3.1415926535897932384 int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;} int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;} //最大公約数 int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;} //最小公倍数 int nCr(int a,int b){ if (b == 0 ){ return 0;} int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;} //コンビネーション int nHr(int a,int b){return nCr(a+b-1,b);} // 重複組み合わせ int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;} //階乗 int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;} // a~bまでの階乗 int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;} //数字の各位の和 int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;} // b進数の各位の和? int sankaku(int x){return ((1+x)*x)/2;} //三角数 xまでの和 //以下long long ver long long llmax(long long a,long long b){if(a>b){return a;}return b;} long long llmin(long long a,long long b){if(a<b){return a;}return b;} long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);} long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;} long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;} long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;} long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;} long long llnCr(long long a,long long b){ if (b == 0 ){ return 0;} long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;} long long llnHr(long long a,long long b){return llnCr(a+b-1,b);} long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;} long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;} long long lldsum(long long x){long long r=0;while(x){r+=(x%10);x/=10;}return r;} long long lldsumb(long long x,long long b){long long r=0;while(x){r+=(x%b);x/=b;}return r;} long long llsankaku(long long x){return ((1+x)*x)/2;} //double double dbmax(double a,double b){if(a>b){return a;}return b;} double dbmin(double a,double b){if(a<b){return a;}return b;} double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);} typedef pair<int, int> ii; typedef long long ll; typedef vector<ll> vll; typedef pair<ll,ll> pll; #define forr(i,a,b) ; for(int i=(a); i<(b); i++) #define clean(arr,val) memset(arr,val,sizeof(arr)) #define forn(i,n) forr(i,0,n) #define PB push_back typedef vector<int> vi; typedef vector<ii> vii; typedef vector<pll> vpll; const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; bool is_prime (int x){ if (x<=1) return false ; for (int i=2 ; i*i<=x ; i++){ if (x%i==0) return false ; } return true; } string alpha = "abcdefghijklmnopqrstuvwxyz" ; string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ; bool chmin (int a,int b){ if ( a > b ){ a = b; return true ; } return false ; } bool chmax (int a,int b){ if ( a < b ){ a = b; return true ; } return false ; } #define SORT(c) sort((c).begin(),(c).end()); #define ANS(ans) cout<<(ans)<<endl; string split (string s , ll n , char x){ // n文字目は前の文字列 string a ,b,c,d; a = s; b = s; if ( x == 'f'){ return c = a.erase(n) ; }else if ( x == 'l'){ return d = b.substr(n) ; } } /*CODE START HERE*/ int main() { int n; cin >> n; string s,t; cin >> s >> t; forr(i,1,n){ string a,b a = split(s,n-i,'l'); b = split(t,i,'f'); if ( a == b){ ANS(2*n-i); return 0; } ANS(2*n); } }
a.cc: In function 'int main()': a.cc:106:7: error: expected initializer before 'a' 106 | a = split(s,n-i,'l'); | ^ a.cc:107:7: error: 'b' was not declared in this scope 107 | b = split(t,i,'f'); | ^ a.cc: In function 'std::string split(std::string, ll, char)': a.cc:97:2: warning: control reaches end of non-void function [-Wreturn-type] 97 | } | ^
s294103981
p03951
C++
#include <iostream> #include<vector> using namespace std; int main(void){ int n; cin >> n; string s,t; cin >> s; cin >> t; int res = 0; for(int i = 0;i <= n;i++){ if(s.substr(i,n - i) == t.substr(0,i))res =i; } cout << 2 * n - i << endl; }
a.cc: In function 'int main()': a.cc:14:20: error: 'i' was not declared in this scope 14 | cout << 2 * n - i << endl; | ^
s669790206
p03951
C++
#include<iostream> #include<string> using namespace std; int main(){ int n;cin>>n; string s,t; cin>>s>>t; for(int i=0;i<n;i++){ if(s.subsrt(i,n-i)==t.subsrt(0,n-i)){ cout<<i+n<<endl; return 0; } } cout<<2*n<<endl; return 0; }
a.cc: In function 'int main()': a.cc:10:10: error: 'std::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'subsrt'; did you mean 'substr'? 10 | if(s.subsrt(i,n-i)==t.subsrt(0,n-i)){ | ^~~~~~ | substr a.cc:10:27: error: 'std::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'subsrt'; did you mean 'substr'? 10 | if(s.subsrt(i,n-i)==t.subsrt(0,n-i)){ | ^~~~~~ | substr
s477470750
p03951
C
#include<bits/stdc++.h> #define all(x) x.begin(), x.end() #define pb push_back using namespace std; using ll = long long; using vi = vector<ll>; using pi = pair<ll, ll>; const int maxn = 5050, mlg = 17, mod = 1e9 + 7; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); string s, t; int main() { cin.tie(0)->sync_with_stdio(0); int n; cin >> n >> s >> t; int ans = 2*n; for(int i = 0; i <= s.size(); i++) { int ok = 1; for(int x = i, y = 0; y < t.size() && x < s.size(); x++, y++) { ok &= s[x] == t[y]; } if(ok) ans = min(ans, i+n); } cout << ans; }
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory 1 | #include<bits/stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s682836626
p03951
C++
t1 = t.substr(0, i);
a.cc:1:9: error: 't1' does not name a type 1 | t1 = t.substr(0, i); | ^~
s986289727
p03951
C++
#include <bits/stdc++.h> using namespace std; int main(){ int counter1,counter2; int N; cin>>N; counter1=0; counter2=0; int answer=0; int counter=0; int i=0; string S,T; cin>>S>>T; while(counter1<N){ if(S.at(i)==T.at(counter2)){ answer++; counter2++; i++;} else { counter=max(answer,counter); answer=0; counter2=0; i=0; counter1++; continue;}} cout<<2*N-counter<<endl;}}
a.cc:25:26: error: expected declaration before '}' token 25 | cout<<2*N-counter<<endl;}} | ^
s831967806
p03951
C++
#include <bits/stdc++.h> using namespace std; int main(){ int counter1,counter2; int N; cin>>N; counter1=0; counter2=0; int answer=0; int counter=0; string S,T; cin>>S>>T; while(counter1<N){ if(S.at(i)==T.at(counter2)){ answer++; counter2++;} else { counter=max(answer,counter); answer=0; counter2=0;counter1++; continue;}} cout<<2*N-counter<<endl;}}
a.cc: In function 'int main()': a.cc:13:9: error: 'i' was not declared in this scope 13 | if(S.at(i)==T.at(counter2)){ | ^ a.cc: At global scope: a.cc:21:26: error: expected declaration before '}' token 21 | cout<<2*N-counter<<endl;}} | ^
s695133119
p03951
C++
#include<bits/stdc++.h> using namespace std; int main(){ int N; string S,T; cin>>N>>S>>T; int kasanari=0; for(int i=0;i<N;i++){ bool flag=true; for(int j=i;j<N;j++){ if(S.at(j)!=T.at(j-i)){ flag=false; } } if(flag){ count=i; break; } if(i==N-1){ count=N; } } cout<<N+count<<endl; }
a.cc: In function 'int main()': a.cc:16:13: error: overloaded function with no contextual type information 16 | count=i; | ^ a.cc:20:13: error: overloaded function with no contextual type information 20 | count=N; | ^ a.cc:23:10: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator+' 23 | cout<<N+count<<endl; | ~^~~~~~
s455502261
p03951
C++
#include <iostream> using namespace std; int main(){ string s, t; cin >> s; cin >> t; bool exist = false; string a = " "; for(int i=0;i<s.size();i++){ if(s[i] == t[0]){ for(int j = i+1 ;j<s.size();j++){ if(s[j] != t[j-i]){ break; } exist = true; } } if(exist) { for(int j=0;j<=i;j++){ a += s[i]; } } } if(exist){ a += t; cout << a << endl; } else{ s += t; cout << s << endl; }
a.cc: In function 'int main()': a.cc:46:4: error: expected '}' at end of input 46 | } | ^ a.cc:5:11: note: to match this '{' 5 | int main(){ | ^
s012618298
p03951
C++
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; string s,t; cin >> s >> t; for(int i=0;i<=n;i++){ if(s.substr(i,s.size())==t.substr(0,t.size()-i){ cout << n+i; return 0; } } }
a.cc: In function 'int main()': a.cc:9:52: error: expected ')' before '{' token 9 | if(s.substr(i,s.size())==t.substr(0,t.size()-i){ | ~ ^ | ) a.cc:13:3: error: expected primary-expression before '}' token 13 | } | ^
s328092089
p03951
C++
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; string s,t; cin >> s >> t; for(int i=0;i<=n;i++){ if(s.substr(i,s.size())==t.substr(0,t.stze()-i){ cout << n+i; return 0; } } }
a.cc: In function 'int main()': a.cc:9:43: error: 'std::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'stze'; did you mean 'size'? 9 | if(s.substr(i,s.size())==t.substr(0,t.stze()-i){ | ^~~~ | size a.cc:9:52: error: expected ')' before '{' token 9 | if(s.substr(i,s.size())==t.substr(0,t.stze()-i){ | ~ ^ | ) a.cc:13:3: error: expected primary-expression before '}' token 13 | } | ^
s654340740
p03951
C++
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; string s,t; cin >> s >> t; for(int i=0;i<=n;i++){ if(s.substr(i,s.size())==t.substr(0,t.stze-i){ cout << n+i; return 0; } } }
a.cc: In function 'int main()': a.cc:9:43: error: 'std::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'stze'; did you mean 'size'? 9 | if(s.substr(i,s.size())==t.substr(0,t.stze-i){ | ^~~~ | size a.cc:9:50: error: expected ')' before '{' token 9 | if(s.substr(i,s.size())==t.substr(0,t.stze-i){ | ~ ^ | ) a.cc:13:3: error: expected primary-expression before '}' token 13 | } | ^
s720123537
p03951
C++
//#define _GLIBCXX_DEBUG #include <bits/stdc++.h> #include <algorithm> #define rep(i,n) for(int i=0;i<(n);++i) #define all(a) (a).begin(),(a).end() using namespace std; using Graph = vector<vector<int>>; typedef long long ll; const int mod= 1e+9+7; int main(){ int n; cin>>n; string s,t; cin>>s>>t; int ans=n*2; int cnt; rep(i,n){ if(s.sunstr(i,n-i)==t.substr(0,n-i)){ cnt=n; } } cout<<ans-cnt<<endl; }
a.cc: In function 'int main()': a.cc:17:14: error: 'std::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'sunstr'; did you mean 'substr'? 17 | if(s.sunstr(i,n-i)==t.substr(0,n-i)){ | ^~~~~~ | substr
s050528192
p03951
C++
#include<iostream> #include<stdio.h> #include<vector> #include<algorithm> #include<set> #include<string> #include<map> #include<string.h> #include<complex> #include<math.h> #include<queue> #include <functional> #include<time.h> #include <stack> #include<iomanip> using namespace std; #define rep(i,a,n) for(int i=(a);i<(n);i++) #define ll long long #define llint long long int #define reverse(v) reverse(v.begin(), v.end()); #define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl; #define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl; #define hei(a) vector<a> #define whei(a) vector<vector<a>> #define UF UnionFind #define rt (a); return (a); #define Pint pair<int,int> #define keta(a) fixed << setprecision(a) constexpr auto INF = 1000000000; constexpr auto mod = 1000000007; //辞書順はnext_permutation( begin( v ), end( v ) );やで! llint gcd(llint a, llint b) { if (b > a)swap(a, b); if (a % b == 0)return b; return gcd(b, a % b); } llint Tow(int n) {//2のn乗 if (n == 0)return 1; llint x = Tow(n / 2); x %= mod; x *= x; x %= mod; if (n % 2 == 1)x *= 10; x %= mod; return x; } int main(){ int n; string s,t ; cin >> n >> s >> t; int x = n; rep(i, 0, n) { if (s.substr(i, n - i) == t.substr(0, n - i))x = i; } cout << x + n << end; return 0; }
a.cc: In function 'int main()': a.cc:56:23: error: no match for 'operator<<' (operand types are 'std::basic_ostream<char>' and '<unresolved overloaded function type>') 56 | cout << x + n << end; | ~~~~~~~~~~~~~~^~~~~~ In file included from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/ostream:116:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ostream_type& (*)(__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 116 | operator<<(__ostream_type& (*__pf)(__ostream_type&)) | ^~~~~~~~ /usr/include/c++/14/ostream:116:36: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)' {aka 'std::basic_ostream<char>& (*)(std::basic_ostream<char>&)'} 116 | operator<<(__ostream_type& (*__pf)(__ostream_type&)) | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:125:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; __ios_type = std::basic_ios<char>]' 125 | operator<<(__ios_type& (*__pf)(__ios_type&)) | ^~~~~~~~ /usr/include/c++/14/ostream:125:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'} 125 | operator<<(__ios_type& (*__pf)(__ios_type&)) | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:135:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 135 | operator<<(ios_base& (*__pf) (ios_base&)) | ^~~~~~~~ /usr/include/c++/14/ostream:135:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::ios_base& (*)(std::ios_base&)' 135 | operator<<(ios_base& (*__pf) (ios_base&)) | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:174:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 174 | operator<<(long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:174:23: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long int' 174 | operator<<(long __n) | ~~~~~^~~ /usr/include/c++/14/ostream:178:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 178 | operator<<(unsigned long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:178:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long unsigned int' 178 | operator<<(unsigned long __n) | ~~~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:182:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 182 | operator<<(bool __n) | ^~~~~~~~ /usr/include/c++/14/ostream:182:23: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'bool' 182 | operator<<(bool __n) | ~~~~~^~~ In file included from /usr/include/c++/14/ostream:1022: /usr/include/c++/14/bits/ostream.tcc:96:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]' 96 | basic_ostream<_CharT, _Traits>:: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/ostream.tcc:97:22: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short int' 97 | operator<<(short __n) | ~~~~~~^~~ /usr/include/c++/14/ostream:189:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 189 | operator<<(unsigned short __n) | ^~~~~~~~ /usr/include/c++/14/ostream:189:33: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short unsigned int' 189 | operator<<(unsigned short __n) | ~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/ostream.tcc:110:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]' 110 | basic_ostream<_CharT, _Traits>:: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/ostream.tcc:111:20: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'int' 111 | operator<<(int __n) | ~~~~^~~ /usr/include/c++/14/ostream:200:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 200 | operator<<(unsigned int __n) | ^~~~~~~~ /usr/include/c++/14/ostream:200:31: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'unsigned int' 200 | operator<<(unsigned int __n) | ~~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:211:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 211 | operator<<(long long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:211:28: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long int' 211 | operator<<(long long __n) | ~~~~~~~~~~^~~ /usr/include/c++/14/ostream:215:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 215 | operator<<(unsigned long long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:215:37: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long unsigned int' 215 | operator<<(unsigned long long __n) | ~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:231:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 231 | operator<<(double __f) | ^~~~~~~~ /usr/include/c++/14/ostream:231:25: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'double' 231 | operator<<(double __f) | ~~~~~~~^~~ /usr/include/c++/14/ostream:235:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 235 | operator<<(float __f) | ^~~~~~~~ /usr/include/c++/14/ostream:235:24: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'float' 235 | operator<<(float __f) | ~~~~~~^~~ /usr/include/c++/14/ostream:243:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 243 | operator<<(long double __f) | ^~~~~~~~ /usr/include/c++/14/ostream:243:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long double' 243 | operator<<(long double __f) | ~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:301:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 301 | operator<<(const void* __p) | ^~~~~~~~ /usr/include/c++/14/ostream:301:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const void*' 301 | operator<<(const void* __p) | ~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:306:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::nullptr_t) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; std::nullptr_t = std::nullptr_t]' 306 | operator<<(nullptr_t) | ^~~~~~~~ /usr/include/c++/14/ostream:306:18: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::nullptr_t' 306 | operator<<(nullptr_t)
s724282728
p03951
C++
const int INF = 1e9; const int MOD = 1e9+7; const ll LINF = 1e18; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) for(int i=0;i<(n);++i) #define REPR(i,n) for(int i=n;i>=0;i--) #define ALL(v) (v.begin(),v.end()) #define COUT(x) cout<<(x)<<'\n' int main(){ int n; cin >> n; string s,t; cin >> s >> t; int count = 0; if(s==t)COUT(n); else{ REP(i,n){ if(t[i]==s[n-i-1])count++; } COUT(2*n-count); } return 0; }
a.cc:3:7: error: 'll' does not name a type 3 | const ll LINF = 1e18; | ^~ a.cc: In function 'int main()': a.cc:13:5: error: 'cin' was not declared in this scope 13 | cin >> n; | ^~~ a.cc:14:5: error: 'string' was not declared in this scope 14 | string s,t; | ^~~~~~ a.cc:15:12: error: 's' was not declared in this scope 15 | cin >> s >> t; | ^ a.cc:15:17: error: 't' was not declared in this scope 15 | cin >> s >> t; | ^ a.cc:9:17: error: 'cout' was not declared in this scope; did you mean 'count'? 9 | #define COUT(x) cout<<(x)<<'\n' | ^~~~ a.cc:17:13: note: in expansion of macro 'COUT' 17 | if(s==t)COUT(n); | ^~~~ a.cc:9:17: error: 'cout' was not declared in this scope; did you mean 'count'? 9 | #define COUT(x) cout<<(x)<<'\n' | ^~~~ a.cc:22:9: note: in expansion of macro 'COUT' 22 | COUT(2*n-count); | ^~~~
s715326205
p03951
C++
N = int(input()) s = input() t = input() if s == t: print(N) exit(0) tr = t[::-1] match = 0 for i in reversed(range(0, N)): if s[i] == tr[i]: match += 1 else: break print(N*2-match)
a.cc:1:1: error: 'N' does not name a type 1 | N = int(input()) | ^
s853501503
p03951
C++
#include <iostream> #include <vector> #include <algorithm> #include <numeric> #include <functional> #include <queue> #include <stack> #include <bitset> #include <set> #include <chrono> #include <string> using namespace std; #define endl '\n' int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; string a, b; cin >> a >> b; for (int i = n; i >= 0; --i) { bool ok = true; for (int j = 0; j < i && ok; ++j) { if (b[j] != a[n - i + j]) ok = false; } if (ok) { cout << 2 * n - i << endl; return 0; } } assert(false); return 0; }
a.cc: In function 'int main()': a.cc:44:5: error: 'assert' was not declared in this scope 44 | assert(false); | ^~~~~~ a.cc:11:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>' 10 | #include <chrono> +++ |+#include <cassert> 11 | #include <string>
s805047133
p03951
C++
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; string s,t; cin >> s >> t; int count=0; for(int i=1;i<=n;i++){ if(s.substr(n-i,i)==t.substr(0.i)) count=i; } cout << n+n-count << endl; }
a.cc: In function 'int main()': a.cc:11:38: error: cannot convert 'std::complex<double>' to 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} 11 | if(s.substr(n-i,i)==t.substr(0.i)) count=i; | ^~~ | | | std::complex<double> In file included 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, from a.cc:1: /usr/include/c++/14/bits/basic_string.h:3208:24: note: initializing argument 1 of 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::substr(size_type, size_type) const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' 3208 | substr(size_type __pos = 0, size_type __n = npos) const | ~~~~~~~~~~^~~~~~~~~
s488176300
p03951
C++
#include <iostream> #include <algorithm> #include <cstdio> #include <vector> #include <math.h> #include <iomanip> #include <bitset> #include <string> #include <cstring> #include <stdlib.h> #include <utility> #include <set> using namespace std; typedef long long int ll; typedef long double ld; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const long long INF = 1LL << 60; typedef pair<ll,ll> pairs; vector<pairs> p; bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){ return firstElof.first < secondElof.first; } #define MAX_N 1000100 bool x[MAX_N]; ll num[MAX_N]; ll fibl[MAX_N]={0}; ll fib(ll a){ if (fibl[a]!=0)return fibl[a]; if (a==0){ return 0; }else if (a==1){ return 1; } return fibl[a]=fib(a-1)+fib(a-2); } ll eratosthenes(ll n) { int p = 0; for (ll i=0; i<=n; ++i) x[i] = true; x[0] = x[1] = false; for(int i=2; i<=n; ++i) { if(x[i]) { p++; for(int j=2*i; j<=n; j+=i) x[j] = false; } num[i] = p; } return p; } ll gcd(ll a,ll b){ if (a%b==0)return(b); else return(gcd(b,a%b)); } ll keta(ll N){ int tmp{}; while( N > 0 ){ tmp += ( N % 10 ); N /= 10; } N = tmp; return N; } int main(){ ll n; cin >> n; string s,t; cin >> s >> t; ll ans=2*n; for (ll i=0;i<n;i++){ ans=2*n; for (ll j=i;j<n;j++){ if (s[j]==t[j-i]){ ans--; }else{ break; } if(j==n-1){ cout << ans << endl return 0; } } } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:85:36: error: expected ';' before 'return' 85 | cout << ans << endl | ^ | ; 86 | return 0; | ~~~~~~
s293842842
p03951
C++
#include <iostream> #include <algorithm> #include <cstdio> #include <vector> #include <math.h> #include <iomanip> #include <bitset> #include <string> #include <cstring> #include <stdlib.h> #include <utility> #include <set> using namespace std; typedef long long int ll; typedef long double ld; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const long long INF = 1LL << 60; typedef pair<ll,ll> pairs; vector<pairs> p; bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){ return firstElof.first < secondElof.first; } #define MAX_N 1000100 bool x[MAX_N]; ll num[MAX_N]; ll fibl[MAX_N]={0}; ll fib(ll a){ if (fibl[a]!=0)return fibl[a]; if (a==0){ return 0; }else if (a==1){ return 1; } return fibl[a]=fib(a-1)+fib(a-2); } ll eratosthenes(ll n) { int p = 0; for (ll i=0; i<=n; ++i) x[i] = true; x[0] = x[1] = false; for(int i=2; i<=n; ++i) { if(x[i]) { p++; for(int j=2*i; j<=n; j+=i) x[j] = false; } num[i] = p; } return p; } ll gcd(ll a,ll b){ if (a%b==0)return(b); else return(gcd(b,a%b)); } ll keta(ll N){ int tmp{}; while( N > 0 ){ tmp += ( N % 10 ); N /= 10; } N = tmp; return N; } int main(){ ll n; cin >> n; string s,t; cin >> s >> t; ll ans=2*n; for (ll i=0;i<n;i++){ ans=2*n; for (ll j=i;j<n;j++){ if (s[j]==t[j-i]){ ans--; }else{ break; } if(j==n-1)cout << ans << endl{ return 0; } } } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:84:42: error: expected ';' before '{' token 84 | if(j==n-1)cout << ans << endl{ | ^ | ;
s050383243
p03951
C++
// 006 AGC A - Prefix and Suffix 2016/10/29 #include <bits/stdc++.h> #define rep(i ,n) for(int i=0;i<(int)(n);++i) using namespace std; typedef long long int int64; typedef unsigned long long uint64; int main(int argc , char* argv[]){ int n; cin >> n; string s , t; cin >> s >> t; rep(i ,n){ string s1=s.substr(i,n-i); string t1=t.substr(0,n-i); if (s1==t1 && s!==t) { cout << 2*n - i << endl; return 0;} } if(s == t) cout << n << endl; }
a.cc: In function 'int main(int, char**)': a.cc:18:30: error: expected primary-expression before '=' token 18 | if (s1==t1 && s!==t) { cout << 2*n - i << endl; return 0;} | ^
s214826352
p03951
C++
#include <bits/stdc++.h> #include <math.h> #define rep(i, n) for(int i = 0; i < n; ++i) using namespace std; int main() { int n, s; string s, t; cin >> n >> s >> t; rep(i, n){ bool b = 1; rep(j, n-i){ if(s[j] != t[i+j]){ b = 0; break; } } if(b){ s = n + i; break; } } cout << s << endl; return 0; }
a.cc: In function 'int main()': a.cc:8:10: error: conflicting declaration 'std::string s' 8 | string s, t; | ^ a.cc:7:10: note: previous declaration as 'int s' 7 | int n, s; | ^ a.cc:13:11: error: invalid types 'int[int]' for array subscript 13 | if(s[j] != t[i+j]){ | ^
s277787148
p03951
C++
# coding:utf-8 N = int(input()) S = input() T = input() ans = 0 for n in range(1,N+1): #print (S[-n:],T[:n]) if (S[-n:]==T[:n]): ans = n print (2*N-ans)
a.cc:1:3: error: invalid preprocessing directive #coding 1 | # coding:utf-8 | ^~~~~~ a.cc:7:6: error: invalid preprocessing directive #print 7 | #print (S[-n:],T[:n]) | ^~~~~ a.cc:2:1: error: 'N' does not name a type 2 | N = int(input()) | ^