UVA 1610-Party Games(聚会游戏)

UVa 1610 聚会游戏(Party Games) 题意: 输入一个n个字符串的集合D,找一个长度最短的字符串(不一定在D中出现)S, 使得D中恰好一半串小于等于S,另一半串大于S,如果有多解,输出字典序最小的解。 分析: vector 存,排序,取中间的两个,然后把第一个逐渐变大,例如 ABC -> AC -> B 这样,一次次检验和第二个的关系,一旦大于了就停止循环,要注意的是 如果是 AZC 按照算法会变成 A(Z+1) Z + ... 阅读详情

题目链接

题意 给你一N个字符串 要你构造一个字符串D 满足有n/2个字符串比它大 另外半个比它小
分析 给n组字符串排序。然后取中间的两组进行比较。

#include<bits/stdc++.h>
using namespace std;
string a[1006];
int main (void){
    ios::sync_with_stdio(false);
    int n;
    while(cin>>n && n){
        int arr=0;
        for(int i=0;i<n;i++) cin>>a[i];
        sort(a,a+n);
        string b,w=a[n/2],s=a[n/2-1];
        bool f=true;
        while(f){
            for(int i=0;i<26;i++){
                b=s.substr(0,arr);
                b+=i+'A';
                if(b>=s  && b<w){ f=false; break;}
            }
            arr++;
        }
        cout<<b<<endl;
    }
    return 0;
}

总结紫书上说这道题坑很多,刚开始想到的是先比较s,w两个字符串中的相同元素。
后来发现这么做要考虑得情况有点麻烦。于是想出了这么一个耿直的思路hhhh。

ARFoundation系列讲解-教程目录 一、教程目录 ARFoundation快速入门-01简介 ARFoundation快速入门-02环境搭建 ARFoundation快速入门-03环境配置之iOS ARFoundation快速入门-04环境配置之Android ARFoundation快速入门-05ARKit设备支持列表 ARFoundation快速入门-06ARCore设备支持列表 ARFoundation快速入门-07检查设备支持 ARFoundation快速入门-08平面检.......... 阅读详情

相关推荐

基于STM32智能教室灯光照明人数监测系统

本文设计了一套基于STM32和物联网技术的智能教室照明系统,通过光照传感器和双红外对管实现精准人数统计,结合"光照+人数"双条件判断实现按需照明。系统采用"感知-决策-执行-云联"架构,包含环境感知、人数统计、控制执行等模块,支持本地自动控制和手机APP远程管理。测试表明系统能有效避免"长明灯"现象,具有节能降耗、管理智能化的特点。创新点在于双向人数统计算法和双条件控制逻辑,为智慧校园建设提供了实用解决方案。

1161

Party Games UVA - 1610 解题报告

题目大意:自己写一个串S,使得题中给出串一半小于等于S,另一半大于S,如果有多解,输出字典序,最小的。 思路:一道十分细节的题目,里面的细节点太多,导致反复的改,反复的WA。 刚开始的思路,就是排序,比较中间两个串,但是比较里面的细节非常多,特比是在处理末尾字符的时候,自己最后是卡死在末尾全是Z串上,虽然卡的时间比较长,但感觉收获比较多,不卡题怎么进步呢。 下面给出AC代码: #incl...

NCC__dapeng的博客 334

极空间NAS小白也能搞定的Gitea部署:Docker+MySQL避坑全记录

本文为极空间NAS用户提供了一份详尽的Gitea私有代码仓库部署指南。针对极空间ARM架构和图形化Docker管理的特殊性,文章重点讲解了如何通过Docker和MySQL容器进行部署,并提供了三种获取兼容镜像的实战策略,特别是利用第三方镜像站转录的方法,帮助小白用户成功搭建并初始化Gitea服务,实现私有Git托管。

weixin_28318011的博客 368

UVA1610 聚会游戏 Party Games

仔细读题,大于等于而不是大于; 首先对所有字符串排序; 如果在两者最短长度内一直相同,答案就是这一部分; 考虑能不能在第一位不一样的位置j解决,分三种情况:较小串的长度为j+1,较大串与较小串在这一位的差值大于1,较大串的长度>j+1;需保证字典序最小,三种情况应一次讨论; 根据较小串找到最低的能够确定答案的位,注意,如果是最后一位,答案应该是较小串的最后一位; #include <iostream> #include <cstdio> #include <cstri.

