UVA11734_Big Number of Teams will Solve This
题意很简单,本身也是个水题。
给你两个字符串,如果两个串完全相同,那么输出yes;如果两串只是空格的不同,出去空格后完全相同,那么输出Output Format Error,否则输出Wrong Answer。
很简单,在两个数组上面各设置一个指针逐个比对向后移动,同时设置两个flag分别标记有无不相同的字符或者空格就ok了。
#include <iostream>
#include <cstdio>
#include <cstring>
#define maxn 1000100
using namespace std; char s1[maxn],s2[maxn];
int n,m,t,x1,x2,T;
bool flag1,flag2; void compare()
{
x1=x2=;
if (strlen(s1)!=strlen(s2)) flag2=false;
while (s1[x1] && s2[x2])
{
if (s1[x1]==s2[x2]) x1++,x2++;
else
{
if (s1[x1]==' ') x1++;
else if (s2[x2]==' ') x2++;
else
{
flag1=false;
return;
}
}
}
if (!s1[x1] && !s2[x2]) return;
if (s1[x1])
{
for (int i=x1; s1[i]; i++)
if (s1[i]!=' ')
{
flag1=false;
return;
}
}
for (int i=x2; s2[i]; i++)
if (s2[i]!=' ')
{
flag1=false;
return;
}
} int main()
{
scanf("%d",&T);gets(s1);
for (int i=; i<=T; i++)
{
flag2=flag1=true;
gets(s1);gets(s2);
compare();
printf("Case %d: ",i);
if (!flag1) puts("Wrong Answer");
else if (!flag2) puts("Output Format Error");
else puts("Yes");
}
return ;
}
UVA11734_Big Number of Teams will Solve This的更多相关文章
- UVA 11734 Big Number of Teams will Solve This
大水题,不解释啦! #include<cstdio> #include<cstring> #define maxn 50 using namespace std; char s ...
- Zerojudge解题经验交流
题号:a001: 哈囉 背景知识:输出语句,while not eof 题号:a002: 簡易加法 背景知识:输出语句,while not eof,加法运算 题号:a003: 兩光法師占卜術 背景知识 ...
- Gym 100952E&&2015 HIAST Collegiate Programming Contest E. Arrange Teams【DFS+剪枝】
E. Arrange Teams time limit per test:2 seconds memory limit per test:64 megabytes input:standard inp ...
- Rnadom Teams
Rnadom Teams 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.actioncid=88890#problem/B 题目: Descript ...
- CF478 B. Random Teams 组合数学 简单题
n participants of the competition were split into m teams in some manner so that each team has at le ...
- cf478B Random Teams
B. Random Teams time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
- codeforces 478B Random Teams
codeforces 478B Random Teams 解题报告 题目链接:cm.hust.edu.cn/vjudge/contest/view.action?cid=88890#probl ...
- Random Teams
n participants of the competition were split into m teams in some manner so that each team has at le ...
- single number i && ii && iii
Problem statement Elementary knowledge: There is a popular question when I seeked my job at Beijing: ...
随机推荐
- 20155321 2016-2017-2《Java程序设计》课程总结
20155321 2016-2017-2<Java程序设计>课程总结 每周作业链接汇总 预备作业1:我期望的师生关系 预备作业2:学习情况的相关调查 预备作业3:安装虚拟机以及学习Linu ...
- Ubuntu + apache + Mysql +php
发生了乱码问题: 打开apache配置文件: sudo gedit /etc/apache2/apache2.conf,在最后面加上:AddDefaultCharset UTF-8,如果还乱码,再将U ...
- python 逆波兰式
逆波兰式,也叫后缀表达式 技巧:为简化代码,引入一个不存在的运算符#,优先级最低.置于堆栈底部 class Stack(object): '''堆栈''' def __init__(self): se ...
- angular之$watch() $watchGroup()和$watchCollection()
$watch $watch主要是用来监听一个对象,在对象发生变化时触发某个事件. 用法: $scope.$watch(watchFn,watchAction, deepWatch) 接下来讲一下这几个 ...
- grep 文件内容搜索
比如现在我们要查找在/home/userlan/目录中哪些文件中包含foobar这个关键字 1. 打开终端2. 输入命令 grep -rl "foobar" /home/userl ...
- jenkins 入门教程
jenkins是一个广泛用于持续构建的可视化web工具,持续构建说得更直白点,就是各种项目的"自动化"编译.打包.分发部署.jenkins可以很好的支持各种语言(比如:java, ...
- 学习笔记之ubuntu修改固定IP脚本
一.shell脚本编程 二.正则表达式 三.linux修改IP的方法 #!/bin/bash cd /etc/network/ stty erase '^?' write_interfaces() { ...
- 创建oracle数据表示例sql
CREATE TABLE "BRAND_RELATION" ( "ID" NUMBER(10,0) NOT NULL ENABLE, ...
- Linux 安装Zookeeper<准备>(使用Mac远程访问)
阅读本文需要安装JDK 一 Zookeeper简介 zookeeper是用java语言编写的一款为分布式应用所设计的协调服务 zookeeper是apacahe hadoop的子项目 使用zookee ...
- NO.02---聊聊Vue提升
如果本篇有看不明白的地方,请翻阅上一篇文章 上一篇我们讲了如何通过一些简单的动作来改变 store.js 中的数据对象,在实际工作中,这是完全无法满足工作需求的,所以这篇我们来说说如何做一些简单的流程 ...