水果(HDU-1263)

HDU oj——1263题,c++/java,双重map实现 一、问题概述 Problem Description 夏天来了~~好开心啊,呵呵,好多好多水果~~ Joe经营着一个不大的水果店.他认为生存之道就是经营最受顾客欢迎的水果.现在他想要一份水果销售情况的明细表,这样Joe就可以很容易掌握所有水果的销售情况了. Input 第一行正整数N(0<N<=10)表示有N组测试数据. 每组测试数据的第一行是一个整数M(0<M<=... 阅读详情
Problem Description
夏天来了~~好开心啊,呵呵,好多好多水果~~
Joe经营着一个不大的水果店.他认为生存之道就是经营最受顾客欢迎的水果.现在他想要一份水果销售情况的明细表,这样Joe就可以很容易掌握所有水果的销售情况了.
 

Input
第一行正整数N(0<N<=10)表示有N组测试数据.
每组测试数据的第一行是一个整数M(0<M<=100),表示工有M次成功的交易.其后有M行数据,每行表示一次交易,由水果名称(小写字母组成,长度不超过80),水果产地(小写字母组成,长度不超过80)和交易的水果数目(正整数,不超过100)组成.
 

Output
对于每一组测试数据,请你输出一份排版格式正确(请分析样本输出)的水果销售情况明细表.这份明细表包括所有水果的产地,名称和销售数目的信息.水果先按产地分类,产地按字母顺序排列;同一产地的水果按照名称排序,名称按字母顺序排序.
两组测试数据之间有一个空行.最后一组测试数据之后没有空行.
 

Sample Input
1 5 apple shandong 3 pineapple guangdong 1 sugarcane guangdong 1 pineapple guangdong 3 pineapple guangdong 1
 

Sample Output
guangdong |----pineapple(5) |----sugarcane(1) shandong |----apple(3)
 

第一次用的方法是比较笨的方法,用的sort排序,代码也很长,这次回过头来看,发现用map很简单,代码也比较短
代码如下:
#include<bits/stdc++.h>
using namespace std;
map<string,map<string,int> >s;
set<string>sg,name;
int main()
{
    int t,c,n;
    cin>>t;
    string a,b;
    while(t--)
    {
        cin>>n;
        for(int k=1;k<=n;k++)
        {
            cin>>a>>b>>c;
            s[b][a]+=c;
            sg.insert(b);
            name.insert(a);
        }
        for(set<string>::iterator i=sg.begin();i!=sg.end();i++)
        {
            cout<<*i<<endl;
            for(set<string>::iterator j=name.begin();j!=name.end();j++)
               if(s[*i][*j])
            cout<<"   |----"<<*j<<'('<<s[*i][*j]<<')'<<endl;
        }
        s.clear();
        sg.clear();
        name.clear();
        if(t!=0)
            cout<<endl;
    }
    return 0;
}


CMOS传输门设计:从原理到工程实践,攻克信号传输核心挑战 在模拟与数字混合信号系统中,开关是实现信号路由、采样和选择的基础功能单元。其核心原理在于通过控制信号的通断,实现信号路径的高效切换。一个理想的开关应具备极低的导通电阻、极高的关断阻抗以及对信号近乎无损的传输特性,这直接决定了系统的信号保真度、带宽和精度。CMOS传输门技术通过并联互补的NMOS和PMOS管,巧妙地克服了单管传输中的阈值电压损失和非线性导通电阻问题,从而在接近理想的电压传输特性上实现了重大突破。这项技术的核心价值在于为高精度数据转换器(如ADC)、模拟多路复用器以及高速开关电容滤波器等关键电路 阅读详情

相关推荐

Leaflet 加载天地图完整配置指南:从插件修改到无限缩放(附源码)

本文详细介绍了Leaflet与天地图深度集成的完整配置指南,包括插件修改、无限缩放实现及源码示例。通过解析天地图服务的WMTS协议、双投影支持和密钥机制,帮助开发者突破缩放级别限制,优化地图应用性能,适用于Web地图开发和高精度GIS系统。

weixin_27180827的博客 442

HDU 1263 水果 (STL中的map嵌套)

水果 Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1362Accepted Submission(s): 532 Problem Description 夏天来了~~好开心啊,呵呵,好多好多水果~~Joe经营着一个不大的水...

weixin_30861797的博客 788

CAN收发器选型避坑指南:TJA1051T与TJA1051T/3的硬件兼容性问题实录

本文详细解析了CAN收发器TJA1051T与TJA1051T/3的硬件兼容性问题,通过实测数据和故障案例揭示了VIO引脚的关键差异及其对系统的影响。提供从选型到验证的完整防坑方案,帮助开发者避免常见设计错误,确保CAN总线通信的稳定性。

weixin_42715608的博客 464

【题解】HDU 1263 水果

目录 题目描述 题意分析 AC代码   题目描述 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Problem Description 夏天来了~~好开心啊,呵呵,好多好多水果~~ Joe经营着一个不大的水果店.他认为生存之道就是经营最受顾客欢迎的水果.现在他想...

飒然霜林的博客 545

3GPP协议解读_NTN系列(一)_38.811_非地面网络(NTN)的背景、应用场景和信道建模

非地面网络覆盖广,对物理攻击和自然灾害有一定的抵抗性。本文根据3GPP协议对NTN网络的背景、应用场景和信道模型进行了整理。

JCMLSY的博客 4932

STM32F103C8T6+HX711实战:从零打造智能体重秤(附OLED显示与语音播报)

本文详细介绍了基于STM32F103C8T6微控制器和HX711称重模块,从零构建智能体重秤的完整实战教程。内容涵盖硬件选型、系统架构、驱动编写、数据滤波校准算法,并实现了OLED显示与语音播报功能。该项目是嵌入式学习的综合性实践,尤其适合作为毕业设计课题,帮助开发者掌握传感器应用、数据处理及人机交互等核心技能。

weixin_28285943的博客 520

C++ 二维、三维 map 的使用

前言 最近复习了一下 map 的使用,因为使用的都是一维的,所以使用常规操作就能满足需求。以前看到过有人在工作环境中使用多维度的 map,当时没有尝试实现这种需求,今天想起来了就试了下。类似于 map<string, map<string, string>> 这种形式。常规操作是对数据的增删查改。 二维 map 创建一个二维map,这里以string为例: map<string, map<string, string>> b; 增加元素 增加元素可分为两种情

geejkse_seff的博客 2965

AM驱动架构—优质Mini-LED显示技术解决方案

(VR)和增强现实(AR)设备:MiniLED背光驱动方案适用于虚拟现实和增强现实设备中的显示技术,通过高亮度和高对比度的显示效果,创造更逼真的虚拟体验此外,MiniLED背光还能够实现更快的响应速度,减少图像残影,使得用户的动作在虚拟环境中更加流畅自然。以其出色的性能和广泛的应用前景备受关注是实现MiniLED显示效果的重要环节。1)更高的亮度和对比度:尺寸更小,可以在同样面积的显示屏上配置更多的LED,并且通过独立控制每一个MiniLED,可以实现更高的亮度和更细致的对比度,使得显示画面更加鲜明清晰。

