Sicily 1155. Can I Post the lette
2014-10-20 18:25
507 查看
// 从起点开始DFS会TLE。逆向思维:从终点开始,AC #include <iostream> #include <cstring> using namespace std; bool r[202][202]; int n, m; bool flag; void find(int dst) { if (!dst) { flag = true; return; } for (int i = 0; i < n; i++) { if (flag) break; if (r[i][dst]) find(i); } } int main(int argc, char **argv) { while (cin >> n && n) { flag = false; memset(r, false, sizeof(r)); cin >> m; int from, to; for (int i = 0; i < m; i++) { cin >> from >> to; r[from][to] = true; } find(n - 1); if (flag) cout << "I can post the letter" << endl; else cout << "I can't post the letter" << endl; } return 0; }
相关文章推荐
- sicily 1155. Can I Post the lette
- [sicily online]1155. Can I Post the lette(图的深度优先搜索)
- sicily 1155. Can I Post the lette
- sicily 1155. Can I Post the lette
- Sicily 1155. Can I Post the lette
- 算法学习【12】—— 1155. Can I Post the lette
- sicily 1155 Can I Post the letter
- sicily:1155.Can I Post the letter
- Sicily 1155 Can I Post the letter (图的遍历 BFS)
- 1155. Can I Post the lette
- Sicily 1155. Can I Post the letter
- 1155. Can I Post the letter(有向图遍历判断两点是否可到达)
- <OJ_Sicily>Can I Post the letter
- Can I Post the lette
- finally I find the problem why my phone cant post before
- 1155. Can I Post the lette
- 1155. Can I Post the lette
- Can not find the tag library descriptor for “http://java.sun.com/jsp/jstl/core” 解决方法
- cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element
- tomcat server for the webapp can be custom defined.