Skip to content

Instantly share code, notes, and snippets.

@prehistoricpenguin
Created March 4, 2013 02:53
Show Gist options
  • Select an option

  • Save prehistoricpenguin/5079585 to your computer and use it in GitHub Desktop.

Select an option

Save prehistoricpenguin/5079585 to your computer and use it in GitHub Desktop.
/*
pat 1035
author chm
*/
#include <cctype>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <list>
#include <queue>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
using namespace std;
int n;
struct T
{
string name, pwd;
} accu[1086];
int main()
{
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
assert(freopen("in", "r", stdin) != NULL);
assert(freopen("out", "w", stdout) != NULL);
#endif
vector<int> seq;
while (cin >> n)
{
int cnt = 0;
for (int i = 0; i < n; ++i) //one line
{
cin >> accu[i].name >> accu[i].pwd;
bool moded = false;
for (int j = 0; j < accu[i].pwd.length(); ++j) //do with pwd
{
int flag = 1;
char ch = accu[i].pwd[j];
switch (ch)
{
case '1':
ch = '@';
break;
/*
O by o
*/
case '0':
ch = '%';
break;
case 'l':
ch = 'L';
break;
case 'O':
ch = 'o';
break;
default: // not changed
flag = 0;
break;
}
if (flag)
{
cerr << "n: " << i+1 << ' ' << accu[i].pwd[j] <<endl;
moded = true;
}
accu[i].pwd[j] = ch;
}
if (moded)
{
cerr << "i ----> " << i << endl;
seq.push_back(i);
++cnt;
}
}
cerr << "cnt :" << cnt << endl;
if (cnt)
{
cout << cnt << endl;
for (int i = 0; i < cnt; ++i)
cout << accu[seq[i]].name <<' ' << accu[seq[i]].pwd << endl;
}
else
{
const char* str = (n > 1) ? "are " : "is ";
const char* str1 = (n > 1) ? "s" : "";
cout << "There " << str << n
<< " account" << str1 << " and no account is modified" << endl;
}
}
#ifndef ONLINE_JUDGE
fclose(stdout);
assert(freopen("/dev/tty", "w", stdout) != NULL);
system("diff standard out");
#endif
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment