比赛总结——atcoder beginner contest 109

第一次AK的ABC

虽然题非常简单

但是值得纪念一下

T1

一道很水的题

不存在做法

纯粹乱跑

但是我把Yes打成YES了,哭唧唧

#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  if((1*a*b)%2==1||(2*a*b)%2==1||(3*a*b)%2==1)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}

T2

就是普通的判重和模拟

stl真好用

#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <set>
#include <iostream>
using namespace std;
int n;
set<string> s;
string a;
char lat;
int main(){
  scanf("%d",&n);
  for(int i=1;i<=n;i++){
    cin>>a;
    if(s.count(a)){
      printf("No\n");
      return 0;
    }
    if(i>1&&a[0]!=lat){
      printf("No\n");
      return 0;
    }
    lat=a[a.length()-1];
    s.insert(a);
  }
  printf("Yes\n");
  return 0;
}

T3

有趣的GCD应用

秒掉

#include <cstdio>
#include <cstring>
#include <algorithm>
#define int long long
using namespace std;
int n,x,pos[110000];
int gcd(int a,int b){
  return (b==0)?a:gcd(b,a%b);
}
signed main(){
  scanf("%lld %lld",&n,&x);
  for(int i=1;i<=n;i++)
    scanf("%lld",&pos[i]);
  for(int i=1;i<=n;i++)
    pos[i]-=x;
  ++n;
  pos[n]=0;
  sort(pos+1,pos+n+1);
  int ans=pos[2]-pos[1];
  for(int i=2;i<=n-1;i++){
    ans=gcd(ans,pos[i+1]-pos[i]);
  }
  printf("%lld",ans);
  return 0;
}

T4

乍一看不好做其实很水的构造

#include <cstdio>
#include <algorithm>
#include <cstring>
#define int long long
using namespace std;
int mat[510][510],mat2[510][510],ans=0;
int h,w;
signed main(){
  scanf("%lld %lld",&h,&w);
  for(int i=1;i<=h;i++)
    for(int j=1;j<=w;j++)
      scanf("%lld",&mat[i][j]),mat2[i][j]=mat[i][j];
  for(int i=1;i<=h;i++)
    for(int j=1;j<=w-1;j++){
      if(mat2[i][j]%2==0)
        continue;
      else{
        ans++;
        mat2[i][j+1]++;
        mat2[i][j]--;
      }
      //ans+=mat2[i][j],mat2[i][j+1]+=mat2[i][j],mat2[i][j]=0;
    }
  for(int i=1;i<=h-1;i++){
    //ans+=mat2[i][w],mat2[i+1][w]+=mat2[i][w],mat2[i][w]=0;
    if(mat2[i][w]%2==0)
      continue;
    else{
      ans++;
      mat2[i+1][w]++;
      mat2[i][w]--;
    }
  }
  printf("%lld\n",ans);
  for(int j=1;j<=h;j++)
    for(int i=1;i<=w-1;i++){
      if(mat[j][i]%2==0)
        continue;
      else{
        printf("%lld %lld %lld %lld\n",j,i,j,i+1);
        mat[j][i+1]++;
        mat[j][i]--;
      }
//      for(int k=1;k<=mat[j][i];k++){
//        printf("%d %d %d %d\n",j,i,j,i+1);
//        mat[j][i+1]+=1;
//      }
//      mat[j][i]=0;
  }
  for(int i=1;i<=h-1;i++){
    if(mat[i][w]%2==0)
      continue;
    else{
      mat[i+1][w]++;
      mat[i][w]--;
      printf("%lld %lld %lld %lld\n",i,w,i+1,w);
    }
  }
//    for(int k=1;k<=mat[i][w];k++)
//      printf("%d %d %d %d\n",i,w,i+1,w),mat[i+1][w]++;
  return 0;
}

原文地址:https://www.cnblogs.com/dreagonm/p/9610877.html

时间: 2024-10-09 22:11:57

