北大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 ...
随机推荐
- Shared File System Master Slave 全配置以及测试
在本机完成2个broker的共享文件测试 2个broker的完整配置文件如下 <!-- Licensed to the Apache Software Foundation (ASF) ...
- TypeHandler的简单实例
转自:http://ccchhhlll1988-163-com.iteye.com/blog/1420149 TypeHandler是MyBatis config文件中可选的配置选项,其可以对实体属性 ...
- 9款风格华丽的jQuery/CSS3插件
今天向大家分享9款效果相当不错的jQuery/CSS3插件,不多说,直接来看看这些插件吧. 1.jQuery动画下拉菜单Smart Menu 这是一款基于jQuery的动画下拉菜单,子菜单外观比较时尚 ...
- 《转》Java中HashMap详解
HashMap 和 HashSet 是 Java Collection Framework 的两个重要成员,其中 HashMap 是 Map 接口的常用实现类,HashSet 是 Set 接口的常用实 ...
- eclipse的scala环境搭建
两种方法使eclipse安装scala环境(eclipse luna) 1.下载eclipse for scala IDE http://scala-ide.org/download/sdk.html ...
- 基于C#实现的HOOK键盘钩子实例代码
本文所述为基于C#实现的HOOK实例,该实例可用来屏蔽系统热键.程序主要实现了安装钩子.传递钩子.卸载钩子等功能.在传递钩子中:<param name="pHookHandle&quo ...
- WPF 之 TreeView右键选中节点及节点重命名
下面的TreeView节点是通过数据双向绑定的方式,绑定到TextBlock控件和TextBox控件的Text属性上,并且让两者绑定相同的属性,同时使TextBox控件刚好完全覆盖TextBlock控 ...
- FOR XML PATH 解决联接返回结果集各记录问题
FOR XML PATH 有的人可能知道有的人可能不知道,其实它就是将查询结果集以XML形式展现,有了它我们可以简化我们的查询语句实现一些以前可能需要借助函数活存储过程来完成的工作.那么以一个实例为主 ...
- C. Mobile phones
Suppose that the fourth generation mobile phone base stations in the Tampere area operate as follows ...
- PN-Traniger
首先先从Bezier说起: 一条直线上有两个端点,P0和P1,那么直线可以写成 y = kx+b ,其实也就是P(t) = (1-t)P0 + P1 (这是个插值函数),(小注,我时常把这两个 ...