about summary refs log tree commit diff
path: root/usth/MATH2.3/2/incidentmat2edges.cc
blob: 2fe5d79f21dbb00cc58e7120bf9aaec7904c4189 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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;
}