总结一下这场比赛,就是我太SB了。说多了都是泪。

A,大水题。

B,根据题意,可以肯定有一个城市是可以与所有城市相连的,直接找到该点然后输出该点与其他所有点相连即可。

int x[111111] , y[111111] ,num ;
bool vis[111111] ;
int aa[111111] ,nn = 0 ;
void antry(){
num = 0 ;
int n , m ;
cin >> n >> m ;
mem(vis,0) ; for (int i = 0 ;i < m ;i ++ ){
int a , b ;
cin >> a >> b ;
vis[a] = 1 ;
vis[b] = 1 ;
}
int pos ;
for (int i = 1 ;i <= n ;i ++ ){
if(!vis[i]){
pos = i ;
break ;
}
}
cout << n - 1 << endl;
for (int i = 1 ;i <= n ;i ++ ){
if(i == pos)continue ;
cout << pos <<" " << i << endl;
}
}
int main() {
antry() ;
return 0 ;
}

C,先说-1的情况,当点[x , y ]行x 与列y 都是E的时候,那么就是-1。

然后只要判断 每一行 ,是否没满 ,或者每一列是否没满 。

如果每一行都没满 ,那么每一行都输出一个点,如果每一列都没满,那么每一列都找一个点输出。

char Map[1111][1111] ;
int hang[1111] ;
int lie[1111] ;
int main() { int n ;
cin >> n ;
for (int i = 1 ; i <= n ;i ++ ){
for (int j = 1 ;j <= n ;j ++ ){
cin >> Map[i][j] ;
if(Map[i][j] == 'E'){
hang[i] ++ ;
lie[j] ++ ;
}
}
}
int flag = 0 ;
for (int i = 1 ;i <= n ;i ++ ){
for (int j = 1 ;j <= n ;j ++ ){
if(hang[i] == n && lie[j] == n){
flag = 1 ;
}
}
}
if(flag)cout << -1 << endl;
else {
int num1 = 0 ;
int num2 = 0 ;
for (int i = 1 ;i <= n ;i ++ ){
if(hang[i] != n)num1 ++ ;
if(lie[i] != n)num2 ++ ;
}
if(num1 == n){
for (int i = 1 ;i <= n ;i ++ )
{
bool ff = 0 ;
for (int j = 1 ;j <= n ;j ++ ){
if(Map[i][j] == '.'){
cout << i << " " << j << endl;
ff = 1 ;
}
if(ff)break ;
}
}
}
else if(num2 == n){
for (int i = 1 ;i <= n ;i ++ ){
int ff = 0 ;
for (int j = 1 ;j <= n ;j ++ ){
if(Map[j][i] == '.'){
cout << j << " " <<i << endl;
ff = 1 ; }
if(ff)break ;
}
}
}
}
return 0;
}

D,大水题,直接从E开始BFS,找出所有点的距离,然后判断是否比S 到E的时间小,加起来即可。

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <queue>
#include <set>
#include <vector>
#include <stack>
#include <map>
#include <iomanip>
#define PI acos(-1.0)
#define Max 2505
#define inf 1<<28
#define LL(x) ( x << 1 )
#define RR(x) ( x << 1 | 1 )
#define REP(i,s,t) for( int i = ( s ) ; i <= ( t ) ; ++ i )
#define ll long long
#define mem(a,b) memset(a,b,sizeof(a))
#define mp(a,b) make_pair(a,b)
#define PII pair<int,int>
using namespace std; inline void RD(int &ret) {
char c;
do {
c = getchar();
} while(c < '0' || c > '9') ;
ret = c - '0';
while((c=getchar()) >= '0' && c <= '9')
ret = ret * 10 + ( c - '0' );
} char Map[1111][1111] ;
PII st[11111111] ;
int sx ,sy ;
int ex ,ey ;
int vis[1005][1005] ;
int n , m ;
int num[1005][1005] ;
queue<PII > qe ;
int mx[4] = {0 , 0 ,-1, 1} ;
int my[4] = {1, -1, 0 ,0 } ;
int inmap(int x ,int y){
if(x >= 1 && x <= n && y >= 1 && y <= m)return 1 ;
return 0 ;
}
int dbfs(){
PII s , e ;
mem(vis,0) ;
mem(num , 0) ;
e.first = ex ;
e.second = ey ;
while(!qe.empty())qe.pop() ;
qe.push(e) ;
num[ex][ey] = 0 ;
vis[ex][ey] = 1 ;
while(!qe.empty()){
PII tmp = qe.front() ;
qe.pop() ;
for (int i = 0 ;i < 4 ;i ++ ){
int tx = tmp.first + mx[i] ;
int ty = tmp.second + my[i] ;
if(inmap(tx, ty) && Map[tx][ty] != 'T'){
if(!vis[tx][ty]){
vis[tx][ty] = 1 ;
num[tx][ty] = num[tmp.first][tmp.second] + 1 ;
qe.push(mp(tx,ty)) ;
} }
}
}
return inf ;
}
void antry(){ cin >> n >> m ;
int num1 = 0 ;
for (int i = 1 ;i <= n ; i ++ ){
for (int j = 1 ;j <= m ; j ++ ){
cin >> Map[i][j] ;
if(Map[i][j] >= '1' && Map[i][j] <= '9'){
st[num1].first = i ;
st[num1].second = j ;
num1 ++ ;
}
else if(Map[i][j] == 'S'){
sx = i ;
sy = j ;
}
else if(Map[i][j] == 'E'){
ex = i ;
ey = j ;
}
}
}
dbfs() ;
int ans = 0 ;
int s1 = num[sx][sy] ;
for (int i = 0 ;i < num1 ; i ++ ){
int s2 = num[st[i].first][st[i].second] ;
if(s2 <= s1 && s2 != 0){
ans += Map[st[i].first][st[i].second] - '0' ;
}
}
cout << ans << endl;
}
int main() {
antry() ;
return 0 ;
}

