首页 > 其他分享 >ABC 288 ABC

ABC 288 ABC

时间:2023-02-04 23:55:39浏览次数:54  
标签:typedef ABC const int LL father cin 288

来水一篇博客,前面虽然打了挺多比赛,但是一直在忙项目和考试,没补题,那些就等补完题目再写完整的题解咯(:水多了也不好哈哈
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;
}

标签:typedef,ABC,const,int,LL,father,cin,288
From: https://www.cnblogs.com/Vivian-0918/p/17092665.html

相关文章

  • 【230203-2】(一道几何上一目了然,代数能列式却举步维艰的题)等腰直角三角形ABC中,C为直
    ......
  • POJ 2886(线段树+单点修改+约瑟夫环)
    DescriptionN childrenaresittinginacircletoplayagame.Thechildrenarenumberedfrom1to N inclockwiseorder.Eachofthemhasacardwithanon-zer......
  • [ABC266] AtCoder Beginner Contest 266
    比赛链接:Tasks-AtCoderBeginnerContest266先贴代码,题解有空再补。TasksTaskNameTimeLimitMemoryLimitAMiddleLetter2sec1024MBSubmit......
  • abc172e NEQ
    abc172e构造两个长度为n的序列,可选的数在[1..M]范围,要求满足以下条件\(A_i\neqB_i\)\(A_i\neqA_j\),\(B_i\neqB_j\)求方案数如果两个条件一起考虑会很麻烦,假设不......
  • ABC287 解题报告【A~F】
    AtcoderBeginnerContest287姗姗来迟的解题报告C题漏了一个细节,狂WA,心态爆炸,暴跌58ratingContestlinkMyresultA-Majority直接统计For的个数,与\(\dfrac{......
  • Atcoder ABC282F Union of Two Sets
    https://atcoder.jp/contests/abc282/tasks/abc282_fST表板子???这怎么出的?发现要每一个区间都能拆分成至多两个区间,那很明显就能联想到ST表的查询。大概算一下发现......
  • Atcoder ABC282E Choose Two and Eat One
    https://atcoder.jp/contests/abc282/tasks/abc282_e发现选出两个球去掉一个球其实很像一颗树去掉叶子节点,贡献即为叶子节点与父亲的边权。那这题就很明显了,预处理好每......
  • Atcoder ABC282H Min + Sum
    https://atcoder.jp/contests/abc282/tasks/abc282_h挂了好久发现二分写挂了……对于\(\min\{a_i\}\)这一部分,不难想到找到当前\(\min\{a_i\}\)的位置计算其左右两......
  • 随机码 abcD
    packagecom.fqs.demo;importjava.util.Random;publicclassMa{publicstaticvoidmain(String[]args){//随机码abcd//(char)97=a(cha......
  • [ABC014D] 閉路 [LCA]
    现有一棵\(N(N\le10^5)\)个节点的树,保证节点编号为\(1\toN\)。首先输入\(N\),然后输入\(N-1\)条边。然后输入一个整数\(q(q\le10^5)\)。接下来给出\(q\)次询......