比赛总结——atcoder beginner contest 109的相关文章

AtCoder Beginner Contest 154 题解

人生第一场 AtCoder,纪念一下 话说年后的 AtCoder 比赛怎么这么少啊(大雾 AtCoder Beginner Contest 154 题解 A - Remaining Balls We have A balls with the string S written on each of them and B balls with the string T written on each of them. From these balls, Takahashi chooses one

AtCoder Beginner Contest 103 D(贪心)

AtCoder Beginner Contest 103 D 题目大意:n个点,除第n个点外第i与第i+1个点有一条边,给定m个a[i],b[i],求最少去掉几条边能使所有a[i],b[i]不相连. 按右端点从小到大排序,如果当前选的去掉的边在区间内,那么符合条件,否则ans++,并贪心地把去掉的边指向右端点,因为前面的区间都满足条件了,所以要去掉的边要尽量向右移使其满足更多的区间. 1 #include <iostream> 2 #include <cstdio> 3 #incl

AtCoder Beginner Contest 136

AtCoder Beginner Contest 136 Contest Duration : 2019-08-04(Sun) 20:00 ~ 2019-08-04(Sun) 21:40 Website: AtCoder BC-136 后面几题都挺考思考角度D. C - Build Stairs 题目描述: 有n座山从左到右排列,给定每一座山的高度\(Hi\),现在你可以对每座山进行如下操作至多一次:将这座山的高度降低1. 问是否有可能通过对一些山进行如上操作,使得最后从左至右,山的高度呈不下降

AtCoder Beginner Contest 155 简要题解

AtCoder Beginner Contest 155 A:签到失败,WA一次. int main() { int a, b, c; cin >> a >> b >> c; if(a == b && b == c) cout << "No"; else if(a == b || a == c || b == c) cout << "Yes"; else cout << &quo

AtCoder Beginner Contest 152 - F - Tree and Constraints (容斥定理+树上路径的性质)

AtCoder Beginner Contest 152 - F - Tree and Constraints (容斥定理+树上路径的性质) We have a tree with NN vertices numbered 11 to NN. The ii-th edge in this tree connects Vertex aiai and Vertex bibi. Consider painting each of these edges white or black. There ar

【ATcoder】AtCoder Beginner Contest 161 题解

题目链接:AtCoder Beginner Contest 161 原版题解链接:传送门 A - ABC Swap 这题太水,直接模拟即可. 1 #include <iostream> 2 using namespace std; 3 int main() { 4 int a, b, c; 5 cin >> a >> b >> c; 6 swap(a, b); 7 swap(a, c); 8 cout << a << " &

AtCoder Beginner Contest 115 题解

题目链接:https://abc115.contest.atcoder.jp/ A Christmas Eve Eve Eve 题目: Time limit : 2sec / Memory limit : 1024MB Score : 100 points Problem Statement In some other world, today is December D-th. Write a program that prints Christmas if D=25, Christmas E

AtCoder Beginner Contest 144:E.Gluttony【题解】

题目链接:https://atcoder.jp/contests/abc144/tasks/abc144_e 一道很简单的二分加贪心,但我在比赛时没过.因为我输入错了,它竟然加上样例还有6个点是对的,于是我查了半小时都没发现这件事,到最后只能怀疑是自己想法错了放弃. (我不管我不管,是数据的锅!)至于难度的话应该有T1无T2吧 首先二分答案sum. 现在的问题是你要将A,F数组一一对应,如果A[i]*F[i]>SUM,K-=A[i]-SUM/F[i],看K最后是否小于0. 然后你就会发现其实只要

AtCoder Beginner Contest 102

A - Multiple of 2 and N Time Limit: 2 sec / Memory Limit: 1024 MB Score : 100100 points Problem Statement You are given a positive integer NN. Find the minimum positive integer divisible by both 22 and NN. Constraints 1≤N≤1091≤N≤109 All values in inp