about summary refs log tree commit diff
path: root/usth/MATH2.3/2/incidentmat2edges.cc
diff options
context:
space:
mode:
Diffstat (limited to 'usth/MATH2.3/2/incidentmat2edges.cc')
-rw-r--r--usth/MATH2.3/2/incidentmat2edges.cc33
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;
+}