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列表的交、并、差集
#!/usr/bin/env python3 l1 = ['] l2 = ['] # 交集 result1 = [i for i in l1 if i in l2] result2 = list(se ...
- 试试自行封装AJAX和jQuery中的ajax封装的基本使用
封装的套路: 1.写一个相对比较完善的用例2.写一个空函数,没有形参,将刚刚的用例直接作为函数的函数体3.根据使用过程中的需求抽象函数 代码记录如下: <script> function ...
- Java数据结构和算法 - 链表
Q: 为什么要引入链表的概念?它是解决什么问题的? A: 数组作为数据存储结构有一定的缺陷,在无序数组中,搜索是低效的:而在有序数组中,插入效率又很低:不管在哪一个数组中删除效率都很低:况且一个数组创 ...
- ASP.NET Core 3.0 上的gRPC服务模板初体验(多图)
早就听说ASP.NET Core 3.0中引入了gRPC的服务模板,正好趁着家里电脑刚做了新系统,然后装了VS2019的功夫来体验一把.同时记录体验的过程.如果你也想按照本文的步骤体验的话,那你得先安 ...
- Fiddler原理~知多少?
首先我们学习Fidder这个工具,我们就应该去了解它的基本东西,比如这个单词的意思.Fiddler叫:小提琴.骗子的意思. 那么它是干什么的呢? Fiddler是一个http协议调试代理工具,它能够记 ...
- Kubernetes的污点和容忍(下篇)
背景 继上一篇<Kubernetes的污点和容忍(上篇)>,这是https://kubernetes.io/docs/concepts/configuration/taint-and-to ...
- springboot~集成测试里的redis
测试不应该访问外部资源 对于单元测试,集成测试里,如果被测试的方法中使用到了redis,你需要去模拟一个单机环境的redis server,因为只有这样,你的测试才是客观的,即不会因为网络和其它因素影 ...
- 学习ASP.NET Core Razor 编程系列十六——排序
学习ASP.NET Core Razor 编程系列目录 学习ASP.NET Core Razor 编程系列一 学习ASP.NET Core Razor 编程系列二——添加一个实体 学习ASP.NET ...
- 阿里 Java 手册系列教程:为啥强制子类、父类变量名不同?
摘要: 原创出处 https://www.bysocket.com 「公众号:泥瓦匠BYSocket 」欢迎关注和转载,保留摘要,谢谢! 目录 父子类变量名相同会咋样? 为啥强制子类.父类变量名不同? ...
- 痞子衡嵌入式:飞思卡尔i.MX RT系列MCU开发那些事 - 索引
大家好,我是痞子衡,是正经搞技术的痞子.本系列痞子衡给大家介绍的是飞思卡尔i.MX RT系列微控制器相关知识. 飞思卡尔半导体(现恩智浦半导体)于2017年开始推出的i.MX RT系列开启了高性能MC ...