前言

这次ABC还是有一点难度的吧.

TaskA Security

Solution

直接模拟就好了.

Code

/*
  mail: mleautomaton@foxmail.com
  author: MLEAutoMaton
  This Code is made by MLEAutoMaton
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi(){
    int f=1,sum=0;char ch=getchar();
    while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
    return f*sum;
}
char s[100010];
int main(){
    scanf("%s",s+1);
    for(int i=1;i<strlen(s+1);i++){
        if(s[i]==s[i+1])return puts("Bad"),0;
    }
    puts("Good");
    return 0;
}

TaskB Bite Eating

Solution

直接枚举删除那个然后判断就行了.

Code

/*
  mail: mleautomaton@foxmail.com
  author: MLEAutoMaton
  This Code is made by MLEAutoMaton
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi(){
    int f=1,sum=0;char ch=getchar();
    while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
    return f*sum;
}
int n,L,a[210];
int main(){
    n=gi();L=gi();int Sum=0;
    for(int i=1;i<=n;i++)a[i]=L+i-1,Sum+=a[i];
    int Min=1e9+10,ans;
    for(int i=1;i<=n;i++){
        int sum=0;
        for(int j=1;j<=n;j++)if(i!=j)sum+=a[j];

        if(abs(Sum-sum)<Min){Min=abs(Sum-sum);ans=sum;}
    }
    printf("%d\n",ans);
    return 0;
}

TaskC Anti-Division

Solution

求个\(gcd\)容斥就行了.

Code

/*
  mail: mleautomaton@foxmail.com
  author: MLEAutoMaton
  This Code is made by MLEAutoMaton
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define int ll
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi(){
    int f=1,sum=0;char ch=getchar();
    while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
    return f*sum;
}
ll get(ll a,ll b,ll c){
    return (b-a+1)-(b/c-(a-1)/c);
}
ll gcd(ll a,ll b){
    if(!b)return a;
    return gcd(b,a%b);
}
ll a,b,sumc,sumd,sumcd;int c,d;
signed main(){
    scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
    printf("%lld\n",get(a,b,c)+get(a,b,d)-get(a,b,1ll*c*d/gcd(c,d)));
    return 0;
}

TaskD Megalomania

Solution

直接按照最晚完成时间排序然后模拟就行.

Code

/*
  mail: mleautomaton@foxmail.com
  author: MLEAutoMaton
  This Code is made by MLEAutoMaton
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define int ll
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi(){
    int f=1,sum=0;char ch=getchar();
    while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
    return f*sum;
}
struct node{int x,y;}job[200010];
int n;
bool operator<(const node a,const node b){
    return a.y<b.y || (a.y==b.y && a.x<b.x);
}
signed main(){
    n=gi();
    for(int i=1;i<=n;i++)job[i].x=gi(),job[i].y=gi();
    sort(&job[1],&job[n+1]);int now=0;
    for(int i=1;i<=n;i++){
        now+=job[i].x;
        if(now>job[i].y)return puts("No"),0;
    }
    puts("Yes");
    return 0;
}

TaskE Friendships

Solution

考虑菊花图是最多的,那么一步一步往菊花图里面加边就行了.

Code

/*
  mail: mleautomaton@foxmail.com
  author: MLEAutoMaton
  This Code is made by MLEAutoMaton
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi(){
    int f=1,sum=0;char ch=getchar();
    while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
    return f*sum;
}
int n,k;
struct node{int x,y;}edge[1000010];
int main(){
    n=gi();k=gi();
    int tot=(n-2)*(n-1)/2,m=n-1;
    for(int i=1;i<=m;i++)edge[i].x=n,edge[i].y=i;
    if(k>tot)return puts("-1"),0;int now=2,Q=1;
    n--;
    while(tot!=k){
        tot--;
        edge[++m]=(node){now,(now+Q-1)%n+1};
        now++;now=(now-1)%n+1;
        if(now==2)Q++;
    }
    printf("%d\n",m);
    for(int i=1;i<=m;i++)
        printf("%d %d\n",edge[i].x,edge[i].y);
    return 0;
}

TaskF Must Be Rectangular!

Solution

\(yyb\)就是神仙!!!
考虑把一个点的\(x,y\)分割,那么就相当于\(x\)->\(y\)连边,然后就有考虑一个联通块肯定可以搞成完全图,那么完全图的边数就是点数...
最后直接减去最初的点数就没了.

Code

/*
  mail: mleautomaton@foxmail.com
  author: MLEAutoMaton
  This Code is made by MLEAutoMaton
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
#define MAX 100100
inline int gi(){
    int f=1,sum=0;char ch=getchar();
    while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
    return f*sum;
}
int n,f[MAX<<1];
int getf(int x){return x==f[x]?x:f[x]=getf(f[x]);}
int sz1[MAX<<1],sz2[MAX<<1];
ll ans;
int main(){
    n=gi();
    for(int i=1;i<MAX+MAX;++i)f[i]=i;
    for(int i=1;i<=n;++i)
    {
        int u=gi(),v=gi();
        f[getf(u)]=getf(v+MAX);
    }
    for(int i=1;i<=MAX;++i)
        sz1[getf(i)]+=1;
    for(int i=MAX+1;i<MAX+MAX;++i)
        sz2[getf(i)]+=1;
    for(int i=1;i<MAX+MAX;++i)ans+=1ll*sz1[i]*sz2[i];
    cout<<ans-n<<endl;
    return 0;
}

AtCoder Beginner Contest 131 Solution的更多相关文章

  1. AtCoder Beginner Contest 114 Solution

    A 753 Solved. #include <bits/stdc++.h> using namespace std; ]; int main() { mp[] = mp[] = mp[] ...

  2. AtCoder Beginner Contest 115 Solution

    A Christmas Eve Eve Eve Solved. #include <bits/stdc++.h> using namespace std; int main() { int ...

  3. AtCoder Beginner Contest 131 Task F. Must Be Rectangular

    Score: 600 points Approach 固定横坐标 $x$,考虑横坐标为 $x$ 的竖直线上最多可以有几个点. Observations 若最初两条竖直线 $x_1$.$x_2$ 上都有 ...

  4. AtCoder Beginner Contest 131 F - Must Be Rectangular!

    题意:给出二维平面的n个点坐标,定义一种操作:若恰好三个点能形成一个矩形(当然这个矩形会缺了一个点),那么就在图上添加这个缺的点,问在原图上最多能进行几次这样的操作. 解法:这题想了挺久没想到,一看题 ...

  5. AtCoder Beginner Contest 053 ABCD题

    A - ABC/ARC Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Smeke has ...

  6. AtCoder Beginner Contest 068 ABCD题

    A - ABCxxx Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement This contes ...

  7. AtCoder Beginner Contest 154 题解

    人生第一场 AtCoder,纪念一下 话说年后的 AtCoder 比赛怎么这么少啊(大雾 AtCoder Beginner Contest 154 题解 A - Remaining Balls We ...

  8. AtCoder Beginner Contest 238 A - F 题解

    AtCoder Beginner Contest 238 \(A - F\) 题解 A - Exponential or Quadratic 题意 判断 \(2^n > n^2\)是否成立? S ...

  9. AtCoder Beginner Contest 100 2018/06/16

    A - Happy Birthday! Time limit : 2sec / Memory limit : 1000MB Score: 100 points Problem Statement E8 ...

随机推荐

  1. nginx目录列表和目录访问权限设置

    1.目录列表(directory listing) nginx让目录中的文件以列表的形式展现只需要一条指令 autoindex on; autoindex可以放在location中,只对当前locat ...

  2. bzoj1531

    背包+倍增 直接背包跑不过去,那么我们把容量分成二进制,然后原来需要枚举c次就只用枚举log(c)次了,这样还是能组合出任意小于等于c的组合方案 #include<bits/stdc++.h&g ...

  3. Linux中的LVM

    逻辑卷管理器,通过将另外一个硬盘上的分区加到已有文件系统,来动态地向已有文件系统添加空间的方法. 逻辑卷管理的核心是处理安装在系统上的硬盘分区.在逻辑卷管理的世界里,硬盘称作物理卷(Physical ...

  4. SP2916 GSS5 - Can you answer these queries V

    给定一个序列.查询左端点在$[x_1, y_1]$之间,且右端点在$[x_2, y_2]$之间的最大子段和,数据保证$x_1\leq x_2,y_1\leq y_2$,但是不保证端点所在的区间不重合 ...

  5. [App Store Connect帮助]四、添加 App 图标、App 预览和屏幕快照(6)设置 App 预览海报帧

    App 预览海报帧仅在 App 状态为可编辑时,才能被编辑. 必要职能:“帐户持有人”职能.“管理”职能.“App 管理”职能或“营销”职能.请参见职能权限. 在首页上,点按“我的 App”,选择您的 ...

  6. Photoshop CC2019破解版

    Photoshop CC2019 精简版: 链接:https://pan.baidu.com/s/1PeFrhtLHxLRXCW_vMkAZDg  提取码:q6nl Photoshop CC2019: ...

  7. C++面向对象程序设计_Part2

    目录 Composition(复合) 内存视角下的composition(复合) composition(复合)关系下的构造与析构 Delegation (委託) -- Composition by ...

  8. python自动化测试学习笔记-6excel操作xlwt、xlrd、xlutils模块

    python中通过xlwt.xlrd和xlutils操作xls xlwt模块用于在内存中生成一个xls/xlsx对象,增加表格数据,并把内存中的xls对象保存为本地磁盘xls文件; xlrd模块用于把 ...

  9. docker血一样的教训,生成容器的时候一定要设置数据卷,把数据文件目录,配置文件目录,日志文件目录都要映射到宿主机上保存啊!!!

    打个比方,比如mysql,如果你想重新设置一下mysql的配置,不小心配错里,启动容器失败,已启动就停止了. 根本进不去mysql的容器里.如果之前run容器的时候,没有把数据文件,日志文件,配置文件 ...

  10. Java易忘知识点统计

    缺少 内容 替代措施 幂运算 借助Math类的pow方法 注意 内容 备注 const Java保留关键字,未使用 其他 强制类型转换时,若要舍入得到最接近的整数,可以使用Math.round方法 J ...