Codeforces Round #192 (Div. 2)
吐槽一下,这次的CF好简单啊。 可是我为什么这么粗心这么大意这么弱。把心沉下来,想想你到底想做什么!
A
题意:O(-1)
思路:O(-1)
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std; int main()
{
string s[];
int mp[][];
int n, m;
while(cin >> n >> m)
{
memset(mp,,sizeof(mp));
for(int i=; i<n; i++)
cin >> s[i];
for(int i=; i<n; i++)
{
int cnt=;
for(int j=; j<m; j++)
if(s[i][j]!='S') cnt++;
if(cnt==m)
{
for(int j=; j<m; j++) mp[i][j]=;
}
}
for(int i=; i<m; i++)
{
int cnt=;
for(int j=; j<n; j++)
if(s[j][i]!='S') cnt++;
if(cnt==n)
{
for(int j=; j<n; j++) mp[j][i]=;
}
}
int sum=;
for(int i=; i<n; i++)
for(int j=; j<m; j++)
if(mp[i][j]) sum++;
cout << sum <<endl;
}
}
B
题意:有n个城市,然后给定m对城市不可建路,一个城市到另一个城市最多经过两条路,问你如何建路。
思路:两个城市之间的距离最多为2说明一条线上最多三个点,且有一点必须再所有三个点的中心。找出一个没有在不可连接的城市的点(因为0<M<N/2).
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <map>
using namespace std; const int maxn=;
int que[*maxn]; int main()
{
int n, m;
while(cin >> n >> m)
{
map<int,int>mp;
int num=;
for(int i=; i<m; i++)
{
int u, v;
cin >>u >> v;
mp[u]=;
mp[v]=;
}
int tp;
for(int i=; i<=n; i++)
if(!mp[i]) tp=i;
cout << n- <<endl;
for(int i=; i<=n; i++)
{
if(i!=tp) cout << i << " " << tp <<endl;
}
}
return ;
}
C
题意:O(-1)
思路:开始想复杂了,想成n皇后问题。其实这题想想也就很水的一题,对每行分析,每行能找出一个空点就是可行解,如果有一行找不到,就对每列找,每列能找到一个空点就是可行解。很水的一题,开始写成了N皇后问题,然后再源代码上改的,最后挂了,悲剧,为什么就懒这一些重新写两个for循环不就好了么,下次不能偷懒了。
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std; const int maxn=;
int a[maxn][maxn], b[maxn]
string s[]; int main()
{
int n;
while(cin >> n)
{
for(int i=; i<n; i++) cin >> s[i];
int top=, flag=;
for(int i=; i<n; i++)
for(int j=; j<n; j++)
if(s[i][j]=='.')
{
top++;
break;
}
if(top==n)
{
flag=;
for(int i=; i<n; i++)
for(int j=; j<n; j++)
if(s[i][j]=='.')
{
cout << i+ << " " << j+ <<endl;
break;
}
}
top=;
for(int j=; j<n; j++)
for(int i=; i<n; i++)
if(s[i][j]=='.')
{
top++;
break;
}
if(top==n&&!flag)
{
flag=;
for(int j=; j<n; j++)
for(int i=; i<n; i++)
if(s[i][j]=='.')
{
cout << i+ << " " << j+ <<endl;
break;
}
}
if(!flag) puts("-1");
}
return ;
}
/*
3
EEE
...
...
*/
D:
题意:屌丝从起点S出发去终点E找女神,途中可能会遇见情敌,问屌丝最少能遇见几个情敌。
思路:开始看错了题,以为题目要求最少要遇见一个情敌,然后用了两次广搜,起点和终点分别搜一次。题目木有这么要求啊啊啊啊啊啊啊 O.O O.O O.O。
下次能再给我大意一点么!这题不用想得太复杂,不管这么走,屌丝和情敌都往女神那里走,情敌先到女神那里就一定能遇见屌丝然后干一架,从终点广搜一次就够了。
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std; const int maxn=;
char map[][];
long long a[maxn][maxn],visit[maxn][maxn];
int n, m, si, sj, di, dj;
int dir[][]= {,,,-,,,-,}; struct node
{
int x, y;
long long time;
} f[maxn*maxn]; void bfs(int st, int sd)
{
queue<node>q;
memset(visit,,sizeof(visit));
node s, p;
s.x=st, s.y=sd, s.time=;
q.push(s);
while(!q.empty())
{
p=q.front();
q.pop();
for(int i=; i<; i++)
{
s.x=p.x+dir[i][];
s.y=p.y+dir[i][];
s.time=p.time+;
if(<=s.x&&s.x<=n&&<=s.y&&s.y<=m&&map[s.x][s.y]!='T'&&!visit[s.x][s.y])
{
visit[s.x][s.y]=;
a[s.x][s.y]=s.time;
q.push(s);
}
}
}
} int main()
{
while(cin >> n >> m)
{
int num=;
for(int i=; i<=n; i++)
{
scanf("%s",map[i]+);
for(int j=; j<=m; j++)
{
if(map[i][j]=='S') si=i, sj=j;
else if(map[i][j]=='E') di=i, dj=j;
else if(''<map[i][j]&&map[i][j]<='')
{
f[num].x=i;
f[num].y=j;
num++;
}
}
}
memset(a,,sizeof(a));
bfs(di,dj);
long long sum=;
for(int i=; i<num; i++)
{
int x=f[i].x, y=f[i].y;
if(a[x][y]<=a[si][sj]&&a[x][y]) sum+=map[x][y]-'';
}
cout << sum <<endl;
}
return ;
}
E:
不会。
Codeforces Round #192 (Div. 2)的更多相关文章
- Codeforces Round #192 (Div. 1) C. Graph Reconstruction 随机化
C. Graph Reconstruction Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/3 ...
- Codeforces Round #192 (Div. 1) B. Biridian Forest 暴力bfs
B. Biridian Forest Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/329/pr ...
- Codeforces Round #192 (Div. 1) A. Purification 贪心
A. Purification Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/329/probl ...
- [Codeforces Round #192 (Div. 2)] D. Biridian Forest
D. Biridian Forest time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #192 (Div. 2) (330B) B.Road Construction
题意: 要在N个城市之间修建道路,使得任意两个城市都可以到达,而且不超过两条路,还有,有些城市之间是不能修建道路的. 思路: 要将N个城市全部相连,刚开始以为是最小生成树的问题,其实就是一道简单的题目 ...
- Codeforces Round #192 (Div. 2) (330A) A. Cakeminator
题意: 如果某一行没有草莓,就可以吃掉这一行,某一列没有也可以吃点这一列,求最多会被吃掉多少块蛋糕. //cf 192 div2 #include <stdio.h> #include & ...
- Codeforces Round #192 (Div. 2) A. Cakeminator
#include <iostream> #include <vector> using namespace std; int main(){ int r,c; cin > ...
- Codeforces Round #192 (Div. 2) B. Road Construction
#include <iostream> #include <vector> using namespace std; int main(){ int n,m; cin > ...
- Codeforces Round #192 (Div. 2) (329A)C.Purification
题意: 在一个正常的点可以净化该行该列的所有细胞,判断是否可以净化所有的细胞,并且输出所选的点. 思路: 如果可以的话,一定会选n个点. 先判断每一行是否有正常细胞,然后判断每一列是否有,如果都没有肯 ...
随机推荐
- 金融左侧js错误
- loadrunner取出关联数组中的所有元素
方法一: int num; char nameVar[100]; char nameValue[100]; lr_save_string("AAA","name_1&qu ...
- ASP.NET中Url编码解码
今天遇到Url编码解码的问题,纠结了一天的时间,结果上网一查才发现太二了我们. 同事写的代码把url用HttpUtility.UrlEncode编码和解码了,本地测试没有问题,部署到服务器上就提示转码 ...
- javascript引擎工作原理
1. 什么是JavaScript解析引擎? 简单地说,JavaScript解析引擎就是能够“读懂”JavaScript代码,并准确地给出代码运行结果的一段程序.比方说,当你写了 var a = 1 + ...
- Uva 548 Tree
0.这是一道利用中序遍历和后序遍历确定二叉树的题目,学会建树 关键点理解这段代码 int build(int L1,int R1,int L2,int R2) { //printf("bui ...
- css/js(工作中遇到的问题)
移动设备点击时去掉外加的蓝色边框 a, input, button { -webkit-tap-highlight-color: rgba(0,0,0,0); -webkit-tap-highligh ...
- 使用dSYM分析App崩溃日志
前言 我们在开发App过程中,因为连接到控制台,所以遇到问题会很容易找到问题代码.但是对于线上的App出现Crash的时候,我们不可能通过这种方式,也不现实,所以我们只能通过收集Crash信息,来解决 ...
- BestCoder Round #71 (div.2)
数学 1001 KK's Steel 类似斐波那契求和 #include <cstdio> #include <cstring> #include <algorithm& ...
- Oracle 使用小计(4)
1.oracle字符串分割函数split )定义split_type类型: CREATE OR REPLACE TYPE split_type IS TABLE OF VARCHAR2 (4000) ...
- time元素
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...