OUC_TeamTraining_#1 720
Time Limit:2000MS Memory Limit:0KB 64bit IO Format:%lld & %llu
Description
With water from the stream Galadriel filled the basin to the brim, and breathed on it, and when the water was still again she spoke. 'Here is the Mirror of Galadriel,' she said. 'I have brought you here so that you may look in it, if you will. For this is what your folk would call magic, I believe; though I do not understand clearly what they mean; and they seem also to use the same word of the deceits of the Enemy. But this, if you will, is the magic of Galadriel. Did you not say that you wished to see Elf-magic?' - Galadriel to Frodo and Sam, describing her Mirror.
We call a string S magical if every substring of S appears in Galadriel's Mirror (under lateral inversion). In other words, a magical string is a string where every substring has its reverse in the string.
Given a string S, determine if it is magical or not.
Input (STDIN):
The first line contains T, the number of test cases. The next T lines contain a string each.
Output (STDOUT):
For each test case, output "YES" if the string is magical, and "NO" otherwise.
Constraints:
1 <= T <= 100
1 <= |S| <= 10
S contains only lower-case characters.
Sample Input:
2
aba
ab
Sample Output:
YES
NO
Notes/Explanation of Sample Input:
For the first test case, the list of substrings are : a, b, ab, ba, aba. The reverse of each of these strings is present as a substring of S too.
For the second test case, the list of substring are : a, b, ab. The reverse of "ab", which is "ba" is not present as a substring of the string.
一个字符串的所有子串倒序后还是该字符串的子串。(规律就是这个字符串是对称的。)
#include<stdio.h>
#include<string.h>
char str[];
char str2[];
int main()
{
int t;
int len;
scanf("%d",&t);
while(t--)
{
scanf("%s",str);
len = strlen(str);
int i = ,j = len-;
for(;i < len;i++,j--)
{
str2[j] = str[i];
}
if(strcmp(str,str2) == )
printf("YES\n");
else
printf("NO\n");
memset(str,'\0',);
memset(str2,'\0',);
len = ;
}
return ;
}
Time Limit:2000MS Memory Limit:0KB 64bit IO Format:%lld & %llu
Description
'Strange are the ways of Men, Legolas! Here they have one of the marvels of the Northern World, and what do they say of it? Caves, they say! Caves! Holes to fly to in time of war, to store fodder in! My good Legolas, do you know that the caverns of Helm's Deep are vast and beautiful? There would be an endless pilgrimage of Dwarves, merely to gaze at them, if such things were known to be. Aye indeed, they would pay pure gold for a brief glance!
'And, Legolas, when the torches are kindled and men walk on the sandy floors under the echoing domes, ah! then, Legolas, gems and crystals and veins of precious ore glint in the polished walls; and the light glows through folded marbles, shell-like, translucent as the living hands of Queen Galadriel.' - Gimli, describing to Legolas the Glittering Caves of Aglarond.
While these caves are by and large natural, there is one place where the Men of Rohan have chiseled into the rock to create a magnificent exhibit. You have a wall of the cave consisting of 'lighted diamonds' arranged in a N by M grid (basically, you have a light behind each diamond which can be turned on or off). Further, you have a switch corresponding to each row of this diamond-grid. When you operate a switch, it will toggle (flip) the lights corresponding to that row.
You are given the current configuration of the lighted diamonds. Gimli challenges Legolas to turn on as many diamonds as possible using EXACTLY K on/off operations of the switches. Since Legolas is an Elf of the Wood and doesn't care much for things that glitter, he instead asks for your help. Note that the same switch (i.e. row) can be chosen multiple times.
Input (STDIN):
The first line contains the number of test cases T. Each test case contains N, M and K on the first line followed by N lines containing M characters each. The ith line denotes the state of the diamonds in the ith row, where '*' denotes a diamond which is on and '.' denotes a diamond which is off.
Output (STDOUT):
Output T lines containing the answer for the corresponding case.
Between successive test cases, there should not be any blank lines in the output.
Constraints:
1 <= T <= 100
1 <= N,M <= 50
1 <= K <= 100
Sample Input:
2
2 2 1
..
**
2 2 2
..
**
Sample Output:
4
2
Notes/Explanation of Sample Input:
In the first test case, row 1 can be toggled hence leaving all 4 lights to be in the ON state.
In the second test case, row 1 (or row 2) can be toggled twice, hence maintaining the state of the initial configuration.
#include<stdio.h>
#include<string.h>
char D[][];
int l[] = {};
int Min(int l[],int n)
{
int i,min = l[],j = ;
for(i = ;i < n;i++)
{
if(min > l[i])
{
min = l[i];
j = i;
}
}
return j;
}
int main()
{
int T,M,N,K,min = ;
scanf("%d",&T);
while(T--)
{
scanf("%d%d%d",&N,&M,&K);
getchar();
int i,j; for(i = ;i < N;i++)
{
for(j = ;j <M;j++)
{
scanf("%c",&D[i][j]);
if(D[i][j] == '*')l[i]++;
}
getchar();
} while(K--)
{
min = Min(l,N);
l[min] = M - l[min];
}
int sum = ;
for(i = ;i < N;i++)
{
sum += l[i];
}
printf("%d\n",sum);
memset(l,,sizeof(l));
}
return ;
}
下面这道题一直交不对不知道是不是理解题错了。
G - The Glittering Caves of Aglarond
Time Limit:2000MS Memory Limit:0KB 64bit IO Format:%lld & %llu
Submit Status Practice SPOJ AMR12G
Description
' Strange are the ways of Men, Legolas! Here they have one of the marvels of the Northern World, and what do they say of i? Caves, they say! Caves! Holes to fly to in time of war, to store fodder in! My good Legolas, do you know that the caverns of Helm's Deep are vast and beautiful? There would be an endless pilgrimage of Dwarves, merely to gaze at them, if such things were known to be. Aye indeed, they would pay pure gold for a brief glance!'And, Legolas, when the torches are kindled and men walk on the sandy floors under the echoing domes, ah! then, Legolas, gems and crystals and veins of precious ore glint in the polished walls; and the light glows through folded marbles, shell-like, translucent as the living hands of Queen Galadriel.' - Gimli, describing to Legolas the Glittering Caves of Aglarond.While these caves are by and large natural, there is one place where the Men of Rohan have chiseled into the rock to create a magnificent exhibit. You have a wall of the cave consisting of 'lighted diamonds' arranged in a N by M grid (basically, you have a light behind each diamond which can be turned on or off). Further, you have a switch corresponding to each row of this diamond-grid. When you operate a switch, it will toggle (flip) the lights corresponding to that row.You are given the current configuration of the lighted diamonds. Gimli challenges Legolas to turn on as many diamonds as possible using EXACTLY K on/off operations of the switches. Since Legolas is an Elf of the Wood and doesn't care much for things that glitter, he instead asks for your help. Note that the same switch (i.e. row) can be chosen multiple times.Input (STDIN):The first line contains the number of test cases T. Each test case contains N, M and K on the first line followed by N lines containing M characters each. The ith line denotes the state of the diamonds in the ith row, where '*' denotes a diamond which is on and '.' denotes a diamond which is off.Output (STDOUT):Output T lines containing the answer for the corresponding case.Between successive test cases, there should not be any blank lines in the output.Constraints:1 <= T <= 1001 <= N,M <= 501 <= K <= 100Sample Input:22 2 1..**2 2 2..**Sample Output:42Notes/Explanation of Sample Input:In the first test case, row 1 can be toggled hence leaving all 4 lights to be in the ON state.In the second test case, row 1 (or row 2) can be toggled twice, hence maintaining the state of the initial configuration.
Strange are the ways of Men, Legolas! Here they have one of the marvels of the Northern World, and what do they say of it? Caves, they say! Caves! Holes to fly to in time of war, to store fodder in! My good Legolas, do you know that the caverns of Helm's Deep are vast and beautiful? There would be an endless pilgrimage of Dwarves, merely to gaze at them, if such things were known to be. Aye indeed, they would pay pure gold for a brief glance!
'And, Legolas, when the torches are kindled and men walk on the sandy floors under the echoing domes, ah! then, Legolas, gems and crystals and veins of precious ore glint in the polished walls; and the light glows through folded marbles, shell-like, translucent as the living hands of Queen Galadriel.' - Gimli, describing to Legolas the Glittering Caves of Aglarond.
While these caves are by and large natural, there is one place where the Men of Rohan have chiseled into the rock to create a magnificent exhibit. You have a wall of the cave consisting of 'lighted diamonds' arranged in a N by M grid (basically, you have a light behind each diamond which can be turned on or off). Further, you have a switch corresponding to each row of this diamond-grid. When you operate a switch, it will toggle (flip) the lights corresponding to that row.
You are given the current configuration of the lighted diamonds. Gimli challenges Legolas to turn on as many diamonds as possible using EXACTLY K on/off operations of the switches. Since Legolas is an Elf of the Wood and doesn't care much for things that glitter, he instead asks for your help. Note that the same switch (i.e. row) can be chosen multiple times.
Input (STDIN):
The first line contains the number of test cases T. Each test case contains N, M and K on the first line followed by N lines containing M characters each. The ith line denotes the state of the diamonds in the ith row, where '*' denotes a diamond which is on and '.' denotes a diamond which is off.
Output (STDOUT):
Output T lines containing the answer for the corresponding case.
Between successive test cases, there should not be any blank lines in the output.
Constraints:
1 <= T <= 100
1 <= N,M <= 50
1 <= K <= 100
Sample Input:
2
2 2 1
..
**
2 2 2
..
**
Sample Output:
4
2
Notes/Explanation of Sample Input:
In the first test case, row 1 can be toggled hence leaving all 4 lights to be in the ON state.
In the second test case, row 1 (or row 2) can be toggled twice, hence maintaining the state of the initial configuration.
题目的意思应该是有一队士兵要被涂上颜色,每次必须涂K个士兵,传送带可以向前走可以向后走。给出规定的颜色,如果能被涂出颜色 输出最少要涂色的次数 如果不能 输出-1
我是这样想的,要是能被涂好颜色必须 前K个或后K个是一样的颜色,否则不行。如果前K个不一样后K个一样传送带从前向后走,如果前K个一样后K个不一样 传送带从后向前走,如果两边都能走,则从前向后,从后向前结果应该是一样的。这里还有一个问题是,不会存在传送带一会向前一会向后的情况,那样就没有意义了。所以在一开始就要确定方向就好了。然后传送带在走的过程中每次处理K个士兵,先都涂上K个中第一个的颜色,不符合要求的留下来再涂。写成代码就是如果前后不一样就要加1如果一样集齐K个后就要加1.
但是交了就是不对 好懊恼 要是有路过的大神求指点~~
#include<stdio.h>
#include<string.h>
char D[][];
int l[] = {};
int Min(int l[],int n)
{
int i,min = l[],j = ;
for(i = ;i < n;i++)
{
if(min > l[i])
{
min = l[i];
j = i;
}
}
return j;
}
int main()
{
int T,M,N,K,min = ;
scanf("%d",&T);
while(T--)
{
scanf("%d%d%d",&N,&M,&K);
getchar();
int i,j; for(i = ;i < N;i++)
{
for(j = ;j <M;j++)
{
scanf("%c",&D[i][j]);
if(D[i][j] == '*')l[i]++;
}
getchar();
} while(K--)
{
min = Min(l,N);
l[min] = M - l[min];
}
int sum = ;
for(i = ;i < N;i++)
{
sum += l[i];
}
printf("%d\n",sum);
memset(l,,sizeof(l));
}
return ;
}
编译器太难用了颜色什么的忽略吧 凑活看吧
OUC_TeamTraining_#1 720的更多相关文章
- VR全景智慧城市-720全景项目行业应用
		
