cf 906A Shockers

SAP 移动类型简述 SAP系统中用于标志物料移动(收货/发货/转储/转储记帐)的三位的数字/字母 通常分几大类:收货 发货 转储 库房调整 常用的有: 收货类 (MB1C) 101 采购订单收货 103 采购订单收货至冻结状态 122 无采购订单退货 161 按退货采购订单退货 131 从生产订单 501 无采购订单收货 511 免费收货 发货类(MB1A) 201 成本中心消耗 阅读详情

一 原题

C. Shockers
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Valentin participates in a show called "Shockers". The rules are quite easy: jury selects one letter which Valentin doesn't know. He should make a small speech, but every time he pronounces a word that contains the selected letter, he receives an electric shock. He can make guesses which letter is selected, but for each incorrect guess he receives an electric shock too. The show ends when Valentin guesses the selected letter correctly.

Valentin can't keep in mind everything, so he could guess the selected letter much later than it can be uniquely determined and get excessive electric shocks. Excessive electric shocks are those which Valentin got after the moment the selected letter can be uniquely determined. You should find out the number of excessive electric shocks.

Input

The first line contains a single integer n (1 ≤ n ≤ 105) — the number of actions Valentin did.

The next n lines contain descriptions of his actions, each line contains description of one action. Each action can be of one of three types:

  1. Valentin pronounced some word and didn't get an electric shock. This action is described by the string ". w" (without quotes), in which "." is a dot (ASCII-code 46), and w is the word that Valentin said.
  2. Valentin pronounced some word and got an electric shock. This action is described by the string "! w" (without quotes), in which "!" is an exclamation mark (ASCII-code 33), and w is the word that Valentin said.
  3. Valentin made a guess about the selected letter. This action is described by the string "? s" (without quotes), in which "?" is a question mark (ASCII-code 63), and s is the guess — a lowercase English letter.

All words consist only of lowercase English letters. The total length of all words does not exceed 105.

It is guaranteed that last action is a guess about the selected letter. Also, it is guaranteed that Valentin didn't make correct guesses about the selected letter before the last action. Moreover, it's guaranteed that if Valentin got an electric shock after pronouncing some word, then it contains the selected letter; and also if Valentin didn't get an electric shock after pronouncing some word, then it does not contain the selected letter.

Output

Output a single integer — the number of electric shocks that Valentin could have avoided if he had told the selected letter just after it became uniquely determined.

Examples
input
5
! abc
. ad
. b
! cd
? c
output
1
input
8
! hello
! codeforces
? c
. o
? d
? h
. l
? e
output
2
input
7
! ababahalamaha
? a
? b
? a
? b
? a
? h
output
0
Note

In the first test case after the first action it becomes clear that the selected letter is one of the following: a, b, c. After the second action we can note that the selected letter is not a. Valentin tells word "b" and doesn't get a shock. After that it is clear that the selected letter is c, but Valentin pronounces the word cd and gets an excessive electric shock.

In the second test case after the first two electric shocks we understand that the selected letter is e or o. Valentin tries some words consisting of these letters and after the second word it's clear that the selected letter is e, but Valentin makes 3 more actions before he makes a correct hypothesis.

In the third example the selected letter can be uniquely determined only when Valentin guesses it, so he didn't get excessive electric shocks.


二 分析

事先设定一个小写字母c作为答案,你每次可以:1)说出一个字符串,如果字符串包含c,则被shock一次;2)说出你认为是c的一个字母,如果猜错,被shock一次。输入保证最后一次一定是行为2),且猜测正确。

问有多少次shock是不必要的,即c已经唯一确定,但你还被shock了。。简单模拟,之前不知道c++还可以写range-based loop,原来c++11就引入了。。


三 代码

运行结果:
LANG: GNU C++14
Verdict: Accepted

AC代码:
#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;

// #define LOCAL

enum State {
    unknown, safe
};

char c;
string s;
State state[26];
bool appear[26], sure = false;
int n, ans;

inline void check() {
    if(sure) {
        return;
    }
    int cnt = 0;
    for(int i = 0; i < 26; i++) {
        if(state[i] == unknown) {
            cnt++;
        }
    }
    if(cnt == 1) {
        sure = true;
    }
}

int main() {
    #ifdef LOCAL
    freopen("1.in", "r", stdin);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    cin >> n;
    while(n--) {
        cin >> c >> s;
        if(c == '.') {
            for(char cc: s) {
                state[cc - 'a'] = safe;
            }
        }
        else if(c == '?') {
            if(sure && n != 0) {
                ans++;
            }
            else {
                state[s[0] - 'a'] = safe;
            }
        }
        else {
            if(sure) {
                ans++;
            }
            else {
                memset(appear, 0, sizeof(appear));
                for(char cc: s) {
                    appear[cc - 'a'] = true;
                }
                for(int i = 0; i < 26; i++) {
                    if(!appear[i]) {
                        state[i] = safe;
                    }
                }
            }
        }
        check();
    }
    cout << ans << endl;
    return 0;
}