gyp0205的博客 212

Linux音频调试实战:ALSA架构与tinymix工具的高级应用技巧

本文深入探讨了Linux音频调试的核心技术,重点解析了ALSA架构下音频信号的路由与混合机制。通过介绍轻量级命令行工具tinymix的高级应用技巧,指导开发者如何精准排查无声、音量异常、多路音频共存等复杂问题,并分享编写自动化测试脚本以提升嵌入式及智能设备音频开发效率的实战方法。

weixin_29210727的博客 101

FPGA工程师面试试题集锦11~20

时钟抖动是指芯片的某一个给定点上时钟周期发生暂时性变化,也就是说时钟周期在不同的周期上可能加长或缩短。它是一个平均值为0的平均变量。

FPGA/MATLAB学习教程/源码/项目合作开发 678

uva 1610 Party Games

这是第八章的第二个习题。这是细节上的问题, 想清楚不太难的。。。 #include #include using namespace std; string haha[1003]; int number; string str,s; char ans[100]; void work(); int main() { /*freopen("1610.in","r",stdin); freop

Lighting_的博客 433

【用unity实现100个游戏之1】制作类元气骑士、挺进地牢——俯视角射击游戏多种射击效果(一)(附源码)

俯视角射击游戏)是一类以俯视视角进行游戏展示的射击游戏。在这种游戏中,玩家控制着一个角色或载具,从俯视的角度上方观察游戏世界,并与敌人进行战斗。这种视角使玩家能够有更好的全局观察和策略性,同时也强调快速反应和精确射击。视角:俯视角度可以是固定的,也可以随着玩家角色的移动而变化,但都允许玩家以全局视角观察整个战场,有利于制定战略和规划行动。射击:玩家通常需要使用各种武器来与敌人进行战斗,包括枪械、爆炸物等。射击动作依赖于玩家的反应速度和准确性。

向宇的博客,专注php/web全栈 unity游戏开发,欢迎大家评论纠错 7833

Uva - 1610 - Party Games

细节题目,排序之后拿中间的两个比较,比较麻烦,注意每种可能性,调试了好久,WA了好几次。 AC代码: #include #include #include #include #include #include #include #include #include #include #include #include #include #include #inclu

yofer张耀琦的专栏 800

基于FPGA的万兆以太网学习(1)

万兆(10G) 以太网测速视频:SFP+屏蔽笼可以插入千兆或万兆光模块。SFP+信号定义与 SFP 一致。

baidu_34971492的博客 2250

YOLOv13改进策略【Neck篇】| GSConv 轻量卷积,Slim-Neck 减参数还不掉点

Neck 篇的第二篇继续"替换式"改进,这次的对象是 Neck 里的下采样卷积。GSConv 出自《Slim-neck by GSConv: a better design of lightweight detector》(2022),它的出发点:DWSConv(深度可分离)轻但"信息混不进通道",标准卷积重但表达好——GSConv 用GConv(分组卷积)混通道 + DWConv 补空间 + Channel Shuffle 打散,两全其美。

qq_53329130的博客 30

Party Games UVA - 1610

仔细分析题意,其实很容易发现,如果将整个序列按照字典序排序之后,最终的结果其实仅仅只与最中间的两个字符串序列是有关的,所以后续的求解就很简单了,取出两个最靠中间的字符串,a和b,逐步取a的子串,然后枚举‘A’ 到‘Z’的字符,将二者拼接,假设拼接之后得到的是temp,如果temp>=a&&temp #include #include #include #include #include #inc

zju2016的博客 366

华为OD机试双机位C卷-水库溃坝填补(Py/Java/C/C++/Js/Go)

华为OD机试(机考)双机位C卷 【水库溃坝填补】,提供C语言、Java、C++、Python、Go、JavaScript源码实现,并提供完整思路讲解,以及在线OJ模拟做题。水库溃坝填补。

qq_45776114的博客 2109

[UVa 1610] 聚会游戏(Party Games)

Judge:https://vjudge.net/problem/UVA-1610 题意:输入一些字符串,找一个长度最短的字符串(不一定是输入的字符串),使得输入的字符串中有一半小于等于该字符串,另一半大于该字符串。若有多解,输出字典序最小的解。

StarlitNight的博客 653

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

深度学习工具包 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")

UVA1610 聚会游戏 Party Games 题解

