Login Verification CodeForces - 928A (实现)
When registering in a social network, users are allowed to create their own convenient login to make it easier to share contacts, print it on business cards, etc.
Login is an arbitrary sequence of lower and uppercase latin letters, digits and underline symbols («_»). However, in order to decrease the number of frauds and user-inattention related issues, it is prohibited to register a login if it is similar with an already existing login. More precisely, two logins s and t are considered similar if we can transform s to t via a sequence of operations of the following types:
- transform lowercase letters to uppercase and vice versa;
- change letter «O» (uppercase latin letter) to digit «0» and vice versa;
- change digit «1» (one) to any letter among «l» (lowercase latin «L»), «I» (uppercase latin «i») and vice versa, or change one of these letters to other.
For example, logins «Codeforces» and «codef0rces» as well as «OO0OOO00O0OOO0O00OOO0OO_lol» and «OO0OOO0O00OOO0O00OO0OOO_1oI» are considered similar whereas «Codeforces» and «Code_forces» are not.
You're given a list of existing logins with no two similar amonst and a newly created user login. Check whether this new login is similar with any of the existing ones.
Input
The first line contains a non-empty string s consisting of lower and uppercase latin letters, digits and underline symbols («_») with length not exceeding 50 — the login itself.
The second line contains a single integer n (1 ≤ n ≤ 1 000) — the number of existing logins.
The next n lines describe the existing logins, following the same constraints as the user login (refer to the first line of the input). It's guaranteed that no two existing logins are similar.
Output
Print «Yes» (without quotes), if user can register via this login, i.e. none of the existing logins is similar with it.
Otherwise print «No» (without quotes).
Examples
1_wat
2
2_wat
wat_1
Yes
000
3
00
ooA
oOo
No
_i_
3
__i_
_1_
I
No
La0
3
2a0
La1
1a0
No
abc
1
aBc
No
0Lil
2
LIL0
0Ril
Yes
Note
In the second sample case the user wants to create a login consisting of three zeros. It's impossible due to collision with the third among the existing.
In the third sample case the new login is similar with the second one.
题意:
给你一个字符串str,和n个其他字符串x,
如果这n个字符串中有任意一个可以通过题目给的3种变换操作变成和str一样的字符串,就输出No,否则输出Yes。
思路:
把规则统一即可。
即把所有的字符串和str都执行以下操作。
,所有的大写字符变为小写字符。
所有的L,I,i,l,都变为1
所有的o,O,都变为0,
然后对于每一个字符串都直接比较和str是否相等,相等就是No即可。
注意细节被出错误即可。
见代码:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define rt return
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll powmod(ll a, ll b, ll MOD) {ll ans = ; while (b) {if (b % )ans = ans * a % MOD; a = a * a % MOD; b /= ;} return ans;}
inline void getInt(int* p);
const int maxn = ;
const int inf = 0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/ int main()
{
//freopen("D:\\common_text\\code_stream\\in.txt","r",stdin);
//freopen("D:\\common_text\\code_stream\\out.txt","w",stdout); string str;
gbtb;
cin >> str;
int n;
cin >> n;
int isok = ;
string temp;
int len = str.length();
rep(j, , len)
{
if (str[j] == 'O')
{
str[j] = '';
} else if (str[j] == 'o')
{
str[j] = '';
} else if (str[j] == 'l')
{
str[j] = '';
} else if (str[j] == 'L')
{
str[j] = '';
} else if (str[j] == 'i')
{
str[j] = '';
} else if (str[j] == 'I')
{
str[j] = '';
} else if (str[j] >= 'A' && str[j] <= 'Z')
{
str[j] += ('a' - 'A');
}
}
repd(i, , n)
{
cin >> temp;
int tlen = temp.length();
if (tlen == len)
{
rep(j, , tlen)
{
if (temp[j] == 'O')
{
temp[j] = '';
} else if (temp[j] == 'o')
{
temp[j] = '';
} else if (temp[j] == 'l')
{
temp[j] = '';
} else if (temp[j] == 'L')
{
temp[j] = '';
} else if (temp[j] == 'i')
{
temp[j] = '';
} else if (temp[j] == 'I')
{
temp[j] = '';
} else if (temp[j] >= 'A' && temp[j] <= 'Z')
{
temp[j] += ('a' - 'A');
}
}
if (temp == str)
{
isok = ;
}
}
} if (!isok)
{
cout << "Yes" << endl;
} else
{
cout << "No" << endl;
}
return ;
} inline void getInt(int* p) {
char ch;
do {
ch = getchar();
} while (ch == ' ' || ch == '\n');
if (ch == '-') {
*p = -(getchar() - '');
while ((ch = getchar()) >= '' && ch <= '') {
*p = *p * - ch + '';
}
}
else {
*p = ch - '';
while ((ch = getchar()) >= '' && ch <= '') {
*p = *p * + ch - '';
}
}
}
Login Verification CodeForces - 928A (实现)的更多相关文章
- asp.net mvc ClaimsIdentity 授权研究 (还是测试版 有bug)
安装 Microsoft.Owin.Host.SystemWeb Identity.Core Microsoft.Owin.Security.Cookies 在是startup.cs做如下修改 p ...
- CQRS学习——集成ASP.NET Identity[其五]
[其实和Cqrs没啥关系] 缘由 其实没啥原因,只是觉得以前写了不知多少遍的用户登录复用性太差,实现的功能也不多. 依赖的Nuget包 简单登陆 就简单登陆而言,只需要实现如下接口/抽象类: Stor ...
- Python基础-day01
写在前面 先后接触过很多编程语言,最喜欢的就是C和Python,相比其他语言,C 是神器,优点太多了:个人而言,C 最重要的一点就是能够让你在敲代码的时候是以一个计算机科学家的角度去思考,而不是仅仅停 ...
- asp.net Identity 设置自定义登录
添加Startup.Auth.cs public partial class Startup { // For more information on configuring authenticati ...
- SSM基于Token的登录认证
1.什么是token token的意思是“令牌”,是服务端生成的一串字符串,作为客户端进行请求的一个标识. 当用户第一次登录后,服务器生成一个token并将此token返回给客户端,以后客户端只需带上 ...
- 某宝抢购taobaosnap开发与实现
某宝抢购脚本 Taobaosnap Taobaosnap is a completely open tool, which is used to buy goods in seconds on Tao ...
- Codeforces Round #455 (Div. 2) A. Generate Login【贪心】
A. Generate Login time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- 主机宝(zhujibao) /a/apps/zhujibao/manager/apps/config/config.php no-password Login Vulnerabilities Based On Default cookie Verification From Default File
catalog . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述 主机宝管理程序使用了CodeIgniter框架,要想在CodeIgnit ...
- 【Codeforces Round #455 (Div. 2) A】Generate Login
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 枚举两个串的前缀长度就好. 组出来. 排序. 取字典序最小的那个. [代码] #include <bits/stdc++.h& ...
随机推荐
- Python存储系统(Redis)
存储系统数据缓存一般会使用三个模块:Mongodb,redis,memcache.其中memcache是轻量级缓存,只能将数据保存到内存中,redis可以配置数据保存在内存还是硬盘. 其主要用途有:不 ...
- PHP内核之旅-5.强大的数组
PHP 内核之旅系列 PHP内核之旅-1.生命周期 PHP内核之旅-2.SAPI中的Cli PHP内核之旅-3.变量 PHP内核之旅-4.字符串 PHP内核之旅-5.强大的数组 PHP内核之旅-6.垃 ...
- SDK测试实践
最近开始接SDK的测试项目,因为之前没有接触过,还是很新奇的,记录一下测试方法. 大家都知道SDK其实就是一个基础工具包,我的理解,对于安卓和IOS来说,SDK就是一个应用程序的基础包,在SDK的基础 ...
- 04-创建kubeconfig认证文件
本文档记录自己的学习历程! 创建 kubeconfig 文件 kubelet.kube-proxy 等 Node 机器上的进程与 Master 机器的 kube-apiserver 进程通信时需要认证 ...
- fuzzing学习
1.简介 1.1 fuzzing 模糊测试(fuzzing)是一种通过向程序提供非预期的输入并监控输出中的异常来发现软件中的故障的方法. 用于模糊测试的模糊测试器(fuzzer)可以按照以下3种方式进 ...
- Flutter 即学即用系列博客——08 MethodChannel 实现 Flutter 与原生通信
背景 前面我们讲了很多 Flutter 相关的知识点,但是我们并没有介绍怎样实现 Flutter 与原生的通信. 比如我在 Flutter UI 上面点击了一个按钮,我希望原生做一些处理,那么原生怎么 ...
- CAD.NET二次开发 新建图层 删除图层 指定图层颜色以及线形等
基于浩辰CAD 2019测试 功能实现 直接上代码: [CommandMethod("CreateAndAssignAlayer")] //新建图层 然后添加到图层表里 publi ...
- Java 插入附件到PDF文档
在文档中插入附件,可以起到与源文档配套使用的目的,以一种更简便的方式对文档起到补充说明的作用.下面将介绍通过Java编程插入附件到PDF文档中的方法.这里插入的文档可以是常见的文档类型,如Word.E ...
- Django之路由分发和反向解析
一.路由分发: 路由分发是指:总路由不再直接做路由与视图函数的对应关系,而是将获取的路由分发给下面的app去处理对应关系 from django.conf.urls import url,includ ...
- Spring+MyBatis整合过程
步骤: 1.引入Spring+MyBatis开发包 >spring(ioc aop dao)开发包 >mybatis开发包,dbcp,驱动包 >mybatis-spring.jar整 ...