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
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.TreeMap; import java.util.StringTokenizer; import java.util.Map; import java.io.BufferedReader; 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; constexpr int MOD = 1e9 + 7; class TaskC { public: void solve(istream& in, ostream& out) { int n, m; in >> n >> m; vector<vector<int>> v(m); for (int i = 0; i < n; ++i) { int len; in >> len; for (int j = 0; j < len; ++j) { int tm...
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.io.*; import java.util.*; public class C { public static final long MOD = 1000000007; static class Gym implements Comparable<Gym> { public ArrayList<Integer> ar; Gym() { ar = new ArrayList<Integer>(); } public void add(int vl) { ar.add(vl); } ...
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], ans = 1, key; vector<long long> arr[1000005]; inline void precalc() { fact[0] = 1; fact[1] = 1; for (int i = 2; i <= n; ++i) { fact[i] = (fact[i - 1] * i) % 1000000007; } } int main() { scanf("%lld%lld", &n, &m); for (int i = 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; constexpr int MOD = 1e9 + 7; class TaskC { public: void solve(istream& in, ostream& out) { int n, m; in >> n >> m; vector<multiset<int>> v(m); for (int i = 0; i < n; ++i) { int len; in >> len; for (int j = 0; j < len; ++j) { 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
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f, MOD = 1e9 + 7, N = 1e6 + 5; int n, m, g, type, res = 1; vector<int> grupos[N]; long long fat[N]; int main() { fat[0] = fat[1] = 1; for (long long i = 2; i < N; i++) fat[i] = (fat[i - 1] * i) % MOD; scanf("%d%d", &n, &m); for (int gym = 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.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.IOException; import java.util.Random; import java.math.BigInteger; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */...
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 = 2000200; const long long MOD = 1e9 + 7; long long mult(long long a, long long b) { return (a * b) % MOD; } long long factor[MAXN]; int n, m; int it; int num[MAXN]; set<int> sets[MAXN]; int a[MAXN]; int cnt[MAXN]; vector<int> v[MAXN]; int main() { factor[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; long long i, j, n, m, t, k, a, s; vector<long long> v[1000009]; int main() { cin >> n >> m; for (i = 1; i <= n; i++) { cin >> t; for (j = 1; j <= t; j++) { cin >> a; v[a].push_back(i); } } sort(v + 1, v + m + 1); s = k = 1; for (i = 2; 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 long long mod = 1e9 + 7; vector<int> vec[1000005]; int val[500005], cnt = 1; map<int, int> ch[500005]; long long J[1000005]; int main(int argc, const char *argv[]) { cin.sync_with_stdio(false); J[0] = 1; for (int i = 1; i <= 1000000; i++) { J[i] = i * J[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; map<int, int> M; map<vector<int>, int> Map; vector<int> fr[1000005], vec[1000005]; int n, m, f[1000005]; int main() { int i, j, k, ind = 0, x; cin.sync_with_stdio(false); cin >> n >> m; for (i = f[0] = 1; i <= m; ++i) f[i] = (1LL * f[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
#include <bits/stdc++.h> using namespace std; template <class T> inline bool updateMin(T& a, T b) { return a > b ? a = b, 1 : 0; } template <class T> inline bool updateMax(T& a, T b) { return a < b ? a = b, 1 : 0; } inline int nextInt() { int x; scanf("%d", &x); return x; } inline long long nextI64() { 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 CF757C { static int M = 1000000007; static int T = 1000000; static long[] ff = new long[T + 1]; static void init() { ff[0] = 1; for (int i = 1; i <= T; i++) ff[i] = ff[i - 1] * i % M; } static class C implements Comparable<C> { int i, cnt; C(int i, in...
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 INF = 0x3fffffff; const int SINF = 0x7fffffff; const long long LINF = 0x3fffffffffffffff; const long long SLINF = 0x7fffffffffffffff; const int MAXN = 100007; const int MAXM = 1000007; const int MOD = 1e9 + 7; int n, m, ng; int ns[MAXN]; set<int> s[MAXM]; map<pair...
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 prime1 = 2473; int prime2 = 7919; long long MOD = 1000000007; long long hash1[1000005], hash2[1000006], fac[1000006]; int main() { fac[0] = 1; for (int i = 1; i < 1000001; i++) { fac[i] = (fac[i - 1] * i) % MOD; } int n; cin >> n; int m; cin >> m; 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
#include <bits/stdc++.h> using namespace std; const int N = 2e6 + 100; const int mod = 1e9 + 7; int p[N], n, m; vector<int> g[N]; int calc[N], a[N]; long long res = 1; int find(int v) { if (v == p[v]) return v; p[v] = find(p[v]); return p[v]; } void unite(int v, int u) { v = find(v); u = find(u); if (rand()...
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.PrintWriter; import java.util.StringTokenizer; import java.util.TreeMap; public class C { public static void main(String[] args) throws IOException { FastScanner scan = new FastScanner(); PrintWriter out ...
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> struct Data { int con; int poz; }; std::vector<Data> v[1000001]; int pos[1000002]; int vf[1000001]; int x[600000]; int fact[1000001]; bool cmp(int a, int b) { int i = 0; while (i < v[a].size() && i < v[b].size() && v[a][i].poz == v[b][i].poz && v[a][i].con == v[b][i].con) 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; vector<int> a[1000010]; int n, m, g, x; long long cnt = 1, ans = 1; int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) { scanf("%d", &g); for (int j = 1; j <= g; j++) scanf("%d", &x), a[x].push_back(i); } sort(a + 1, a + m + 1); for (int 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.math.BigInteger; import java.util.*; public class Template implements Runnable { BufferedReader in; PrintWriter out; StringTokenizer tok = new StringTokenizer(""); void init() throws FileNotFoundException { try { in = new BufferedReader(new FileReader...
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; long long ans = 1; long long fact[1010101]; vector<pair<int, int> > species[1010101]; vector<int> justNumber; void dealWithGym(int id) { int gi; scanf("%d", &gi); unordered_map<int, int> bank; for (int i = 0; i < gi; i++) { int tmp; scanf("%d", &tm...
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[1000111], pw[1000111], pw1[1000111]; vector<int> a[1000111]; vector<pair<int, int> > v[1000111]; pair<long long, long long> hashing(vector<pair<int, int> > v) { pair<long long, long long> h; h.first = h.second = 0LL; for (int i = 0; i < v.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
#!/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.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.List; 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 M = 1e9 + 7; vector<int> v[1000005]; int main() { int n, m; scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) { int num, x; scanf("%d", &num); for (int j = 1; j <= num; j++) { scanf("%d", &x); v[x].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 java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Comparator; import java.util.StringTokenizer; import java.util.TreeMap; public class C { public s...
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; map<vector<pair<int, int>>, int> ans; vector<pair<int, int>> pokemon[1000002]; int counti[1000002] = {}; int main() { int n; int m, t; cin >> n >> m; int total, j; for (int i = 1; i <= n; i++) { cin >> total; for (j = 1; j <= total; j++) { scanf("%d"...
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.io.*; public class C757 { static long MOD = 1000000007; static public long fact(int x) { long res = 1; for(int i=2;i<=x;i++) { res*=i; res%=MOD; } return res; } static public String toString(ArrayList<Integer> nums) { StringBuilder res = new StringBuilder(); for...
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.math.BigInteger; import java.util.*; public class Problem1 { public static final long mod = 1000000007; final static boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null; void solve() { int n = nextInt(), m = nextInt(); ArrayList<ArrayList<Intege...
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 main() { int n, m; cin >> n >> m; vector<multiset<int> > a(m, multiset<int>()); for (int i = 0; i < n; i++) { int gi; cin >> gi; for (int j = 0; j < gi; j++) { int gj; cin >> gj; a[gj - 1].insert(i); } } sort(a.begin(), a.en...
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; void smain(); int main() { ios_base::sync_with_stdio(0); smain(); return 0; } long long n, m; vector<long long> g[1000002]; pair<long long, long long> base, mod; pair<long long, long long> c[1000002]; long long f[1000002]; void add(pair<long long, long long> &x, pair<...
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 N = 100005; const double eps = 1e-9; int n; struct cmp { bool operator()(int const& lhs, int const& rhs) const { return lhs > rhs; } }; void solveAA() { int t; cin >> t; for (int z = 0; z < t; z++) { cin >> n; set<int, cmp> p; map<int, int> mp;...
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 final class round_391_c { static BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); static FastScanner sc=new FastScanner(br); static PrintWriter out=new PrintWriter(System.out); static Random rnd=new Random(); static long mod=(long)(1e9+7); ...
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 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
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(); M...
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> const long long INF = 4e18L + 1; const int IINF = 2e9 + 1; using namespace std; const long long mod = 1e9 + 7; int n, m; long long fact(int k) { if (k == 0LL) { return 1LL; } else { return (k * fact(k - 1)) % mod; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); 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.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.OutputStream; import java.util.Collection; import java.util.HashMap; import java.io.IOException; import java.io.InputStreamReader; import java.io.BufferedOutputStream; import java.util.StringT...
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 maxm = 1000005; vector<int> vec[maxm]; int n, m, t, c; long long res, tc; int main() { scanf("%d%d", &n, &m); for (int i = 0; i < n; ++i) { scanf("%d", &t); while (t--) { scanf("%d", &c); vec[c].push_back(i); } } sort(vec + 1, 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; const int N = 1000005; const int oo = 1000000007; int n, m; vector<int> poke[100005]; vector<pair<int, int> > vec[100005]; long long perm[N]; vector<pair<int, int> > a[N]; map<vector<pair<int, int> >, int> Map; int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= (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
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): for t in [int(x) for x in raw_input().split()][1:]: inv[t-1].append(i) r = 1 mod = 10**9+7 for c in Counter(x.tostring() for x in inv).itervalues(...
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 int MOD = 1e9 + 7; const int SIZE = 1e6 + 10; vector<int> d[SIZE]; int a[SIZE]; bool cmp(int x, int y) { return d[x] < d[y]; } int main() { int m, n; scanf("%d%d", &m, &n); for (int i = 0; i < (m); ++i) { int(K); scanf("%d", &K); for (int j = 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
import java.io.*; import java.util.*; public class C { BufferedReader br; PrintWriter out; StringTokenizer st; boolean eof; static Random rng = new Random(System.currentTimeMillis() + 1280375817201L); static int[] hashMult = new int[3]; static { for (int i = 0; i < hashMult.length; i++) { hashMult[i] = r...
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 s = 1099003; vector<int> gem; vector<pair<int, int> > te; vector<vector<int> > q; vector<pair<int, int> > w[s]; stack<int> stk; stack<int> sttk; stack<int> sttkja; vector<int> vec; int ja[s]; bool ju[s]; int moa[s]; int main() { int n, m, v, vv, a; cin >> 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
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; const long long mod = 1e9 + 7; long long n, m, k, x; long long a[N], b[N]; vector<long long> v[N]; int main() { ios_base::sync_with_stdio(0); int T = 1; while (T--) { cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> k; wh...
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 cnt[1000005]; int t[500005]; int vis[1000005]; long long mod = 1000000007ll; long long mod2 = 1000000000000007ll; long long sum[1000005]; long long fac[1000005]; long long x[100005]; map<long long, int> mp; map<long long, bool> ts; long long ans = 1ll; int n, m; int mai...
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 P = 1000000007; int n, m, x; int K, jc[1000001]; int tp[1000001], t_cnt; int tmp[1000001], tmp_cnt, intmp[1000001]; int sum[1000001]; int q[1000001], inq[1000001], qr; map<int, int> pyc; struct re { int a, b; bool operator()(const re &a, const re &b) { return ...
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
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.Map.Entry; import java.util.StringTokenizer; import java.util.TreeMap; import java.util.TreeSet; public class C { static f...
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; constexpr int MOD = 1000000007; template <typename T> std::istream& operator>>(std::istream& i, vector<T>& t) { for (auto& v : t) { i >> v; } return i; } template <typename T> std::ostream& operator<<(std::ostream& o, const vector<T>& t) { for (size_t i = 0; 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.util.*; import java.io.*; public class C { FastScanner in; PrintWriter out; boolean systemIO = true; public static class Link { int timeUsed; int to; public Link(int timeUsed, int to) { this.timeUsed = timeUsed; this.to = to; } } public void solve() throws IOException { int pr...
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 = 1000050; int n, m, g; vector<int> a[MaxN]; int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= n; ++i) { scanf("%d", &g); while (g--) { int x; scanf("%d", &x); a[x].push_back(i); } } sort(a + 1, a + m + 1); int t...
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.math.BigInteger; import java.util.*; public class CodecraftqC { public static void main(String[] args) { InputReader in = new InputReader(System.in); PrintWriter w = new PrintWriter(System.out); int n = in.nextInt(); int m = in.nextInt(); int a[][] = new int[n][]...
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
from collections import Counter n, m = map(int, input().split()) x = [[] for i in range(m)] for i in range(n): a = list(map(int, input().split())) k = a[0] for j in a[1:]: x[j - 1].append(i) ans = 1 MOD = 10 ** 9 + 7 for e in Counter(list(map(str, x))).values(): for i in range(2, e + 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.io.*; import java.util.*; public class CF757C { static int M = 1000000007; static int T = 1000000; static long[] ff = new long[T + 1]; static void init() { ff[0] = 1; for (int i = 1; i <= T; i++) ff[i] = ff[i - 1] * i % M; } static class C implements Comparable<C> { int i, cnt; C(int i, in...
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
from array import array from collections import Counter n,m = [int(x) for x in raw_input().split()] v = [array('i') for i 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(): v[t-1].append(i) v[t-1].append(c) mod = 10**9+7 fac =...
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; template <class T> void print_vec(const vector<T> &v, string desc = "") { cout << desc << " "; for (T e : v) { cout << e << " "; } cout << endl; } int gyms, ptypes, poks, x; vector<int> gyms_for_ptype[1000005]; const long long int MOD = 1e9 + 7; void try_add_pok...
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 N = 1e6 + 5, MOD = 1e9 + 7; int a[N], P[N]; pair<int, int> calc(const pair<int, int> &a) { return make_pair(::a[a.first], a.second); } int main() { int n, m, cnt = 1; scanf("%d%d", &n, &m); for (int i = 0; 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; long long int Mmax(long long int a, long long int b) { if (a > b) return a; return b; } long long int Mmin(long long int a, long long int b) { if (a < b) return a; return b; } long long int nod(long long int a, long long int b) { while (a && b) { if (a > 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 sys (n, m) = sys.stdin.readline().split(' ') n = int(n) m = int(m) a1097 = 1000000007 def myread(s, i): j = i lens = len(s) while j < lens and s[j] != ' ': j += 1 return (int(s[i:j]), j + 1) table = {} total = 1 for i in range(n): inp = sys.stdin.readline() si = 0 input_...
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.io.*; import java.util.*; /** * Created by Firеfly on 1/1/2017. */ public class C_Forcess { public static void main(String[] args) throws IOException { Emaxx emaxx = new Emaxx(); } } class Emaxx { FScanner fs; PrintWriter pw; long MOD = 1000000007; HashMap<Integer, Integ...
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> const int Mod = (int)1e9 + 7; const int MX = 1073741822; const long long MXLL = 4611686018427387903; const int Sz = 1110111; const int MAXN = 1e5 + 1; const int MAXM = 1e6 + 1; using namespace std; inline void Read_rap() { ios_base ::sync_with_stdio(0); cin.tie(0); } int n, m; vector<pair<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 sys from collections import defaultdict, Counter P = 10 ** 9 + 7 def factmod(n): res = 1 for i in range(2, n+1): res *= i res %= P return res def solve(): n, m = map(int, input().split()) colour = {i:0 for i in range(1, m+1)} colour_map = {} for i, line in enumerat...
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
# ---------------------------iye ha aam zindegi--------------------------------------------- import math import random import heapq, bisect import sys from collections import deque, defaultdict,Counter from fractions import Fraction import sys import threading from collections import defaultdict threading.stack_size(10...
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.io.*; import java.util.*; public class B implements Runnable { private static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null; private BufferedReader in; private PrintWriter out; private StringTokenizer tok = new StringTokenizer(""); private void init() throws...
JAVA
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
# ---------------------------iye ha aam zindegi--------------------------------------------- import math import random import heapq, bisect import sys from collections import deque, defaultdict,Counter from fractions import Fraction import sys import threading from collections import defaultdict threading.stack_size(10...
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
#!/usr/bin/env python3 from sys import stdin,stdout from math import * from collections import Counter def ri(): return map(int, stdin.readline().split()) n, m = ri() g = [[] for i in range(m)] for i in range(n): for t in list(ri())[1:]: g[t-1].append(i) ans = 1 mod = 10**9 +7 for e in Counter(list(...
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
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5, MOD = 1e9 + 7; vector<int> a[N]; int main() { int n, m; scanf("%d %d", &n, &m); for (int g, x, i = 0; i < n; i++) { scanf("%d", &g); while (g--) { scanf("%d", &x); a[x].push_back(i); } } sort(a + 1, a + 1 + m); 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.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){ this....
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 inf = 0x3f3f3f3f; const long long INF = 0x3f3f3f3f3f3f3f3fll; const int N = 1e6 + 10; const int M = 1e4 + 10; const long long mod = 1000000007; const double eps = 1e-10; const double pi = acos(-1.0); int n, m; long long cnt[N]; vector<int> ve; long long k[N]; 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
#include <bits/stdc++.h> using namespace std; long long fat[int(1e6 + 5)]; vector<int> x[int(1e6 + 5)]; const long long mod = 1e9 + 7; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m; int g, t; fat[0] = fat[1] = 1; for (int i = 2; i < int(1e6 + 5); i++) { fat[i] = (i * fat[i - 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 mod = 1E9 + 7; const double eps = 1e-6; template <typename T> T abs(T val) { return val > 0 ? val : -val; } int n, m; long long fac[1000001]; void init() { fac[0] = fac[1] = 1; for (int i = 2; i <= 1000000; i++) fac[i] = (fac[i - 1] * i) % mod; } int main() ...
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 grps = 0; int current_grp[2000009], grp_size[2000009], freq[2000009]; vector<int> v, uniques, fre_v[2000009], unique_f; vector<vector<int> > fgrps, grops; void divide_by_frequency(vector<int> v) { uniques.clear(); unique_f.clear(); fgrps.clear(); 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
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.util.Arrays; import java.util.InputMismatchException; import java.util.Random; import java.io.OutputStreamWriter; import java.util.NoSuchElementException; import java.io.OutputStream; import java.io.PrintWriter; 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; const double PI = acos(-1); const double eps = 1e-9; const int inf = 2000000000; const long long infLL = 1000000000000000000; inline bool checkBit(long long n, int i) { return n & (1LL << i); } inline long long setBit(long long n, int i) { return n | (1LL << i); ; } 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> using namespace std; const int MAX = 100000; const int MOD = 1000000007; int mult(int a, int b) { return (int)(((long long)a * (long long)b) % MOD); } vector<int> fact; void build_fact(int m) { fact.resize(m + 10); fact[1] = 1; fact[2] = 2; for (int i = 3; i < m + 5; ++i) { fact[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.*; import java.util.stream.Collectors; public class Solution { static MyScanner sc; private static PrintWriter out; static long M2 = 1_000_000_000L + 7; public static void main(String[] s) throws Exception { StringBuilder stringBuilder = new StringBuilder(); ...
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; vector<int> a[1000001]; int main() { int n, m, g, x, i, j; long long int ans, f; scanf("%d%d", &n, &m); for (i = 0; i < n; i++) { scanf("%d", &g); for (j = 0; j < g; j++) { scanf("%d", &x); a[x].push_back(i); } } sort(a + 1, a + 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
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 xrange(n): tcs = (int(x) for x in raw_input().split()) tcs.next() for t in tcs: inv[t-1].append(i) r = 1 mod = 10**9+7 for c in Counter(x.tostring()...
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> int main() { const long long MOD = 1000000007; long n, m; scanf("%ld %ld", &n, &m); std::vector<std::vector<long> > a(m); for (long p = 0; p < n; p++) { long g; scanf("%ld", &g); while (g--) { long x; scanf("%ld", &x); a[x - 1].push_back(p); } } s...
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 { private FastScanner in; private PrintWriter out; long[] fact = new long[1_000_001]; long MOD = (int) 1e9 + 7; { fact[0] = 1; for (int i = 1; i < fact.length; i++) { fact[i] = fact[i - 1] * i; fact[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
/* Author- Ayub Subhaniya Institute- DAI-ICT */ import java.util.*; import java.io.*; public class DAIPC3 { static long mod=(long)1e9+7; public static void main(String[] args){ FastScanner in = new FastScanner(); OutputWriter out = new OutputWriter(System.out); int n=in.nextInt(); int m=in.nextInt(); 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 mod = 1e9 + 7; const int N = 1e6 + 6; vector<int> a[N]; int main() { int n, m; cin >> n >> m; for (int i = 1; i <= n; i++) { int size; cin >> size; while (size--) { int num; cin >> num; a[num].push_back(i); } } sort(a + ...
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 fact[1000005]; int b1 = 109831, b2 = 109987; int m1 = 1000000007, m2 = 1000000007 + 2; vector<pair<int, int> > occ[1000005]; int p1[100005], p2[100005]; int main() { int n, m, x, y; cin >> n >> m; fact[0] = 1; for (int i = 1; i <= m; i++) fact[i] = (fact[i - 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.*; import java.math.BigInteger; import java.math.RoundingMode; import java.text.DecimalFormat; import java.util.*; import java.util.Map.Entry; public class Palindrome { // static int ans[]=new int[10]; static int count=0; static int flag=0; static double eps=(double)1e-6; static 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> using namespace std; using ll = long long; using ld = long double; using pll = pair<ll, ll>; using vll = vector<ll>; using vpll = vector<pll>; struct d_ { template <typename T> d_& operator,(const T& x) { cerr << ' ' << x; return *this; } template <typename T> d_& operator,(co...
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; char READ_DATA; int SIGNAL_INPUT; template <typename Type> inline char ru(Type &v) { SIGNAL_INPUT = 1; while ((READ_DATA = getchar()) < '0' || READ_DATA > '9') if (READ_DATA == '-') SIGNAL_INPUT = -1; else if (READ_DATA == EOF) return EOF; v = READ...
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.PrintWriter; import java.util.Arrays; import java.util.Comparator; import java.util.StringTokenizer; import static java.lang.Math.random; /** * @author Don Li */ public class FelicityIsComing { int M...
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 long long int M = 1e6 + 7; const long long int mod = 1e9 + 7; const long long int infi = LLONG_MAX; long long int i, j, ans, k, n, x, y, m, mymax = LLONG_MIN, mymin = LLONG_MAX, b, c, z, sum; map<string, long long int> ms; strin...
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; unsigned long long hash1[1000005], hash2[1000005], cnt[1000005], fact[1000005]; map<pair<unsigned long long int, pair<unsigned long long int, unsigned long long int> >, int> X; void precal() { fact[0] = 1; int i; for (i = 1; i <= 1000000; i++) fact[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.OutputStream; import java.io.IOException; import java.io.InputStream; import java.util.Arrays; import java.util.AbstractSet; import java.util.InputMismatchException; import java.util.Random; import java.util.Map; import java.io.OutputStreamWriter; import java.util.NoSuchElementException; import java.io.O...
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 in() { int x; cin >> x; return x; } template <typename T> istream &operator>>(istream &in, vector<T> &vec) { for (int i = 0; i < vec.size(); ++i) in >> vec[i]; return in; } template <typename T> ostream &operator<<(ostream &out, const vector<T> &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
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; public class Q { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); // Divide pokemon types into equivalence classes...
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; vector<pair<int, int>> L[1000005]; long long fac[1000005]; const long long MOD = 1000000007; int main() { int N, M; scanf("%d%d", &N, &M); for (int i = 0; i < N; ++i) { int g; scanf("%d", &g); map<int, int> cnt; for (int j = 0; j < g; ++j) { 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
#include <bits/stdc++.h> using namespace std; const int MAXM = 1e6 + 10; int fact[MAXM]; void mult(int &a, int b) { long long x = a * b; if (x >= 1000000007) x %= 1000000007; a = (int)x; } int mult_t(int a, int b) { long long x = a * b; if (x >= 1000000007) x %= 1000000007; return (int)x; } void init() { ...
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, x, y; vector<vector<int> > g(1000002); int main() { scanf("%d %d", &n, &m); for (int i = (1); i <= (int)(n); ++i) { scanf("%d", &x); while (x--) { scanf("%d", &y); g[y].push_back(i); } } sort(g.begin() + 1, g.begin() + 1 + m); lon...
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 xrange(n): for t in [int(x) for x in raw_input().split()][1:]: inv[t-1].append(i) r = 1 mod = 10**9+7 for c in Counter(x.tostring() for x in inv).itervalues...
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; map<int, int> fr[1000010], min_cnt[1000010]; map<int, vector<int>> cnt[1000010]; vector<pair<int, int>> ans[1000010]; map<vector<pair<int, int>>, int> grp; const long long mod = 1e9 + 7; long long fact[1000010]; void pre() { fact[0] = 1; for (long long i = 1; i < 100001...
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.StringTokenizer; import java.io.BufferedReader; import java.io.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
import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.Writer; import java.util.Arrays; import java.util.Comparator; import java.util.InputMismatchException; import java.util.Random...
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 long long mod = 1e9 + 7; vector<int> ve[1000005]; int main() { int n, m; while (~scanf("%d%d", &n, &m)) { for (int i = 0; i <= 1000000; i++) ve[i].clear(); for (int i = 0; i < n; i++) { int x; scanf("%d", &x); for (int j = 0; j < x; j++) ...
CPP