Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
晕死了!相同代码居然得到不同结果!真的想哭啊!POJ这不是整人吗!错误代码: #pragma warning (disable:4786) #include <iostream> #include <map> #include <algorithm> #include <string> using namespace std; map<char,char> CtoCMap; void init() { CtoCMap.insert(map<char,char>::value_type('A','2')); CtoCMap.insert(map<char,char>::value_type('B','2')); CtoCMap.insert(map<char,char>::value_type('C','2')); CtoCMap.insert(map<char,char>::value_type('D','3')); CtoCMap.insert(map<char,char>::value_type('E','3')); CtoCMap.insert(map<char,char>::value_type('F','3')); CtoCMap.insert(map<char,char>::value_type('G','4')); CtoCMap.insert(map<char,char>::value_type('H','4')); CtoCMap.insert(map<char,char>::value_type('I','4')); CtoCMap.insert(map<char,char>::value_type('J','5')); CtoCMap.insert(map<char,char>::value_type('K','5')); CtoCMap.insert(map<char,char>::value_type('L','5')); CtoCMap.insert(map<char,char>::value_type('M','6')); CtoCMap.insert(map<char,char>::value_type('N','6')); CtoCMap.insert(map<char,char>::value_type('O','6')); CtoCMap.insert(map<char,char>::value_type('P','7')); CtoCMap.insert(map<char,char>::value_type('R','7')); CtoCMap.insert(map<char,char>::value_type('S','7')); CtoCMap.insert(map<char,char>::value_type('T','8')); CtoCMap.insert(map<char,char>::value_type('U','8')); CtoCMap.insert(map<char,char>::value_type('V','8')); CtoCMap.insert(map<char,char>::value_type('W','9')); CtoCMap.insert(map<char,char>::value_type('X','9')); CtoCMap.insert(map<char,char>::value_type('Y','9')); for (int i = 0;i < 10;i++) { CtoCMap['0' + i] = '0' + i; } } int main() { //freopen("input.txt","r",stdin); bool checking = true; map<string,int>::iterator it; map<string,int> RepeatTimes; init(); string InputString; int i =0,j = 0; int cases; cin >> cases; while(cases--){ cin >> InputString; string p(8,0); for (i = 0,j =0; i < InputString.length();i++) { if (InputString[i] >= 'A' && InputString[i] <= 'P'||InputString[i] >'Q' && InputString[i] < 'Z') { p[j] = CtoCMap[InputString[i]]; j++; } else if (InputString[i] >='0'&&InputString[i] <='9') { p[j] = InputString[i];j++; } } for (i = j;i > 3;i--) { p[i] = p[i - 1]; } p[3] = '-'; p[j + 1] = '\0'; if (RepeatTimes[p] == NULL) { RepeatTimes[p] = 1; } else { RepeatTimes[p]++; } } for (it = RepeatTimes.begin();it != RepeatTimes.end();it++) { if (it->second > 1) { checking = true; cout<<it->first<<" "<<it->second<<endl; } } if (!checking){ cout<<"No duplicates."<<endl; } return 0; } AC代码: #pragma warning (disable:4786) #include <iostream> #include <map> #include <algorithm> #include <string> using namespace std; map<char,char> CtoCMap; void print(string& Chr) { cout<<Chr<<" "; } void init() { CtoCMap.insert(map<char,char>::value_type('A','2')); CtoCMap.insert(map<char,char>::value_type('B','2')); CtoCMap.insert(map<char,char>::value_type('C','2')); CtoCMap.insert(map<char,char>::value_type('D','3')); CtoCMap.insert(map<char,char>::value_type('E','3')); CtoCMap.insert(map<char,char>::value_type('F','3')); CtoCMap.insert(map<char,char>::value_type('G','4')); CtoCMap.insert(map<char,char>::value_type('H','4')); CtoCMap.insert(map<char,char>::value_type('I','4')); CtoCMap.insert(map<char,char>::value_type('J','5')); CtoCMap.insert(map<char,char>::value_type('K','5')); CtoCMap.insert(map<char,char>::value_type('L','5')); CtoCMap.insert(map<char,char>::value_type('M','6')); CtoCMap.insert(map<char,char>::value_type('N','6')); CtoCMap.insert(map<char,char>::value_type('O','6')); CtoCMap.insert(map<char,char>::value_type('P','7')); CtoCMap.insert(map<char,char>::value_type('R','7')); CtoCMap.insert(map<char,char>::value_type('S','7')); CtoCMap.insert(map<char,char>::value_type('T','8')); CtoCMap.insert(map<char,char>::value_type('U','8')); CtoCMap.insert(map<char,char>::value_type('V','8')); CtoCMap.insert(map<char,char>::value_type('W','9')); CtoCMap.insert(map<char,char>::value_type('X','9')); CtoCMap.insert(map<char,char>::value_type('Y','9')); for (int i = 0;i < 10;i++) { CtoCMap['0' + i] = '0' + i; } } int main() { bool checking = false; map<string,int>::iterator it; map<string,int> RepeatTimes; init(); string InputString; int i = 0,j = 0; int cases; cin>>cases; while (cases--) { cin>>InputString; string p(8,0); for (i = 0,j = 0;i < InputString.length();i++) { if (InputString[i] >= 'A' && InputString[i] <= 'P'||InputString[i] >'Q' && InputString[i] <= 'Z') { p[j] = CtoCMap[InputString[i]]; j++; } else if (InputString[i] >='0'&&InputString[i] <='9') { p[j] = InputString[i]; j++; } } for (i = j;i > 3;i--) { p[i] = p[i - 1]; } p[3] = '-'; p[j + 1] = '\0'; if (RepeatTimes[p] == NULL) { RepeatTimes[p] = 1; } else { RepeatTimes[p]++; } } for (it = RepeatTimes.begin();it != RepeatTimes.end();it++) { if (it->second > 1) { checking = true; cout<<it->first<<" "<<it->second<<endl; } } if (!checking) { cout<<"No duplicates."<<endl; } return 0; } 真是无语啊……我也看不出有什么错误了!怎么后面的就可以AC呐!死啦! Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator