prompt string | response string |
|---|---|
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Main {
private static Map<Character, List<Character>> m = new HashMap();
priv... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | /*
Keep solving problems.
*/
import java.util.*;
import java.io.*;
public class IndiaHacks2016B {
BufferedReader br;
PrintWriter out;
StringTokenizer st;
boolean eof;
final long MOD = 1000L * 1000L * 1000L + 7;
String[] a;
char[] b;
int q;
void solve() throws IOException {
... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
int ans = 0;
int n, q;
string a[50], b[50];
void solve(int p, char x) {
if (p == n) {
ans++;
return;
}
for (int i = 1; i <= q; i++) {
if (b[i][0] == x) solve(p + 1, a[i][0]);
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t =... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
/**
* @author madi.sagimbekov
*/
public class C653B {
private static B... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
int find(map<char, vector<string> > m, int n, char start) {
int sum = 0;
if (n == 1) {
return 1;
}
for (int i = 0; i < m[start].size(); i++) {
string s = m[start][i];
char c = s[0];
sum = sum + find(m, n - 1, c);
}
return sum;
}
int main() {
in... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
map<char, vector<char> > letter;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long n, m;
cin >> n >> m;
char s1, s2, s3;
for (int q = 0; q < m; q++) {
cin >> s1 >> s2 >> s3;
letter[s3].push_back(s1);
}
long long cur = 1;
lo... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | from sys import stdin
from copy import deepcopy
def main():
line=stdin.readline().split()
n,q=int(line[0]),int(line[1])
a=[]
b=[]
for i in range(0,q):
line=stdin.readline().split()
#print line
a.append(ord(line[0][0])-ord('a'))
b.append(ord(line[1])-ord('a'))
p=[[... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | n, k = map(int, input().split())
l = []
for _ in range(k):
s1, s2 = input().split()
l.append((s1, s2))
s = 0
def dfs(last, cl):
global s, l, n
if cl == n:
s += 1
return
for item in l:
if item[1] == last:
dfs(item[0][0], cl + 1)
dfs('a', 1)
pr... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.StringTokenizer;
public class Solution {
public static final double... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
imp... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 105;
char a[maxn][2], b[maxn];
int n, q;
int dfs(int pos, int cnt) {
if (cnt <= 0) return 1;
int ans = 0;
for (int i = 0; i < q; i++) {
if (b[i] == a[pos][0]) {
ans += dfs(i, cnt - 1);
}
}
return ans;
}
int main(void) {
cin >> n >>... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000009ll;
const long long INF = 9223372036854775807ll;
long long power(long long x, long long y, long long z) {
long long t = 1;
while (y > 0) {
if (y % 2) {
t = (t * x) % z;
}
x = (x * x) % z;
}
return t;
}
int n, q, p = ... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | import java.io.*;
import java.math.BigInteger;
import java.util.*;
import static java.lang.Math.PI;
import static java.lang.System.in;
import static java.lang.System.out;
import static java.lang.System.err;
public class B {
public static boolean check(int idx, ArrayList<Integer> s, ArrayList<Pair> arr){
... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
char a[100][2], b[100];
int n, q;
int bfs(int pos, int duljina) {
if (duljina == 0) {
return 1;
}
int count = 0;
int len = duljina;
queue<pair<int, int>> s;
s.push(make_pair(pos, len));
while (!s.empty()) {
if (s.front().second > 0) {
for (int i ... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
long double det(long double x, long double y, long double z, long double t) {
return x * t - y * z;
}
long long fact(long long n) { return (n == 1 || n == 0) ? 1 : fact(n - 1) * n; }
long long star(long long n) {
long long x = 0;
while (log2(n) != 1) {
n = log2(n)... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | import java.util.*;
/**
* 653B
*
* @author hemenghai
* @date 2019/1/12 14:59
*/
public class Main {
private static int[] dx = {-1, 0, 0, 1};
private static int[] dy = {0, -1, 1, 0};
private static int obj, pos, ans, res;
private static int max, min, cur, sum;
private static int ai, bi, ci, di... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
vector<string> ve[10];
int ans = 0, n;
void sea(string a) {
if (a.size() == n) {
ans++;
return;
}
int num = a[0] - 'a';
for (int j = 0; j < ve[num].size(); j++) {
string c = "";
c = ve[num][j];
for (int k = 1; k < a.size(); k++) c += a[k];
se... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | n,q=map(int, input().split())
w=[]
for _ in range(q):w+=[input().split()[::-1]]
r=set(["a"])
t=set()
for _ in range(n-1):
for s in r:
for a, b in w:
if s.startswith(a):t.add(b+s[1:])
r=t
t=set()
print(len(r)) |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... |
import java.awt.event.KeyEvent;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.ArrayList;
im... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | n,k = map(int,input().split())
l = {}
cnt = 0
for i in range(k):
a,b = input().split()
l[a] = b;
if n==2:
print(list(l.values()).count('a'))
exit(0)
def allcombs(s,prefix,l):
global cnt
if l==0:
if (check(prefix)):
cnt+=1
return
for i in s:
allcombs(s,prefix+i,l-1)
def check(s):
while len(s)>1:
yes... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | import java.io.*;
import java.util.*;
public class bearandcompressing {
static int ans = 0;
public static void main(String[] args) throws IOException {
BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(f.readLine());
int n = Integer.parseInt(st.nex... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;
public class bearAndCompressing {
static String c;
static q[] q;
static int sum;
static int gl;
public static void main(String[] args) throws IOException {
BufferedReader ... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
char ss[10], p_ss[10];
char a[50][5], b[50];
char st[3];
int n, m;
int ans, sum;
bool judge() {
for (int i = 1; i < n; i++) {
int mark = 0;
st[0] = p_ss[i - 1], st[1] = p_ss[i], st[2] = '\0';
for (int j = 0; j < m; j++) {
if (strcmp(st, a[j]) == 0) {
p_ss[i] = b[j];
... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
long long n, q, j = 1, ans;
map<char, vector<string>> A;
void dfs(char x) {
j++;
for (int u = 0; u < A[x].size(); u++) {
if (j < n)
dfs(A[x][u][0]);
else {
ans += A[x].size();
break;
}
}
j--;
}
int main() {
cin >> n >> q;
while (q--... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution i... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | from collections import defaultdict
def rep(cand, succ):
ret = set()
for word in cand:
for r in succ[word[0]]:
ret.add(r + word[1:])
return ret
n, q = map(int, input().split())
succ = defaultdict(list)
for _ in range(q):
a, b = input().split()
succ[b].append(a)
cand = set("a... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
int n, q;
int ans = 0;
char b[37], a[37];
;
void generation(char el, int n, int len) {
if (len == n)
ans++;
else
for (int i = 0; i < q; i++)
if (b[i] == el) generation(a[i], n, len + 1);
}
int main() {
ios_base::sync_with_stdio(0);
cin >> n >> q;
for... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Main {
static List<List<Integer>> list;
static List<Integer> component;
static boolean[] visited;
public static void main(String[] args) {
FastReader scanner = new FastReader();
Map<Int... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
int n, q;
string a[40];
char b[40];
int ans;
void solve(char s, int idx) {
if (idx == n - 1) {
ans++;
return;
}
for (int i = 0; i < q; i++)
if (s == b[i]) solve(a[i][0], idx + 1);
}
int main() {
cin >> n >> q;
for (int i = 0; i < q; i++) cin >> a[i] >>... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | import java.io.*;
import java.util.*;
@SuppressWarnings("unused")
public class Main {
static Map<Character, Set<String>> map = new HashMap<Character, Set<String>>();
static int count = 0;
static Set<String> seen = new HashSet<String>();
public static void solve(String str, int n) {
if (str.length() == n) {
i... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
vector<string> z[6];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, q;
cin >> n >> q;
for (int i = 0; i < q; i++) {
string a;
char b;
cin >> a >> b;
z[b - 'a'].push_back(a);
}
set<string> s;
s.insert("a");
for (int i = 2; i <... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
public class Grylls {
private static String START_LETTER = ... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | import java.io.*;
import java.util.*;
import static java.lang.Math.*;
public class Main {
FastScanner in;
PrintWriter out;
static final String FILE = "";
ArrayList<String> list = new ArrayList<>();
char to[][];
TreeMap<String, Boolean> map = new TreeMap<>();
void calc(int n, String s) ... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, q;
long long s = 0;
char a[40][3], b[40][2];
queue<char> q1, q2;
vector<char> v[6];
scanf("%d%d", &n, &q);
for (int i = 0; i < q; i++) {
for (int j = 0; j < 2; j++) scanf(" %c", &a[i][j]);
scanf(" %c", &b[i][0]);
if (b[i][0] == ... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | import java.util.*;
import java.io.*;
import java.util.LinkedList;
public class CF653B{
public static int n, q;
public static HashMap<String, Character> map;
public static HashSet<String> set;
public static String a[];
public static void main(String[] args)throws Exception {
InputReader in = new InputRea... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
map<char, vector<string>> operations;
int main() {
int n, m;
cin >> n >> m;
for (int i = 0; i < (m); ++i) {
string s;
char c;
cin >> s >> c;
swap(s[0], s[1]);
operations[c].push_back(s);
}
set<string> used;
queue<string> q;
auto push = [&](... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #/usr/bin/env pypy3
# -*- coding: utf-8 -*-
import collections
import itertools
GOAL = "a"
Operation = collections.namedtuple("Operation", "before after")
def is_possible_operation(original_str, operation):
return original_str.startswith(operation.before)
def perform_operation(original_str, operation):
r... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
multimap<char, string> m;
int swim(string s, unsigned int n) {
if (s.size() == n) return 1;
int res = 0;
auto e = m.equal_range(s[0]);
for (auto i = e.first; i != e.second; i++) {
string d = i->second;
d += s.substr(1, s.size() - 1);
res += swim(d, n);
... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
long long dx[] = {-1, 1, 0, 0};
long long dy[] = {0, 0, 1, -1};
void DBG() { cerr << "]" << endl; }
template <class H, class... T>
void DBG(H h, T... t) {
cerr << to_string(h);
if (sizeof...(t)) cerr << ", ";
DBG(t...);
}
const long long in... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
map<string, string> p;
int ans = 0;
string tmp = "abcdef";
void doit(int n, string s) {
if (n == 0) {
int f = 0;
while (true) {
if (s.length() == 2) {
if (p.find(s) == p.end()) {
f = 1;
break;
}
if (p[s] != "a") {
... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
const int N = 10005;
const int mod = 1e9 + 7;
int b[55];
vector<string> s[6];
set<string> x;
int main() {
int n, q;
string a, b, temp, ex;
set<string>::iterator iter;
while (cin >> n >> q) {
for (int i = 0; i <= 5; i++) s[i].clear();
for (int i = 1; i <= q; ... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, q;
cin >> n >> q;
int mat[10][10] = {0};
for (int i = 0; i < q; i++) {
string a, b;
cin >> a >> b;
mat[b[0] - 'a'][a[0] - 'a']++;
}
long long dp[10][40] = {0};
dp[1][0] = 1;
for (int i = 2; i <= n; i++) {
for (int j = 0; j... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
int n, q;
string a[100];
string b[100];
int ans;
void run(int x, string now) {
if (x == n) {
if (now == "a") ++ans;
return;
}
if (x == 0) {
for (int i = 0; i < 6; ++i) {
string go = "a";
go[0] = 'a' + i;
run(1, go);
}
return;
}
... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
const long long mod = 2019;
const long double pi = acos(-1);
const long long maxn = 300006;
template <class T>
ostream &operator<<(ostream &out, vector<T> &A) {
for (auto x : A) out << x << " ";
return out;
}
template <class T>
ostream &operator<<(ostream &out, set<T> &... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
int n, q;
long long dp[10][10];
string op[50][2];
void read() {
cin >> n >> q;
for (int i = 0; i < q; i++) cin >> op[i][0] >> op[i][1];
}
void solve() {
for (int i = 0; i < 6; i++) dp[0][i] = 1;
for (int i = 1; i <= n; i++)
for (int j = 0; j < q; j++)
dp[i... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
int len, q;
vector<string> G[10];
void solve() {
queue<string> que;
map<string, bool> vis;
que.push("a");
int ret = 0;
while (!que.empty()) {
string u = que.front();
que.pop();
if (vis[u]) continue;
vis[u] = true;
if (u.size() == len) {
r... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
pair<string, char> ope[40];
int ans, q, n;
set<string> conj;
void backtrack(string s, int i) {
if (i == n) {
ans++;
} else {
for (int k = 0; k < q; k++) {
if (s[0] == ope[k].second)
backtrack(ope[k].first + s.substr(1, s.size() - 2), i + 1);
}
... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;
public class D2358B {
static HashMap map = new HashMap();
static int maxLen;
static int total;
static ArrayList<String>[] x = new ArrayList[6];
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
Strin... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
std::vector<pair<string, char> > v;
int n, q, ans = 0;
void fun(string second, int id) {
for (int i = 0; i < q; i++) {
if (second == v[i].first) {
second = "";
second += v[i].second;
break;
}
}
if (id == n - 1) {
if (second == "a") ans++;... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;
//653B
public class BearAndCompressing {
static int N;... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
const int xx[] = {1, -1, 0, 0}, yy[] = {0, 0, 1, -1};
long long pow(long long a, long long b, long long p) {
long long sum = 1;
for (a %= p; b; a = a * a % p, b >>= 1)
if (b & 1) sum = sum * a % p;
return sum;
}
char ch;
void rd(int &x) {
for (ch = getchar(); ch... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
set<string> ok;
vector<pair<string, string>> ops;
int len, sol, op;
void dfs(string s) {
if ((int)s.size() == len) {
sol++;
return;
}
for (auto &it : ops) {
if (it.second[0] == s[0]) {
string t;
t = it.first;
for (int i = 1; i < (int)s.si... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | import java.io.*;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
public class Task3 {
public static void main(String[] args) throws IOException {
new Task3().solve();
}
//ArrayList<Integer>[] g;
int mod = 1000000007;
Print... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | import itertools
from collections import deque
def all_strings(n):
for i in itertools.product('abcdef', repeat=n):
yield "".join(i)
n, q = map(int, input().split())
operations = {}
for _ in range(q):
a, b = input().split()
operations[a] = b
count = 0
for i in all_strings(n):
while i[:2] in op... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
long long MAX = 1e17;
vector<pair<string, char> > v(50);
long long count(string cur_string, long long target, long long op) {
if (cur_string.size() == target) return 1;
long long sum = 0;
for (int i = 0; i < op; i++) {
if (cur_string[0] == v[i].second) {
str... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
const int M = 1e3 + 10;
int str[10], sum, n, hash_[100];
int str1[10];
int check() {
for (int j = 1; j <= n; j++) str1[j] = str[j];
int i = 2;
while (i <= n) {
int num = str1[i - 1] * 10 + str1[i];
str1[i] = hash_[num];
if (str1[i] == 0) return 0;
i++;... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | n, q = map(int, raw_input().split())
edges = {}
for i in xrange(q):
e = raw_input().split()
edges[e[0]] = e[1]
def makeStr(i):
if i == 0: return [""]
ans = []
t = makeStr(i-1)
for ch in 'abcdef':
for l in t:
ans += [ch + l]
return ans
def check(s, n):
for i in x... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
public class Main {
static int MOD = 1000 * 1000 * 100... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeSet;
public class B {
static TreeSet<String> u = new TreeSet<String>();
public static void main(String[] args) t... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
long long fpow(long long base, long long power) {
long long result = 1;
while (power > 0) {
if (power % 2 == 1) {
result = (result * base);
}
base = (base * base);
power /= 2;
}
return result;
}
string a[50], b[50];
string Go = "abcdef";
long l... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | var alphabet = ['a', 'b', 'c', 'd', 'e', 'f']
var input = readline().split(' ')
var n = input[0]
var strings = generateStrings(n)
var q = input[1]
var ops = {}
for (var i = 0; i < q; i++) {
input = readline().split(' ')
ops[input[0]] = input[1]
}
print(
strings
.filter(function (string) {
... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
template <class T>
inline void gmax(T &a, T b) {
if (b > a) a = b;
}
template <class T>
inline void gmin(T &a, T b) {
if (b < a) a = b;
}
using namespace std;
const int N = 1e5 + 10, M = 2e6 + 10, Z = 1e9 + 7, maxint = 2147483647,
... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.Collection;
import java.util.Set;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
struct word {
int i, j;
};
word rules[10][50];
int ruletot[10];
int n, q, i, ans, u, v, w;
bool anses[65536];
int s[10];
inline int get() {
return s[1] + s[2] * 6 + s[3] * 36 + s[4] * 216 + s[5] * 1296 + s[6] * 7776;
}
inline void find(int dep) {
if (dep == n) {
i... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | from itertools import product
n, q = map(int, input().split())
T, k = {}, 0
for _ in range(q):
a, b = input().split()
T[a] = b
for s in product('abcdef', repeat=n):
s = ''.join(s)
for _ in range(n - 1):
a = s[:2]
if a not in T:
break
s = T[a] + s[2:]
else:
... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
int n, m, a[1000100], b[1000100];
vector<string> v[10];
int main() {
int r, k, i, c = 0, x = 0, y = 0, j, t, l, z, x1 = 0, y1 = 0;
long long ans = 0;
string p, s;
scanf("%d %d", &n, &m);
while (m--) {
cin >> p >> s;
v[s[0] - 'a'].push_back(p);
}
queue<... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
using namespace std;
long long n, ans, sum, x, k, ret;
string a;
int arr[1000000];
char c, b;
map<char, vector<string> > m;
map<char, int> ma;
void solve(int sz, char v) {
if (sz == n - 1) {
ans += ma[v];
return;
}
if (m[v].size() == 0) return;
for (int i = ... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
using namespace std;
int ans = 0;
int n, m;
string l[55], r[55];
bool used[55];
void dfs(int depth, int lastChar) {
if (depth == n - 1) {
if (lastChar == 'a') {
++ans;
}
return;
}
for (int i = 0; i < m; i++) {
if (lastChar != -1 && lastChar != l[... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | import itertools
n,q = map(int,raw_input().split())
op = {}
for i in xrange(q):
a,b = raw_input().split()
op[a] = b
def check(s):
if (len(s)) == 1:
return s=="a"
for i in xrange(2,3):
p = s[i-2:i]
if p in op:
if check(s[:i-2]+op[p]+s[i:]):
return Tru... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
map<char, vector<string> > m;
int l, n;
long long ans = 0;
void rek(int d, char last) {
if (d == l)
ans++;
else
for (int i = 0; i < m[last].size(); i++) {
string c = m[last][i];
rek(d + 1, c[0]);
}
return;
}
int main() {
cin >> l >> n;
for ... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | from collections import defaultdict
from itertools import product
def generate_strings(n):
for s in product("abcdef", repeat = n):
yield ''.join(s)
def compress(s, d):
while len(s) > 1:
p = s[:2]
if p not in d:
break
s = d[p] + s[2:]
return s
def solve(n, d):
... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | n, m = map(int, input().split())
t = [[] for i in range(6)]
for i in range(m):
a, b = input().split()
t[ord(b) - ord('a')] += [a]
l = ['a']
A = 0
while len(l) > 0:
L = []
for s in l:
if len(s) == n:
A += 1
continue
for i in range(1):
ch = s[i]
... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
map<char, map<char, int>> m;
int sol(char z, int n) {
int ss = 0;
int kk;
if (n == 1) return 1;
for (char i = 'a'; i <= 'f'; i++)
if (m[z][i] > 0) ss += m[z][i] * sol(i, n - 1);
return ss;
}
int main() {
int n, q;
cin >> n >> q;
string a, b;
while (q--... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
/*07:05:45PM
String x =sc.next();
char inp [] = x.toCharArray();
SimpleDateFormat displayFormat = new SimpleDateFo... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
int n, m, q[6];
long long x[1005][1 << 6], ans;
char y[5], z[5];
vector<int> w[6][6];
int main() {
scanf("%d%d", &n, &m);
for (int a = 0; a < m; a++) {
scanf("%s%s", y, z);
w[z[0] - 'a'][y[1] - 'a'].push_back(y[0] - 'a');
}
x[0][1] = 1;
for (int a = 0; a <... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
map<char, vector<string> > adj;
int c = 2, cnt = 0, s, n;
void dfs(char node) {
if (c == s) {
cnt += adj[node].size();
return;
}
c++;
if (adj[node].empty()) return;
for (string child : adj[node]) {
int d = c;
dfs(child[0]);
c = d;
}
}
int mai... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | def recursion(lst, dictionary):
if len(lst) == 0:
return []
if len(lst[0]) >= n:
return lst
newLst = []
for el in lst:
if dictionary.has_key(el[0]):
newLst += [x + el[1:] for x in dictionary[el[0]]]
return recursion(newLst, dictionary)
n, q = map(int, raw_in... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
int n, q, o;
char s[80], t[80], a[380][3], b[380][2];
bool check(void) {
int i, j;
bool f;
strcpy(t, s);
for (i = 1; i < n; i++) {
for (j = 0, f = false; j < q; j++)
if (t[i - 1] == a[j][0] && t[i] == a[j][1]) {
f = true;
t[i] = b[j][0];
... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | a,b=map(int,input().split());c=[list(input().split()) for _ in " "*b];z=['a'];t=[]
for i in range(1,a):
for j in z:
for k in c:
if j[0]==k[1]:t.append(k[0]+j[1::])
z=t;t=[]
print(len(z))
|
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
char a[40][5], b[40][5];
long long dp[10][10];
int main() {
int n, q;
cin >> n >> q;
for (int i = 0; i < q; ++i) cin >> a[i] >> b[i];
dp[0][0] = 1;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < 6; ++j) {
if (dp[i][j]) {
for (int k = 0; k < q;... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
vector<string> sequences;
map<string, char> subs;
string symbols = "abcdef";
int n, q;
void generate(int pos, string str) {
if (pos == n) {
sequences.push_back(str);
return;
}
for (int i = 0; i < symbols.size(); i++) {
generate(pos + 1, str + symbols[i]);
... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
const int M = 1000000007;
long long n, q;
vector<string> v;
set<string> o;
void fun(string a, long long c) {
if (c == (n - 1)) {
if (o.find(a) == o.end()) o.insert(a);
return;
}
long long i;
string b;
for (i = 0; i < q; i++) {
if (v[i][2] == a[0]) {
... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | import java.io.*;
import java.util.*;
public class Main_653B {
private static Scanner sc;
private static Printer pr;
private static void solve() {
int n = sc.nextInt();
int q = sc.nextInt();
char[][][] ab = new char[q][2][];
for (int i = 0; i < q; i++) {
ab[i][0] = sc.next().toCharArray();
ab[i][1... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | n, q = map(int, input().split())
operations = [None] * q
for i in range(q):
operations[i] = input().split()
dp = [0] * 26
dp_buf = [0] * 26
length = 1
dp[0] = 1
cnt = 0
while length < n:
for new, c in operations:
for i in range(26):
if dp[i] > 0 and chr(97 + i) == c:
dp_buf[o... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | def deep(ch, curn):
s = 0
for i in d[ch]:
if i[0] in 'abcdef' and i[1] in 'abcdef':
if curn and i[0] in d:
s += deep(i[0], curn-1)
elif curn == 0:
s += 1
return s
n, m = map(int, input().split())
d = {}
for i in range(m):
dec, en = input()... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
#pragma comment(linker, "/STACK:66777216")
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
const char* ... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
int n, q, ans;
char ar[150][150];
map<string, bool> used;
void f(string h) {
if (used[h] != 0) {
return;
}
used[h] = 1;
if (h.length() == n) {
ans++;
return;
}
for (int i = 0; i < 26; i++)
for (int j = 0; j < 26; j++)
if (ar[char(i + 97)][c... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | import java.io.*;
import java.util.*;
public class Main
{
static BufferedReader br;
static StringTokenizer st;
static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
public static class AL<T> extends ArrayList<T> {};
public static class HM<T,Integer> ... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
int n, q;
string a[50];
string b[50];
int dfs(char c, int dep) {
if (dep == n - 1) {
return 1;
}
int ans = 0;
for (long long int i = 1; i <= q; i++) {
if (b[i][0] == c) {
ans += dfs(a[i][0], dep + 1);
}
}
return ans;
}
int main() {
ios::sync_... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
const int maxn = 4007;
std::vector<char> lis;
struct Node {
char a[11], b;
} node[maxn];
int n, q;
int dfs(char s, int len) {
if (len == n) return 1;
int ret = 0;
for (int i = 1; i <= q; i++) {
if (node[i].b == s) ret += dfs(node[i].a[0], len + 1);
}
return ret;
}
int main() {
... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | def q(curr):
global ans
if len(curr)==n:
while len(curr)>1 and curr[:2] in w:
curr=w[curr[:2]]+curr[2:]
if curr=='a':ans+=1
else:
for i in 'abcdef':q(curr+i)
n,qq=map(int,raw_input().split())
w={}
ans=0
for i in xrange(qq):
a,b=raw_input().split()
w[a]=b
q('')
pri... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | import java.io.*;
import java.util.LinkedList;
import java.util.Objects;
import java.util.StringTokenizer;
import java.util.TreeMap;
public final class Main {
static TreeMap<String, String> map = new TreeMap<>();
static int cnt = 0, q, n;
public void solve() {
n = in.nextInt();
q = in.nex... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | import java.io.*;
import java.util.*;
import java.lang.*;
import java.awt.*;
import java.awt.geom.*;
import java.math.*;
import java.text.*;
import java.math.BigInteger.*;
import java.util.Arrays;
public class Question51
{
BufferedReader in;
StringTokenizer as;
boolean nums[],nums2[];
int[] nums1[];
Array... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, q, ans = 0;
cin >> n >> q;
map<string, char> two;
for (int i = 0; i < q; i++) {
string s1;
char c;
cin >> s1 >> c;
two[s1] = c;
}
string cur(n, 'a'), end(n, 'f');
while (cur ... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | import java.io.*;
import java.util.*;
public class Main {
static int n;
static int q;
static String[][] oper;
static char[] arr = { 'a', 'b', 'c', 'd', 'e', 'f' };
static char[] result;
static boolean[] check = new boolean[6];
static int count;
public static void main(String[] args) throws IOException {
Buf... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
int n, q;
vector<int> v[60];
inline int ch(char c) { return (c - 'a' + 1); }
int dfs(int depth, int s) {
if (depth == n) return s == 1;
int res = 0;
for (int i = 1; i <= 6; ++i) {
int p = s * 6 + i;
if (v[p].size() == 0) continue;
res += dfs(depth + 1, v[p... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
map<string, int> mp;
char a[40][3] = {0}, b[40];
int n, q, tot = 0;
void dfs(int x, string s) {
if (x == n) {
if (!mp.count(s)) mp[s] = 1, tot++;
return;
}
for (int j = 0; j < q; j++)
if (b[j] == s[0]) {
string tmp = "";
tmp += (string)a[j] + s... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
long long M = 1e15 + 37;
const long long N = 1000 + 10;
const long long IM = 1e18;
const long long PI = 3.14159265;
void PV(vector<long long> v) {
for (long long i = 0; i < v.size(); i++) cout << v[i] << " ";
cout << "\n";
}
void PA(long long v[], long long n, long long... |
Problem: Limak is a little polar bear. Polar bears hate long strings and thus they like to compress them. You should also know that Limak is so young that he knows only first six letters of the English alphabet: 'a', 'b', 'c', 'd', 'e' and 'f'.
You are given a set of q possible operations. Limak can perform them in an... | #include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 1200;
int a[maxn];
vector<int> v[15];
char str[50][30], str2[50][30];
int n, m;
long long dfs(int cur, int x) {
if (cur + 1 == n) return a[x];
long long s = 0;
for (vector<int>::iterator it = v[x].begin(); it != v[x].end(); it... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.