# Codeforces Round #427 (Div. 2)

/Tag: Codeforces Round #427 (Div. 2)

## Codeforces Round #427 (Div. 2), problem: (F) Roads in the Kingdom Solution In C/C++

By |2017-08-05T21:46:16+06:00August 5th, 2017|Categories: C/C++, Programming||

#include <bits/stdc++.h> using namespace std; int n; int to[500000], pre[500000], cost[500000], last[250000], en; long long wxs; void addedge(int f, int t, int w) { to[++en] = t; cost[en] = w; pre[en] = last[f]; last[f] = en; } int Stack[250000], vis[250000], top; int ring[250000], rs; [...]

## Codeforces Round #427 (Div. 2), problem: (E) The penguin’s game Solution In C/C++

By |2017-08-05T21:44:16+06:00August 5th, 2017|Categories: C/C++, Programming||

#include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int N=1010; int n,x,y,bit,ans; int cnta,cntb; int a[N],b[N]; int ans1,ans2; int gao(int *a,int l,int r){ if (r-l+1==0) return 0; printf("? %d ",r-l+1); for (int i=l;i<=r;i++) printf("%d ",a[i]); printf("\n"); fflush(stdout); int res; scanf("%d",&res); return res; } int find(int [...]

## Codeforces Round #427 (Div. 2), problem: (D) Palindromic characteristics Solution In C/C++

By |2017-08-05T21:42:19+06:00August 5th, 2017|Categories: C/C++, Programming||

#include <stdio.h> #include <string.h> #define N 5000 int main() { static char cc[N]; static int dp[N][N], kk[N + 1]; int n, i, j; scanf("%s", cc); n = strlen(cc); for (i = 0; i < n; i++) { dp[i][i] = 1; if (i + 1 [...]

## Codeforces Round #427 (Div. 2), problem: (C) Star sky Solution In C/C++

By |2017-08-05T21:40:34+06:00August 5th, 2017|Categories: C/C++, Programming||

#include<iostream> #include<cstdio> using namespace std; int a[201][201][21]; int x,y,x1,y1,s; int main() { int n,q,c; int i,j,k; scanf("%d%d%d",&n,&q,&c); for(i=1;i<=n;i++) { scanf("%d%d%d",&x,&y,&s); for(j=0;j<=c;j++) a[x][y][j]+=(s+j)%(c+1); } for(i=1;i<=100;i++) for(j=1;j<=100;j++) for(k=0;k<=c;k++) a[i][j][k]+=a[i][j-1][k]+a[i-1][j][k]-a[i-1][j-1][k]; for(i=1;i<=q;i++) { scanf("%d%d%d%d%d",&s,&x,&y,&x1,&y1); s%=(c+1); printf("%d\n",a[x1][y1][s]-a[x-1][y1][s]-a[x1][y-1][s]+a[x-1][y-1][s]); } }

## Codeforces Round #427 (Div. 2), problem: (B) The number on the board Solution In C/C++

By |2017-08-05T21:39:07+06:00August 5th, 2017|Categories: C/C++, Programming||

#include <stdio.h> int k, c, d[10], ans; main() { scanf("%d", &k); getchar(); while ((c = getchar() - '0') >= 0) d[c]++, k -= c; for(c = 0; k > 0; d[c] ? d[c]-- : c++) if(d[c]) ans++, k -= 9 - c; printf("%d\n", ans); [...]

## Codeforces Round #427 (Div. 2), problem: (A) Key races Solution in C/C++

By |2017-08-05T21:37:32+06:00August 5th, 2017|Categories: C/C++, Programming||

#include <cstdio> int s,t1,t2,v1,v2; int main() { scanf("%d%d%d%d%d",&s,&v1,&v2,&t1,&t2); t1=2*t1+s*v1; t2=2*t2+s*v2; puts((t1==t2)?"Friendship":(t1<t2)?"First":"Second"); }