HDU 6264 Super-palindrome

mac2022-06-30  27

Problem Description 比赛题目: http://acm.hdu.edu.cn/downloads/CCPC2018-Hangzhou-ProblemSet.pdf  

 

Source 2017中国大学生程序设计竞赛-杭州站-重现赛(感谢浙江理工)   Recommend liuyiding   |   We have carefully selected several similar problems for you:   6730  6729  6728  6727  6726    #include<bits/stdc++.h> using namespace std; #define ll long long const int inf = 0x3f3f3f3f; const int mod = 1000000007; const int maxn = 10000 + 8; int t, num; string s; map<char, int>mp, np; int main() { scanf("%d", &t); while(t--) { mp.clear(); np.clear(); cin >> s; int len = s.size(), maxx1 = 0, maxx2 = 1, sum1= 0, sum2 = 0; for(int i = 0; i < len; i++) { if(i % 2) { if(!mp[s[i]]) mp[s[i]] = 1; else mp[s[i]]++; sum1++; } else if(!(i % 2)) { if(!np[s[i]]) np[s[i]] = 1; else np[s[i]]++; sum2++; } } map<char, int>::iterator i; for(i = mp.begin(); i != mp.end(); i++) if(i->second > maxx1) maxx1 = i->second; for(i = np.begin(); i != np.end(); i++) if(i->second > maxx2) maxx2 = i->second; printf("%d\n", sum1 - maxx1 + sum2 - maxx2); } return 0; }

 

转载于:https://www.cnblogs.com/RootVount/p/11586894.html

相关资源:JAVA上百实例源码以及开源项目
最新回复(0)