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
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
def solve(k): if k == 1: return ('a', 'a') if k == 2: return ('aa', 'a') s, p = solve((k-1) // 2) x = chr(ord(p[-1])+1) return (p+x*(2-k%2)+s[len(p):]+x*2, p+x) s, p = solve(int(input())) print(s, p)
PYTHON3
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; long long int div_floor(const long long int &a, const long long int &b) { return a / b - (((a ^ b) < 0) and a % b); } long long int div_ceil(const long long int &a, const long long int &b) { return a / b + (((a ^ b) >= 0) and a % b); } string c = "b"; pair<string, strin...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long INFF = 0x3f3f3f3f3f3f3f3fll; const long long M = 1e9 + 7; const long long maxn = 3e6 + 7; const double eps = 0.00000001; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } template <typename T> inline T abs(...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; long long a[50]; int cn[50]; int dp[5][555]; void init() { for (int i = 1; i <= 40; i++) a[i] = 1LL * i * (i + 1) * (i + 2) * (i + 3) / 24; } int get(char *t, int tn) { memset(dp, 0, sizeof dp); for (int i = tn - 1; i >= 0; i--) { dp[0][i] = dp[0][i + 1] + (t[...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; const int MAXN = 210; int n; int f[MAXN][MAXN]; int c[MAXN][MAXN]; string ins; int dp(string s1, string s2) { f[0][0] = 1; for (int i = 0; i < s1.length(); i++) { for (int j = 0; j < s2.length(); j++) { f[i + 1][j] += f[i][j]; if (s1[i] == s2[j]) f[i + 1...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; int n; string a, b; char c; void Work(int len) { if (len == 1) { c = 'A', a = "", b = c; } else if (len == 2) { c = 'B', a = "B", b = "AB"; } else if (len & 1) { Work(len >> 1); ++c, a = a + c + c, b = b + c; } else { Work((len >> 1) - 1); ++...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; inline long long read() { register long long x = 0, f = 0; register char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = 1; c = getchar(); } while (c >= '0' && c <= '9') x = (x << 3) + (x << 1) + (c ^ '0'), c = getchar(); return f ? -x ...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll dp[30][8] = {}; dp[0][0] = 1; for (int(i) = 0; (i) < (int)(25); ++(i)) for (int(j) = 0; (j) < (int)(8); ++(j)) for (int(k) = 0; (k) < (int)(8); ++(k)) if (j <= k) dp[i + 1][k] += dp[i][j]; ll n; cin >> n; l...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; using vpii = vector<pii>; using vi = vector<int>; using vvi = vector<vi>; using ll = long long; using vll = vector<long long>; template <class T> using min_queue = priority_queue<T, vector<T>, greater<T>>; template <class T> istream &operator>>(i...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; long long val(long long n) { return (n * (n - 1) * (n - 2) * (n - 3) * (n - 4)) / 120; } signed main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); ; long long n; cin >> n; vector<long long> cnt(51, 0); for (long long i = 50; i >= 5; i--) { long lon...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; int N, pt[205], blen = 1000000000; long long a[205]; string ba, bb; int main() { scanf("%d", &N); int tN = N; for (int R = 3; R <= 9; R++) { N = tN; for (int i = 0; i < 200; i++) a[i] = 1; for (int i = 0; i < R; i++) { for (int j = 1; j < 200; j++) a...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; deque<char> ch; void M2P1(string& lp, string& rp) { auto c = ch[0]; ch.pop_front(); lp = string(2, c) + lp; rp = string(1, c) + rp; } void P1(string& lp, string& rp) { auto c = ch[0]; ch.pop_front(); lp = string(1, c) + lp; rp = string(1, c) + rp; } void Sol...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; int n; char now; string s, t; void solve(int len) { if (len == 1) { s = ""; t = "a"; now = 'a'; return; } if (len == 2) { s = "b"; t = "ab"; now = 'b'; return; } if (len % 2 == 0) { solve(len / 2 - 1); now++; s = now + s...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; int a[11], n, cnt[11]; int main() { a[1] = 1; for (int k = 2; k <= 10; k++) a[k] = a[k - 1] * (k + 9) / (k - 1); scanf("%d", &n); for (int k = 10; k >= 1; k--) { while (n >= a[k]) { cnt[k]++; n -= a[k]; } } for (int k = 1; k <= 10; k++) { ...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; int Comb[110][6], C[110], S; int main() { int i, j; for (i = 0; i <= 45; i++) { Comb[i][0] = 1; for (j = 1; j <= 5 && j <= i; j++) Comb[i][j] = Comb[i - 1][j] + Comb[i - 1][j - 1]; } scanf("%d", &S); for (i = 45; i >= 5; i--) { while (S >= Comb[i...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> inline void chkmax(T& x, U y) { if (x < y) x = y; } template <typename T, typename U> inline void chkmin(T& x, U y) { if (y < x) x = y; } const int N = 1000000 + 10; int hd[N]; char pat[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRS...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; int C[50][50]; int main() { C[0][0] = 1; for (int i = 1; i <= 30; i++) { C[i][0] = C[i][i] = 1; for (int j = 1; j <= 30; j++) { C[i][j] = C[i - 1][j] + C[i - 1][j - 1]; } } string p = "aaaaaaaaab"; int pSize = (int)p.size() - 1; string result =...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; long long n; char now; string s, t; inline void solve(int len) { if (len == 1) { s = ""; t = "a"; now = 'a'; return; } if (len == 2) { s = "b"; t = "ab"; now = 'b'; return; } if (len & 1) { solve(len / 2); now++; s = s +...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; template <class T> ostream& operator<<(ostream& stream, const vector<T> v) { stream << "[ "; for (int i = 0; i < (int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream; } long long fpow(long long x, long long p, long long m) { long long r = 1; f...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; long long n; string s, p; long long bin[34][34]; void read() { cin >> n; for (int i = 0; i <= 30; i++) { bin[i][0] = bin[i][i] = 1; for (int j = 1; j < i; j++) { bin[i][j] = bin[i - 1][j - 1] + bin[i - 1][j]; } } } void solve() { string res = ""; ...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; pair<string, string> Solve(int n) { if (n == 1) return pair<string, string>("a", "a"); if (n == 2) return pair<string, string>("abb", "ab"); if (n % 2 == 0) { pair<string, string> a = Solve(n / 2 - 1); char c = char(a.second[(int)a.second.size() - 1] + 1); ...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using db = double; int n; const int N = 18; int main() { cin >> n; string s, p; for (int i = 0; i < N; ++i) p.push_back('a' + i); s = p; for (int i = 2; i <= N; ++i) for (int j = N - i; j < N; ++j) s.push_back('a' ...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; template <typename A, typename B> inline void chmin(A &a, B b) { if (a > b) a = b; } template <typename A, typename B> inline void chmax(A &a, B b) { if (a < b) a = b; } string S; long long dp[3333333]; signed main() { for (long long i = 0; i < 26; i++) S += (char)('a...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; inline int readInt() { static int n, ch; n = 0, ch = getchar(); while (!isdigit(ch)) ch = getchar(); while (isdigit(ch)) n = n * 10 + ch - '0', ch = getchar(); return n; } const int MAX_N = 1000000 + 3; string s, p; void solve(int n) { if (n == 1) { s = p = ...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; int n; int op[200]; int cnt = 0; void dfs(int n, int k) { if (n == 0) { cnt = k; return; } if (n & 1) { dfs((n - 1) / 2, k + 1); op[k] = 1; } else { dfs((n - 2) / 2, k + 1); op[k] = 2; } } int main() { while (cin >> n) { dfs(n, 0); ...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; int n; char now; string s, t; void solve(int len) { if (len == 1) { s = ""; t = "a"; now = 'a'; return; } if (len == 2) { s = "b"; t = "ab"; now = 'b'; return; } if (len % 2 == 0) { solve(len / 2 - 1); now++; s = now + s...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7, INF = 9e18; const int inf = 2e9; vector<string> ans; string f(int l, int r) { string s = ""; for (int i = l; i <= r; i++) { s += (char)((int)'a' + i); } return s; } string f2(int l, int r) { string s = ""; for (int i = l; i <= ...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; template <class T> int getbit(T s, int i) { return (s >> i) & 1; } template <class T> T onbit(T s, int i) { return s | (T(1) << i); } template <class T> T offbit(T s, int i) { return s & (~(T(1) << i)); } template <class T> int cntbit(T s) { return __builtin_popcnt(...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; int n; string s, p; char c; void solve(int x) { if (x == 1) { s = "", p = "a", c = 'a'; return; } if (x == 2) { s = "b", p = "ab", c = 'b'; return; } if (!(x & 1)) { solve((x >> 1) - 1); ++c; s = c + s + c + c; p = p + c; return...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; const int N = 30; const int K = 4; int C[N + 1][K + 1]; int main() { for (int i = 0; i <= N; ++i) { for (int j = 0; j <= K; ++j) { if (i == 0 || j == 0) { C[i][j] = 1; } else { C[i][j] = C[i - 1][j] + C[i][j - 1]; } } } for (i...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; int main() { string s; int cnt[6]; int val[105]; memset(cnt, 0, sizeof(cnt)); s += "abcde"; for (int i = 0; i < 95; i++) { s += (char)(rand() % 5 + 'a'); } for (int i = 0; s[i] != 0; i++) { if (s[i] == 'a') cnt[0]++; else cnt[s[i] - '...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; using ll = long long; ll comb(ll n, ll k) { ll res = 1; for (int i = 0; i < k; i++) { res *= (n - i); } for (int i = 1; i <= k; i++) { res /= i; } return res; } int main() { ll n; cin >> n; string res; for (int i = 30; i >= 0; i--) { ll a = n...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; template <class S, class T> ostream& operator<<(ostream& o, const pair<S, T>& p) { return o << "(" << p.first << "," << p.second << ")"; } template <class T> ostream& operator<<(ostream& o, const vector<T>& vc) { o << "sz = " << vc.size() << endl << "["; for (const T&...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; long long int power(long long int x, long long int y) { long long int res = 1; while (y) { if (y & 1) res = (res * x) % 1000000007; y = y / 2, x = (x * x) % 1000000007; } return res % 1000000007; } pair<string, pair<string, string> > func(long long int n) { ...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; char str[200], ans[201]; int dp[200], ins[200]; int main() { int n; cin >> n; for (int i = 0; i < 120; i += 4) { str[i] = 'a'; str[i + 1] = 'b'; str[i + 2] = 'c'; str[i + 3] = 'd'; if (i) { dp[i] = dp[i - 4] + 1; dp[i + 1] = dp[i - 3] +...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return x * f; } int num[50 + 5], n, C[5...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; int inline read() { int x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return x * f; } int jilu[12], n, i, j, ...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; const int maxn = 201; int a[maxn]; char t[maxn], s[maxn]; char c[30] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D'}; int main() { int n; ...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; long long n; long long fac[200005]; vector<char> vr; long long check(long long x) { vr.clear(); long long temp = n, st = -1; for (int i = x;; i++) { long long pr = 1; for (int j = i; j > i - x; j--) pr = pr * j; pr /= fac[x]; if (pr > temp) { st ...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; string s1, s2, a = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; int n, cnt; int main() { cin >> n; while (--n) { if (n % 2) { s1 = s1 + a[cnt]; ++cnt; } else { s1 = s1 + a[cnt] + a[cnt]; ++cnt; n /= 2; } } for (in...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; long long n; char now; string s, t; void work(int len) { if (len == 1) { s = ""; t = "a"; now = 'a'; return; } if (len == 2) { s = "b"; t = "ab"; now = 'b'; return; } if (len % 2 == 0) { work(len / 2 - 1); now++; s = now...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; int n; char now; string s, t; void dd(int l) { if (l == 1) { s = ""; t = "a"; now = 'a'; return; } if (l == 2) { s = "b"; t = "ab"; now = 'b'; return; } if (l % 2 == 0) { dd(l / 2 - 1); now++; s = now + s + now + now; ...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; const char alpha[70] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; int main() { int n; scanf("%d", &n); int p = 0; int cnt[205] = {0}; if (n == 1) { printf("a a\n"); return 0; } while (n != 1) { n--; if (n % 2 == 0) { cnt[p] =...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; const int N = 100; long long binom[N][N]; int main() { ios_base::sync_with_stdio(0), cin.tie(0); for (int i = 0; i < N; i++) { binom[i][0] = binom[i][i] = 1; for (int j = 1; j < i; j++) binom[i][j] = binom[i - 1][j] + binom[i - 1][j - 1]; } int n; ci...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; const int MAXS = 201; int N; char letter; char s[MAXS], p[MAXS]; void solve(int n) { if (n == 1) { s[0] = 'a'; p[0] = 'a'; letter = 'b'; return; } if (n == 2) { s[0] = s[1] = 'a'; p[0] = 'a'; letter = 'b'; return; } if (n % 2 == 0) ...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; template <class T1, class T2> istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second; } template <class T1, class T2> ostream &operator<<(ostream &os, pair<T1, T2> &p) { return os << p.first << " " << p.second; } pair<string, string> solve(...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
import java.io.*; import java.util.*; public class fake_news_medium { public static void main(String hi[]) throws Exception { BufferedReader infile = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(infile.readLine()); int N = Integer.parseInt(st....
JAVA
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; string p = "abcdef"; string s = "aabcdef"; int Count(int i, int j) { if (i == p.size()) return 1; if (j == s.size()) return 0; int res = Count(i, j + 1); if (p[i] == s[j]) { res += Count(i + 1, j + 1); } return res; } const int N = 200; int x[N]; int a[N]; i...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 100; int MAX; void solve(int n) { string res; for (int i = 72; i >= 1; i--) { int each = i * (i - 1) * (i - 2) * (i - 3) / 24; if (each) { int c = n / each; n %= each; while (c--) { res.insert(res.begin(), 'B'); ...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; const int SIZE = 3e5 + 5; const long long INF = 1e14 + 5; const long long MOD = 1e9 + 7; struct abc { int num; int pos; }; bool operator<(abc a, abc b) { if (a.pos != b.pos) { return a.pos > b.pos; } return a.num > b.num; } int gcd(int a, int b) { while (b) ...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; int main() { ios::sync_with_stdio(0); cin.tie(0); string ans, pat; for (int i = 0; i < 20; i++) ans += char('a' + i); pat = ans + char('a' + 20); int n; cin >> n; int t = 18; for (int j = 0; j < t; j++) { int till = 19; if (n...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; const int maxn = 201; int a[maxn]; char t[maxn], s[maxn]; char c[30] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D'}; int main() { int n; ...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; vector<int> ord; while (n > 2) { ord.push_back(n); if (n % 2 == 0) { n = n / 2 - 1; } else { n = n / 2; } } string s, p; if (n == 1) { ...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; string s; int poly(int n) { return (n * n * n + 3 * n * n + 2 * n) / 6; } int n; int val[N]; int main() { scanf("%d", &n); int ile_bedzie = 38; int znaki = 0; val[1] = 1; for (int i = 1; i <= 1000; ++i) val[i] = val[i - 1] + poly(i); while...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
import string alphabet = list(string.ascii_lowercase + string.ascii_uppercase) def calc(n): if n == 1: return '', 'a' if n == 2: return 'a', 'a' if n % 2 == 1: u, p = calc(n//2) x = alphabet.pop() return u+x+x, p+x else: u, p = calc(n//2-1) x = a...
PYTHON3
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; string t, p; int s, c = 3; string abc[60]; void add(int x) { if (x == 1) { t = p = "A"; return; } if (x == 2) { t = "AA"; p = "A"; return; } if (x % 2) { add((x - 1) / 2); t.insert(t.size() - p.size(), abc[c]); t.insert(0, abc[c]); ...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
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.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; import java.util.ArrayList; ...
JAVA
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; long long pow(long long x) { return x * (x - 1) * (x - 2) * (x - 3) / 24; } int main() { long long n; cin >> n; long long i = 0; while (pow(i + 1) <= n) { i++; } long long As = i; vector<int> v; while (n) { for (int i = As; i > 0; i--) { if (po...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; int c[210][210], t[210], a[210]; int main() { cin.tie(0); ios_base::sync_with_stdio(false); for (int i = 1; i < 210; i++) c[i][0] = c[i][i] = 1; for (int i = 1; i < 210; i++) for (int j = 1; j < i; j++) c[i][j] = c[i - 1][j - 1] + c[i - 1][j]; for (int i = 0; ...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:102400000,102400000") using namespace std; template <class T, class U> inline void Max(T &a, U b) { if (a < b) a = b; } template <class T, class U> inline void Min(T &a, U b) { if (a > b) a = b; } inline void add(int &a, int b) { a += b; while (a >= 10000...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; template <class T, class U> ostream& operator<<(ostream& o, const pair<T, U>& p) { o << "(" << p.first << "," << p.second << ")"; return o; } template <class T> ostream& operator<<(ostream& o, const vector<T>& v) { o << "["; for (T t : v) { o << t << ","; } ...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; int n; char now; string s, t; void solve(int len) { if (len == 1) { s = ""; t = "a"; now = 'a'; return; } if (len == 2) { s = "c"; t = "ac"; now = 'c'; return; } if (len % 2 == 0) { solve(len / 2 - 1); now++; s = now + s...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; long long tests; long long n, m, z[505], j = 'a'; bool ok; string s; void solve() { cin >> n; m = 80; while (n) { while ((m * (m - 1) * (m - 2) * (m - 3)) / 24 > n) m--; n -= (m * (m - 1) * (m - 2) * (m - 3)) / 24; z[m]++; } for (int i = 1; i < 80; i++...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; string s = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; int main() { string res1, res2; int n = 0, len = 0; cin >> n; while (--n) { if (n % 2) { res1 = res1 + s[len]; ++len; } else { res1 = res1 + s[len] + s[len]; ++len; ...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; int Comb[110][6], C[110], S; int main() { int i, j; for (i = 0; i <= 45; i++) { Comb[i][0] = 1; for (j = 1; j <= 5 && j <= i; j++) Comb[i][j] = Comb[i - 1][j] + Comb[i - 1][j - 1]; } scanf("%d", &S); for (i = 45; i >= 5; i--) { while (S >= Comb[i...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; long long n, da = 6, db = 2, a = 5; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n; while (a <= n) a = a * da++ / db++; --da, --db, a = a * db / da, --da, --db; string ans = string(da, 'a'); while (a <= n) n -= a, ans += "b"; while (a !=...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; long long n; string s; long long c[101]; int32_t main() { cin >> n; for (long long i = 4; i <= 100; i++) { long long now = 1; for (long long j = 0; j < 4; j++) { now *= (i - j); } for (long long j = 0; j < 4; j++) { now /= (j + 1); } ...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; long long int dp[202][4]; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); dp[0][0] = 1; for (long long int i = 1; i <= 200; i++) { for (long long int j = 0; j <= 3; j++) { dp[i][j] = dp[i - 1][j]; if (j > 0) { dp[...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; long long int n; string ans; long long int high, low; long long int comb4(long long int x) { return x * (x - 1) * (x - 2) * (x - 3) / 24; } int main() { scanf("%I64d", &n); ans = "a"; low = -1; high = 101; while (high - low > 1) { long long int mid = (high +...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; string s, p; void dfs(int n, char x) { if (n == 1) { s = s + x; p += x; return; } if (n == 2) { s = s + x + x; p += x; return; } if (n % 2) { dfs(n / 2, x + 1); s = p + x + s.substr(p.size(), s.size() - p.size() + 1) + x + x; p ...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; const int MAX = 1e6 + 10; int getlen(int b) { int ans = 0; while (b) { ans++; b >>= 1; } return ans; } string p, s; void slove(int now, int deep) { string cnt; cnt += ((char)('a' + deep)); if (now == 1) { p = s = cnt; return; } else if (now =...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; long long n; char now; string s, t; inline void solve(int len) { if (len == 1) { s = ""; t = "a"; now = 'a'; return; } if (len == 2) { s = "b"; t = "ab"; now = 'b'; return; } if (len & 1) { solve(len / 2); now++; s = s +...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; pair<string, string> sq(int n, char& next) { if (n == 2) return {"a", "a"}; if (n == 1) return {"", "a"}; auto x = next; next = (next == 'z' ? 'A' : next + 1); if (n % 2) { auto [u, p] = sq(n / 2, next); return {u + x + x, p + x}; } auto [u, p] = sq(n ...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; string p, u; char c; void solve(int x) { if (x == 1) return p = "", c = 'a', p += c, u = "", c++, void(); else if (x == 2) return solve(x / 2), p = p + c, u = u + c, c++, void(); else if (x & 1) return solve((x - 1) / 2), p = p + c, u = u + c + c, c++, voi...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; bool debug = 0; int n, m, k; int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; string direc = "RDLU"; long long ln, lk, lm; void etp(bool f = 0) { puts(f ? "YES" : "NO"); exit(0); } void addmod(int &x, int y, int mod = 1000000007) { x += y; if (x >= mod) x -= mod; ...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; char aux[] = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM"; int n, p; int main() { cin >> n; if (n == 1) { cout << "a a"; return 0; } --n; while (n) { if (n % 2 == 1) { cout << aux[p]; ++p, --n; } else { cout << aux[p] <<...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; long long n; char now; string s, t; inline long long read() { long long x = 0; bool f = 0; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) f ^= (ch == '-'); for (; isdigit(ch); ch = getchar()) x = (x << 3) + (x << 1) + (ch ^ 48); return f ? -x : x; } i...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; const int INF = 0x3f3f3f3f, N = 2e5 + 5; inline int read() { int sum = 0, f = 1; char c = getchar(); while (c > '9' || c < '0') { if (c == '-') f = -f; c = getchar(); } while (c >= '0' && c <= '9') sum = su...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; void file_put() { freopen("filename.in", "r", stdin); freopen("filename.out", "w", stdout); } const int N = 105; int n = 100, k, a[N], num[N], s = 0, p = 0; int C(int n) { return n * (n - 1) * (n - 2) / 6; } int main() { scanf("%d", &k); for (int i = (1); i < (n + 1...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; long long c[210][5], n; vector<char> res; int main(void) { c[0][0] = 1; for (int i = 1; i <= 200; i++) { c[i][0] = 1; for (int j = 1; j <= 5; j++) c[i][j] = c[i - 1][j] + c[i - 1][j - 1]; } cin >> n; int r = 125; while (c[r][4] > n) r--; for (int i = r...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> const int F[8] = {1, 21, 231, 1771, 10626, 53130, 230230, 888030}; int N, f[1000001], c[1000001], U[8]; int main() { f[0] = 0; for (int i = 1; i <= 1000000; i++) f[i] = 1000000000; for (int i = 0; i < 8; i++) for (int j = F[i]; j <= 1000000; j++) if (f[j - F[i]] + 1 < f[j]) { ...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; const int T = 700; const long long f[] = {0LL, 1LL, 8LL, 36LL, 120LL, 330LL, 792LL, 1716LL, ...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; string s = "FESTIVAL"; long long dp[1010][10]; int a[1010]; int main(void) { int i, j, k; dp[0][0] = 1; for ((i) = 0; (i) < (int)(1000); (i)++) for ((j) = 0; (j) < (int)(8); (j)++) for ((k) = 0; (k) < (int)(8); (k)++) if (j <= k) dp[i + 1][k] = min(d...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
import java.util.Arrays; import java.util.Scanner; public class H { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { int N = sc.nextInt(); int[][] c = new int[10][10]; for (int i = 0; i < c[0].length; i++) { c[0][i] = i + 1; } for (int i = 1; i < c.len...
JAVA
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; const int N = 4e5 + 5; int n; int main() { ios_base::sync_with_stdio(0); ; cin >> n; vector<int> v; if (n == 1) { cout << "a a\n"; return 0; } while (n > 2) { if (n & 1) { v.push_back(1); } else { v.push_back(2); n -= 2; }...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; stack<int> st; int n; string str, pat; int main() { str = ""; pat = ""; cin >> n; while (n) { if (n % 2) st.push(1), n = (n - 1) / 2; else st.push(0), n = (n - 2) / 2; } int curr, cont = 0; string ch = " "; while (!st.empty()) { curr ...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; int IN() { int c, f, x; while (!isdigit(c = getchar()) && c != '-') ; c == '-' ? (f = 1, x = 0) : (f = 0, x = c - '0'); while (isdigit(c = getchar())) x = (x << 1) + (x << 3) + c - '0'; return !f ? x : -x; } string s, t, alp = "abcdefghijklmnopqrstuvwxyzABCDEF...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; int dp[4][100]; int main() { int n, f = 25, m = 100; dp[0][0] = 1; cin >> n; string a = ""; while (f--) a += "abcd"; a += " abcde"; for (int l = 0; l < 4; l++) for (int i = 1; i < 100; i++) dp[l][i] = dp[l][i - 1] + ((i % 4 == l) ? ((l == 0...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; string s1, s2, a = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; int cnt = 0; int main() { int n; scanf("%d", &n); while (--n) { if (n % 2) { s1 += a[cnt++]; } else { s1 += a[cnt]; s1 += a[cnt++]; n /= 2; } } for (int ...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
def getstr(n): if n==1: return 'a','',1 elif n==2: return 'ab','b',2 else: if n%2==0: p,u,now=getstr((n-2)//2) c = chr(ord('a')+now) return p+c,c+u+c+c,now+1 else: p,u,now=getstr((n-1)//2) c = chr(ord('a')+now) ...
PYTHON3
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; int fx[] = {-1, +0, +1, +0, +1, +1, -1, -1, +0}; int fy[] = {+0, -1, +0, +1, +1, -1, +1, -1, +0}; int day[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; template <typename T> inline bool isLeap(T y) { return (y % 400 == 0) || (y % 100 ? y %...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; pair<string, string> solve(int n) { if (n <= 4) { return {string(n, 'a'), string("a")}; } if (n % 2) { auto prv = solve(n / 2); string s = prv.first; string p = prv.second; char c = max(*max_element((s).begin(), (s).end()), *max_el...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; long long n; char aa; string a, q; inline long long read() { long long x = 0; bool f = 0; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) f ^= (ch == '-'); for (; isdigit(ch); ch = getchar()) x = (x << 3) + (x << 1) + (ch ^ 48); return f ? -x : x; } in...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; const int N = 35; int c[N][N]; int cnt[N]; int main() { for (int i = 0; i < N; i++) { c[i][0] = 1; for (int j = 1; j <= i; j++) c[i][j] = c[i - 1][j] + c[i - 1][j - 1]; } int n; cin >> n; for (int i = N - 1; i >= 6; i--) while (n >= c[i][6]) { n ...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; string arr[52]; void solve() { int n; cin >> n; vector<int> path; int m = n; path.push_back(m); while (m > 2) { if (m % 2) { path.push_back((m - 1) / 2); m = (m - 1) / 2; } else { path.push_back((m - 2) / 2); m = (m - 2) / 2; ...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; string p, s; int n; void dfs(int n, char c) { if (n == 1) { s += c, p += c; return; } else if (n == 2) { s += c, s += c, p += c; return; } if (n & 1) { dfs(n / 2, c + 1); s = p + c + s.substr(p.size(), s.size() - p.size() + 1) + c + c, p += c...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; pair<pair<string, string>, string> solve(int n) { if (n == 1) { return {{"a", ""}, "a"}; } if (n == 2) { return {{"a", "a"}, "a"}; } int k = n - 1 >> 1; auto res = solve(k); string c = ""; c += res.second[res.second.size() - 1] + 1; if (k * 2 + 1 =...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 10; long long f[maxn]; long long C(int n, int m) { return f[n] / f[m] / f[n - m]; } int main() { int n; scanf("%d", &n); f[0] = 1; for (int i = 1; i <= 20; i++) f[i] = f[i - 1] * i; string s, p = "abbbbbbbb"; int lenp = 8; for (int i = 2...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; char c = 'a'; pair<string, string> gen(int n) { ; if (n == 1) return {"a", ""}; else if (n == 2) return {"a", "a"}; else if (n & 1) { pair<string, string> res = gen((n - 1) / 2); c++; return {res.first + string(1, c), res.second + string(2, c)}; ...
CPP
802_H. Fake News (medium)
Thanks to your help, Heidi is confident that no one can fool her. She has now decided to post some fake news on the HC2 Facebook page. However, she wants to be able to communicate to the HC2 committee that the post is fake, using some secret phrase hidden in the post as a subsequence. To make this method foolproof, she...
2
14
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } int n; char a[100]; int na; char b[100]; int nb; char get(int x) { if (x < 26) return 'a' + x; if (x < 52) return 'A' + (x - 26); assert(false); return '?'; } void run() { scanf("%d", &...
CPP