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... | #include <bits/stdc++.h>
using namespace std;
bool b[1000100];
int n, m, q[1000100], from[50], to[50];
int len(int x) {
int l = 1;
while (x / 10 != 0) {
l++;
x /= 10;
}
return l;
}
int fd(int x) {
while (x / 10 != 0) {
x /= 10;
}
return x;
}
int pow(int x) {
int p = 1;
while (x / 10 != 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... | #include <bits/stdc++.h>
using namespace std;
map<char, vector<string>> s;
long long func(char a, long long n) {
if (n == 2) {
return s[a].size();
} else {
long long suma = 0;
for (string q : s[a]) {
suma += func(q[0], n - 1);
}
return suma;
}
}
int main() {
long long n, q, i;
scanf(... |
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 inf = (int)2 * 1e9;
const int MOD = (int)1e9 + 7;
const int p = 239;
const int MAX_N = 10;
const long double pi = 3.1415926535897932384626;
const long double eps = 1e-6;
int n, q;
string a[36][2];
int rec(int num, string s) {
if (num == n) {
for (int 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... | //package spoj;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Vector;
import javax.jws.Oneway;
public class Back {
static int req,count=0;
private static void dfs(char c,HashMap<Character, ArrayList<String>> map,int level) {
if(level==req)
... |
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> ans;
int n, q;
vector<pair<string, string>> a;
map<string, int> used;
vector<string> can;
void solve() {
while (can.size()) {
string cur = can.back();
can.pop_back();
if (cur.size() == n) {
ans.insert(cur);
continue;
}
for (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... | from collections import defaultdict
n, q = map(int, input().split())
es = defaultdict(list)
for _ in range(q):
a, b = input().split()
es[b].append(a)
ss = set('a')
for i in range(1,n):
ssp = set()
for s in ss:
for e in es[s[0]]:
ssp.add(e+s[1:])
ss = ssp
if not ss:
break
print(len(ss))
|
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;
import java.util.StringTokenizer;
public class B {
public static void main(String[] args) {
... |
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{
int n;;
int q;;
char[][] from;
char[] to;
HashSet<String> ans = new HashSet<>();
HashSet<String> memo = new HashSet<>();
public void solve(){
n = nextInt();
q = nextInt();
from = new char[q][2];
to = new char[q];
for(int i = 0; i < q; 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 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;
set<string>::iterator iter;
while (cin >> n >> q) {
for (int i = 0; i <= 5; i++) s[i].clear();
for (int i = 1; i <= q; 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 sys import stdin, stdout, setrecursionlimit
import threading
# tail-recursion optimization
# In case of tail-recusion optimized code, have to use python compiler.
# Otherwise, memory limit may exceed.
# declare the class Tail_Recursion_Optimization
class Tail_Recursion_Optimization:
def __init__(self, RECURSI... |
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, b;
set<string> S;
map<char, set<string>> ab;
int go(string s) {
if (s.length() == n)
S.insert(s);
else
for (auto &a : ab[s[0]]) go(a + s.substr(1, 42));
return S.size();
}
int main() {
for (cin >> n >> q; q--; ab[b[0]].insert(a)) cin >> 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;
char a[36], b[36];
int recursion(char c, int s) {
int ttl = 0;
if (s == n - 1) return 1;
for (int i = 0; i < q; i++)
if (c == b[i]) {
ttl += recursion(a[i], s + 1);
}
return ttl;
}
int main() {
cin >> n >> q;
for (int i = 0; i < q; i++) 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... |
/**
*
* @author sarthak
*/
import java.util.*;
import java.math.*;
import java.io.*;
public class indiahacks16_B {
static class FastScanner {
BufferedReader br;
StringTokenizer st;
public FastScanner(InputStream is) {
br = new BufferedReader(new InputStreamReader(is));
... |
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>
struct pairhash {
template <typename T, typename U>
std::size_t operator()(const std::pair<T, U>& x) const {
return std::hash<T>()(x.first) ^ std::hash<U>()(x.second);
}
};
long long compute_gcd(long long a, long long b) {
if (b == 0) return a;
return compute_gcd(b, a % b);
}
unsi... |
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... | /* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Ideone
{
static int n,q;
static HashMap<String, String> hm;
public static boolean isValid(String s) {
while(s.length() ... |
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;
template <class T>
inline T gcd(T a, T b) {
return b ? gcd(b, a % b) : a;
}
template <class T>
inline T LCM(T a, T b) {
if (a < 0) return LCM(-a, b);
if (b < 0) return LCM(a, -b);
return a * (b / gcd(a, b));
}
int l, q;
int arr[200][200];
char len[10];
int ans = 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... | #include <bits/stdc++.h>
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* comma = strchr(names + 1, ',');
cerr.writ... |
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;
string s1[40], s2[40];
map<string, int> msi;
map<string, string> mss;
bool cnt(string s) {
if (s.size() == 1 && s[0] == 'a') return 1;
if (s.size() == 1) return 0;
string nn = "";
nn += s[0];
nn += s[1];
if (msi.count(nn)) {
nn = mss[nn];
for (int i = 2;... |
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 MX = 2005;
int n, q;
map<string, string> m;
int ans = 0;
void eval(string s) {
while (s.length() > 1) {
if (m.count(s.substr(0, 2)) > 0) {
s = m[s.substr(0, 2)] + s.substr(2, s.length() - 2);
} else
break;
}
if (s == "a") ans++;
}
void ge... |
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.HashMap;
import java.util.Scanner;
/**
* Created by karimo on 6/9/16.
*/
public class Main {
public static int Count = 0;
public static HashMap<String,String> ListOf = new HashMap<String,String> ();
public static void Check(String x){
while(x.length () != 1){
if(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... | //package codeforces;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
public class BearAndCompressing {
static Map<Character, List<String>> map;
static Set<String> result;
public static v... |
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 Indiahacks_2016_B {
public static void main(String[] args) throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] str = br.readLine().split(" ");
int n = Integer.parseInt(str[0]), q = Integer.parseInt(str[1]);
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... | import java.io.PrintWriter;
import java.util.HashMap;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
public class B2 {
private static HashMap<String, String> map;
private static int ANS;
public static void... |
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... | # -*- coding:utf-8 -*-
class Limak(object):
def change(self, c):
if c == 'a':
return 0
elif c == 'b':
return 1
elif c == 'c':
return 2
elif c == 'd':
return 3
elif c == 'e':
return 4
elif c == 'f':
return 5
def __init__(self):
self.n, q = map(int, raw_input().split())
self.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... | #include <bits/stdc++.h>
using namespace std;
vector<pair<string, char> > query;
void increment(string& str) {
int ind = str.size() - 1;
while (ind >= 0) {
if (str[ind] != 'f') {
char cur = str[ind] + 1;
str[ind] = cur;
return;
} else {
str[ind] = 'a';
ind--;
}
}
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;
int n, q;
int cnt;
string a[100], t, x;
char b[100];
set<string> ss;
void compr(string a1) {
if (a1.length() == n) {
cnt++;
return;
} else {
for (int j = 0; j < q; j++) {
if (b[j] == a1[0]) {
t = a1;
x = a1.replace(0, 1, a[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... |
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
public class Tree {
public static HashMap<Integer, Integer> sortByValue(HashMap<Integer, Integer> hm)
{
List<Map.Entry<Integer, Integer> > list =
new LinkedList<Map.En... |
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, ans = 0;
deque<char> q;
map<string, char> mp;
void gen(int idx) {
if (idx == n) {
deque<char> aux;
string res;
while (!q.empty()) {
res += q.front();
aux.push_back(q.front());
q.pop_front();
}
bool flag = true;
while (fl... |
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>
int n, q, Ans = 0;
char s[100], a[100];
int head[100], l = 0;
struct Node {
int from, to, next;
} f[100];
void Dfs(int k, int st) {
if (st == n) {
Ans++;
return;
}
for (int i = head[k]; i; i = f[i].next) Dfs(f[i].to, st + 1);
}
int main() {
scanf("%d%d", &n, &q);
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... | n,q=map(int,raw_input().split())
d={}
ans=chk=0
l=[]
for i in range(q):
a,b=map(str,raw_input().split())
d[a]=b
if b=='a':
l.append([a[0],2])
while 1:
if len(l)==0:
break
tmp=l.pop()
if tmp[1]==n:
ans+=1
continue
for i in d:
if d[i]==tmp[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... | /**
* Created by Omar on 3/19/2016.
*/
import java.util.*;
import java.io.*;
public class BEditorial {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(System.out);
//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... | read = lambda: map(int, input().split())
n, q = read()
s = [tuple(input().split()) for i in range(q)]
dp = [[0] * (n + 1) for i in range(6)]
alp = 'abcdef'
for c in alp:
res = 0
for a, b in s:
if b == c:
res += 1
dp[ord(c) - ord('a')][0] = res
for j in range(1, n - 1):
for c in alp:
... |
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<string> ops[26];
void read() {
cin >> n >> q;
while (q--) {
string s, t;
cin >> s >> t;
ops[t[0] - 'a'].push_back(s);
}
}
void process() {
vector<string> ans;
queue<pair<string, int> > q;
q.emplace("a", 0);
while (q.size()) {
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;
pair<string, string> p[40];
char arr[] = {'a', 'b', 'c', 'd', 'e', 'f'};
map<string, int> mp;
vector<string> vec;
int n, q;
void rec(string s) {
if (s.size() == n) {
vec.push_back(s);
return;
}
for (int i = 0; i < 6; i++) {
rec(s + arr[i]);
}
}
int solve... |
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.*;
public class PhoneNumber {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int n = in.nextInt(),
q= in.nextInt();
Map<String, String> m = new HashMap<>();
for (int i = 0; i < q; i++){
m.put(in.next(), 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... | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import time
pat = {}
(n, q) = (int(i) for i in input().split())
for i in range(q):
(a, b) = [i for i in input().split()]
if b in pat.keys():
pat[b].append(a)
else:
pat[b] = [a]
start = time.time()
str = ['a']
for i in range(n-1):
newstr... |
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;
unordered_map<string, string> mp;
vector<string> v;
void gen(int k, string s) {
if (k == 0) {
v.push_back(s);
return;
}
for (char ch = 'a'; ch <= 'f'; ch++) {
s.push_back(ch);
gen(k - 1, s);
s.pop_back();
}
}
int main() {
ios::sync_with_stdio(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.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.LinkedHashSet;
public class bearAndCompressing {
public static String[][] array;
public static LinkedHashSet<String> set = new LinkedHashSet<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>
using namespace std;
int n, q, ans[10];
long long res;
map<char, vector<string> > mp;
vector<char> fr;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cin >> n >> q;
for (int i = 0; i < q; i++) {
string a;
char b;
cin >> a >> b;
mp[b].push_back(a);
}
if (mp... |
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.math.*;
import java.io.*;
public class B
{
public static void main(String args[])throws Exception
{
Scanner in=new Scanner(System.in);
//Scanner in=new Scanner(new FileReader("C://Users//Lokesh//Desktop//"));
//BufferedReader br=new BufferedReader(new 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... | ans=0
def check(s,n):
global ans
if len(s)==n:
while len(s)>1:
try:
s=l[s[:2]]+s[2:]
except KeyError:
return
if s=='a':
ans+=1
return
for i in range(6):
check(s+chr(97+i),n)
n,q = list(map(int,input().split... |
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 power(int n) {
long long k = 1;
for (int i = 1; i <= n; i++) {
k *= 6;
}
return k;
}
int main() {
int n, q;
long long num = 0, s = 0;
char a[47000][6], b[36][2], c[36];
scanf("%d%d", &n, &q);
for (int i = 0; i < q; i++) {
scanf("%s %c", 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... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class B {
BufferedReader reader;
StringTokenizer tokenizer;
PrintWriter out;
public void solve() throws IOException {
int N = nextInt();
int Q = 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;
string s = "abcdef";
char x[40][2], y[40];
int n, q, ans;
vector<char> v;
void rec(int idx) {
if (idx == n) {
bool f;
ans++;
string vv = "";
for (int i = 0; i < n; i++) vv += v[i];
for (int i = 0; i < n - 1; i++) {
f = 0;
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 m, wys, n;
string s[38];
char c[38];
void dfs(int id, int k) {
if (k == n - 1) {
if (c[id] == 'a') wys++;
return;
}
for (int i = 0; i < m; i++) {
if (c[id] == s[i][0]) dfs(i, k + 1);
}
}
int main() {
wys = 0;
cin >> n >> m;
for (int i = 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... | #include <bits/stdc++.h>
#pragma comment(linker, "/STACK:66777216")
using namespace std;
set<string> ans;
map<char, vector<string> > m;
int n, q;
string a[200005];
string b[200005];
void solve(string s) {
if (s.size() == n) {
ans.insert(s);
return;
}
string cur = "";
for (int i = 0; i < s.size() - 1; 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 sys
sys.setrecursionlimit(10000000)
n, nEdges = map(int, raw_input().split())
edges = {}
for _ in xrange(nEdges):
u, v = raw_input().split()
edges[u] = v
letters = 'abcdef'
def bfs(start):
visited = {start}
q = [start]
while q:
curStr = q.pop(0)
firstTwo = curStr[:2]
... |
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 int n, q;
string input[36], output[36];
map<string, bool> M;
long long int res(string cur) {
if (cur.length() == n) {
if (!M[cur]) {
M[cur] = true;
return 1;
}
return 0;
}
long long int curResult = 0;
for (long long int T = 0; T < 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 cou[6];
int q;
string a[40], b[40];
long long dp[6][8];
long long calc(int i, int n) {
if (dp[i][n] != -1) {
return dp[i][n];
}
if (n == 2) {
return dp[i][n] = cou[i];
} else {
long long ans = 0;
for (int j = 0; j < q; j++) {
if (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... | #include <bits/stdc++.h>
using namespace std;
int count_n = 0, n, b;
void tree(char x, int l, string a[], char z[]) {
if (l == n) {
count_n++;
return;
} else {
for (int i = 0; i < b; i++) {
if (z[i] == x) {
tree(a[i][0], l + 1, a, z);
}
}
}
}
int main() {
cin >> n >> b;
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... | import java.util.*;
import java.io.*;
public class Solution{
static Map<String , List<String>> map = new HashMap<>();
public static void main(String []args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int q = sc.nextInt();
int res = 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.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
public class Main {
/**
* @param args
*/
// 1.a 2.b 3.c 4.d 5.e 6.f 0.null
static int num[][] = new int [7][7];
static int jishu = 0;
public static void main(String[] args) {
// TODO Auto-generated met... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const double PI = acos(-1);
const int MOD = (int)1e9 + 7;
const int MAXN = (int)3e6 + 7;
struct line {
long long slope, delta;
line() {}
line(long long k, long long c) {
slope = k;
delta = c;
}
friend bool operator<(line a, line b)... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
struct op {
int tp;
int a, b, x;
int id;
void read() {
scanf("%d", &tp);
if (tp == 1)
scanf("%d%d", &a, &b);
else
scanf("%d", &x);
}
};
int n, i, bucket_size;
op Q[300011];
map<pair<int, int>, int> M;
vector<pair<int, int> > lines;
int cnt[... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
#pragma warning(disable : 4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("-ffloat-store")
using namespace std;
clock_t time_p = clock();
void aryanc403() {
time_... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
const int N = 300005;
struct Point {
int x, y;
Point(int _x = 0, int _y = 0) {
x = _x;
y = _y;
}
Point operator-(const Point &R) const { return Point(x - R.x, y - R.y); }
long long operator^(const Point &R) const {
return (long long)x * R.y - (long lon... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
int const inf = 1000 * 1000 * 1000;
long long const inf64 = 1ll * inf * inf;
template <class T>
struct ConvexHullTrick {
size_t sz;
vector<pair<T, T> > Lines, st;
ConvexHullTrick() { sz = 0; }
bool check(pair<T, T> a, pair<T, T> b) const {
if (a.second < 0) a.fi... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
template <typename Tp>
Tp &read(Tp &x) {
static char c, f;
for (f = 0; !isdigit(c = getchar());) f |= (c == '-');
for (x = 0; isdigit(c); c = getchar()) x = x * 10 + c - '0';
return f ? x = -x : x;
}
template <typename Tp>
Tp read() {
Tp x;
return read(x);
}
str... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
const int BLOCK_SIZE = 1000;
const long long INF = 3e18;
struct TQuery {
int Idx;
int Type;
union {
struct {
long long A;
long long B;
};
struct {
int Q;
};
struct {
int EraseIdx;
};
};
};
struct TFrac {
long long P;... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <typename T, const T id>
class retroactive_CHT {
struct line {
T a, b;
line(T a_ = 0, T b_ = 0) : a(a_), b(b_) {}
T get(T x) const { return a * x + b; }
};
const int n;
const vector<T> pos;
vector<line> data;
vector<pai... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
const long long int is_query = LLONG_MIN;
struct Line {
long long int m, b;
mutable function<const Line*()> succ;
bool operator<(const Line& rhs) const {
if (rhs.b != is_query) return m < rhs.m;
const Line* s = succ();
if (!s) return 0;
long long int x... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
const int N = 300010;
int n, out[N], in[N], q[N], tot;
pair<int, int> p[N];
long long ans[N];
bool pd[N];
vector<pair<int, int> > v[N * 4], tmp;
struct Node {
int l, r;
} t[N * 4];
void build(int x, int l, int r) {
t[x].l = l, t[x].r = r;
if (l == r) return;
int mid... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
const double g = 10.0, eps = 1e-12;
const int N = 300000 + 10, maxn = 400000 + 10;
struct point {
long long x, y;
point(long long x = 0, long long y = 0) : x(x), y(y) {}
bool operator<(const point &rhs) const {
return x < rhs.x || (x == rhs.x && y < rhs.y);
}
... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
const long long INF = 1LL << 61;
using namespace std;
int t[300005], r[300005], empty[300005];
long long ans[300005];
struct Point {
long long x, y;
bool operator<(const Point &B) const {
return x < B.x || (x == B.x && y < B.y);
}
Point operator-(const Point &B) const { return (Poin... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18 + 2e9;
struct query {
int flag, x, y, id;
};
query qy[300100];
struct point {
int x, y;
double ix, iy;
bool operator<(const point &temp) const {
if (x == temp.x) return y > temp.y;
return x < temp.x;
}
};
point now, stk[300100];
... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
const int N = 300005;
using ll = long long;
int n, tp[N], x[N], y[N];
ll ans[N], q[N];
bool vis[N];
struct TNode {
int l, r;
vector<pair<int, int>> v;
} t[N << 2];
inline int lc(int pos) { return pos << 1; }
inline int rc(int pos) { return pos << 1 | 1; }
void build(int... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
const long long inf = 3e18;
const int inf2 = 1e9 + 2;
const int mod = 1000000007;
inline int mf(int a, int b) {
int buf = 0;
if (a % b != 0) buf++;
if ((a >= 0 && b >= 0) || (a < 0 && b < 0)) return a / b + buf;
return a / b;
}
pair<int, int> ma[300003];
int cht[300... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 50;
int n, cnt, x[N], y[N], s[N], t[N], q[N], m, p[N], L[N * 4], R[N * 4], tt[N],
num;
long long d, ans[N];
vector<int> v[N * 4];
bool cmp(int a, int b) { return x[a] < x[b]; }
bool cmpp(int a, int b) { return q[a] < q[b]; }
bool cmp1(int a, int b, i... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 5;
int n;
struct P {
long long x, y;
};
bool operator<(const P &a, const P &b) {
return a.x == b.x ? a.y < b.y : a.x < b.x;
}
P operator-(P a, P b) { return (P){a.x - b.x, a.y - b.y}; }
long long operator*(P a, P b) { return a.x * b.y - a.y * b.x;... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > tree[1050000];
void add(int s, int e, int ps, int pe, int p, pair<int, int> v) {
if (e < ps || pe < s) return;
if (s <= ps && pe <= e) {
tree[p].push_back(v);
return;
}
int pm = (ps + pe) / 2;
add(s, e, ps, pm, 2 * p, v);
add(s, e... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
int sgn(int a) {
if (!a) return 0;
if (a > 0) return 1;
return -1;
}
int di(int a, int b) {
if (!a) return 0;
if (sgn(a) == sgn(b)) return a / b;
return a / b - 1;
}
struct query {
int t, a, b;
};
const int N = 300000;
const int K = 20000;
int n;
long long ans[N];
query q[N];
bool... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &t) {
t = 0;
char c = getchar();
long long f = 1;
while (c < '0' || c > '9') {
if (c == '-') f = -f;
c = getchar();
}
while (c >= '0' && c <= '9') {
t = (t << 3) + (t << 1) + c - '0';
c = getchar();
}
... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
void bad(string mes = "Impossible") {
cout << mes;
exit(0);
}
template <typename... T>
void shit(T&... x) {}
template <typename... T>
void dec(T&... x) {
shit(--x...);
}
template <typename... T>
void inc(T&... x) {
shit(++x...);
}
template <typename T>
string bin(T ... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
const long double EPS = 1e-10;
const long long int MOD = 1000000007ll;
const long long int mod1 = 1000000009ll;
const long long int mod2 = 1100000009ll;
int INF = 2147483645;
long long int INFINF = 9223372036854775807;
int debug = 0;
using namespace std;
void print(int a[], int s, int e) {
fo... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
const int N = 301010;
int n, op[N], a[N], b[N], c[N];
vector<pair<int, int> > v[N << 1];
void Ins(int l, int r, int L, int R, pair<int, int> p) {
int c = (l + r) | (l != r), mid = (l + r) >> 1;
if (L <= l && r <= R)
v[c].push_back(p);
else {
if (L <= mid) Ins(... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
long long read() {
long long x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = (x << 3) + (x << 1) + (ch ^ 48);
ch = getchar();
}
return x * f;
}
pair... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 4e5 + 10;
const long long INF = 2e18;
const long double EPS = 1e-9;
struct Line {
int a, b;
long double inter(const Line& l) const {
assert(a != l.a);
return (long double)(l.b - b) / (a - l.a);
}
Line() {}
Line(int a, int b) : a(a), b(b) {... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
const long double EPS = 1e-20;
const long long mod = 1000000007;
const long long INF = mod * mod + mod;
struct Line {
long long a, b;
long double inter(const Line& l) const {
return (long double)(l.b - b) / (a - l.a);
}
Line() {}
Line(long long a, long long b)... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
struct lichao {
int l, r;
long long A, B;
lichao() : l(0), r(0), A(0), B(-0x7fffffffffffffffLL) {}
} tree[3 << 20];
const int MAX = 1e9, SZ = 1 << 19, MAX_SIZE = 1 << 20;
int op, node_cnt = 2 * SZ, T[300000];
vector<pair<int, int>> query;
char buf[MAX_SIZE], obuf[MAX_... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
const long long inf = 2e18;
const int maxn = 500010;
int n, root, topt, nt[maxn], sx, sy;
long long ans;
struct da {
int lc, rc;
} a[4 * maxn];
struct qu {
int op;
long long x, y;
} q[maxn];
vector<int> now[4 * maxn];
vector<int> tu[4 * maxn];
bool cmp(int aa, int bb)... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
struct P {
long long x, y;
void read() { scanf("%lld%lld", &x, &y); }
void write() const { printf("(%lld,%lld)", x, y); }
long long operator*(const P& b) const { return x * b.y - y * b.x; }
P operator+(const P& b) const { return P{x + b.x, y + b.y}; }
P operator... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
const long long INF = 5 * 1e18;
template <class T1, class T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
return os << p.first << " " << p.second;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
for (size_t i = 0; i < v.size(); ... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
const int MAX_N = (int)3e5 + 123;
const double eps = 1e-6;
const int mod = 2017;
using namespace std;
struct Line {
int k, b;
Line() {}
Line(int k, int b) : k(k), b(b) {}
bool operator<(const Line &first) const {
if (k != first.k) return k < first.k;
return b > first.b;
}
do... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
const int N = 301010;
const int K = (int)log2(N) + 2;
const int SQRTN = (int)sqrt(N) + 7;
const long long infi = 1ll << 63;
long long n, t[N], a[N], b[N], sz, ans[N], mn, mx;
set<long long> remprev, rem;
const long long is_query = -(1LL << 62);
struct Line {
long long m, ... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
#pragma comment(linker, "/STACK:667772160")
using namespace std;
struct __isoff {
__isoff() {
if (0) freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
srand('C' + 'T' + 'A' + 'C' + 'Y' + 'M' + 'B' + 'A');
}
~__isoff() {}
} __osafwf;
const unsigned long long p1 ... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
const long long N = 3e5 + 5;
const long long inf = 9000000000000000000;
const long long xiinf = 1e9 + 5;
long long n, dui[N], cnt, cnt1, ma[N << 2], pan[N], h[N << 2], t[N << 2], cnt2,
gudan, ans[N];
struct pigu {
long long x, y, l, r;
} a[N];
struct xunwen {
long l... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
const int B = 1000;
const long long NIL = LLONG_MIN;
struct P {
long long x, y;
P() : x(0), y(0) {}
P(long long x, long long y) : x(x), y(y) {}
P operator-() const { return P(-x, -y); }
P operator-(const P &r) const { return P(x - r.x, y - r.y); }
bool operator<... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
const int N = 300005;
const long long INF = 2000000000000000000LL;
int n;
struct Point {
int x, y;
Point() {}
Point(int x, int y) : x(x), y(y) {}
bool operator<(const Point& c) const {
if (x == c.x) return y < c.y;
return x < c.x;
}
Point operator-(const... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = 2e18;
const int N = 1400000;
struct line {
ll a, b;
line(ll a = 0, ll b = -inf) : a(a), b(b) {}
ll getValue(ll x) { return a * x + b; }
} L[N];
int qx[N];
void add(int u, int l, int r, line li) {
int m = l + r >> 1;
bool lef = ... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
const long long N = 3e5 + 5;
const long long inf = 9000000000000000000;
const long long xiinf = 1e9 + 5;
long long n, dui[N], cnt, cnt1, ma[N << 2], pan[N], h[N << 2], t[N << 2], cnt2,
gudan, ans[N];
struct pigu {
long long x, y, l, r;
} a[N];
struct xunwen {
long l... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 3e5 + 66;
const ll inf = 2e18;
struct node {
int L, R;
ll x, y;
node(int a, int b, ll c, ll d) { L = a, R = b, x = c, y = d; }
};
vector<node> lines;
ll a[N], b[N], ans[N], q[N];
int t[N], rem[N], ind[N];
struct line {
ll k, b;
... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
long long ln, lk, lm;
void etp(bool f = 0) {
puts(f ? "Yes" : "No");
exit(0);
}
void addmod(int &x, int y, int mod = 1000000007) {
x += y;
if (x >= mod) x -= mod;
}... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
const long long inf = 2e18;
struct cht {
vector<pair<int, int> > hull;
int cur = 0;
cht() { hull.clear(); }
bool useless(const pair<int, int> left, const pair<int, int> middle,
const pair<int, int> right) {
return (middle.second - left.second) * 1... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
const int N = 300005;
struct Point {
int x, y;
Point(int _x = 0, int _y = 0) {
x = _x;
y = _y;
}
Point operator-(const Point &R) const { return Point(x - R.x, y - R.y); }
long long operator^(const Point &R) const {
return (long long)x * R.y - (long lon... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | import java.util.*;
import java.io.*;
/*
7
3 1
1 2 3
3 1
1 -1 100
3 1
2 4
3 1
48
3 -99
1 -1 32
2 2
1 -18 -86
2 4
3 -32
1 -21 -38
1 -60 -96
3 37
2 8
3 56
3 -72
1 -91 -7
1 21 -41
3 -59
3 -12
3 -33
3 -75
3 -7
2 7
2 14
2 13
3 -49
1 -79 -94
2 24
1 37 -39
3 60
3 93
2 26
1 34 72
3 -73
1 42 76
3 -17
1 64 64
1 17 -90
2 32
2 3... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
bool Q;
struct Line {
mutable long long k, m, p;
bool operator<(const Line &o) const { return Q ? p < o.p : k < o.k; }
};
struct HullDynamic : multiset<Line> {
const long long inf = LLONG_MAX;
long long div(long long a, long long b) {
return a / b - ((a ^ b) < 0... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
int q, OP[300010][2];
int fin[300010];
struct Line {
int k, b;
double xLeft;
bool type;
Line() {
xLeft = -9e18;
type = false;
}
bool operator<(const Line &l) const {
if (l.type) return xLeft < l.xLeft;
return k < l.k || k == l.k && b < l.b;
}
}... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
const int N = 300005;
const long long INF = 2000000000000000000LL;
int n;
struct Point {
int x, y;
Point() {}
Point(int x, int y) : x(x), y(y) {}
bool operator<(const Point& c) const {
if (x == c.x) return y < c.y;
return x < c.x;
}
Point operator-(const... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
struct node {
long long x, y;
node(long long X = 0, long long Y = 0) : x(X), y(Y) {}
node operator+(node a) { return node(x + a.x, y + a.y); }
node operator-(node a) { return node(x - a.x, y - a.y); }
long long operator*(node a) { return x * a.y - y * a.x; }
boo... |
Problem: Lena is a programmer. She got a task to solve at work.
There is an empty set of pairs of integers and n queries to process. Each query is one of three types:
1. Add a pair (a, b) to the set.
2. Remove a pair added in the query number i. All queries are numbered with integers from 1 to n.
3. For a giv... | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 4e5 + 10;
const long long INF = 2e18;
const long double EPS = 1e-9;
struct Line {
int a, b;
long double inter(const Line& l) const {
assert(a != l.a);
return (long double)(l.b - b) / (a - l.a);
}
Line() {}
Line(int a, int b) : a(a), b(b) {... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.