Codeforces Round #419 (Div. 1), problem: (E) Karen and Neighborhood Solution In C/C++

By |2017-08-07T21:46:50+00:00August 7th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , |

#include <bits/stdc++.h> using namespace std; typedef pair<long long,long long> ii; long long n,k,i,w,res; long long m[65]; map <long long,long long> num,f,c; long long get(long long t) { if (f[t]>=0) return f[t]; f[t]=get((t-1)/2)+get(t/2); if (c[t]==1) f[t]++; return f[t]; } void cal(long long t) { if [...]

Codeforces Round #419 (Div. 1), problem: (D) Karen and Cards Solution In C/C++

By |2017-08-07T21:44:43+00:00August 7th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , , |

#include <bits/stdc++.h> #define ll long long using namespace std; const int N = 500010; ll maxn[N<<2],minn[N<<2],sum[N<<2]; int n,p,q,r,tot=1,x[N],y[N],z[N]; ll ret=0; vector<int> c[N]; void update(int a,int b,int x,int l,int r,int i) { if(a>r || l>b || minn[i]>x) return; if(a<=l && r<=b && maxn[i]<=x) { maxn[i]=minn[i]=x; [...]

Codeforces Round #419 (Div. 1), problem: (C) Karen and Supermarket Solution In C/C++

By |2017-08-07T21:43:10+00:00August 7th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , , |

#include<cstdio> #include<algorithm> #include<queue> using namespace std; const int N=5010; int n,m,c[N],d[N],fa[N]; int w[N],head[N],next[N]; void add(int f,int t){ static int cnt=0; w[++cnt]=t; next[cnt]=head[f]; head[f]=cnt; } int f[N][N],g[N][N],size[N]; //f[i][j],g[i][j]表示在子树i中买j件物品的最小代价 //其中g要求购买从根到i的物品 void dfs(int x){ for (int i=1;i<=n;i++) f[x][i]=g[x][i]=1e9+1; g[x][0]=g[x][1]=c[x]-d[x]; f[x][1]=c[x]; size[x]=1; for (int i=head[x];i;i=next[i]){ int v=w[i]; dfs(v); [...]

Codeforces Round #419 (Div. 1), problem: (B) Karen and Test Solution In C/C++

By |2017-08-07T21:37:49+00:00August 7th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , , |

#include <cstdio> #include <iostream> #include <cstring> #include <cstdlib> using namespace std; #define ll long long const int N=200010; const ll M=1000000007ll; ll n,a[N],e[N],re[N]; ll suan(ll x,ll y){ ll t=1;while(y){if(y&1)t=t*x%M;x=x*x%M;y>>=1;}return t; } ll work(ll x,ll y){ if(y==0)return 1; return e[x]*re[x-y]%M*re[y]%M; } int main(void){ ll i; [...]

Codeforces Round #419 (Div. 1), problem: (A) Karen and Game Solution In C/C++

By |2017-08-07T21:36:03+00:00August 7th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , , |

#include <bits/stdc++.h> #define inf 0x3f3f3f3f #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long ll; int const N = 111; int g[N][N], r[N], c[N], e[N], f[N]; int main() { int n, m; scanf("%d%d", &n, &m); [...]