B. Sereja and Suffixes Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/problem/368/B Description Sereja has an array a, consisting of n integers a1, a2, ..., an. The boy cannot sit and do nothing, he decided to study an…
#include <iostream> #include <vector> #include <algorithm> #include <set> using namespace std; int main(){ int n,m; cin >> n >>m; vector<int> a(n),l(m); ; i < n ; ++ i) cin >>a[i]; ; i < m; ++ i) cin &…
B. Sereja ans Anagrams Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/problem/367/B Description Sereja has two sequences a and b and number p. Sequence a consists of n integers a1, a2, ..., an. Similarly, sequence b con…
http://codeforces.com/contest/368/problem/D 题意:有a.b两个数组,a数组有n个数,b数组有m个数,现在给出一个p,要你找出所有的位置q,使得位置q  q+p   q+2*p  .....q+(m-1)*p   经过一定的操作(不改变数据大小)全等于b数组. 思路:首先肯定对a数组离散,然后二分对a.b数组分配好离散后的值.其实我们只需要枚举0————p位置,哈希记录,然后从q----一直滚到q(m-1)*p>=n,对于一个数据,出来第一个数,进去最后…
#include <iostream> #include <vector> #include <algorithm> #include <string> using namespace std; int main(){ string s ; cin >>s; int m; cin >>m; vector<int> l(m),r(m); ; i < m ; ++ i ) cin >> l[i]>>…
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ int n,d; cin >> n >>d; vector<int>a(n); ; i < n ; ++ i ) cin >>a[i]; int m; cin >> m; sort(a.begin(),a.end()); ;…
                                                    D. Prefixes and Suffixes You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|)…
题目链接:http://codeforces.com/contest/381/problem/E  E. Sereja and Brackets time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a…
D. Sereja ans Anagrams time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Sereja has two sequences a and b and number p. Sequence a consists of n integers a1, a2, ..., an. Similarly, sequence …
A Sereja and Algorithm 题意:给定有x,y,z组成的字符串,每次询问某一段s[l, r]能否变成变成zyxzyx的循环体. 分析: 分析每一段x,y,z数目是否满足构成循环体,当然长度<3的要特判. 代码: #include <bits/stdc++.h> #define in freopen("solve_in.txt", "r", stdin); #define pb push_back using namespace s…
Sereja and Dima time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Sereja and Dima play a game. The rules of the game are very simple. The players have n cards in a row. Each card contains a n…
A. Sereja and Swaps time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output As usual, Sereja has array a, its elements are integers: a[1], a[2], ..., a[n]. Let's introduce notation: A swap operatio…
由于n比较小,直接暴力解决 #include <iostream> #include <vector> #include <algorithm> #include <numeric> #include <functional> #include<iterator> using namespace std; int main(){ int n,k; cin >> n >> k; vector<int>…
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ int n,m; cin >> n >> m; vector<vector<)); ; i < n; ++ i){ ; j < m ; ++ j){ cin >> a[i][j]; } } ) cout<<n<&…
#include <iostream> #include <vector> #include <algorithm> #include <numeric> using namespace std; int main(){ int n,s; cin >> n >> s; vector<int> a(n); ; i < n ; ++ i) cin >> a[i]; sort(a.begin(),a.end()…
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ int x,k; cin >> x >> k; vector<, false); num[x] = true; ; i < k ; ++ i){ int index, num1,num2; cin >> index; ){ cin >&…
出来冒个泡 由于数比较大  开了map计数  然后边走边删边加 勉强可过 #include <iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<stdlib.h> #include<queue> #include<map> #include<string> using namespace std; #define…
题目 题意:求任意连续序列的最大值,这个连续序列可以和其他的 值交换k次,求最大值 思路:暴力枚举所有的连续序列.没做对是因为 首先没有认真读题,没看清交换,然后,以为是dp或者贪心 用了一下贪心,各种bug不对. 这次用了一下优先队列,以前用的不多,看这个博客又学了一下 AC代码: #include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include <…
D. Prefixes and Suffixes time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce s…
题目链接 题意:给你一个长度n,还有2*n-2个字符串,长度相同的字符串一个数前缀一个是后缀,让你把每个串标一下是前缀还是后缀,输出任意解即可. 思路;因为不知道前缀还是后缀所以只能搜,但可以肯定的是长度为n-1的字符串一个是前缀一个是后缀,那么只要搜两次就完事了,一个当前缀不行就换另一个当前缀,然后中间判断一下即可. ps:这也是给远古题,没补,因为最不喜欢 字符串的题,,,qwq. #include<bits/stdc++.h> #define LL long long #define f…
题意:给你某个字符串的\(n-1\)个前缀和\(n-1\)个后缀,保证每个所给的前缀后缀长度从\([1,n-1]\)都有,问你所给的子串是前缀还是后缀. 题解:这题最关键的是那两个长度为\(n-1\)的子串,我们只要判断哪个是前缀就行了,然后再遍历一遍所给的子串,用长度为\(n-1\)的前缀子串来判断是子串是前缀还是后缀. 代码: int n; string s[N]; bool vis[N]; int cnt; int main() { ios::sync_with_stdio(false);…
A. Sereja and Dima time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Sereja and Dima play a game. The rules of the game are very simple. The players have n cards in a row. Each card contains…
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate it n = int(raw_input()) s = "" a = ["I hate that ","I love that ", "I hate it","I love it"] for i in ran…
Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/output 1 s, 256 MB    x3384 B Pyramid of Glasses standard input/output 1 s, 256 MB    x1462 C Vasya and String standard input/output 1 s, 256 MB    x1393…
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输出”#Color”,如果只有”G”,”B”,”W”就输出”#Black&White”. #include <cstdio> #include <cstring> using namespace std; const int maxn = 200; const int INF =…
 cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....       其实这个应该是昨天就写完的,不过没时间了,就留到了今天.. 地址:http://codeforces.com/contest/651/problem/A A. Joysticks time limit per test 1 second memory limit per test 256…
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/output 1 s, 256 MB  x2377 B Queue standard input/output 2 s, 256 MB  x1250 C Hacking Cypher standard input/output 1 s, 256 MB  x740 D Chocolate standard in…
Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little beaver is a beginner programmer, so informatics is his favorite subject. Soon his info…
Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Little Victor adores the sets theory. Let us remind you that a set is a group of…
A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给出的01序列相等(比较时如果长度不等各自用0补齐) 题解: 1.我的做法是用Trie数来存储,先将所有数用0补齐成长度为18位,然后就是Trie的操作了. 2.官方题解中更好的做法是,直接将每个数的十进制表示中的奇数改成1,偶数改成0,比如12345,然后把它看成二进制数10101,还原成十进制是2…