PROBLEM B D E F ARE INCLUDED

Problem B. 3D City Model

题意:

用积木搭成 N * M 的物体,并给出每块的高度求表面积。

思路:

对于每一块区域,有基础面积 4 * H + 2

再分别减去与上下左右的重合面积(两个区域的最小高度)

代码:

#include <bits/stdc++.h>using namespace std;
int a[105][105];
char x;
int dirx[4]={1,0,-1,0};
int diry[4]={0,1,0,-1};
int main()
{freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);int n,m;while(cin>>n>>m){long long ans=0;memset(a,0,sizeof(a));for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cin>>x;x-='0';a[i][j]=x;}}for(int i=1;i<=n;i++)for(int j=1;j<=m;j++){if(a[i][j]) ans+=4*a[i][j]+2;for(int k=0;k<4;k++){ans-=min(a[i+dirx[k]][j+diry[k]],a[i][j]);}}cout<<ans<<endl;}
}

Problem D. Fire in the Country

题意:

有n个点,m条无向边(m >= n-1),棋子在点1,一人走一步,只能走到直接关联的点,然后点1着火了,每次从1开始扩散,与着火点直接关联的点都会着火,而且不会灭,谁往火力走谁输。第一个人甲先走,问谁输。

思路:

由于给出的大部分是图,要先 bfs 染色确定火在第几步会烧到那个点,同时记录下到达哪个点时该谁走。

再从 1 点开始 dfs 搜索。在搜索中我们考虑一下几种情况:

1.当前点是一个终点,那么如果这个点轮到甲走,他已无路可走则甲输,反之则乙输。

2.当前点是一个分叉点,走到这一点可以选择一条路径继续走。那么:

(1)如果是轮到甲走,如果分叉点下存在一条甲的必胜路径,则甲胜。若一条甲的必胜路径都没有,则甲输。

(2)如果是轮到乙走,如果分叉点下存在一条甲的必输路径,则乙胜。若所有的路径都是甲的必胜路径,则甲胜。

代码:

#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1000+100;
int n,m,color[MAXN],son[MAXN];
bool peo[MAXN];
vector <int> mp[MAXN];
void ini(){for(int i=1;i<=n;i++){color[i]=MAXN;mp[i].clear();son[i]=0;peo[i]=0;}
}
void make_color(){queue <int> que;que.push(1);color[1]=0;peo[1]=0;int pos,now;while(!que.empty()){pos=que.front();que.pop();int len=mp[pos].size();for(int i=0;i<len;i++){now=mp[pos][i];if(color[now]>color[pos]){son[pos]++;peo[now]=!peo[pos];if(color[now]==MAXN) que.push(now);color[now]=color[pos]+1;}}}
}
int solve(int pos){if(son[pos]==0) return peo[pos];int len=mp[pos].size();int ans=0;for(int i=0;i<len;i++)if(color[mp[pos][i]]>color[pos])ans+=solve(mp[pos][i]);if(!peo[pos]){if(ans) return 1;else return 0;}else{if(ans==son[pos]) return 1;else return 0;}
}
int main(){ios::sync_with_stdio(false);freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);while(cin>>n>>m){int x,y;ini();for(int i=0;i<m;i++){cin>>x>>y;mp[x].push_back(y);mp[y].push_back(x);}make_color();if(solve(1)) cout<<"Vladimir"<<endl;else cout<<"Nikolay"<<endl;}
}

Problem E. Kidnapping

转自:http://blog.csdn.net/tianyuhang123/article/details/62054038

题意:     抓劫匪的题,最后总结为有n条路,a[x][y]表示第x条路与第y条路之间的距离,由于绑匪将人绑着,所以人只能计算出走的路程给出计算的路程问最后到达的劫匪窝点可能是那条街(每次都是从第一条路开始)思路:     直接搜索就行了,输入一个数把可能的点标记,然后再输入后来的数,但每次标记时需要把以前标记过得请0,最后被标记的那些点就是可能的点代码:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;int main()
{freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);int a[205][205],b[205],c[205],n,m,h;while(cin>>n){for(int i=1;i<=n;i++){for(int j=1;j<=n;j++)cin>>a[i][j];}cin>>m;memset(b,0,sizeof(b));memset(c,0,sizeof(c));b[1]=1;for(int i=1;i<=m;i++){cin>>h;for(int j=1;j<=n;j++){if(b[j]){for(int k=1;k<=n;k++){if(a[j][k]==h)c[k]=1;}}}for(int j=1;j<=n;j++)b[j]=c[j];memset(c,0,sizeof(c));}int sum=0;for(int i=1;i<=n;i++){if(b[i]==1){c[sum++]=i;}}cout<<sum<<endl;if(sum>0){for(int i=0;i<sum-1;i++)printf("%d ",c[i]);printf("%d\n",c[sum-1]);}}return 0;
}

Problem F. Elevator

