Codeforces Round #454 (Div. 2)

传送门:http://codeforces.com/contest/907

A. Masha and Bears

题意:神坑的一道题。比赛的时候wa到怀疑人生w(゚Д゚)w。
Masha came to test these cars. She could climb into all cars, but she liked only the smallest car.
玛莎帮熊爸熊妈和孩子挑车,已知熊爸熊妈熊孩子和玛莎的尺寸,挑出三辆车,使三人都喜欢自己的车,Masha只喜欢最小的车,中车大车都不喜。2*size(masha)< size(中车)。

#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<map>
#include<cstdlib>
using namespace std;
typedef double db;
typedef long long ll;
const int MAXN = 200005;
int main ()
{
    //yyy_3y
   // freopen("1.in","r",stdin);
    int v1,v2,v3,v4; cin >>v1>>v2>>v3>>v4;

    if (vm > 2*v3 || vm > v2) cout <<-1<<endl;
    else {
        cout <<v1*2<<endl<<v2*2<<endl<<min(v3,v4)<<endl;
    }
}

B. Tic-Tac-Toe

题意:有一个9×9大小的方格,可以将其看作一个由9个3×3方格组成的大3×3方格,给定一个起始坐标,求出其所在的3×3方格内的坐标,填充该坐标所对应的大3×3方格内所有空白处,如果该区域内没有空白,则填充9×9方格内所有空白处。

思路:根据相对位置求出在3×3中位置。然后在3×3中搜一下,看看是不是都满,如果都满了,那么就填满9×9,否则就填满当前3×3。注意读入和输出。

#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<map>
#include<cstdlib>
using namespace std;
typedef double db;
typedef long long ll;
const int MAXN = 20;
char s[MAXN][MAXN];
char b[MAXN][MAXN];
int x,y;
int main ()
{
    //yyy_3y
   // freopen("1.in","r",stdin);
    for (int i=1;i<=9;i++){
        scanf("%s",s[i]+1);
        scanf("%s",s[i]+4);
        scanf("%s",s[i]+7);
        for (int j=1;j<=9;j++){
            b[i][j]=s[i][j];
        }
    }

    scanf("%d%d",&x,&y);
    int cnt = 0;
    while(x>3) x-=3;
    while(y>3) y-=3;
    int p =(x-1)*3+1;
    int q =(y-1)*3+1;
    for(int i=p;i<=p+2;i++)
        for(int j=q;j<=q+2;j++)
            if(s[i][j]=='.') {
                cnt++;
                s[i][j]='!';
            }
    if (!cnt){
        for (int i=1;i<=9;i++)
            for(int j=1;j<=9;j++)
             if(s[i][j]=='.') s[i][j]='!';
    }
    for (int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
                printf("%c",s[i][j]);
                if(j==3||j==6) printf(" ");
            }
        if (i==3||i==6) printf("\n");
        printf("\n");
    }
}

C. Shockers

题意:游戏初始选定一个字母,选手猜这个字母。
三种情况:
“. word”:选手说出的单词中不包含该字母
“! word”:选手说出的单词中包含该字母
“? letter”:选手猜了某一个字母,这个行为只在最后一次是正确的
在最后一次之前,每有一个’!’或’?’,选手都会被电一次。

当答案能唯一确定的时起,到最后有多少个!和?。(相当于能避免被点多少次,因为他已经知道准确的字母)

#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<map>
#include<cstdlib>
using namespace std;
typedef double db;
typedef long long ll;
int c[1000],lo[1000];
int x,y;
int main ()
{
    //yyy_3y
   //freopen("1.in","r",stdin);
    int n;scanf("%d",&n);
    int ans=0,num=26;
    bool flag=false;
    for(int i='a';i<='z';i++)c[i]=1;
    for(int i=1;i<=n;i++){
        char op; string s;
        cin >>op>>s;
        if(flag){
            if(i!=n) if(op=='!'||op=='?') ans++;
        }
        else {
            if(op=='!'){
                memset(lo,0,sizeof(lo));
                for(int j=0;j<s.length();j++)  lo[s[j]]=1;
                for(int j='a';j<='z';j++) {
                    if(c[j]&&!lo[j]) c[j]=0,num--;
                }
            }
            else if(op=='.'){
                for(int j=0;j<s.length();j++) if(c[s[j]]) c[s[j]]=0,num--;
            }
            else {
                if(c[s[0]]) c[s[0]]=0,num--;
            }
            if(num==1) flag=true;
        }
    }
    printf("%d\n",ans);

}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值