diff options
author | Nguyễn Gia Phong <vn.mcsinyx@gmail.com> | 2020-01-14 18:29:11 +0700 |
---|---|---|
committer | Nguyễn Gia Phong <vn.mcsinyx@gmail.com> | 2020-01-14 18:29:11 +0700 |
commit | a3dd2581ed4847670f81157091016c14ca18803d (patch) | |
tree | 3362ab15de119f1e75799f58715b7683e6bfd6ca /usth/MATH2.3/2/incidentmat2edges.cc | |
parent | 65b8ebda4c47fa27ac28899fb2b29097f445b6df (diff) | |
download | cp-a3dd2581ed4847670f81157091016c14ca18803d.tar.gz |
[usth/MATH2.3] Mathemate Discretely
Diffstat (limited to 'usth/MATH2.3/2/incidentmat2edges.cc')
-rw-r--r-- | usth/MATH2.3/2/incidentmat2edges.cc | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/usth/MATH2.3/2/incidentmat2edges.cc b/usth/MATH2.3/2/incidentmat2edges.cc new file mode 100644 index 0000000..2fe5d79 --- /dev/null +++ b/usth/MATH2.3/2/incidentmat2edges.cc @@ -0,0 +1,33 @@ +#include <iostream> +#include <map> +#include <utility> + +using namespace std; + +int +main () +{ + int v, e, b; + map<pair<int, int>, int> m; + + cin >> v >> e; + for (int i = 0; i < v; ++i) + { + pair<int, int> p {-1, -1}; + + for (int j = 0; j < e; ++j) + { + cin >> b; + if (!b) + continue; + if (p.first < 0) + p.first = p.second = j; + else + p.second = j; + } + m[p]++; + } + + for (auto const& [p, c] : m) + cout << p.first << " " << p.second << " " << c << endl; +} |