Submission #128247

# Submission time Handle Problem Language Result Execution time Memory
128247 2019-07-10T15:01:42 Z zeyad49 Pipes (CEOI15_pipes) Java 11
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
const int N=5000;
int n;
int cnt[N][N];
bool visited[N];
	 void dfs(int u) {
		visited[u] = true;
		for (int v = 0; v < n; v++)
			if (cnt[u][v] > 0 && !visited[v])
				dfs(v);
	}
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(NULL);
    int m,u,v;
    cin>>n>>m;
		while (m-- > 0) {
		    cin>>u>>v;
		    u--;
		    v--;
			cnt[u][v]++;
			cnt[v][u]++;
		}
		for (int u = 0; u < n; u++)
			for (int v = u + 1; v < n; v++) {
				if (cnt[u][v] != 1)
					continue;
				cnt[u][v] = cnt[v][u] = 0;
				for(int i=0;i<n;i++)
				visited[i]=false;
				dfs(u);
				if (!visited[v])
					printf("%d %d\n", u + 1, v + 1);
 
				cnt[u][v] = cnt[v][u] = 1;
			}
 
}

Compilation message

pipes.java:1: error: illegal character: '#'
#include <bits/stdc++.h>
^
pipes.java:1: error: class, interface, or enum expected
#include <bits/stdc++.h>
         ^
pipes.java:3: error: class, interface, or enum expected
const int N=5000;
^
pipes.java:4: error: class, interface, or enum expected
int n;
^
pipes.java:5: error: class, interface, or enum expected
int cnt[N][N];
^
pipes.java:6: error: class, interface, or enum expected
bool visited[N];
^
pipes.java:7: error: class, interface, or enum expected
	 void dfs(int u) {
	 ^
pipes.java:9: error: class, interface, or enum expected
		for (int v = 0; v < n; v++)
		^
pipes.java:9: error: class, interface, or enum expected
		for (int v = 0; v < n; v++)
		                ^
pipes.java:9: error: class, interface, or enum expected
		for (int v = 0; v < n; v++)
		                       ^
pipes.java:12: error: class, interface, or enum expected
	}
	^
pipes.java:16: error: class, interface, or enum expected
    cin.tie(nullptr);
    ^
pipes.java:17: error: class, interface, or enum expected
    cout.tie(NULL);
    ^
pipes.java:18: error: class, interface, or enum expected
    int m,u,v;
    ^
pipes.java:19: error: class, interface, or enum expected
    cin>>n>>m;
    ^
pipes.java:20: error: class, interface, or enum expected
		while (m-- > 0) {
		^
pipes.java:22: error: class, interface, or enum expected
		    u--;
		    ^
pipes.java:23: error: class, interface, or enum expected
		    v--;
		    ^
pipes.java:24: error: class, interface, or enum expected
			cnt[u][v]++;
			^
pipes.java:25: error: class, interface, or enum expected
			cnt[v][u]++;
			^
pipes.java:26: error: class, interface, or enum expected
		}
		^
pipes.java:27: error: class, interface, or enum expected
		for (int u = 0; u < n; u++)
		                ^
pipes.java:27: error: class, interface, or enum expected
		for (int u = 0; u < n; u++)
		                       ^
pipes.java:28: error: class, interface, or enum expected
			for (int v = u + 1; v < n; v++) {
			                    ^
pipes.java:28: error: class, interface, or enum expected
			for (int v = u + 1; v < n; v++) {
			                           ^
pipes.java:31: error: class, interface, or enum expected
				cnt[u][v] = cnt[v][u] = 0;
				^
pipes.java:32: error: class, interface, or enum expected
				for(int i=0;i<n;i++)
				^
pipes.java:32: error: class, interface, or enum expected
				for(int i=0;i<n;i++)
				            ^
pipes.java:32: error: class, interface, or enum expected
				for(int i=0;i<n;i++)
				                ^
pipes.java:34: error: class, interface, or enum expected
				dfs(u);
				^
pipes.java:35: error: class, interface, or enum expected
				if (!visited[v])
				^
pipes.java:38: error: class, interface, or enum expected
				cnt[u][v] = cnt[v][u] = 1;
				^
pipes.java:39: error: class, interface, or enum expected
			}
			^
33 errors