题目链接:Quiz for EXO-L

题面:

B - Quiz for EXO-L

Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu

Submit Status Practice ZOJ 3864

Description

Exo (Korean: 엑소; Chinese:爱咳嗽; often stylized as EXO) is a Chinese-South Korean boy band based in Seoul, South Korea. Formed by SM Entertainment in 2011, the group consists of twelve members separated into two subgroups, EXO-K and EXO-M, performing music in Korean and Mandarin, respectively. The group officially debuted on April 8, 2012, with Suho, Baekhyun, Chanyeol, D.O, Kai, and Sehun under the Korean subgroup while Xiumin, Luhan, Kris, Lay, Chen, and Tao are under the Mandarin group. Kris filed a lawsuit against S.M. to be removed from the group, and Luhan followed suit in October 2014. The band now promotes with 10 members since mid-October 2014, which consists of 8 Korean and 2 Chinese members.

In their first album, each member of EXO has a kind of super power. For example, Tao can control time and Lay has a super power of healing. The badges are the symbols of their super powers. Each member of EXO has an unique badge. The following table shows the shapes of their badges.

Baekhyun Chanyeol Chen D.O
Kai Kris Lay Luhan
Sehun Suho Tao Xiumin

EXO’s official fanclub name has been announced to be EXO-L. EXO-L is short for EXO-LOVE, L being the letter between M and K in the alphabet, signifying all the fans' love for both EXO-K and EXO-M of EXO, and also holds the meaning of 'EXO and the fans are one' like their team slogan 'WE ARE ONE.'

You should help an EXO-L pass a quiz about image recognition. The quiz requires a program to recognize the badges. The input is one of the above 12 images with rotation, and the output should be the owner of the badge in the image. The badge is rotated at an unknown angle. And each image is a square matrix. The badges will never touch or exceed the boundary of the image.

Since the images are large, we will compress the images. Each pixel in the image is either 1(white) or 0(black) after binarization. The compress method is simple:

  • Concatenate the pixels in the row first order to a string.
  • Split the string to some runs with same characters, and two adjacent runs have different characters.
  • Output the length of each run.

For example, an image in size 6×6:

111111
100101
100011
110111
101001
111111

We can compress it as the following:

  • Concatenate the pixels in the row first order, then we can get

    111111100101100011110111101001111111
    
  • The runs are
    1111111 00 1 0 11 000 1111 0 1111 0 1 00 1111111
    
  • So the result of compressed images is
    7 2 1 1 2 3 4 1 4 1 1 2 7
    

Note that in this task the first run and the last run is always in white.

Input

There are multiple test cases. The first line of input contains an integer T indicating the number of test cases. For each test case:

The first line contains 2 integers n and mn is the size of the square image. m is the number of the runs in the compressed images. (100≤n ≤ 900)

The second line contains m positive integers, indicating the length of the each runs in the compressed image. (The sum of the integers isn2).

Output

the length of each run.

For example, an image in size 6×6:

111111
100101
100011
110111
101001
111111

We can compress it as the following:

  • Concatenate the pixels in the row first order, then we can get

    111111100101100011110111101001111111
    
  • The runs are
    1111111 00 1 0 11 000 1111 0 1111 0 1 00 1111111
    
  • So the result of compressed images is
    7 2 1 1 2 3 4 1 4 1 1 2 7
    

Note that in this task the first run and the last run is always in white.

Input

There are multiple test cases. The first line of input contains an integer T indicating the number of test cases. For each test case:

The first line contains 2 integers n and mn is the size of the square image. m is the number of the runs in the compressed images. (100≤n ≤ 900)

The second line contains m positive integers, indicating the length of the each runs in the compressed image. (The sum of the integers isn2).

Output

For each case, output the owner of the badge in one line. Your output should be formated as one of following words: "Suho", "Baekhyun", "Chanyeol", "D.O", "Kai", "Sehun", "Xiumin", "Luhan", "Kris", "Lay", "Chen", and "Tao".

Sample Input

