设为首页 加入收藏

TOP

HDU 4339 Query
2015-07-20 17:49:17 来源: 作者: 【 】 浏览:2
Tags:HDU 4339 Query

Query

Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 2595 Accepted Submission(s): 860


Problem Description You are given two strings s1[0..l1], s2[0..l2] and Q - number of queries.
Your task is to answer next queries:
1) 1 a i c - you should set i-th character in a-th string to c;
2) 2 i - you should output the greatest j such that for all k (i<=k and k
Input The first line contains T - number of test cases (T<=25).
Next T blocks contain each test.
The first line of test contains s1.
The second line of test contains s2.
The third line of test contains Q.
Next Q lines of test contain each query:
1) 1 a i c (a is 1 or 2, 0<=i, i 2) 2 i (0<=i, i All characters in strings are from 'a'..'z' (lowercase latin letters).
Q <= 100000.
l1, l2 <= 1000000.
Output For each test output "Case t:" in a single line, where t is number of test (numbered from 1 to T).
Then for each query "2 i" output in single line one integer j.

Sample Input
1
aaabba
aabbaa
7
2 0
2 1
2 2
2 3
1 1 2 b
2 0
2 3

Sample Output
Case 1:
2
1
0
1
4
1

Source 2012 Multi-University Training Contest 4
解题思路:用 保存字符不同的位置,修改的话直接改,查的话用lower_bound,注意要把字符串长度len也添加进去,这是为了避免字符串全部相等的情况
#include 
     
      
#include 
      
        #include 
       
         #include 
        
          #include 
         
           #include 
          
            #define Maxn 1000005 using namespace std; char str1[Maxn],str2[Maxn]; int main() { int t,ncase=1,q,a,c,b; char ch; set
           
             s; //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); scanf("%d",&t); while(t--) { s.clear(); set
            
             ::iterator it; scanf("%s%s",str1,str2); scanf("%d",&q); int len=strlen(str1); for(int i=0;i
             
              


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇POJ 1236 Network of Schools(强.. 下一篇poj 1328 Radar Installation (..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·Announcing October (2025-12-24 15:18:16)
·MySQL有什么推荐的学 (2025-12-24 15:18:13)
·到底应该用MySQL还是 (2025-12-24 15:18:11)
·进入Linux世界大门的 (2025-12-24 14:51:47)
·Download Linux | Li (2025-12-24 14:51:44)