北大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 ...
随机推荐
- 【MongoDB】mongoimport and mongoexport of data (一)
In the software development, we usually are faced with a common question of exporting or importing d ...
- HTML5 <script>元素async,defer异步加载
原文地址:HTML5′s async Script Attribute原文日期: 2010年09月22日翻译日期: 2013年08月22日 (译者注: 异步加载,可以理解为无阻塞并发处理.) (译者再 ...
- DB2数据库性能优化介绍
DB2数据库性能优化介绍 作者:chszs,转载需注明.博客主页:http://blog.csdn.net/chszs 前段时间,我从CSDN得到了这本书<DB2数据库性能调整和优化(第2版)& ...
- [Express] Level 2: Middleware -- 2
Logging Middleware Help finish the following middleware code in the logger.js file: On the response ...
- MySql服务器的启动和关闭
转自:http://zqding.iteye.com/blog/1562095 在windows下: 启动: .cd c:\mysql\bin .mysqld --console 关闭: .cd c: ...
- Linux开机执行顺序
1. 加载 BIOS 的硬件信息,并取得第一个开机装置的代号: 2. 读取第一个开机装置的 MBR 的 boot Loader (亦即是 lilo, grub 等等) 的开机信息: 3. 加载 K ...
- 学习笔记之高质量C++/C编程指南
高质量C++/C编程指南 http://man.lupaworld.com/content/develop/c&c++/c/c.htm 高质量C++/C编程指南(附录 C :C++/C 试题的 ...
- 工作随笔记 点击除div自身之外的地方,关闭自己
<div id="showSelectOptions" style="width:100px;height:100px;background-color:red;b ...
- Preventing CSRF in Java web apps---reference
reference from:http://ricardozuasti.com/2012/preventing-csrf-in-java-web-apps/ Cross-site request fo ...
- 3.6html学习笔记之样式选择
1.元素选择器 *{padding:0;margin:0;} p,span{} 2.类选择器 *.class{} p.class{} <p class="important class ...