2
100 443
1445 1 99 2 97 3 97 4 6 1 88 5 5 2 88 5 4 4 86 6 4 4 73 1 12 6 3 6 72 4 8 6 5 5 72 6 6 6 5 6 72 7 3 6 6 6 12 1 59 16 7 6 9 3 60 14 8 6 6 6 61 13 9 6 3 7 65 12 7 16 8 1 45 3 10 12 5 15 6 4 45 5 9 14 3 12 6 6 45 6 8 15 2 9 9 5 47 5 7 17 1 7 10 6 47 6 6 17 2 3 13 5 48 6 5 18 17 6 49 5 5 8 1 10 5 3 8 5 50 6 3 8 5 7 3 7 6 5 50 6 3 8 7 18 2 5 52 5 3 7 10 23 52 6 2 7 13 20 52 6 3 6 15 17 53 7 2 5 19 15 49 10 2 5 21 16 44 12 2 4 24 17 38 12 6 3 25 18 34 12 6 4 26 7 1 13 31 9 7 6 25 7 5 10 34 4 6 9 25 7 8 5 46 8 25 8 58 9 25 7 59 8 25 8 59 8 25 7 48 4 7 8 26 7 8 2 35 9 5 8 25 6 7 7 33 11 3 8 25 4 6 11 35 18 25 3 5 15 36 16 25 3 3 15 40 17 21 4 2 14 44 17 19 5 2 10 49 17 16 6 2 8 51 20 13 6 2 6 52 23 11 7 2 4 53 5 2 18 8 8 2 5 51 6 5 8 2 7 6 7 3 5 51 5 8 4 5 9 2 8 4 4 50 6 17 18 5 5 49 5 13 3 2 18 5 5 48 6 11 5 3 16 7 5 47 6 9 8 2 16 7 5 47 5 7 11 3 14 9 4 46 3 8 14 4 13 9 4 45 1 8 16 6 14 8 2 54 16 9 13 62 9 3 5 8 15 60 6 6 5 8 16 58 5 9 5 7 5 2 9 58 2 12 5 6 6 5 7 72 5 5 5 8 5 72 5 4 6 11 2 73 3 5 5 87 3 5 5 87 3 5 4 89 1 6 4 97 3 97 2 98 2 1445
100 451
1449 2 96 4 96 5 94 6 93 6 94 5 93 6 93 6 10 4 78 7 7 13 72 6 6 18 80 21 62 2 14 24 58 3 14 26 55 3 13 15 6 8 54 4 10 20 8 5 51 5 8 25 8 3 51 4 7 29 7 3 49 5 6 31 7 2 48 5 6 15 4 14 7 1 48 5 5 15 9 11 54 6 4 15 12 10 53 5 4 16 14 8 53 5 3 16 16 8 51 6 3 8 1 6 18 8 50 6 2 8 2 6 19 7 50 6 2 7 3 5 7 21 5 1 43 6 1 7 4 5 4 24 4 2 43 6 1 7 4 5 2 26 4 3 43 12 4 5 2 28 3 3 43 12 4 5 16 14 3 4 42 11 5 5 19 12 3 4 42 10 5 5 15 1 5 10 3 5 41 10 6 3 16 1 7 8 4 5 40 9 7 3 16 2 7 8 3 7 32 1 6 8 7 3 16 2 8 7 4 7 29 5 4 8 7 3 16 3 7 8 4 6 29 6 4 7 7 3 16 3 8 7 5 5 29 7 3 8 7 2 16 3 8 8 5 3 31 6 4 8 6 2 16 4 7 8 40 6 4 8 6 1 16 4 6 10 40 6 3 9 6 1 15 4 6 10 42 4 3 11 20 4 6 10 42 4 4 12 18 4 6 11 42 3 4 15 15 4 5 12 43 2 4 26 3 5 5 12 43 2 4 25 4 5 4 6 1 6 44 1 5 6 2 14 6 5 4 6 1 6 44 1 5 7 5 6 9 6 3 7 1 6 50 8 19 6 2 7 2 6 51 8 18 6 1 7 3 6 51 9 16 15 3 6 52 10 13 15 4 5 54 11 11 14 5 5 47 1 6 14 6 15 6 4 49 1 6 33 6 5 49 2 6 31 7 4 50 3 7 27 8 4 52 4 6 25 9 3 53 6 7 20 10 3 55 29 12 2 57 26 14 1 60 23 78 20 6 5 71 15 7 8 72 10 8 7 92 7 92 6 93 6 94 6 94 5 95 4 97 2 1448

Sample Output

Xiumin
Sehun

Hint

The images in the sample input are visualized as:

Sample 1
Sample 2

解题:

这绝对是我目前为止做过的最掉炸天的图形处理题了。之前毫无思路,看了别人的题解之后,才知道去判断图中黑白联通块的数量,可以判断出十张图,然而有两张图是一样的,即给出的两组样例。只能说题目设计的很有心机,通过给定的两组样例,数黑白块数量,拿白块除以黑块,一个值为4.3,一个值为4.8,以4.5为界判断即可。(深搜会爆栈,然而我应该想到,所以用广搜)。

