北大ACM(POJ1013-Counterfeit Dollar)
Question:http://poj.org/problem?id=1013
问题点:排除+验证。
Memory: 244K Time: 16MS
Language: C++ Result: Accepted #include <iostream>
#include <string>
using namespace std;
int flag[];//0:未出现 1:even 2:up/down
string str[];
int main()
{
int k,weight;
cin>>k;
while(k-->)
{
weight=;
memset(flag,,sizeof(flag));
for(int i=;i<;i++){
cin>>str[i];
if(i==||i==||i==)
{
if(str[i]=="even")
{
for(int j=;j<str[i-].size();j++)
{
flag[str[i-].at(j)-'A']=;
flag[str[i-].at(j)-'A']=;
}
}else{//up down
for(int j=;j<str[i-].size();j++)
{
if(flag[str[i-].at(j)-'A']!=)
{
flag[str[i-].at(j)-'A']+=;
weight=weight>flag[str[i-].at(j)-'A']?weight:flag[str[i-].at(j)-'A'];
}
if(flag[str[i-].at(j)-'A']!=)
{
flag[str[i-].at(j)-'A']+=;
weight=weight>flag[str[i-].at(j)-'A']?weight:flag[str[i-].at(j)-'A'];
}
}
}
}
}
for(int i=;i<;i++)
{
char c=i+'A';
string s="";
if(flag[i]==weight)
{
for(int j=;j<;j++)
{
string t="";
if(str[j*+]=="up")
{
if(str[j*].find(c)!=string::npos) t="heavy.";
else if(str[j*+].find(c)!=string::npos) t="light.";
}else if(str[j*+]=="down")
{
if(str[j*].find(c)!=string::npos) t="light.";
else if(str[j*+].find(c)!=string::npos) t="heavy.";
}
if(s==""){
s=t;
}else if(t!="" && s!=t){
s="";
break;
}
}
if(s!="") cout<<c<<" is the counterfeit coin and it is "<<s<<endl;
}
}
}
return ;
}
北大ACM(POJ1013-Counterfeit Dollar)的更多相关文章
- POJ1013 Counterfeit Dollar
题目来源:http://poj.org/problem?id=1013 题目大意:有12枚硬币,其中有一枚假币.所有钱币的外表都一样,所有真币的重量都一样,假币的重量与真币不同,但我们不知道假币的重量 ...
- poj1013.Counterfeit Dollar(枚举)
Counterfeit Dollar Time Limit: 1 Sec Memory Limit: 64 MB Submit: 415 Solved: 237 Description Sally ...
- 北大 ACM 分类 汇总
1.搜索 //回溯 2.DP(动态规划) 3.贪心 北大ACM题分类2009-01-27 1 4.图论 //Dijkstra.最小生成树.网络流 5.数论 //解模线性方程 6.计算几何 //凸壳.同 ...
- 北大ACM题库习题分类与简介(转载)
在百度文库上找到的,不知是哪位大牛整理的,真的很不错! zz题 目分类 Posted by fishhead at 2007-01-13 12:44:58.0 -------------------- ...
- 北大ACM - POJ试题分类(转自EXP)
北大ACM - POJ试题分类 -- By EXP 2017-12-03 转载请注明出处: by EXP http://exp-blog.com/2018/06/28/pid-38/ 相关推荐文: 旧 ...
- Counterfeit Dollar -----判断12枚钱币中的一个假币
Counterfeit Dollar Time Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64u ...
- POJ 1013 Counterfeit Dollar
Counterfeit Dollar Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 36206 Accepted: 11 ...
- Counterfeit Dollar 分类: POJ 2015-06-12 15:28 19人阅读 评论(0) 收藏
Counterfeit Dollar Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 41559 Accepted: 13 ...
- Poj 1013 Counterfeit Dollar / OpenJudge 1013(2692) 假币问题
1.链接地址: http://poj.org/problem?id=1013 http://bailian.openjudge.cn/practice/2692 http://bailian.open ...
- POJ 1013:Counterfeit Dollar
Counterfeit Dollar Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 42028 Accepted: 13 ...
随机推荐
- MariaDB5.5.32 绿色版下载安装一条龙
1.下载地址: http://ftp.yz.yamagata-u.ac.jp/pub/dbms/mariadb/mariadb-5.5.32/win32-packages/mariadb-5.5.32 ...
- Python 条件语句
Python条件语句是通过一条或多条语句的执行结果(True或者False)来决定执行的代码块. Python程序语言指定任何非0和非空(null)值为true,0 或者 null为false. Py ...
- SQL with(unlock)与with(readpast) (转)
所有Select加 With (NoLock)解决阻塞死锁,在查询语句中使用 NOLOCK 和 READPAST 处理一个数据库死锁的异常时候,其中一个建议就是使用 NOLOCK 或者 READPAS ...
- Swift 编程风格指南(raywenderlich.com 版本号)
官方 raywenderlich.com Swift 编程风格指南 本文版权归 raywenderlich.com .The Official raywenderlich.com Swift Styl ...
- NPOI 教程 - 3.2 打印相关设置
转:http://www.cnblogs.com/wolfplan/archive/2013/01/13/2858991.html NPOI 教程 - 3.2 打印相关设置 打印设置主要包括方向设 ...
- Eclipse启动Tomcat时,45秒超时解决方案
在Eclipse中启动Tomcatserver时,常常因为系统初始化项目多,导致出现45秒超时的Tomcatserver启动错误,出现以下的错误. 曾经我们一般通过找到XML配置文件,将相应Timeo ...
- valgrind 内存检测与调用图生成
http://blog.csdn.net/destina/article/details/6198443 感谢作者的分享! 一 valgrind是什么? Valgrind是一套Linux下,开放源 ...
- oracle中to_date() 与 to_char() 日期和字符串转换
to_date("要转换的字符串","转换的格式") 两个参数的格式必须匹配,否则会报错. 即按照第二个参数的格式解释第一个参数. to_char(日期,& ...
- matplotlib作图中文显示问题
def set_ch(): from pylab import mpl mpl.rcParams['font.sans-serif'] = ['FangSong'] # 指定默认字体 mpl.rcPa ...
- IIS 之 HTTP错误 404.17 - Not Found(请求的内容似乎是脚本,因而将无法由静态文件处理程序来处理。)
问题描述:HTTP 404.17 - Not Found" IIS 7.5 请求的内容似乎是脚本,因而将无法由静态文件处理程序来处理 . 出现这种情况的原因通常是因为先安装了Framew ...