What Kind of Friends Are You?(字符串匹配)
来源:互联网 发布:网络词 抓马什么梗 编辑:程序博客网 时间:2024/06/06 19:20
链接:http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5579
题意:给出一些字符串被回答的序列,要求在接下来的序列中,是否能够唯一确定字符串。
思路:用字符串匹配,用字符串来存储它的回答情况,回答了的直接加到相对应的字符串后面,没有回答到的,全部在字符串尾加‘0’,接下来给出的每一种情况,直接进行匹配即可。
代码:
#include <iostream>#include <cstring>#include <cstdio>#include <string>#include <map>#include <algorithm>using namespace std;char name[220][30];int vis[200];int main(){ int t; cin >> t; while(t--) { string value[200]; int n,q; cin >> n >> q; int c; cin >> c; for(int i=0; i<c; i++) scanf("%s",name[i]); for(int i=0; i<q; i++) { int m; cin >> m; memset(vis, 0 ,sizeof vis); for(int j=0; j<m; j++) { char s[30]; scanf("%s",s); for(int k=0; k<c; k++) { if(!strcmp(s,name[k])) { value[k]+='1'; vis[k] = 1; } } } for(int j=0; j < c; j++) { if(!vis[j]) value[j] += '0'; } } for(int i=0; i<n; i++) { string a; for(int j=0; j<q; j++) { char x; cin >> x; a += x; } int cnt = 0, k=0; for(int j=0; j<c; j++) { if(a == value[j]) { cnt++; k = j; } } if(cnt == 1) printf("%s\n",name[k]); else printf("Let's go to the library!!\n"); } } return 0;}
0 0
- What Kind of Friends Are You?(字符串匹配)
- What Kind of Friends Are You?
- What Kind of Friends Are You?
- What Kind of Friends Are You?
- ZOJ3960-What Kind of Friends Are You?
- What Kind of Friends Are You?
- ZOJ 3960 What Kind of Friends Are You?(哈希)
- zoj 3960 What Kind of Friends Are You?
- 浙江省赛 C What Kind of Friends Are You?
- 浙江省赛C题 What Kind of Friends Are You?
- zoj 3960 What Kind of Friends Are You?
- ZOJ 3960 What Kind of Friends Are You? 题解
- ZOJ 3960 What Kind of Friends Are You?【】
- ZOJ 3960What Kind of Friends Are You?
- zoj 3960 What Kind of Friends Are You?(map+哈希)
- ZOJ 3960 What Kind of Friends Are You?(STL map,状态压缩)
- 2017 浙江省赛 C What Kind of Friends Are You + D Let's Chat
- 17年浙江省省赛C-What Kind of Friends Are You?
- Spring整合JUnit【了解】【操作
- android开发问题1
- [炉石]2017杭州第五周实力赛记录
- Hibernate的命名查询(NamedQuery)
- mysql5.7 本地计算机上的mysql 服务启动后停止 的问题解决
- What Kind of Friends Are You?(字符串匹配)
- java的正则表达式
- JS中创建一个新的对象的方法
- Qt与WINDOWS图片相互转换
- Linux 开机启动 PHP 环境
- c++第五次实验
- 【LeetCode刷题记录】1.Two Sum解法与Hashmap的应用
- Win7 安装SSMS16.5 报无法建立到信任根颁发机构的证书链。(0x800B010A)
- 二、Solr配置中文分词器IKAnalyzer并配置业务域