Atcoder C - Closed Rooms(思维+bfs)】的更多相关文章

题目链接:http://agc014.contest.atcoder.jp/tasks/agc014_c 题意:略. 题解:第一遍bfs找到所有可以走的点并标记步数,看一下最少几步到达所有没锁的点,然后再 for一遍所有标记过的点之后就是考虑向上走向左走向右走向下走(直走). #include <iostream> #include <cstring> #include <cstdio> #include <queue> using namespace st…
#define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h>using namespace std;int col[207],s[207],n;char ss[207][207];int bfs(int x){ int l=0,r=0; for(int i=1;i<=n;i++) col[i]=0; s[++r]=x; col[x]=1; while(l<r){ x=s[++l]; for(int i=1;i<=n;i++) if(s…
传送门 D. Arthur and Walls time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output Finally it is a day when Arthur has enough money for buying an apartment. He found a great option close to the cente…
D. Vladik and Favorite Game time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output This is an interactive problem. Vladik has favorite game, in which he plays all his free time. Game field could…
我真是一只菜狗......emm... 题意: 判断一个从1开始的队列是否可以按照bfs的顺序 进行遍历..必须从1开始...然后后边依次是bfs顺序 解析: 看代码能看懂吧...emm...就是把每个有关系的用map标记一下 然后bfs的时候 加一个循环进队列就好了  emm../. #include <bits/stdc++.h> #define rap(i, a, n) for(int i=a; i<=n; i++) #define rep(i, a, n) for(int i=a…
Description 蓝色空间号和万有引力号进入了四维水洼,发现了四维物体--魔戒. 这里我们把飞船和魔戒都抽象为四维空间中的一个点,分别标为 "S" 和 "E".空间中可能存在障碍物,标为 "#",其他为可以通过的位置. 现在他们想要尽快到达魔戒进行探索,你能帮他们算出最小时间是最少吗?我们认为飞船每秒只能沿某个坐标轴方向移动一个单位,且不能越出四维空间. Input 输入数据有多组(数据组数不超过 30),到 EOF 结束. 每组输入 4…
题目链接:http://agc017.contest.atcoder.jp/tasks/agc017_e 题解:这题很巧妙运用了cnt[i]抽象的表示了上下互补的状态,最后上面突出的一定要处理完.下面突出的可以多.而且最后要处理一下下面多的情况不能自己左右互补具体看一下代码. #include <iostream> #include <cstring> #include <cmath> #include <cstdio> #include <vecto…
题目链接:http://agc016.contest.atcoder.jp/tasks/agc016_c 题解:挺简单的构造,很容易想到的构造方法就是(h*w)的小矩阵里其他值赋值为1,最后一个赋值为(h*w).这只是最基础的构造,然后 判断count - (H * W - count) * (h * w - 1)(count表示基础构造后正数的个数)是否大于0,如果大于0都可以构造,怎么构造就是将正的不断+1,负的不断-(h*w-1) 就行.如果小于等于0就要看初始的sum值(sum表示基础构…
题目链接:http://arc075.contest.atcoder.jp/tasks/arc075_d 题意:求rev(N)=N+D的个数,rev表示取反.例如rev(123)=321 题解:具体看一下代码,这题需要思考一下,虽然是简单的dfs但是不好想到. #include <iostream> #include <cstring> #include <cmath> using namespace std; typedef long long ll; ll Powe…
Code: #include <bits/stdc++.h> #define ll long long #define setIO(s) freopen(s".in","r",stdin) #define maxn 3002 using namespace std; queue<int>Q; vector<int>G[maxn]; int n,m,s1,t1,l1,s2,t2,l2; int vis[maxn],d[maxn][m…