text
stringlengths
49
983k
#include<bits/stdc++.h> using namespace std; int n,ti,a,b; int main() { cin>>n; for(int i=0;i<n;i++) { cin>>ti>>a>>b; if(!(a+b<=ti&&(ti-a-b)%2==0)) { cout<<"No"<<endl; return 0; } } cout<<"Yes"<<endl; return 0; }
#include<iostream> #include<algorithm> using namespace std; int main() { int n,t,tb=0,x,xb=0,y,yb=0,tt,i; cin >> n; for(i=0;i<n;i++){ cin >> t >> x >> y; tt=t-tb-abs(x-xb)-abs(y-yb); if(tt<0||tt%2==1){ cout << "No" << endl; return 0; } tb=t; xb=x; yb=y; } cout << "Yes" << endl; return 0; }
#include<iostream> #include<cstdio> using namespace std; int n,t,a,b,f=1; int jl(int x,int y) { return x+y; } int main() { cin>>n; while(n--) { cin>>t>>a>>b; if(t<jl(a,b)) f=0; if(((a+b)%2==1&&t%2==0)||(a+b)%2==0&&t%2==1) f=0; } if(!f) cout<<"No"<<'\n'; else cout<<"Yes"<<'\n'; return 0; }
#include<bits/stdc++.h> using namespace std; int n,t,x,y; int main() { ios::sync_with_stdio(false); cin >> n; while(n--) { cin >> t >> x >> y; if(x + y > t || t - x - y & 1) { cout << "No\n"; return 0; } } cout << "Yes\n"; return 0; }
#include<stdio.h> #include<iostream> using namespace std; int main() { int n; int flag = 0; cin>>n; int t1=0,x1=0,y1=0; while(n--) { int t,x,y; cin>>t>>x>>y; if((t-t1-x+x1-y+y1)>=0 && (t-t1-x+x1-y+y1)%2 == 0) continue; else flag = 1; t1 = t; x1 = x; y1 = y; } if(flag == 1) cout<<"No"; else cout<<"Yes"; }
#include<iostream> using namespace std; int a[100000][4]; int main(){ int f=1,i,j,n; cin>>n; for(i=1;i<=n;i++) { cin>>a[i][1]>>a[i][2]>>a[i][3]; if((a[i][2]+a[i][3]>a[i][1])||a[i][1]%2!=(a[i][2]+a[i][3])%2) f=0; } if(f==1) cout<<"Yes"<<endl; else cout<<"No"<<endl; }
#include <iostream> int main(){ int N; int pt=0,px=0,py=0; std::cin>>N; for(int i=0;i<N;++i){ int t,x,y; std::cin>>t>>x>>y; if((t-pt)-(x-px)-(y-py) < 0 || ((t-pt)-(x-px)-(y-py))%2 == 1){ std::cout<<"No"; return 0; } } std::cout<<"Yes"; return 0; }
#include<stdio.h> #include<math.h> int main() { int n,m,t,a,x,y,a0=0,x0=0,y0=0,s,k=0; scanf("%d",&t); while(t--) { scanf("%d%d%d",&a,&x,&y); s=fabs(x-x0)+fabs(y-y0); x0=x,y0=y; if(!(s<=a-a0&&(a-a0-s)%2==0)) { k=1; } a0=a; } if(k)puts("No"); else puts("Yes"); }
#include <iostream> using namespace std; int a[100000][3]; int main() { int f=1,i,j,n; cin>>n; for(i=0;i<=n;i++) { cin>>a[i][0]>>a[i][1]>>a[i][2]; if(a[i][2]+a[i][1]>a[i][0]||a[i][0]%2!=(a[i][1]+a[i][2])%2) f=0; } if(f==1) cout<<"Yes"<<endl; else cout<<"No"<<endl; return 0; }
#include<bits/stdc++.h> using namespace std; int n,t,x,y; int main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>t>>x>>y; if((x+y<=t&&(t-x-y)%2==0)==0){ cout<<"No"; return 0; } } cout<<"Yes"; return 0; }
#include <iostream> #include <algorithm> int main() { int n,t,x,y,d,pt=0,px=0,py=0; bool a=true; std::cin >> n; while(std::cin>>t>>x>>y) { d = abs(x-px) + abs(y-py); if(t-pt<d||(t-pt-d)%2) {a=false;break;} pt = t; px = x; py = y; } std::cout << (a?"Yes":"No") << "\n"; }
#include <iostream> #include <cstring> using namespace std; int main() { int n; cin >> n; for(int i=0;i<n;i++) { int t,a,b; cin >> t >> a >> b; if(a+b>t||(a+b)%2!=t%2) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; return 0; }
#include<stdio.h> #include<math.h> int main() { int n; int t,x,y; bool flag=true; scanf("%d",&n); for(int i=0;i<n;i++) { scanf("%d%d%d",&t,&x,&y); if(x+y<=t&&(t-(x+y))%2==0); else { flag=false; } } if(flag==true) printf("Yes\n"); else printf("No\n"); return 0; }
// luogu-judger-enable-o2 #include<bits/stdc++.h> using namespace std; int main(){ int n,t,x,y; cin>>n; for(int i=0;i<n;i++){ cin>>t>>x>>y; if(!(x+y<=t&&(t-x-y)%2==0)){ cout<<"No"<<endl; return 0; } } cout<<"Yes"<<endl; return 0; }
#include"bits/stdc++.h" using namespace std; int n,x[111111],y[111111],t[111111]; int main() { scanf("%d",&n); for(int i=1; i<=n; i++) scanf("%d%d%d",&t[i],&x[i],&y[i]); for(int i=1; i<=n; i++) if(x[i]+y[i]>t[i]||(t[i]-x[i]-y[i])%2!=0) { printf("No"); return 0; } printf("Yes"); return 0; }
#include<iostream> #include<cmath> using namespace std; int main() { int n; cin>>n; while(n--) { int t,a,b; cin>>t>>a>>b; if(abs(a)+abs(b)>t||((int)(abs(a)+abs(b))%2)^(t%2)) { cout<<"No"<<endl; return 0; } } cout<<"Yes"<<endl; return 0; }
#include<bits/stdc++.h> using namespace std; int main(){cin.tie(0);ios::sync_with_stdio(false);int n;cin>>n;int t=0,x=0,y=0;bool flag=true;for(int i=0;i<n;i++){int a,b,c;cin>>a>>b>>c;int dl=abs(x-b)+abs(y-c),dt=a-t;if((dl-dt)>0 || (dl-dt)%2){flag=false;}t=a,x=b,y=c;}if(flag)cout<<"Yes"<<endl;else cout<<"No"<<endl;}
#include<bits/stdc++.h> using namespace std; int main() { int n;cin>>n; while(n--) { int t,x,y; cin>>t>>x>>y; if(t<abs(x)+abs(y)||(abs(x)+abs(y)-t)%2!=0) return puts("No"),0; } puts("Yes"); return 0; }
#include<bits/stdc++.h> using namespace std; int main(){ int n,t,x,y,i; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d%d%d",&t,&x,&y); if(x+y>t||(x+y+t)%2==1){ printf("No\n"); return 0; } } printf("Yes\n"); return 0; }
#include <iostream> using namespace std; int main() { int N; scanf("%d",&N); int n; int flag = -1; for(n = 0;n < N;n++){ int t,x,y; scanf("%d %d %d",&t,&x,&y); if( !( (0 == (t - (x + y) ) % 2) && (x + y <= t) ) ) flag = flag + 1; } if(-1 == flag) printf("Yes\n"); else printf("No\n"); return 0; }
#include<iostream> using namespace std; int main() { int a[100000][3]; int f=1,i,j,n; cin>>n; for(i=0;i<=n;i++) { cin>>a[i][0]>>a[i][1]>>a[i][2]; if(a[i][2]+a[i][1]>a[i][0]||a[i][0]%2!=(a[i][1]+a[i][2])%2) f=0; } if(f==1) cout<<"Yes"; else cout<<"No"; }
#include<cstdio> int main() { int n; scanf("%d",&n); long long x=0LL,y=0LL,z=0LL,a,b,t; for(int i=0;i<n;i++) { scanf("%lld%lld%lld",&t,&a,&b); long long len=a-x+b-y,tim=t-z; if(tim<len||(tim-len)%2) { printf("No\n"); return 0; } x=a,y=b,z=t; } printf("Yes\n"); }
#include <iostream> #include <cmath> using namespace std; int x,y,s,n,t,lx,ly,lt; int main(){ cin>>n; lx=0;ly=0; for(int i=1;i<=n;i++){ cin>>t>>x>>y; s=abs(x-lx)+(y-ly); int ss=t-lt;ss-=s; if(ss<0||ss%2==1){ cout<<"No"<<endl; return 0;} s=0;lx=x;ly=y;lt=t; } cout<<"Yes"; return 0; }
#include<iostream> #include<cmath> using namespace std; int main(){ int n,cx=0,cy=0,ct=0; cin>>n; for(int i=0;i<n;i++){ int t,x,y,v,tt; cin>>t>>x>>y; v=abs(cx-x)+abs(cy-y); tt=abs(ct-t); if(tt<v||(tt-v)%2==1){ cout<<"No"; return 0; } cx=x; cy=y; ct=t; } cout<<"Yes"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin>>n; int x=0,y=0,tp=0; while(n--) { int t,nx,ny; cin>>t>>nx>>ny; int t1=t; t=t-tp; tp=t1; int d=abs(nx-x)+abs(ny-y); x=nx,y=ny; if(d>t) { cout<<"No"; return 0; } if(d<t&&(t-d)%2==1) { cout<<"No"; return 0; } } cout<<"Yes"; return 0; }
#include<iostream> #include<cmath> using namespace std; int main() { int n; cin>>n; int t1=0,x1=0,y1=0,t2,x2,y2; for(int i=1;i<=n;i++) { cin>>t2>>x2>>y2; int t=abs(t2-t1); int x=abs(x2+y2-x1-y1); if(x>t||(x-t)%2!=0) { cout<<"No"<<endl; return 0; } t1=t2; x1=x2; y1=y2; } cout<<"Yes"<<endl; return 0; }
#include <iostream> using namespace std; int main() { int m; cin>>m; for(int i=1;i<=m;i++) { int t,x,y; cin>>t>>x>>y; if(t-x-y<0||(t-x-y)%2!=0) {cout<<"No";return 0;} } cout<<"Yes";return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main(){ int n; string ans = "Yes"; cin >> n; int t, x, y, prevt=0, pos=0; for(int i=0; i<n; i++){ cin >> t >> x >> y; t = (t - prevt) - (abs(pos-(x+y))); if(t<0 || t%2==1) ans = "No"; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { ll n,f=0; cin>>n; for(ll i=1;i<=n;i++) { ll t,x,y,z; cin>>t>>x>>y; z=x+y; if(!(t%2==z%2&&t>=z)) { f=1; } } if(f) { cout<<"No"<<endl; } else { cout<<"Yes"<<endl; } }
#include<bits/stdc++.h> using namespace std; int main() { int n,t,x,y; cin>>n; for(int i=0;i<n;i++) { cin>>t>>x>>y; if(!(x+y<=t&&(t-x-y)%2==0)) { cout<<"No\n"; return 0; } } cout<<"Yes\n"; return 0; }
#include<iostream> #include<cmath> using namespace std; int main() { int n; cin>>n; int t1=0,x1=0;int f=1,i,j,q=0,x[n],y[n],t[n]; for(i=0;i<n;i++) { cin>>t[i]>>x[i]>>y[i]; if(x[i]+y[i]<=t[i]&&(x[i]+y[i]-t[i])%2==0) q++; } if(q==n)cout<<"Yes"; else cout<<"No"; return 0; }
#include<bits/stdc++.h> using namespace std; int tt,tx,ty,x,y,t,f; int n; int main() { cin >> n; for(int i=0;i<n;i++) { cin >> tt >> tx >> ty; if((((tt-t)-(abs(tx-x)+abs(ty-y)))%2!=0||abs(tx-x)+abs(ty-y)>tt-t)) { cout << "No"; return 0; } t=tt,x=tx,y=ty; } cout << "Yes"; return 0; }
#include<iostream> #include<cmath> using namespace std; int main() { int n,i; cin>>n; int t[n+1],x[n+1],y[n+1]; t[0]=0;x[0]=0;y[0]=0; for(i=1;i<=n;i++) cin>>t[i]>>x[i]>>y[i]; for(i=1;i<=n;i++) if(x[i]+y[i]>t[i] || (x[i]+y[i])%2!=t[i]%2){ cout<<"No"; return 0; } cout<<"Yes"; return 0; }
#include<iostream> #include<cstdio> using namespace std; int n,a,b,c; int main() { cin>>n; while(n--) { cin>>a>>b>>c; if(a<b+c || (a&1)!=(b+c&1)) { puts("No"); return 0; } } puts("Yes"); }
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { bool can = true; int n, t, x, y; cin >> n; for (int i = 0; i < n; i++) { cin >> t >> x >> y; if (t>=x+y && (t-x-y)%2==0) continue; else can = false; } if (can) cout << "Yes" << endl; else cout << "No" << endl; }
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main() { int n; cin>>n; int flag=1; while(n--) { int t,x,y; cin>>t>>x>>y; if((x+y)==t||((t>x+y)&&(t-x-y)%2==0)) { continue; } else { flag=0; } } if(flag==1) cout<<"Yes"<<endl; else cout<<"No"<<endl; return 0; }
#include<bits/stdc++.h> using namespace std; int T,x,y,t,t1,flag,x1,y2; int main(){ scanf("%d",&T); while(T--){ scanf("%d%d%d",&t,&x,&y); if(abs(x-x1)+abs(y-y2)>(t-t1)) flag=1; if((abs(x-x1)+abs(y-y2))%2!=(t-t1)%2) flag=1; x1=x;y2=y;t1=t; } if(flag) puts("No"); else puts("Yes"); return 0; }
#include <bits/stdc++.h> using namespace std; int a=0,b=0,n,t,x,y,z,l=0; int main() { cin>>n; for(int i=1;i<=n;i++) { cin>>t>>x>>y; z=(x-a)+(y-b); if(z<=t && (t-z)%2==0) l++; } if(l==n) cout<<"Yes"; else { cout<<"No"; } return 0; }
#include<iostream> #include<cstdio> #include<algorithm> #include<cmath> #include<string> #include<cstring> using namespace std; int n,a,b,c; int main() { cin>>n; for(int i=1;i<=n;i++) { cin>>a>>b>>c; if(a<b+c||(a-b-c)%2==1){cout<<"No";return 0;} } cout<<"Yes"; return 0; }
#include<iostream> using namespace std; int main(){ int n,a; cin >> n; int t[n],x[n],y[n]; for(int i=0;i<n;i++) cin >> t[i] >> x[i] >> y[i]; for(int i=0;i<n;i++) { a=t[i]-x[i]-y[i]; if(a<0 or a%2!=0) { cout << "No"; return 0; }} cout << "Yes"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, q = 0; cin >> n; int x[n], y[n], t[n]; for ( int i = 0; i < n; i++ ) { cin >> t[i] >> x[i] >> y[i]; if ( x[i] + y[i] <= t[i] && ( x[i] + y[i] - t[i] ) % 2 == 0 ) q++; } if ( q == n ) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
#include<bits/stdc++.h> using namespace std; int main() { int n; while(~scanf("%d",&n)) { int flag=0; while(n--) { int t,x,y; scanf("%d%d%d",&t,&x,&y); if((t-(x+y))%2!=0||t<(x+y)) { flag=1; } } if(flag) { printf("No\n"); }else { printf("Yes\n"); } } }
#include<bits/stdc++.h> using namespace std; int n,t,x,y; int main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>t>>x>>y; if(!(x+y<=t&&(t-x-y)%2==0)){ cout<<"No\n"; return 0; } } cout<<"Yes\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int main(){ int N,T,X,Y,t=0,x=0,y=0,i;cin>>N; for(i=0;i<N;i++){ cin>>T>>X>>Y; if(abs(X-x)+abs(Y-y)>T-t||(T+X+Y-t-x-y)%2==1)break; t=T,x=X,y=Y; } if(i==N)cout<<"Yes"<<endl; else cout<<"No"<<endl; }
#include<cstdio> using namespace std; int main(){ int a,b,c,d,e; scanf("%d",&a); for(b=1;b<=a;b++){ scanf("%d%d%d",&c,&d,&e); if(c%2^(d+e)%2||c<d+e){ printf("No"); return 0; } } printf("Yes"); return 0; }
#include <cstdio> #include <algorithm> using namespace std; int n; int main() { scanf("%d",&n); int t,x,y; bool tmp=1; for(int i=1;i<=n;i++) { scanf("%d%d%d",&t,&x,&y); if(t<x+y||(t-x-y)%2!=0) { tmp=0; break; } } if(tmp) printf("Yes"); else printf("No"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin>>n; int a=0, b=0, p=0; for(int t, x, y; cin>>t>>x>>y; a=x, b=y, p=t) { int w=abs(a-x)+abs(b-y); int u=t-p; if (w>u or w%2!=u%2) return !printf("No\n"); } puts("Yes"); }
#include<iostream> #include<cmath> using namespace std; int main() { int flag=1; int n,t=0,x=0,y=0,tt,tx,ty; cin>>n; for(int i=1;i<=n;i++) { cin>>tt>>tx>>ty; if((abs(tx-x)+abs(ty-y))%2!=(tt-t)%2||abs(tx-x)+abs(ty-y)>(tt-t))flag=0; t=tt;x=tx;y=ty; } if(flag)cout<<"Yes"; else cout<<"No"; return 0; }
#include<bits/stdc++.h> using namespace std; int n; int x,y,t; int main() { cin>>n; int px=0,py=0,pt=0; bool f=1; while(n--) { cin>>t>>x>>y; int d=abs(px-x)+abs(py-y); if(d>t-pt||d%2!=(t-pt)%2) f=0; px=x; py=y; pt=t; } cout<<(f?"Yes":"No")<<endl; }
#include<bits/stdc++.h> using namespace std; int main() { int n,x[100001],y[100001],a[100001]; cin>>n; for(int i=1; i<=n; i++) cin>>a[i]>>x[i]>>y[i]; for(int i=1; i<=n; i++) if(x[i]+y[i]>a[i]||(a[i]-x[i]-y[i])%2!=0) { cout<<"No"; goto no; } cout<<"Yes"; no: return 0; }
#include<iostream> const int N=100001; using namespace std; int main(){ int n,x[N],y[N],t[N]; cin>>n; for(int i=1;i<=n;i++) cin>>t[i]>>x[i]>>y[i]; for(int i=1;i<=n;i++) if(x[i]+y[i]>t[i]||(t[i]-x[i]-y[i])%2!=0){cout<<"No"; return 0;} cout<<"Yes"; }
#include<iostream> #include<vector> using namespace std; int main(){ int n; cin>>n; vector<int> t(n),x(n),y(n); for(int i=0;i<n;i++){ cin>>t[i]>>x[i]>>y[i]; int g=x[i]+y[i]-t[i]; if(g%2!=0||x[i]+y[i]>t[i]){ cout<<"No"<<endl; exit(0); } } cout<<"Yes"<<endl; }
#include<bits/stdc++.h> using namespace std; int main(){ int N, t0 = 0, x0 = 0, y0 = 0, t1, x1, y1; cin >> N; for(int i=0;i<N;i++){ cin >> t1 >> x1 >> y1; int k = (t1 - t0) - ((x1 - x0) + (y1 - y0)); if(k<0 || k%2){ cout << "No\n"; return 0; } t0 = t1; x0 = x1; y0 = y1; } cout << "Yes\n"; return 0; }
#include <iostream> using namespace std; int a[100000][3]; int main() { int f=1, i, j, n; cin >> n; for(i=0; i<n; i++) { cin >> a[i][0] >> a[i][1] >> a[i][2]; if((a[i][2]+a[i][1]>a[i][0])||a[i][0]%2!=(a[i][1]+a[i][2])%2) f=0; } if(f==1) cout<<"Yes"; else cout<<"No"; return 0; }
#include<bits/stdc++.h> #define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++) using namespace std; int main(){ int n;cin>>n; int t,x,y,T=0,X=0,Y=0; string ans="Yes"; rep(i,n){ cin>>t>>x>>y; T=t-T; X=abs(X-x); Y=abs(Y-y); if(X+Y>T||((X+Y)%2!=T%2))ans="No"; } cout<<ans; }
#include <cstdio> using namespace std; int n, a, b, c; int main() { scanf("%d", &n); while (n --> 0) { scanf("%d%d%d", &a, &b, &c); if (a < b + c || ((a & 1) != (b + c & 1))) { puts("No"); return 0; } } puts("Yes"); }
#include <iostream> using namespace std; int main() { int N, t, x, y; cin >> N; bool valid = true; for (int i = 0; i < N; i++) { cin >> t >> x >> y; if (valid) valid &= t >= x + y && (t - x - y) % 2 == 0; } cout << (valid ? "Yes" : "No") << endl; return 0; }
#include<stdio.h> int main(void){ int x, t1, x1, x2, ans = 1; scanf("%d", &x); while(x--){ scanf("%d%d%d", &t1, &x1, &x2); if(t1 < (x1 + x2))ans = 0; int mod_t1 = t1 % 2; int mod_x = (x1 + x2) % 2; if(mod_t1 != mod_x)ans = 0; } if(ans)puts("Yes"); else puts("No"); }
#include<bits/stdc++.h> using namespace std; int n; int main() { cin >> n; int t, x, y, ans = 1; while (n--) { cin >> t >> x >> y; if (t < x + y || t % 2 != (x + y) % 2) ans = 0; } if (ans) cout << "Yes" << '\n'; else cout << "No" << '\n'; return 0; }
#include <iostream> using namespace std; int main() { int n,i; cin>>n; int t[n+1],x[n+1],y[n+1]; for (i=1;i<=n;i++) cin>>t[i]>>x[i]>>y[i]; for (i=1;i<=n;i++) if (x[i]+y[i]>t[i]||(x[i]+y[i])%2!=t[i]%2) { cout<<"No"; return 0; } cout<<"Yes"; return 0; }
#include<bits/stdc++.h> using namespace std; int main(){ int n,t,x,y,nt,nx,ny;cin>>n; bool b=true,travel; x=0,y=0;t=0; for(int i=0;i<n;i++){ cin>>nt>>nx>>ny; if(nt-t<abs(nx-x)+abs(ny-y)||(nt-t+abs(nx-x)+abs(ny-y))%2==1){b=false;break;} t=nt,x=nx,y=ny; } cout<<(b?"Yes":"No"); }
#include<iostream> #include<cmath> using namespace std; int main() { int n,a,b,c; cin>>n; for(int i=1;i<=n;i++) { scanf("%d%d%d",&a,&b,&c); if((a-b-c)%2||b+c>a) { printf("No\n"); return 0; } } printf("Yes\n"); return 0; }
#include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; while(n--) { int t,x,y; cin>>t>>x>>y; if(t<x+y || (t-x-y)%2){cout<<"No\n";return 0;} } cout<<"Yes\n"; }
#include<iostream> using namespace std; int main(){ int N; cin>>N; bool f=false; int y=0,x=0,t=0; for(int i=0;i<N;i++){ int ti,xi,yi; cin>>ti>>xi>>yi; auto d=abs(y-yi)+abs(x-xi); auto td=ti-t; f|=td<d||d-td&1; t=ti; y=yi; x=xi; } cout<<(f?"No":"Yes")<<endl; }
#include<iostream> #include<cstdio> #include<algorithm> #include<cmath> #include<string> #include<cstring> using namespace std; int n,a,b,c; int main() { cin>>n; for(int i=1;i<=n;i++) { cin>>a>>b>>c; if(a<b+c||(a-b-c)%2==1){cout<<"No\n";return 0;} } cout<<"Yes\n"; return 0; }
#include <iostream> #include <cmath> using namespace std; int n,t,x,y,dx,dy,dt; int main() { cin>>n; bool temp=true; while(n--){ cin>>t>>x>>y; int d=abs(dx-x)+abs(dy-y); if(abs(dt-t)<d||((abs(dt-t)-d)%2!=0)) temp=false; dx=x,dy=y,dt=t; } if(temp) cout<<"Yes"<<endl; else cout<<"No"<<endl; return 0; }
#include<bits/stdc++.h> #define ll long long int using namespace std; int main() { int n; int t,x,y; cin>>n; int x1=0,y1=0,t1=0; bool b=1; while(n) { cin>>t>>x>>y; if(abs(x-x1)+abs(y-y1)>t-t1||(abs(x-x1)+abs(y-y1))%2!=(t-t1)%2){b=0; } x1=x; y1=y; t1=t; n--; } if(b==0)cout<<"No\n"; else cout<<"Yes\n"; }
#include<cstdio> #include<iostream> int n,x,y,t; using namespace std; int main() { scanf("%d",&n); for(int i=1;i<=n;i++) { cin>>t>>x>>y; if(x+y>t||(t-x-y)%2!=0) { cout<<"No"; return 0; } } cout<<"Yes"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; bool f = true; for (int i = 0; i < N; i++) { int t, x, y; cin >> t >> x >> y; if (t < x + y || (x + y) % 2 != t % 2) { f = false; } } cout << (f ? "Yes" : "No") << endl; }
#include<bits/stdc++.h> using namespace std; int T,t,x,y,b,u,v,w; int main() { scanf("%d",&T); while(T--) { scanf("%d%d%d",&u,&v,&w); if(abs(v-x)+abs(w-y)>abs(u-t)||(abs(u-t)-abs(v-x)-abs(w-y))%2) b=1; t=u; x=v; y=w; } puts(b?"No":"Yes"); return 0; }
#include<iostream> #include<fstream> #include<algorithm> #include<cstdio> #include<cmath> #include<string> #include<cstring> using namespace std; long long n,sj,x,y; int main() { cin>>n; for(int i=1;i<=n;i++) { cin>>sj>>x>>y; sj-=x+y; if(sj<0||sj%2==1) { cout<<"No"; return 0; } } cout<<"Yes"; return 0; }
#include<bits/stdc++.h> using namespace std; int a[100000][3]; int main() { int f=1,i,j,n; cin>>n; for(i=0;i<n;i++) { cin>>a[i][0]>>a[i][1]>>a[i][2]; if((a[i][2]+a[i][1]>a[i][0])||a[i][0]%2!=(a[i][1]+a[i][2])%2) f=0; } if(f==1) cout<<"Yes"; else cout<<"No"; return 0; }
#include<iostream> #include<cmath> using namespace std; int main(){ int n,x,y,t,tt=0,xx=0,yy=0,f=0; cin>>n; for(int i=0;i<n;i++){ cin>>t>>x>>y; f+=t-tt<x-xx+y-yy||(t-tt-x+xx-y+yy)%2; xx=x;yy=y;tt=t; } if(f)cout<<"No"<<endl; else cout<<"Yes"<<endl; return 0; }
#include<bits/stdc++.h> using namespace std; int main(){ int a,b,c,d,e; scanf("%d",&a); for(b=1;b<=a;b++){ scanf("%d%d%d",&c,&d,&e); if(c<d+e){ printf("No"); return 0; } if(c%2!=(d+e)%2){ printf("No"); return 0; } } printf("Yes"); return 0; }
#include<iostream> using namespace std; int N, t, x, y, nx, ny; int main() { cin >> N; string ans = "Yes"; while (N--) { cin >> t >> x >> y; int dist = abs(nx - x) + abs(ny - y); if (dist > t || (dist - t) % 2) ans = "No"; } cout << ans << endl; }
#include <iostream> using namespace std; int main(){ int i,j,k,p,n,m,t=0; cin>>n; for(i=1;i<=n;i++){ cin>>m>>k>>p; if(m<k+p) t=1; else{ if((m-p-k)%2==1) t=1; } } if(t==0) cout<<"Yes"<<endl; else cout<<"No"<<endl; }
#include<bits/stdc++.h> using namespace std; int n,t,x,y; int main() { cin>>n; for(int i=1;i<=n;i++) { cin>>t>>x>>y; if(!(x+y<=t&&(t-x-y)%2==0)) { cout<<"No"<<endl; return 0; } } cout<<"Yes"<<endl; return 0; }
#include<iostream> using namespace std; int main(){ int n; cin>>n; int a,b,c; for(int i=0;i<n;i++){ cin>>a>>b>>c; if(a<b+c||((b+c)%2!=a%2)) { cout<<"No"<<endl; return 0; } } cout<<"Yes"<<endl; }
#include <bits/stdc++.h> using namespace std; int a[100000][3]; int main() { int f=1,i,j,n; cin>>n; for (i=0;i<n;i++) { cin>>a[i][0]>>a[i][1]>>a[i][2]; if ((a[i][2]+a[i][1]>a[i][0]) || a[i][0]%2!=(a[i][1]+a[i][2])%2) f=0; } if (f==1) cout<<"Yes"<<endl; else cout<<"No"<<endl; return 0; }
#include<cstdio> #include<cstring> #define maxn 200005 #define D 26 #define LL long long int n,cnt[D]; char s[maxn]; int main() { scanf("%s",s+1); n=strlen(s+1); for(int i=1;i<=n;i++) cnt[s[i]-'a']++; LL ans=1ll*n*(n-1)/2; for(int i=0;i<D;i++) ans-=1ll*cnt[i]*(cnt[i]-1)/2; printf("%lld\n",ans+1); }
#include <bits/stdc++.h> using namespace std; int main(){ string s; cin>>s; long long ans = 0; long long n = s.size(); ans = n * (n - 1) / 2 + 1; map<char,int>mp; for(int i = 0; i < n; ++i){ ans -= mp[s[i]]++; } cout<<ans<<endl; }
#include<bits/stdc++.h> using namespace std; int cnt[26]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); string s; cin>>s; long long int ans=1; for(int i=0;i<s.size();i++){ for(int j=0;j<26;j++) if((s[i]-'a')!=j) ans+=cnt[j]; cnt[s[i]-'a']++; } cout<<ans<<endl; }
#include<bits/stdc++.h> #define maxn 2000100 #define LL long long using namespace std; char str[maxn]; LL num[1000]; int main(){ cin>>str; int n=strlen(str); LL ans=1; for(int i=0;i<n;i++){ ans+=i-num[str[i]]; num[str[i]]++; } cout<<ans; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; char A[200005]; int B[555]; ll Ans = 1; int N; int main() { scanf(" %s", A); N = int(strlen(A)); for(int i = 0; i < N; i++) { B[A[i]]++; ll c = i - B[A[i]] + 1; Ans += c; } cout << Ans << endl; return 0; }
#include<bits/stdc++.h> using namespace std; string s; int n,A[26],i,j,k; long long ans; int main() { cin>>s; n=s.size(); for(i=0;i<n;i++) { A[s[i]-'a']++; } ans=1LL*n*(n-1)/2; for(i=0;i<26;i++) { if(A[i]>1) { ans-=1LL*A[i]*(A[i]-1)/2; } } cout<<ans+1<<endl; }
#include <bits/stdc++.h> using namespace std; long long c[255]; int main () { string s; cin >> s; long long n = s.size(); long long ans = n*(n+1)/2; for (int i=0; i<n; i++) c[ s[i] ]++; for (int i='a'; i<='z'; i++) ans -= c[i]*(c[i]+1)/2; ans = ans+1; cout << ans << endl; }
#include<bits/stdc++.h> using namespace std; typedef long long ll; int c[226]; int main(){ ios::sync_with_stdio(false); string s;cin >> s; for(auto cc:s) c[cc]++; ll n=s.size();ll ans=n*(n+1)/2+1; for(int i='a'; i<='z' ;i++) ans-=1LL*c[i]*(c[i]+1)/2; cout << ans << endl; }
#include <iostream> using namespace std; string s; int n; int cnt[26]; int main() { cin >> s; for(char c: s) ++cnt[c-'a']; n = s.length(); long long ans = 1LL*n*(n+1)/2LL+1LL; for(int i=0; i< 26; ++i) ans -= 1LL*cnt[i]*(cnt[i]+1)/2LL; cout << ans; return 0; }
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main(){ ios::sync_with_stdio(0); //freopen("in.txt","r",stdin); string str; while(cin>>str){ int num[27]={0}; ll ans=0; for(int i=0;i<str.size();i++){ ans+=i-num[str[i]-'a']; num[str[i]-'a']++; } cout<<ans+1<<endl; } }
#include<bits/stdc++.h> using namespace std; #define ll long long ll cnt[39]; int main(){ string s; cin>>s; ll n=s.size(); for(int i=0;i<n;i++){ cnt[s[i]-'a']++; } ll sum=0; for(int i=0;i<27;i++){ sum+=cnt[i]*(cnt[i]-1)/2; } cout<<n*(n-1)/2-sum+1<<endl; return(0); }
#include<iostream> #include<cstdio> #include<vector> using namespace std; string a; int s[26]; long long ans; int main() { cin>>a; for(int i=0;i<a.size();i++) { for(int j=0;j<26;j++) { if(a[i]-'a'==j)continue; ans+=s[j]; } s[a[i]-'a']++; } printf("%lld",ans+1); return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { string s; cin >> s; vector<ll> m(26); for (auto c : s) { m[c - 'a']++; } ll n = (s.size() - 1) * s.size() / 2 + 1; for (auto e : m) { n -= (e - 1) * e / 2; } cout << n << endl; return 0; }
#include <cstdio> typedef long long LL; const int MN = 200005, Sig = 26; char s[MN]; int buk[Sig]; LL Ans; int main() { scanf("%s", s + 1); for (int i = 1; s[i]; ++i) Ans += i - ++buk[s[i] - 'a']; printf("%lld\n", Ans + 1); return 0; }
#include<bits/stdc++.h> using namespace std; int main(){ long ans,l; string s; cin>>s; l=s.length(); ans=l*(l-1)/2; for(char c='a';c<='z';++c){ long k=count(s.begin(),s.end(),c); ans-=k*(k-1)/2; } cout<<++ans; return 0; }
#include<iostream> #include<string> using namespace std; int main(){ long long cnt=1,h[200]={}; string a; cin>>a; for(int i=0;i<a.size();i++)h[a[i]]++; for(int i=0;i<200;i++)for(int j=i+1;j<200;j++)if(i!=j)cnt+=h[i]*h[j]; cout<<cnt; return 0; }
#include<iostream> #include<algorithm> using lint=int64_t; using namespace std; int main() { string A; cin >> A; lint al[26]={}; lint ans=1; for(int i=0;i<A.size();i++) { ans+=i-al[A[i]-'a']; al[A[i]-'a']++; } cout << ans << endl; return 0; }
#include <iostream> #include <algorithm> using namespace std; string s; int ct[26]; long long ans = 1; int main() { cin >> s; for (int i = 0; i < s.size(); i++) { ans += i - ct[s[i] - 'a']; ct[s[i] - 'a']++; } cout << ans << '\n'; }
#include <bits/stdc++.h> using namespace std; char s[200010]; int cnt[26]; int main() { scanf("%s", s); memset(cnt, 0, sizeof cnt); long long ans = 1; for (int i = 0; s[i]; ++i) { ans += i - cnt[s[i] - 'a']; ++cnt[s[i] - 'a']; } printf("%lld\n", ans); }
#include <stdio.h> char st[200003]; int al[26]; int main() { scanf("%s",st); int len = 0; long long int ans=0; for(;st[len];len++) { al[st[len]-'a']++; } ans = (long long int)(len)*(len-1)/2; for(int i = 0; i < 26;i++) ans -= (long long int)al[i]*(al[i]-1)/2; printf("%lld\n",ans+1); }
#include<bits/stdc++.h> using namespace std; int a[26]; int main() { string s; cin>>s; int n=s.size(),sum=n; for(int i=0;i<n;i++)a[s[i]-'a']++; long long ans=1; for(int i=0;i<n;i++) { sum--; a[s[i]-'a']--; ans+=(long long)(sum-a[s[i]-'a']); } printf("%lld\n",ans); return 0; }