
Codeforces
x_mn
二餐三楼的饮料好好喝~
展开
-
【Codeforces】#605(div 3) E. Nearest Opposite Parity(BFS,最短路)
题目链接题意:一个长度为 n 的序列,每个位置可以跳到 i−ai和i+aii-a_i 和 i+a_ii−ai和i+ai,求出每个位置最少需要跳几次,可以使起始位置和结束位置的奇偶性不同。题解:反向建边,先找到起始点(即只需跳一次即可到达的),每次由花费最少且未访问过的边继续拓展。不能使用记忆化搜索,因为内部存在环。可以不使用优先队列,因为权值相同,使用普通队列即可。...原创 2019-12-13 15:25:26 · 289 阅读 · 0 评论 -
【Codeforces】#604(div 2) D. Beautiful Sequence(构造,枚举起点)
题目链接:http://codeforces.com/contest/1265/problem/D题意:有a个0,b个1,c个2,d个3,构造一个序列,使每个相邻的数相差结果为1.题解:分别枚举以0,1,2,3开始的序列,寻找是否存在满足要求的序列。#include<bits/stdc++.h>using namespace std;vector<int...原创 2019-12-07 14:23:32 · 510 阅读 · 1 评论 -
【Codeforces】 #604(div 2) E. Beautiful Mirrors(概率DP)
题目链接:http://codeforces.com/contest/1265/problem/E题意:n个魔镜,每个魔镜有个概率会说“漂亮”,当过程中出现”不漂亮“则会从头开始。问全部n个魔镜说漂亮的时候的期望。题解:解法一:期望DP:当前第i个的期望由=>前一个(i-1)的期望+第(i)个说“漂亮”的概率+第(i)个说不“漂亮”的概率 * 期望正向推导:DP[...原创 2019-12-07 14:15:35 · 230 阅读 · 0 评论 -
【Codeforces】Permute Digits——模拟退火
题目链接题解:模拟退火,进行位置交换的尝试,通过判断最高位是否相等缩小区间。#include<bits/stdc++.h>#define ll long long intusing namespace std;ll pow(int a,ll b){ ll sum=1; for(int i=0;i<b;i++) { sum*=a; } return ...原创 2019-03-11 15:35:28 · 1107 阅读 · 0 评论 -
【Codeforces】2017ACM/ICPC广西邀请赛 D-Covering
题意:4*n的区域,放置1*2和2*1的地砖,有多少种方法。题解:矩阵快速幂+状压dp,或者 BM杜教首先状压dp,找到转移状态,注释的地方为无效状态,有效状态只有6种#include<bits/stdc++.h>using namespace std;typedef long long int ll;const int mod=1000000007;ll ...原创 2019-05-16 20:40:27 · 298 阅读 · 1 评论 -
【codeforces】Codeforces Round #552 (Div. 3) E. Two Teams
题目链接:http://codeforces.com/contest/1154/problem/E题解:数组模拟链表,按照操作模拟。#include<bits/stdc++.h>using namespace std;const int maxn=4e5+10;int b[maxn];struct node { int x,id;}a[maxn];int fa...原创 2019-04-21 17:23:43 · 163 阅读 · 0 评论 -
【Codeforces】C. Minimum Value Rectangle
C. Minimum Value Rectangle题目链接time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou havennsticks of the given lengths.Your t...原创 2018-08-19 21:14:32 · 1582 阅读 · 0 评论 -
【Codeforces】B. Numbers on the Chessboard
B. Numbers on the Chessboard题目链接time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a chessboard of sizen×nn×n. It i...原创 2018-08-19 20:57:41 · 2650 阅读 · 0 评论 -
Codeforces C. A Mist of Florescence
C. A Mist of Florescencetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output题目链接As the boat drifts down the river, a wood full of blossoms shows up on ...原创 2018-06-13 13:52:08 · 254 阅读 · 0 评论 -
Codeforces C. Bracket Sequences Concatenation Problem
C. Bracket Sequences Concatenation Problemtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output题目链接A bracket sequence is a string containing only chara...原创 2018-06-12 11:15:48 · 387 阅读 · 0 评论 -
Codeforces B. Micro-World
B. Micro-Worldtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output题目链接You have a Petri dish with bacteria and you are preparing to dive into the harsh...原创 2018-06-11 13:22:20 · 1671 阅读 · 0 评论