转自:http://blog.csdn.net/tianyuhang123/article/details/62054491
题意:
坐电梯然后在一个楼层有好多人按了不同的楼层,根据先来后到的顺序,不过如果在前面人和原楼层之间的人可以在过程中下楼梯
思路:
从头往后遍历一遍如果后面有在前面人俺的楼层之间的直接输出然后把标记清0,不过需要注意有两种情况,有可能是从高楼层到低楼层(降序输出),从低楼层到高楼层(升序输出)
代码:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;int main()
{freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);int m,n;int a[105],b[105],h,flag;while(cin>>n>>m){memset(b,0,sizeof(b));for(int i=1;i<=n;i++){cin>>a[i];b[a[i]]=1;}int h=0;for(int i=1;i<=n;i++){if(b[a[i]]){int g;if(a[i]>m)g=1;elseg=-1;for(int k=m;k!=a[i];k+=g){if(b[k]==1){if(h==n-1)cout<<k<<endl;elsecout<<k<<" ";h++;b[k]=0;}}if(h==n-1)cout<<a[i]<<endl;elsecout<<a[i]<<" ";h++;b[a[i]]=0;}}}return 0;
}

Gym 101246(ACM ICPC 2010-2011, NEERC, Southern Subregional Contest Russia, Saratov)相关推荐

  1. 【*2000】【2018-2019 ICPC, NEERC, Southern Subregional Contest C 】Cloud Computing

    [链接] 我是链接,点我呀:) [题意] [题解] 我们可以很容易知道区间的每个位置有哪些安排可以用. 显然 我们优先用那些花费的钱比较少的租用cpu方案. 但一个方案可供租用的cpu有限. 我们可以 ...

  2. [CodeForces1070C]Cloud Computing(2018-2019 ICPC, NEERC, Southern Subregional Contest )

    传送门:戳我 在cf上做的镜像赛,结果不是很妙啊.. 这题是用时最长但并没有在比赛内写出来(事实上在赛后还话了大概五小时调试才找出错误) 首先不难发现我们需要一棵线段树,(其实一开始我考虑的是主席树) ...

  3. Codeforces 1070A Find a Number(BFS) 2018-2019 ICPC, NEERC, Southern Subregional Contest Problem A

    Description You are given two positive integers ddd and sss. Find minimal positive integer nnn which ...

  4. 2013-2014 ACM-ICPC, NEERC, Southern Subregional Contest Problem D. Grumpy Cat 交互题

    Problem D. Grumpy Cat 题目连接: http://www.codeforces.com/gym/100253 Description This problem is a littl ...

  5. 2013-2014 ACM-ICPC, NEERC, Southern Subregional Contest Problem C. Equivalent Cards 计算几何

    Problem C. Equivalent Cards 题目连接: http://www.codeforces.com/gym/100253 Description Jane is playing a ...

  6. 2013-2014 ACM-ICPC, NEERC, Southern Subregional Contest Problem I. Plugs and Sockets 费用流

    Problem I. Plugs and Sockets 题目连接: http://www.codeforces.com/gym/100253 Description The Berland Regi ...

  7. 2017-2018 ACM-ICPC, NEERC, Southern Subregional Contest

    A. Automatic Door 对于规律的点可以推公式计算,对于噪点则暴力计算,时间复杂度$O(m\log m)$. #include<stdio.h> #include<ios ...

  8. 《算法竞赛入门经典》 习题4-1(象棋 Xiangqi ACM ICPC Fuzhou 2011,UVa1589)——仅提供大体方法

    原题及翻译 Xiangqi is one of the most popular two-player board games in China. 象棋是中国最流行的两人棋类游戏之一. The gam ...

  9. 《算法竞赛入门经典》 习题 4-1 (Xiangqi, ACM/ICPC Fuzhou 2011, UVa1589,hdoj_4121)

    原题: [hdoj链接](http://acm.hdu.edu.cn/showproblem.php?pid=4121) Problem Description Xiangqi is one of t ...

  10. 象棋 (Xiangqi, ACM/ICPC Fuzhou 2011, UVa1589)

    Description Xiangqi is one of the most popular two-player board games in China. The game represents ...

最新文章

  1. Linux 终端下颜色的输出
  2. go标准命令详解0.1 go build
  3. Hadoop源代码分析(二)
  4. MySQL is running but PID file could not be found(在macOS系统下解决方法)
  5. XML和HTML的区别
  6. VSCode如何进入到终端中
  7. 化工企业数据分析中心项目之采购模块分析
  8. python--二叉树库函数
  9. python 多关键字排序_用Python排序字​​典
  10. win10固态硬盘分区 整数_固态硬盘先装系统还是先4k对齐?
  11. ANSYS网格划分标准及方法
  12. 2022道路运输企业安全生产管理人员复训题库及答案
  13. layui之动态树形菜单
  14. 2018级《程序设计基础(B)II》期末上机考试 重现--SDUT
  15. 改造汇文OPAC,使其通过萌校的通用扫码接口登录
  16. php的外文参考文献_php英文文献翻译及参考文献
  17. 2018 年物联网发展五大趋势预测
  18. cdr 表格自动填充文字_CDR小工具YG插件,从此提升工作效率!
  19. CF 1567 C. Carrying Conundrum(思维)
  20. 洛谷P4196 半平面交

热门文章

  1. Android开发学习之路III-服务器技术篇
  2. idea去掉拼写检查
  3. oracle chr(10)用法,chr(10) chr(13)
  4. 16万大奖,名企offer,翼支付杯大数据建模大赛邀你来战!
  5. Java 计算排列_java如何进行排列组合运算
  6. liuyubobobo:学习方法分享
  7. jscript php,JavaScript_JScript 运算符,JScript 运算符算术运算符- phpStudy
  8. Connection error with cocoapods. Proxy CONNECT abo
  9. python跳出双循环break图例
  10. 工厂模式与抽象工厂模式