Codeforces Round #427 (Div. 2)——ABCD
http://codeforces.com/contest/835
A.拼英语水平和手速的签到题
#include <bits/stdc++.h>
using namespace std;
int s, v1, v2, t1, t2;
int main() {
cin >> s >> v1 >> v2 >> t1 >> t2;
int a1 = t1 + v1 * s + t1;
int a2 = t2 + v2 * s + t2;
if(a1 < a2) puts("First");
else if(a1 > a2) puts("Second");
else puts("Friendship");
return ;
}
B.同签到
#include <bits/stdc++.h>
using namespace std;
int k, n, a[];
string s;
long long sum;
int main() {
cin >> k >> s;
for(int i = ;i < s.size();i ++)
a[s[i] - ''] ++, sum += s[i] - '';
if(sum >= k) {
puts("");
return ;
}
k -= sum;
for(int i = ;i < ;i ++)
for(int j = ;j <= a[i];j ++) {
k -= - i, n ++;
if(k <= ) {
printf("%d\n", n);
return ;
}
}
return ;
}
C.看到xyc的数据范围就能明白是道水题...然后就WA了
1W个位置10W个点,可能一个位置好几颗星星...令人无语
#include <bits/stdc++.h>
using namespace std;
vector<int> c[][][];
int n, q, cc, b[][][];
int main() {
scanf("%d %d %d", &n, &q, &cc), cc ++;
for(int u, v, w, i = ;i <= n;i ++) {
scanf("%d %d %d", &u, &v, &w);
c[][u][v].push_back(w);
}
for(int i = ;i < cc;i ++)
for(int j = ;j <= ;j ++)
for(int k = ;k <= ;k ++)
if(c[i - ][j][k].size() != ) {
for(int p = ;p < c[i - ][j][k].size();p ++)
c[i][j][k].push_back((c[i - ][j][k][p] + ) % cc);
}
for(int i = ;i < cc;i ++)
for(int j = ;j <= ;j ++)
for(int k = ;k <= ;k ++) {
b[i][j][k] += b[i][j - ][k] + b[i][j][k - ] - b[i][j - ][k - ];
for(int p = ;p < c[i][j][k].size();p ++)
b[i][j][k] += c[i][j][k][p];
}
for(int t, A, B, C, D, i = ;i <= q;i ++) {
scanf("%d %d %d %d %d", &t, &A, &B, &C, &D);
t %= cc, printf("%d\n", b[t][C][D] + b[t][A - ][B - ] - b[t][A - ][D] - b[t][C][B - ]);
}
return ;
}
如果没有亮度变化,坐标到1e9,会有新的星星在某个位置出现,询问不变
允许离线的话可以CDQ分治解决,O(nlog^2n)
强制在线的话可以树状数组套主席树,时间复杂度相同,常数略大,空间O(nlogn)
当然这个模型感觉都快被写烂了...
D.注意到1阶回文是普通回文
而k阶回文决定了它一定也是回文,而且它也是1...k-1阶回文
想清楚了它的性质,就是个区间DP了
import java.util.Scanner;
public class D {
public static void main(String []args) {
Scanner cin = new Scanner(System.in);
int[][] dp = new int[5005][5005];
int[] ans = new int[5005];
String s = cin.nextLine();
int n = s.length();
for(int d = 1;d <= n;d ++)
for(int i = 0;i + d - 1< n;i ++) {
int j = i + d - 1;
if(d < 3) dp[i][j] = (s.charAt(i) == s.charAt(j) ? d : 0);
else if(s.charAt(i) != s.charAt(j) || dp[i + 1][j - 1] == 0) dp[i][j] = 0;
else if(s.charAt(i) == s.charAt((i + j - 1) / 2)) dp[i][j] = dp[i][(i + j - 1) / 2] + 1;
else dp[i][j] = 1;
ans[dp[i][j]] ++;
}
for(int i = n - 1;i > 0;i --)
ans[i] += ans[i + 1];
for(int i = 1;i <= n;i ++)
System.out.printf("%d ", ans[i]);
}
}
Codeforces Round #427 (Div. 2)——ABCD的更多相关文章
- Codeforces Round #258 (Div. 2)[ABCD]
Codeforces Round #258 (Div. 2)[ABCD] ACM 题目地址:Codeforces Round #258 (Div. 2) A - Game With Sticks 题意 ...
- CodeForces 835C - Star sky | Codeforces Round #427 (Div. 2)
s <= c是最骚的,数组在那一维开了10,第八组样例直接爆了- - /* CodeForces 835C - Star sky [ 前缀和,容斥 ] | Codeforces Round #4 ...
- CodeForces 835D - Palindromic characteristics | Codeforces Round #427 (Div. 2)
证明在Tutorial的评论版里 /* CodeForces 835D - Palindromic characteristics [ 分析,DP ] | Codeforces Round #427 ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #268 (Div. 2) ABCD
CF469 Codeforces Round #268 (Div. 2) http://codeforces.com/contest/469 开学了,时间少,水题就不写题解了,不水的题也不写这么详细了 ...
- Codeforces Round #449 (Div. 2)ABCD
又掉分了0 0. A. Scarborough Fair time limit per test 2 seconds memory limit per test 256 megabytes input ...
- Codeforces Round #143 (Div. 2) (ABCD 思维场)
题目连链接:http://codeforces.com/contest/231 A. Team time limit per test:2 seconds memory limit per test: ...
- Codeforces Round #248 (Div. 2) (ABCD解决问题的方法)
比赛链接:http://codeforces.com/contest/433 A. Kitahara Haruki's Gift time limit per test:1 second memory ...
- Codeforces Round #427 (Div. 2) Problem D Palindromic characteristics (Codeforces 835D) - 记忆化搜索
Palindromic characteristics of string s with length |s| is a sequence of |s| integers, where k-th nu ...
随机推荐
- Silverlight 2学习笔记二:三个基本布局控件(Canvas、StackPanel、Grid )
这篇文章主要是翻译了ScottGu博客的文章:Silverlight Tutorial Part 2: Using Layout Management.虽然是翻译,但通过笔记记录,我发现对这三个布局控 ...
- 树的遍历 迭代算法——思路:初始化stack,pop stack利用pop的node,push new node to stack,可以考虑迭代一颗树 因为后序遍历最后还要要访问根结点一次,所以要访问根结点两次是难点
144. Binary Tree Preorder Traversal Given a binary tree, return the preorder traversal of its nodes' ...
- struts表单验证xml配置文件
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE validators PUBLIC &quo ...
- 洛谷P1387最大正方形(dp,前缀和)
题目描述 在一个n*m的只包含0和1的矩阵里找出一个不包含0的最大正方形,输出边长. 输入输出格式 输入格式: 输入文件第一行为两个整数n,m(1<=n,m<=100),接下来n行,每行m ...
- 自定义滚动条配合鼠标滚轮demo
<!DOCTYPE html> <html> <head> <title></title> <meta charset="u ...
- OpenResty / Nginx模块,Lua库和相关资源的列表
OpenResty / Nginx模块,Lua库和相关资源的列表 什么是OpenResty OpenResty是一个成熟的网络平台,它集成了标准的Nginx核心,LuaJIT,许多精心编写的Lua库, ...
- JavaScript--提问(prompt 消息对话框)
prompt弹出消息对话框,通常用于询问一些需要与用户交互的信息.弹出消息对话框(包含一个确定按钮.取消按钮与一个文本输入框). 语法: prompt(str1, str2); 参数说明: str1: ...
- hbuilder中的 http://www.w3.org/TR/html4/frameset.dtd
<!-- This is the HTML 4.01 Frameset DTD, which should be used for documents with frames. This DTD ...
- jsp之servlet模板问题
如果你在web项目下创建一个Servlet类,那么它会自带很多东西,比如有很多的注释,还有很多out.println()语句等.可能这些东西都不是你需要,这样看起来就会比较的令人不爽.下面的话就教大家 ...
- aop 切面demo
/** * 必须要@Aspect 和 @Component一起使用否则没法拦截通知 * 搞了好久才明白刚刚开始以为时execution里面的配置的问题 * AOP使用很简单的 */@Aspect@Co ...