Codecraft-17 and Codeforces Round #391 (Div. 1 + Div. 2

/Tag: Codecraft-17 and Codeforces Round #391 (Div. 1 + Div. 2

Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals), problem: (C) Jury Marks Solution In C/C++

By |2017-07-24T17:45:19+06:00July 24th, 2017|Categories: C/C++, Programming||

#include<bits/stdc++.h> using namespace std; int main(){ int n,k; cin>>k>>n; int t; int arr[k]; set<int>c; for(int i=0;i<k;i++){ cin>>t; arr[i]= arr[i-1]+t; } for(int i=0;i<n;i++){ cin>>t; set<int>mmp; for(int j=0;j<k;j++){ int x = t-arr[j]; if(!i||(c.find(x) != c.end())){ mmp.insert(x); } } c =mmp; } cout<<c.size(); return 0; }

Codecraft-17 and Codeforces Round #391 (Div. 1 + Div. 2, combined), problem: (G) Can Bash Save the Day? Solution in C/C++

By |2017-04-07T22:10:19+06:00January 16th, 2017|Categories: C/C++, Programming||

#include<bits/stdc++.h> #define N 200100 using namespace std; int sz[N]; vector<int> g[N],w[N]; int loc[N][20],dep[N],tloc[20],td; long long len[N][20]; bool del[N]; void build(int u, int p, int ly, long long d){ sz[u]=1; len[u][ly]=d; for(int i=0;i<g[u].size();i++){ int v=g[u][i]; if(v==p||del[v]) continue; build(v,u,ly,d+w[u][i]); sz[u]+=sz[v]; } } void decom(int u){ build(u,0,td,0); [...]

Codecraft-17 and Codeforces Round #391 (Div. 1 + Div. 2, combined), problem: (F) Team Rocket Rises Again Solution in C/C++

By |2017-04-07T22:10:19+06:00January 16th, 2017|Categories: C/C++, Programming||

#include <bits/stdc++.h> #define F first #define S second #define X real() #define Y imag() using namespace std; typedef long long ll; typedef long double ld; vector<pair<int, ll> > g[202020]; int u[202020]; int bc[202020]; int b[202020]; vector<int> fr[202020]; ll d[202020]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int [...]

Codecraft-17 and Codeforces Round #391 (Div. 1 + Div. 2, combined), problem: (E) Bash Plays with Functions Solution in C/C++

By |2017-04-07T22:10:19+06:00January 16th, 2017|Categories: C/C++, Programming||

#include <cstdio> const int mod = 1000000007; int a[1000010][21]; int b[1000010]; int main() { int q, r, n; a[0][0] = 1; for (int j = 1; j < 21; j++) { a[0][j] = 2; } for (int i = 1; i < 1000010; i++) [...]

Codecraft-17 and Codeforces Round #391 (Div. 1 + Div. 2, combined), problem: (D) Felicity’s Big Secret Revealed Solution in C/C++

By |2017-04-07T22:10:19+06:00January 16th, 2017|Categories: C/C++, Programming||

#include<stdio.h> #define m 1000000007u typedef unsigned u; u D[76][1u<<20],S[1u<<20]; char C[76]; u V[76][76]; int main() { u n,i,j,k,N=1u<<20,b,r=0; scanf("%u",&n); scanf("%s",C); for(i=-1;++i<n;)for(j=i-1,k=0;++j<n;) { k=k<<1|(C[j]=='1'); V[i][j]=k; } for(i=-1;++i<=n;)D[i][0]=1; for(i=-1;++i<n;) { for(j=i-1;++j<n;) { if(!V[i][j])continue; if(V[i][j]>20)break; b=1u<<(V[i][j]-1); for(k=-1;++k<N;) if((D[j+1][k|b]+=D[i][k])>=m)D[j+1][k|b]-=m; } } for(i=-1;++i<=n;) { for(j=1;j<N;j=j<<1|1) if((r+=D[i][j])>=m)r-=m; } printf("%u\n",r); return [...]

Codecraft-17 and Codeforces Round #391 (Div. 1 + Div. 2, combined), problem: (C) Felicity is Coming! Solution in C/C++

By |2017-04-07T22:10:20+06:00January 16th, 2017|Categories: C/C++, Programming||

#include<stdio.h> #include<stdlib.h> #define m 1000000007u typedef long long unsigned llu; typedef unsigned u; int C(const void*x,const void*y){return*(u*)x-*(u*)y;} int D(const void*x,const void*y) { if(*(llu*)x>*(llu*)y)return 1; if(*(llu*)x<*(llu*)y)return-1; return 0; } llu H[1111111],P[1111111]; u F[1111111],Q[1111111]; int main() { u t,q,n,i,j,r=1; for(F[i=0]=1;++i<1111111;)F[i]=i*(llu)F[i-1]%m; for(P[i=0]=1;++i<1111111;)P[i]=m*P[i-1]+1; for(scanf("%u%u",&t,&n);t--;) { scanf("%u",&q); for(i=-1;++i<q;)scanf("%u",Q+i); qsort(Q,q,sizeof(u),C);Q[q]=-1u; [...]

Codecraft-17 and Codeforces Round #391 (Div. 1 + Div. 2, combined), problem: (B) Bash’s Big Day Solution in C/C++

By |2017-04-07T22:10:20+06:00January 16th, 2017|Categories: C/C++, Programming||

#include <stdio.h> int main(){ int n; scanf("%d",&n); int i, temp, max=1, freq[100001]={0}, ans=1, j; for(i=0;i<n;i++){ scanf("%d",&temp); freq[temp]++; if(temp>max){ max=temp; } } for(i=2; i<=max; ++i){ temp=0; for(j=i; j<=max; j+=i){ temp+=freq[j]; } if(temp>ans) ans=temp; } printf("%d",ans); return 0; }

Codecraft-17 and Codeforces Round #391 (Div. 1 + Div. 2, combined), problem: (A) Gotta Catch Em’ All! Solution in C/C++

By |2017-04-07T22:10:20+06:00January 16th, 2017|Categories: C/C++, Programming||

#include<stdio.h> #include<string.h> int main(){ int i,j; char ch; char a[100005]; int b[256]={0}; while((ch=getchar())!=EOF){ b[ch]++; } char *d="ulbasr"; int min=b['B']; b['u']=b['u']/2; b['a']=b['a']/2; for(i=0;i<strlen(d);i++){ if(min>b[d[i]]){ min=b[d[i]]; } } printf("%d",min); }