AtCoder Grand Contest 029 Solution
A:
Solved.
签。
#include <bits/stdc++.h>
using namespace std; #define ll long long
#define N 200010
char s[N]; int main()
{
while (scanf("%s", s + ) != EOF)
{
ll res = ;
int len = strlen(s + ); int last = len;
for (int i = len; i >= ; --i)
{
if (s[i] == 'B')
{
res += last - i;
--last;
}
}
printf("%lld\n", res);
}
return ;
}
B:
Solved.
签。
#include <bits/stdc++.h>
using namespace std; #define N 200010
int n, a[N], Bit[];
unordered_map <int, int> mp; int main()
{
Bit[] = ;
for (int i = ; i <= ; ++i) Bit[i] = Bit[i - ] << ;
while (scanf("%d", &n) != EOF)
{
mp.clear();
for (int i = ; i <= n; ++i)
{
scanf("%d", a + i);
++mp[a[i]];
}
sort(a + , a + + n);
int res = ;
for (int i = n; i >= ; --i)
{
int pos = upper_bound(Bit, Bit + , a[i]) - Bit;
//cout << a[i] << " " << Bit[pos] << endl;
if (pos >= || mp[a[i]] == ) continue;
int tar = Bit[pos] - a[i];
if ((tar != a[i] && mp[tar]) || (tar == a[i] && mp[tar] > ))
{
++res;
--mp[tar];
}
--mp[a[i]];
}
printf("%d\n", res);
}
return ;
}
C:
Unsolved.
题意:
一共有n个字符串,给出每个字符串的长度,要求构造这些字符串,使得$S_1 < S_2 < \cdots < S_n$
这里的小于重载为字典序
D:
Solved.
题意:
在一个棋盘上,A只能向下走,B只能向走
刚开始一个棋子位于(1, 1)位置,有些地方有障碍物,如果有障碍物或到边界就不能走
A想要总步数最多,B想要总步数最少,双方都采用最优策略,问A最后最多能走多少步
思路:
因为A只能向下走,而且只要下面没有障碍物,他一定会向下走
那我们维护B最远能走到那里,然后一层一层往下看,如果最远能走的地方大于等于当前层某个障碍物的横坐标
那么就可以在这层让A停下来
#include <bits/stdc++.h>
using namespace std; #define N 200010
int h, w, n;
vector <int> v[N]; int main()
{
while (scanf("%d%d", &h, &w) != EOF)
{
scanf("%d", &n);
int res = h;
for (int i = ; i <= h; ++i) v[i].clear();
for (int i = , x, y; i <= n; ++i)
{
scanf("%d%d", &x, &y);
v[x].push_back(y);
}
int far = ;
for (int i = ; i <= h; ++i)
{
if (v[i].empty())
{
++far;
continue;
}
sort(v[i].begin(), v[i].end());
if (v[i][] <= far)
{
res = i - ;
break;
}
bool flag = true;
for (auto it : v[i]) if (it == far + )
flag = false;
far += flag;
}
printf("%d\n", res);
}
return ;
}
E:
Unsolved.
题意:
在一棵树上,有一个人迷路了,在某个地方,他要回到编号为1的结点
他采用的策略是每次都选择相邻的编号最小的点去走,走不通就回溯,求最后走到结点1的步数为多少
注意输出n - 1个数,分别为当前处于第$i点,要回到1的步数$
F:
Unsolved.
AtCoder Grand Contest 029 Solution的更多相关文章
- AtCoder Grand Contest 029 翻车记
A:对于每个B,会和其右边的每个W交换一次. #include<iostream> #include<cstdio> #include<cmath> #includ ...
- AtCoder Grand Contest 030 Solution
A - Poisonous Cookies 签到. #include <bits/stdc++.h> using namespace std; #define ll long long l ...
- AtCoder Grand Contest 031 简要题解
AtCoder Grand Contest 031 Atcoder A - Colorful Subsequence description 求\(s\)中本质不同子序列的个数模\(10^9+7\). ...
- AtCoder Grand Contest 012
AtCoder Grand Contest 012 A - AtCoder Group Contest 翻译 有\(3n\)个人,每一个人有一个强大值(看我的假翻译),每三个人可以分成一组,一组的强大 ...
- AtCoder Grand Contest 011
AtCoder Grand Contest 011 upd:这篇咕了好久,前面几题是三周以前写的... AtCoder Grand Contest 011 A - Airport Bus 翻译 有\( ...
- AtCoder Grand Contest 010
AtCoder Grand Contest 010 A - Addition 翻译 黑板上写了\(n\)个正整数,每次会擦去两个奇偶性相同的数,然后把他们的和写会到黑板上,问最终能否只剩下一个数. 题 ...
- AtCoder Grand Contest 009
AtCoder Grand Contest 009 A - Multiple Array 翻译 见洛谷 题解 从后往前考虑. #include<iostream> #include< ...
- AtCoder Grand Contest 008
AtCoder Grand Contest 008 A - Simple Calculator 翻译 有一个计算器,上面有一个显示按钮和两个其他的按钮.初始时,计算器上显示的数字是\(x\),现在想把 ...
- AtCoder Grand Contest 007
AtCoder Grand Contest 007 A - Shik and Stone 翻译 见洛谷 题解 傻逼玩意 #include<cstdio> int n,m,tot;char ...
随机推荐
- swift学习笔记之---数组、字典、枚举、结构体
1.数组-Array let types = ["none","warning","error"] //省略类型的数组声明 let menb ...
- laravel 社会化(联合)登录扩展包(QQ、微信、微博等)
laravel的官方包只支付国外网站的联合登录:http://laravelacademy.org/post/6288.html 国内用户的话,可以用这个:https://github.com/ove ...
- url重写(urlrewrite)的一些系统变量
学php也有3年了,一直对url重写不是很了解,本学用到的话都是百度一下,再复制作简单修改,一些变量的参数都不太了解什么意思,难得今天有时间,做个笔记吧! 1)可用的一些系统变量,在重写条件和重写规则 ...
- 【RF库Collections测试】Dictionary Should Contain Key
Name:Dictionary Should Contain KeySource:Collections <test library>Arguments:[ dictionary | ke ...
- BSTR与char*、cstring、CComBSTR的转换
// BSTR_Convert.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <comutil.h> // ...
- js中replace()方法
str.replace(/Microsoft/g, "W3School");//全局替换 str.replace(/Microsoft/, "W3School" ...
- thinkphp5.0开发规范
命名规范 ThinkPHP5遵循PSR-2命名规范和PSR-4自动加载规范,并且注意如下规范: 目录和文件 目录不强制规范,驼峰及小写+下划线模式均支持: 类库.函数文件统一以.php为后缀: 类的文 ...
- win8.1rtm专业版无法安装net3.5还有iis
win8.1rtm专业版无法安装net3.5还有iis错误代码:0x800F0906 已解决:dism.exe /online /enable-feature /featurename:NetFX3 ...
- url-loader与file-loader
一开始用url-loader的时候,想着为什么npm run build的时候,不能将图片打包到build images的目录下,原来,没有自己看这样的说明: loader 后面 limit 字段代表 ...
- thinkphp---定义前台视图模板
具体可以参考: http://document.thinkphp.cn/manual_3_2.html#template_define 方法一:在入口文件中定义 // 定义模板路径 define(&q ...