代码:(代码写得很挫,看看就好..)

#include <iostream>
#include <cstdio>
#include <fstream>
#include <cstring>
#include <queue>
using namespace std;
bool status1[1000][1000],status2[1000][1000];
bool vis1[1000][1000],vis2[1000][1000];
int t,n,m,tmp,cnt_black,cnt_white,flag,row,column,whiteblock,blackblock,ans;
void bfs1(int x,int y)
{int xx,yy;queue <int> q1;queue <int> q2;status1[x][y]=0;q1.push(x);q2.push(y-1);q1.push(x);q2.push(y+1);q1.push(x-1);q2.push(y-1);q1.push(x-1);q2.push(y+1);q1.push(x-1);q2.push(y);q1.push(x+1);q2.push(y-1);q1.push(x+1);q2.push(y+1);q1.push(x+1);q2.push(y);while(!q1.empty()){xx=q1.front();q1.pop();yy=q2.front();q2.pop();if(xx<0||yy<0||xx>901||yy>901)continue;if(status1[xx][yy]==0)continue;status1[xx][yy]=0;q1.push(xx);q2.push(yy-1);q1.push(xx);q2.push(yy+1);q1.push(xx-1);q2.push(yy-1);q1.push(xx-1);q2.push(yy+1);q1.push(xx-1);q2.push(yy);q1.push(xx+1);q2.push(yy-1);q1.push(xx+1);q2.push(yy+1);q1.push(xx+1);q2.push(yy);}
}void search1()
{for(int i=1;i<=n;i++){for(int j=1;j<=n;j++){if(status1[i][j]==1){bfs1(i,j);whiteblock++;}}}
}
void bfs2(int x,int y)
{int xx,yy;queue <int> q1;queue <int> q2;status2[x][y]=1;q1.push(x);q2.push(y-1);q1.push(x);q2.push(y+1);q1.push(x-1);q2.push(y-1);q1.push(x-1);q2.push(y+1);q1.push(x-1);q2.push(y);q1.push(x+1);q2.push(y-1);q1.push(x+1);q2.push(y+1);q1.push(x+1);q2.push(y);while(!q1.empty()){xx=q1.front();q1.pop();yy=q2.front();q2.pop();if(xx<0||yy<0||xx>901||yy>901)continue;if(status2[xx][yy]==1)continue;status2[xx][yy]=1;q1.push(xx);q2.push(yy-1);q1.push(xx);q2.push(yy+1);q1.push(xx-1);q2.push(yy-1);q1.push(xx-1);q2.push(yy+1);q1.push(xx-1);q2.push(yy);q1.push(xx+1);q2.push(yy-1);q1.push(xx+1);q2.push(yy+1);q1.push(xx+1);q2.push(yy);}
}void search2()
{for(int i=1;i<=n;i++){for(int j=1;j<=n;j++){if(status2[i][j]==0){bfs2(i,j);blackblock++;}}}
}int main()
{scanf("%d",&t);while(t--){scanf("%d%d",&n,&m);whiteblock=blackblock=cnt_black=cnt_white=0;flag=row=column=1;memset(status1,0,sizeof(status1));memset(status2,0,sizeof(status2));memset(vis1,-1,sizeof(vis1));memset(vis2,-1,sizeof(vis2));for(int i=0;i<m;i++){scanf("%d",&tmp);if(flag==1){for(int j=0;j<tmp;j++){status1[row][column]=status2[row][column]=1;cnt_white++;if(column==n){row++;column=0;}column++;}flag*=-1;}else{for(int j=0;j<tmp;j++){cnt_black++;if(column==n){row++;column=0;}column++;}flag*=-1;}}search1();search2();ans=blackblock*100+whiteblock;if(ans==902)printf("Baekhyun\n");else if(ans==501)printf("Chanyeol\n");else if(ans==103)printf("Chen\n");else if(ans==102)printf("D.O\n");else if(ans==213)printf("Kai\n");else if(ans==301)printf("Kris\n");else if(ans==602)printf("Lay\n");else if(ans==508)printf("Luhan\n");else if(ans==208)printf("Suho\n");else if(ans==204)printf("Tao\n");else{if(2*cnt_white>(cnt_black*9))printf("Xiumin\n");else printf("Sehun\n");}}
}

