HDU 6264 Super-palindrome
生活随笔
收集整理的這篇文章主要介紹了
HDU 6264 Super-palindrome
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Problem Description 比賽題目:
http://acm.hdu.edu.cn/downloads/CCPC2018-Hangzhou-ProblemSet.pdf
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 longconst 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;elsemp[s[i]]++;sum1++;}else if(!(i % 2)){if(!np[s[i]])np[s[i]] = 1;elsenp[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; }
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 longconst 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;elsemp[s[i]]++;sum1++;}else if(!(i % 2)){if(!np[s[i]])np[s[i]] = 1;elsenp[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
總結
以上是生活随笔為你收集整理的HDU 6264 Super-palindrome的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 操作系统修炼秘籍(1):秘籍简介
- 下一篇: git初使用(本地创建后第一次提交到gi