487-3279
http://poj.org/problem?id=1002
題解:
/* *@Author: STZG *@Language: C++ */ #include <bits/stdc++.h> #include<iostream> #include<algorithm> #include<cstdlib> #include<cstring> #include<cstdio> #include<string> #include<vector> #include<bitset> #include<queue> #include<deque> #include<stack> #include<cmath> #include<list> #include<map> #include<set> //#define DEBUG #define RI register int #define endl "\n" using namespace std; typedef long long ll; //typedef __int128 lll; const int N=100000+10; const int M=100000+10; const int MOD=1e9+7; const double PI = acos(-1.0); const double EXP = 1E-8; const int INF = 0x3f3f3f3f; int t,n,m,k,p,l,r,u,v; int ans,cnt,flag,temp,sum; int a[N]; char str; struct node{}; char convert(char c){if(c <= 'C') return '2';else if(c <= 'F') return '3';else if(c <= 'I') return '4';else if(c <= 'L') return '5';else if(c <= 'O') return '6';else if(c <= 'S') return '7';else if(c <= 'V') return '8';else if(c <= 'Y') return '9'; } int main() { #ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout); #endif//ios::sync_with_stdio(false);//cin.tie(0);//cout.tie(0);//scanf("%d",&t);//while(t--){int N;bool flag = false;cin >> N;map<string,int> telp_count;while(N--){string s,res;cin >> s;int i = 0;for(string::iterator s_it = s.begin();s_it != s.end();++s_it){if(*s_it >= '0' && *s_it <= '9') res.push_back(*s_it);if(*s_it >= 'A' && *s_it <= 'Z') res.push_back(convert(*s_it));}res.insert(3,1,'-');++telp_count[res];}map<string,int>::iterator map_it = telp_count.begin();for(;map_it != telp_count.end();++map_it)if(map_it->second >= 2){flag = true;cout << map_it->first << " " << map_it->second << endl;}if(!flag)cout << "No duplicates." << endl;//}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC); #endif//cout << "Hello world!" << endl;return 0; }?
總結(jié)
- 上一篇: Save your cats
- 下一篇: Hangover