Aug 16, 2015 · 267 words · 1 min
给一个字符串,问这个字符串中是否26个字母都出现过(大小写只出现一个就算出现过) 开个布尔数组,扫一遍即可。 嘛,做两道水题放松下== 反正也是要清的。
代码实现 1/************************************************************************* 2 > File Name: code/cf/#295/A.cpp 3 > Author: 111qqz 4 > Email: rkz2013@126.com 5 > Created Time: 2015年08月17日 星期一 04时05分12秒 6 ************************************************************************/ 7 8#include<iostream> 9#include<iomanip> 10#include<cstdio> 11#include<algorithm> 12#include<cmath> 13#include<cstring> 14#include<string> 15#include<map> 16#include<set> 17#include<queue> 18#include<vector> 19#include<stack> 20#define y0 abc111qqz 21#define y1 hust111qqz 22#define yn hez111qqz 23#define j1 cute111qqz 24#define tm crazy111qqz 25#define lr dying111qqz 26using namespace std; 27#define REP(i, n) for (int i=0;i<int(n);++i) 28typedef long long LL; 29typedef unsigned long long ULL; 30const int inf = 0x7fffffff; 31bool v[30]; 32int main() 33{ 34 int n; 35 scanf("%d",&n); 36 memset(v,false,sizeof(v)); 37 string st; 38 cin>>st; 39 for ( int i = 0 ; i < n ; i ++) 40 { 41 if (islower(st[i])) 42 { 43 v[st[i]-'a'] = true; 44 } 45 else 46 { 47 v[st[i]-'A'] = true; 48 } 49 } 50 for ( int i = 0 ; i < 26 ; i++) 51 { 52 if (!v[i]) 53 { 54 55 cout<<"NO"<<endl; 56 return 0; 57 } 58 } 59 cout<<"YES"<<endl; 60 61 return 0; 62}
Aug 14, 2015 · 475 words · 1 min
先预处理出来比小于等于n的素数的个数和回文数的个数…
素数不筛竟然也可以过
然后暴力就好.
需要注意的是,比值并不单调,找最大的n,可能之前某个数开始不满足条件,之后又有满足条件的了.
Aug 13, 2015 · 1010 words · 3 mins
C. Replacement
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Daniel has a string s, consisting of lowercase English letters and period signs (characters ‘.’). Let’s define the operation of replacement as the following sequence of steps: find a substring “..” (two consecutive periods) in string s, of all occurrences of the substring let’s choose the first one, and replace this substring with string “.”. In other words, during the replacement operation, the first two consecutive periods are replaced by one. If string s contains no two consecutive periods, then nothing happens.
Aug 5, 2015 · 212 words · 1 min
给一个有序序列,问对于没一个数,和它相差最少和最多的数的位置。
代码实现 1/************************************************************************* 2 > File Name: code/cf/#314/A.cpp 3 > Author: 111qqz 4 > Email: rkz2013@126.com 5 > Created Time: 2015年08月06日 星期四 00时01分51秒 6 ************************************************************************/ 7 8#include<iostream> 9#include<iomanip> 10#include<cstdio> 11#include<algorithm> 12#include<cmath> 13#include<cstring> 14#include<string> 15#include<map> 16#include<set> 17#include<queue> 18#include<vector> 19#include<stack> 20#define y0 abc111qqz 21#define y1 hust111qqz 22#define yn hez111qqz 23#define j1 cute111qqz 24#define tm crazy111qqz 25#define lr dying111qqz 26using namespace std; 27#define REP(i, n) for (int i=0;i<int(n);++i) 28typedef long long LL; 29typedef unsigned long long ULL; 30const int inf = 0x7fffffff; 31const int N=2E5+7; 32LL a[N]; 33int main() 34{ 35 int n; 36 cin>>n; 37 a[0]=-inf; 38 a[n+1]=inf; 39 40 for ( int i = 1 ; i <= n ; i ++ ) 41 { 42 cin>>a[i]; 43 } 44 int mx = -1; 45 int mi = inf; 46 cout<<a[2]-a[1]<<" "<<a[n]-a[1]<<endl; 47 for ( int i = 2 ; i <= n-1 ; i++ ) 48 { 49 cout<<min(abs(a[i]-a[i-1]),abs(a[i+1]-a[i]))<<" "<<max(abs(a[i]-a[1]),abs(a[n]-a[i]))<<endl; 50 } 51 cout<<a[n]-a[n-1]<<" "<<a[n]-a[1]<<endl; 52 return 0; 53}
Jul 29, 2015 · 561 words · 2 mins
快要炸了..
tle成狗
因为是tle,看了下自己没有写cin cout,估计就是算法的问题…
我是先存了二进制的每一位到数组,然后扫一遍…
嗯,这都tle…
Jul 28, 2015 · 445 words · 1 min
B. Kolya and Tandem Repeat
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Kolya got string s for his birthday, the string consists of small English letters. He immediately added k more characters to the right of the string.
Then Borya came and said that the new string contained a tandem repeat of length l as a substring. How large could l be?
See notes for definition of a tandem repeat.
Jul 28, 2015 · 767 words · 2 mins
http://acm.hdu.edu.cn/showproblem.php?pid=5311 题意:问能否从一个给定的字符串中拿出三个不相交的字串(原串可以有剩余),组成字符串“anniversary” 思路:暴力。
比赛的时候没做出来,sad 我发现我有一个问题,就是不敢跑暴力 有不少题其实正解就是暴力 或者有的题,暴力不是标解,但是绝对可A,可我就不敢写… 就觉得不会是这样.. 说到底还是不自信吧…
Jul 23, 2015 · 986 words · 2 mins
http://poj.org/problem?id=3279
反转类问题.
有N*M个方格,每个上面有数字0或者1
操作一个方格,这个方格及其相邻的四个方格(有公共边)会改变状态(由0变1或者由1变0)
问至少需要多少次操作,所有的状态都为0
Jul 21, 2015 · 759 words · 2 mins
http://codeforces.com/contest/558/problem/C
题目大意是说,给定N个数,可以对任意数进行任意次两种操作,×2,和/2(整除)
问最少操作多少次,可以让所有数相等。
嘛,前半个小时A掉了前两个提,d E貌似都是线段树。。并不会。。。就一直搞C。。。。
May 27, 2015 · 443 words · 1 min
http://codeforces.com/problemset/problem/548/B
比赛的时候不懂为什么就没做出来…. 其实很容易想到一个o(q*(n+m))的做法… 就是每次更新,要同时更新当前更新行的最大连续和….O(m)可以完成…然后在O(n)扫一遍,找到所有行中的最大值。 然后需要注意的是,在第一次更改之前就要把每个行的最大值处理出来l.. 然后cf机器真是够快,O(nmq)的1.2S过。。。。