Codeforces Round #454 (Div. 2)

这是一场打得很一般的比赛qwq
但是还是记一下吧。。
顺便膜一下cqz大佬打到rk4….

比赛链接

A. Masha and Bears

题意:

给出a,b,c,x,要求A,B,C,满足:
a<=A<=2a
b<=B<=2b
c<=C<=2c
x<=C<=2x
2x

做法:

直接暴力枚举吧。

代码:

#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;

int a, b, c, x;

int main()
{
    scanf("%d%d%d%d", &a, &b, &c, &x);
    for(int A = a; A <= 2*a; A ++)
        for(int B = b; B <= 2*b; B ++)
            for(int C = c; C <= 2*c; C ++) {
                if(A > B && B > C && C <= 2*x && C >= x && 2*x < B) {
                    printf("%d\n%d\n%d\n", A, B, C);
                    return 0;
                }
            }
    puts("-1");
    return 0;
}

B. Tic-Tac-Toe

题意:

给一个9×9的方格,有一些格子被占用了,占用的格子不能走。可以看成3×3个九宫格。
现在给出上一步的格子,规定下一步只能走3×3个九宫格中的一个,而这个九宫格在整个棋盘的相对位置和上一步的格子所在的九宫格的相对位置是一样的。
假如那个九宫格全都被占用了,就可以选任意空着的格子。
现在你要把可以选的格子都变成感叹号。
qwq听不懂自己看样例。

做法:

题面讲了那么多做法却很sb。。
直接模拟。。。

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

char a[15][5][5];
int x, y;

int main()
{
    for(int i = 1; i <= 9; i ++)
        for(int j = 1; j <= 3; j ++) scanf("%s", a[i][j]+1);
    scanf("%d%d", &x, &y);
    while(x-3 > 0) x -= 3;
    while(y-3 > 0) y -= 3;
    int cnt = 0;
    for(int i = (x-1)*3+1; i <= x*3; i ++) {
        for(int j = 1; j <= 3; j ++)
            if(a[i][y][j] != '.') cnt ++;
    }
    if(cnt == 9) {
        for(int i = 1; i <= 9; i ++)
            for(int j = 1; j <= 3; j ++)
                for(int k = 1; k <= 3; k ++) if(a[i][j][k] == '.') a[i][j][k] = '!';
    } else {
        for(int i = (x-1)*3+1; i <= x*3; i ++) {
            for(int j = 1; j <= 3; j ++)
                if(a[i][y][j] == '.') a[i][y][j] = '!';
        }
    }
    for(int i = 1; i <= 9; i ++) {
        for(int j = 1; j <= 3; j ++) printf("%s", a[i][j]+1), putchar(' ');
        puts("");
        if(i%3 == 0) puts("");
    }
    return 0;
}

C. Shockers

题意:

现在要在26个字母中猜一个字母。
有n个操作,分为三种,
! s 表示s串中有这个字母,并且会遭受一次电击。
. s 表示s串中没有这个字母。
? s 会遭收一次电击,但假如s=这个字母就不会遭受电击。
现在你可以通过!和.操作推断出这个字母是什么。
你需要求出在可以确定这个字母后还会遭受多少电击。

做法:

维护一个二进制数或者一个bool数组就可以了。大模拟。

代码:

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

int n, cnt = 26, clk;
char s[100010];
int a[30], b[30];

int main()
{
    scanf("%d", &n); int ans = 0, ch = 0;
    for(int i = 0; i < 26; i ++) a[i] = 1;
    for(int T = 1; T <= n; T ++) {
        char opt[5]; scanf("%s%s", opt, s+1);
        int l = strlen(s+1);
        if(opt[0] == '!') {
            if(cnt == 1) ans ++;
            memset(b, 0, sizeof b);
            for(int i = 1; i <= l; i ++) b[s[i]-'a'] = 1;
            for(int i = 0; i < 26; i ++)
                if(!b[i] && a[i]) a[i] = 0, cnt --;
        } else if(opt[0] == '.') {
            for(int i = 1; i <= l; i ++) {
                if(a[s[i]-'a'] == 1) cnt --;
                a[s[i]-'a'] = 0;
            }
        } else {
            if(cnt == 1 && T < n) ans ++;
            if(a[s[1]-'a']) a[s[1]-'a'] = 0, cnt --;
        }
    }
    printf("%d\n", ans);
    return 0;
}

总结:

比赛时通过ABC,Rank 502,rating+30。
不得不吐嘈cf的题意真是恶心= =
一堆大佬过了F膜一发。。。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值