密码学与信息安全面试题及参考答案(2万字长文) 密码学是一门研究信息安全的学科,它涉及加密、解密以及保护数据免受非授权访问的技术和方法。这门学科的核心在于设计并分析各种协议,使通信双方即使在存在潜在敌手的环境中也能安全地传输信息。保密性:确保信息只能被预期的接收方读取,阻止未经授权的第三方获取信息的真实内容。完整性:保证数据在传输过程中不被篡改,确保接收方接收到的信息与发送方发送的信息完全一致。认证性:验证信息的来源,即确认信息确实是由声称的发送方发出的。不可否认性:确保发送方不能在事后否认曾经发送过某条信息。访问控制。 阅读详情

相关推荐

2021.11.23 Covins 多机器人单目协同建图 跑Euroc数据集 更新

近日,一直在调试如何使用Covins跑通数据集,因为是初学者,所以很多bug出来的时候原理都不懂,只能复制——百度——尝试解决的过程。 现分享一下近日的结果以及与Covins作者帮助解答的一些问题。 使用代码行跑依次跑Euroc多数据集 这里的意思是使用作者提供的covins_examples文件夹中的euroc_examples_mh123_vigba.sh文件,这个文件是将三个Euroc数据集依次运行,跑完第一个数据集,第二个数据集运行的时候在第一个数据集生成地图的基础上继续绘制,由于我只下载了两个数据

qq_42614598的博客 2475

Codeforces 906A Shockers (模拟)

  A. Shockers time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Valentin participates in a show called "Shockers". The rules are q...

知与谁i的博客 655

使用Termux在Android设备上编译运行SpecCPU2006

SPEC2006搭配Termux,竟然还能这么玩?!

菜菜的菜园子 2960

906A - Shockers

题意:题意不是很好懂,一个人参加演讲活动,每次说出一句话,最后找出那个非法字符,如果说的话里有非法字符,就要遭受电击,如果确定了那个非法字符,然后猜了其他字母也要电击。!代表说的话里有非法字母,.代表说的话里没有非法子母,?代表每次猜的字母,每次猜一个。让我们求出这个人遭受的电击。 题解: 模拟,就是思路一定要清晰,在某个时刻一定能够唯一确定那个非法字母,不然会晕的。花了很多时间,才彻底弄懂的。

memory_qianxiao的博客 476

RV1106G3的AOV下的yolov5调试记录

本文介绍了基于LuckFoxPicoMax开发板的RV1106芯片调试经验,重点包括AOV(Always-On Vision)和Yolov5目标检测的实现。在硬件方面,板载1TOPS NPU、256MB内存,并更换为SPI NOR存储。软件调试涉及MK配置文件修改、设备树调整(按键唤醒和sensor配置)以及程序自启动设置。Yolov5模型优化为320*320尺寸,推理时间约45ms。系统采用VI采图与AI识别通过共享内存通信的方案,实测功耗在20-35mA范围。文章还指出了当前存在的功耗优化、ISP调试等

fzktongyong的博客 1715

【深度学习】tensorboard中的图片放到论文中

1. 利用tensorboard中的导出数据功能 选中左上角的标签,然后选择csv格式的数据下载即可。 左边的smoothing 数值不影响导出数据的大小。 2.tensorboard 图下标签介绍: 放大 Toggle y-axis log scale:将y轴对数化 Fit domain to data:如果拖动了图片等,再重新回到原始位置 Download Current Chart as SVG 3.用下载下来的csv数据来画图 第一幅图片:训练的平均长度 fig, ax1 = plt.sub

gaocui883的博客 1万+

Codeforces Round #454 - Div. 1 - (A)

A. Shockers time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Valentin participates in a show called "Shocker

Orz 390

华为手环实时心率数据导出到UWP项目中

hello大家好呀O(∩_∩)O最近在做毕设 其中有个小功能要用到实时心率数据。查找网上的资料发现只有小米手环的实时心率数据导出但是没有华为手环的,我试了华为手环但是并不能行得通哈哈哈。现在分享一下华为手环实时心率数据导出的代码。

apple_63713858的博客 1582

Codeforces Round #454 (Div. 2, based on Technocup 2018 Elimination Round 4) A-C

这套题有史以来做的最恶心的一套题,没有之一; A题,讲的不明不白的。到底是区间还是这4个数,没有说明白, 交了7遍 全都是WA on test 4;因为一直认为就是这4个数里面选择 ,恶心, 实际要求是在区间里选定某个值; 暴力枚举!!!!!!! A: A. Masha and Bears time limit per test 2 seconds ...

