Codeforces Testing Round #16 C.Skier】的更多相关文章

题意: 一个人在雪地上滑雪,每次可以向上下左右四个方向移动一个单位,如果这条路径没有被访问过,则需要5秒的时间,如果被访问过,则需要1秒(注意:判断的是两点之间的距离,不是单纯的点).给你他的行动轨迹,求消耗的时间. 题解:我们用两个pair来维护边,用map来对边进行标记,每次更新map记得双向更新即可(e.g:(1,2)和(2,1)两个方向都要标记). 代码: #include <iostream> #include <cstdio> #include <cstring&…
Codeforces Beta Round #16 (Div. 2 Only) http://codeforces.com/contest/16 A 水题 #include<bits/stdc++.h> using namespace std; #define lson l,mid,rt<<1 #define rson mid+1,r,rt<<1|1 #define sqr(x) ((x)*(x)) #define maxn 500005 typedef long lo…
Codeforces Beta Round #16 (Div. 2 Only) E. Fish 题目链接:## 点击打开链接 题意: 有 \(n\) 条鱼,每两条鱼相遇都会有其中一只吃掉对方,现在给你一个 \(n * n\)的矩阵,表示 \(i\) 吃掉 \(j\) 的概率,最后问你每条鱼存活的概率. 题解: 最多有 \(18\) 条鱼,吃掉的概率都不一样,可以用状态压缩,设\(dp[1<<n]\)种状态,最多有 \(1<<18\) 种状态. $ dp[i]$ 表示当前鱼的状态为…
比赛链接:https://codeforces.com/contest/1351 A - A+B (Trial Problem) #include <bits/stdc++.h> using namespace std; void solve() { int a, b; cin >> a >> b; cout << a + b << "\n"; } int main() { int t; cin >> t; whi…
题目链接:http://codeforces.com/problemset/problem/328/B 水题~ #include <cstdio> #include <cstdlib> #include <cstring> ], a[]; ], c[]; int main(void) { //freopen("in.txt", "r", stdin); scanf("%s%s", n, a); int len1…
C. Subsequences Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/597/problem/C Description For the given sequence with n different elements find the number of increasing subsequences with k + 1 elements. It is guaranteed tha…
B. Restaurant Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/597/problem/B Description A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order…
A. Divisibility Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/597/problem/A Description Find the number of k-divisible numbers on the segment [a, b]. In other words you need to find the number of such integer values x tha…
C. Monitor time limit per test 0.5 second memory limit per test 64 megabytes input standard input output standard output Reca company makes monitors, the most popular of their models is AB999 with the screen size a × b centimeters. Because of some pr…
A:The Way to Home link:http://codeforces.com/contest/910/problem/A 题面:有每次最大跳跃距离d,只有一部分的点可以落脚,求最少几步达到终点D Solution :预处理+贪心 用f[i]表示离点i最近的可落脚点,贪心即可(dp同理) #include <bits/stdc++.h> using namespace std; ]; string s; int main() { cin >> n >> d &…