Submission #5565976


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  map<int, map<int, int>> m;
  int N, M;
  cin >> N >> M;
  vector<map<int, int>> v(N);
  for (int i = 0; i < M; i++) {
    int A, B, L;
    cin >> A >> B >> L;
    m[A][L]++;
    m[B][L]++;
    v[A - 1][L]++;
    v[B - 1][L]++;
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (auto j = v[i].begin(); j != v[i].end(); j++) {
      int l = j -> first;
      int t1 = j -> second;
      int t2 = v[i][2540 - l];
      if (l == 1270) t1--;
      ans += t1 * t2;
    }
  }
  ans /= 2;
  cout << ans << "\n";
  return 0;
}

Submission Info

Submission Time
Task A - 2540
User yamakasa
Language C++14 (GCC 5.4.1)
Score 300
Code Size 689 Byte
Status AC
Exec Time 220 ms
Memory 42368 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 11
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
01.txt AC 133 ms 28544 KB
02.txt AC 187 ms 21504 KB
03.txt AC 33 ms 384 KB
04.txt AC 33 ms 384 KB
05.txt AC 220 ms 42368 KB
06.txt AC 93 ms 12288 KB
07.txt AC 100 ms 28416 KB
08.txt AC 1 ms 256 KB
09.txt AC 35 ms 384 KB
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB