标签:nod ever base ace team rac modify rds nbsp
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 replace1
(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.
Each input file contains one test case. Each case contains a positive integer N (≤1000), followed by N lines of accounts. Each account consists of a user name and a password, both are strings of no more than 10 characters with no space.
For each test case, first print the number M of accounts that have been modified, then print in the following M lines the modified accounts info, that is, the user names and the corresponding modified passwords. The accounts must be printed in the same order as they are read in. If no account is modified, print in one line 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.
3
Team000002 Rlsp0dfa
Team000003 perfectpwd
Team000001 R1spOdfa
2
Team000002 RLsp%dfa
Team000001 R@spodfa
1
team110 abcdefg332
There is 1 account and no account is modified
2
team110 abcdefg222
team220 abcdefg333
There are 2 accounts and no account is modified
1 #include <iostream> 2 #include <algorithm> 3 #include <cstdio> 4 #include <cstring> 5 #include <map> 6 #include <stack> 7 #include <vector> 8 #include <queue> 9 #include <set> 10 #define LL long long 11 using namespace std; 12 const int MAX = 20, MAXN = 1e3 + 10; 13 14 struct node 15 { 16 char s1[MAX], s2[MAX]; 17 }P[MAXN]; 18 char buf1[MAX], buf2[MAX]; 19 int n, cnt = 0; 20 map <char, char> mp; 21 22 23 bool is_ans() 24 { 25 bool flag = false; 26 int len = strlen(buf2); 27 for (int i = 0; i < len; ++ i) 28 { 29 if (mp.find(buf2[i]) != mp.end()) 30 { 31 buf2[i] = mp[buf2[i]]; 32 flag = true; 33 } 34 } 35 if (flag) return true; 36 return false; 37 } 38 39 int main() 40 { 41 // freopen("Date1.txt", "r", stdin); 42 mp[‘l‘] = ‘L‘, mp[‘O‘] = ‘o‘, mp[‘1‘] = ‘@‘, mp[‘0‘] = ‘%‘; 43 scanf("%d", &n); 44 for (int i = 1; i <= n; ++ i) 45 { 46 scanf("%s %s", &buf1, &buf2); 47 if (is_ans()) 48 { 49 strcpy(P[cnt].s1, buf1); 50 strcpy(P[cnt ++].s2, buf2); 51 } 52 } 53 if (cnt != 0) 54 { 55 printf("%d\n", cnt); 56 for (int i = 0; i < cnt; ++ i) 57 printf("%s %s\n", P[i].s1, P[i].s2); 58 return 0; 59 } 60 if (n == 1) 61 printf("There is 1 account and no account is modified\n"); 62 else 63 printf("There are %d accounts and no account is modified\n", n); 64 return 0; 65 }
标签:nod ever base ace team rac modify rds nbsp
原文地址:https://www.cnblogs.com/GetcharZp/p/9589514.html