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 sys
import queue
sys.setrecursionlimit(100000)
# global constant
INF = int(1e7+1)
MAX = 100005
# For testing
#sys.stdin = open("INP.txt", 'r')
#sys.stdout = open("OUT.txt", 'w')
# global variables
parents = []
ranks = []
size = []
n = 0
# classes
class Pair:
def __init__(self, a, b):
self.first... | 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;
long long visited[100010];
vector<long long> g[100010];
void dfs(long long u) {
visited[u] = true;
for (auto x : g[u]) {
if (!visited[x]) {
dfs(x);
}
}
}
void solve() {
long long n, m;
cin >> n >> m;
for (long long i = 0; i < m; ++i) {
long lon... | 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.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.function.BiFunction;
public class Graph {
static Scanner sc = new Scanner(System.in);
static PrintWri... | 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 connected[100];
void dfs(const vector<vector<int>>& a, int node) {
connected[node] = true;
for (int child : a[node]) {
if (connected[child] == false) {
dfs(a, child);
}
}
}
int main() {
memset(connected, false, sizeof(connected));
int n, m, a, 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 sys
import copy
n, m = map(int, sys.stdin.readline().split())
g = [[] for i in xrange(105)]
visited = [0 for i in xrange(105)]
path = [1]
for i in xrange(m):
a, b = map(int, sys.stdin.readline().split())
g[a].append(b)
g[b].append(a)
cycles = 0
def dfs():
global path
u = path[len(path)-1]... | 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.io.*;
import java.util.*;
public class A implements Runnable {
private static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
private BufferedReader in;
private PrintWriter out;
private StringTokenizer tok = new StringTokenizer("");
private void init() throws... | 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 solve():
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
edges = []
link = [i for i in range(n+1)]
size = [1 for _ in range(n+1)]
def find_link(x):
while x != link[x]:
x = link[x]
return x
def same(x, y):
return find_link(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 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
def rd(): return map(int, raw_input().split())
n, m = rd()
g = [[] for _ in xrange(n)]
for _ in xrange(m):
x, y = rd()
g[x-1].append(y-1)
g[y-1].append(x-1)
color = [0]*n
used = [False]*n
parent = [None]*n
cc = []
def dfs(x):
used[x] = True
color[x] ... | 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<long long> arr[101];
long long vis[101];
void dfs(long long node) {
vis[node] = 1;
for (auto x : arr[node]) {
if (vis[x]) continue;
dfs(x);
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
long long n, m;
cin >> n >> m;
long long u, ... | 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 bool testcase = 0;
const long long int mod1 = 1000000007;
const long long int mod2 = 998244353;
const long long int N = 1e5 + 5;
std::vector<long long int> adj[N];
std::vector<long long int> vis(N, false);
bool hasLoop(long long int i, long long int p) {
vis[i] = tr... | 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;
long long power(long long x, unsigned long long y) {
long long temp;
if (y == 0) return 1;
temp = power(x, y / 2);
if (y % 2 == 0)
return temp * temp;
else
return x * temp * temp;
}
long long modpow(long long x, unsigned int y, long long p) {
long long r... | 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.LinkedList;
import java.util.Scanner;
/**
* Created with IntelliJ IDEA.
* Author : Dylan
* Date : 2013-08-03
* Time : 13:56
* Project : Cthulhu
*/
public class Main {
static LinkedList<Integer>[] graph;
static boolean[] visited;
public static void main(String[] args) {
... | 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.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class B103_Cthulhu {
static int n;
static boolean[] vis, adjMatrix[];
static void dfs(int node) {
vis[node] = true;
for (int i = 0; i < n; i++)
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 | /** https://codeforces.com/problemset/problem/103/B
* idea: DSU
*/
import java.util.Scanner;
public class Cthulhu {
public static void makeSet(int[] parent, int[] size) {
int sz = parent.length;
for (int i=0; i < sz; i++) {
parent[i] = i;
size[i] = 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.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 | r=lambda:map(int,raw_input().split())
n,m=r()
g=[[] for i in range(n+1)]
for i in range(m):
a,b=r()
g[a]+=[b]
g[b]+=[a]
v=set()
def d(i):
if i in v: return
v.add(i)
for j in g[i]:
d(j)
d(1)
if len(v) ==n==m: print "FHTAGN!"
else: print "NO" | 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;
bool use[105];
vector<int> a[105];
void dfs(int f) {
use[f] = 1;
for (int i = 0; i < a[f].size(); i++)
if (!use[a[f][i]]) dfs(a[f][i]);
}
int main() {
cin >> n >> m;
int i, j, x, y;
if (n != m) {
cout << "NO" << endl;
return 0;
}
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 | import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;
public class B {
static ArrayList<ArrayList<Integer>> graph;
static LinkedList<Integer> cycle;
static int[] vis, parent;
public static void dfs(int cur, int pnt) {
if (cycle.size() > 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 | s=raw_input().split()
n=int(s[0])
m=int(s[1])
C= [[0 for col in range(n)] for row in range(n)]
for i in range(m):
s=raw_input().split()
x=int(s[0])
y=int(s[1])
C[x-1][y-1]=1
C[y-1][x-1]=1
e= [0 for i in range(n)]
def dfs(u):
ver=1;
ed=0;
e[u]=1
for v in range(n):
if C[u][v... | 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> g[100010];
int visited[100010];
int parent[100010];
int flag;
void explore(int u) {
visited[u] = 1;
for (int i = 0; i < g[u].size(); i++) {
if (!visited[g[u][i]]) {
parent[g[u][i]] = u;
explore(g[u][i]);
} else if (g[u][i] == parent[u])
... | 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.LinkedList;
import java.util.ListIterator;
import java.util.Scanner;
public class Cthulhu {
public static void main(String args[]){
Graphe g = new Graphe();
if(g.n_m){
g.dfs(0);
if(g.all_marked())
System.out.println("FHTAGN!");
else
System.out.println("NO");
} else
Syste... | 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 CF_Cthulu_104C{
public static void main(String[] args)throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String[] input;
input = in.readLine().split(" ");
int n = Integer.parseInt(input[0]);
int m = Integer.parse... | 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 C {
int n, m;
boolean[][] e;
boolean[] u;
boolean[] cycle;
int[] trace;
int cycleN;
void f(int x, int from, int k){
if(cycleN>1)return;
for(int i=0;i<n;i++){
if(i==from)continue;
if(e[x][i]){
if... | 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 implements Runnable {
int N;
List<Integer>[] edges;
boolean[] visited;
public void dfs(int at){
visited[at] = true;
for(int c : edges[at]){
if(!visited[c])
dfs(c);
}
}
public void solve() throws IOException {
N = nextInt();
int e... | 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 INFint = 2e9;
const long long INF = 1e18;
const long long MOD = 1000000007ll;
int g[100][100];
vector<int> used;
set<int> roots;
int n, m;
void dfs(int v, int p) {
used[v] = 1;
for (int i = 0; i < n; i++) {
if (i == p || !g[v][i]) continue;
if (used[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.io.*;
import java.util.*;
public class B {
int n, m;
ArrayList<Integer>[] g;
int k;
int[] s;
boolean[] used;
void dfs(int v) {
used[v] = true;
for (int j : g[v]) {
if (!used[j]) {
dfs(j);
}
}
}
void solve() throws Exception {
n = nextInt();
m = nextInt();
if (n != m) {
... | 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 | //I AM THE CREED
/* //I AM THE CREED
/* package codechef; // don't place package name! */
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.*;
import java.awt.Point;
public class Main{
static int[] g=new int[101];
... | 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 | # Bosdiwale code chap kr kya milega
# Motherfuckers Don't copy code for the sake of doing it
# ..............
# ╭━┳━╭━╭━╮╮
# ┃┈┈┈┣▅╋▅┫┃
# ┃┈┃┈╰━╰━━━━━━╮
# ╰┳╯┈┈┈┈┈┈┈┈┈◢▉◣
# ╲┃┈┈┈┈┈┈┈┈┈┈▉▉▉
# ╲┃┈┈┈┈┈┈┈┈┈┈◥▉◤
# ╲┃┈┈┈┈╭━┳━━━━╯
# ╲┣━━━━━━┫
# ……….
# .……. /´¯/)………….(\¯`\
# …………/….//……….. …\\….\
# ………/….//……………....\\….\
# …./... | 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 | inp = input().split()
n = int(inp[0])
m = int(inp[1])
if n < 3 or n != m:
print('NO')
exit()
e, f = [[] for i in range(n + 1)], set()
for j in range(m):
x, y = map(int, input().split())
e[x].append(y)
e[y].append(x)
def dfs(x):
f.add(x)
for y in e[x]:
if not ... | 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;
vector<int> g[111];
bool u[111];
int n, m, x, y, z;
void dfs(int i) {
u[i] = true;
z++;
for (int j = 0; j < g[i].size(); j++) {
if (u[g[i][j]] == false) dfs(g[i][j]);
}
}
int main() {
cin >> n >> m;
for (int i = 1; i <= n; i++) u[i] = false;
for (int i = 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 | from sys import stdin, exit
buf = []
for line in stdin:
buf.append(line.strip())
buf.reverse()
def getints():
return [int(e) for e in buf.pop().split()]
d = getints()
if d[0] != d[1]:
print 'NO'
exit()
v = d[0]
UF = [i for i in range(v)]
def find(i):
p = UF[i]
if p == i:
return i
... | 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;
void build(long long v, long long tl, long long tr, long long st[],
long long lz[], bool f[], long long a[]) {
if (tl == tr) {
st[v] = a[tl];
lz[v] = 0LL;
f[v] = false;
return;
}
build((v << 1), tl, ((tl + tr) >> 1), st, lz, f, a);
build((... | 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.*;
import java.math.*;
public class Main implements Runnable {
int n, m;
boolean[][] a;
boolean[] f;
int[] p, d;
int ck = 0;
boolean ok = true;
void dfs(int v) {
f[v] = true;
for (int i=0; i<n; i++)
if (a[v][i])
if (!f[i]) { p[i] = v; dfs(i); } else {
if (i!=p... | 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;
struct edge {
long long u, v;
} e[5005 << 1] = {0};
long long n, m, cnt = 0, tot = 0, v[5005] = {0}, h[5005] = {0};
inline void add(long long u, long long v) {
e[++tot] = (edge){h[u], v}, h[u] = tot;
}
void dfs(long long x) {
v[x] = 1, cnt++;
for (register long long... | 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 cthulu {
public static void main(String[] args) throws IOException{
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int m = s.nextInt();
if (n == m) {
boolean[] seen = new boolean[n];
ArrayDeque<Integ... | 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 maxn = 105;
long cht;
vector<long> edges[maxn];
long n, m;
long mark[maxn];
void dfs(long u, long pred) {
mark[u] = 1;
if (edges[u].size() != 0) {
for (long choice = 0; choice < edges[u].size(); choice++) {
long next = edges[u][choice];
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 | #include <bits/stdc++.h>
using namespace std;
const int N = 101;
int mat[N][N];
bool chk[N];
int cnt;
int n, m;
void dfs(int now) {
if (chk[now]) return;
chk[now] = true;
cnt++;
for (int i = 1; i <= n; i++) {
if (mat[now][i]) {
dfs(i);
}
}
}
int main() {
while (scanf("%d %d", &n, &m) == 2) {
... | 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.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class test {
static int[] parents;
static int[] ranks;
static int[] count;
static class pair {
int x, y;
public pair (int x, int y){
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 | #include <bits/stdc++.h>
using namespace std;
int find_parent(int a, int *parent) {
if (parent[a] == a) return a;
return find_parent(parent[a], parent);
}
int dfs(int u, int v, vector<vector<int>> &adj, bool *visited) {
visited[u] = true;
if (u == v) return 0;
int myres = INT_MIN;
for (int i = 0; i < adj[u]... | 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.InputStream;
import java.io.PrintStream;
import java.util.*;
public class Ktulhu implements Runnable {
public void run() {
int n = in.nextInt();
int m = in.nextInt();
if(n != m) {
out.println("NO");
return;
}
Node[] nodes = new Node[n];
for(int i = 0; i < n; ++i) {
nodes[i] = ne... | 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;
bool a[maxn][maxn];
int u[maxn];
vector<int> st;
int n, m;
void dfs0(int x) {
u[x] = 1;
for (int i = 0; i < n; i++) {
if (a[x][i] && !u[i]) dfs0(i);
}
}
int dfs(int x, int p = -1) {
u[x] = 1;
st.push_back(x);
for (int i = 0; i < n; 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;
int g[128][128];
vector<bool> visited;
int n, m;
void dfs(int v = 0) {
for (int i = 0; i < n; i++)
if (!visited[i] && g[v][i]) visited[i] = true, dfs(i);
}
int main() {
cin >> n >> m;
if (n != m) {
cout << "NO" << endl;
return 0;
}
visited.resize(n, fa... | 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 B103 {
static int n, m;
static ArrayList<Integer> adjList[];
static boolean visited[];
@SuppressWarnings("unchecked")
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
n = in.nextInt();
m = in.nextInt();
adjList = new Arra... | 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;
template <class T>
inline T Get_Max(const T& a, const T& b) {
return a < b ? b : a;
}
template <class T>
inline T Get_Min(const T& a, const T& b) {
return a < b ? a : b;
}
const int maxn = 110;
vector<int> G[maxn];
int mark[maxn];
int dfs(int u) {
int cnt = 0;
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 | # Team ASML
MAX_EDGES = 10000
def nr_edges(n):
if (n != None):
return len(n)
else:
return MAX_EDGES
if __name__=='__main__':
l = map(int,raw_input().split())
n, m = l[0], l[1]
nodes = [[] for i in xrange(n)]
nodes_left = n
for i in xrange(m):
l = map(int,raw_input().split())
nodes[l... | 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.*;
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
/*```````````````````````````````````````````````````````````````````````````````````... | 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 solvingProblems;
import java.util.LinkedList;
import java.util.Scanner;
public class Cthulhu {
static boolean visited[];
static LinkedList<Integer>[] g;
static int count;
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int m = scan.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 | import java.io.*;
import java.util.*;
public class B103 {
static int n, m;
static int[] parent, size;
public static void main(String[] args) throws IOException {
PrintWriter w = new PrintWriter(System.out);
InputReader in = new InputReader(System.in);
n = in.nextInt(); m = in.nextIn... | 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.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;
public class CF103B {
static class UndirectedGraph {
ArrayList<Integer>[] adjList;
int n;
... | 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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
/**
* Built using CHelper plug-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 | //thnks learn Ds
import java.io.*;
import java.util.*;
public class CNew
{
public static void main(String args[])throws IOException
{
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st=new StringTokenizer(in.readLine());
int n=Integer.parseInt(st.nextToken());
int m=In... | 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.*;
import java.math.BigInteger;
import static java.lang.Math.*;
public class Sol implements Runnable {
int [] par;
int parent(int u) {
return par[u] == u ? u : (par[u] = parent(par[u]));
}
void unite(int u, int v) {
int pu = parent(u);
int pv = parent(v);
par[pu] = pv;... | 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 MAX_N = 1000;
vector<int> g[MAX_N + 10];
vector<int> dfs_trace;
bool is_circle[MAX_N + 10] = {0};
int circles_finded = 0;
int b[MAX_N + 10] = {0};
void scanGraph(int m) {
int x;
int y;
for (int i = 0; i < m; ++i) {
scanf("%d %d", &x, &y);
g[x].push_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 | #include <bits/stdc++.h>
using namespace std;
vector<int> x[101];
int vis[101] = {0}, flag = 0;
void dfs(int i, int parent) {
if (vis[i]) {
if (vis[i] != parent) flag++;
return;
}
vis[i] = parent;
for (int j = 0; j < x[i].size(); ++j) {
if (x[i][j] == parent) continue;
dfs(x[i][j], i);
}
}
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 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
public class B103 {
public static class V{
int ind;
int vis;
List<V> roadsTo = new ArrayList<>();
public... | 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;
int i;
int x, y;
vector<int> a[100];
int color[100];
int c_count;
bool isCyclic(int node, int prev) {
int i;
color[node] = 1;
for (i = 0; i < a[node].size(); i++) {
int k = a[node][i];
if (k == prev) continue;
if (color[k] == 1) return true;
... | 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 func(n):
global a, b, c, lst
a[n] = 1
for j in lst[n]:
if a[j] == 1 and b[n] != j:
c += 1
if(not a[j]):
b[j] = n
func(j)
a[n] = 2
n , m = [int(x) for x in input().split()]
lst = [[] for i in range(n +1)]
for i in range(m):
x , y = map(int, 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 |
import java.awt.Point;
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import static java.lang.Math.*;
public class ProblemC_80 {
final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE")!=null;
BufferedReader in;
PrintWriter out;
StringTokenizer tok = new StringTokenizer("");
void... | 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 ans = 0;
int a = 0;
vector<int> v[101];
int visited[101];
int parent[101];
void dsf(int s) {
visited[s] = 1;
for (int n = 0; n < v[s].size(); n++) {
int d = v[s][n];
if (parent[s] != d && visited[d] != 2) {
if (visited[d] == 1) {
ans++;
}... | 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, 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)
visn = 0
visited = [0] * N
def dfs(n):
global visn
visn += 1
visited[n] = 1
for i in g[n]:
if not visited[i]:
dfs(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 | #include <bits/stdc++.h>
using namespace std;
const long long INF64 = 3e18;
const int mod = (int)1e9 + 7;
const int MAX_N = 100000 + 5;
long long binp(long long a, long long b) {
if (b == 0) return 1;
long long ans = binp(a, b / 2);
long long tmp = (ans * ans);
if (b % 2) return ((tmp * a));
return ((tmp));
}... | 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 | """
https://codeforces.com/problemset/problem/103/B
"""
parent = []
ranks = []
edge = []
cycle = 0
def makeSet(n):
global parent, ranks
parent = [i for i in range(n)]
ranks = [0 for _ in range(n)]
def findSet(u):
global parent
if parent[u] != u:
parent[u] = findSet(parent[u])
... | 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 a {
static long mod = 1000000007;
public static void main(String[] args) throws IOException
{
input.init(System.in);
PrintWriter out = new PrintWriter(new PrintStream(System.out));
//Scanner input = new Scanner(new File("input.txt"));
//PrintWriter out = 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 | n, m = map(int, raw_input().split())
g = []
for i in range(n):
g.append([0] * n)
for i in range(m):
x, y = map(int, raw_input().split())
x -= 1
y -= 1
g[x][y] = 1
g[y][x] = 1
v = [0] * n
x = 0
def dfs(i, d):
global x
if v[i] == 1:
if d > 0:
x += 1
else:
... | 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.Scanner;
public class Cthulhu {
int[] parents;
int numOfLoops=0;
public static void main(String[] args) {
Cthulhu obj=new Cthulhu();
Scanner input = new Scanner(System.in);
int n = input.nextInt();
int m = input.nextInt();
obj.parents = new int[n + 1];
int x,y,numOfSets=0;
obj.createS... | 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;
long long n, m, x, y;
void dfs(int s, vector<bool>& visited, vector<vector<long long> >& g) {
visited[s] = true;
for (int i = 0; i < g[s].size(); i++) {
if (visited[g[s][i]] == false) dfs(g[s][i], visited, g);
}
}
int main() {
cin >> n >> m;
vector<vector<long... | 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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Main
{
int nodes;
int edges;
int count;
boolean graph[][];
boolean visited[];
int parent[];
int rank[];
FastScanner in;
PrintWriter out;
pu... | 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
from array import array
if len(sys.argv) > 1:
infile = open(sys.argv[1],'rU')
else:
infile = sys.stdin
def rd():
return infile.readline()
n,m = map(int, rd().split())
adjl = {} # the adjoint list
for i in range(1,n+1):
adjl[i] = []
for i in range(m):
v1,v2 = map(int, rd().split())
adjl[v1].append(v2)... | 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.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
public class Main {
static int n,m;
static boolean visi[],mat[][];
public static void dfs(int j)
{
visi[j]=true;
for(int i=0;i<n;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 fa[1005];
int n, m;
int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
void merge(int u, int v) {
int ru = find(u);
int rv = find(v);
if (ru != rv) {
fa[ru] = rv;
}
}
int main() {
int u, v;
int flag = 0, fail = 0, r = 0;
cin >> 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 | /**
* Created by IntelliJ IDEA.
* User: mac
* Date: 11-11-25
* Time: 下午8:20
* To change this template use File | Settings | File Templates.
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Str... | 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 hits = 0;
vector<int> edges[101];
void print_vector2d(vector<vector<int>>& a, string name) {
cout << name << " is\n";
for (int i = 0; i < a.size(); i++) {
for (int j = 0; j < a[0].size(); j++) {
cout << a[i][j] << " ";
}
cout << "\n";
}
cout <<... | 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 long long OO = (long long)1e15 + 1;
const int MAX = 1e5 + 5;
vector<vector<int> > adjLst;
int n, m, vis[101], countt = 0, x, y;
void dfs(int cur = 1) {
if (vis[cur]) return;
vis[cur] = 1;
for (int i = 0; i < adjLst[cur].size(); i++) {
int child = adjLst[cur]... | 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> mp[105];
int vis[105];
struct node {
int fa;
int kid;
node(int fa, int b) {
this->fa = fa;
kid = b;
}
};
bool bfs(int rt, int n) {
queue<node> q;
q.push(node(-1, rt));
vis[rt] = 1;
while (!q.empty()) {
int now = q.front().kid;
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>
using namespace std;
int a, b, n, m, ok, passou[1 << 20];
vector<int> grafo[1 << 20];
void dfs(int u) {
passou[u] = 1;
for (int i = 0; i < grafo[u].size(); i++) {
int v = grafo[u][i];
if (!passou[v]) dfs(v);
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie... | 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> gr[1000];
int vis[1000];
int ans = 0;
void dfs(int a) {
vis[a] = 1;
ans++;
for (int i = 0; i < gr[a].size(); i++)
if (vis[gr[a][i]] == 0) dfs(gr[a][i]);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
memset(vis,... | 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 Main {
public static void main(String[] args) {
PrintWriter stdout = new PrintWriter(new BufferedOutputStream(System.out));
kernel("stdin", stdout);
}
public static void kernel(String source, PrintWriter out) {
MyScanner sc = 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 | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Saransh
*/
import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;
public class Main {
/**
* @param args the command line arguments
*/
static Stack<Integer>c... | 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 eD[150][150], mark[150], delx, dely, flag, n, m;
int dfs(int x, int rem) {
mark[x] = 1;
for (int i = 1; i <= n; i++) {
if (!eD[x][i] || i == rem) continue;
if (mark[i]) {
delx = x;
dely = i;
flag = 1;
return 1;
} else
dfs(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 MX = (1 << 20);
class Disjoint_Set {
public:
int sz[MX], P[MX];
int find_(int x) {
if (x != P[x]) P[x] = find_(P[x]);
return P[x];
}
int comp;
void init(int N) {
for (int j = 1; j <= N; j++) sz[j] = 1, P[j] = j;
comp = N;
}
bool same... | 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;
int x, y;
vector<int> ga[200];
bool vis[200];
void dfs(int u) {
vis[u] = true;
for (int i = 0; i < ga[u].size(); i++) {
int v = ga[u][i];
if (!vis[v]) dfs(v);
}
}
int main() {
cin >> n >> m;
for (int i = 1; i <= m; i++) {
cin >> x >> y;
g... | 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;
int P[102];
int p(int x) {
if (P[x] == x)
return x;
else
return p(P[x]);
}
int main() {
scanf("%d%d", &n, &m);
for (int i = 1; i <= 100; i++) {
P[i] = i;
}
for (int i = 1; i <= m; i++) {
int k, l;
scanf("%d%d", &k, &l);
int u = ... | 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;
vector<int> adj[N];
int n, m, cnt = 0;
bool vis[N];
void dfs(int u) {
cnt++;
vis[u] = 1;
for (auto v : adj[u])
if (!vis[v]) dfs(v);
}
int main() {
scanf("%d %d", &n, &m);
if (n != m) {
printf("NO\n");
return 0;
}
int u, v;
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 | #include <bits/stdc++.h>
using namespace std;
const int MAX_N = (100 + 10);
int N, M, cnt, mark[MAX_N];
vector<int> g[MAX_N];
void dfs(int u) {
mark[u] = 1;
++cnt;
for (int i = (0); i < ((int)g[u].size()); ++i) {
int v = g[u][i];
if (!mark[v]) dfs(v);
}
}
int main() {
while (cin >> N >> M) {
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 | #include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-11;
template <class T>
inline void checkmin(T &a, T b) {
if (b < a) a = b;
}
template <class T>
inline void checkmax(T &a, T b) {
if (b > a) a = b;
}
template <class T>
inline T sqr(T x) {
return x * x;
}
int mp[101]... | 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 | from __future__ import print_function
import sys
from collections import *
from heapq import *
from functools import *
import re
from itertools import *
INF=float("inf")
NINF=float("-inf")
try:
input=raw_input
except:
pass
def read_string():
return input()
def read_string_line():
return [x for x in ... | 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 sys
sys.setrecursionlimit(10 ** 6)
class Edge:
def __init__(self, u, v, w=0):
self.frm = u
self.to = v
self.weight = w
def __repr__(self):
return "{frm} - {to}: {weight}".format(frm=self.frm, to=self.to, weight=self.weight)
def __eq__(self, other):
return s... | 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;
long long int visited[100000];
long long int len[100000];
long long int cycle = 0;
void dfs(long long int second, vector<long long int> v[]) {
visited[second] = 1;
long long int vp;
for (long long int i = 0; i < v[second].size(); i++) {
vp = v[second][i];
if (... | 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.*;
import java.util.function.*;
import java.lang.*;
public class Main {
final static String fileName = "";
final static boolean useFiles = false;
public static void main(String[] args) throws FileNotFoundException {
InputStream inputStream;
OutputStream o... | 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.Arrays;
import java.util.StringTokenizer;
public class B103 {
static BufferedReader br;
static StringTokenizer st;
static PrintWriter pw;
static String nextToken() ... | 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 os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writabl... | 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;
vector<int> edges[5001];
int n, m;
bool vis1[110];
bool flag = false;
int ans = 0;
void dfs(int u, int parent) {
vis1[u] = true;
for (int i = 0; i < edges[u].size(); i++) {
int v = edges[u][i];
if (!vis1[v]) {
dfs(v, u);
} else if (v != 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;
const int N = 1e5 + 5;
const int inf = 1e9 + 1;
const double eps = 1e-15;
const double EPS = 1e-9;
const double PI = acos(-1.0);
vector<int> edge[200];
int vis[200];
int n, m, u, v;
void dfs(int id) {
vis[id] = 1;
for (int i = 0; i < edge[id].size(); i++) {
int 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;
bool v[105], f[105][105];
int n, m, s = 0;
void dfs(int x) {
v[x] = 1;
s++;
for (int i = 1; i <= n; i++)
if (!v[i] && f[x][i]) dfs(i);
}
int main() {
scanf("%d%d", &n, &m);
if (n != m) {
puts("NO");
return 0;
}
for (int i = 1; i <= m; i++) {
in... | 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.*;
public class B103 {
HashSet<Integer> visited;
List<Integer> edges[];
public static void main(String[] args) {
new B103().solve();
}
@SuppressWarnings("unchecked")
public void solve() {
Scanner in = new Scanner(System.in);
int n = in.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;
int parent[1005];
bool visited[1005];
int f = 0;
int findParent(int node) {
if (parent[node] == node) return node;
return parent[node] = findParent(parent[node]);
}
set<int> Connected[1005];
void dfs(int node) {
if (visited[node]) return;
f++;
visited[node] = true... | 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.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 Cthulhu
{
/*
* Look at the formal part of statement.
* Cthulhu is a simple cycle wit... | 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 v, e, a, b, x, y, cyc, found, head, chk[105];
vector<int> par, deg;
int findr(int a) {
if (par[a] != a) par[a] = findr(par[a]);
return par[a];
}
int main() {
scanf("%d %d", &v, &e);
for (int i = 0; i <= v; ++i) par.push_back(i);
deg.resize(v + 1);
while (e--... | 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, d[111], fa[111];
bool bo[111][111];
bool vis[111], flag, pd;
int getfa(int x) {
if (fa[x] == x)
return x;
else
return fa[x] = getfa(fa[x]);
}
void round() {
int i, j;
while (1) {
flag = true;
for (i = 1; i <= n; i++)
if (d[i] <= 1 && !vi... | 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> g[100000];
bool used[100000];
void dfs(int v) {
used[v] = true;
for (int i = 0; i < g[v].size(); i++) {
int to = g[v][i];
if (used[to] == false) {
dfs(to);
}
}
}
int main() {
cin >> n >> m;
for (int i = 1; i <= m; i++) {
... | CPP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.