cf 906A Shockers

C300 | 5680t | 新格林| AN5516 | 远程ONU升级指导 ONU的远程管理升级 1、ZTE C300 OLT : 1.1 环境拓扑: PC1(filezilla server)------(uplink_default-vlanID)OLT---------ONU | | mng1 1.2 配置部署: 1):PC1(filezilla server): IP:192.168.88.252 255.255.255.0 配置FTP-Server的用户名:gp... 阅读详情

一 原题

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;
}


Silvaco TCAD | 从极化效应到高频开关:GaN HEMT仿真设计与性能验证 本文深入探讨了使用Silvaco TCAD进行GaN HEMT仿真设计与性能验证的关键技术。从极化效应到高频开关特性,详细解析了2DEG形成机制、器件结构设计优化及高频特性仿真技巧,帮助工程师提升GaN HEMT的性能与可靠性。通过实战案例展示了如何通过仿真优化击穿电压和导通电阻,实现开关品质因数的显著提升。 阅读详情

相关推荐

告别CAPL编程!用Matlab/Simulink+CANoe实现复杂ECU仿真的5个技巧

本文介绍了如何利用Matlab/Simulink与CANoe进行联合仿真,以替代复杂的CAPL编程,高效实现复杂ECU仿真。文章分享了5个核心技巧,涵盖信号映射、模型编译集成、实时参数调整、性能优化及数据分析,帮助算法工程师构建稳定强大的仿真环境,显著提升开发与测试效率。

rgv234567的博客 296

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

XILINX偶然加载不成功的问题原因及解决方法

本文为明德扬原创文章,转载请注明出处! 一、项目背景 明德扬(MDY)在2021年承担了多个基于XILINX芯片的研发项目,包括VPX网络透明传输项目(芯片为XC7K325T-2FBG900)、某高端测试仪项目(芯片为XCKU060-FFVA1156)、某网闸设备项目(芯片为XC7Z030-FBG676)等,另外,明德扬自研了基于XC7K325T-2FBG900和基于XC7K410T-2FBG900芯片的核心板,在XILINX研发领域拥有丰富的经验。即使拥有丰富经验和积累,每个新项目我们均...

6036

906A - Shockers

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

memory_qianxiao的博客 476

STM32F411CEU6实战:用W25Q64存储多张图片,在240x240 LCD上轮播显示(附源码)

本文详细介绍了如何使用STM32F411CEU6通过SPI接口管理W25Q64 Flash中的多张图片,并在240x240 LCD上实现平滑轮播显示。内容涵盖硬件配置、图片存储方案设计、轮播系统实现及性能优化技巧,特别针对SPI传输优化和多图存储管理提供了实用解决方案。附源码,适合嵌入式开发者参考。

weixin_32025789的博客 309

Latex下使用JabRef添加参考文献

文章目录 前言 一、pandas是什么? 二、使用步骤 1.引入库 2.读入数据 总结 前言 Latex可以手动添加参考文献,但文献过多时,使用JabRef软件相对方便。 提示:以下是本篇文章正文内容,下面案例可供参考 一、JabRef安装 网址:http://www.jabref.org 打开网址后,点击“Download” 进入如下页面后,选择 portable (便携版,无需安装),下载后是一压缩包,打开即可使用。 二、使用 1.创建库 ...

sz3076799的博客 3467

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

用Python玩转Milvus:从安装SDK到完成第一个向量搜索Demo

本文为Python开发者提供了一份详细的Milvus向量数据库实战指南。文章重点讲解了如何规避版本兼容性陷阱,正确部署Milvus服务端并安装匹配的Python SDK。通过一个电影推荐系统的完整案例,演示了从数据建模、集合创建、向量插入、索引构建到执行混合搜索的全流程,帮助开发者快速上手并完成第一个向量搜索Demo。

weixin_29239279的博客 192

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

第55篇:数据隐私保护技术盘点——差分隐私、同态加密与它们的坑(踩坑总结)

数据隐私保护是AI工程化中必须严肃对待的课题。差分隐私和同态加密是两把利器,但也都是“重武器”,使用不当反而会伤及自身。差分隐私像“模糊处理”,通过加噪来保证统计安全性,要小心管理隐私预算和效用权衡。同态加密像“保险箱里打算盘”,保证了计算的精确性,但必须承受巨大的性能和工程复杂度代价。我的建议是:从小规模实验开始,先用DP-SGD在MNIST/CIFAR-10等标准数据集上感受噪声与精度的关系;再用TenSEAL等易用的库尝试一个加密逻辑回归,体会密文膨胀和速度延迟。

ai_blue_pm的博客 281

国科大学习资料--人工智能原理与算法-2021年期末考试题解析(学长整理)

国科大学习资料–人工智能原理与算法-2021年期末考试题解析(学长整理) 国科大学习资料–人工智能原理与算法-2021年期末考试题解析(学长整理) 国科大学习资料–人工智能原理与算法-2021年期末考试题解析(学长整理) 根据学弟的反馈,该年的期末题只有5道,且均是作业题(所以大家一定要积极完成作业,考前多做几遍!!!!) 下面解析: 3.25 由于该题,我没有做过,所以只能给你英文版的答案。答案如下,其他的题目答案都是中文版。 5.9 8.10 12.20 15.13 ...

无名何许人的博客 3980

【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

MZI and MI Optical Waveguide(马赫曾德与迈克尔逊光波导)

注意,这里的 “镜子” 并不是真的在波导中做一个镜子出来,而是通过使用一个 1x2 的 MMI 结构将 MMI 输出的两个端口连接起来形成一个 “宽带镜子”。对于这里形成镜子的详细原理,后面有时间了我们再做更加详细地介绍。,它由一个 splitter 构成和两个仿佛带有 “镜子” 的臂组成。相比较于 MZI,光波可以在它的臂中传输,最终从进光口处出去得到相长或者相消干涉,很明显,在。)的折射率,从而使得两个臂上产生的相位差值不同,最终得到相长或者相消干涉的结果。这里,给大家介绍一下。,它更像是一个折叠的。

u011699626的博客 2454

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

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

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

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

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、付费专栏及课程。

余额充值