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& ...
随机推荐
- pandas 对数据帧DataFrame中数据的增删、补全及转换操作
1.创建数据帧 import pandas as pd df = pd.DataFrame([[1, 'A', '3%' ], [2, 'B'], [3, 'C', '5%']], index=['r ...
- Notepad++ 安装连接服务器的NppFTP插件
用Notepad++连接服务器,可以随时编辑一些文件不用特意下载.有时重做系统经常忘记一些插件备份到了哪.再此做个记录,方便重新安装. 下载完NppFTP插件,解压后将bin文件夹下的NppFTP.d ...
- 中国.NET:各地微软技术俱乐部汇总(更新中...)
与微软技术的发展历程相似,微软俱乐部的发展同样经历着沉沉浮浮.2002年周庆麒先生创办的著名Office技术论坛Excel Home的上线,各种线上技术社区在中国的互联网世界中萌发.接着以鞠海洋(广州 ...
- LogUtil【实现自由的控制日志的打印的封装类】
版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 主要用于控制项目开发和上线阶段日志的打印. 效果图 暂不需要. 代码分析 在LogUtil类中声明代表不同日志级别的常量值(VERB ...
- FragmentTabHostTopDemo【FragmentTabHost固定宽度且居中】
版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 使用FragmentTabHost实现顶部选项卡(居中且宽度非全屏)展现. 备注:该Demo主要是演示FragmentTabHost ...
- [深度概念]·K-Fold 交叉验证 (Cross-Validation)的理解与应用
K-Fold 交叉验证 (Cross-Validation)的理解与应用 我的网站 1.K-Fold 交叉验证概念 在机器学习建模过程中,通行的做法通常是将数据分为训练集和测试集.测试集是与训练独立的 ...
- 能够玩转BKY皮肤的 geek,有一半最后都成为了前端大师
By Conmajia March 9, 2018 剩下的那一半全部扑街了. 世纪之初,BKY那些花里胡哨的预设皮肤曾经让初识网络的懵懂学子雀跃不已. 然而以现在的审美眼光看来,这些带着一股子扑面而来 ...
- socket,模拟服务器、客户端通信
服务器代码: using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;u ...
- 69道Spring面试题和答案,简单明了无套路
目录 Spring 概述 依赖注入 Spring beans Spring注解 Spring数据访问 Spring面向切面编程(AOP) Spring MVC Spring 概述 1. 什么是spri ...
- 怎么从Linux服务器上下载超过4G的文件?
使用sz命令下载文件时,超过4G下载不了,如何下载呢? 本文介绍的方法是先对该文件进行拆分,拆分成多个小于4G的文件,然后分别下载,下载到本地后再进行合并或直接解压,具体操作如下: 1.分拆为多个文件 ...