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的更多相关文章

  1. Codeforces Round #258 (Div. 2)[ABCD]

    Codeforces Round #258 (Div. 2)[ABCD] ACM 题目地址:Codeforces Round #258 (Div. 2) A - Game With Sticks 题意 ...

  2. CodeForces 835C - Star sky | Codeforces Round #427 (Div. 2)

    s <= c是最骚的,数组在那一维开了10,第八组样例直接爆了- - /* CodeForces 835C - Star sky [ 前缀和,容斥 ] | Codeforces Round #4 ...

  3. CodeForces 835D - Palindromic characteristics | Codeforces Round #427 (Div. 2)

    证明在Tutorial的评论版里 /* CodeForces 835D - Palindromic characteristics [ 分析,DP ] | Codeforces Round #427 ...

  4. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  5. Codeforces Round #268 (Div. 2) ABCD

    CF469 Codeforces Round #268 (Div. 2) http://codeforces.com/contest/469 开学了,时间少,水题就不写题解了,不水的题也不写这么详细了 ...

  6. Codeforces Round #449 (Div. 2)ABCD

    又掉分了0 0. A. Scarborough Fair time limit per test 2 seconds memory limit per test 256 megabytes input ...

  7. Codeforces Round #143 (Div. 2) (ABCD 思维场)

    题目连链接:http://codeforces.com/contest/231 A. Team time limit per test:2 seconds memory limit per test: ...

  8. Codeforces Round #248 (Div. 2) (ABCD解决问题的方法)

    比赛链接:http://codeforces.com/contest/433 A. Kitahara Haruki's Gift time limit per test:1 second memory ...

  9. 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 ...

随机推荐

  1. bzoj1143: [CTSC2008]祭祀river && bzoj27182718: [Violet 4]毕业旅行

    其实我至今不懂为啥强联通缩点判入度会错... 然后这个求的和之前那道组合数学一样,就是最长反链=最小链覆盖=最大独立集. #include<cstdio> #include<iost ...

  2. 【POJ 3349】 Snowflake Snow Snowflakes

    [题目链接] http://poj.org/problem?id=3349 [算法] 哈希 若两片雪花相同,则它们六个角上的和一定相同,不妨令 H(A) = sigma(Ai) % P ,每次只要到哈 ...

  3. windows下写的脚本,在linux下执行失败

    Windows中的换行符为CRLF, 即正则表达式的rn(ASCII码为13和10), 而Unix(或Linux)换行符为LF, 即正则表达式的n. 在Windows和Linux下协同工作的时候, 往 ...

  4. [Swift通天遁地]二、表格表单-(12)设置表单文字对齐方式以及自适应高度的文本区域TextArea

    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...

  5. [Swift通天遁地]八、媒体与动画-(1)实现音频的播放和停止

    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...

  6. 题解报告:hdu 3790 最短路径问题

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3790 Problem Description 给你n个点,m条无向边,每条边都有长度d和花费p,给你起 ...

  7. 329 Longest Increasing Path in a Matrix 矩阵中的最长递增路径

    Given an integer matrix, find the length of the longest increasing path.From each cell, you can eith ...

  8. SharePoint通过IP地址访问

    问题:SP站点通过计算机名称可以访问,但不能通过IP地址访问 解决方案:打开SharePoint2010管理中心>应用程序管理>配置备用访问映射>编辑公用 URL 备用访问映射集:选 ...

  9. 函数 out 传值 分割

    public void Jia(int a ,int b) { a = a + b; Console.WriteLine(a); } public void Jia1(int a,out int b) ...

  10. 【转】utf-8的中文是一个汉字占三个字节长度

    因为看到百度里面这个人回答比较生动,印象比较深刻,所以转过来做个笔记 原文链接 https://zhidao.baidu.com/question/1047887004693001899.html 知 ...