Language: Java

/********************************************
 *Author*        :ZZZZone
 *Created Time*  : 一  2/ 5 11:22:16 2018
 * Ended  Time*  : 一  2/ 5 11:37:07 2018
*********************************************/

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <stack>
using namespace std;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

inline void OPEN(string s){
	freopen((s + ".in").c_str(), "r", stdin);
	freopen((s + ".out").c_str(), "w", stdout);
}

const int MaxN = 2000;
int pre[MaxN + 5], last[MaxN + 5], other[MaxN + 5], cost[MaxN + 5];
int a[MaxN + 5];
bool vis[MaxN + 5];
int n, m, all;
bool flag = true;

void build(int u, int v, int c){
	pre[++all] = last[u];
	last[u] = all;
	other[all] = v;
	cost[all] = c;
}

void dfs(int u, int sum){
	if(flag == false) return;
	if(vis[u] == false){
		vis[u] = true;
		a[u] = sum;
	}
	else{
		if(a[u] != sum) flag = false;
		return;
	}
	int ed = last[u];
	int dr, ned;
	while(ed != -1){
		dr = other[ed];
		ned = cost[ed];
		dfs(dr, sum + ned);
		ed = pre[ed];
	}
}


int main()
{
	memset(last, -1, sizeof(last)); all = -1;
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= m; i++){
		int u, v, c;
		scanf("%d %d %d", &u, &v, &c);
		build(u, v, c);
		build(v, u, -c);
	}
	for(int i = 1; i <= n; i++)
		if(vis[i] == false) dfs(i, i);
	if(flag == true) printf("Yes\n");
	else printf("No\n");
    return 0;
}


Compiler output:
Main.java:7: error: illegal character: '#'
#include <cstdio>
^
Main.java:8: error: illegal character: '#'
#include <cstring>
^
Main.java:9: error: illegal character: '#'
#include <iostream>
^
Main.java:10: error: illegal character: '#'
#include <algorithm>
^
Main.java:11: error: illegal character: '#'
#include <vector>
^
Main.java:12: error: illegal character: '#'
#include <queue>
^
Main.java:13: error: illegal character: '#'
#include <set>
^
Main.java:14: error: illegal character: '#'
#include <map>
^
Main.java:15: error: illegal character: '#'
#include <string>
^
Main.java:16: error: illegal character: '#'
#include <cmath>
^
Main.java:17: error: illegal character: '#'
#include <cstdlib>
^
Main.java:18: error: illegal character: '#'
#include <ctime>
^
Main.java:19: error: illegal character: '#'
#include <stack>
^
Main.java:21: error: class, interface, enum, or record expected
typedef pair<int, int> PII;
^
Main.java:22: error: class, interface, enum, or record expected
typedef long long LL;
^
Main.java:23: error: class, interface, enum, or record expected
typedef unsigned long long ULL;
^
Main.java:25: error: class, interface, enum, or record expected
inline void OPEN(string s){
^
Main.java:27: error: class, interface, enum, or record expected
	freopen((s + ".out").c_str(), "w", stdout);
	^
Main.java:28: error: class, interface, enum, or record expected
}
^
Main.java:31: error: class, interface, enum, or record expected
int pre[MaxN + 5], last[MaxN + 5], other[MaxN + 5], cost[MaxN + 5];
^
Main.java:32: error: class, interface, enum, or record expected
int a[MaxN + 5];
^
Main.java:33: error: class, interface, enum, or record expected
bool vis[MaxN + 5];
^
Main.java:34: error: class, interface, enum, or record expected
int n, m, all;
^
Main.java:35: error: unnamed classes are a preview feature and are disabled by default.
bool flag = true;
^
  (use --enable-preview to enable unnamed classes)
Main.java:68: error: illegal start of expression
	scanf("%d %d", &n, &m);
	               ^
Main.java:68: error: illegal start of expression
	scanf("%d %d", &n, &m);
	                   ^
Main.java:71: error: illegal start of expression
		scanf("%d %d %d", &u, &v, &c);
		                  ^
Main.java:71: error: illegal start of expression
		scanf("%d %d %d", &u, &v, &c);
		                      ^
Main.java:71: error: illegal start of expression
		scanf("%d %d %d", &u, &v, &c);
		                          ^
29 errors