my code is only 0 pts , who can help me?
查看原帖
my code is only 0 pts , who can help me?
1001535
封禁用户楼主2024/8/28 17:27

code:

#include <bits/stdc++.h>
using namespace std;
#define int long long
int n, m;
int g;
int ans;
int u[1000001], v[1000001], w[1000001];
map<int , map < int , map <int , int>>> mp;
signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= m; i++) {
		cin >> u[i] >> v[i] >> w[i];
	    mp[u[i]][v[i]][w[i]] = 1;
	}
	for (int  i = 1; i <= m; i ++) {
	    int a = u[i] , b = v[i] , c = w[i];
	    for(auto [d , count_d] : mp[a][b])
	    {
			if(c < d && d <= n && mp[a][c].count(d) && mp[b][c].count(d))
			{
				ans += mp[a][b][c] * mp[a][c][d] * mp[b][c][d];
//				cout << a << " " << b << " " << c << " "<<  d << endl;
			}
		}
	}
	cout << ans;
	return 0;
}

时间复杂度错了,还是?

2024/8/28 17:27
加载中...