hdoj 5592 ZYB's Biology 【线段树】 hdoj 5590 ZYB's Biology 【字符串水题】
来源:互联网 发布:淘宝童装便宜货源 编辑:程序博客网 时间:2024/06/05 04:39
ZYB's Biology
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 340 Accepted Submission(s): 281
Problem Description
After getting 600 scores in NOIP ZYB(ZJ−267) begins to work with biological questions.Now he give you a simple biological questions:
he gives you aDNA sequence and a RNA sequence,then he asks you whether the DNA sequence and the RNA sequence are
matched.
TheDNA sequence is a string consisted of A,C,G,T ;TheRNA sequence is a string consisted of A,C,G,U .
DNA sequence and RNA sequence are matched if and only if A matches U ,T matches A ,C matches G ,G matches C on each position.
he gives you a
matched.
The
Input
In the first line there is the testcase T .
For each teatcase:
In the first line there is one numberN .
In the next line there is a string of lengthN ,describe the DNA sequence.
In the third line there is a string of lengthN ,describe the RNA sequence.
1≤T≤10 ,1≤N≤100
For each teatcase:
In the first line there is one number
In the next line there is a string of length
In the third line there is a string of length
Output
For each testcase,print YES or NO ,describe whether the two arrays are matched.
Sample Input
24ACGTUGCA4ACGTACGU
Sample Output
YESNO
Source
BestCoder Round #65
恩,题目大意就是说,给出一个序列到相应位置的逆序数,求原序列。本来想的是求当前位置的数前有几个数比它大就把它插到从后面数几个数之前,这个用for循环写的超时。。。然后现在是找到当前位置的数前有x个数比它大,那么它就是第x+1大的数,倒着插。(看的雨神代码,好久才懂)
<span style="font-family:Comic Sans MS;font-size:18px;">#include<cstdio>#include<cstring>#include<algorithm>#define maxn 50050using namespace std;int n,a[maxn],b[maxn];struct Node{ int l,r,s;};Node node[maxn<<2];void pushup(int o){ node[o].s=node[o<<1].s+node[o<<1|1].s;}void build(int o,int l,int r){ node[o].l=l; node[o].r=r; node[o].s=1; if(l==r) return ; int mid=(l+r)>>1; build(o<<1,l,mid); build(o<<1|1,mid+1,r); pushup(o);}void update(int o,int aim){ if(node[o].l==node[o].r) { node[o].s=0; return ; } int mid=(node[o].l+node[o].r)>>1; if(aim<=mid) update(o<<1,aim); else update(o<<1|1,aim); pushup(o);}int query(int o,int aim){ if(node[o].l==node[o].r) return node[o].l; if(node[o<<1].s>=aim) return query(o<<1,aim); else return query(o<<1|1,aim-node[o<<1].s);}int main(){ int t; scanf("%d",&t); while(t--) { scanf("%d",&n); for(int i=1;i<=n;++i) scanf("%d",&a[i]); a[0]=0; build(1,1,n); for(int i=n;i>=1;i--) { int tem=a[i]-a[i-1]; int p=query(1,tem+1); b[i]=n-p+1; update(1,p); } for(int i=1;i<=n;++i) { if(i==1) printf("%d",b[i]); else printf(" %d",b[i]); } printf("\n"); } return 0;}</span>
恩,打BC时的代码,本来以为做对了,又被hack掉了,超时。。。。(还是要用上面线段树做,这个是从前面开始的,其实思想都差不多)
<span style="font-family:Comic Sans MS;font-size:18px;background-color: rgb(192, 192, 192);">#include <iostream>#include<cstdio>#include<cstring>#define maxn 50050using namespace std;int a[maxn],b[maxn];void in(int x,int pos){ for(int i=x;i>x-pos;--i) { b[i]=b[i-1]; } b[x-pos]=x;}int main(){ int t,n; scanf("%d",&t); while(t--) { scanf("%d",&n); for(int i=1;i<=n;++i) scanf("%d",&a[i]); b[1]=1; int s=1; for(int i=2;i<=n;++i) { if(!a[i]) b[i]=i; else { int tem=a[i]-a[i-1]; in(i,tem); } } for(int i=1;i<=n;++i) a[b[i]]=i; for(int i=1;i<=n;++i) { if(i==1) printf("%d",a[i]); else printf(" %d",a[i]); } printf("\n"); } return 0;}</span>
ZYB's Biology
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 340 Accepted Submission(s): 281
Problem Description
After getting 600 scores in NOIP ZYB(ZJ−267) begins to work with biological questions.Now he give you a simple biological questions:
he gives you aDNA sequence and a RNA sequence,then he asks you whether the DNA sequence and the RNA sequence are
matched.
TheDNA sequence is a string consisted of A,C,G,T ;TheRNA sequence is a string consisted of A,C,G,U .
DNA sequence and RNA sequence are matched if and only if A matches U ,T matches A ,C matches G ,G matches C on each position.
he gives you a
matched.
The
Input
In the first line there is the testcase T .
For each teatcase:
In the first line there is one numberN .
In the next line there is a string of lengthN ,describe the DNA sequence.
In the third line there is a string of lengthN ,describe the RNA sequence.
1≤T≤10 ,1≤N≤100
For each teatcase:
In the first line there is one number
In the next line there is a string of length
In the third line there is a string of length
Output
For each testcase,print YES or NO ,describe whether the two arrays are matched.
Sample Input
24ACGTUGCA4ACGTACGU
Sample Output
YESNO
Source
BestCoder Round #65
恩,字符串水题
<span style="font-family:Comic Sans MS;font-size:18px;background-color: rgb(204, 204, 204);">#include <iostream>#include<cstdio>#include<cstring>#define maxn 110using namespace std;char dna[maxn],rna[maxn];int judge(int x){ if(dna[x]=='A'&&rna[x]=='U') return 1; if(dna[x]=='C'&&rna[x]=='G') return 1; if(dna[x]=='T'&&rna[x]=='A') return 1; if(dna[x]=='G'&&rna[x]=='C') return 1; return 0;}int main(){ int t,n; scanf("%d",&t); while(t--) { scanf("%d",&n); getchar(); for(int i=0;i<n;++i) scanf("%c",&dna[i]); getchar(); for(int i=0;i<n;++i) scanf("%c",&rna[i]); int flag=0; for(int i=0;i<n;++i) { if(!judge(i)) { flag=1; break; } } if(flag) printf("NO\n"); else printf("YES\n"); } return 0;}</span>
0 0
- hdoj 5592 ZYB's Biology 【线段树】 hdoj 5590 ZYB's Biology 【字符串水题】
- HDOJ 5590 ZYB's Biology
- HDOJ 5590 ZYB's Biology
- hdoj-5590-ZYB's Biology
- 【水】HDOJ ZYB's Biology 5590
- hdoj ZYB's Biology 5590 (字符串) 水
- hdoj 5590 ZYB's Biology 【水题】
- HDU 5590 ZYB's Biology
- HDU 5590 ZYB's Biology
- hdu 5590 ZYB's Biology(水)
- ZYB's Biology
- 杭电5590 ZYB's Biology
- ZYB's Biology解题报告
- BestCoder Round #65 ZYB's Biology
- hdoj 5592 ZYB's Premutation 【线段树插空】
- HDOJ 5592 ZYB's Premutation(逆序对变题:树状数组+二分||线段树)
- BestCoder Round #65 1001 ZYB's Biology HDU5590
- HDOJ 5591 ZYB's Game
- 12.7 coding-python-mongo相关代码笔记
- 玩转ptrace
- 七牛---音视频切片关于用户认证
- CentOS下防火墙的配置
- 为LINQ实现自定义类的Distinct方法
- hdoj 5592 ZYB's Biology 【线段树】 hdoj 5590 ZYB's Biology 【字符串水题】
- Java:对象的强、软、弱和虚引用
- 04_Java序列化
- 认识标签<三>
- 项目经验总结
- cocos2d-x着色器基础之类似水纹效果的实现
- Ubuntu安装mips平台交叉编译环境
- swing JTable学习(七)—TableModelListener
- Develop--Training(三)Getting Started--Interacting with Other Apps