Codeforces Round #548 (Div. 2) (还缺3题~)

A. Even Substrings

#include
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	string s;
	cin>>s;
	long long ans=0;
	for(int i=0;i

 B. Chocolates

#include
using namespace std;
int a[200005];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i=0;--i){
		if(a[i+1]-1>=a[i]) ans+=a[i];
		else a[i]=max(a[i+1]-1,0),ans+=a[i];
	}
	printf("%lld",ans);
}

C. Edgy Trees

#include
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int MAXV=100005;
vectoradj[MAXV];
int n;//n为顶点数,MAXV为最大顶点数 
bool vis[MAXV];//如果顶点i已被访问,则vis[i]=true.初值为false

ll poww(ll a, ll b){
    ll ans = 1, base = a;
    while(b>0){
        if(b&1) ans*=base,ans%=MOD; 
        base*=base,base%=MOD;
        b>>=1; //b=b/2
    }
    return ans%MOD;
}

int main(){
	int k;
	scanf("%d%d",&n,&k);
	int u,v,color;
	ll cnt=0,num=0,sum=0;
	for(int i=0;iq;
			if(!vis[i]){//注意 
				q.push(i);
				vis[i]=true;
			}
			while(!q.empty()){
				int top=q.front();
				q.pop();
				for(int j=0;j

 

你可能感兴趣的:(Codeforces)