C - 4-adjacent Time limit : 2sec / Memory limit : 256MB Score : 400 points Problem Statement We have a sequence of length N, a=(a1,a2,…,aN). Each ai is a positive integer. Snuke's objective is to permute the element in a so that the following conditi…
题目链接:https://abc042.contest.atcoder.jp/tasks/arc058_b 题目大意: 给定一个 H * W 的矩阵,其中左下角 A * B 区域是禁区,要求在不踏入禁区的前提下,从左上角走到右下角一共有多少种走法? 分析: 设 D 为往下,R为往左. 这里举个 H = 10,W = 7,A = 3,B = 4的例子: 首先不管怎么走,路线都是要跨越蓝色边界线的,这里我们只讨论从 A 跨越到 B 的情况,其余情况同理. 在这种情况下,总的路数就是所有从 S 走到…
地址:http://arc080.contest.atcoder.jp/tasks/arc080_b 题目: D - Grid Coloring Time limit : 2sec / Memory limit : 256MB Score : 400 points Problem Statement We have a grid with H rows and W columns of squares. Snuke is painting these squares in colors 1, 2…
ATCODER ABC 099 记录一下自己第一场AK的比赛吧...虽然还是被各种踩... 只能说ABC确实是比较容易. A 题目大意 给你一个数(1~1999),让你判断它是不是大于999. Solution 没什么好说的,代码学过编程就应该都会打. B 题目大意 有一排树,高度分别为1,1+2,1+2+3,1+2+3+4....1+2+3+...+999.现在下雪了,给出露在外面的两棵相邻的树的高度,问你雪的厚度. Solution 明显,我们把这俩数减一下就可以得出他们本来的位置,然后直接…
Atcoder ABC 141 A - Weather Prediction SB题啊,不讲. #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> using namespace std; char ch[50]; int main() { scanf("%s",ch+1); if(ch[1] == 'S') puts("Cloudy…
Atcoder ABC 139E 题意: n支球队大循环赛,每支队伍一天只能打一场,求最少几天能打完. 解法: 考虑抽象图论模型,既然一天只能打一场,那么就把每一支球队和它需要交手的球队连边. 求出拓扑序,每次从入度为0的点进行拓扑排序,并把答案加1,删去所有出度,重复该操作. 如果形成环的话就无解. CODE: #include<iostream> #include<cstdio> #include<cstring> #include<algorithm>…
Atcoder ABC 139D 解法: 等差数列求和公式,记得开 $ long long $ CODE: #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; #define LL long long LL n,ans; int main() { scanf("%lld",&n); ans =…
Atcoder ABC 139C 题意: 有 $ n $ 个正方形,选择一个起始位置,使得从这个位置向右的小于等于这个正方形的高度的数量最多. 解法: 简单递推. CODE: #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; #define LL long long const int N = 1e5 + 100; in…
Atcoder ABC 139B 题意: 一开始有1个插口,你的插排有 $ a $ 个插口,你需要 $ b $ 个插口,问你最少需要多少个插排. 解法: 暴力模拟. CODE: #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; #define LL long long #define N 100010 LL a,b,an…
Atcoder ABC 139A 题意: 给你两个字符串,记录对应位置字符相同的个数 $ (n=3) $ 解法: 暴力枚举. CODE: #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; #define N 10 char s1[N],s2[N]; int ans; int main() { scanf("%s…