E,在搞。

CF 192 DIV.2的更多相关文章

  1. CF #376 (Div. 2) C. dfs

    1.CF #376 (Div. 2)    C. Socks       dfs 2.题意:给袜子上色,使n天左右脚袜子都同样颜色. 3.总结:一开始用链表存图,一直TLE test 6 (1)如果需 ...

  2. CF #375 (Div. 2) D. bfs

    1.CF #375 (Div. 2)  D. Lakes in Berland 2.总结:麻烦的bfs,但其实很水.. 3.题意:n*m的陆地与水泽,水泽在边界表示连通海洋.最后要剩k个湖,总要填掉多 ...

  3. CF #374 (Div. 2) D. 贪心,优先队列或set

    1.CF #374 (Div. 2)   D. Maxim and Array 2.总结:按绝对值最小贪心下去即可 3.题意:对n个数进行+x或-x的k次操作,要使操作之后的n个数乘积最小. (1)优 ...

  4. CF #374 (Div. 2) C. Journey dp

    1.CF #374 (Div. 2)    C.  Journey 2.总结:好题,这一道题,WA,MLE,TLE,RE,各种姿势都来了一遍.. 3.题意:有向无环图,找出第1个点到第n个点的一条路径 ...

  5. CF #371 (Div. 2) C、map标记

    1.CF #371 (Div. 2)   C. Sonya and Queries  map应用,也可用trie 2.总结:一开始直接用数组遍历,果断T了一发 题意:t个数,奇变1,偶变0,然后与问的 ...

  6. CF #365 (Div. 2) D - Mishka and Interesting sum 离线树状数组

    题目链接:CF #365 (Div. 2) D - Mishka and Interesting sum 题意:给出n个数和m个询问,(1 ≤ n, m ≤ 1 000 000) ,问在每个区间里所有 ...

  7. CF #365 (Div. 2) D - Mishka and Interesting sum 离线树状数组(转)

    转载自:http://www.cnblogs.com/icode-girl/p/5744409.html 题目链接:CF #365 (Div. 2) D - Mishka and Interestin ...

  8. Codeforces Round #192 (Div. 2) (330B) B.Road Construction

    题意: 要在N个城市之间修建道路,使得任意两个城市都可以到达,而且不超过两条路,还有,有些城市之间是不能修建道路的. 思路: 要将N个城市全部相连,刚开始以为是最小生成树的问题,其实就是一道简单的题目 ...

  9. Codeforces Round #192 (Div. 2) (330A) A. Cakeminator

    题意: 如果某一行没有草莓,就可以吃掉这一行,某一列没有也可以吃点这一列,求最多会被吃掉多少块蛋糕. //cf 192 div2 #include <stdio.h> #include & ...

随机推荐

  1. MVC验证09-使用MVC的Ajax.BeginForm方法实现异步验证

    原文:MVC验证09-使用MVC的Ajax.BeginForm方法实现异步验证 MVC中,关于往后台提交的方法有: 1.Html.BeginForm():同步 2.Ajax.BeginForm():异 ...

  2. CSS下背景属性background的使用方法

    背景颜色(background-color) CSS可以用纯色来作为背景,也可以将背景设置为透明,background相当于xhtml中的bgcolor. 它的两个值: transparent(默认值 ...

  3. leetcode -day31 Subsets I II

    1.  Subsets Given a set of distinct integers, S, return all possible subsets. Note: Elements in a ...

  4. Fluent NHibernate

    Fluent NHibernate]第一个程序 目录 写在前面 Fluent Nhibernate简介 基本配置 总结 写在前面 在耗时两月,NHibernate系列出炉这篇文章中,很多园友说了Flu ...

  5. lsof基本使用

    当你想在计算机上启动一个服务,电脑已经建议"port already in use",此时,可以使用lsof命令查看占用端口的进程(lsof -i:port). lsof这是LiS ...

  6. 2014年3I工作室成员的正式名单

    后3I认真审议和审查工作室的老师及相关人员,今天,新成员首次正式发布,如以下:博才文(11软件).黄彩云(11软件).朱小丹(11软件).海(11软件).欧剑灵(11此计).黄思源(12软件).黄龙营 ...

  7. C#中文本模板(.tt)

    关于C#中文本模板(.tt)的简单应用 这两天做项目突遇 .tt文件,之前没有接触过,so查询学习做笔记,帮助记忆和后来者. 在项目添加中点击选择文本模板 下面贴出代码,做了简单的注释 1 2 3 4 ...

  8. Ubuntu 14.04 字体设置

    ubuntu 14.04消息公布后,我迫不及待地安装和使用.不知道怎么搞的,整个系统彻底改变了字体.有罪,看. 后来.听说文泉驿米黑效果不错.就试了一下,确实还行. 以下是设置方法: 1.安装文泉驿米 ...

  9. Android学习路径(四)文件项目学习的名单,android显示单元经常使用的

    1.的该项目文件所谓名单AndroidManifest.xml文件.该文件,但有很大的利用,例:app名字.图标,app支持的版本app等等.以下我就介绍下这个清单文件的各个參数的作用. <ma ...

  10. Protocol Buffer和JSON性能比较

      JSON PB 数据结构支持 简单结构 较复杂结构 数据格式 文本 二进制 数据大小 一般 小,json大小的1/3左右 解析效率 一般 快,是json解析速度的3-10倍 可读性 好,自描述的 ...