# Codeforces Round #411 (Div. 2)

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

## Codeforces Round #411 (Div. 2), problem: (F) Expected diameter of a tree Solution In C/C++

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

#include <set> #include <vector> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int N=200050; vector<int>vec[N],dis[N],sum[N]; struct Node{int x,y;double ans;}JY; bool operator<(Node a,Node b){if(a.x!=b.x)return a.x<b.x;return a.y<b.y;} set<Node>s;set<Node>::iterator it; int n,m,q,first[N],nxt[N],v[N],w[N],tot,root,xx,yy,vis[N]; int maxx[N][2],rec[N][2],f[N],Root[N],vv[N],fi,flag,size[N]; void add(int x,int y){w[tot]=1,v[tot]=y,nxt[tot]=first[x],first[x]=tot++;} int find(int x){return x==f[x]?x:f[x]=find(f[x]);} void get_dia(int x,int [...]

## Codeforces Round #411 (Div. 2), problem: (E) Ice cream coloring Solution In C/C++

By |2017-07-24T02:06:43+06:00July 24th, 2017|Categories: C/C++, Programming||

#include<cstdio> #include<cstring> #include<cstdlib> #include<algorithm> #include<set> using namespace std; const int MX=600111; int n,m; int pool[MX],*c[MX],s[MX]; int hed[MX],nxt[MX],t[MX],ec,vis[MX],vism[MX],no[MX]; set<int>cur; inline void ade(int u,int v){ ec++;nxt[ec]=hed[u];t[ec]=v;hed[u]=ec; } void dfs(int k){ vis[k]=1; for(int *i=c[k];i!=c[k+1];i++)if(vism[*i])cur.erase(no[*i]); for(int *i=c[k];i!=c[k+1];i++)if(!vism[*i]){ no[*i]=*(cur.lower_bound(1)); cur.erase(no[*i]); vism[*i]=1; } for(int *i=c[k];i!=c[k+1];i++)cur.insert(no[*i]); for(int i=hed[k];i;i=nxt[i])if(!vis[t[i]])dfs(t[i]); } int main(){ [...]

## Codeforces Round #411 (Div. 2), problem: (D) Minimum number of steps Solution In C/C++

By |2017-07-24T02:03:29+06:00July 24th, 2017|Categories: C/C++, Programming||

#include<bits/stdc++.h> using namespace std; int c,d,i,n,m,k,x,j=1000000007; string s; main(){ cin>>s; for(i=s.size()-1;i>=0;i--){ if(s[i]=='b')c++;else{ k+=c;c*=2;k%=j;c%=j; } } cout<<k; }

## Codeforces Round #411 (Div. 2), problem: (B) 3-palindrome Solution In C/C++

By |2017-07-24T01:55:33+06:00July 24th, 2017|Categories: Uncategorized||

#include <cstdio> int n; int main (){ scanf("%d", &n); for (int i = 0; i < n; i++) printf("%c", i % 4 < 2 ? 'a' : 'b'); printf("\n"); return 0; }