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
1379_E. Inverse Genealogy
Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in...
2
11
def ng():print("NO");exit() n, k = map(int,input().split()) if (n,k)==(1,0):print("YES");print(0);exit() ans = [0] * n;u = 0;popcnt = lambda x: bin(x).count("1") if n & 1 == 0 or n < 2 * k + 3 or (popcnt(n + 1) > 1 and k == 0): ng() if popcnt(n + 1 - 2 * (k - 1)) == 1: for v in range(1, 4): ans[v] = v // 2+1 k ...
PYTHON3
1379_E. Inverse Genealogy
Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in...
2
11
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 7; int s[MAXN]; int isComplete(int n) { return (n & (n + 1)) == 0; } int gen(int n, int niche) { for (int i = 2; i <= niche; i += 2) { s[i] = i / 2; s[i + 1] = i / 2; } int last = 1; for (int i = niche + 1; i <= n; i += 2) { s[i] =...
CPP
1379_E. Inverse Genealogy
Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in...
2
11
#include <bits/stdc++.h> using namespace std; int ans[100010]; void solve(const int &l, const int &r, const int &k); inline char legal(const int &N, const int &k) { if (N < 0 || k < 0) return false; char flag; int n = N + 1 >> 1; if (n == 1) flag = !k; else if (n == 5) flag = (k == 1 || k == 3); els...
CPP
1379_E. Inverse Genealogy
Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in...
2
11
import java.io.*; import java.util.*; public class Solution { int bound = 100000; int N = 31; private void solve() throws Exception { memo = new Boolean[N+1][N+1]; nodes = new Node[N+1][N+1]; // for(int i = 1; i <= n; i+=2) { // String a = String.format("%3d", i); /...
JAVA
1379_E. Inverse Genealogy
Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in...
2
11
#include <bits/stdc++.h> using namespace std; inline int read() { char ch = getchar(); int nega = 1; while (!isdigit(ch)) { if (ch == '-') nega = -1; ch = getchar(); } int ans = 0; while (isdigit(ch)) { ans = ans * 10 + ch - 48; ch = getchar(); } if (nega == -1) return -ans; return ans...
CPP
1379_E. Inverse Genealogy
Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in...
2
11
#include <bits/stdc++.h> using namespace std; const int maxn = 100009; int judge(int n, int k) { if (k < 0) return 0; if (n % 2 == 0) return 0; if (k == 0) { if (__builtin_popcount(n + 1) == 1) return 1; else return 0; } if (k == 1) { if (__builtin_popcount(n + 1) == 1) return 0;...
CPP
1379_E. Inverse Genealogy
Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in...
2
11
#include <bits/stdc++.h> using namespace std; mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count()); const long long inf = 1e15 + 7; bool check(long long n) { return __builtin_popcount(n + 1) == 1; } vector<long long> res; bool solve(long long n, long long k, long long par) { if (n == 11 && k =...
CPP
1379_E. Inverse Genealogy
Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in...
2
11
#include <bits/stdc++.h> using namespace std; int n, k; inline int lowbit(int x) { return x & -x; } void get_lian(int num) { printf("0 "); for (int i = 1; i <= num; i++) { printf("%d %d ", i * 2 - 1, i * 2 - 1); } } void get_binary(int root, int num) { for (int i = 2; i <= num; i++) { printf("%d ", i / ...
CPP
1379_E. Inverse Genealogy
Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in...
2
11
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005; int cnt; int par[MAXN], br[MAXN]; void solve(int n, int k, int root) { if (n == 0) return; int curr = ++cnt; par[curr] = root; if (k == 0) { solve((n - 1) / 2, 0, curr); solve((n - 1) / 2, 0, curr); } else if (k == 1) { int pot...
CPP
1379_E. Inverse Genealogy
Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in...
2
11
#include <bits/stdc++.h> using namespace std; int n, k, fa[100005]; bool check(int x) { return x - (x & -x) == 0; } int main() { scanf("%d%d", &n, &k); int mx = max((n - 3) / 2, 0); if (k > mx || (n % 2 == 0) || (n == 9 && k == 2) || (check(n + 1) && k == 1) || (!check(n + 1) && k == 0)) { printf("NO");...
CPP
1379_E. Inverse Genealogy
Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in...
2
11
from heapq import * import sys int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)]...
PYTHON3
1379_E. Inverse Genealogy
Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in...
2
11
def ng(): print("NO") exit() n, k = map(int,input().split()) if (n,k)==(1,0): print("YES") print(0) exit() ans = [0] * n popcnt = lambda x: bin(x).count("1") if n & 1 == 0 or n < 2 * k + 3 or (popcnt(n + 1) > 1 and k == 0): ng() u = 0 if popcnt(n + 1 - 2 * (k - 1)) == 1: for v in range(1, 4)...
PYTHON3
1379_E. Inverse Genealogy
Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in...
2
11
#include <bits/stdc++.h> using namespace std; int mx(int u) { if (u < 5) return 0; return (u - 3) / 2; } bool can(int u, int v) { if (u == 9 && v == 2) { return false; } if ((u & 1) == 0) { return false; } if (v == 0) { return __builtin_popcount(u + 1) == 1; } if (v > 1) { return mx(u)...
CPP
1379_E. Inverse Genealogy
Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in...
2
11
#include <bits/stdc++.h> using namespace std; int fa[100005]; void js() { puts("NO"); exit(0); } int check(int x) { return x == (x & -x); } int main() { int n, k; scanf("%d%d", &n, &k); if (!(n & 1)) js(); if (k > max(0, (n - 3) / 2)) js(); if (check(n + 1) && k == 1) js(); if (!check(n + 1) && k == 0) ...
CPP
1379_E. Inverse Genealogy
Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in...
2
11
#include <bits/stdc++.h> const int maxn = 1e5 + 5; const int pow2 = 1 << 20; int fa[maxn], N; int cnt = 1; void dfs(int o, int n, int k) { if (k <= 1) { for (int i = o + 1; i <= n; i++) fa[i] = (i - o + 1) / 2 + o - 1; if (k == 1 && pow2 % (n - o + 2) == 0) { fa[n] = N; fa[n - 1] = N; } re...
CPP
1379_E. Inverse Genealogy
Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in...
2
11
#include <bits/stdc++.h> using namespace std; template <class TH> void _dbg(const char *sdbg, TH h) { cerr << sdbg << '=' << h << endl; } template <class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) { while (*sdbg != ',') cerr << *sdbg++; cerr << '=' << h << ','; _dbg(sdbg + 1, a...); } template ...
CPP
1379_E. Inverse Genealogy
Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in...
2
11
#include <bits/stdc++.h> using namespace std; inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; } inline int msbp(int x) { return 31 - __builtin_clz(x); } inline int msb(int x) { return 1 << msbp(x); } const int INF = 0x3f3f3f3f; const int N = 1e5 + 10; void bad() { cout << "NO" << endl; exit(0); } in...
CPP
1379_E. Inverse Genealogy
Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in...
2
11
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.StringTokenizer; import java.io.BufferedReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
JAVA
1379_E. Inverse Genealogy
Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in...
2
11
#include <bits/stdc++.h> const int bufSize = 1e6; inline char nc() { static char buf[bufSize], *p1 = buf, *p2 = buf; return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, bufSize, stdin), p1 == p2) ? EOF : *p1++; } template <typename T> inline T read(T &r) { static char c; r = 0; for (...
CPP
1379_E. Inverse Genealogy
Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in...
2
11
#include <bits/stdc++.h> using namespace std; int n, k; inline int lowbit(int x) { return x & (-x); } bool check() { if (n % 2 == 0) return 0; if (max((n - 3) / 2, 0) < k) return 0; if (n == 9 && k == 2) return 0; if (n + 1 == lowbit(n + 1) && k == 1) return 0; if (n + 1 != lowbit(n + 1) && k == 0) return 0; ...
CPP
1379_E. Inverse Genealogy
Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in...
2
11
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 7; int ans[maxn]; int lowbit(int x) { return x & -x; } bool is_two(int x) { return x == lowbit(x); } bool dfs(int n, int k, int id) { if (k == 1) { printf("%d %d %d\n", n, k, id); if (is_two(n)) { return false; } ans[id] = max(...
CPP
1379_E. Inverse Genealogy
Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in...
2
11
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 7; bool isbalanced(int x, int y) { return (2 * x > y && 2 * y > x); } bool ispow(int x) { return (__builtin_popcount(x + 1) == 1); } int getdep(int x) { return __builtin_ctz(x + 1); } int n, k, cnt; int ans[MAXN]; void build(int fa, int dep) { if (d...
CPP
1379_E. Inverse Genealogy
Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in...
2
11
#include <bits/stdc++.h> using namespace std; int cur; bool possible(int n, int k) { if (n % 2 == 0) return false; if ((n & (n + 1)) == 0) { if (k == 0) return true; else if (k == 1) return false; } if (n == 9 && k == 2) return false; return k > 0 && k < n / 2; } void dfs(int n, int k, int...
CPP
1379_E. Inverse Genealogy
Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in...
2
11
#include <bits/stdc++.h> using namespace std; int memo[105][6]; pair<int, int> next1[105][6]; pair<int, int> next2[105][6]; bool boleh(int n, int k); int dp(int n, int k) { if (n % 2 == 0) { return false; } if (k < 0) { return false; } if (n == 1) { return k == 0; } if (memo[n][k] != -1) { ...
CPP
1379_E. Inverse Genealogy
Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in...
2
11
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; const int pow2 = 1 << 20; int fa[maxn], N; int cnt = 1; void dfs(int o, int n, int k) { if (k <= 1) { for (int i = o + 1; i <= n; i++) fa[i] = (i - o + 1) / 2 + o - 1; if (k == 1 && pow2 % (n - o + 2) == 0) { fa[n] = N; fa[n -...
CPP
1379_E. Inverse Genealogy
Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in...
2
11
#include <bits/stdc++.h> namespace ztd { using namespace std; template <typename T> inline T read(T& t) { t = 0; short f = 1; char ch = getchar(); double d = 0.1; while (ch < '0' || ch > '9') { if (ch == '-') f = -f; ch = getchar(); } while (ch >= '0' && ch <= '9') t = t * 10 + ch - '0', ch = getc...
CPP
1379_E. Inverse Genealogy
Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in...
2
11
#include <bits/stdc++.h> using namespace std; bool can(long long n, long long k) { if (n % 2 == 0) return 0; if (k == 0) return !(n & (n + 1)); if (k == 1) return n & (n + 1); return (k > 0 && k * 2 + 3 <= n) && !(k == 2 && n == 9); } long long i = 1; void construct(long long n, long long k, long long a = 0) { ...
CPP
1379_E. Inverse Genealogy
Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in...
2
11
#include <bits/stdc++.h> using namespace std; int n, k, w; void v(int a) { cout << a << " "; } void t(int a, int b) { for (int i = a + 1; i <= b; i++) v(a + (i - a - 1) / 2); } void s(int db, int p, int f) { v(f); if (db < 2) t(p, n); else { if (db == 3 && n - p == 10) t(p, p + 6), t(p + 6, p + 8)...
CPP
1379_E. Inverse Genealogy
Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in...
2
11
#include <bits/stdc++.h> using namespace std; template <class T> inline void cmin(T &a, T b) { ((a > b) && (a = b)); } template <class T> inline void cmax(T &a, T b) { ((a < b) && (a = b)); } char IO; template <class T = int> T rd() { T s = 0; int f = 0; while (!isdigit(IO = getchar())) f |= IO == '-'; do s...
CPP
1379_E. Inverse Genealogy
Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in...
2
11
#include <bits/stdc++.h> using namespace std; int ans[100011]; int n, k; inline int ok(int n, int k) { if (n % 2 == 0) return 0; if (n == 1 and k == 0) return 1; if (k > n / 2 - 1) return 0; if (n == 9 and k == 2) return 0; if (__builtin_popcount(n + 1) == 1) { if (k == 1) return 0; return 1; } re...
CPP
1379_E. Inverse Genealogy
Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in...
2
11
#include <bits/stdc++.h> using namespace std; int ans[100011]; int n, k; inline int ok(int n, int k) { if (n % 2 == 0) return 0; if (n == 1 and k == 0) return 1; if (k > n / 2 - 1) return 0; if (n == 9 and k == 2) return 0; if (__builtin_popcount(n + 1) == 1) { if (k == 1) return 0; return 1; } re...
CPP
1379_E. Inverse Genealogy
Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in...
2
11
#include <bits/stdc++.h> using namespace std; bool ok(int n, int k) { if (n % 2 == 0) return false; if (n == 1) return k == 0; bool pw2 = ((n + 1) & n) == 0; if (pw2 && k == 1) return false; if (!pw2 && k == 0) return false; if (k > (n - 3) / 2) return false; if (n == 9 && k == 2) return false; return t...
CPP
1379_E. Inverse Genealogy
Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in...
2
11
#include <bits/stdc++.h> using namespace std; mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count()); const long long inf = 1e15 + 7; bool check(long long n) { return __builtin_popcount(n + 1) == 1; } vector<long long> res; bool solve(long long n, long long k, long long par) { if (n == 11 && k =...
CPP
1379_E. Inverse Genealogy
Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in...
2
11
#include <bits/stdc++.h> using namespace std; const int inf = (int)1e9; const long long INF = (long long)5e18; const int MOD = 998244353; int _abs(int x) { return x < 0 ? -x : x; } int add(int x, int y) { x += y; return x >= MOD ? x - MOD : x; } int sub(int x, int y) { x -= y; return x < 0 ? x + MOD : x; } void...
CPP
1379_E. Inverse Genealogy
Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in...
2
11
#include <bits/stdc++.h> #pragma GCC optimize("O3") #pragma GCC target("sse4") using namespace std; template <class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; } template <class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; } mt19937 rng(chrono::steady_clock::now().time_since_epo...
CPP
1379_E. Inverse Genealogy
Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in...
2
11
#include <bits/stdc++.h> using namespace std; const int nax = 100; int mem[nax][nax]; int ok(int n, int k) { if (n % 2 == 0 || n <= 0 || k < 0) return 0; if (n == 1) return (k == 0); int& memo = mem[n][k]; if (!memo) { int r = 0; for (int na = 1; na < n - 1; na = na * 2 + 1) { int ka = 0; in...
CPP
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
#include <bits/stdc++.h> using namespace std; typedef struct { char c[15000]; int ipos, len; } st; bool glas(char s) { if (s == 'a' || s == 'e' || s == 'i' || s == 'o' || s == 'u') return true; return false; } int findPos(st* a, int k) { if (a->len == -1) a->len = strlen(a->c); if (a->ipos == -2) return -1;...
CPP
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
#include <bits/stdc++.h> using namespace std; const double PI = 4 * atan(1.0); void fast_stream() { std::ios_base::sync_with_stdio(0); } int K; bool isVowel(char a) { return a == 'a' || a == 'i' || a == 'u' || a == 'e' || a == 'o'; } bool match(string &a, string &b) { int cnt = 0; for (int i = 0;; i++) { if (...
CPP
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
n, k = [int(it) for it in raw_input().split()] Quatrains = [] Results = [] for i in range(0, n): temp = [] temp.append(raw_input()) temp.append(raw_input()) temp.append(raw_input()) temp.append(raw_input()) Quatrains.append(temp) def CheckQuatrain(a): def Suffix(a): result = [] ...
PYTHON
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
#include <bits/stdc++.h> using namespace std; int style[2500]; int n, k; string lk[4]; string getLaskK(const string& str) { if (str.size() < k) return ""; int l = str.size() - 1; int tot = 0; while (l >= 0) { if (str[l] == 'a' || str[l] == 'e' || str[l] == 'i' || str[l] == 'o' || str[l] == 'u') { ...
CPP
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
#include <bits/stdc++.h> using namespace std; string s[4]; int t, n, k; int pd[4][4]; map<char, int> mp; char ss; bool xd(string s1, string s2) { int l1, l2; int tt = 0; l1 = s1.size() - 1; l2 = s2.size() - 1; while (l1 >= 0 && tt < k) { if (mp[s1[l1]]) { tt++; } l1--; } if (tt < k) { ...
CPP
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
#include <bits/stdc++.h> using namespace std; int n, k; int a[2510]; int ans; int main() { cin >> n >> k; for (int i = 0; i < n; i++) { string s[4]; string p[4]; for (int j = 0; j < 4; j++) { cin >> s[j]; int t = s[j].size() - 1; int cur = 0; while (t >= 0 && cur != k) { ...
CPP
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
#include <bits/stdc++.h> using namespace std; const long long Maxn = 1e5 + 7; const long long Max = 1e3 + 7; const long long Mod = 1e9 + 7; const long long Inf = 1e9 + 7; string s[Maxn], V[Maxn]; long long ans[5]; long long check(char t) { if (t == 'u' || t == 'o' || t == 'a' || t == 'i' || t == 'e') return true; r...
CPP
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
import java.util.*; import java.lang.*; import java.io.*; import java.awt.Point; // U KNOW THAT IF THIS DAY WILL BE URS THEN NO ONE CAN DEFEAT U HERE................ // ASCII = 48 + i ;// 2^28 = 268,435,456 > 2* 10^8 // log 10 base 2 = 3.3219 // odd:: (x^2+1)/2 , (x^2-1)/2 ; x>=3// even:: (x^2/4)+1 ,(x^2/4)-1 x >=4...
JAVA
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
import java.util.*; import java.lang.*; import java.math.*; import java.io.*; import static java.lang.Math.*; import static java.util.Arrays.*; public class C{ Scanner sc=new Scanner(System.in); int INF=1<<28; double EPS=1e-9; int n, k; String[] ss; void run(){ n=sc.nextInt(); ...
JAVA
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
from sys import stdin rints = lambda: [int(x) for x in stdin.readline().split()] str_inp = lambda n: [stdin.readline()[:-1] for x in range(n)] n, k = rints() a, vow, pat, flag = [str_inp(4) for _ in range(n)], 'aeiou', set(), 0 pats = {'aabb', 'abab', 'abba'} for i in range(n): ixs = [0] * (4) for j in range...
PYTHON
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
#include <bits/stdc++.h> using namespace std; int countbit(int n) { return (n == 0) ? 0 : (1 + countbit(n & (n - 1))); } int lowbit(int n) { return (n ^ (n - 1)) & n; } const double pi = acos(-1.0); const double eps = 1e-11; char str[4][10010]; int N, K; char mode[4][5] = {"aaaa", "aabb", "abba", "abab"}; int getMode()...
CPP
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
import sys n,k=map(int,sys.stdin.readline().split()) def func(s): if (s==''): return cur_gl=k pos=len(s)-1 while pos>=0 and cur_gl>0: if s[pos] in ('a','e','i','o','u'): cur_gl-=1 if cur_gl>0: pos-=1 if cur_gl>0: print 'NO' exit(0) ...
PYTHON
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
import java.util.Scanner; // C public class Main { private static boolean isVowel(char c) { return c=='a' || c=='e' || c=='i' || c=='o' || c=='u'; } public static void main (String[] args) { Scanner c = new Scanner(System.in); int n = c.nextInt(); int k = c.nextInt(); c.nextLine(); boolean aabb = true;...
JAVA
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
JAVA
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
import static java.lang.Math.*; import java.util.*; import java.io.*; public class C { public void solve() throws Exception { int n = nextInt(), kk = nextInt(); boolean aabb=true, abab=true, abba=true; for (int i=0; i<n; ++i) { String[] q = new String[4]; int[] cnt...
JAVA
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
import java.io.*; import java.util.*; public class Main implements Runnable{ private void solve()throws IOException{ HashSet<Character> vowels=new HashSet<>(); vowels.add('a'); vowels.add('e'); vowels.add('i'); vowels.add('o'); vowels.add('u'); int n=nextInt(); int...
JAVA
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
#------------------------template--------------------------# import os import sys from math import * from collections import * from fractions import * from bisect import * from heapq import* from io import BytesIO, IOBase def vsInput(): sys.stdin = open('input.txt', 'r') sys.stdout = open('output.txt', 'w') BUF...
PYTHON3
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
import java.util.*; public class c { public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.nextInt(); int k = input.nextInt(); String a, b, c, d; boolean abab = true, abba = true, aabb = true, aaaa = true; for(int i = 0; i < n; i++) { a = inpu...
JAVA
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
#include <bits/stdc++.h> using namespace std; const string tp[4] = {"aaaa", "aabb", "abab", "abba"}; int n, k; string w[10000]; int main() { cin >> n >> k; n *= 4; bool bad = false; for (int i = 0; i < n; i++) { string s; cin >> s; w[i] = ""; int l = 0; while (l < k && (int)s.size()) { ...
CPP
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
#include <bits/stdc++.h> using namespace std; int k; bool Is(char a) { return (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u'); } bool Equal(string s, string t) { int n = (int)s.size(), m = (int)t.size(); int v1 = 0, v2 = 0; for (int i = 0; i < n; i++) v1 += Is(s[i]); for (int i = 0; i < m; i++) v2 ...
CPP
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
#!/usr/bin/env python """(c) gorlum0 [at] gmail.com""" import itertools as it from sys import stdin vowels = 'aeiou' types_rhymes = 'NO abba abab # aabb # # aaaa'.split() def suffix(k, w): for i in xrange(len(w)-1, -1, -1): if w[i] in vowels: k -= 1 if not k: break return w[i:] if not k else ''...
PYTHON
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
#include <bits/stdc++.h> using namespace std; int k; bool eq(char &q) { return (q == 'a' || q == 'e' || q == 'o' || q == 'u' || q == 'i'); } bool rifm(string &a, string &b) { int n = a.length(), m = b.length(); int k1, k2; k1 = k2 = 0; int i = n; while (i > 0 && k1 < k) { i--; if (eq(a[i])) k1++; ...
CPP
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
def bad(a,b,c,d): if a == 'bad' or b == 'bad' or c == 'bad' or d == 'bad': return True return False if __name__ == "__main__": p = map(eval,raw_input().split(" ")) n=p[0] K=p[1] poem = [] vowel = ['a','e','i','o','u'] for i in range(0,n): quat = [] for j in range...
PYTHON
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int i, j, n, k, l, m; bool a, b, c; string s, t[4]; a = b = c = true; cin >> n >> k; for ((i) = 0; (i) < (int)(n); (i)++) { for ((j) = 0; (j) < (int)(4); (j)++) { cin >> s; l = 0; t[j] = ""; for (m = s.length() - 1; m >= ...
CPP
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
#include <bits/stdc++.h> using namespace std; int n, k; int rhymes[2550]; string arr[4]; int vowel(char a) { return (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u'); } int rhyme(string a, string b) { int cnt = 0; int i; for ((i) = 0; (i) < (int)(((int)(a).size())); (i)++) if (vowel(a[i])) cnt++; ...
CPP
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int i, j, k; int n, m; while (cin >> n >> m) { int f = 0; for (i = 0; i < n; ++i) { string t[4]; for (j = 0; j < 4; ++j) { string s; cin >> s; if (f < 0) continue; int ln = s.length(); int ct = 0...
CPP
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { static String[] list; static String type(String s[]){ if(s[0].equals(s[1]) && s[1].equals(s[2]) && s[2].equals(s[3])) return "aaaa"; if(s[0].equal...
JAVA
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
import java.util.*; import java.lang.*; public class Main { public static boolean rhymes(String[][] ap, int a, int b, int k) { int la = ap[a].length, lb = ap[b].length; //System.out.println(la); for(int i = la - k, j = lb - k; i < la && j < lb;) { if(i < 1 || j < 1) return false; //System.out.println(ap[a]...
JAVA
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
#include <bits/stdc++.h> using namespace std; vector<int> aux; int n, k; char m[100][150]; bool vogal(char a) { return (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u'); } bool igual(string a, int ida, string b, int idb) { if (a.length() - ida != b.length() - idb) return false; for (int i = ida; i < a.le...
CPP
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
#include <bits/stdc++.h> using namespace std; string S1[10002], an[] = {"aabb", "abab", "abba", "aaaa", "NO"}, S; int ar[5], n, m; int main() { cin >> n >> m; for (int i = 0; i < 4 * n; i++) { int l = 0, k; cin >> S; for (k = S.size(); k >= 0 && l != m;) { k--; if (S[k] == 'a' || S[k] == 'e'...
CPP
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
#include <bits/stdc++.h> using namespace std; const long double EPS = 1E-9; const int INF = (int)1E9; const long long INF64 = (long long)1E18; int n, k; bool check1(string a, string b, string c, string d) { string p, q, r, s; int t = 0; for (int i = a.size() - 1; i >= 0; i--) { if (a[i] == 'a' || a[i] == 'e' ...
CPP
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
#include <bits/stdc++.h> using namespace std; set<char> V = {'a', 'e', 'i', 'o', 'u'}; bool match(string& a, string& b, int k) { int i = a.size() - 1, j = b.size() - 1; while (i >= 0 && j >= 0) { if (a[i] != b[j]) return 0; if (V.count(a[i]) && --k == 0) return 1; i--, j--; } return 0; } int main() ...
CPP
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
#include <bits/stdc++.h> using namespace std; const int maxi = 1e6 + 10; int a[maxi]; string s[maxi]; int n, k; vector<int> v[maxi]; int vowel(char x) { return x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u'; } int rima(int x, int y) { int n1 = s[x].size(); int n2 = s[y].size(); int pozX, pozY; int v...
CPP
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
#include <bits/stdc++.h> using namespace std; string lines[10001]; string pieces[10001]; int n, k; char v[] = {'a', 'e', 'i', 'o', 'u'}; int main() { cin >> n >> k; for (int i = 0; i < n; i++) { cin >> lines[4 * i] >> lines[4 * i + 1] >> lines[4 * i + 2] >> lines[4 * i + 3]; } set<char> vowels(v, v ...
CPP
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
/** * Jerry Ma * Program lit */ import java.io.*; import java.util.*; public class lit { static BufferedReader cin; static StringTokenizer tk; static char [] vowels = {'a','e','i','o','u'}; public static void main (String [] args) throws IOException { init(); int num = gInt(), vowelPos = gInt(); ...
JAVA
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
import java.util.HashMap; import java.util.Scanner; /* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author Alex */ public class _139C { private static String getSuffix(String a, int k) { String res = ""; StringBuilder temp = new Stri...
JAVA
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
#include <bits/stdc++.h> using namespace std; const int N = 100005; string s[N], suf[N]; string ans[4] = {"aaaa", "aabb", "abab", "abba"}; int main() { int n, k; scanf("%d%d", &n, &k); for (int i = 1; i <= n; ++i) { for (int j = (i - 1) * 4 + 1; j <= i * 4; ++j) { cin >> s[j]; } } int f = -1; ...
CPP
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
#include <bits/stdc++.h> using namespace std; bool pro(char c) { return (c == 'a' || c == 'i' || c == 'o' || c == 'e' || c == 'u'); } long long n, k; bool ttt(string a, string b) { long long t = min(a.length(), b.length()), i = 1, u = 0; while (i <= t) { if (a[a.length() - i] == b[b.length() - i]) { if ...
CPP
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
#include <bits/stdc++.h> using namespace std; const int inf = 1 << 30, N = 1002; int ax[] = {0, 1, -1, 0, 0}; int ay[] = {0, 0, 0, -1, 1}; string a[10002]; bool rifma(int first, int second, int k) { int n = a[first].size() - 1; int m = a[second].size() - 1; while (true) { if (a[first][n] != a[second][m]) retu...
CPP
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); String cur = ""; String tmp; int cnt = 0; String s[] = new String[4]; for (int i = ...
JAVA
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
#include <bits/stdc++.h> using namespace std; using ll = long long; using ii = pair<int, int>; using vi = vector<int>; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3fLL; const double err = 1e-9; const int mod = 1e9 + 7; const int N = 1e5 + 10; ll n, k; bool isVowel(char c) { return c == 'a' or c == 'e' o...
CPP
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int n, k, i, j, l; string s, t, r, z, u, p[5], q; char c; cin >> n >> k; getline(cin, z); for (i = 1; i <= n; i++) { t = " "; r = ""; c = 'a'; for (l = 1; l <= 4; l++) { getline(cin, z); j = z.length() - 1; q = s...
CPP
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
#include <bits/stdc++.h> using namespace std; string getBack(string s, int k) { int p = s.size(); for (int i = 0; i < k; i++) { int ap = s.substr(0, p).find_last_of("a"); int ep = s.substr(0, p).find_last_of("e"); int ip = s.substr(0, p).find_last_of("i"); int op = s.substr(0, p).find_last_of("o"); ...
CPP
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ import java.util.HashSet; import java.util.Scanner; /** * * @author Eslam Ashraf */ public class C { static HashSet<Integer> set = new HashSet<Integer>(); public static void main(String[] args) { ...
JAVA
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
import java.util.*; import java.math.*; public class main { public static void main(String args[]) { Scanner c=new Scanner(System.in); int N=c.nextInt(); int K=c.nextInt(); String P[][]=new String [N][4]; for(int i=0;i<N;i++) { for(int j=0;...
JAVA
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
#include <bits/stdc++.h> using namespace std; vector<int> room; string str[4]; int check(char x) { if (x == 'a' || x == 'e' || x == 'i' || x == 'u' || x == 'o') return 1; return 0; } int main() { int n, m; scanf("%d%d", &n, &m); int ret = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < 4; j++) { ...
CPP
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
#include <bits/stdc++.h> using namespace std; void nope() { cout << "NO"; exit(0); } int main() { set<string> res; int n, k; cin >> n >> k; for (int i = 0; i < n; i++) { string sp[4]; for (int j = 0; j < 4; j++) { string s; cin >> s; int p = s.size(); int c = 0; while (...
CPP
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
#include <bits/stdc++.h> using namespace std; const int maxn = 10010; string s1[maxn]; string check(string t1, string t2, string t3, string t4) { if (t1 == t2 && t3 == t4 && t1 == t3) return "aaaa"; if (t1 == t3 && t2 == t4 && t1 != t2) return "abab"; if (t1 == t4 && t2 == t3 && t1 != t2) return "abba"; if (t1 ...
CPP
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
#include <bits/stdc++.h> using namespace std; int mode(char a[], char b[], char c[], char d[]) { if (strcmp(a, b) == 0 && strcmp(c, d) == 0 && strcmp(b, c) != 0) return 1; else if (strcmp(a, b) == 0 && strcmp(c, d) == 0 && strcmp(a, c) == 0) return 0; else if (strcmp(a, c) == 0 && strcmp(b, d) == 0 && str...
CPP
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
#include <bits/stdc++.h> using namespace std; char str[4][10005]; int k; bool isV(char ch) { if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') return 1; return 0; } int get_type() { int len[4], i, j, st[4], x; for (i = 0; i < 4; i++) { len[i] = strlen(str[i]); if (len[i] < k) return 0; ...
CPP
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; char c[5] = {'a', 'e', 'i', 'o', 'u'}; int r[4] = {0}; int flag = 0; for (int i = 0; i < n; i++) { vector<string> v; for (int i = 0; i < 4; i++) { string str, p = ""; cin >> str; int ctr = 0; ...
CPP
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
""" Literature Lesson """ import random def split_str(string, k): index = len(string) for char in string[::-1]: index -= 1 if char in 'aeiou': k -= 1 if k == 0: return string[index:] return string * random.randint(0, 100) def rhyme_schemes(quatrain, k): ...
PYTHON
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
#include <bits/stdc++.h> using namespace std; int n, k; char a[4][100000]; int c[4]; int b[3000]; bool is(char ch) { if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') return true; return false; } int i, j, m; int main() { scanf("%d%d", &n, &k); bool flag = true; for (i = 1; i <= n; i++) {...
CPP
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
import sys def finish(result): print(result) sys.exit() n, k = map(int, raw_input().split()) scheme_count = { 'aabb': 0, 'abab': 0, 'abba': 0, 'aaaa': 0 } def make_scheme(suffixes): if None in suffixes: return None suffix_hash = {} symbol = 'a' scheme_parts = [] for suffix in suffixes: if suffi...
PYTHON
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.InputStreamReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.StringTokenizer; publ...
JAVA
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
import re r = lambda: raw_input().strip() n,k = map(int,r().split(' ')) poem = [r().strip()[::-1] for i in xrange(4*n)] counter = 0 ptype = 'aaaa' s = [] for line in poem: i = k suffix = None match = re.search('([^aeiou]*[aeiou]){%d}' % k, line) if match: suffix = match.group(0) if suffix ...
PYTHON
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
import java.util.*; import java.math.*; public class codeforces { public static int go(Scanner sc,int k) { String[] data=new String[4]; for(int i=0;i<4;i++) { data[i]=sc.next(); int t=0; ...
JAVA
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
import java.io.*; import java.util.*; public class CF139C { static boolean vowel(char c) { return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'; } static String suffix(String s, int k) { for (int i = s.length() - 1; i >= 0; i--) if (vowel(s.charAt(i))) { k--; if (k == 0) return s.subs...
JAVA
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
#include <bits/stdc++.h> int main(void) { int type = 0, i, j, k, l, m, n; char str[4][10001], last[4][10001]; scanf("%d %d%*c", &n, &k); while (n--) { for (i = 0; i < 4; i++) scanf("%s%*c", str[i]); for (m = 0; m < 4; m++) { l = strlen(str[m]); for (i = 0, j = 0; i < l && j < k; i++) { ...
CPP
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
import java.util.Scanner; public class LiteratureLesson { public static void main(String[] args) { Scanner in = new Scanner(System.in); String s = in.nextLine(); int n = Integer.parseInt(s.substring(0, s.indexOf(" ")).trim()); int k = Integer.parseInt(s.substring(s.indexOf(" "))....
JAVA
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
#include <bits/stdc++.h> using namespace std; struct sd { int f, s, t; }; string ff(string a, int k) { string tt = ""; for (int i = a.size() - 1; i >= 0; i--) { if (k == 0) break; if (a[i] == 'a' || a[i] == 'e' || a[i] == 'i' || a[i] == 'o' || a[i] == 'u') k--; tt += a[i]; } if (k != 0) retu...
CPP
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; public class codefo { public static void main(String[] args) throws IOException { Scanner scan = new Scanner(System.in); scan.useDelimiter("\\p{javaWhitespace}+|[\\s,]+"); /*int n = Integer.v...
JAVA
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
#include <bits/stdc++.h> using namespace std; bool is[10020][5]; int n, k; bool Is(char x) { if (x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u') return 1; else return 0; } char *solve(char *x) { int t = strlen(x), c = 0; for (int i = t; i >= 0; --i) { if (Is(x[i])) { c++; if (c...
CPP
139_C. Literature Lesson
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes. Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels. Two lines rhyme if their ...
2
9
#include <bits/stdc++.h> using namespace std; bool f[2510][5]; int n, k; bool Is(char x) { if (x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u') return 1; return 0; } bool NO; char *judge(char *c) { if (NO) return NULL; int l = strlen(c), t = 0; for (int i = l - 1; i >= 0; --i) { if (Is(c[i])) { ...
CPP