#include #include #include #include #include #include #include #include using namespace std; #define int long long #define endl "\n" constexpr long long INF = (long long)1e18; constexpr long long MOD = 1'000'000'007; struct fast_io { fast_io(){ std::cin.tie(nullptr); std::ios::sync_with_stdio(false); }; } fio; int N, M; vector> cost; struct Node{ int y, x, z, c; bool operator > (const Node &n) const { return c > n.c; } }; int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; int dijkstra(){ priority_queue, greater> Q; vector>> d(N, vector>(N, vector(2, INF))); Q.push({0, 0, 0, 0}); d[0][0][0] = 0; while(Q.size()){ Node cur = Q.top(); Q.pop(); // cout<= N || x < 0 || x >= N) continue; if(cur.z == 0) { if(cur.c + 1 < d[y][x][cur.z+1]) { d[y][x][cur.z+1] = cur.c + 1; Q.push({y, x, cur.z + 1, cur.c + 1}); } } // cout<<"i = "<"<<" y = "<>N>>M; cost.resize(N, vector(N)); for(int i = 0; i < M; i++){ int h, w, c; cin>>h>>w>>c; h--, w--; cost[h][w] = c; } cout<