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
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#!/usr/bin/env python3 from __future__ import absolute_import from sys import stdin,stdout from math import * from collections import Counter from itertools import imap def ri(): return imap(int, stdin.readline().split()) lines = stdin.readlines() n, m = imap(int, lines[0].split()) g = [[] for i in xrange(m)] for...
PYTHON
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; vector<int> in[1001000]; int id[1001000]; bool cmp(int a, int b) { if (in[a].size() < in[b].size()) return true; if (in[a].size() > in[b].size()) return false; for (int i = 0; i < in[a].size(); i++) { if (in[a][i] < in[b][i]) return true; if (in[a][i] > in[b][...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; int m, n; vector<int> v[1000010]; int main() { int i, j, k, x, t; scanf("%d%d", &n, &m); for (i = 1; i <= n; i++) { scanf("%d", &x); while (x--) { scanf("%d", &t); v[t].push_back(i); } } sort(v + 1, v + 1 + m); ...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.util.*; import java.math.*; import java.io.*; import java.text.DecimalFormat; import java.math.BigInteger; public class Main{ //static int d=20; static long mod=1000000007 ; static HashMap<String,Double> hm=new HashMap<>(); ...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0; char c; while ((c = getchar()) < '0' || c > '9') ; for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - '0'; return x; } int P[3] = {2333333, 9875321, 10000007}; int h[3][1000000 + 5], ls[1000000 + 5], a[1000000 + 5], s[1...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int maxn = 1E5 + 5; const int maxm = 1E6 + 5; const int inf = 0x3f3f3f3f; const long long INF = 0x3f3f3f3f3f3f3f3f; const long long mod = 1E9 + 7; const double eps = 1E-6; const double PI = acos(-1.0); template <class T> bool scan(T &ret) { char c; int sgn; if (...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int NMAX = 100000; const int MMAX = 1000000; const int MOD = 1000000007; const int MOD1 = 402653189; const int MOD2 = 1000000009; const int BASE1 = 196613; const int BASE2 = 786433; vector<int> spell[MMAX]; int factorial[MMAX + 1]; int main(void) { cin.tie(0); ios...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.io.*; import java.util.*; public class Solution { private BufferedReader in; private StringTokenizer line; private PrintWriter out; private boolean isDebug; public Solution(boolean isDebug) { this.isDebug = isDebug; } public void solve() throws IOException { i...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; int n, m; const int MAXN = 1000005, MOD = 1e9 + 7; vector<int> gym[MAXN]; int g[MAXN]; long long fact[MAXN]; int main() { ios::sync_with_stdio(0); cin >> n >> m; fact[0] = 1; for (int i = 1; i <= m; i++) fact[i] = (fact[i - 1] * i) % MOD; for (int i = 0; i < n; i+...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int MAX_N = 1e5 + 6; const int MAX_M = 1e6 + 6; const long long mod = 1e9 + 7; const long long P = 77773; map<pair<long long, long long>, int> mp; long long per[MAX_M]; bool used[MAX_M]; vector<int> v[MAX_M]; long long hash1(vector<int> v) { long long p = P; long ...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
// package codeforces.cf3xx.cf391; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.*; public class C { private static final long MOD = 1000000007; public static void main(String[] args) { InputReader in = new InputReader(System.in); PrintWr...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.io.*; import java.util.*; public class Main { final int p=(int)(1e5+1); final long mod=(long)(1e9+7); final long mod2=999999937l; final int maxn=(int)(1e6); long fact[]; Main() { fact=new long[maxn+1]; fact[0]=1; for(int i=1;i<=maxn;i++) fact[i]=(fact[i-1]*i)%mod; } private void solve(...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int N = 1000001; vector<int> v[N]; int main() { int n, m; scanf("%d %d", &n, &m); for (int i = 1; i <= n; i++) { int x; scanf("%d", &x); for (int j = 1; j <= x; j++) { int y; scanf("%d", &y); v[y].push_back(i); } } sort(v + ...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
from array import array from collections import Counter n, m = [int(x) for x in raw_input().split()] inv = [array('i') for t in range(m)] for i in range(n): tcs = Counter([int(x) for x in raw_input().split()][1:]) for t, c in tcs.iteritems(): inv[t-1].append(i) inv[t-1].append(c) r = 1 mod ...
PYTHON
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; struct node { map<pair<int, int>, int> next; int ends; node() { ends = 0; } }; node B[1000005]; int sz(1); unsigned long long ans(1), fact[1000005]; void insert(const vector<pair<int, int> > &s) { int v = 0; pair<int, int> cur; for (int i(0); i < s.size(); ++i) ...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.io.*; import java.util.*; public class _757C { public static void main(String[] args) throws Exception { Reader.init(System.in); BufferedWriter cout = new BufferedWriter(new OutputStreamWriter(System.out)); int n = Reader.nextInt(); int m = Reader.nextInt(); L...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> #pragma GCC optimize("O3") using namespace std; struct custom_hash { static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } size_t operator()(uint64_t x) ...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.awt.*; import java.awt.event.*; import java.awt.geom.*; import java.io.*; import java.math.*; import java.text.*; import java.util.*; /* br = new BufferedReader(new FileReader("input.txt")); pw = new PrintWriter(new BufferedWriter(new FileWriter("output.txt"))); br = new BufferedReader(new InputStreamReade...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; long long int mul(long long int x, long long int y) { long long int ans = 1; while (y > 0) { if (y & 1) ans = (ans * x) % 1000000007; x = (x * x) % 1000000007; y /= 2; } return ans; }; vector<vector<pair<long long int, long long int> > > v(1000005); long...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; vector<int> a[200000]; vector<pair<long long, long long> > b[2000000]; vector<long long> kq; long long base = 1000000007; pair<long long, long long> p[200000]; pair<long long, long long> B; pair<long long, long long> H[2000000]; long long gt[2000000]; int n, m; void inc(vec...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; int x, k, n, m; vector<int> v[1000005]; long long ans = 1, fac[1000005]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; fac[0] = 1; for (long long i = 1; i <= 1000005 - 5; i++) fac[i] = (fac[i - 1] * i) % 1000000007; for...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.HashMap; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; import java.util.Map; import java....
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; double safe_sqrt(double x) { return sqrt(max((double)0.0, x)); } long long GI(long long& x) { return scanf("%lld", &x); } const long long MOD = 1e9 + 7; const long long MN = 1000111; long long gt[MN]; vector<long long> h[MN]; int main() { ios::sync_with_stdio(0); cin.ti...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const int mod = 1e9 + 7; const int maxn = 1000010 * 2; int n, m; vector<int> vec[maxn]; int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) { int k; scanf("%d", &k); while (k--) { int x; scanf("%d", &x); ...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
// Don't place your source in a package import java.util.*; import java.lang.*; import java.io.*; import java.math.*; /* 6666666666666 6666666666666 6 6 6 6 6 6 6 6 ...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#!/usr/bin/env python3 from __future__ import absolute_import from sys import stdin,stdout from math import * from collections import Counter from itertools import imap def ri(): return imap(int, raw_input().split()) n, m = ri() g = [[] for i in xrange(m)] for i in xrange(n): for t in list(ri())[1:]: ...
PYTHON
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const double PI = 3.141592653589793238; long long powmod(long long a, long long b) { long long res = 1; a %= 1000000007; for (; b; b >>= 1) { if (b & 1) res = res * a % 1000000007; a = a * a % 1000000007; } return res; } long long fac[1000005]; void factor...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int MAX = 1e6 + 5; const long long MOD = 1e9 + 7; int n, m, x, y; long long fac[MAX]; void init() { fac[0] = 1; fac[1] = 1; for (long long i = 2; i < MAX; ++i) { fac[i] = (fac[i - 1] * i) % MOD; } } void solve() { cin >> n >> m; vector<vector<int> > ar...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
from sys import stdin from collections import defaultdict def main(t=tuple): n, m = map(int, stdin.readline().split()) d = [[] for _ in xrange(m)] e = defaultdict(set) for i in xrange(n): a = map(int, stdin.readline().split())[1:] for x in a: d[x-1] += [i] s = defaultdict...
PYTHON
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; long long mod2 = 67280421310721ll; int n, m; int allocated = 0; map<int, long long int> rem; map<long long int, int> same; long long fact[1000005]; long long int power[1000005]; int l[1000005]; long long mulmod(long long a, long long b, long long c) { long long x = 0, y =...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int MAXN = 1000010; int val[2][MAXN]; const int MOD[] = {1000000007, 1000000009}; const int QTD = 2; const int B = 97; int powers[2][MAXN]; int fact[MAXN]; int main() { int n, m; scanf(" %d %d", &(n), &(m)); for (int i = 0; i < (QTD); ++i) { powers[i][0] = 1...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 10; const int mo = 1e9 + 7; vector<int> g[maxn]; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; for (int i = 1; i <= n; ++i) { int t; cin >> t; for (int j = 0; j < t; ++j) { int tem; ci...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; import java.util.stream.Collectors; import java.util.stream.IntStream; public class Main4 { static long ...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; multiset<int> v[1000000 + 50]; long long mod = 1000000007; int main() { ios::sync_with_stdio(false); int n, m, x, g; cin >> n >> m; for (int i = 0; i < n; i++) { cin >> g; while (g--) { cin >> x; v[x].insert(i); } } sort(v + 1, v + m + 1)...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005, MAXM = 1000006; int P1 = 5323, P2 = 5333, MOD1 = 1e9 + 7, MOD2 = 1e9 + 9; int pot1 = 1, pot2 = 1; pair<int, int> hesh[MAXM]; int fact[MAXM]; inline int add(int x, int y, int m) { return (x + y) % m; }; inline int mul(int x, int y, int m) { return (i...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
// Don't place your source in a package import java.util.*; import java.lang.*; import java.io.*; import java.math.*; /* 6666666666666 6666666666666 6 6 6 6 6 6 6 6 ...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> #pragma warning(disable : 4996) int n, m, c, x; unsigned long long p[1000009]; int main() { scanf("%d %d", &n, &m); unsigned long long t = 10101010101010101; for (int i = 0; i < n; i++) { scanf("%d", &c); t = t ^ (t << 13); t = t ^ (t >> 7); t = t ^ (t << 17); for (int...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.io.*; import java.util.*; /** * 757C * θ(m + Σ(g_i)) time * θ(m + max(g_i)) space * * @author artyom */ public class _757C implements Runnable { private static final int MOD = 1_000_000_007; private BufferedReader in; private StringTokenizer tok; private long solve() throws IOExcepti...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int NUM = 1000010; int n, m; int g, t[NUM]; int mod = 1e9 + 7; int id[NUM], tot = 0; int cnt[NUM]; int a[NUM], h; bool cmp(int i, int j) { if (id[i] == id[j]) return cnt[i] < cnt[j]; return id[i] < id[j]; } void solve() { sort(a, a + h, cmp); for (int i = 0, j...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; long long fact[1000001]; void f() { fact[0] = 1; fact[1] = 1; for (int i = 2; i <= 1000001; i++) fact[i] = (fact[i - 1] * i) % 1000000007; } int main() { ios_base::sync_with_stdio(0); f(); int n, m; cin >> n >> m; vector<vector<int> > p(m); for (int i = 0;...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e6 + 10; const long long mod = 1e9 + 7; vector<int> v[MAXN]; int main() { int N, M, a, b; scanf("%d %d", &N, &M); for (int i = 1; i <= N; i++) { scanf("%d", &a); while (a--) { scanf("%d", &b); v[b].push_back(i); } } sort(v...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import static java.lang.Double.parseDouble; import static java.lang.Integer.parseInt; import static java.lang.Long.parseLong; import static java.lang.System.arraycopy; import static java.lang.System.exit; import static java.util.Arrays.copyOf; import java.io.BufferedReader; import java.io.IOException; import java.io.I...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; int fact[1000050]; int main() { ios::sync_with_stdio(false); fact[0] = 1; for (int i = 1; i < 1000050; i++) fact[i] = (fact[i - 1] * 1ll * i) % 1000000007; int n, m; cin >> n >> m; vector<vector<int> > pokemonIin(m); for (int i = 0; i < n; i++) { int c...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.PrintStream; import java.util.Arrays; import java.util.HashMap; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.StringTokenizer; impo...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.util.*; import java.io.*; /** * * @author umang */ public class Problem { public static int mod = (int) (1e9+7); public static long[] fac=new long[1000001]; public static void pre(){ fac[0]=1; for(int i=1;i<fac.length;i++){ fac[i]=fac[i-1]*i; ...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; int kek = 1000000007; int fact(int n, int& fact_last, vector<int>& factv) { if (n <= fact_last) { return factv[n]; } else { for (int i = fact_last + 1; i <= n; ++i) factv[i] = (long long)factv[i - 1] * i % kek; fact_last = n; return factv[n]; } }...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#!/usr/bin/env python3 from sys import stdin,stdout from math import * from collections import Counter def ri(): return map(int, stdin.readline().split()) lines = stdin.readlines() n, m = map(int, lines[0].split()) g = [[] for i in range(m)] for i in range(n): for t in list(map(int, lines[i+1].split()))[1:]: ...
PYTHON3
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.util.*; import java.io.*; import java.util.HashMap; import java.util.Map; public class A { public static void main(String ar[]) throws Exception { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String s1[]=br.readLine().split(" "); int...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
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.Collection; import java.util.Collections; import java.util.Map.Entry; import java.util.Comparator; import java.util.HashSet; impo...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
rr=raw_input rrI = lambda: int(rr()) rrM = lambda: map(int,rr().split()) debug=0 if debug: fi = open('t.txt','r') rr=lambda: fi.readline().replace('\n','') from collections import Counter, defaultdict MOD = 10**9 + 7 N, M = rrM() grpct = 0 seen = defaultdict(set) saw = set() for _ in xrange(N): inp = rrM()...
PYTHON
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Map.Entry; impo...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 5; const int mod = 1e9 + 7; vector<int> s[maxn]; int n, m; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> m; for (int i = 1; i <= n; i++) { int num; cin >> num; for (int j = 0; j < num; j++) { int b; ...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.lang.*; import java.util.*; import java.io.*; public class Main { void solve() { int n=ni(),m=ni(); int a[][]=new int[n][]; for(int i=0;i<n;i++){ int sz=ni(); a[i]=new int[sz]; for(int j=0;j<sz;j++) a[i][j]=ni(); } long pow1[]=new long[n+1]; ...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int MX = 1e5 + 5; int n, k; map<int, int> mp; vector<vector<pair<int, int>>> adj; long long fact[10 * MX]; map<pair<long long, long long>, int> cnt; int main() { cin >> n >> k; adj.resize(10 * MX); for (int i = 1; i <= n; i++) { int g; scanf("%d", &g); ...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const int maxn = 1e6; vector<int> g[maxn + 50]; int n, m; int main() { scanf("%d%d", &n, &m); for (int i = 0; i <= m; ++i) g[i].clear(); for (int i = 0; i < n; ++i) { int num, x; scanf("%d", &num); while (num--) { scanf...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> const double EPS = 1e-24; const long long MOD = 1000000007ll; const double PI = 3.14159265359; long long INF = 1e18; template <class T> T Max2(T a, T b) { return a < b ? b : a; } template <class T> T Min2(T a, T b) { return a < b ? a : b; } template <class T> T Max3(T a, T b, T c) { retur...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int MAXM = 1000005; const int MAXN = 100005; long long MODP = 1000000000 + 7; long long MOD[] = {999999937, 999999929}; long long X[] = {31, 37}; long long fdsfdsfsddfsd[MAXM][2]; long long pwr[MAXN][2]; long long f[MAXM]; void precompute() { pwr[0][0] = pwr[0][1] =...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; import java.util.stream.Collectors; import java.util.stream.IntStream; public class Main4 { static long ...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; int mod[3] = {1000000007, 1000000009, 1500450271}; int B[3] = {100019, 223007, 100003}; int pw[3][100001]; int hsh[3][1000001]; int cid[1000001]; bool cmp(int a, int b) { if (hsh[0][a] == hsh[0][b]) { if (hsh[1][a] == hsh[1][b]) return hsh[2][a] < hsh[2][b]; retur...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e6 + 10; const int MOD = 1e9 + 7; const long long B1 = 701; const long long B2 = 721; int n, m; vector<int> vec[MAXN]; vector<pair<int, int>> sec[MAXN]; long long ss[MAXN], t1[MAXN], t2[MAXN]; map<pair<long long, long long>, int> mp; int main() { ss[0] =...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.StreamTokenizer; import java.util.Arrays; public class Main { static class Node { public int n; public Node next; public Node(int x){ thi...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.StringTokenizer; public class R391P3 { static final long MOD = 1000000007; public static void main(String[] args) throws Exception { ...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; int my_hash(const vector<int>& v) { int xd = 100003, mod = 1e9 + 7; long long r = 0; for (auto x : v) { r *= xd; r += x; r %= mod; } return r; } int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cout.setf(ios_base::fixed); cout.p...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int MAXN = 1000010; int val[2][MAXN]; const int MOD[] = {1000000007, 1000000009}; const int QTD = 2; const int B = 97; long long powers[2][MAXN]; long long fact[MAXN]; int main() { int n, m; scanf(" %d %d", &(n), &(m)); for (int i = 0; i < (QTD); ++i) { powe...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; int n, m; const int maxm = 1000000; vector<int> vt[maxm + 2]; const int mod = 1e9 + 7; int main() { cin >> n >> m; for (int i = 1; i <= n; i++) { int g; cin >> g; while (g--) { int x; cin >> x; vt[x].push_back(i); } } sort(vt + 1, v...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int maxM = 1000100; int N, M; int d[maxM], K; int main() { scanf("%d%d", &N, &M); K = 1; while (N--) { static int q[maxM]; int l; scanf("%d", &l); for (int i = 0; i < l; i++) scanf("%d", q + i), q[i]--; sort(q, q + l); static pair<int, in...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const double eps = 0.000000000000001; string convertstring(long long n) { stringstream ss; ss << n; return ss.str(); } vector<vector<int> > a; vector<int> v[1000005]; long long fact[1000005], hsh[1000005]; int main() { int n, m, i, j; scanf("%d%d", &n, &m); ; ...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws FileNotFoundException { ConsoleIO io = new ConsoleIO(new InputStreamReader(System.in), new PrintWriter(System.out)); //ConsoleIO io = new ConsoleIO(new FileReader("D:\\fbhc\\fighting_the_zombie.t...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; int n, m, t, mm; vector<int> g[1000005]; int main() { cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> t; while (t--) { cin >> mm; g[mm].push_back(i); } } sort(g + 1, g + 1 + m); long long k = 1, ans = 1; for (int i = 2; i <= m; i++) ...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; long long hasha[1000100], hashb[1000100]; long long p1 = 1e9 + 123; long long p2 = 1e9 + 181; long long d = 10007; map<pair<int, int>, int> mp; int n, m; long long fac[1000010]; int main() { scanf("%d%d", &n, &m); long long pp1 = 1, pp2 = 1; for (int i = 0; i < n; i++...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; struct FastReader { FastReader &operator,(int &x) { scanf("%d", &x); return *this; } FastReader &operator,(signed long long &x) { scanf( "%" "ll" "d", &x); return *this; } FastReader &operator,(double &x) { scanf...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; inline string toString(long long x) { string ans = ""; while (x) ans.push_back(x % 10 + '0'), x /= 10; if (ans.size() == 0) ans = "0"; for (long long i = 0; i < ans.size() / 2; i++) swap(ans[i], ans[ans.size() - 1 - i]); return ans; } inline long long gcd(long...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.io.*; import java.util.*; public class Main { public void solve() { int n = ni(); int m = ni(); ArrayList<ArrayList<Integer>> ts = new ArrayList<>(); for (int i = 0; i < m; i++) { ts.add(new ArrayList<>()); } for (int i = 1; i <= n; i++) { ...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> #pragma GCC target("avx2") #pragma GCC optimization("O3") #pragma GCC optimization("unroll-loops") #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") using namespace std; const long long mod1 = 1e9 + 1011; const long long mod2 = 1e9 + 9; ...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.io.BufferedWriter; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.ObjectInputStream.GetField; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet;...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int nmax = 1000009; int base[2][nmax], mod[2], a[nmax], fact[nmax]; pair<int, int> arr[nmax]; pair<int, int> arr0; int i, n, m, j, cnt0, a0, answer, t; void initHashing() { base[0][0] = 1000000007; base[1][0] = 2000003; mod[0] = 2000003; mod[1] = 1000000007; ...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.io.*; import java.util.*; import java.math.*; public class C { public static void main(String[] args) throws IOException { /**/ Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in))); /*/ Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(new FileInputStream...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int p = 1000000007; long long int flag[1000001], fn; int read(void) { char ch; do { ch = getchar(); } while (ch < '0' || ch > '9'); int ret = 0; while (ch >= '0' && ch <= '9') { ret = ret * 10 + ch - '0'; ch = getchar(); } return ret; } bool ...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.util.HashMap; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelpe...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int maxN = 100000 + 10, maxM = 1000000 + 10; const int MOD = int(1e9 + 7); const int BB[4] = {3, 5, 7, 11}; int n, m; map<vector<int>, int> ma; long long V[maxM][4], fac[maxM]; int main() { scanf("%d%d", &n, &m); memset(V, 0, sizeof V); long long Z[4] = {1, 1, 1...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; long long int fact[100100 * 10]; vector<long long int> v[100100 * 10]; void facto(long long int m) { fact[0] = 1; for (long long int i = 1; i <= m; i++) { fact[i] = (fact[i - 1] * i) % 1000000007; } } int main() { ios::sync_with_stdio(0); cin.tie(0); long lo...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.io.*; import java.util.*; public class C { FastScanner scanner; PrintWriter writer; int MOD = 1_000_000_007; void solve() throws IOException { scanner = new FastScanner(System.in); writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); i...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
//package round391; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.InputMismatchException; import java.util.List; imp...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int p = 1000 * 1000 * 1000 + 7; int main() { int n, m; vector<long long> fact(1000001); fact[0] = 1; for (int i = 1; i < 1000001; i++) fact[i] = (i * fact[i - 1]) % p; cin >> n >> m; vector<pair<int, int>> v(m); for (int i = 0; i < n; i++) { int k; ...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; import java.util.stream.Collectors; import java.util.stream.IntStream; public class Main4 { static long ...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import sys from collections import Counter n, m = [int(u) for u in sys.stdin.readline().split()] gyms = [[int(u) for u in sys.stdin.readline().split()][1:] for i in xrange(n)] P = 10**9 + 7 types = {t: [] for t in xrange(1, m+1)} for (i, gym) in enumerate(gyms): for t in gym: types[t].append(i) for t i...
PYTHON
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
//package round391; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.math.BigInteger; import java.util.Arrays; import java.util.Comparator; import java.util.InputMismatchException; import java.util.Random; public class C { InputStream...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
//package round391; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.Comparator; import java.util.InputMismatchException; import java.util.Random; public class C4 { InputStream is; PrintWriter out; Stri...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.List; import java.util.StringTokenizer; import java.util.Set; import java.util.HashMap; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import ja...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; long long n, m, fact[1000005], x, a, has[1000006]; vector<pair<long long, long long> > vecsor; vector<vector<long long> > vec(1000006), mat(1000004); map<long long, long long> mp; map<long long, long long>::iterator it; bool func(long long x, long long y) { if (vec[x].siz...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
import javax.print.DocFlavor; import java.util.*; import java.io.*; import java.math.*; import java.lang.*; /** * Created by vishakha on 07-11-2016. */ public class Problem { public static FastReader sc = new FastReader(System.in); public static OutputWriter out = new OutputWriter(System.out); public st...
JAVA
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int MAXN = 1000010; int val[2][MAXN]; const int MOD[] = {1000000007, 1000000009}; const int QTD = 2; const int B = 97; int powers[2][MAXN]; int fact[MAXN]; int main() { int n, m; scanf(" %d %d", &(n), &(m)); for (int i = 0; i < (QTD); ++i) { powers[i][0] = 1...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; int n, m; vector<int> a[1000006]; int md = 1e9 + 7; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> m; for (int i = 1; i <= n; i++) { int u; cin >> u; for (int j = 1; j <= u; j++) { int v; cin >> v; a[v].push_back(i); ...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; long long MOD = 1e9 + 7; long long PRIME = 999727999; long long PRIME2 = 999999937; long long INF = LLONG_MAX / 4; template <class F1, class F2> ostream& operator<<(ostream& os, const pair<F1, F2>& p) { return os << p.first << ' ' << p.second; } template <class F1, class ...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const long long INF = 0x7FFFFFFFFFFFFFFF / 2; vector<int> arr[1000001]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m, g, a; cin >> n >> m; for (long long i = 1; i <= n; i++) { cin >> g; while (g--...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; template <typename T1, typename T2> inline void chkmin(T1 &x, T2 y) { if (x > y) x = y; } template <typename T1, typename T2> inline void chkmax(T1 &x, T2 y) { if (x < y) x = y; } inline int readChar(); template <class T = int> inline T readInt(); template <class T> inl...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> inline long long sbt(long long x) { return __builtin_popcount(x); } using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << std::endl; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&....
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; long long int power(long long int x, long long int y) { long long int ans = 1; while (y > 0) { if (y & 1) ans = (ans * x) % 1000000007; x = (x * x) % 1000000007; y /= 2; } return ans; } long long int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy[]...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; int dp[1000004]; int mul(int N, int M) { if (M == 0) { return 0; } if (M == 1) { return N; } return ((mul(N, M / 2) * 2) % 1000000007 + (M & 1 ? N : 0)) % 1000000007; } int fact() { dp[1] = 1; for (int i = 2; i <= 1000000; ++i) { dp[i] = mul(dp[i -...
CPP
757_C. Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has gi Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special evolution camp set up in t...
2
9
#include <bits/stdc++.h> using namespace std; const int maxm = 1000000 + 5; vector<int> g[maxm]; long long p[maxm]; const int md = 1000000000 + 7; void pre() { p[1] = 1; for (int i = 2; i <= 1000000; i++) { p[i] = i * p[i - 1] % md; } } int main() { pre(); int n, m; scanf("%d %d", &n, &m); for (int i ...
CPP