isweekDN的博客 2764

【HDU 1263】水果 题解(二维映射)

夏天来了Joe经营着一个不大的水果店.他认为生存之道就是经营最受顾客欢迎的水果.现在他想要一份水果销售情况的明细表,这样Joe就可以很容易掌握所有水果的销售情况了.Input第一行正整数N(0

HEX9CF的技术博客 444

解锁 Bootloader 不再难!HyperOS澎湃系统小米与红米手机通用

必要时,可以在工具右上角安装驱动模块,手动安装驱动。解决方法:确保手机升级到最新稳定版,登录同一个小米账号,并在。新机型解锁时需要等待一段时间,通常为 7 天。如果账号安全评分较低,解锁等待时间会更长。如果解锁失败提示权限不足,说明账号存在安全问题。出现这个错误时,通常是因为网络不稳定。如果解锁次数已满,需要等到下个月。解锁后,手机会重启,首次开机会稍微慢一些,等耐心等待即可。按钮,开始解锁过程,注意:解锁会清除手机内所有数据。7次,开启开发者选项。,右键解压到指定文件夹。,使用小米账号登录。

代码简单说 Vue、JAVA、PHP、Node.js 熟练运用,接口、架构、性能全搞定。 7241

【Inpho精品教程】Inpho简介、安装教程(附Inpho8安装包下载)

本文介绍Trimble旗下Inpho UASMaster航空摄影测量软件,涵盖其核心功能模块(如Match-AT、OrthoMaster、Summit Evolution等)及安装教程。文章详细说明了从安装到汉化破解的全过程,并提供Inpho 8.0.1安装包下载链接与提取码,适用于无人机摄影测量专业用户。

智慧空间实验室 1万+

hdu 1263 水果

hdu   1263   水果              题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1263

slicer的技术交流栈 948

【PINN物理信息网络】基于PINN物理信息网络求解瞬态薛定谔方程(python)

【PINN物理信息网络】基于PINN物理信息网络求解瞬态薛定谔方程(python)

k8291121的博客 2724

HDU 1263 水果

地址:http://acm.hdu.edu.cn/showproblem.php?pid=1263 Input 第一行正整数N(0 每组测试数据的第一行是一个整数M(0   Output 对于每一组测试数据,请你输出一份排版格式正确(请分析样本输出)的水果销售情况明细表.这份明细表包括所有水果的产地,名称和销售数目的信息.水果先按产地分类,产地按

u012964281的专栏 1029

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

HDU 1263 水果 (map精简版)

HDU 1263 水果 map嵌套。特判了产地为空、产地不为空但水果为空的情况。 #include <bits/stdc++.h> using namespace std; int T,n,w; string place,fruit; map<string,map<string,int> >vis; int main() { ios::sync_with...

nefu_ljw的博客 432

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

HDU-1263 水果

HDU-1263 水果(双map实现) 题目链接:HDU-1263 题目大意:数据整合排版 解题思路:使用双map实现,即map<string, map<string, int> >的形式 注意后面的>>一定要分开写 不然会判别为位运算 由于输出以产地为第一级,所以map里面的第一个string即储存地名 后面的map储存水果名称和数量信息 map里的key是实...

鱼头的水题之路 278

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

HDU_1263_水果

HDU_1263_水果思路 STL 夏天来了~~好开心啊,呵呵,好多好多水果~~ Joe经营着一个不大的水果店.他认为生存之道就是经营最受顾客欢迎的水果.现在他想要一份水果销售情况的明细表,这样Joe就可以很容易掌握所有水果的销售情况了.

Sothan 553

【HDU1263 水果】 STL之map应用经典好题

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1263 题目大意:对同一地方的同一水果进行归类。 解题思路: map真心强大,以前只知道map的一维运用,今天了解了map的二维运用(map映射map)。 View Code 1 #include <iostream> 2 #include ...

baidui8622的博客 190

HDU1263 水果【map】

水果 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 18636 Accepted Submission(s): 7191 Problem Description 夏天来了~~好开心啊,呵呵,好多好多水果~~ Joe经营着一个不大的水果店.他认为生存之道就是经营最受顾客欢迎的水果.现在他想要一份水果销售情况的明细表,这样Joe就可以很容易掌握

海岛Blog 978

hdu 1263 水果

水果 Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 13974Accepted Submission(s): 5479 Problem Description 夏天来了~~好开心啊,呵呵,好多好多水果~~ Joe经营着...

Twinkle_sone的博客 306

水果 hdu1263 水题

http://acm.hdu.edu.cn/showproblem.php?pid=1263 。。输出统计结果嘛,相对而言比较水。 #include #include #include using namespace std; #define M 105 struct fruit_node{ string place,name; int num; }; fruit_node

operator456的专栏 530

HDU 1263 水果

水果 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 5919    Accepted Submission(s): 2335 Problem Description 夏天来了~~好开心啊,呵呵,好多好多水果~~

summerFanL的博客 2775

HDU1263:水果

Problem Description 夏天来了~~好开心啊,呵呵,好多好多水果~~ Joe经营着一个不大的水果店.他认为生存之道就是经营最受顾客欢迎的水果.现在他想要一份水果销售情况的明细表,这样Joe就可以很容易掌握所有水果的销售情况了.   Input 第一行正整数N(0 每组测试数据的第一行是一个整数M(0   Output 对于每一组测试数据,请你输出一

ACM!荣耀之路! 6363
上一篇: Humble Numbers(HDU-1058)
下一篇: The kth great number(HDU -4006)
绿蚁.r
博客等级 码龄10年 4粉丝 37原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值