OUC_Summer Training_ DIV2_#4之数据结构
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=26100#problem/A
Time Limit:1000MS Memory Limit:30000KB 64bit IO Format:%I64d & %I64u
Description
Given two strings s and t, you have to decide whether s is a subsequence of t, i.e. if you can remove characters from t such that the concatenation of the remaining characters is s.
Input
Output
Sample Input
sequence subsequence
person compression
VERDI vivaVittorioEmanueleReDiItalia
caseDoesMatter CaseDoesMatter
Sample Output
Yes
No
Yes
No
//是很简单的题啦 但是我数组开的有点小 总是runtime error
#include<stdio.h>
#include<string.h>
char a[];
char b[];
int main()
{
int i,j,na,nb,t = ,m = ;
char c;
while(scanf("%s",a) != EOF)
{
scanf("%s",b);
na = strlen(a);
nb = strlen(b);
for(i = ;i < na;i++)
{
for(j = t;j < nb;j++)
{
if(a[i] == b[j])
{
m++;
t = j + ;
break;
}
}
}
if(m == na )printf("Yes\n");
else printf("No\n");
m = ;
t = ;
}
return ;
}
Time Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64u
Description
q By an integer sequence P = p1 p2...pn where pi is the number of left parentheses before the ith right parenthesis in S (P-sequence).
q By an integer sequence W = w1 w2...wn where for each right parenthesis, say a in S, we associate an integer which is the number of right parentheses counting from the matched left parenthesis of a up to a. (W-sequence).
Following is an example of the above encodings:
S (((()()())))
P-sequence 4 5 6666
W-sequence 1 1 1456
Write a program to convert P-sequence of a well-formed string to the W-sequence of the same string.
Input
Output
Sample Input
2
6
4 5 6 6 6 6
9
4 6 6 6 6 8 9 9 9
Sample Output
1 1 1 4 5 6
1 1 2 4 5 1 1 3 9
//先把括号的情况还原,在用递归的方法给括号配对,递归不是很熟练,虽然很简单,写了好几遍才对。
#include<stdio.h>
char y[];
int w[],n,l,j;
int f()
{
int s=;
while()
if(y[j]=='(')
{
j++;
s+=f();
}
else
{
w[l++]=s;
j++;
return s;
}
}
int main()
{
int N,i,k,m;
scanf("%d",&N);
while(N--)
{
scanf("%d",&n);
for(i=,l=,k=;i<n;i++)
{
scanf("%d",&m);
for(j=;j<m-k;j++)
y[l++]='(';
y[l++]=')';
k=m;
}
l=j=;
f();
for(i=;i<n;i++)
printf("%d ",w[i]);
printf("\n");
}
return ;
}
OUC_Summer Training_ DIV2_#4之数据结构的更多相关文章
- OUC_Summer Training_ DIV2_#16 725
今天做了这两道题真的好高兴啊!!我一直知道自己很渣,又贪玩不像别人那样用功,又没有别人有天赋.所以感觉在ACM也没有学到什么东西,没有多少进步.但是今天的B题告诉我,进步虽然不明显,但是只要坚持努力的 ...
- OUC_Summer Training_ DIV2_#13 723afternoon
A - Shaass and Oskols Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I ...
- OUC_Summer Training_ DIV2_#12(DP1) 723
这一次是做练习,主要了解了两个算法,最大子矩阵和,最长上升子序列. 先看题好啦. A - To The Max Time Limit:1000MS Memory Limit:32768KB ...
- OUC_Summer Training_ DIV2_#14 724
又落下好多题解啊...先把今天的写上好了. A - Snow Footprints Time Limit:1000MS Memory Limit:262144KB 64bit IO F ...
- OUC_Summer Training_ DIV2_#2之解题策略 715
这是第一天的CF,是的,我拖到了现在.恩忽视掉这个细节,其实这一篇只有一道题,因为这次一共做了3道题,只对了一道就是这一道,还有一道理解了的就是第一篇博客丑数那道,还有一道因为英语实在太拙计理解错了题 ...
- OUC_Summer Training_ DIV2_#7 718
是18号做的题啦,现在才把报告补上是以前不重视报告的原因吧,不过现在真的很喜欢写报告,也希望能写一些有意义的东西出来. A - Dragons Time Limit:2000MS Memory ...
- OUC_Summer Training_ DIV2_#11 722
企鹅很忙系列~(可惜只会做3道题T_T) A - A Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d &am ...
- OUC_Summer Training_ DIV2_#9 719
其实自己只会做很简单的题,有时都不想写解题报告,觉得不值得一写,但是又想到今后也许就不会做ACM了,能留下来的东西只有解题报告了,所以要好好写,很渣的题也要写,是今后的纪念. B - B Time L ...
- OUC_Summer Training_ DIV2_#5
这是做的最好的一次了一共做了4道题 嘻嘻~ A - Game Outcome Time Limit:2000MS Memory Limit:262144KB 64bit IO For ...
随机推荐
- O054、Attach Volume 操作(Part II)
参考https://www.cnblogs.com/CloudMan6/p/5631328.html 计算节点作为iSCSI initiator 访问存储节点 iSCSI Target 上的v ...
- win DLL 笔记
DLL 头文件: #ifdef DLL_API #else #define DLL 导出类 class DLL_API point { public: void aaa() { } } 导出类中函数 ...
- Linux JDK升级
一.jdk1.4卸载 Redhat Enterprise 5 中自带安装了jdk1.4,在安装jdk1.6前,把jdk1.4卸载: 1. 首先查看系统自带的JDK版本: [root@linux ~]# ...
- Caffe Blob测试
本例子来源于<21天实战Caffe> 代码如下: #include <vector> #include <iostream> #include <caffe/ ...
- Gephi简单导入数据
使用工具 Gephi-0.9.2 事前要导入的数据 Node.csv 节点:名称可以所以定,格式.csv Edge.csv 边:名称可以所以定,格式.csv 导入操作 新建项目 导入节点 新建列要与表 ...
- Hadoop 上Hive 的操作
数据dept表的准备: --创建dept表 CREATE TABLE dept( deptno int, dname string, loc string) ROW FORMAT DELIMITED ...
- kbmMWClientQuery判断一个字段是否修改?
function TForm5.IsFieldChanged(aDataSet: TkbmMWCustomClientQuery; aFieldName: string): Boolean; var ...
- python函数:叠加装饰器、迭代器、自定义迭代器、生成式
一.叠加多个装饰器二.迭代器三.自定义迭代器四.xxx生成式 一.叠加多个装饰器 # 加载装饰器就是将原函数名偷梁换柱成了装饰器最内层那个wrapper函数 # 在加载完毕后,调用原函数其实就是在调用 ...
- 关于shell中函数调用的理解
今天做一个试题就是调用函数的问题,题意如下: 执行shell脚本,打印一个如下的水果菜单: 1.apple 2.pear 3.banana 4.cherry 当用户输入对应的数字选择水果的时候,告诉他 ...
- hadoop/hbase/hive单机扩增slave
原来只有一台机器,hadoop,hbase,hive都安装在一台机器上,现在又申请到一台机器,领导说做成主备, 要重新配置吗?还是原来的不动,把新增的机器做成slave,原来的当作master?网上找 ...