fzu2280
来源:互联网 发布:淘宝店铺名字大全霸气 编辑:程序博客网 时间:2024/05/21 11:00
Accept: 37 Submit: 134
Time Limit: 2000 mSec Memory Limit : 262144 KB
Problem Description
Kim is a magician, he can use n kinds of magic, number from 1 to n. We use string Si to describe magic i. Magic Si will make Wi points of damage. Note that Wi may change over time.
Kim obey the following rules to use magic:
Each turn, he picks out one magic, suppose that is magic Sk, then Kim will use all the magic i satisfying the following condition:
1. Wi<=Wk
2. Sk is a suffix of Si.
Now Kim wondering how many magic will he use each turn.
Note that all the strings are considered as a suffix of itself.
Input
First line the number of test case T. (T<=6)
For each case, first line an integer n (1<=n<=1000) stand for the number of magic.
Next n lines, each line a string Si (Length of Si<=1000) and an integer Wi (1<=Wi<=1000), stand for magic i and it’s damage Wi.
Next line an integer Q (1<=Q<=80000), stand for there are Q operations. There are two kinds of operation.
“1 x y” means Wx is changed to y.
“2 x” means Kim has picked out magic x, and you should tell him how many magic he will use in this turn.
Note that different Si can be the same.
Output
For each query, output the answer.
Sample Input
Sample Output
#include <iostream>#include <stdio.h>#include <string.h>#include <algorithm>using namespace std;struct node{ char c[1005]; int a,b,n;}a[1005];int main(){ int T; scanf("%d",&T); char d[1005]; while(T--) { int n; scanf("%d",&n); int i; for(i=1;i<=n;i++) { scanf("%s %d",d,&a[i].a); a[i].n=strlen(d); strcpy(a[i].c,d); } int m; scanf("%d",&m); while(m--) { int k,x,y; scanf("%d",&k); if(k==1) { scanf("%d %d",&x,&y); a[x].a=y; } if(k==2) { scanf("%d",&x); int sum=0; for(i=1;i<=n;i++) { int flag=1; if(a[i].a<=a[x].a&&a[i].n>=a[x].n) { int jj=a[i].n-1; for(int j=a[x].n-1;j>=0;j--) { if(a[i].c[jj]==a[x].c[j]) { jj--; } else { flag=0; break; } } if(flag==1) { sum++; } } } cout<<sum<<endl; } } } return 0;}
- fzu2280
- fzu2280-hash预处理
- fzu2280 Magic 暴力
- 51nod 1006(输出其中一个最长上升子序列)
- notepad++快捷键
- 基于多尺度卷积神经网络框架结合语义标签和surface normals以及深度预测
- PID算法研究
- python常用内建模块
- fzu2280
- Jemer安装问题总结及实例
- Python的排序函数Sort,Sorted
- HTML特殊字符编码对照表
- 百练_1664:放苹果
- IDEA 提示全无
- 119. Pascal's Triangle II
- Java8新特性
- 解决NestedScrollView 嵌套 RecyclerView出现的卡顿,上拉刷新无效