003-algorithm-have circle-topology sort
来源:互联网 发布:杨幂睡小鲜肉知乎 编辑:程序博客网 时间:2024/06/07 06:15
#include<iostream>#include<vector>#include<map>using namespace std;bool have_circle(int a[], int m){vector<int> b(a, a+m*m);map<int, int> rudu;vector<int> stack; for (int i = 0; i < m; i++){int tmp(0);for (int j = 0; j < m; j++){tmp += a[i + j*m];}if (tmp == 0){stack.push_back(i);}else{rudu[i] = tmp;//rudu.insert(std::make_pair(i, tmp));//rudu.insert(std::pair<int, int>(i, tmp));//rudu.insert(map<int, int>::value_type(i, tmp));}}//forwhile (!stack.empty()){int x = *(stack.end() - 1);stack.pop_back();for (int i = 0; i < m; i++){if (b[x*m + i]--){rudu[i]--;if (rudu[i] == 0){stack.push_back(i);rudu.erase(i);}}//if}//for}//whileif (rudu.empty()){return 0;}else{return 1;}//cout << *(b.end() - 4) << endl;return 0;}int main(){int a[] = {0,1,0,0, 0,0,1,0, 1,0,0,0, 0,1,1,0};int m=4;cout << have_circle(a, m) << endl;;}
0 0
- 003-algorithm-have circle-topology sort
- sort algorithm
- sort algorithm
- Sort algorithm
- Sort Algorithm-->Bubble Sort
- Sort Algorithm-->Select Sort
- Bresenham's line and circle algorithm
- Sort algorithm overview.
- quick sort algorithm
- insert sort algorithm
- select sort algorithm
- Insertion sort algorithm
- Algorithm---Selection Sort
- Algorithm---Insert Sort
- ACM algorithm sort
- STL: <algorithm>中 sort()
- Csharp Algorithm - Bubble Sort
- CSharp Algorithm - Shell sort
- 详解jQuery的元素选择器
- C++ 神奇的头文件
- 软件测试
- JavaScript个人笔记:闭包及压栈
- 漫步线性代数十六——投影和最小二乘
- 003-algorithm-have circle-topology sort
- 机器学习资料
- BCB 中 Application->CreateForm 和 New 的一个区别
- POJ 1475 Pushing Boxes 嵌套BFS -
- Qt学习之五: 添加动作与资源文件
- 大数据IMF传奇行动绝密课程第54课:Spark性能优化第十季之Spark统一内存管理
- 1059. Prime Factors (25)
- Java数组运算
- Android简易实战教程--第二十七话《自定义View入门案例之开关按钮详细分析》