VR虚拟现实.VR全景概念已成为科技发展热议的焦点.在这样的市场大环境下,全景智慧城市做为一家对大众创新万众创业和用户体验为理念的VR全景城市化信息搜素平台平地而生成为的VR行业领跑者,致力VR全景V ...
 - 2014年最新720多套Android源码2.0GB免费一次性打包下载
		
之前发过一个帖子,但是那个帖子有点问题我就重新发一个吧,下面的源码是我从今年3月份开始不断整理源码区和其他网站上的android源码,目前总共有720套左右,根据实现的功能被我分成了100多个类,总共 ...
 - VR全景加盟、720全景、VR全景技术平台-全国招商模式疯狂开始
		
VR全景:互联网与实体店的完美结合 VR元年已过,VR项目.VR创业潮转为理性,VR行业分为两个方向:硬件和内容.硬件又分为VR头显和辅助设备,内容又分为VR全景和VR虚拟内容,如游戏.娱乐.根据行 ...
 - win10连接宽带,拨号提示错误720:不能建立到远程计算机的连接,解决方法
		
使用账号密码登录时,一直报720错误.解决方法是卸载以下IP驱动.卸载之后重新连接就正常了.亲测有效
 - win10 校园宽带连接不上的解决办法(错误720、“以太网”没有有效的ip设置)
		
