ACdream区域赛指导赛之手速赛系列(2)
版权声明:本文为博主原创文章。未经博主同意不得转载。 https://blog.csdn.net/DaiHaoC83E15/article/details/26187183
回到作案现场:http://acdream.info/onecontest/1014
前言:自己出份山寨版的解题报告。
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
A - Boy or Girl
统计用了多少种单词,分奇偶数输出结论,能够用STL的set实现,我对map比較熟。所以果断用map水了。
/*
* this code is made by code4101
* Problem: 1080
* Verdict: Accepted
* Submission Date: 2014-05-19 01:47:38
* Time: 0 MS
* Memory: 1676 KB
*/
#include <iostream>
#include <map>
using namespace std;
int main()
{
string s;
map<char, int> a;
while (cin >> s)
{
a.clear();
for (int i = 0; i < s.size(); i++) a[s[i]]++;
if (a.size()&1) cout << "IGNORE HIM!\n";
else cout << "CHAT WITH HER!\n";
}
return 0;
}
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
B - Walking in the Rain
题目非常多无用的干扰信息。
题意非常easy,就是给n个砖块顺序排好,告诉你每块砖几天后坏。
然后问几天后"路径不通",不通的定义是:①第一个或最后一个坏了 ②存在连续的两个坏了。
我是用递归,每次找到最小的非0值模拟暴力解(比赛中的我常常该去吃药了)。
后来__M子__给的思想是一次遍历就够了:遍历max(a[i]。a[i+1]),记录最小值,再与头尾比較。
/*
* this code is made by code4101
* Problem: 1079
* Verdict: Accepted
* Submission Date: 2014-05-19 02:01:47
* Time: 0 MS
* Memory: 1672 KB
*/
#include <iostream>
using namespace std;
int main()
{
int n, a[1010], i, ans, t;
while (cin >> n)
{
for (i = 0; i < n; i++) cin >> a[i];
ans = min(a[0], a[n-1]);
for (i = 0; i < n-1; i++)
{
t = max(a[i], a[i+1]);
if (t < ans) ans = t;
}
cout << ans << "\n";
}
return 0;
}
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
C - Cutting Figure
就是给一个连通图,让你用最小的删除操作把它变成非连通图。事实上答案范围一定在-1~4之间(随便找一个点,把上下左右全删除。这个点就孤立了。最坏情况下把其变为非连通图),-1代表无法实现。再进一步分析,事实上答案仅仅有-1、1、2三种情况(角上的点最多去掉2个相邻的就孤立了)。
-1就是初始集合元素不超过2个。这样无论怎么删都是连通的。1的话要遍历,一个个顶点去掉,用BFS尝试看是不是非连通图(BFS用队列实现。这个不懂去补基础吧)。假设不是前两者,那么答案就一定是2了。
/*
* this code is made by code4101
* Problem: 1078
* Verdict: Accepted
* Submission Date: 2014-05-18 12:04:24
* Time: 0 MS
* Memory: 1688 KB
*/
#include <cstdio>
#include <iostream>
#include <cstring>
#include <queue>
using namespace std;
int n, m;
bool a[60][60], b[60][60], zero[60][60] = {};
struct point{
int x, y;
};
// 推断一个b是不是连通
bool isconnected(int x, int y)
{
// 先进行一遍BFS
queue<point> A;
point p, t;
p.x = x; p.y = y;
A.push(p); b[p.x][p.y] = 0;
while (A.size())
{
t = A.front(); A.pop();
if (b[p.x = t.x-1][p.y = t.y]) A.push(p), b[p.x][p.y] = 0;
if (b[p.x = t.x][p.y = t.y-1]) A.push(p), b[p.x][p.y] = 0;
if (b[p.x = t.x][p.y = t.y+1]) A.push(p), b[p.x][p.y] = 0;
if (b[p.x = t.x+1][p.y = t.y]) A.push(p), b[p.x][p.y] = 0;
}
if (memcmp(zero, b, sizeof(b))) return 0;
else return 1;
}
// 推断去掉随意一个#是不是连通
int fun()
{
int i, j;
for (i = 1; i <= n; i++)
{
for (j = 1; j <= m; j++) if (a[i][j])
{
memcpy(b, a, sizeof(a));
b[i][j] = 0;
int x, y; // 起点
if (b[x = i-1][y = j]);
else if (b[x = i][y = j-1]);
else if (b[x = i][y = j+1]);
else if (b[x = i+1][y = j]);
if (!isconnected(x, y)) return 1;
}
}
return 2;
}
int main()
{
while (cin >> n >> m)
{
memset(a, 0, sizeof(a));
int sum = 0, i, j;
for (i = 1; i <= n; i++)
{
getchar();
for (j = 1; j <= m; j++)
{
if (getchar() == '#')
{
sum += a[i][j] = 1;
}
}
}
if (sum <= 2) cout << "-1\n";
else cout << fun() << "\n";
}
return 0;
}
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
D - LCM Challenge
这题我在蓝桥杯做过:http://www.coolnote.cn/problems/66/。这篇文章分析的非常具体:http://blog.csdn.net/u011669700/article/details/18702757,事实上我到如今还是不太懂原理;原题来自这里: m=ProblemSet&a=showProblem&problem_id=1632" rel="nofollow">http://acm.hrbust.edu.cn/index.php?m=ProblemSet&a=showProblem&problem_id=1632
/*
* this code is made by code4101
* Problem: 1077
* Verdict: Accepted
* Submission Date: 2014-05-19 02:15:50
* Time: 0 MS
* Memory: 1672 KB
*/
#include <iostream>
using namespace std;
int main()
{
unsigned long long n, ans;
while (cin >> n)
{
if (n <= 2) ans = n;
else if (n & 1) ans = n * (n - 1) * (n - 2);
else if (n % 3) ans = n * (n - 1) * (n - 3);
else ans = (n - 1) * (n - 2) * (n - 3);
cout << ans << '\n';
}
return 0;
}ACdream区域赛指导赛之手速赛系列(2)的更多相关文章
- ACdream区域赛指导赛之手速赛系列(5) 题解
A - Problem A Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) Submi ...
- ACdream区域赛指导赛之手速赛系列(7)
A -Dragon Maze Time Limit: 2000/1000MS (Java/Others)Memory Limit: 128000/64000KB (Java/Others) Submi ...
- ACDream手速赛2
地址:http://acdream.info/onecontest/1014 都是来自Codeforce上简单题. A. Boy or Girl 简单字符串处理 B. Walking in ...
- 快速切题 acdream手速赛(6)A-C
Sudoku Checker Time Limit: 2000/1000MS (Java/Others)Memory Limit: 128000/64000KB (Java/Others) Submi ...
- Acdream手速赛7
蛋疼啊,本次只做出了一道题目...渣爆了... 妈蛋,,卡题之夜..比赛结果是1道题,比赛完哗啦哗啦出4道题.. A acdream1191 Dragon Maze 题意: 给一个迷宫,给出入口坐标和 ...
- ACdream区域赛指导赛之专题赛系列(1)の数学专场
Contest : ACdream区域赛指导赛之专题赛系列(1)の数学专场 A:EOF女神的相反数 题意:n(<=10^18)的数转化成2进制.翻转后(去掉前导零)输出十进制 思路:water ...
- Contest - 2014 SWJTU ACM 手速测试赛(2014.10.31)
题目列表: 2146 Problem A [手速]阔绰的Dim 2147 Problem B [手速]颓废的Dim 2148 Problem C [手速]我的滑板鞋 2149 Problem D [手 ...
- 手速太慢QAQ
显然D是个细节题,但是还剩1h时看眼榜还没人过EF,只好冷静写D,大概思路是任何时候如果min(n,m)<=2,max(n,m)<=4暴搜,否则直接贪心是很对的,即第一步让S.T长度平均化 ...
- tensorflow笔记(四)之MNIST手写识别系列一
tensorflow笔记(四)之MNIST手写识别系列一 版权声明:本文为博主原创文章,转载请指明转载地址 http://www.cnblogs.com/fydeblog/p/7436310.html ...
随机推荐
- ListView的ScrollBar设置
默认ListView的滑动时,右侧会有滑动条显示,等ListView滑动结束时,滑动条消失.修改ScrollBar的显示可以在XML以及CODE中实现. CODE中实现:1.setFastScroll ...
- appium问题解决
ppium 1.4.16 版本 测试安卓7.0 提示AppiumSettings.Unlock.AndroidInputManager 安装 修改 C:\Program Files (x86)\App ...
- Python 读取写入配置文件 ConfigParser
https://blog.csdn.net/piaodexin/article/details/77371343 https://www.cnblogs.com/feeland/p/4502931.h ...
- 【小坑】java下载excel文件
excel文件的导入导出是很常见的功能,这次做了个下载的功能,踩了一些坑,记下来避免以后重复踩…… 1.inputstream序列化问题 Could not write JSON document: ...
- 20145105 《Java程序设计》第5周学习总结
20145105 <Java程序设计>第5周学习总结 教材学习内容总结 第八章 异常处理 一.语法与继承架构 (一)使用try.catch 执行流程 尝试执行try区块中程序代码 如果出现 ...
- 'workspace' in VS Code
What is a 'workspace' in VS Code? You can save settings at the workspace level and you can open mult ...
- Codeforces Round #390 (Div. 2) A. Lesha and array splitting
http://codeforces.com/contest/754/problem/A 题意: 给出一串序列,现在要把这串序列分成多个序列,使得每一个序列的sum都不为0. 思路: 先统计一下不为0的 ...
- UVa 10534 波浪子序列(快速求LIS)
https://vjudge.net/problem/UVA-10534 题意:给定一个长度为n的整数序列,求一个最长子序列(不一定连续),使得该序列的长度为2k+1,前k+1个数严格递增,后k+1个 ...
- Python的hasattr() getattr() setattr() 函数使用方法详解--转载
hasattr(object, name)判断一个对象里面是否有name属性或者name方法,返回BOOL值,有name特性返回True, 否则返回False.需要注意的是name要用括号括起来 1 ...
- python 字符串的反转
def string_reverse(str1): rstr1 = '' index = len(str1) : rstr1 += str1[ index - ] index = index - re ...