Language: C++

#include <bits/stdc++.h> using namespace std; typedef pair<int,int> PII; vector<pair<int , int> >::iterator it; int m; int shortestpath(vector<PII> adj[],int a,int b) { int mdistance[m]; bool visited[m]; priority_queue<PII, vector<PII>, greater<PII> >PQ; for(int i = 0 ; i < m ; i++) { mdistance[i] = INT_MAX; visited[i] = false; } PII p; PQ.push(make_pair(0,a)); mdistance[a] = 0; while(!PQ.empty()) { p = PQ.top(); PQ.pop(); int weight = p.first; a = p.second; visited[a] = true; if(a == b) break; if(mdistance[a] < weight) continue; for(it = adj[a].begin() ; it != adj[a].end() ; it++) { int d = it -> first; int w = it -> second; if(visited[d] == false && w + mdistance[a] < mdistance[d]) { mdistance[d] = w + mdistance[a]; PQ.push(make_pair(mdistance[d],d)); } } } return mdistance[b]; } int main() { int ans = 0; int n; cin >> m >> n; int arr[n][3]; vector<pair<int,int> > adj[m + 1]; int a , b , c; for(int i = 0 ; i < n ; i++) { cin >> a >> b >> c; adj[a - 1].push_back({b - 1, c});adj[b - 1].push_back({
	a -1,c
}); arr[i][0] = a; arr[i][1] = b; arr[i][2] = c; } for(int i = 0 ; i < n ; i++) { a = arr[i][0]; b = arr[i][1]; c = arr[i][2]; if(shortestpath(adj,a - 1,b - 1) != c) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; return 0; }


Compiler output:
a.cc:1:26: warning: extra tokens at end of #include directive
    1 | #include <bits/stdc++.h> using namespace std; typedef pair<int,int> PII; vector<pair<int , int> >::iterator it; int m; int shortestpath(vector<PII> adj[],int a,int b) { int mdistance[m]; bool visited[m]; priority_queue<PII, vector<PII>, greater<PII> >PQ; for(int i = 0 ; i < m ; i++) { mdistance[i] = INT_MAX; visited[i] = false; } PII p; PQ.push(make_pair(0,a)); mdistance[a] = 0; while(!PQ.empty()) { p = PQ.top(); PQ.pop(); int weight = p.first; a = p.second; visited[a] = true; if(a == b) break; if(mdistance[a] < weight) continue; for(it = adj[a].begin() ; it != adj[a].end() ; it++) { int d = it -> first; int w = it -> second; if(visited[d] == false && w + mdistance[a] < mdistance[d]) { mdistance[d] = w + mdistance[a]; PQ.push(make_pair(mdistance[d],d)); } } } return mdistance[b]; } int main() { int ans = 0; int n; cin >> m >> n; int arr[n][3]; vector<pair<int,int> > adj[m + 1]; int a , b , c; for(int i = 0 ; i < n ; i++) { cin >> a >> b >> c; adj[a - 1].push_back({b - 1, c});adj[b - 1].push_back({
      |                          ^~~~~
a.cc:1:2: error: 'a' does not name a type
    1 | #include <bits/stdc++.h> using namespace std; typedef pair<int,int> PII; vector<pair<int , int> >::iterator it; int m; int shortestpath(vector<PII> adj[],int a,int b) { int mdistance[m]; bool visited[m]; priority_queue<PII, vector<PII>, greater<PII> >PQ; for(int i = 0 ; i < m ; i++) { mdistance[i] = INT_MAX; visited[i] = false; } PII p; PQ.push(make_pair(0,a)); mdistance[a] = 0; while(!PQ.empty()) { p = PQ.top(); PQ.pop(); int weight = p.first; a = p.second; visited[a] = true; if(a == b) break; if(mdistance[a] < weight) continue; for(it = adj[a].begin() ; it != adj[a].end() ; it++) { int d = it -> first; int w = it -> second; if(visited[d] == false && w + mdistance[a] < mdistance[d]) { mdistance[d] = w + mdistance[a]; PQ.push(make_pair(mdistance[d],d)); } } } return mdistance[b]; } int main() { int ans = 0; int n; cin >> m >> n; int arr[n][3]; vector<pair<int,int> > adj[m + 1]; int a , b , c; for(int i = 0 ; i < n ; i++) { cin >> a >> b >> c; adj[a - 1].push_back({b - 1, c});adj[b - 1].push_back({
      |  ^
a.cc:2:8: error: expected declaration before '}' token
    2 |         a -1,c
      | ^       
a.cc:2:9: error: expected unqualified-id before ')' token
    2 |         a -1,c
      |         ^
a.cc:2:12: error: 'arr' does not name a type
    2 |         a -1,c
      |            ^~~
a.cc:2:27: error: 'arr' does not name a type
    2 |         a -1,c
      |                           ^  
a.cc:2:42: error: 'arr' does not name a type
    2 |         a -1,c
      |                                          ^  
a.cc:2:57: error: expected declaration before '}' token
    2 |         a -1,c
      |                                                         ^
a.cc:2:59: error: expected unqualified-id before 'for'
    2 |         a -1,c
      |                                                           ^  
a.cc:2:75: error: 'i' does not name a type
    2 |         a -1,c
      |                                                                           ^
a.cc:2:83: error: 'i' does not name a type
    2 |         a -1,c
      |                                                                                   ^
a.cc:2:212: error: 'cout' does not name a type
    2 |         a -1,c
      |                                                                                                                                                                                                                    ^   
a.cc:2:235: error: expected unqualified-id before 'return'
    2 |         a -1,c
      |                                                                                                                                                                                                                                           ^     
a.cc:2:245: error: expected declaration before '}' token
    2 |         a -1,c
      |                                                                                                                                                                                                                                                     ^