zoukankan      html  css  js  c++  java
  • BestCoder Round #92 (hdu 6015 6016)

    比赛链接

    A题主要是map的使用,比赛的时候问了下队友,下次要记住了

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long LL;
    
    LL T,n;
    map<string,int> mp1,mp2;
    
    int main()
    {
        cin>>T;
        while(T--)
        {
            mp1.clear();mp2.clear();
            cin>>n;
            for(int i=0;i<n;i++)
            {
                string str;
                int t;
                cin>>str>>t;
                if(mp1[str]<t)
                {
                    mp2[str]=mp1[str];
                    mp1[str]=t;
                }
                else if(mp2[str]<t)
                {
                    mp2[str]=t;
                }
            }
            int ans=0;
            for(map<string,int>::iterator it=mp1.begin();it!=mp1.end();++it)
                ans+=it->second;
            for(map<string,int>::iterator it=mp2.begin();it!=mp2.end();++it)
                ans+=it->second;
            cout<<ans<<endl;
        }
    }
    hdu_6015

    B题算是道组合数学吧,枚举可能满足条件的 -B-C- (也即-C-B),以BC为中间二点的满足条件的序列数=(du[B]-1)*(du[C]-1)*2

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long LL;
    
    LL du[200005];
    struct Edge
    {
        LL u,v;
    }e[100005];
    
    int main()
    {
        ios::sync_with_stdio(false);cin.tie(0);
        LL T,n,m,k;
        cin>>T;
        while(T--)
        {
            memset(du,0,sizeof(du));
            cin>>n>>m>>k;
            for(int i=0;i<k;i++)
            {
                LL u,v;
                cin>>u>>v;
                du[u]++,du[n+v]++;
                e[i]=(Edge){u,v+n};
            }
            LL ans=0;
            for(int i=0;i<k;i++)
                ans+=(du[e[i].u]-1)*(du[e[i].v]-1)*2;
            cout<<ans<<endl;
        }
    }
    hdu_6016
  • 相关阅读:
    〖Linux〗-- 复制、用户和组操作、权限更改
    〖Linux〗-- 文本结构和基本命令
    〖Demo〗-- ATM
    〖Python〗-- 脚本目录规范
    二、配置文件
    一、SpringBoot入门
    File--字节流--字符流
    File--字节流--字符流
    SpringBoot快速搭建流程
    SpringBoot快速搭建流程
  • 原文地址:https://www.cnblogs.com/Just--Do--It/p/6442931.html
Copyright © 2011-2022 走看看