ZOJ 3864 Quiz for EXO-L相关推荐

  1. zoj 3864 Quiz for EXO-L(连通块 bfs)

    Quiz for EXO-L Time Limit: 2 Seconds      Memory Limit: 65536 KB Exo (Korean: 엑소; Chinese:爱咳嗽; often ...

  2. ZOJ 3992 2017CCPC秦皇岛 L:One-Dimensional Maze

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3992 题意: 一条长度为n的直线,你一开始在位置m上 其中每个整 ...

  3. ZOJ3864:Quiz for EXO-L(BFS)

    Exo (Korean: 엑소; Chinese:爱咳嗽; often stylized as EXO) is a Chinese-South Korean boy band based in Seo ...

  4. zoj 1204 Additive equations

    ACCEPT acm作业 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=204 因为老师是在集合那里要我们做这道题.所以我很是天 ...

  5. 2018 ICPC 青岛 L. Sub-cycle Graph(生成函数)

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 L. Sub-cycle Graph Weblink https://zoj.pintia.cn/pr ...

  6. Week 3 Quiz - Shallow Neural Networks

    2019独角兽企业重金招聘Python工程师标准>>> Week 3 Quiz - Shallow Neural Networks Which of the following ar ...

  7. 模拟 ZOJ 3878 Convert QWERTY to Dvorak

    题目传送门 1 /* 2 模拟:手敲map一一映射,累! 3 除了忘记读入字符串不能用gets用getline外还是很顺利的AC了:) 4 */ 5 #include <cstdio> 6 ...

  8. 矩阵连乘积 ZOJ 1276 Optimal Array Multiplication Sequence

    题目传送门 1 /* 2 题意:加上适当的括号,改变计算顺序使得总的计算次数最少 3 矩阵连乘积问题,DP解决:状态转移方程: 4 dp[i][j] = min (dp[i][k] + dp[k+1] ...

  9. ZOJ 3597 Hit the Target! (线段树扫描线 -- 矩形所能覆盖的最多的点数)

    ZOJ 3597 题意是说有n把枪,有m个靶子,每把枪只有一发子弹(也就是说一把枪最多只能打一个靶子), 告诉你第 i 把枪可以打到第j个靶, 现在等概率的出现一个连续的P把枪,在知道这P把枪之后,你 ...

最新文章

  1. 为什么150kHz定位,距离越远接收信号越强呢?
  2. 你应该了解的CSS语义化命名方式及常用命名规则
  3. #舍得Share#Flash Media Server4.5迅雷高速下载地址by lwxshow
  4. Linux---输入与输出函数总结
  5. GNU ARM汇编伪操作(Directives) 命令集
  6. MySQL 5.6 Threadpool(优先队列)介绍及性能测试【转】
  7. 【RS码2】RS码的BM迭代译码原理详解及MATLAB实现(不使用MATLAB库函数-代码见CSDN同名资源)
  8. linux语言 翻译工具,Linux文本转语音工具eSpeak介绍
  9. swoole 捕捉php错误,swoole怎么处理错误
  10. 5.4万Star全部归零,项目作者:十分后悔
  11. 句向量的表示(上)—无监督
  12. Airflow 中文文档:安全
  13. 3GPP Releases
  14. 京东今天还在用 .NET 架构的原因是什么?
  15. mqtt等待来自服务器响应超时,等待来自服务器的响应时超时 (32000) at org.eclipse.paho.client.mqttv3.interna...
  16. ML--K-近邻算法
  17. NB-IOT之一个完整的BC95 UDP从开机到数据发送接收过程
  18. 基于Java JAAS表单的身份验证
  19. 色彩空间与色彩深度。详细分析相机中sRGB/AdobeRGB、RAW/JPG到底该怎么选
  20. 反双曲余弦 双曲余弦_不要“聪明”:双曲括号反模式

热门文章

  1. 「1.9W字总结」一份通俗易懂的 TS 教程,入门 + 实战!
  2. 44道Redis面试题,含参考答案!
  3. 时事评论---宣誓不欠薪,好一场秀
  4. SSH密钥登录系统报错Permissions 0644 for ‘xxx‘ re too open
  5. 方便的U盘量产工具不刻盘装系统
  6. 英语不好,能学好计算机吗?
  7. 考研英语善变的more than:后加词性不同,意思有变
  8. python画圣诞树【方块圣诞树、线条圣诞树、豪华圣诞树】
  9. 转载--文章(感谢陈晨博主分享) 关于 Json.net
  10. 【渝粤教育】电大中专新媒体营销实务 作业 题库