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.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.math.BigInteger; import java.util.Arrays; import java.util.InputMismatchException; public class C implements Runnable { private InputReader in; private PrintWriter out; private static final int MAX = 100+5; public stat...
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.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; public class ABC { static int N, E, counter; static ArrayList<Integer>[] ...
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, a[100][100], vis[100], p[100]; void dfs(int x) { vis[x] = 1; for (int i = 0; i < n; i++) if (a[x][i]) { if (vis[i]) { if (p[x] != i) m++; } else { p[i] = x; dfs(i); } } } int main() { int x, y; 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; int table[105][105]; int used[105]; int N, M; int cycle = 0; int visit[105]; void DFS(int from, int s) { int i, j, k; for (i = 1; i <= N; i++) { if (table[s][i] && i != from && !visit[i]) { if (used[i]) { cycle++; } else { used[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
#include <bits/stdc++.h> using namespace std; template <class T1> void deb(T1 e1) { cout << e1 << endl; } template <class T1, class T2> void deb(T1 e1, T2 e2) { cout << e1 << " " << e2 << endl; } template <class T1, class T2, class T3> void deb(T1 e1, T2 e2, T3 e3) { cout << e1 << " " << e2 << " " << e3 << endl; ...
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; public class Main{ static ArrayList<Integer> adjList[]; static int n, m; static boolean visited[]; public static void main(String args[]) { Scanner in = new Scanner(System.in); n = in.nextInt(); m = in.nextInt(); if (m != n) { 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 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
#include <bits/stdc++.h> #pragma GCC optimize("O3") using namespace std; void FastInputOutput() { ios_base ::sync_with_stdio(0); cin.tie(0); cout.tie(0); } void ReadFromFile(string name, string extention) { string fullPath = name + "." + extention; freopen(fullPath.c_str(), "r", stdin); } inline int D() { 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.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class DvorkinKtylxy { static int[][] matr; static boolean[] versh; public static void main(String[] args) throws IOException { BufferedReader in = new BufferedRead...
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; public class Tests{ static Scanner in = new Scanner (System.in); static PrintWriter out = new PrintWriter (System.out); static ArrayList <Integer>[] adjList ; static boolean vis []; static int n , m , count=0; public static void main (String ...
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 FindCycle { private: int n; bool vs[100 + 5]; int prv[100 + 5]; vector<int> adj[100 + 5]; vector<int> cycle; bool found; public: FindCycle(vector<int> _adj[], int _n) { found = false; n = _n; for (int _b = (n), i = (1); i <= _b; 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.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.StringTokenizer; /** * * @author Prateep */ public class JavaApplication2 { /** * @...
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.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner r = new Scanner(System.in); int n = r.nextInt(); int m = r.nextInt(); boolean[][] g = new boolean[n][n]; for(int k = 0; k < m; k++){ int i = r.nextInt()-1; int j = r.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
R = lambda: map(int, raw_input().split()) n, m = R() if m != n: print 'NO' exit() matrix = [[0]*n for _ in range(n)] for i in range(m): x, y = R() x, y = x-1, y-1 matrix[x][y] = 1 matrix[y][x] = 1 v = [0]*n m = matrix def dfs(i): for j in range(n): if v[j]: continue if m[i][j]: v[j] = 1 dfs(j) dfs(0...
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 a[102][102], reach[102], n; void dfs(int v) { int i; reach[v] = 1; for (i = 1; i <= n; i++) if (a[v][i] && !reach[i]) { dfs(i); } } int main() { int i, j, count = 0; int c, b, m; scanf("%d%d", &n, &m); for (i = 0; i <= n; i++) for (j = 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
#include <bits/stdc++.h> using namespace std; int n, m; vector<int> uf; void init_uf() { fill(uf.begin(), uf.end(), -1); } int find(int x) { if (uf[x] < 0) { return x; } return uf[x] = find(uf[x]); } void join(int x, int y) { x = find(x); y = find(y); if (x == y) { return; } if (uf[x] > uf[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.util.*; import java.math.*; public class Main { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); StringTokenizer tokenizer=null; int n,m; int adjMat[][]; hello ver[]; int cycle[]; int cycles = 0; public static void main(String[] args) throws IOException ...
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 visit[105]; vector<int> Adj[105]; void dfs(int s) { visit[s] = true; for (int i = 0; i < Adj[s].size(); i++) { int to = Adj[s][i]; if (to != s && !visit[to]) dfs(to); } } int main() { cin >> n >> m; 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
#include <bits/stdc++.h> using namespace std; using P = pair<long long, long long>; using WeightedGraph = vector<vector<P>>; using UnWeightedGraph = vector<vector<long long>>; using Real = long double; using Point = complex<Real>; using Vector2d = complex<Real>; const long long INF = 1LL << 60; const long long MOD = 10...
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 CF103b { private void run() { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); if(n != m) { //木構造ならn = m-1。一箇所連結していればn=mとなる。 System.out.println("NO"); return; } bo...
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 = 100010; int n, m, k, f[N]; vector<int> v[N]; void dfs(int c) { f[c] = true; k++; for (auto i : v[c]) if (!f[i]) dfs(i); } int main() { scanf("%d %d", &n, &m); for (int i = 1; i <= m; i++) { int x, y; scanf("%d %d", &x, &y); v[x].push_...
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 java.util.Stack; //인접 리스트로 표현.. public class B103 { static int n = 0; static int m = 0; static ArrayList<ArrayList<Integer>> grape = new ArrayList<>(); static Stack st = new Stack(); static int[] visit = null; 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.util.Scanner; public class Cthulhu { static int numOfCycles = 0; static int[] parents; public static void main(String[] args) { // TODO Auto-generated method stub Scanner input = new Scanner(System.in); int nodes = input.nextInt(); int edges = input.nextInt(); int[] connection = new int[2...
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.math.BigInteger; import java.util.*; public class Main implements Runnable { // leave empty to read from stdin/stdout private static final String TASK_NAME_FOR_IO = ""; // file names private static final String FILE_IN = TASK_NAME_FOR_IO + ".in"; private static final...
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): f.add(x) for y in e[x]: if not y in f: dfs(y) if n >= 3 and n == m: e, f = [[] for i in range(n + 1)], set() for j in range(m): x, y = map(int, input().split()) e[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> const int INF = 0x3f3f3f3f; using namespace std; bool bfs(vector<vector<int> >& graph, vector<int>& usados, int atual, int tamanho) { bool temloop = false; vector<int> pai(tamanho, -1); queue<int> filona; int aux = 0; filona.push(atual); while (!filona.empty()) { int at...
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 ktulu(): verts, edges = map(int, raw_input().split()) if verts != edges: return 'NO' comps = [[i] for i in range(verts)] cycles = 0 for e in range(edges): v1, v2 = map(lambda x: int(x) - 1, raw_input().split()) i1, = [i for i in range(len(comps)) if v1 in comps[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; int parent[101]; int ssize[101]; int find_set(int vector) { if (vector == parent[vector]) return vector; return parent[vector] = find_set(parent[vector]); } void make_set(int vector) { parent[vector] = vector; ssize[vector] = 1; } void union_sets(int a, int b) { 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
#include <bits/stdc++.h> using namespace std; vector<int> graph[10000]; bool visited[10000]; int nodes = 1; void dfs(int x) { visited[x] = true; for (int i = 0; i < graph[x].size(); i++) { if (visited[graph[x][i]]) continue; nodes++; dfs(graph[x][i]); } } int main() { int n, m; cin >> n >> m; fo...
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.IOException; import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Cthulhu { static boolean isCthulhu(int n, int m, List<Integer>[] edges) { if (n < 3 || n != m) { return false; } boolean[] visited = new boolean[edges.length];...
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 static java.util.Arrays.*; import static java.lang.Math.*; import static java.math.BigInteger.*; import java.util.*; import java.math.*; import java.io.*; public class B implements Runnable { String file = "input"; boolean TEST = false; void solve() throws IOException { n = nex...
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.BufferedInputStream; import java.io.IOException; import java.io.PrintWriter; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.InputMismatchEx...
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<int> adj[105]; vector<pair<int, int>> edge; bool mark[105]; void dfs(int x, int dx, int dy) { mark[x] = true; for (int i = 0; i < adj[x].size(); i++) { int y = adj[x][i]; if (mark[y]) continue; if (x == dx && y == dy) continue; if (x == dy && 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
#include <bits/stdc++.h> using namespace std; const long double eps = 1e-9; vector<vector<int> > g; vector<int> state; vector<int> st; vector<int> cyc; set<pair<int, int> > forbid; int cnt; void dfs(int u, int pr = -1) { cnt++; state[u] = 1; st.push_back(u); for (int i = 0; i < g[u].size(); ++i) if (g[u][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 gra[102][102], vis[102]; int n, m; void dfs(int u) { int i; vis[u] = 1; for (i = 1; i <= n; i++) if (0 == vis[i] && gra[u][i]) dfs(i); } int main() { int i, u, v; cin >> n >> m; for (i = 1; i <= m; i++) { cin >> u >> v; gra[u][v] = gra[v][u] = 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
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class sample { static int cnt = 0; static boolean[][] adj; static boolean[] v; public static void main(String[] args) throws IOException { BufferedReader in = 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
#include <bits/stdc++.h> using namespace std; int n, m; int adj[102][102]; int a, b, i; int k = 0; void dfs(int i, int vis[]) { vis[i] = 1; int ii; for (ii = 1; ii <= n; ii++) { if (vis[ii] == 0 && adj[i][ii] == 1) { dfs(ii, vis); } } } int main() { cin >> n >> m; if (n != m) { cout << "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.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.Scanner; public class Y103bKtulhu { Scanner in; PrintWriter out; public static void main(String[] args) throws IOException { new Y103bKtulhu().run(); ...
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.util.ArrayList; public class Cthulhu { static ArrayList<Integer>[]adjList; static int []dfs_num; //0-->UNVISITED 1-->VISITED 2-->EXPLORED static int []dfs_parent; static int cycles=0; public static void mai...
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 main(): def dfs(u): avail[u] = False for v in l[u]: if avail[v]: dfs(v) n, m = map(int, input().split()) if m != n: return print("NO") l = [[] for _ in range(m + 1)] for _ in range(m): a, b = map(int, input().split()) l[a].appe...
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 = 1000; int n, m; vector<int> g[N]; bool used[N]; void dfs(int v) { used[v] = 1; int sz = g[v].size(); for (int i = 0; i < sz; ++i) { int u = g[v][i]; if (!used[u]) dfs(u); } } int main() { 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 C80C{ static BufferedReader br; static ArrayList ar[]; static int path[]; static int colors[]; static int c=0; static int cross=0; public static void main(String args[])throws Exception{ br=new BufferedReader(new InputStreamReader(Sy...
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<int> edges[105]; bool visited[105]; int cnt; int cycle; void dfs(int cur, int pre) { visited[cur] = 1; ++cnt; int nxt; for (int i = 0; i < edges[cur].size(); ++i) { nxt = edges[cur][i]; if (nxt == pre) continue; if (visited[nxt]) { ++cycle; ...
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 pt{ static void dfs(LinkedList<Integer> l[],int s,boolean v[]){ v[s]=true; for(Integer i : l[s]) if(v[i]==false) dfs(l,i,v); }...
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 a, b, c, d, e, f, g, n, m, k, t, p, x, h, w, q; long long curr = 1; long long mod = 998244353; int dsu[109]; int find_parent(int v1) { if (dsu[v1] == v1) return v1; return dsu[v1] = find_parent(dsu[v1]); } void solve() { cin >> n >> m; int cycles = 0; fo...
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
//package taz; import java.util.*; import java.lang.StringBuilder; import java.util.ArrayList; import java.util.Scanner; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; public class Taz { static int maxn=105; static int[][] Gg = new int[maxn][maxn]; static boolean...
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 B103 { static int status[]; static ArrayList<Integer>[]adjList; static int c=0; public static void dfs(int i) { status[i]=1; for(int x:adjList[i]) { if(status[x]==0) { adjList[x].remove(adjList[x].indexOf(i)); dfs(x); } else if(status[x]==1)c++; } sta...
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.HashSet; import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; import java.util.Set; public class P103B { public static void main(String[] args) { Scanner inScanner = new Scanner(System.in); int n = inScanner.nextInt(); int m = inScanner.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.BufferedReader; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Cthulhu implements Closeable { private InputReader in = new InputReader(System.in); 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
#include <bits/stdc++.h> using namespace std; void connected(vector<vector<bool> > chu, vector<bool>& v, int s) { v[s] = 1; for (int i = 0; i < chu.size(); i++) { if (chu[s][i] && !v[i]) { connected(chu, v, i); } } } int main() { int n, m; while (cin >> n >> m) { if (n != m) { 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
lectura=lambda:map(int, input().split()) nVertices, nEdges= lectura() array1= [[] for i in range(nVertices + 1)] array2=[] for i in range(0, nEdges): x, y= lectura() array1[x].append(y) array1[y].append(x) def DFS(x): array2.append(x) for y in array1[x]: if (y not in array2): DFS...
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.*; import java.util.*; public class Cthulhu { static boolean isCthulhu(int n, int m, List<Integer>[] edges) { if (n < 3 || n != m) { return false; } boolean[] visited = new boolean[edges.length]; dfs(0, visited, edges); for (boolean b : 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; #pragma GCC optimize("-O3") using ld = long double; const long long mod = 1000000007; const long long inf = 1000000000000000000; const long long rk = 256; const ld PI = 3.141592653589793; ostream& operator<<(ostream& os, pair<long long, long long> const& x) { os << x.firs...
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
inp = lambda: map(int,raw_input().split()) n,m = inp() par = [i for i in range (0,n+1)] def findPar(x): if (x == par[x]): return x par[x] = findPar(par[x]) return par[x] def Union(x,y): x = findPar(x) y = findPar(y) if (x!=y): par[x] = y return 0 return ...
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.awt.*; import java.util.*; public class Cthulhu { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(), m = s.nextInt(),circle=0; ArrayList<Integer> a = new ArrayList<>(); ArrayList<Integer> b = new ArrayList<>(); a.add...
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(): n,m = map(int,input().split()) color = [0 for _ in range(n+1)] edges = [[] for _ in range(n+1)] visited = [False for _ in range(n+1)] for _ in range(m): u,v = map(int,input().split()) edges[u].append(v) edges[v].append(u) stack = list() stack.append(1) while stack: cur = stack.pop() 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.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.StringTokenizer; import java.util.TreeMap; imp...
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 v, p[10005], ans, ans1, x, y, z, n, m; pair<int, pair<int, int> > a[100005]; map<int, int> mp; int get_col(int v) { if (v == p[v]) return v; p[v] = get_col(p[v]); return p[v]; } void col(int a, int b) { p[get_col(a)] = get_col(b); } 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 java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.StringTokenizer; public class Main { private static BufferedReader br; private static PrintWriter pw; private static StringTokenizer stk = ...
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.io.PrintWriter; import java.util.ArrayList; import java.util.StringTokenizer; public class Cthulhu { static ArrayList<Integer>[] g; static boolean[] vis; static void dfs(int u) { ...
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 C { Scanner sc = new Scanner(System.in); int n; ArrayList<ArrayList<Integer> > edges; boolean [] visited; int [] hist; boolean found; ArrayList<Integer> spheric; boolean solve() { n = sc.nextInt(); edges = new ArrayList<ArrayList<Integer>>(n); for(int i = 0; i < n; i++) 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
import java.*; import java.awt.List; import java.util.ArrayList; import java.util.Iterator; import java.util.Scanner; public class Main { static boolean [] visited; static ArrayList<ArrayList<Integer>> adjlist; static int cycles; static void dfs (int v,int father) { visited[v] = true; for (int u : adjl...
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 project; import java.io.FileInputStream; import java.util.Scanner; public class Algorithm { static int N; static int M; static int[][] graphs; static int countV; public static void main(String[] args) throws Exception { //System.setIn(new FileInputStream("src/project/input.txt")); Scanner sc = 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; int main() { int n, m, a, b; cin >> n >> m; if (m == n) { vector<bool> rev(n, false); vector<vector<int> > mat(n + 1); for (int i = 0; i < m; i++) { cin >> a >> b; mat[a].push_back(b); mat[b].push_back(a); } int cont = 0; 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; int n, m; int cycles = 0; vector<vector<int> > tree(101); vector<int> parents(101); vector<int> vis(101); vector<int> color(101); void dfs(int node, int parent) { if (vis[node] == 2) return; if (vis[node] == 1) { int p = parent; cycles++; color[p] = cycles; ...
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.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.StreamTokenizer; import java.util.Arrays; public class B implements Runnable { boolean[][] e; boolean[] g; private static final String NO = "NO"; public void solve() throws IOException { 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 B103 { static int n, m; static List<Integer>[] graph; static boolean[] visited; public static void main(String[] args) throws IOException { PrintWriter w = new PrintWriter(System.out); InputReader in = new InputReader(System.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.io.*; import java.util.*; import java.util.stream.*; import java.lang.*; public class cf { public static void main(String[] args) { InputStream inputStream=System.in; OutputStream outputStream=System.out; InputReader in=new InputReader(inputStream); PrintWriter out=new PrintWriter(outputStream); T...
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 b{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); boolean isK = true; int[][] g = new int[n][n]; for(int i = 0; i < m; i++){ int a = sc.nextInt()-1; int b = sc.nextInt()-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; int n = 0; int m = 0; bool *visited; bool **ADJ; int ind = 0; int speicial[] = {6, 6, 6, 3, 6, 4, 5, 1, 2, 5, 1, 4, 5, 4}; int input[1000]; void DFS(int begin) { stack<int> search; int curr = begin; visited[curr] = true; search.push(curr); while (!search.empty()) ...
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<vector<int>> g(110); int vis[110]; int dfs(int v, int pai) { int nciclos = 0; for (int i = 0; i < g[v].size(); i++) { int u = g[v][i]; if (u == pai) continue; if (vis[u] != 0) nciclos++; else { vis[u] = 1; nciclos += dfs(u, v); ...
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 map[110][110]; int n, m; int pre[110]; int find(int t) { if (t != pre[t]) { return pre[t] = find(pre[t]); } return t; } int main() { int i, j; int u, v; cin >> n >> m; for (i = 1; i <= n; i++) pre[i] = i; int cnt = 0; for (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
#include <bits/stdc++.h> using namespace std; const int maxn = 110; const int mod = 1e9 + 7; int n, m; int pre[maxn]; int found(int x) { return pre[x] == x ? x : (pre[x] = found(pre[x])); } int main() { scanf("%d%d", &n, &m); for (int i = 0; i <= n; i++) pre[i] = i; int ans = 1; int cnt = 0; int x, y; 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.*; /** * * @author Sourav Kumar Paul */ public class SolveD { public static ArrayList<Integer> adj[]; public static boolean marked[], inStack[]; public static int con[], count =0; public static void main(String[] args) throws IOException{ Reader in = new Re...
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 p3b { public static void main(String[]args) { Scanner sc = new Scanner(System.in); String yes="FHTAGN!"; String no="NO"; int N=sc.nextInt(); int M=sc.nextInt(); int adj[][]=new int[N][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.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class Main { static int arr[],size[]; static int n,count,m; public static int root(int k) { while(k!=arr[k]) { 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
#include <bits/stdc++.h> using namespace std; int n, m, ff, nn; bool vis[105] = {0}; vector<int> eg[105]; void dfs(int u, int pr, int st) { vis[u] = 1; for (int i = 0; i < eg[u].size(); i++) { int v = eg[u][i]; if (!vis[v]) dfs(v, u, st); else if (v != u && v != pr && v == st) ff++; } } vo...
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; public class C_120 { public static void main(String[] args) { Scanner in=new Scanner(System.in); int n=in.nextInt(); int m=in.nextInt(); boolean[][] mas=new boolean[n][n]; 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
n, m = [int(i) for i in input().split()] adj = [[] for i in range(n+1)] seen = [False for i in range(n+1)] pai = [0 for i in range(n+1)] ciclos = 0 def dfs (u): seen[u] = True global ciclos for v in adj[u]: if not seen[v]: pai[v] = u dfs(v) elif v != pai[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.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.LinkedList; import java.util.StringTokenizer; public class Main { private BufferedReader input; private StringTokenizer stoken = new StringTokenizer(""); 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
#include <bits/stdc++.h> using namespace std; struct DSU { DSU() = default; DSU(int n) { v.resize(n); for (int i = 0; i < (int)n; i++) { v[i] = make_pair(i, 1); } } int getLeader(int a) { while (v[a].first != a) { a = v[a].first; } return a; } void merge(int a, int 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
//103B //Cthulhu import java.util.*; public class Cthulhu { static int nodes; static boolean[] visited; static ArrayList<Integer>[] adjList; public static void dfs(int cur) { nodes++; visited[cur] = true; for(int nxt : adjList[cur]) if(!visited[nxt]) ...
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()) 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 y in f: dfs(y) dfs(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 sys def getroot(lab, u): if lab[u] == -1: return u lab[u] = getroot(lab, lab[u]) return lab[u] def union(lab, cou, a, b): if cou[a] > cou[b]: cou[a] += cou[b] lab[b] = a else: cou[b] += cou[a] lab[a] = b def inp(): return 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
#include <bits/stdc++.h> using namespace std; const long long inf = 1e8; const double pi = 3.1415926535897; const double EPS = (1e-7); int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; } struct edge { int from, to, w; edge(int u, int v, int w) : from(u), to(v), w(w) {} bool operator<(...
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 MOD = 1e9 + 7; long long gcd(long long a, long long b, long long &x, long long &y) { if (b == 0) { x = 1; y = 0; return a; } long long x1, y1; long long g = gcd(b, a % b, x1, y1); x = y1; y1 = x1 - y1 * (a / b); return g; } 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
#include <bits/stdc++.h> using namespace std; int n, m; vector<long long> G[110]; bool visited[110]; int visitededge; void dfs(int x) { if (visited[x]) return; visitededge++; visited[x] = true; for (int i = 0; i < G[x].size(); i++) { dfs(G[x][i]); } } int main() { cin >> n >> m; if (n != m) { 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; vector<int> a[105]; int n, m, v[105]; void dfs(int s, int l) { v[s] = true; for (int i = 0; i < (int)a[s].size(); i++) if (v[a[s][i]] == 0 && a[s][i] != l) dfs(a[s][i], s); } int main() { cin >> n >> m; int x, y; for (int i = 0; i < m; i++) { cin >> 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
from collections import defaultdict #def gcd(a,b): # while b > 0: a,b = b, a%b # return a #def lcm(a, b): # return a*b/gcd(a,b) n, m = map(int, raw_input().split()) if n != m: print "NO" exit() else: pol = defaultdict(list) for i in xrange(m): x, y = map(int, raw_input().split()) ...
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.BigInteger; public class Tests{ static Scanner in = new Scanner (System.in); //static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static PrintWriter out = new PrintWriter (System.out); public static void main (String []args) 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 dfs(int a[100][100], int n) { int v[n]; int x[n]; memset(v, 0, sizeof(v)); memset(x, 0, sizeof(x)); stack<int> s; int c; int cnt = 0; c = 0; s.push(c); while (s.size() > 0) { c = s.top(); s.pop(); x[c] = 1; v[c] = 1; 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.ArrayList; import java.util.Arrays; import java.util.LinkedList; import java.util.Scanner; public class C { //AC static ArrayList<ArrayList<Integer>> graph; static LinkedList<Integer> cycle; static int[] vis, parent; public static void dfs(int cur, int 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; using ll = long long int; using ld = long double; inline int in() { int n; scanf("%d", &n); return n; } const ll maxn = 101; vector<int> adj[maxn]; bool visited[maxn]; void dfs(int v) { visited[v] = true; for (int u : adj[v]) if (!visited[u]) dfs(u); } int mai...
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 vis[1000] = {0}; vector<int> v[1000]; void paltu(int x) { if (vis[x] == 1) { return; } vis[x] = 1; for (int i = 0; i < v[x].size(); i++) { paltu(v[x][i]); } } int main() { int n, m, i, a, b; cin >> n >> m; for (i = 0; i < m; i++) { cin >> 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
/** * JUDGE_ID : 104262PN * User : Денис * Date : 07.08.11 * Time : 13:31 * ICQ : 785625 * Email : popokus@gmail.com */ import java.io.*; import java.util.Stack; public class s80_c { public static void main(String[] args) throws IOException { new s80_c().run(); } int 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; int pole[105][105]; int stav[105]; int pathFrom[105]; int main() { int N, M; cin >> N >> M; for (int i = 0; i < M; i++) { int x, y; cin >> x >> y; pole[x][y] = 1; pole[y][x] = 1; } queue<int> OPEN; OPEN.push(1); stav[1] = 1; int Cycle = 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
#include <bits/stdc++.h> using namespace std; vector<long long> graph[105]; bool vis[105]; void dfs(long long node) { vis[node] = true; for (auto child : graph[node]) { if (vis[child] == false) dfs(child); } } int32_t main() { ios_base::sync_with_stdio(false), cin.tie(NULL); clock_t clk = clock(); 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.InputStreamReader; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedList; import java.util.StringTokenizer; public class ktulhu implemen...
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> > g(105); int v[101]; int dfs(int root) { v[root] = 1; for (int i = 0; i < g[root].size(); i++) { if (v[g[root][i]] == 0) dfs(g[root][i]); } } int main() { int n, m; cin >> n >> m; int a, b; for (int i = 0; i < m; i++) { cin >> 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.BitSet; import java.util.Scanner; import java.io.IOException; public class Task2 { static int calls; static BitSet visi; static ArrayList<Integer>[] adj; static void dfs(int node){ ++calls; visi.set(node); for (int child :adj[node])...
JAVA