ABC 288 ABC

来水一篇博客,前面虽然打了挺多比赛,但是一直在忙项目和考试,没补题,那些就等补完题目再写完整的题解咯(:水多了也不好哈哈
https://atcoder.jp/contests/abc288

今天这场断层了,D直接ac人数不超过1k,unrated的我慢悠悠造完三题下班~

A - Many A+B Problems

题目大意:

输出a+b.
Sample Input 1  
4
3 5
2 -6
-5 0
314159265 123456789
Sample Output 1  
8
-4
-5
437616054
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18,MINN=31;
const LL N=1e6+10,M=4002;
const double PI=3.1415926535;
#define endl '\n'
LL a[N];
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    int T=1;
    cin>>T;
    while(T--)
    {
        LL x,y;
        cin>>x>>y;
        cout<<x+y<<endl;
    }
    return 0;
}

B - Qualification Contest

题目大意:

给定n个名字,求前m个名字按字典序排名。
Sample Input 1  
5 3
abc
aaaaa
xyz
a
def
Sample Output 1  
aaaaa
abc
xyz
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18,MINN=31;
const LL N=1e6+10,M=4002;
const double PI=3.1415926535;
#define endl '\n'
LL a[N];
string s[N];
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    int T=1;
    //cin>>T;
    while(T--)
    {
        LL n,m;
        cin>>n>>m;
        for(int i=1;i<=n;i++)
        {
            cin>>s[i];
        }
        sort(s+1,s+1+m);
        for(int i=1;i<=m;i++)
            cout<<s[i]<<endl;
    }
    return 0;
}

C - Don’t be cycle

题目大意:

n个点,m条边,不能出现环,问我们至少删除几条边?
Sample Input 1  
6 7
1 2
1 3
2 3
4 2
6 5
4 6
4 5
Sample Output 1  
2
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18,MINN=31;
const LL N=1e6+10,M=4002;
const double PI=3.1415926535;
#define endl '\n'
LL n,m;
LL father[N];
vector<LL> v[N];
LL find(LL x)
{
    if(father[x]!=x) father[x]=find(father[x]);
    return father[x];
}
int main()
{
    //cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    int T=1;
    //cin>>T;
    while(T--)
    {
        cin>>n>>m;
        for(LL i=1;i<=n;i++)
        {
            father[i]=i;
        }
        LL sum=0;
        for(LL i=1;i<=m;i++)
        {
            LL x,y;
            cin>>x>>y;
            LL fx=find(x),fy=find(y);
            if(fx==fy) sum++;
            else father[min(fx,fy)]=max(fx,fy);
        }
        cout<<sum<<endl;
    }
    return 0;
}
posted @ 2023-02-04 23:43  Vijurria  阅读(49)  评论(0编辑  收藏  举报