uva 1610——Party Games
来源:互联网 发布:淘宝买恒压阀警察找我 编辑:程序博客网 时间:2024/06/05 15:29
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=51171
题意:给你n个串的集合D,然后求一个长度最短的串s,使得使得s大于等于D中一半的串,又同时小于另一半串。
思路:直接暴力。先对n个串排序,然后选择第n/2-1个串,从第一个字母开始找,在后面添加26个字母枚举,直至找到目标串。
code:
#include <iostream>#include <cstdio>#include <cmath>#include <algorithm>#include <cstring>#include <sstream>#include <string>#include <vector>#include <list>#include <queue>#include <stack>#include <map>#include <set>#include <bitset>using namespace std;typedef long long ll;typedef unsigned long long ull;typedef long double ld;const int INF=0x3fffffff;const int inf=-INF;const int N=1000000;const int M=2005;const int mod=1000000007;const double pi=acos(-1.0);#define cls(x,c) memset(x,c,sizeof(x))#define cpy(x,a) memcpy(x,a,sizeof(a))#define fr(i,s,n) for (int i=s;i<=n;i++)#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1#define lrt rt<<1#define rrt rt<<1|1#define middle int m=(r+l)>>1#define lowbit(x) (x&-x)#define pii pair<int,int>#define mk make_pair#define IN freopen("in.txt","r",stdin);#define OUT freopen("out.txt","w",stdout);string s[M];int n;void sol(){ sort(s,s+n); //fr(i,0,n-1) cout<<s[i]<<endl; string s1=s[n/2-1],s2=s[n/2],t="",p=""; for (int i=0;;++i) { for (char c='A';c<='Z';++c) { t=p+c; if(t>=s1&&t<s2){cout<<t<<endl;return;} } p+=s1[i]; }}int main(){ while (~scanf("%d",&n)&&n) { fr(i,0,n-1) cin>>s[i]; sol(); }}
0 1
- uva 1610——Party Games
- Uva - 1610 - Party Games
- uva 1610Party Games
- UVA 1610 - Party Games
- UVA 1610 Party Games
- uva 1610 Party Games
- UVA 1610 Party Games
- UVA 1610 Party Games
- UVa 1610 Party Games——细节处理
- UVA - 1610 Party Games 贪心
- UVA 1610(p253)----Party Games
- UVa 1610 - Party Games(细节处理)
- UVa #1610 Party Games (习题8-2)
- UVa:1610 Party Games(字符串处理)
- UVA 1610 Party Games 模拟 有细节
- [UVa 1610] 聚会游戏(Party Games)
- UVA 1610-Party Games(聚会游戏)
- uva 1610 Party Games (贪心+STL字符串)
- flashbacklog区内容的清除
- 【bzoj1477】【青蛙的约会】【扩展欧几里德算法】
- 第八周项目3——顺序串算法(3)
- python中对文件、文件夹(文件操作函数)的操作
- 第8周项目3顺序串算法
- uva 1610——Party Games
- 第九周项目三~~~矩阵转置
- stm32 uart清除中断时机
- 第七周 项目4 队列数组
- 第六周 项目1 建立顺序栈算法库
- 151026总结
- 小程序:荷兰国旗问题 (大小写字母数字排序问题)包含代码
- LocalBroadcastManager的引入与用法
- IOS--单例模式