遇到的问题如下图所示: 插上宽带后,查看以太网状态显示如下: 创建新连接宽带(PPPoE)(R)后,连接失败,错误为720,显示如下: 以太网网络诊断后,结果显示“以太网”没有有效的Ip设置,如下图所 ...
 - AOJ.720 丢失的学妹
		
缺失的学妹 考察点 STL MAP Time Mem Len Lang 3.81s 39.1MB 0.68K G++ 题意分析 给出妹子学号的个数n,给出n个学号,和n-1个学号,求在n学号中那个没有 ...
 - PCB 720全景图嵌入登入界面应用实现
		
通常软件主界面或登入界面背景图片通常采用固定图片,这里介绍如何将720度全景图嵌入到登入界面中来, 这里用的素材来源于这里上个月在公司里拍摄的全景图, 一.拍摄720度全景图片, 建议:最好用三角固定 ...
 - 【Leetcode_easy】720. Longest Word in Dictionary
		
problem 720. Longest Word in Dictionary 题意: solution1: BFS; class Solution { public: string longestW ...
 - PTA数据结构与算法题目集(中文)  7-20
		
PTA数据结构与算法题目集(中文) 7-20 7-20 表达式转换 (25 分) 算术表达式有前缀表示法.中缀表示法和后缀表示法等形式.日常使用的算术表达式是采用中缀表示法,即二元运算符位于两个 ...
 
随机推荐
- luogu2858奶牛零食题解--区间DP
			
题目链接 https://www.luogu.org/problemnew/show/P2858 一句话题意: https://cn.vjudge.net/problem/POJ-3186#autho ...
 - php实现拼图滑块验证的思考及部分实现
			
实现拼图滑块验证,我觉得其中比较关键的一点就是裁剪图片,最起码需要裁剪出下面两张图的样子 底图 滑块图 一张底图和一张滑块图,其中底图实现起来比较简单可以使用添加水印的方式直接将一张拼图形状的半透明图 ...
 - otool随笔测试
			
otool 工具 查看库/反编译等二进制信息 1 依赖库查询 otool -L Payload/XXX.app/XXX 2 查看该应用是否砸壳 otool -l Payload/XXX.app/XXX ...
 - world 页面横向
			
今天浏览world时,发现一个现象: 出现的页面比较宽,如何做的呢? 操作如下: 1.打开一个新的world 2.选择布局页签,分隔符,分节符的下一页 3.鼠标放到第二页上,选择页签布局,纸张方向,选 ...
 - 2019年C题  视觉情报信息分析
			
2019 年第十六届中国研究生数学建模竞赛C 题 任务1中 图三:图3 中拍照者距离地面的高度 目录: 0.试题分析: 1.构建摄像机模型 2.摄像机参数假定 3.像平面坐标计算 4.图像标定及数值测 ...
 - 【Day3】4.Xpath语法与案例
			
课程目标 1.谷歌浏览器配置Xpath 2.Xpath常用语法 3.Xpath常用案例 1.谷歌浏览器配置Xpath Xpath下载:http://chromecj.com/web-developme ...
 - 【异常】ERROR main:com.cloudera.enterprise.dbutil.SqlFileRunner: Exception while executing ddl scripts. com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'ROLES' already exists
			
1 详细异常 2019-10-11 10:33:55,865 INFO main:com.cloudera.server.cmf.Main: ============================= ...
 - yum list报一些error的组件
			
1 删除那些无效的参数配置,就不再报错了
 - Django模型层:单表操作,多表操作,常用(非常用)字段和参数,Django-model进阶
			
一.web应用 二.模板的导入与继承 三.静态文件相关 四.inclusion_tag:返回html片段 五.模型层 一.web应用 -s包括两个部分:web服务器+application -目前阶段 ...
 - Istio技术与实践05:如何用istio实现流量管理
			
Istio是Google继Kubernetes之后的又一开源力作,主要参与的公司包括Google,IBM,Lyft等,它提供了完整的非侵入式的微服务治理解决方案,解决微服务的管理.网络连接以及安全管理 ...