Codeforces Round #487 (Div. 2)

比赛链接

http://codeforces.com/contest/989

吐槽?

公告写的好,故事写的好啊。

两题滚粗,凭借着手速与hack +1:-1成功涨了一波rating……还是我太菜了。

下面只有ABC三题题解,想找DE题解的dalao可以换一篇了,为了保持良好的阅读体验,代码都放在最后面。

A. A Blend of Springtime

题目大意

在一个nn个格子的数轴上,有ABC三种花,每种花凋落后,花瓣就会飘到自己这个格子和相邻的两个格子上,问有没有可能三种花的花瓣飘在同一个格子上。

n100n≤100

题解

只要相邻的3个格子以任意顺序出现ABC三种花,就有可能满足题目要求。

B. A Tide of Riverscape

题目大意

一个长度为nn的01串SS满足下面条件就合法:

对于所有的i[1,np]i∈[1,n−p]Si=Si+pSi=Si+p

现在给出一个01串,一些字符没有确定,用.表示,求如果把.用01补全,是否存在一种方案使得这个串合法, 如果存在输出一组可行解,不存在输出No。

1pn20001≤p≤n≤2000,这个串必须存在”.”字符。

题解

枚举ii,比较SiSiSi+pSi+p,如果:

一边是0,一边是1:其他随便填。

一边是.,另一边是其他的:把.改成与另一边不一样的字符,其他随便填。

两边是.:改成一边是0,一边是1,其他随便填。

两边都是0或都是1:跳过不管。

C. A Mist of Florescence

题目大意

在一个二维平面上有四种颜色ABCD,给出每种颜色四连通块的数量,构造一个满足条件的二维平面。

设构造出的二维平面大小为n×mn×m,要求n,m50n,m≤50

ABCD颜色的连通块数量100≤100

题解

我的想法是首先每种颜色占用8×508×50的块,然后对于每个块,向里面填充成类似下面这样:

ABABABAB...
AAAAAAAA...
ABABABAB...
AAAAAAAA...
...

代码

A. A Blend of Springtime

#include <cstdio>
#include <cstring>

const int maxn=100;

char s[maxn+10];
int n;

int check(int p)
{
  for(char ch='A'; ch<='C'; ++ch)
    {
      int flag=0;
      for(int i=p-1; i<=p+1; ++i)
        {
          if(s[i]==ch)
            {
              flag=1;
              break;
            }
        }
      if(flag==0)
        {
          return 0;
        }
    }
  return 1;
}

int main()
{
  scanf("%s",s+1);
  n=strlen(s+1);
  for(int i=2; i<n; ++i)
    {
      if(check(i))
        {
          puts("Yes");
          return 0;
        }
    }
  puts("No");
  return 0;
}

B. A Tide of Riverscape

#include <cstdio>

const int maxn=2000;

char s[maxn+10];
int n,p,ans[maxn+10];

int main()
{
  scanf("%d%d",&n,&p);
  scanf("%s",s+1);
  for(int i=1; i<=n; ++i)
    {
      if(s[i]=='.')
        {
          ans[i]=-1;
        }
      else
        {
          ans[i]=s[i]-'0';
        }
    }
  int fl=1;
  for(int i=1; i<=n-p; ++i)
    {
      if((ans[i]==-1)&&(ans[i+p]==-1))
        {
          ans[i]=0;
          ans[i+p]=1;
        }
      else if((ans[i]==-1)&&(ans[i+p]!=-1))
        {
          ans[i]=1-ans[i+p];
        }
      else if((ans[i]!=-1)&&(ans[i+p]==-1))
        {
          ans[i+p]=1-ans[i];
        }
      if(ans[i]!=ans[i+p])
        {
          fl=0;
          break;
        }
    }
  if(fl)
    {
      puts("No");
      return 0;
    }
  for(int i=1; i<=n; ++i)
    {
      if(ans[i]==-1)
        {
          ans[i]=0;
        }
      printf("%d",ans[i]);
    }
  puts("");
  return 0;
}

C. A Mist of Florescence

#include <cstdio>
#include <algorithm>

const int maxn=50;
const int opp[]={0,3,4,1,2};
const int st[5][5]={{0,0,0,0,0},
                    {0,1,3,5,7},
                    {0,9,11,13,15},
                    {0,17,19,21,23},
                    {0,25,27,29,31}};

int n,m,ans[maxn+10][maxn+10],a[5];

int main()
{
  scanf("%d%d%d%d",&a[1],&a[2],&a[3],&a[4]);
  for(int k=1; k<=4; ++k)
    {
      for(int i=1; i<=maxn; ++i)
        {
          for(int j=1; j<=8; ++j)
            {
              ans[j+8*(k-1)][i]=k;
            }
        }
    }
  for(int i=1; i<=4; ++i)
    {
      --a[opp[i]];
      for(int k=1; k<=4; ++k)
        {
          for(int j=1; j<=std::min(25,a[opp[i]]); ++j)
            {
              ans[st[i][k]][j<<1]=opp[i];
            }
          a[opp[i]]-=25;
        }
    }
  printf("%d %d\n",32,maxn);
  for(int i=1; i<=32; ++i)
    {
      for(int j=1; j<=50; ++j)
        {
          putchar(ans[i][j]+'A'-1);
        }
      puts("");
    }
  return 0;
}

转载于:https://www.cnblogs.com/Canopus-wym/p/10376164.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值