个人认为一个比较好理解的解法. 思路: 先对所有字符串进行排序. 只需考虑中间那两个串.先预先判断一下两个串的相同部分,让下标k预先到两个串不同的部分. 设第n/2个串为a串,它下一个串为b串 当遇到不同的字符直接跳出循环,如果k到了a串的最后一个字符都还没发现不同的,那么a串本身就满足条件(此处没考虑k是否超出b串的长度,不过最后提交上去也ac了,代码如下 int i=n/2; string ans; ...

qq_34920482的博客 700

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

UVA1610:Party Games(聚会游戏)

作者:xq的acm之路题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4485题目大意:给出n个字符串,求一个字符串,这个字符串比n中的一半的字典序小,大于等于另一半。n为偶数思路:排序,然后一个个字符的比较就行,,,刚开始用if讨论情况,漏了几种

xqacmer 862

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

习题 8-2 聚会游戏(Party Games, Mid-Atlantic 2012, UVa1610)

原题链接:https://vjudge.net/problem/UVA-1610 分类:贪心法 备注:注意字母范围 #include<bits/stdc++.h> using namespace std; const int maxn=1005; int n; string s[maxn]; int main(void){ //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); while(cin&g

TK_wang_的博客 364

UVA - 1610 Party Games(聚会游戏)(构造)

题意:输入一个n(2<=n<=1000,n是偶数)个字符串的集合D,找一个长度最短的字符串S(不一定在D中出现),使得D中恰好一半串小于等于S,另一半串大于S。如果有多解,输出字典序最小的解。 分析:找到最中间的两个串,直接按位构造。 #pragma comment(linker, "/STACK:102400000, 102400000") #include&lt...

Cherrychan2014的博客 229

[字符串] UVa1610 Party Games 聚会游戏(简单模拟)

题目 给出n个串(n为偶数); 要构造一个串,使n串中有一半小于等于它,另外一半大于它; 要求这个串长度尽量小,同时字典序小; 思路 细节较多使人烦躁的模拟题而已 代码 #include &lt;cstdio&gt; #include &lt;cstdlib&gt; #include &lt;algorithm&gt; #include &lt;string&gt; #inc...

OI - IceCab 357

习题8-2 聚会游戏(Party Games, Mid-Atlantic 2012, UVa1610)

思路: 构造题,挫败感max。orz。。。。 容易想到ans为sort后中间两个字符串a,b之间的串。 由于要求长度以及字典序最小,可以按照这两个来枚举构造。 若某长度无解,则ans加上a串的当前字符。#include #include #include #include #include #include #include #include #include #incl

%%% 330

习题8-2 UVA - 1610 Party Games 聚会游戏 (构造字符串)

大体题意: 给你n 个字符串(n 是偶数),让你构造一个字符串ans,使得n个字符串中有一半字典序小于等于ans  另一半大于ans。 思路: 稍微借鉴了学长的博客 = = ! 感觉写的确实很巧妙! 整体思路就是建立一个空的string  然后暴力一位一位的加字母判断就可以了! 首先: 先给string 数组s进行排序,在取出两个字符串u = s[n/2-1]  v = s[n/2]

aozil_yang的博客 517

UVa:1610 Party Games(字符串处理)

题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=845&page=show_problem&problem=4485 题意:输入一个n(2 ≤n≤1000,n是偶数)个字符串的集合D,找一个长度最短的字符串(不一定在D中出现)S,使得D中恰好一半串小于等于S,另一半串大于

nullptr 620

Uva 1610 - Party Games(模拟)

 You’ve been invited to a party. The hostwants to divide the guests into 2 teams for party games, with exactly the samenumber of guests on each team. She wants to be able to tell which guest is onwhic...

Change the world by program. 362

UVa 1610 - Party Games(细节处理)

输入一个含有偶数个串的集合,求一个字符串s0,使集合中一半的串大于s0,另一半小于等于s0,多解输出字典序最小的解。只需将s与中间两个串比较即可。 新串s0从空串开始,每次循环加上一个s1中对应位置的字符。只要满足条件就跳出循环,输出。

wcr1996的专栏 2581
上一篇: uva 11572 Unique Snowflakes (唯一的雪花)
下一篇: 标准C++中的string类的用法总结[转载]
NANAN-
博客等级 码龄9年 12粉丝 21原创
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值