Problem C: The Same Color

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 993  Solved: 595
[Submit][Status][Web Board]

Description

Diao Yang has many balls with different colors. Today he wants to divide his balls into two groups. But he does not know how to divide. Then Diao Ze gives him a suggestion: first you choose a ball and put it into the first group. Then from the second ball, if the color of the ball is same to the last ball you has chosen, then you put the ball into the other group. Otherwise you put the ball into the same group with the last ball. Diao Yang thinks it is OK.

Then the problem is, Diao Yang wants to know the product of the number of two groups’ balls. Can you help him?

Input

The first line contains an integer T, indicating the number of test cases.

In each test case, there are several lines, each line contains only one string with lowercas, indicating the color of the ball Diao Yang has chosen currently. Diao Yang will stop choosing when the string is equal to “END”. Note that the string “END” does not mean a color.

You can assume that there are at most 100 lines in each test case and each string has at most 10 letters.

Output

For each test case, output the answer in a line.

Sample Input

3
yellow
yellow
pink
red
red
green
END
blue
black
purple
purple
END
rose
orange
brown
white
END

Sample Output

9
3
0

HINT

In the first test case, the color of the first group’s balls are yellow, red, green, 3 balls in total. The color of the second group’s balls are yellow, pink, red, 3 balls in total too. So the product is 3×3=9.

In the second test case, the answer is 3×1=3 and in the third test case the answer is 4×0=0.

#include<iostream>
#include<stdio.h>
#include<string.h>
#include<map>
using namespace std;
int main()
{
int n;
scanf("%d",&n);
while(n--)
{
int g[];
g[]=;
g[]=;
char a[];
char b[];
scanf("%s",b);
int t=;
if(strcmp(b,"END")==)
{
printf("0\n");
continue;
}
scanf("%s",a);
while(strcmp(a,"END")!=)
{
if(strcmp(a,b)==)
{
t=-t;
g[t]++;
}
else
{ g[t]++;
}
strcpy(b,a);
scanf("%s",a);
}
printf("%d\n",g[]*g[]);
}
return ;
}

水题,只是考虑第一个颜色就是END就可以了。wa惨了

华中农业大学校赛--c The Same Color的更多相关文章

  1. 华中农业大学校赛 I Catching Dogs

    Catching Dogs Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 1140  Solved: 298[Submit][Status][Web B ...

  2. A喝酒(北京林业大学校赛)

    http://www.jisuanke.com/contest/1410 王大钉喜欢喝酒,存货都喝完了,他就去楼下买,正好楼下的商店为了响应学校的 ACM 校赛推出了优惠活动:凡是在本店买的啤酒,喝完 ...

  3. NOI.ac模拟赛20181021 ball sequence color

    T1 ball 可以发现每次推动球时,是将每个球的位置 −1-1−1 ,然后把最左边的球放到 P−1P-1P−1 处. 记个 −1-1−1 次数,再用set维护就好了. #include <bi ...

  4. 北京师范大学校赛C

    https://www.nowcoder.com/acm/contest/submit/0dff89ad7b8444719df155d507f3e1dd?ACMContestId=3&tagI ...

  5. Heaps(Contest2080 - 湖南多校对抗赛(2015.05.10)(国防科大学校赛决赛-Semilive)+scu1616)

    Problem H: Heaps Time Limit: 2 Sec  Memory Limit: 128 MBSubmit: 48  Solved: 9[Submit][Status][Web Bo ...

  6. 浙江工业大学校赛 小M和天平

    小M和天平 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Subm ...

  7. 浙江工业大学校赛 XiaoWei的战斗力

    XiaoWei的战斗力 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Tota ...

  8. 浙江工业大学校赛 画图游戏 BugZhu抽抽抽!!

    BugZhu抽抽抽!! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Tota ...

  9. 2016广东工业大学校赛 E题 GDUT-oj1173

    Problem E: 积木积水 Description 现有一堆边长为1的已经放置好的积木,小明(对的,你没看错,的确是陪伴我们成长的那个小明)想知道当下雨天来时会有多少积水.小明又是如此地喜欢二次元 ...

随机推荐

  1. go语言基础之switch语句 和 fallthrough 用途

    Go里面switch默认相当于每个case最后带有break,匹配成功后不会自动向下执行其他case,而是跳出整个switch, 但是可以使用fallthrough强制执行后面的case代码: 示例1 ...

  2. Fragment 简介 基础知识 总结 MD

    Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...

  3. Centos7 安装pycharm

    可以通过浏览器访问http://www.jetbrains.com/pycharm/,选择需要下载的版本,也可以通过wget下载可执行程序. [root@localhost ~] wget https ...

  4. (转)实现AI中LOD优化技术

    LOD(Level Of Detail)是3D渲染中用到的概念,按照wikipedia上的翻译,可以译为“细节层次”,它是一种根据与观察点的距离,来减低物体或者模型的复杂度来提升渲染效率的优化技术,因 ...

  5. cocos2dx坐标系

    原文转载:http://blog.csdn.net/ejet_shen/article/details/17327223 cocos2dx坐标系 支持下面几种坐标系: 1.屏幕坐标系 原点在左上角,X ...

  6. 退出app 退出应用程序

    退出app的两种方式1   创建activity的基类,让所有的activity都继承该基类,在基类中创建一个静态的activity列表,并在oncreate方法添加该activity,在退出时,遍历 ...

  7. 网络地址转换相关函数使用(inet_addr,inet_ntoa,inet_addr)

    aa 相关函数原型及参数类型: 函数原型:int inet_aton(const char *cp, struct in_addr *inp); in_addr_t inet_addr(const c ...

  8. Could not parse the file: d:\matlab7\toolbox\ccslink\ccslink\info.xml

    找到安装目录下的info.xml文件,用记事本打开. 我的安装目录是:D:\MATLAB7\toolbox\ccslink\ccslink 用记事本打开,显示如下内容: <productinfo ...

  9. 微信小程序 - 五星评分(含半分)

    转载自:http://blog.csdn.net/column/details/13721.html     演示:     下载:小程序-星级评论.zip  

  10. android KK版本号收到短信后,点亮屏的操作

    alps/packages/apps/mms/src/comandroid\mms\transation\MessagingNotification.java private static void ...