题解 【Codeforces381A】 Sereja and Dima】的更多相关文章

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…
本题是很好的双指针练习题. 关于双指针,详见洛谷日报#73. 我们可以用两个指针l和r表示题中两人接下来要比较的数字,用fl标记下一个将要取的人,并分别用两个计数器统计双方的答案. 因此,我们有了如下AC代码: #include <bits/stdc++.h>//万能头文件 using namespace std;//使用标准名字空间 inline int read()//快速读入 { ,x=; char c=getchar(); ') { ; c=getchar(); } ') { x=x*…
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…
Sereja and Cinema 首先我们可以发现除了第一个人, 其他人都会坐在已入坐人的旁边. 难点在于计算方案数.. 我们可以从外往里把确定的人用组合数算上去,然后缩小范围. #include<bits/stdc++.h> #define LL long long #define LD long double #define fi first #define se second #define mk make_pair #define PLL pair<LL, LL> #de…
B. Little Dima and Equation time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following proble…
题面传送门 解决思路 本题是找最长路的图上问题,所以先考虑如何建图. 首先把每一个字母转化为数字,然后对于每一个点枚举四个方向,如果有下一个字母,就向那个点建一条边,可以用 \(vector\) 存图比较方便.用数字标号,只需要判断 \(t_{x2,y2}=(t_{x1,y1}+1)\mod 4\) 是否成立即可,但直接用字母判断也是比较方便的. 然后考虑 \(\text{dfs}\) 搜索可以走的最长路.有以下几个注意点: 开始搜索的点一定是 D. 已经更新过答案的点就不用搜了,直接 \(\t…
题目大意: 我们有一个集合 S,其中包含了 m 个不完全相同的区间[l1,r1],[l2,r2]…[lm,rm] (1≤li≤ri≤n,li,ri 都为整数). 定义 f(S)=k,表示集合 S 中能取出最多 k 个区间,使得这 k 个区间两两不相交. 问当 f(S)=k 时,符合条件的集合 S 有多少个. 思路: f[i][j]表示集合S中所有区间的端点均小于等于i且f(S)=j的集合S的个数. 显然i≥j,则f[i][j]由f[k][j-1](j-1≤k≤i)转移而来,新的与之前区间不相交的…
Codeforces Round #262 (Div. 2) B B - Little Dima and Equation B. Little Dima and Equation time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Little Dima misbehaved during a math lesson a lot a…
题目链接: http://codeforces.com/problemset/problem/272/D D. Dima and Two Sequences time limit per test2 secondsmemory limit per test256 megabytes 问题描述 Little Dima has two sequences of points with integer coordinates: sequence (a1, 1), (a2, 2), ..., (an, …
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…