A1035 Password (20)
摘要
Title: A1035 Password (20)
Tag: 字符串
Memory Limit: 64 MB
Time Limit: 1000 ms
Powered by:NEFU AB-IN
A1035 Password (20)
-
题意
To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords since it is hard to distinguish 1 (one) from l (L in lowercase), or 0 (zero) from O (o in uppercase). One solution is to replace 1 (one) by @, 0 (zero) by %, l by L, and O by o. Now it is your job to write a program to check the accounts generated by the judge, and to help the juge modify the confusing passwords.
-
思路
用map记录映射关系,按题修改字符串即可
-
代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63/*
* @Author: NEFU AB-IN
* @Date: 2023-01-08 18:49:01
* @FilePath: \GPLT\A1035\A1035.cpp
* @LastEditTime: 2023-01-08 18:49:25
*/
using namespace std;
typedef pair<int, int> PII;
const int N = 1e5 + 10, INF = 0x3f3f3f3f;
struct sa
{
string id, word;
};
unordered_map<char, char> mp = {{'1', '@'}, {'0', '%'}, {'l', 'L'}, {'O', 'o'}};
vector<sa> v;
signed main()
{
int n;
cin >> n;
for (int i = 0; i < n; ++i)
{
string id, word;
cin >> id >> word;
int flag = 0;
for (int i = 0; i < SZ(word); ++i)
{
if (mp.count(word[i]))
{
word[i] = mp[word[i]];
flag = 1;
}
}
if (flag)
v.push_back({id, word});
}
if (SZ(v))
{
cout << SZ(v) << '\n';
for (auto [id, word] : v)
cout << id << " " << word << '\n';
}
else
{
if (n > 1)
printf("There are %lld accounts and no account is modified", n);
else
printf("There is 1 account and no account is modified");
}
return 0;
}