Search is not available for this dataset
name stringlengths 2 112 | description stringlengths 29 13k | source int64 1 7 | difficulty int64 0 25 | solution stringlengths 7 983k | language stringclasses 4
values |
|---|---|---|---|---|---|
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | import java.util.*;
import java.io.*;
public class c104{
static List<Integer>[] adj;
static boolean []visited;
static int vertex;
static int pare;
static boolean cycle;
public static void dfs(int ind,int par)
{
visited[ind]=true;
for(int i=0;i<adj[ind].size();i++)
{
int j = adj[ind].get(i);
if(visite... | JAVA |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | import java.util.*;
/**
* Created by IntelliJ IDEA.
* User: piyushd
* Date: 3/26/11
* Time: 10:53 PM
* To change this template use File | Settings | File Templates.
*/
public class TaskC {
void run(){
int n = nextInt();
int m = nextInt();
boolean[][] g = new boolean[n][n];
f... | JAVA |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int maxN = 110;
int parent[maxN];
void build(int n) {
for (int i = 0; i <= n; i++) parent[i] = i;
}
int find(int n) {
if (parent[n] == n) return n;
return parent[n] = find(parent[n]);
}
void disjoint(int a, int b) {
int u = find(a);
int v = find(b);
parent... | CPP |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int n, m, flag;
long long val[105];
vector<int> gra[105];
int dfn[105], low[105], now;
void dfs(int s, int f) {
dfn[s] = low[s] = ++now;
for (int i = 0; i < gra[s].size(); i++) {
int e = gra[s][i];
if (e == f) continue;
if (dfn[e]) {
flag++;
} else... | CPP |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) { cout << "NEXT\n"; }
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << ", ";
err(++it, args...);
}
template <typename... T>
void rd(T&... args) {
((cin... | CPP |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | n, m = map(int, raw_input().split())
edges = [[0] * n for i in range(n)]
for i in xrange(m):
x, y = map(lambda a: int(a)-1, raw_input().split())
edges[x][y], edges[y][x] = 1, 1
visited = dict()
head = 0
loop_points = []
def f(start, nc, prev):
global head
#print start, nc , prev, visited, edges[start... | PYTHON |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
vector<int> E[1000];
int n, m, x, y, nedges[1001], solution, isam;
bool connected[101][101], is_vertice[1001];
void dfs(int node) {
isam++;
if (is_vertice[node]) solution++;
is_vertice[node] = 1;
for (int i = 0; i < nedges[node]; i++) {
if (!connected[node][E[no... | CPP |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 |
import java.util.Scanner;
public class Solution {
static int arr[][];
static int visited[];
static int vertices;
static int edges;
static int flag =0;
public static void dfs(int x,int parent)
{
if(visited[x]==1)
{
flag=1;
return;
}
visited[x]=1;
for(int i=0;i<=vertices;i++)
{
if(arr... | JAVA |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | import java.io.*;
import java.util.*;
public class Task103b{
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
PrintWriter out = new PrintWriter(outputStream);
... | JAVA |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | //package beta80;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Vector;
public class C
{
public static int n,m,mark[] , st;
public static boolean g[][];
public static Vector<Integer> v[], l;
public static void main(String[] args)
{
Scanner inp = new Scanner(System.in);
n = inp.nextInt(... | JAVA |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
void dfs(vector<int>* graph, int sv, bool* visited, int& count, int parent) {
visited[sv] = true;
for (int i = 0; i < graph[sv].size(); i++) {
int p = graph[sv][i];
if (!visited[p]) {
dfs(graph, p, visited, count, sv);
} else if (p != parent) {
c... | CPP |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> edges[108];
bool visited[108];
void dfs(int n) {
visited[n] = 1;
for (auto i : edges[n]) {
if (!visited[i]) dfs(i);
}
}
int main() {
scanf("%d%d", &n, &m);
if (n != m) {
puts("NO");
return 0;
}
for (int a, b, i = 1; i <= m; ++... | CPP |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | /*
Keep solving problems.
*/
import java.math.BigInteger;
import java.util.*;
import java.io.*;
public class CFA {
BufferedReader br;
PrintWriter out;
StringTokenizer st;
boolean eof;
private static final long MOD = 1000 * 1000 * 1000 + 7;
private static final int[] dx = {0, -1, 0, 1};
pri... | JAVA |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | import java.io.BufferedReader;
import java.io.IOError;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokeniz... | JAVA |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int n, m;
bool use[105];
vector<int> a[105];
queue<int> q;
void bfs() {
q.push(0);
while (!q.empty()) {
int p = q.front();
use[p] = 1;
q.pop();
for (int i = 0; i < a[p].size(); i++)
if (!use[a[p][i]]) q.push(a[p][i]);
}
}
int main() {
cin >> n ... | CPP |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | import sys
def read_values():
return map(int,raw_input().split())
n,m = read_values()
a = [[False]*n for _ in range(n)]
for _ in range(m):
u,v = read_values()
u-=1
v-=1
a[u][v] = True
a[v][u] = True
for k in range(n):
for i in range(n):
for j in range(n):
a[i][j] |= a[i][k] and a[k][j]
res = ... | PYTHON |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | import java.util.*;
public class cf103b {
static int n,k=0;
static int[] color;
static boolean[][] g;
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
n = in.nextInt();
int m = in.nextInt();
g = new boolean[n][n];
color = new int[n];
Arrays.fill(color,-1);
for(int i=0; i<... | JAVA |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | import java.io.*;
import java.util.*;
public class test
{
public static int n,m,f[];
public static int find(int x) { if (f[x] == x) return x; return f[x] = find(f[x]); }
public static void main(String[] args) throws Exception
{
Scanner read = new Scanner(System.in);
n = read.nextInt(); m = read.nextInt();
f... | JAVA |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | import java.io.*;
import java.util.*;
public class Main {
public static PrintWriter out;
public static ArrayList<Integer>[] adjList;
public static boolean[] visited;
public static int totalVisited = 0;
public static void main(String[] args) {
MyScanner sc = new MyScanner();
out = new PrintWriter(new ... | JAVA |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
bool used[105];
int i, n, m, x, y, k;
vector<vector<int> > g(105);
void dfs(int s) {
k++;
used[s] = true;
for (int i = 0; i < g[s].size(); i++)
if (!used[g[s][i]]) dfs(g[s][i]);
}
int main() {
cin >> n >> m;
for (i = 0; i < m; i++) {
cin >> x >> y;
g[x... | CPP |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int countReVisited = 0;
int visited[101];
void dfs(int prev, int n, vector<int> *graph) {
visited[n] = 1;
for (int i = 0; i < graph[n].size(); i++) {
int child = graph[n][i];
if (visited[child] && child != prev) {
countReVisited++;
continue;
} el... | CPP |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int N = 105;
int counter = 0;
int root[N];
int size[N];
int find(int u) {
if (u == root[u]) return u;
return root[u] = find(root[u]);
}
int main() {
int n, m, x, y;
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; i++) {
root[i] = i;
size[i] = 1;
}
... | CPP |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | read_line = lambda: [int(i) for i in input().split(' ')]
n, m = read_line()
g = [[] for i in range(n)]
for i in range(m):
a, b = [v - 1 for v in read_line()]
g[a].append(b)
g[b].append(a)
seen = [False] * n
def dfs(v):
if seen[v]:
return 0
seen[v], cnt = True, 1
for u in g[v]:
... | PYTHON3 |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class temp {
static ArrayList<Integer> graph[];
static int n;
static boolean visited[];
public s... | JAVA |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | n,m=map(int,input().split())
g=[[]for _ in range(n)]
for _ in range(m):
a,b=map(int,input().split())
g[a-1].append(b-1)
g[b-1].append(a-1)
v=[-1]*n
c=[-1,-1]
r=0
def dfs(x,p):
v[x]=p
global r,c
r+=1
for j in g[x]:
if v[j]==-1:
dfs(j,x)
elif v[x]!=j:
i... | PYTHON3 |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | //package codeforces;
/**
*
* @author flash36
*/
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.ArrayList;
public class Main {
int n;
ArrayList<Integer>[]G;
int[]cl;
int[]p;
int[]d;
boolean[]was;
int cycle_st, cycle_end;
FastScanner in = new FastScanner(System.in);
Prin... | JAVA |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 |
import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
if (n != m || n < 3){
System.out.println("NO");
return;
}
int[]... | JAVA |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> e[110];
int par[110];
int rk[110];
int _find(int a) {
if (a == par[a]) return a;
par[a] = _find(par[a]);
return par[a];
}
bool _merge(int a, int b) {
a = _find(a);
b = _find(b);
if (a == b) return false;
if (rk[a] > rk[b]) {
rk[b]++;
... | CPP |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | import java.util.*;
import java.io.*;
public class Solution {
public static void main (String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] temp=br.readLine().trim().split(" ");
int V=Integer.parseInt(temp[0]);
int E=Integer.parseInt(temp[1]);
... | JAVA |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 |
import java.util.*;
public class B
{
public static void main(String[] args)
{
new B(new FastScanner());
}
boolean[][] g;
boolean[] seen;
int N;
boolean isTree(int i, int p)
{
if (seen[i])
{
g[i][p] = false;
g[p][i] = false;
//System.out.printf("R... | JAVA |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | /*
Keep solving problems.
*/
import java.util.*;
import java.io.*;
public class CFA {
BufferedReader br;
PrintWriter out;
StringTokenizer st;
boolean eof;
private static final long MOD = 1000 * 1000 * 1000 + 7;
private static final int[] dx = {0, -1, 0, 1};
private static final int[] dy = ... | JAVA |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | import sys
import copy
n, m = map(int, sys.stdin.readline().split())
g = [[] for i in xrange(105)]
visited = [0 for i in xrange(105)]
prev = [-1 for i in xrange(105)]
cycles = 0
nvis = 0
for i in xrange(m):
a, b = map(int, sys.stdin.readline().split())
g[a].append(b)
g[b].append(a)
def dfs(u):
global... | PYTHON |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int n, m, cnt;
vector<int> e[105];
bool f[105];
void dfs(int x) {
f[x] = 1, ++cnt;
for (int i = 0; i < e[x].size(); ++i)
if (!f[e[x][i]]) dfs(e[x][i]);
}
void work() {
int i, x, y;
scanf("%d%d", &n, &m);
if (n != m) {
puts("NO");
return;
}
for (i =... | CPP |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int N = 100500;
vector<int> a[N];
bool was[N];
int kol;
void dfs(int v, int p = -1) {
was[v] = true;
for (auto to : a[v]) {
if (was[to] && p != to) {
kol++;
continue;
}
if (p != to) dfs(to, v);
}
}
int main() {
srand(time(NULL));
int ... | CPP |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #include <bits/stdc++.h>
int n;
char done[102];
char graph[102][102];
void dfs(int v, int n) {
int i;
done[v] = 'y';
for (i = 1; i <= n; i++)
if (graph[v][i]) {
if (done[i] == 'n') dfs(i, n);
graph[i][v] = graph[v][i] = 0;
}
}
int main() {
int i, m, a, b;
scanf("%d%d", &n, &m);
if (m == ... | CPP |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #Cthulhu
n , m = map(int,input().split())
lst = [[] for i in range(n +1)]
for i in range(m):
x , y = map(int, input().split())
lst[x].append(y)
lst[y].append(x)
#print(lst)
a = [0]*(n+1)
b = [0]*(n+1)
c = 0
def func(n):
global a, b, c, lst
a[n] = 1
for j in lst[n]:
if a[j] == 1 and b... | PYTHON3 |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double eps = 1e-8;
int mat[105][105];
int cnt;
int n, m;
bool err;
bool flag[105];
void dfs(int p, int prt) {
flag[p] = 1;
for (int i = 0; i <= n; ++i) {
if (i == prt) continue;
if (mat[p][i]) {
if (flag[i]) {
--... | CPP |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #!/usr/bin/env python3
n, m = map(int, input().rstrip().split())
adj = [[] for i in range(n+1)]
vis = [False for i in range(n+1)]
for i in range(m):
u, v = map(int, input().rstrip().split())
adj[u].append(v)
adj[v].append(u)
def dfs(cur):
cnt = 1
vis[cur] = True
for nxt in adj[cur]:
... | PYTHON3 |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;
public class Cthulhu {
static boolean[][] graph;
static boolean visited[];
static int prev[];
public static void bfs(... | JAVA |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int find(int parent[], int x) {
int c;
if (parent[x] == x) return x;
c = find(parent, parent[x]);
return c;
}
void set_union(int parent[], int rank[], int x, int y) {
int xp = find(parent, x);
int yp = find(parent, y);
if (xp == yp)
return;
else if (rank... | CPP |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | MAX = 101
parent = []
def makeSet():
global parent
parent = [i for i in range(MAX + 1)]
def findSet(u):
while u != parent[u]:
u = parent[u]
return u
def unionSet(u, v):
up = findSet(u)
vp = findSet(v)
parent[up] = vp
makeSet()
n, m = map(int, input().split())
for i in range(m):
... | PYTHON3 |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int n, m, a[100][100], v[100];
void flood(int s) {
v[s] = 1;
for (int t = 0; t < n; t++)
if (a[s][t] && !v[t]) flood(t);
}
int main() {
scanf("%d%d", &n, &m);
if (n != m) return puts("NO");
memset(v, 0, sizeof(v));
for (int i = 0; i < m; i++) {
int x, y;... | CPP |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | class Graph:
def __init__(self, n):
self.n = n
self.adj = [[] for i in range(n)]
def add(self, v, u):
self.adj[v].append(u)
self.adj[u].append(v)
n, m = map(int, input().split())
g = Graph(n)
for i in range(m):
v, u = map(int, input().split())
g.add(v - 1, u - 1)
flag1 ... | PYTHON3 |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int N = 200;
vector<int> adj[N];
int mark[N];
void dfs(int v) {
mark[v] = 1;
for (auto u : adj[v])
if (!mark[u]) dfs(u);
}
int main() {
int n, m;
cin >> n >> m;
for (int i = 0; i < m; i++) {
int u, v;
cin >> u >> v;
u--;
v--;
adj[u].p... | CPP |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | import java.io.* ;
import java.math.* ;
public class Main {
/**
* @param args
* @throws IOException
* @throws NumberFormatException
*/
private static int cycle = 0 ;
private static int n,m,value ;
private static int[] mark ;
private static int[][] a ;
private static void DFS1( int ... | JAVA |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | __author__ = 'yaroslavnazarov'
# -*- coding: utf-8 -*-
def getLoop(arcs, path):
loop = []
path_len = len(path)
current_elem = path[path_len-1]
if path_len > 1:
previous_elem = path[path_len-2]
else:
previous_elem = None
for i in range(0,len(arcs)):
if arcs[i][0] == cu... | PYTHON |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | from sys import stdin,stdout,setrecursionlimit
setrecursionlimit(10**4)
from collections import defaultdict
nmbr = lambda: int(stdin.readline())
lst = lambda: list(map(int,stdin.readline().split()))
def dfs(src,par):
global remu,remv
vis[src]=1
for neigh in g[src]:
if vis[neigh] or neigh==par:contin... | PYTHON3 |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #!/usr/bin/python3
# B - Cthulhu
import sys
def dfs(curvertex):
visited[curvertex] = 1
for v in adjlist[curvertex]:
if visited[v] == 0:
dfs(v)
n, m = [int(x) for x in input().split()]
if n != m:
print("NO")
sys.exit()
adjlist = [[] for x in range(n)]
visited = [0]*n
for i in range(m):
x, y = [int(x) for x... | PYTHON3 |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const double PI = 3.141592653589793238463;
const int INF = 0x3f3f3f3f;
const int INFS = 1000000000;
const long long LLINF = 9223372036854775807;
const int M = 1000000... | CPP |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
vector<int> adj[105];
bool visited[105];
int df[1005];
int ans = 0, k = 0;
void dfs(int i, int parent) {
visited[i] = true;
for (int j = 0; j < adj[i].size(); j++) {
if (!visited[adj[i][j]]) dfs(adj[i][j], i);
}
}
int main() {
int n, m;
cin >> n >> m;
for (i... | CPP |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
class TaskC {
public:
int n, m;
vector<vector<int> > v;
vector<int> vis;
void dfs(int u) {
if (vis[u] == 1) return;
vis[u] = 1;
for (int i = 0; i < v[u].size(); ++i) dfs(v[u][i]);
}
void solve(istream& in, ostream& out) {
string ans[] = {"NO", "... | CPP |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int N = 110;
bool i[N];
vector<int> a[N];
int bi;
void t(int s) {
bi++;
i[s] = 1;
for (int e : a[s]) {
if (!i[e]) t(e);
}
}
int main() {
int i, j, k, n, m, u, v;
cin >> n >> m;
for (i = 0; i < m; i++) {
cin >> u >> v;
a[u].push_back(v);
a... | CPP |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | import java.util.ArrayList;
import java.util.Scanner;
import javax.xml.soap.SAAJResult;
public class Cthulhu {
static ArrayList<Integer>[]graph;
static boolean visited[];
public static void dfs(int node)
{
visited[node]=true;
for (int i = 0; i < graph[node].size(); i++) {
... | JAVA |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int edge[105][105], k = 0, n, m;
bool mark[105];
void dfs(int rt) {
if (mark[rt]) return;
mark[rt] = 1;
k++;
for (int i = 1; i <= n; ++i)
if (edge[rt][i] && !mark[i]) dfs(i);
}
int main() {
scanf("%d%d", &n, &m);
memset(edge, 0, sizeof(edge));
for (int i =... | CPP |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | import java.util.Scanner;
public class Cthulhu {
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
// int t = sc.nextInt();
// for(int tc=0;tc<t;tc++)
// {
int n = sc.nextInt();
int m = sc.nextInt();
int a[][] = new int[n][n];
for(int i=0;i<m;i++)
{
int from = s... | JAVA |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000 * 1000 * 1000 + 7;
const double PI = 3.14159265358979323846264;
const pair<long long int, long long int> steps[] = {
{1, 0}, {0, 1}, {-1, 0}, {0, -1}, {1, -1}, {1, 1}, {-1, -1}, {-1, 1}};
template <typename... T>
void read(T&... args) {
... | CPP |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int f[1005];
int Find(int x) { return f[x] == x ? x : f[x] = Find(f[x]); }
int main() {
int n, m;
scanf("%d", &n), scanf("%d", &m);
for (int i = 1; i <= n; i++) f[i] = i;
int num = 0;
for (int i = 1; i <= m; i++) {
int x, y;
scanf("%d", &x), scanf("%d", &y... | CPP |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | import java.io.*;
import java.math.*;
import java.util.*;
public class B80_div2 {
static boolean test = false;
private void solve() throws Throwable, IOException {
int n = iread(), m = iread();
boolean[][] edge = new boolean[n][n];
for (int i = 0; i < m; i++) {
int a = iread()- 1, b = iread()- 1;
ed... | JAVA |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #include <bits/stdc++.h>
int N, M, cnt;
bool w[101][101], v[101];
void dfs(int n) {
int i;
v[n] = 1;
cnt++;
for (i = 1; i <= N; i++)
if (w[n][i] && !v[i]) dfs(i);
}
int main() {
int i, j, k;
scanf("%d%d", &N, &M);
if (N != M) {
puts("NO");
return 0;
}
for (i = 1; i <= M; i++) {
scanf("... | CPP |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | def dfs(v):
global g, marked
marked[v] = True
for nv in g[v]:
if not marked[nv]:
dfs(nv)
n, m = map(int, input().split())
if (n != m):
print("NO")
else:
g = [[] for _ in range(n)]
for i in range(m):
a, b = map(int, input().split())
g[a-1].append(b-1)
g... | PYTHON3 |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Cthulhu {
public static void main(String[] args) throws NumberFormatException, IOException {
// TODO Auto-generated method stub
BufferedReader r=new BufferedReader(new InputStreamReader(S... | JAVA |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int i, j, k, n, m, r, flag;
int f[110], g[110], h[110];
vector<int> a[110], gen;
void dfs(int x, int y) {
if (flag) return;
int i;
f[x] = 1;
g[++r] = x;
for (i = 0; i < a[x].size(); i++) {
int A = a[x][i];
if (A == y) continue;
if (f[A]) {
for (;... | CPP |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | import java.util.Scanner;
public class Main {
static int garb[], unioned[];
public static void main(String [] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt(), m = scan.nextInt();
DSU dsu = new DSU(n);
garb = new int[n];
unioned = new int[n];
String out = "NO";
for(int i = 0; i... | JAVA |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | def find(node):
while p[node] != node:
p[node] = p[p[node]]
node = p[node]
return node
def union(n1,n2):
a1 = find(n1)
a2 = find(n2)
if a1 != a2: p[a1] = a2
n,m = map(int,input().split())
p = [i for i in range(n+1)]
cnt = 0
for _ in range(m):
a,b = map(int,input().split())
... | PYTHON3 |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | parent = dict()
ranks = dict()
def make_set(N):
global parent, ranks
parent = [i for i in range(N + 5)]
ranks = [0 for i in range(N + 5)]
def find_set(u):
if parent[u] != u:
parent[u] = find_set(parent[u])
return parent[u]
def union_set(u, v):
up = find_set(u)
vp = find_set(v)
... | PYTHON3 |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | import java.util.*;
import java.io.*;
public class Main {
static class Scan {
private byte[] buf=new byte[1024];
private int index;
private InputStream in;
private int total;
public Scan()
{
in=System.in;
}
public int scan()throws IOExcepti... | JAVA |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | n, m = map(int, input().split())
t = [[] for i in range(n + 1)]
for i in range(m):
a, b = map(int, input().split())
t[a].append(b)
t[b].append(a)
q, p, s = [0] * (n + 1), [0] * (n + 1), 0
def dfs(a):
global q, p, s, t
q[a] = 1
for b in t[a]:
if q[b] == 1 and p[a] != b: s += 1
... | PYTHON3 |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | import java.util.*;
import java.io.*;
import java.math.*;
import static java.lang.Math.*;
import static java.math.BigInteger.*;
public class Task {
public static void main(String[] args) throws IOException {
//br = new BufferedReader(new FileReader("input.txt"));
br = new BufferedReader(new InputStreamReader(Syst... | JAVA |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #include <bits/stdc++.h>
const int maxn = 100;
int dsu[maxn], rank[maxn];
int get(int x) { return x == dsu[x] ? x : dsu[x] = get(dsu[x]); }
void unite(int x, int y) {
x = get(x), y = get(y);
if (rank[x] == rank[y]) rank[x]++;
if (rank[x] > rank[y])
dsu[y] = x;
else
dsu[x] = y;
}
int main() {
int n, m,... | CPP |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | import java.lang.reflect.Array;
import java.util.Scanner;
import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;
import static java.lang.Math.*;
public class main implements Runnable {
static ArrayList<Integer> adj[];
static void Check2(int n) {
adj = new ArrayList[n + 1];
... | JAVA |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
vector<vector<int>> path(1000);
bool visited[1000];
void dfs(int nod) {
visited[nod] = true;
for (int i = 0; i < path[nod].size(); i++) {
if (!visited[path[nod][i]]) dfs(path[nod][i]);
}
}
int main(int argc, const char* argv[]) {
int n, m, cont = 0;
cin >> n >... | CPP |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | def BFS(vertices,aristas,s):
U=[s] #nodos visitados
F=[] #aristas de solución
Aux=[]
for e in aristas: #agregamos aristas incidentes de s
if e[0]==s:
Aux=Aux+[e]
elif e[1]==s:
Aux=Aux+[e]
#print("Aux es ",Aux)
while Aux!=[]:
u=Aux.pop(0) #extr... | PYTHON3 |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
bool go[105];
int cnt;
int n, m;
vector<int> road[105];
void rf(int x, int p, int dep) {
if (go[x]) {
cnt++;
return;
}
go[x] = 1;
for (int i = 0; i < road[x].size(); i++) {
if (road[x][i] != p) rf(road[x][i], x, dep + 1);
}
}
int main() {
cin >> n >>... | CPP |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
vector<long long> v, si;
int roo(int i) { return i == v[i] ? i : v[i] = roo(v[i]); }
void w_union(int _a, int _b) {
int a = roo(_a);
int b = roo(_b);
if (a == b) return;
if (si[a] < si[b]) {
v[a] = v[b];
si[b] += si[a];
} else {
v[b] = v[a];
si[a] ... | CPP |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 |
import java.util.Scanner;
public class Solution {
static int arr[][];
static int visited[];
static int vertices;
static int edges;
static int flag =0;
public static void dfs(int x,int parent)
{
if(visited[x]==1)
{
flag=1;
return;
}
visited[x]=1;
for(int i=0;i<=vertices;i++)
{
if(arr[... | JAVA |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | import java.util.Scanner;
public class Task80C {
public static void dfs(int v, boolean[][] match, boolean[] visited) {
visited[v] = true;
for (int i = 0; i < visited.length; i++) {
if (match[v][i] && !visited[i]) {
dfs(i, match, visited);
}
}
}
... | JAVA |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
vector<int> vc[N];
int a, b;
int mark[N];
void DFS(int x) {
mark[x] = 1;
for (int i = 0; i < vc[x].size(); i++)
if (!mark[vc[x][i]]) DFS(vc[x][i]);
}
int main(int argc, const char* argv[]) {
ios_base::sync_with_stdio(false);
int n, m;
cin >>... | CPP |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 |
import java.util.Scanner;
public class Summer {
public static class node {
public int parent;
public int me;
public node(int x, int y) {
parent = x;
me = y;
}
}
public static node[] A;
public static int cycle = 0;
public static void main... | JAVA |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | import java.io.*;
import java.util.LinkedList;
import java.util.Queue;
import java.awt.*;
public class round103B {
static int N;
static boolean [][] graph;
static boolean [] vis;
public static int countCycles(){
vis = new boolean [N];
Queue<Point> dfs = new LinkedList<Point>();
... | JAVA |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | N, M = map(int, input().split())
g = [[] for i in range(N)]
for i in range(M):
a, b = map(int, input().split())
g[a-1].append(b-1)
g[b-1].append(a-1)
visited = [0] * N
def dfs(n):
global visn
visited[n] = 1
for i in g[n]:
if not visited[i]:
dfs(i)
if N != M:
print("NO... | PYTHON3 |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #include <bits/stdc++.h>
int arr[1000][1000] = {0};
int visited[1000] = {0};
int last[100] = {0};
int dfs(int i) {
int j;
if (visited[i] == 1) {
for (j = 0; j < last[i]; j++) {
if (visited[arr[i][j]] == 0) {
visited[arr[i][j]] = 1;
dfs(arr[i][j]);
}
}
} else {
return 0;
}... | CPP |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | def find_parent(i):
if parent[i] != parent[parent[i]]:
parent[i] = find_parent(parent[i])
return parent[i]
n, m = map(int, raw_input().split())
parent = range(n)
size = [1] * n
group_count = n
loop = 0
for i in xrange(m):
a, b = map(lambda x: int(x) - 1, raw_input().split())
parent_a = find_... | PYTHON |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 110;
vector<int> g[MAXN];
int inCycle;
int cycleHead;
vector<int> cycle;
bool isIn[MAXN];
bool mark[MAXN];
int nodeCount;
void dfs0(int u) {
mark[u] = true;
nodeCount++;
for (int i = 0; i < g[u].size(); i++) {
int v = g[u][i];
if (!mark[v]) df... | CPP |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int n, m;
vector<vector<int> > v;
bitset<103> visited;
void dfs(int x) {
visited[x] = 1;
for (int u : v[x])
if (!visited[u]) dfs(u);
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
if (n != m) {
cout << "NO";
re... | CPP |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int mark[10000];
vector<int> adj[10000];
void dfs(int pos) {
if (mark[pos] == 1)
return;
else {
mark[pos] = 1;
for (int i = 0; i < adj[pos].size(); i++) dfs(adj[pos][i]);
}
}
int main() {
memset(mark, -1, sizeof mark);
int m, n;
cin >> m >> n;
for ... | CPP |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | import java.io.*;
import java.util.*;
public class Main2 {
static class Main {
Main() {}
public Scanner sc;
static final int MAX_N = 101;
int[] parent = new int[MAX_N];
int[] rank = new int[MAX_N];
void uf_init(int n) {
for (int i = 0; ... | JAVA |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | /* The main idea is that graph should be connected and should contain only one cycle.
if it contains one cycle then m=n
*/
import java.util.*;
import java.io.*;
public class pt{
static void dfs(LinkedList<Integer> l[],int s,boolean v[]){
v[s]=true;
for(I... | JAVA |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 |
import java.io.*;
import java.util.*;
public class Template implements Runnable {
int[][] g;
int cycle = 0;
int[] p;
private void dfs(int s, int a) {
for (int i = 0; i < g[a].length; i++) {
if (g[a][i] == 1 && s != i) {
if (p[i] == 0) {
p[i] = ... | JAVA |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | /* / フフ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ム
/ )\⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ Y
(⠀⠀| ( ͡° ͜ʖ ͡°)⠀⌒(⠀ ノ
(⠀ ノ⌒ Y ⌒ヽ-く __/
| _⠀。ノ| ノ。 |/
(⠀ー '_人`ー ノ
⠀|\  ̄ _人'彡ノ
⠀ )\⠀⠀ 。⠀⠀ /
⠀⠀(\⠀ #⠀ /
⠀/⠀⠀⠀/ὣ====================D-
/⠀⠀⠀/⠀ \ \⠀⠀\
( (⠀)⠀⠀⠀⠀ ) ).⠀)
(⠀⠀)⠀⠀⠀⠀⠀( | /
|⠀ /⠀⠀⠀⠀⠀⠀ | /
[_] ⠀⠀⠀⠀⠀[___] */
// Main Code at th... | JAVA |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 |
inp = input().split()
n = int(inp[0])
m = int(inp[1])
def dfs(x):
visited.add(x)
for y in e[x]:
if not y in visited:
dfs(y)
if n >= 3 and n == m:
visited = set()
e = [[] for i in range(n + 1)]
for i in range(m):
x, y = map(int, input().split())
... | PYTHON3 |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | /**
* Created by IntelliJ IDEA.
* User: Taras_Brzezinsky
* Date: 8/7/11
* Time: 2:21 PM
* To change this template use File | Settings | File Templates.
*/
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.FileRe... | JAVA |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int n , m;
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
m = sc.nextInt();
DisjointSet ds = new DisjointSet(n);
ds.initialize();
for(int i = 0; i < m; i++){
int start = sc.nextInt();
int end = ... | JAVA |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> adj[107];
bool mark[107];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for (int i = 1; i <= m; ++i) {
int u, v;
cin >> u >> v;
adj[u].push_back(v);
adj[v].push_back(u);
}
int nLoop = 0;
queue<int> q;
... | CPP |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 28;
int N;
vector<vector<int> > g;
bool used[100][100];
bool visited[100];
bool check(const vector<int> &route) {
memset(used, false, sizeof(used));
memset(visited, false, sizeof(visited));
for (int i = 0; i < (int)(route.size()); i++) {
int j... | CPP |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | #include <bits/stdc++.h>
using namespace std;
int n;
vector<int> adj[100010];
bool visited[100010];
void visit(int u) {
visited[u] = true;
for (int i = 0; i < adj[u].size(); i++)
if (!visited[adj[u][i]]) visit(adj[u][i]);
}
int main() {
int m, u, v;
scanf("%d %d", &n, &m);
for (int i = 0; i < m; i++) {
... | CPP |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 |
import java.util.*;
import java.io.*;
public class Main implements Runnable {
boolean[][] edges;
int n;
boolean[] was;
public void solve() throws IOException {
n = nextInt();
int m = nextInt();
if (m != n) {//absence of simple cycle....
System.out.println("NO");
... | JAVA |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | def findSet(u):
while u != parent[u]:
u = parent[u]
return u
def unionSet(u, v):
up = findSet(u)
vp = findSet(v)
parent[up] = vp
if __name__ == '__main__':
n, m = map(int, input().split())
if n != m:
print('NO')
else:
parent = [i for i in range(n + 1)]
f... | PYTHON3 |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | import java.util.*;
import java.math.*;
import java.io.*;
public class Codeforcescodes {
/**
* @param args the command line arguments
*/
static int mod = 1000 * 1000 * 1000 + 7;
static boolean[] mark = new boolean[10005];
static ArrayList<Integer> g[];
static void dfs(int node )
{
... | JAVA |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | import java.util.*;
public class solution{
static Map<Integer,List<Integer>> graph=new HashMap<>();
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int e=sc.nextInt();
if(n!=e){
System.out.println("NO");
}
... | JAVA |
103_B. Cthulhu | ...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu...
Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super... | 2 | 8 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class Cthulhu {
private static void dfs(boolean vis[], Vector<Integer>[] graph, int index) {
vis[index] = true;
if (graph[index] != null)
for (int i = 0; i < graph... | JAVA |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.