{"id":279,"date":"2013-05-28T12:12:59","date_gmt":"2013-05-28T04:12:59","guid":{"rendered":"http:\/\/blog.dayandcarrot.net\/?p=279"},"modified":"2013-05-28T12:12:59","modified_gmt":"2013-05-28T04:12:59","slug":"1035-password-20","status":"publish","type":"post","link":"https:\/\/dayandcarrot.space\/?p=279","title":{"rendered":"1035. Password (20)"},"content":{"rendered":"<p>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.<br \/>\n<b>Input Specification:<\/b><br \/>\nEach input file contains one test case. Each case contains a positive integer N (&lt;= 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.<br \/>\n&nbsp;<br \/>\n<b>Output Specification:<\/b><br \/>\nFor 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 &#8220;There are N accounts and no account is modified&#8221; where N is the total number of accounts. However, if N is one, you must print &#8220;There is 1 account and no account is modified&#8221; instead.<br \/>\n<b>Sample Input 1:<\/b><\/p>\n<pre>3\nTeam000002 Rlsp0dfa\nTeam000003 perfectpwd\nTeam000001 R1spOdfa<\/pre>\n<p><b>Sample Output 1:<\/b><\/p>\n<pre>2\nTeam000002 RLsp%dfa\nTeam000001 R@spodfa<\/pre>\n<p><b>Sample Input 2:<\/b><\/p>\n<pre>1\nteam110 abcdefg332<\/pre>\n<p><b>Sample Output 2:<\/b><\/p>\n<pre>There is 1 account and no account is modified<\/pre>\n<p><b>Sample Input 3:<\/b><\/p>\n<pre>2\nteam110 abcdefg222\nteam220 abcdefg333<\/pre>\n<p><b>Sample Output 3:<\/b><\/p>\n<pre>There are 2 accounts and no account is modified<\/pre>\n<p>======================================<br \/>\n\u8fd9\u9898\u6ca1\u5565\u6280\u672f\u542b\u91cf\uff0c\u76f4\u63a5\u53d1\u4ee3\u7801<\/p>\n<pre>\n#include <stdio.h>\n#include <iostream>\nusing namespace std;\nint main()\n{\n\tint N;\n\tscanf(\"%d\", &N);\n\tbool isModified = false;\n\tint modCount = 0;\n\tchar name[11], pswd[11];\n\tchar *ptrPswd;\n\tstring strOut;\n\tfor(int i=0; i<n; i++)\n\t{\n\t\tisModified = false;\n\t\tscanf(\"%s %s\", name, pswd);\n\t\tptrPswd = &#038;(pswd[0]);\n\t\twhile( (*ptrPswd) != '\u0000')\n\t\t{\n\t\t\tswitch (*ptrPswd)\n\t\t\t{\n\t\t\tcase '1':\n\t\t\t\t(*ptrPswd) = '@';\n\t\t\t\tisModified = true;\n\t\t\t\tbreak;\n\t\t\tcase '0':\n\t\t\t\t(*ptrPswd) = '%';\n\t\t\t\tisModified = true;\n\t\t\t\tbreak;\n\t\t\tcase 'l':\n\t\t\t\t(*ptrPswd) = 'L';\n\t\t\t\tisModified = true;\n\t\t\t\tbreak;\n\t\t\tcase 'O':\n\t\t\t\t(*ptrPswd) = 'o';\n\t\t\t\tisModified = true;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tptrPswd++;\n\t\t}\n\t\tif(isModified)\n\t\t{\n\t\t\t\/\/printf(\"%s %sn\", name, pswd);\n\t\t\tstrOut += name;\n\t\t\tstrOut += \" \";\n\t\t\tstrOut += pswd;\n\t\t\tstrOut += \"n\";\n\t\t\tmodCount++;\n\t\t}\n\t}\n\tif (modCount == 0)\n\t{\n\t\tif(N == 1)\n\t\t{\n\t\t\tprintf(\"There is 1 account and no account is modifiedn\");\n\t\t}\n\t\telse\n\t\t{\n\t\t\tprintf(\"There are %d accounts and no account is modifiedn\", N);\n\t\t}\n\t}\n\telse\n\t{\n\t\tcout << modCount << endl;\n\t\tcout << strOut.c_str();\n\t}\n\treturn 0;\n}\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>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 @, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[84],"class_list":["post-279","post","type-post","status-publish","format-standard","hentry","category-study","tag-pat"],"_links":{"self":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/posts\/279","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=279"}],"version-history":[{"count":0,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/posts\/279\/revisions"}],"wp:attachment":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=279"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=279"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=279"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}