1035 Password
Statement
Metadata
- 作者: CHEN, Yue
- 单位: 浙江大学
- 代码长度限制: 16 KB
- 时间限制: 400 ms
- 内存限制: 64 MB
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.
Input Specification
Each input file contains one test case. Each case contains a positive integer
Output Specification
For each test case, first print the number There are N accounts and no account is modified
where N
is the total number of accounts. However, if N
is one, you must print There is 1 account and no account is modified
instead.
Sample Input 1
Sample Output 1
Sample Input 2
Sample Output 2
Sample Input 3
Sample Output 3
Solution
#include <bits/stdc++.h>
using namespace std;
#define MAXN 1000
struct pp {
string s1, s2;
} a[MAXN];
int main() {
int n, i, j, total = 0, len, flag;
cin >> n;
string s1, s2;
map<char, char> q;
q['1'] = '@', q['0'] = '%', q['l'] = 'L', q['O'] = 'o';
for (i = 0; i < n; i++) {
flag = 0;
cin >> s1 >> s2;
len = s2.size();
for (j = 0; j < len; j++) {
if (s2[j] == '1' || s2[j] == '0' || s2[j] == 'l' || s2[j] == 'O') {
flag = 1;
s2[j] = q[s2[j]];
}
}
if (flag) {
a[total].s1 = s1, a[total].s2 = s2;
total++;
}
}
if (total) {
cout << total << endl;
for (i = 0; i < total; i++) cout << a[i].s1 << " " << a[i].s2 << endl;
} else if (n == 1)
printf("There is 1 account and no account is modified\n");
else if (n > 1)
printf("There are %d accounts and no account is modified\n", n);
}