提出 #3610561
ソースコード 拡げる
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
const int MAX = 2540;
const int N = 1e5;
vector<pair<int, int>> path[N];
map<int, int> cnt[N];
int main() {
ios::sync_with_stdio(false);
int n;
cin >> n;
int m;
cin >> m;
for (int i = 0; i < m; ++i) {
int a, b, l;
cin >> a >> b >> l;
--a;
--b;
path[a].emplace_back(l, b);
path[b].emplace_back(l, a);
++cnt[a][l];
++cnt[b][l];
}
long long res = 0;
for (int mid = 0; mid < n; ++mid) {
for (const auto &a_path : path[mid]) {
int len = a_path.first;
int u = a_path.second;
res += cnt[mid][MAX - len];
if (len + len == MAX) --res;
}
}
cout << res / 2 << '\n';
return 0;
}
提出情報
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 300 / 300 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| 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 |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 01.txt | AC | 78 ms | 20596 KiB |
| 02.txt | AC | 132 ms | 22784 KiB |
| 03.txt | AC | 30 ms | 9344 KiB |
| 04.txt | AC | 30 ms | 9344 KiB |
| 05.txt | AC | 145 ms | 29696 KiB |
| 06.txt | AC | 55 ms | 13056 KiB |
| 07.txt | AC | 49 ms | 19840 KiB |
| 08.txt | AC | 5 ms | 7296 KiB |
| 09.txt | AC | 31 ms | 10368 KiB |
| sample_01.txt | AC | 5 ms | 7296 KiB |
| sample_02.txt | AC | 5 ms | 7296 KiB |