prompt string | response string |
|---|---|
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
const int N = 10000 + 5;
bool dp[N][5];
int main() {
std::string str;
std::cin >> str;
int n = str.length();
memset(dp, false, sizeof(dp));
std::vector<std::string> answer(0);
for (int i = n - 1; i >= 5; i--) {
for (int j = 2; j <= 3; j++) {
if (i + j == n) {
dp[i]... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
string S;
set<string> ans;
int N;
bool u[10001][2];
void dfs(int n, string prev, int p) {
if (u[n][p]) return;
if (n + 1 - 2 > 4) {
string t = S.substr(n - 1, 2);
if (t != prev) {
ans.insert(t);
dfs(n - 2, t, 2);
}
}
if (n + 1 - 3 > 4) {
... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
int main() {
string s, t;
cin >> s;
int n = s.length();
if (n <= 6) {
cout << "0\n";
return 0;
}
bool dp2[10001] = {0}, dp3[10001] = {0};
set<string> ans;
t.push_back(s[n - 2]);
t.push_back(s[n - 1]);
ans.insert(t);
if (n >= 8) {
t = "";
... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
const int N = 1000006;
char s[N];
int n;
set<string> vis[N];
set<string> ss;
void f(int i, const string& last) {
if (vis[i].count(last)) return;
vis[i].insert(last);
if (i - 2 >= 4) {
string tmp = "";
tmp += s[i - 1];
tmp += s[i];
if (tmp != last) {
... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
int main() {
string str;
cin >> str;
int n = str.length();
vector<bool> dp2(str.length(), false);
vector<bool> dp3(str.length(), false);
set<string> codewords;
if (n >= 7) {
dp2[n - 2] = true;
codewords.insert(str.substr(n - 2, 2));
}
if (n >= 8) {... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
const int MaxN = 1e5 + 10;
vector<string> tot[MaxN];
map<string, int> c;
int cnt;
char s[MaxN];
bool check[MaxN], flag;
set<string> ans;
int main() {
scanf("%s", s);
int len = strlen(s);
check[len] = 1;
for (int i = len - 2; i >= 5; i--) {
if (check[i + 2]) {
... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1e4 + 10;
char str[maxn];
string tmp;
set<string> ans;
int dp[maxn][2];
int main() {
scanf("%s", str + 1);
int len = strlen(str + 1);
tmp = " ";
for (int i = 1; i <= len; i++) tmp += str[i];
tmp[len + 1] = '\0';
for (int i = len - 1; i >= 6; i--... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
inline int read() {
int x = 0;
char ch = getchar();
bool positive = 1;
for (; ch < '0' || ch > '9'; ch = getchar())
if (ch == '-') positive = 0;
for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
return positive ? x : -x;
}
inline char RC(... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | import java.util.Scanner;
import java.util.TreeSet;
public class Ejercicio10 {
static TreeSet<String> tree;
static String s;
static boolean[] b1;
static boolean[] b2;
public static void main(String[] args) {
// TODO Auto-generated method stub
//Reberland Linguistics
String l = "";
tree = new TreeSet<S... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 10101;
char s[maxn];
bool dp[maxn][4];
bool exist[30000];
inline int Hash(int l, int r) {
int base = 1, ans = 0;
for (int i = r; i >= l; i--) ans += ((int)s[i] - 96) * base, base *= 26;
return ans;
}
int n;
inline bool check(int i, int i2, int len) {
... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
int n, can[10004];
set<string> ans;
string s, cur;
int main() {
ios::sync_with_stdio(0);
cin >> s;
n = s.size();
can[n - 1] = 5;
for (int r = n - 3; r >= 4; r--) {
if (can[r + 2]) {
if (can[r + 2] != 2 || s.substr(r + 1, 2) != s.substr(r + 3, 2)) {
... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
int lsone(int n) { return (n & -n); }
void mult(long long int a[25][25], long long int b[25][25],
long long int c[25][25], int m, int n, int p) {
for (int i = 1; i <= m; i++) {
for (int j = 1; j <= p; j++) {
c[i][j] = 0;
for (int k = 1; k <= n; k... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
const int Maxl = 10005;
char str[Maxl];
int slen;
bool pos[Maxl][2];
set<string> S;
bool Check(int i, int len) {
int j = i + len;
if (j + len - 1 >= slen) return true;
for (int l = 0; l < len; l++)
if (str[i + l] != str[j + l]) return true;
return false;
}
int m... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... |
if __name__ == '__main__':
word = input()
suffixes = set()
possible = set()
my_set = set()
not_poss = set()
possible.add((len(word), 2))
while possible:
tam, x = possible.pop()
a = tam + x
for i in [x, 5 - x]:
root = tam - i
new_pos = (ro... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
const int MAX = 10005;
set<string> words;
bool memo[4][MAX], visit[4][MAX];
string s;
int n;
bool solve(int idx, int tam) {
if (idx + tam == n) {
string A = s.substr(idx, tam);
reverse(A.begin(), A.end());
words.insert(A);
return true;
}
if (idx + tam ... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | import java.util.*;
import java.lang.*;
import java.io.*;
// Created by @thesupremeone on 18/05/21
public class ReberlandLinguistics {
String s;
TreeSet<String> strings;
Set<String> done;
void explore(int i, String last){
if(i<1) return;
String key = i+":"+last.length();
if(done... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
FastScanner in = new FastScanner(System.in);
PrintWriter out = new PrintWriter(System.out);
new Main().run(in, out);
out.close();
}
public static long mod =... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
string s;
cin >> s;
int n = s.size();
auto get = [&](int i, int j) {
string st = "";
for (int t = i; t < min(n, i + j); t++) st += s[t];
return st;
};
vector<vector<bool>> can(n + 1, vector<b... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
template <typename T>
ostream& operator<<(ostream& out, vector<T> v) {
out << '{';
for (size_t i = 0; i < v.size(); ++i) out << (i == 0 ? "" : ", ") << v[i];
return out << '}';
}
template <typename Arg1>
void myPrint(const char* name, Arg1&& a... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | import java.util.*;
public class linguistics{
public static void main(String [] args){
Scanner sc = new Scanner(System.in);
String in = sc.nextLine();
char[] ch = in.toCharArray();
int n = ch.length;
TreeSet <String> ans = new TreeSet<>();
boolean[] dp2 = new boolean[n+1];
boolean[] dp3 = new boolean[n... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | t = input()
s, d = set(), set()
p = {(len(t), 2)}
while p:
m, x = p.pop()
r = m + x
for y in [x, 5 - x]:
l = m - y
q = (l, y)
if q in d or l < 5 or t[l:m] == t[m:r]: continue
s.add(t[l:m])
d.add(q)
p.add(q)
print(len(s))
print('\n'.join... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | import java.util.Arrays;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;
public class Solution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String s = in.next();
s = s.substring(5);
int[] allowedPath = new int[s.length... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
const int N = 5002;
const int inf = 1e9;
const int md = 1e9 + 7;
const long long linf = 1e18;
string s;
int a1, a2, a3, ans;
vector<string> anss;
bool dp2[10001];
bool dp3[10001];
map<string, bool> used;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
int a, i, sz, b, x[10005][2];
char s[10005];
int u[20005];
int main() {
scanf("%s", s);
a = strlen(s);
x[a][0] = 1;
x[a][1] = 1;
for (i = a - 2; i >= 5; i--) {
if (x[i + 2][1] == 1 ||
(x[i + 2][0] == 1 && (!(s[i] == s[i + 2] && s[i + 1] == s[i + 3])))) {
x[i][0] = 1;... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
bool vaild[100005 + 1000];
set<string> ans;
int main(int argc, char* argv[]) {
string s;
cin >> s;
int len = s.length();
vaild[len] = 1;
for (int i = len; i > 4; i--) {
if (vaild[i + 2]) {
string t = s.substr(i, 2);
if (s.find(t, i + 2) != i + 2 ||... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e5 + 10;
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
long long se[26][26][26], du[26][26], q[MAXN];
string v[MAXN], dp[MAXN];
int main() {
string s;
cin >> s;
long long k = 0;
q[s.size()] = 2;
for (int i = s.size() - 2; i >= ... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
s += "###";
reverse(s.begin(), s.end());
set<string> suff;
bool d[2][s.length() + 10];
for (int i = 0; i < 2; i++) {
for (int j = 0; j < s.length() + 10; j++) {
d[i][j] = 0;
}
}
if (s.length() - 3 > 6) {
d... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Random;
import java.util.Scanner;
import java.util.TreeSet;
public class A {
private static void solve() throws IOException {
char[] c = in.next().toCharArray();
boolean[] can = new boolean[c.length ... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long CFMOD = 998244353;
const double PI = 3.14159265358;
const double EPS = 1e-8;
void solve() {
string s, tmp;
set<string> ans;
vector<bool> dp2, dp3;
cin >> s;
reverse(s.begin(), s.end());
dp2.resize(((int)s.size()));
... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | import java.util.Collections;
import java.util.HashSet;
import java.util.Scanner;
import java.util.TreeSet;
public class Linguistics {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String word = sc.nextLine();
sc.close();
int n = word.length();
... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 1E4 + 10;
char s[MAXN];
bool f[MAXN][2];
int main() {
scanf("%s", s);
int n = strlen(s);
f[n][0] = f[n][1] = true;
vector<string> lst;
for (int i = n - 2; i >= 5; --i) {
f[i][0] = f[i + 2][1] || f[i + 2][0] && strncmp(s + i, s + i + 2, 2);
... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1e4 + 5;
int dp1[maxn], dp2[maxn];
set<string> my;
string x;
int n;
int solve(int i, int l) {
if (l == 2 && dp1[i] >= 0) return dp1[i];
if (l == 3 && dp2[i] >= 0) return dp2[i];
if (i + l - 1 >= n) {
return false;
}
int left = n - (i + l - 1) ... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
int dp[10010][5];
int n;
string s;
int solve(int pos, int lastJump) {
if (dp[pos][lastJump] != -1) return dp[pos][lastJump];
if (pos >= n) return 0;
if (pos == (n - 1)) {
dp[pos][lastJump] = 1;
return 1;
}
if (pos > 3) {
int x = 0;
if (lastJump == ... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | import java.util.Scanner;
import java.util.TreeSet;
public class Competencia2 {
static TreeSet<String> set = new TreeSet<>();
public static void main(String[] args) throws Exception {
Scanner scan = new Scanner(System.in);
char[] character = scan.next().toCharArray();
int n = character.length;
bo... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
bool dp[10001][2];
int main() {
string s;
cin >> s;
int n = s.size();
vector<string> ans;
dp[n][0] = dp[n][1] = true;
for (int i = n - 2; i >= 5; i--) {
if (i + 2 == n) {
dp[i][0] = true;
string s1 = "";
s1.push_back(s[i]);
s1.push_ba... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
#pragma comment(linker, "/STACK:66777216")
using namespace std;
const int N = 10000 + 5;
int n;
char s[N];
int dp[N][5];
void solve() {
scanf("%s", s);
n = strlen(s);
dp[n][0] = 1;
dp[n][1] = 1;
dp[n][2] = 1;
dp[n][3] = 1;
for (int i = (int)(n)-1; i >= 0; --i) {
while (i == 5)... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | import sys
pow2 = pow # for modular expo pow2(base, n, mod)
from math import *
from time import time
from collections import defaultdict
from bisect import bisect_right, bisect_left
from string import ascii_lowercase as lcs
from string import ascii_uppercase as ucs
from fractions import Fraction, gcd
from ... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
long long N;
char s[200005];
set<string> ans;
long long hashi[200005];
bool vis[200005][2];
bool memo[200005][2];
long long pot[200005];
long long val(long long l, long long r) {
long long tmp = hashi[r] - (hashi[l - 1] * pot[r - l + 1]);
tmp %= 1000000007;
tmp += 100... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 3 * 1000 * 1000 + 10;
const long long mod = 1000 * 1000 * 1000 + 7;
const long long inf = 1LL * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 10;
long long pw(long long a, long long b) {
return (b == 0 ? 1LL
: ((pw(a * a % mod, b / 2) * (b & ... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
int n, m, dp[1000005][2];
char a[1000005];
struct el {
char a[5];
int n;
} v[1000005], sol[1000005];
inline int Cmpp(el A, el B) {
int i;
for (i = 1; i <= A.n && i <= B.n && A.a[i] == B.a[i]; ++i)
;
if (i > A.n) {
if (i > B.n) return 0;
return 2;
}
... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
const int N = 20110;
char p[N];
bool dp[N][4];
vector<string> ans;
int n;
string str(int u, int v) {
string ans = "";
for (int i = u; i <= v; i++) ans = ans + p[i];
return ans;
}
int main() {
scanf("%s", p + 1);
n = strlen(p + 1);
dp[n + 1][2] = dp[n + 1][3] = t... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | // practice with rainboy
import java.io.*;
import java.util.*;
public class CF666A extends PrintWriter {
CF666A() { super(System.out, true); }
Scanner sc = new Scanner(System.in);
public static void main(String[] $) {
CF666A o = new CF666A(); o.main(); o.flush();
}
void main() {
byte[] cc = sc.next().getByte... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int dp[4][N];
string str2[N], str3[N];
set<string> ans;
int n;
int cal(int len, int idx) {
if (dp[len][idx] != -1) return dp[len][idx];
if (idx == n - 1) return dp[len][idx] = 1;
;
int x = 0;
if (idx + 2 < n) {
if (len == 2 && str2[idx]... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
bool dp[maxn][2];
void work() {
string str;
cin >> str;
memset(dp, false, sizeof(dp));
int len = str.length();
str += "0";
dp[len - 3][1] = true;
dp[len - 2][0] = true;
for (int i = len - 4; i >= 5; --i) {
if ((dp[i + 2][1] || (d... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
bool can2[10101];
bool can3[10101];
bool suff[32][32][32];
int main() {
cin.sync_with_stdio(false);
cin.tie(nullptr);
string S;
cin >> S;
int n = S.size();
can2[n - 2] = true;
can3[n - 3] = true;
for (int i = n - 4; i >= 0; --i) {
if (can3[i + 2] ||
... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const double pi = acos(-1.0);
int dblcmp(double d) {
if (fabs(d) < eps) return 0;
return d > eps ? 1 : -1;
}
int dp[111111][6];
int main() {
int i, j, k;
string s;
cin >> s;
int l = (int)((s).size());
s = "@" + s;
set<string> st;
m... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
string s;
int l;
int vis[10009][4];
set<string> suff;
bool solve(int idx, string prev) {
if (idx == l) return 1;
if (idx > l) return 0;
int z = prev.length();
if (vis[idx][z]) return vis[idx][z];
bool flg1 = 0, flg2 = 0;
if (idx + 2 <= l) {
string s1;
fo... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
int main() {
char s[10001];
scanf("%s", s);
string str(s);
int n = (int)str.length();
vector<set<string>> answer(n);
for (auto &it : answer) it.clear();
if (str.length() <= 6)
cout << "0" << endl;
else if (str.length() == 7)
cout << "1\n" << str.subs... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
const int MAX = 1e4 + 10;
bool dp[MAX][2];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
string s;
cin >> s;
int n = s.size();
dp[n - 2][0] = dp[n - 3][1] = true;
set<string> ans;
for (int i = n - 1; i >= 0; i--) {
for (int j ... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
string str;
set<string> s;
map<pair<string, int>, int> dp;
int func(string tmp, int n) {
if (n >= 4 && tmp.length() != 0) {
s.insert(tmp);
}
if (n <= 4) {
return 0;
}
if (dp[make_pair(tmp, n)] != 0) {
return dp[make_pair(tmp, n)];
}
string t1 = "",... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
int n, dp[10007][4];
set<string> S;
string str;
int rec(int pos, int prev, string back) {
if (pos == n && prev != n - 1) return 1;
int &ret = dp[pos][pos - prev];
if (ret != -1) return ret;
int now1 = 0, now2 = 0, now3 = 0;
string st;
if (pos + 2 <= n) {
st ... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
inline int in() {
int32_t x;
scanf("%d", &x);
return x;
}
inline string get() {
char ch[100010];
scanf("%s", ch);
return ch;
}
const int MAX_LG = 21;
const long long maxn = 1e5 + 10;
const long long base = 29;
const long long mod = 1e9 + 7;
bool dp2[maxn], dp3[m... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x);
template <typename T>
void write(T x);
template <typename T>
void writesp(T x);
template <typename T>
void writeln(T x);
const long long N = 1e5 + 5;
char wn[N];
long long n;
bool f[N][2];
bool vis[N][2];
string s[N];
long long cnt;
in... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
set<string> result;
string s;
int n;
int main() {
ios::sync_with_stdio(NULL);
cin.tie(NULL);
cin >> s;
n = int(s.size());
vector<bool> can3(n + 3, false);
vector<bool> can2(n + 3, false);
can2[n] = can3[n] = true;
for (int i = n - 1; i >= 0; i--) {
if (c... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
int dp[4][10100];
char str[10100];
int n;
set<string> S;
int get(int bad, int pos) {
if (pos == n) return 1;
if (pos > n) return 0;
if (dp[bad][pos] + 1) return dp[bad][pos];
int r = 0;
if (bad != 2) {
int u = 1;
if (str[pos] != str[pos + 2] || str[pos + 1... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... |
import java.util.Scanner;
import java.util.TreeSet;
public class ReberlandLinguistics3
{
static String s;
static int n;
static boolean valid(int pos, int chars)
{
if(pos - chars < 0)return true;
for(int i = pos-chars+1; i <= pos; i++)
{
if(s.charAt(i) != s.charAt(i-chars))
return true;
}
r... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | import java.io.*;
import java.util.*;
public class R349qA {
public static void main(String[] args) {
InputReader in = new InputReader(System.in);
PrintWriter w = new PrintWriter(System.out);
char s[] = in.readString().toCharArray();
TreeSet<String> ans = new TreeSet<String>();
int n = s.length;
b... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void smin(T &a, const U &b) {
if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, const U &b) {
if (a < b) a = b;
}
template <class T>
inline void gn(T &first) {
char c, sg = 0;
while (c = getchar(), ... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 10;
int n, f[N][2];
int v1[30][30], v2[30][30][30];
char s[N];
vector<string> res;
int main() {
scanf("%s", s + 1);
n = strlen(s + 1);
if (n >= 7) f[n][0] = 1;
if (n >= 8) f[n][1] = 1;
for (int i = n; i >= 7; i--) {
if (f[i][0]) {
v1[... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int n;
char a[20000];
int d[20000][2];
int main() {
int i, j, k, l;
scanf("%s", a);
n = strlen(a);
d[n][0] = d[n][1] = 1;
for (i = n - 2; i >= 5; i--) {
d[i][0] |= d[i + 2][1];
if (make_pair(a[i], a[i + 1]) != make_pair(a[i ... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | s = raw_input()
if len(s)<7:
print 0
elif len(s) == 7:
print 1
print s[-2:]
else:
dp2 = [False for i in range(len(s)+1)] # dp2[i] = 1 means its possible to pick s[i:i+2]
dp3 = [False for i in range(len(s)+1)] # dp3[i] = 1 means its possible to pick s[i:i+3]
n = len(s)
s = '0' + s ... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | import java.util.Scanner;
import java.util.TreeSet;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
TreeSet<String> suffixes = new TreeSet<>();
String word = sc.nextLine();
sc.close();
String tempSubstring;
boolean... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
int to[10100], ant[10100], adj[6010], z;
const int oo = 0x3f3f3f3f;
char str[100100];
bool can2[100100], can3[100100];
char tmp[10];
set<string> ans;
void addStr(int a, int b) {
for (int(i) = (a); (i) < (b + 1); ++(i)) {
tmp[i - a] = str[i];
}
tmp[b - a + 1] = 0;
... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | string = input()
s = set()
finded = {}
import sys
sys.setrecursionlimit(900000000)
def get_substr(string, start, parent):
# Π±Π°Π·ΠΎΠ²ΡΠΉ ΡΠ»ΡΡΠ°ΠΉ
if start >= len(string):
return
if start+1 < len(string):
substr = string[start:start+2]
# ΠΏΡΠΎΠ²Π΅ΡΠΈΠΌ Π½Π΅ ΡΠ° ΠΆΠ΅ Π»ΠΈ ΡΡΠΎ ΡΡΡΠΎΠΊΠ°
i... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
string S;
vector<string> V;
int n, d[10005][3], ans;
void dp(int x, int len) {
if (d[x][len] != 0) return;
d[x][len] = 1;
string s2(S, x - 1, 2), s3(S, x - 2, 3);
if (len == 2) {
if (x >= 6) {
V.push_back(s2);
dp(x - 2, 0);
}
if (x >= 7) {
... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
const int N = 1e4;
char s[N + 3];
bool v[2][N + 3];
set<string> ans;
int main() {
ios_base::sync_with_stdio(false), cin.tie(0), cout << fixed;
cin >> s;
int n = strlen(s);
v[0][n] = v[1][n] = true;
for (int i = n - 2; i > 4; i--) {
... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
const int maxN = 10005, MOD = 1e7 + 7, eps = 1e-7;
int dp2[maxN], dp3[maxN];
string str;
string range(int l, int step) { return str.substr(l, step); }
set<string> S;
bool check2(int n) {
if (n < 3) {
return true;
}
return range(n - 3, 2) != range(n - 1, 2);
}
bool... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
//package CP;
import java.io.*;
import java.util.*;
public class A666 {
static TreeSet<String> set;static String s;
static bool... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100;
string s;
bool dp[N];
int main() {
while (cin >> s) {
int n = s.length();
set<string> se;
for (int i = 0; i <= n; i++) dp[i] = true;
dp[n - 1] = false;
for (int i = n - 2; i >= 5; i--) {
int cnt = 0;
if (i + 2 <= n ... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
const int cmx = 1e4 + 5;
int n;
string s;
int dp[cmx][2];
set<string> ans;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> s;
n = s.size();
if (n <= 6) {
cout << 0 << '\n';
return 0;
}
dp[n - 1][1] = 1;
if (n > 7) dp[n - ... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | import java.io.*;
import java.lang.*;
import java.util.*;
// Sachin_2961 submission //
public class CodeforcesA {
static TreeSet<String>treeSet = new TreeSet<>();
public void solve() {
char[]str = fs.next().toCharArray();
int n = str.length;
boolean[][]dp = new boolean[n+1][2];
... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeSet;
public class Solution{
static final int N = (int)1e5+10;
static final long inf = (lo... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
bool valid[10000 + 100];
set<string> ans;
int main() {
string s;
cin >> s;
valid[s.length()] = 1;
for (int i = s.length() - 1; i > 4; --i) {
if (valid[i + 2]) {
string t = s.substr(i, 2);
if (s.find(t, i + 2) != i + 2 || valid[i + 5]) {
valid... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
int n, l;
set<string> ans;
string s;
map<pair<int, string>, int> mp;
bool solve(int idx, string tmp = "") {
if (idx == s.size()) {
return 1;
}
if (idx > s.size()) return 0;
if (mp.count({idx, tmp})) {
return mp[{idx, tmp}];
}
string s3, s2;
bool x3, x2... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
const int oo = 1000000009;
const double eps = 1e-9;
const int mod = 1000000007;
bool x[10050], y[10050];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
string s;
cin >> s;
vector<string> ans;
int i = s.size() - 2;
for (; i >= 5; --i) {
if (i ==... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | import sys
value = input()
if (len(value) < 7):
print(0)
sys.exit(0)
res = set()
possible = {}
possible[len(value)] = set([2])
if (len(value) > 7):
possible[len(value)].add(3)
possibleLen = [2, 3]
for i in reversed(range(7, len(value) + 1)):
possibleVal = possible.get(i, set())
for length in poss... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1e4 + 10, md = 1000000007;
char str[maxn];
string s;
set<string> res;
int n, dp[maxn][6];
bool solve(int p, int l) {
if (p + l - 1 == n - 1) {
res.insert(s.substr(p, l));
return 1;
}
if (p + l - 1 > n - 1) return 0;
int &ret = dp[p][l];
if... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll inf = 1;
const ll mod = 1E9;
int vis[10010][4];
string a;
int n;
set<string> ms;
int bctk(int pos, int len) {
int &ret = vis[pos][len];
if (ret != -1) {
return ret;
}
ret = 0;
... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void ckmax(T& x, T y) {
x = (y > x ? y : x);
}
template <typename T>
inline void ckmin(T& x, T y) {
x = (y < x ? y : x);
}
namespace Fread {
const int SIZE = 1 << 21;
char buf[SIZE], *S, *T;
inline char getchar() {
if (S == T) {
T = (S... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 10100;
int n;
string s;
int f[maxn][5];
set<string> ret;
void dfs(int st, int len, string ori) {
if (st - len + 1 < 5 || f[st][len]) return;
f[st][len] = 1;
string tmp = "";
for (int i = st - len + 1; i <= st; i++) {
tmp += s[i];
}
if (tmp =... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
const int CHAR_COUNT = 'z' - 'a' + 1;
string s;
vector<map<string, bool>> dp;
bool F(int pos, const string& bad) {
if (dp[pos].find(bad) != dp[pos].end()) return dp[pos][bad];
if (pos == (int)s.size()) return dp[pos][bad] = true;
dp[pos][bad] = false;
if (pos + 2 <=... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
std::cout << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
const char* comma = strchr(names + 1, ',');
std::cout.write(names, comma -... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | import java.util.Scanner;
import java.util.TreeSet;
public class AlyonaAndStrings {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String word = sc.next();
TreeSet<String> set = new TreeSet<>();
boolean[] dp = new boolean[word.length()];
int num = findWords(set, dp, word);
... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
const int N = 10010;
const int A = 26;
int d2[N], d3[N];
int main() {
int i, j;
string s;
cin >> s;
int n = s.length();
d2[n] = d3[n] = 1;
for (i = n - 2; i >= 0; --i) {
d2[i] |=
d2[i + 2] & ((i + 2 > n - 2) || (s.substr(i, 2) != s.substr(i + 2, 2)))... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | import java.io.*;
import java.util.*;
public class reberland_linguistics
{
static int [][] dp;
static String s;
static TreeSet<String> hs;
static void rec(int start, int len)
{
if (start <= 4 || dp[start][len-2] == 1)
return;
dp[start][len-2] = 1;
String a = s.substring(start, start+len);
hs.add(... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | from sys import stdin, stdout
from collections import Counter, defaultdict
from itertools import permutations, combinations
raw_input = stdin.readline
pr = stdout.write
def in_num():
return int(raw_input())
def in_arr():
return map(int,raw_input().split())
def pr_num(n):
stdout.write(str(n)+'\n')
de... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
template <typename Tp>
inline void read(Tp &x) {
static char c;
static bool neg;
x = 0, c = getchar(), neg = false;
for (; !isdigit(c); c = getchar()) {
if (c == '-') {
neg = true;
}
}
for (; isdigit(c); c = getchar()) {
x = x * 10 + c - '0';
... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 10;
int dp[N][5], n;
set<string> ans;
string s;
int main() {
cin >> s;
n = s.size();
s = '.' + s;
if (n <= 6)
puts("0");
else {
dp[n + 1][2] = dp[n + 1][3] = 1;
for (int i = n - 1; i > 5; i--) {
if (i <= n - 3)
dp[i][2... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
string s;
bool dp[10100];
void read() { cin >> s; }
void solve() {
if (s.length() < 7) {
cout << 0 << endl;
return;
}
set<string> ans;
dp[s.length()] = true;
for (int i = s.length() - 2; i >= 5; i--) {
if (i == (s.length() - 2)) {
dp[i] = true;
... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
const int N = 1e4;
string s;
int n, dp[N + 10][5];
bool dfs(int i, int l) {
if (i == n) return dp[i][l] = true;
int now = 0;
if (dp[i][l] != -1) return dp[i][l];
if (l == 2) {
if (i + 1 < n && (s[i] != s[i - 2] || s[i + 1] != s[i - 1]))
now |= dfs(i + 2, 2... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pdi = pair<double, int>;
using pli = pair<ll, int>;
using triple = tuple<int, int, int>;
const int N = 3e5 + 7;
const int mod = 1e9 + 7;
string s;
bool dp[N][5];
set<string> res;
int main() {
ios_base::sync_with_stdi... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long maxn = 1e5 + 7;
const long long maxe = 1e6 + 7;
const long long INF = 1e9 + 7;
const double PI = acos(-1);
int dx[4] = {0, 0, 1, -1};
int dy[4] = {-1, 1, 0, 0};
int len;
string s;
const int maxm = 11000;
int dp[maxm][5];
set<st... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
string S;
int dp[10005][4];
int main() {
cin >> S;
dp[S.size() - 2][2] = 1;
dp[S.size() - 3][3] = 1;
for (int i = S.size() - 1; i >= 0; i--) {
if (dp[i + 3][2] == 1) dp[i][3] = 1;
if (dp[i + 2][3] == 1) dp[i][2] = 1;
if (dp[i + 3][3] == 1) {
if (S.... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
/** Class: ReberlandLinguistics.java
* @author Yury Park
* @version 1.0 <p>
* Course:
* Written / Updated: Jun 14, 2016
*
* This Cl... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
bool can[100007][4];
string s;
string get2(int pos) {
string ans;
ans += s[pos];
ans += s[pos + 1];
return ans;
}
string get3(int pos) {
string ans;
ans += s[pos];
ans += s[pos + 1];
ans += s[pos + 2];
return ans;
}
int main() {
ios::sync_with_stdio(fals... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | import java.io.*;
import java.util.Collections;
import java.util.InputMismatchException;
import java.util.LinkedList;
public class Cf2904C {
private static InputReader in = new InputReader(System.in);
private static OutputWriter out = new OutputWriter(System.out);
private static void solve() throws Excep... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | word = input()
length = len(word)
acceptable2 = [None] * length
acceptable2[0] = True; acceptable2[1] = False; acceptable2[2] = True; acceptable2[3] = False
acceptable3 = [None] * length
acceptable3[0] = True; acceptable3[1] = False; acceptable3[2] = False; acceptable3[3] = True
all_possible_suffixes = set()
def is_... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5;
set<string> S;
set<string>::iterator it;
bool vis[maxn][10];
char s[maxn];
int n, i;
void dfs(int o, int m) {
if (vis[o][m] || o - m < 5) return;
vis[o][m] = 1;
string l(s + o - m + 1, s + o + 1), r(s + o - m * 2 + 1, s + o + 1 - m);
S.insert(l... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | import java.io.*;
import java.lang.*;
import java.util.*;
// Sachin_2961 submission //
public class CodeforcesA {
static TreeSet<String>treeSet = new TreeSet<>();
public void solve() {
char[]a = fs.next().toCharArray();
int n = a.length;
boolean[][] dp = new boolean[n+1][2];
... |
Problem: First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you shou... | #include <bits/stdc++.h>
using namespace std;
char s[10005];
map<int, int> flag[10005];
set<string> ans;
int code(const string &s) {
int ret = 0;
for (int i = 0; i < s.size(); i++) ret = ret * 27 + (s[i] - 'a' + 1);
return ret;
}
void go(int n, int last) {
if (flag[n].count(last)) return;
flag[n][last] = 1;
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.