当前位置:网站首页>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;
}
边栏推荐
- Update failed to update bytea type PostgreSQL
- 杰理之BLE 芯片供电范围及防烧芯片措施【篇】
- string类的常见构造及容量操作
- Introduction and usage of Eval function
- (key points of software engineering review) Chapter IV overall design exercises
- 6. how to automatically generate header file dependency -m
- What is the best annuity insurance product in 2022?
- 杰理之BLE SPP 开启 pin_code 功能【篇】
- Jerry's ble spp open pin_ Code function [chapter]
- 985高校博士因文言文致谢走红!导师评价其不仅SCI写得好...
猜你喜欢

找到自己的优势,才能干活不累,事半功倍!

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

施一公:我直到博士毕业,对研究也没兴趣!对未来很迷茫,也不知道将来要干什么......

Use pydub to modify the bit rate of the wav file, and an error is reported: c:\programdata\anaconda3\lib\site packages\pydub\utils py:170: RuntimeWarning:

想做钢铁侠?听说很多大佬都是用它入门的
![[games101] operation 2 -- triangle rasterization](/img/43/1a58206b8b7e6d19d2944cdb7bb0dc.png)
[games101] operation 2 -- triangle rasterization

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

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

Why does a ddrx power supply design require a VTT power supply

Don't be a fake worker
随机推荐
Cube 技术解读 | Cube 渲染设计的前世今生
SAP Spartacus Reference App Structure
Installing redis in CentOS 7 environment
Introduction to database system -- Chapter 2 -- relational database (2.4 relational algebra)
The first day of the new year | at 8:00 p.m. tomorrow, pulsar Chinese developer and user group meeting registration
Common construction and capacity operation of string class
UCI-HAR数据集的处理
Working principle analysis of rxjs fromEvent
Writing the program into the microcontroller can control the forward and reverse rotation of the motor more conveniently and quickly
使用Labelimg制作VOC数据集或yolo数据集的入门方法
使用Yolov3训练自己制作数据集,快速上手
Encrypt and decrypt strings using RSA and Base64
Exploration of kangaroo cloud data stack on spark SQL optimization based on CBO
Content-Type: multipart/form-data; boundary=${bound}
Shi Yigong: I was not interested in research until I graduated from my doctor's degree! I'm confused about the future, and I don't know what to do in the future
Appearance mode -- it has been used in various packages for a long time!
1712. 将数组分成三个子数组的方案数 ●●
Jerry's ble spp open pin_ Code function [chapter]
SurroundDepth:自监督多摄像头环视深度估计
MYSQL(九)