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

  1. AtCoder Grand Contest 029 翻车记

    A:对于每个B,会和其右边的每个W交换一次. #include<iostream> #include<cstdio> #include<cmath> #includ ...

  2. AtCoder Grand Contest 030 Solution

    A - Poisonous Cookies 签到. #include <bits/stdc++.h> using namespace std; #define ll long long l ...

  3. AtCoder Grand Contest 031 简要题解

    AtCoder Grand Contest 031 Atcoder A - Colorful Subsequence description 求\(s\)中本质不同子序列的个数模\(10^9+7\). ...

  4. AtCoder Grand Contest 012

    AtCoder Grand Contest 012 A - AtCoder Group Contest 翻译 有\(3n\)个人,每一个人有一个强大值(看我的假翻译),每三个人可以分成一组,一组的强大 ...

  5. AtCoder Grand Contest 011

    AtCoder Grand Contest 011 upd:这篇咕了好久,前面几题是三周以前写的... AtCoder Grand Contest 011 A - Airport Bus 翻译 有\( ...

  6. AtCoder Grand Contest 010

    AtCoder Grand Contest 010 A - Addition 翻译 黑板上写了\(n\)个正整数,每次会擦去两个奇偶性相同的数,然后把他们的和写会到黑板上,问最终能否只剩下一个数. 题 ...

  7. AtCoder Grand Contest 009

    AtCoder Grand Contest 009 A - Multiple Array 翻译 见洛谷 题解 从后往前考虑. #include<iostream> #include< ...

  8. AtCoder Grand Contest 008

    AtCoder Grand Contest 008 A - Simple Calculator 翻译 有一个计算器,上面有一个显示按钮和两个其他的按钮.初始时,计算器上显示的数字是\(x\),现在想把 ...

  9. AtCoder Grand Contest 007

    AtCoder Grand Contest 007 A - Shik and Stone 翻译 见洛谷 题解 傻逼玩意 #include<cstdio> int n,m,tot;char ...

随机推荐

  1. Android弹出Dialog使用举例

    Android详细的对话框AlertDialog.Builder使用方法 7种形式的Android Dialog使用举例 第30章.常见对话框之一AlertDialog(从零开始学Android)

  2. ch6-定制数据对象(打包代码和数据)

    为了看出数据属于哪个选手,教练向各个选手的数据文件中添加了标识数据:选手全名,出生日期,计时数据. 例如:sarah文件的数据更新为: Sarah Sweeney,2002-6-17,2:58,2.5 ...

  3. C++11新特性之五——可变参数模板

    有些时候,我们定义一个函数,可能这个函数需要支持可变长参数,也就是说调用者可以传入任意个数的参数.比如C函数printf(). 我们可以这么调用. printf(); 那么这个函数是怎么实现的呢?其实 ...

  4. DNS、链接网页、资源预加载处理

    从网页性能的角度来看,DNS的解析时间是比较耗时的.因此如果能预先下载网页中用到的其它域的资源.可提前进行DNS解析: <link rel="dns-prefetch" hr ...

  5. CodeForces - 459E Pashmak and Graph[贪心优化dp]

    E. Pashmak and Graph time limit per test 1 second memory limit per test 256 megabytes input standard ...

  6. 由JS函数返回值引发的一场”血案"

    ---恢复内容开始--- 啊...  本来昨天晚上想写来着,结果陪老婆看电视剧就忘了... 呢滴神啊,原谅我吧. 背景:昨天在项目中做一个小功能的时候,出现了个小问题,而且一开始找了半天也没找到原因. ...

  7. EUI组件之BitmapLabel 位图字体

    一.制作文图字体文件 使用TextureMerger制作位图字体,具体查看 官方教程. 我们这里制作了一组位图字体. 二.导入位图字体 位图字体素材放入资源配置文件default.res.json 三 ...

  8. Ts中的接口interface(属性也能继承...)

    接口ITest.ts interface ITest { name:string; age:number; run(); to(x:number,y:number):number; } 必须继承接口的 ...

  9. highmaps如何自定义 区间的颜色刻度

    https://api.highcharts.com/highmaps/colorAxis.dataClassColor http://jsfiddle.net/gh/get/library/pure ...

  10. web.xml的contextConfigLocation作用及自动加载applicationContext.xml

    web.xml的contextConfigLocation作用及自动加载applicationContext.xml 转自:http://blog.csdn.net/sapphire_aling/ar ...