weixin_30244889的博客 178

基于TENG的呼吸测量与识别系统:从蓝牙到WiFi的改造与上位机实现

本文介绍了一种基于摩擦纳米发电机(TENG)的呼吸测量系统改造方案,将原有蓝牙通信升级为WiFi传输。系统通过TENG传感器采集呼吸信号,STM32微控制器处理数据后,经ESP8266 WiFi模块发送至上位机。文中详细阐述了硬件改造(四通道改单通道、蓝牙换WiFi)、嵌入式软件修改(包括ESP8266驱动、数据采集与TCP通信实现)以及上位机软件设计。改造后的系统提升了传输距离和稳定性,为可穿戴健康监测提供了更优解决方案。

huanghm88的专栏 110

手把手带你完成基于UNet的医学图像分割系统设计与实现,UNet网络架构讲解,UNet复现,使用vibe coding工具,开发一个完整系统,包含完整源码

哈喽,大家好,这里是落花不写码,本次教程讲一下 U-Net 分割篇,U-Net 它是一篇 2015 年发表的论文,那为什么到现在还需要讲呢?因为后续讲到 GAN、扩散模型时候是离不开 U-Net 架构的,所以今天先带大家使用 U-Net 模型完成一些图像分割。

在职AI算法工程师,擅长计算机视觉,YOLO目标检测、分割等,擅长web、pyqt界面可视化,好内容持续更新中,来这里跟大家一起学习,共同进步 871

【codeforces907C - Shockers】模拟

Valentin participates in a show called “Shockers”. The rules are quite easy: jury selects one letter which Valentin doesn’t know. He should make a small speech, but every time he pronounces a word that

Lesroad 531

基于STM32、HAL库的AD7124-8BCPZ模数转换器ADC驱动程序设计

/ 配置0: 使用内部参考电压(2.5V),增益128,双极性。// 配置通道0: AIN0+和AIN1-,使用配置0和滤波器0。// 100ms采样间隔。// 转换为电压值(使用内部2.5V参考电压)// 构造读命令: 最高位为1表示读,接下来7位是寄存器地址。// 构造写命令: 最高位为0表示写,接下来7位是寄存器地址。// 配置滤波器0: 输出数据率50Hz,后置滤波器4。

corlin6688的博客 529

Shockers (思维+模拟)

ShockersValentin participates in a show called "Shockers". The rules are quite easy: jury selects one letter which Valentin doesn't know. He should make a small speech, but every time he pronounces a ...

codeswarrior的博客 408

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

cf 923C Perfect Security

一 原题 C. Perfect Security time limit per test 3.5 seconds memory limit per test 512 megabytes input standard input output standard output Alice has a very important

max_kibble的博客 1497

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

cf 923B Producing Snow

一 原题 C. Producing Snow time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Alice likes snow a

max_kibble的博客 1336

cf 936B Sleepy Game

一 原题B. Sleepy Gametime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPetya and Vasya arranged a game. The game runs by the following rules. Players h...

max_kibble的博客 966

cf 997c Sky Full of Stars

一 原题E. Sky Full of Starstime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOn one of the planets of Solar system, in Atmosphere University, many stud...

max_kibble的博客 940

cf 1000c Covered Points Count

一 原题C. Covered Points Counttime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given nn segments on a coordinate line; each endpoint of every ...

max_kibble的博客 781

cf 982D Shark

一 原题D. Sharktime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFor long time scientists study the behavior of sharks. Sharks, as many other species, a...

max_kibble的博客 778

cf 933A A Twisty Movement

一 原题 A. A Twisty Movement time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output A dragon symbolizes wisdom, p

max_kibble的博客 684

cf 877D Olya and Energy Drinks

一 原题 D. Olya and Energy Drinks time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Olya loves energy drinks. S

max_kibble的博客 674

cf 1012B Chemical table

一 原题 D. Chemical table time limit per test: 1 second memory limit per test: 512 megabytes input: standard input output: standard output Innopolis University scientists continue to investigate th...

max_kibble的博客 667

cf 979D Kuro and GCD and XOR and SUM

一 原题D. Kuro and GCD and XOR and SUMtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputKuro is currently playing an educational game about numbers. Th...

max_kibble的博客 596

cf 985E Pencils and Boxes

一 原题E. Pencils and Boxestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMishka received a gift of multicolored pencils for his birthday! Unfortuna...

max_kibble的博客 559
上一篇: poj 1300 Door man
下一篇: usaco6.4.3 Wisconsin Squares
max_kibble
博客等级 码龄11年 2粉丝 110原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值