1. 程式人生 > >HDU 1004 模擬題|STL題|Hash題

HDU 1004 模擬題|STL題|Hash題

5/1000

傳送門
題目大意:給你好多顏色 問你那種最多

思路本來想手寫一個hash來著 結果gg 看來hash還需要好好的學習一下 最後用stl裡的map 水過去了

emmm一會先學習一下hash再做其他的題目吧QAQ

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
#include <iostream>
using namespace std;

map<string,int> mp;

int main()
{
    //freopen("in.txt","r",stdin);
int n,ans,temp; while(scanf("%d",&n)!=EOF) { if(n==0)break; string a,b; //ini ans=0; mp.clear(); for(int i=1;i<=n;i++) { cin>>a; temp=mp[a]=mp[a]+1; if(temp>ans){ ans=temp; b=a; } } cout
<<b<<endl; } return 0; }

以上。

相關推薦

HDU 1004 模擬|STL|Hash

5/1000 傳送門 題目大意:給你好多顏色 問你那種最多 思路本來想手寫一個hash來著 結果gg 看來hash還需要好好的學習一下 最後用stl裡的map 水過去了 emmm一會先學習

HDU - 2398 】Savings Account (水模擬

題幹: Suppose you open a savings account with a certain initial balance. You will not make any withdrawals or further deposits for a number of years

第二期訓練第四HDU-1004

問題連結:http://acm.hdu.edu.cn/showproblem.php?pid=1004 問題簡述:在放氣球比賽中,有很多不同顏色的氣球,現在要統計哪種顏色的氣球最多。 Point:N=0表示輸入結束。 Get:(1)用char定義的字元不能直接判斷是否相等,要用函

hdu 5071(2014鞍山現場賽B,大模擬

思路:模擬題,沒啥可說的,移動的時候需要注意top的變化。 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> usin

hdu 4801模擬

Pocket Cube Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 757 Accepted Submissi

HDU 1049 青蛙爬進 (水_模擬

Problem Description An inch worm is at the bottom of a well n inches deep. It has enough energy to climb u inches every minute, but the

hdu 4561 模擬

/* 模擬題 思路: 我的思路是如果一串連續的0,我就存一個0在另外的數組裡面,如果一串連續的2 我就存 多少個2在另外一個數組裡,如果一串連續的-2我就存多少個-2在另外一個數組裡(-2)用負單位儲存 例如:輸入資料為 2,-2,2,2,0,0,-2,-2,-2,2,2

[原創] count 分段Hash

com style int blog else string color main amp 題意    實現 #include <cstdio> #include <cstring> #include <cstdlib> #incl

HDU 2222 Keywords Search (AC自動機模板

出現 tro spa 繼續 time int cas keyword arc Keywords Search Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Othe

liu_runda 給辣雞蒟蒻做的 NOIP模擬賽 1.0 第二 任(duty) 題解

cfa 由於 幹什麽 truct 失去 格子 ace ide ++ 問題 B: 任(duty) 時間限制: 2 Sec 內存限制: 512 MB 題目描述 liu_runda退役之後就失去夢想開始鹹魚生活了… Bilibili夏日畫板活動中,所有人都可以在一塊畫板上進

七中高新 NOIP模擬 第二 上低音號

blog image 形狀 位置 行數 noi 完成 noip alt   由於這道題至今無人改掉(其實是沒人想改),我就不去說題解了,只說說我當時考試的思路。   按照套路,先想暴力,很明顯,枚舉矩形形狀再去暴力查詢是人人都想得到的,但是復雜度O(n^4),而數據範圍第

HDU 1711 Number Sequence (KMP簡單

bmi AMM several rip case ive sts -- 沒有 Number Sequence Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe

hdu 1150 Machine Schedule(二分圖模板)

scanf clas eof hung sched uri font namespace linker 題目大意:有兩臺機器A和B,A機器有n種工作方式,B機器有m種工作方式。共有k個任務。每個任務恰好在一條機器上運行。 如果任務在A機器上運行,就需要轉換為模式Xi,如果在

hdu 2955 Robberies (01背包好)

\n int asp rabl wan limit line esc std Robberies Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total

HDU - 5936 Difference 2016 杭州 CCPC 思維

#include<bits/stdc++.h> #define LL long long using namespace std; const int maxn=1e5+10; struct nod { int x,k;int i; bool operator <(co

HDU 3567 - Eight II 這該死的

關於這道題 我真的想罵娘(好吧是自己太菜了) 我很早其實自己推出來了,就是還是bfs+康託但是列舉九種不同的X位置,同時利用對映,注意要對映第一個輸入的模板,然後倒序輸出路徑!!很重要 我一開始天真的想用路徑urld然後順序輸出 然後- - 也就幾個小時沒了吧小問題 但是我卡在了兩個莫名

字元序列模式識別解題報告---模擬(很坑的

                                    1311: 字元序列模式識別

HDU - 2002 計算球體積【水

計算球體積 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 221819 Accepted Submission(s): 86588

HDU - 2000 ASCII碼排序【水

ASCII碼排序 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 237624 Accepted Submission(s): 93

HDU 2255】【KM演算法模板+KM演算法詳解】 奔小康賺大錢

描述: 奔小康賺大錢 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 7453    Accepted S