当前位置:网站首页>AcWing 1944. Record keeping (hash, STL)
AcWing 1944. Record keeping (hash, STL)
2022-06-11 11:10:00 【Eurya song】
【 Title Description 】
Farmer John has been keeping a detailed record of the cows milking in the barn .
Every hour, a group of three cows will enter the barn to produce milk , John will record their names .
for example , stay 5 5 5 Within hours , He may record the following list , Each row corresponds to a group of cattle entering the cowshed :
BESSIE ELSIE MATILDA
FRAN BESSIE INGRID
BESSIE ELSIE MATILDA
MATILDA INGRID FRAN
ELSIE BESSIE MATILDA
John found that the same group of cows may appear on his list many times , In the example above ,BESSIE ELSIE MATILDA This combination appeared 3 3 3 Time ( Although John doesn't have to record their names in the same order every time ).
Please help John calculate the number of cattle entering the cowshed the most .
【 Input format 】
The first line contains integers N N N.
Next N N N That's ok , Each line contains the names of a group of three cows , Each name has a length of 1 ∼ 10 1\sim 10 1∼10 A string of uppercase letters between .
【 Output format 】
Output the number of cattle entering the cowshed the most .
【 Data range 】
1 ≤ N ≤ 1000 1≤N≤1000 1≤N≤1000
【 sample input 】
5
BESSIE ELSIE MATILDA
FRAN BESSIE INGRID
BESSIE ELSIE MATILDA
MATILDA INGRID FRAN
ELSIE BESSIE MATILDA
【 sample output 】
3
【 analysis 】
First, sort each set of strings , Then the same three strings in different order must be the only sequence after sorting , Store this sequence in vector<string> in . And then we use map<vector<string>, int> Count the occurrence times of each group of sequences .
【 Code 】
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
map<vector<string>, int> cnt;
int n, res;
int main()
{
cin >> n;
while (n--)
{
vector<string> str(3);
for (int i = 0; i < 3; i++) cin >> str[i];
sort(str.begin(), str.end());
cnt[str]++;
}
for (auto &[k, v] : cnt) res = max(res, v);
cout << res << endl;
return 0;
}
边栏推荐
- Electron desktop development (development of an alarm clock [End])
- 数字藏品app小程序公众号源码
- 数据库系统概论 ---- 第二章 -- 关系数据库(2.1~2.3)(重要知识点)
- Xiao P weekly Vol.08
- Working principle analysis of rxjs fromEvent
- Cloud development MBTI personality type test assistant wechat applet source code
- Vscade -- vscode multi window name is configured as project name
- Jszip get the file of the specified file in the uploaded zip package
- 杰理之获取 BLE 查看代码异常复位等异常情况原因【篇】
- 杰理之获取 BLE OTA 双备份升级(只能用于 4Mbits 以上的芯片)【篇】
猜你喜欢

Report on various activity plans of safety month 2022 (28 pages)
![Jerry's ble chip power supply range and anti burn chip measures [chapter]](/img/25/f35ca0366d31a70cd5e487347bb814.png)
Jerry's ble chip power supply range and anti burn chip measures [chapter]

Typeerror: argument of type "Int 'is not Iterable

把程序写进微控制器里可以更方便快捷的控制电机正反转

使用Yolov5训练好模型调用电脑自带摄像头时出现问题:TypeError: argument of type “int‘ is not iterable的解决方法

企业微信小程序避坑指南,欢迎补充。。。

迭代器模式--沙场秋点兵
![[games101] operation 2 -- triangle rasterization](/img/43/1a58206b8b7e6d19d2944cdb7bb0dc.png)
[games101] operation 2 -- triangle rasterization

Writing the program into the microcontroller can control the forward and reverse rotation of the motor more conveniently and quickly

使用pydub修改wav文件的比特率,报错:C:\ProgramData\Anaconda3\lib\site-packages\pydub\utils.py:170: RuntimeWarning:
随机推荐
Interpreting USB3.0 test items
使用Yolov3训练自己制作数据集,快速上手
UCI-HAR数据集的处理
数据库系统概论 ---- 第二章 -- 关系数据库(2.1~2.3)(重要知识点)
小白在同花顺上直接开户是安全的吗?
SurroundDepth:自监督多摄像头环视深度估计
[CV basis] Color: rgb/hsv/lab
Why is Web3 a game changer for the "creator economy"
SQL query statement optimization
RxJs fromEvent 工作原理分析
数据库系统概论 ---- 第二章 -- 关系数据库(2.4 关系代数)
Droid-slam: depth vision slam for monocular and binocular rgbd cameras
Cube 技术解读 | Cube 渲染设计的前世今生
[DBSCAN] DBSCAN instance
距离度量 —— 欧式距离(Euclidean Distance)
把程序写进微控制器里可以更方便快捷的控制电机正反转
使用Yolov5训练好模型调用电脑自带摄像头时出现问题:TypeError: argument of type “int‘ is not iterable的解决方法
SAP Spartacus Reference App Structure
[K-means] K-means learning examples
MYSQL(九)