• Codeforces Round #482 (Div. 2)


    标签: codeforces


    题目链接

    http://codeforces.com/contest/979

    A.Pizza, Pizza, Pizza!!!

    #include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <cstring>
    #include <queue>
    using namespace std;
    typedef long long ll;
    const int maxn=100050;
    const int MOD=1e9+7;
    int main(int argc, char const *argv[])
    {
    	ll x;
    	cin>>x;
    	x++;
    	if(x==1) printf("0
    ");
    	else if(x&1) printf("%lld
    ", x);
    	else printf("%lld
    ", x/2);
    	return 0;
    }
    

    B.Treasure Hunt

    #include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <cstring>
    #include <queue>
    using namespace std;
    const int maxn=100050;
    const int MOD=1e9+7;
    int b[300];
    int solve(string &s,int n){
    	if(n>s.size()) return s.size();
    	memset(b,0,sizeof b);
    	for (int i = 0; i < s.size(); ++i)
    	{
    		b[s[i]]++;
    	}
    	int m=s.size();
    	int ans=0;
    	int cnt=0;
    	for (int i = 0; i < 300; ++i)
    	{
    		if(b[i]) cnt++;
    		if(n<=m-b[i]){
    			ans=max(ans,n+b[i]);
    		}
    		else{
    			if(n==1&&m==b[i]) ans=max(ans,m-1);
    			else ans=max(ans,m);
    		}
    	}
    	return ans;
    }
    int main(int argc, char const *argv[])
    {
    	int n;
    	string a,b,c;
    	cin>>n>>a>>b>>c;
    	int x=solve(a,n);
    	int y=solve(b,n);
    	int z=solve(c,n);
    	int M=max(x,max(y,z));
    	int C=0;
    	if(M==x) C++;
    	if(M==y) C++;
    	if(M==z) C++;
    	if(C>=2) printf("Draw
    ");
    	else if(M==x) printf("Kuro
    ");
    	else if(M==y) printf("Shiro
    ");
    	else if(M==z) printf("Katie
    ");
    	return 0;
    }
    

    C.Kuro and Walking Route

    #include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <cstring>
    #include <queue>
    using namespace std;
    const int maxn=300050;
    const int MOD=1e9+7;
    typedef long long ll;
    std::vector<int> v[maxn];
    int sz[maxn];
    void dfs(int x,int fa){
    	sz[x]=1;
    	for(auto y:v[x]){
    		if(y!=fa){
    			dfs(y,x);
    			sz[x]+=sz[y];
    		}
    	}
    }
    int main(int argc, char const *argv[])
    {
    	int n,x,y;
    	scanf("%d%d%d", &n,&x,&y);
    	for (int i = 0; i < n-1; ++i)
    	{
    		int u,w;
    		scanf("%d%d", &u,&w);
    		v[u].push_back(w);
    		v[w].push_back(u);
    	}
    	dfs(x,x);
    	ll s1=sz[y];
    	dfs(y,y);
    	ll s2=sz[x];
    	printf("%lld
    ", (ll)n*(n-1)-s1*s2);
    	return 0;
    }
    

    D.Kuro and GCD and XOR and SUM

    留坑

    E.Kuro and Topological Parity

    留坑

  • 相关阅读:
    计算某一日期是在一年中第几周
    动态生成web表-asp.net table
    sql server 小技巧(7) 导出完整sql server 数据库成一个sql文件,包含表结构及数据
    循环取月的三位英语名 Jan Feb
    Python面向对象编程
    算法
    UDP Sockets in C#
    C++ 11
    GNU Make
    C++ 11
  • 原文地址:https://www.cnblogs.com/sciorz/p/9039372.html
Copyright © 2020-2023  润新知