Submission #832153

# Submission time Handle Problem Language Result Execution time Memory
832153 2023-08-21T04:08:49 Z RakhimovAmir Crossing (JOI21_crossing) C++14
100 / 100
378 ms 34120 KB
#define Magic ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define tsts int t; cin >> t; while(t--)
#include <bits/stdc++.h>
using namespace std;
using lli = long long int;
using ull = unsigned long long int;
using ld = long double;
using str = string;
#define pb push_back
#define pf push_front
#define sz size()
#define bg begin()
#define ers erase
inline void debugMode() {
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif // ONLINE_JUDGE
}
const lli MOD = 1e9 + 7, N = 2e5 * 4 + 100, p = 5;
lli t[N], sm[N], md[N]; //main tree for hash, tree for sums of hashes, tree for modifications
map <str, lli> visited; //visited strings
map <lli, lli> us; //used for hashes
lli pwr[N]; // powers of p
queue <str> que;
str a;
str sa, sb, sc;
lli count_hash(str &s1){
	lli res = 0, p_pow = 1;
	for (lli i = 0 ; i < s1.sz ; i++){
		lli cur;
		if (s1[i] == 'J')
			cur = 1;
		else if (s1[i] == 'O')
			cur = 2;
		else
			cur = 3;
		res+=cur * p_pow;
		res%=MOD;
		p_pow*=p;
		p_pow%=MOD;
	}
	return res;
}
str combine(str &s1, str &s2){
	str res;
	for (lli i = 0 ; i < s1.sz ; i++){
		if (s1[i] == s2[i])
			res.pb(s1[i]);
		else
			res.pb('J' + 'O' + 'I' - s1[i] - s2[i]);
	}
	return res;
}
void bfs(){
	while (!que.empty()){
		str cur = que.front();
		us[count_hash(cur)] = 1;
		que.pop();
		str res = combine(cur, sa);
		if (!visited[res]){
			visited[res] = 1;
			que.push(res);
		}
		res = combine(cur, sb);
		if (!visited[res]){
			visited[res] = 1;
			que.push(res);
		}
		res = combine(cur, sc);
		if (!visited[res]){
			visited[res] = 1;
			que.push(res);
		}
	}
}
void build(lli x, lli tl, lli tr){
	if (tl == tr){
		lli cur;
		if (a[tl] == 'J')
			cur = 1;
		else if (a[tl] == 'O')
			cur = 2;
		else
			cur = 3;
		t[x] = pwr[tl] * cur;
		t[x]%=MOD;
		sm[x] = pwr[tl];
		sm[x]%=MOD; 
	}
	else{
		lli tm = (tl + tr)/2;
		build(x * 2, tl, tm);
		build(x * 2 + 1, tm + 1, tr);
		t[x] = t[2 * x] + t[2 * x + 1];
		t[x]%=MOD;
		sm[x] = sm[2 * x] + sm[2 * x + 1];
		sm[x]%=MOD;
	}
}
void psh(lli x){
	if (md[x] != 0 && 2 * x + 1 < N && t[2 * x] != 0){
		md[2 * x] = md[x];
		md[2 * x + 1] = md[x];
		t[2 * x] = sm[2 * x] * md[2 * x];
		t[2 * x]%=MOD;
		t[2 * x + 1] = sm[2 * x + 1] * md[2 * x + 1];
		t[2 * x + 1]%=MOD;
		md[x] = 0;
	}
}
void update(lli x, lli tl, lli tr, lli l, lli r, lli c){
	if (l > r)
		return ;
	else if (tl == l && tr == r){
		md[x] = c;
		t[x] = sm[x] * c;
		t[x]%=MOD;
	}
	else{
		psh(x);
		lli tm = (tl + tr)/2;
		update(2 * x, tl, tm, l, min(r, tm), c);
		update(2 * x + 1, tm + 1, tr, max(l, tm + 1), r, c);
		t[x] = t[2 * x] + t[2 * x + 1];
		t[x]%=MOD;
	}
}
int main(){
    Magic
    //debugMode();
    lli n, q;
    cin >> n >> sa >> sb >> sc;
   	visited[sa] = 1;
   	visited[sb] = 1;
   	visited[sc] = 1;
   	que.push(sa);
   	que.push(sb);
   	que.push(sc);
   	bfs();
   	pwr[0] = 1;
   	for (lli i = 1 ; i <= N ; i++){
   		pwr[i] = pwr[i - 1] * p;
   		pwr[i]%=MOD;
   	}
   	cin >> q;
   	cin >> a;
   	build(1, 0, a.sz - 1);
   	if (us[t[1]])
   		cout << "Yes\n";
   	else
   		cout << "No\n";
   	while (q--){
   		lli l, r, cur;
   		char c;
   		cin >> l >> r >> c;
   		l--;
   		r--;
   		if (c == 'J')
   			cur = 1;
   		else if (c == 'O')
   			cur = 2;
   		else
   			cur = 3;
   		update(1, 0, a.sz - 1, l, r, cur);
   		if (us[t[1]])
   			cout << "Yes\n";
   		else
   			cout << "No\n";
   	}
}
///⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⠤⢲⣦⡀⠀⣠⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
///⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣀⣀⣠⠖⠚⠓⠒⠒⠲⠿⣍⣛⣻⣦⣷⢠⣻⣀⠤⠤⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
///⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⠔⡿⠓⠲⠬⢥⡤⠤⠤⠤⠤⣤⣀⣀⣈⣻⣿⣿⠓⠉⣀⡤⠔⢶⣻⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
///⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣤⢤⠞⠁⣼⠀⠀⠀⠀⠀⠀⠰⠶⢌⣽⡶⠟⢏⡁⢈⣉⣭⣷⡯⣝⠒⢦⣄⠙⠷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
///⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡾⣵⠿⣳⡟⠉⠉⠿⠀⠀⡀⠀⠀⣀⣀⣢⣾⣿⡚⠓⠒⠒⠒⠻⢿⣟⣧⡀⢠⣢⡻⠙⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
///⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡀⢿⣟⣲⢿⣷⢀⣤⣠⣄⣈⢿⣷⣤⣷⣻⡓⠒⠻⠭⢷⡄⠒⠲⢶⣦⣬⣻⣏⢦⡈⢿⣆⠘⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀
///⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⢖⣩⠷⢎⣙⣿⣿⣼⡼⣿⣟⣽⣻⢯⢿⠞⣌⠙⢳⡕⠀⠙⠲⣶⠤⢄⡠⣄⡈⠛⣿⣿⣧⢳⣌⢻⡆⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀
///⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠰⠗⠉⢀⣾⠟⠒⡿⣫⡿⡾⢫⢟⡏⠉⢸⡀⠑⢾⡆⢤⣻⣶⣤⣘⣲⣿⣶⡽⠿⣯⠲⣌⣇⢹⣷⣿⣆⠸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀
///⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⡼⠀⣿⢣⣧⠋⣸⠀⣰⢀⣿⣆⠀⠰⣄⠙⣧⣨⣿⣿⣿⣯⣿⣦⠘⣷⡌⢻⡄⠿⣆⠟⣆⢇⠀⠀⠀⠀⠀⠀⠀⠀⠀
///⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⠀⠀⠀⠀⠀⠀⠀⠀⡇⡼⣹⠈⢣⠆⡇⣰⣻⣼⣿⣽⣷⣦⣹⣿⣟⣯⠉⠘⣿⠏⠃⠀⣷⣽⡿⣾⡹⣷⣹⣧⡈⢺⡀⠀⠀⠀⠀⠀⠀⠀⠀
///⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⢾⠟⠉⠀⠀⠀⠀⠀⠀⠀⠀⣷⣱⣽⡀⢸⣆⢳⣿⣇⣷⡿⠖⠿⠷⢦⣙⣆⠩⡗⠀⠀⠀⠀⠀⡯⠿⠳⣟⠻⣽⣄⢧⠈⠳⣷⡀⠀⠀⠀⠀⠀⠀⠀
///⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⡇⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⣿⣿⣷⣸⣿⡀⣿⣅⠛⠇⠀⠀⠀⠀⢈⠙⠂⠀⠀⠀⠀⠀⣸⣿⠀⢠⣜⢦⠘⢿⣮⣷⡀⠀⠙⢦⡀⠀⠀⠀⠀⠀
///⠀⠀⠀⠀⠀⠀⠀⠀⠀⢯⣇⠙⢄⣀⠀⠀⠀⢀⣀⡠⣴⣾⣫⠵⠛⣿⣻⠿⣷⣹⣾⣷⡠⡀⠀⠀⠀⠻⠦⠀⣀⠔⠀⠀⣴⣿⣸⣧⡀⠳⣝⠳⢴⡙⢞⣏⠢⡀⠀⠹⡄⠀⠀⠀⠀
///⠀⠀⠀⠀⠀⠀⢀⣀⣀⣈⣻⣤⣀⠈⠉⠻⠿⢿⣺⣿⡵⣶⢶⣦⠀⠘⣿⢷⣾⢿⣿⡋⢙⣮⣄⡀⠀⠀⠉⠈⠀⠀⢀⢞⣿⣼⣿⣿⣿⣆⡀⠙⢦⣝⣮⠛⢷⡙⢆⠀⣷⠀⠀⠀⠀
///⠀⠀⠀⢠⡴⢟⣫⠤⠖⠒⠛⢛⣲⣿⣿⣿⠟⠋⢱⣿⣴⣷⣿⣹⢃⣀⣘⠃⢩⢿⣫⣥⣿⠧⢿⣿⣗⡶⣤⣄⣀⣴⣷⣻⣿⣿⠻⠘⣏⠛⢿⣦⣀⠱⢤⣉⡑⠛⠮⢿⣹⠀⠀⠀⠀
///⠀⢠⢖⠵⠊⠁⢀⡤⠖⣲⣿⣿⣟⣻⣿⣋⠀⠀⠈⢿⣿⡿⠟⣵⣿⣿⣿⣷⡏⠈⢿⡿⣷⣤⣼⢿⣿⣿⢶⣯⣭⣵⣾⢿⣿⠿⢦⡀⢹⠀⠈⣏⠉⠉⢻⣶⣯⡑⠦⣄⠈⠳⣄⠀
///⠀⠹⠁⠀⠀⣞⢁⡾⢽⣯⣝⣛⣛⣯⣭⣽⣿⣷⣶⣤⣤⣴⣿⣿⣿⣿⣿⣿⡀⣀⣼⣀⠈⠙⠛⠷⣾⡿⢿⡟⣿⠟⠁⣈⣥⡴⠾⠷⢾⡄⠀⣿⠀⠀⠈⢇⠘⣿⣤⣀⠑⢦⡘⢧⠀
///⠄⠀⠀⠀⠀⠈⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⢿⡿⠛⣻⢏⡽⣯⡄⠘⣏⣿⡏⠈⠙⠓⠶⣤⣀⠀⠙⢿⣿⡇⢀⡿⠋⠁⠀⢀⣀⣸⡇⠀⣟⣀⠀⠀⠀⠙⠃⣿⡎⠑⣤⡙⣌⡇
///⠀⠀⠀⠀⠀⠀⠀⠙⢿⣿⣿⣿⣿⣿⣿⣿⡥⣖⡯⠖⢋⣡⡞⣼⣿⠀⠀⢹⣿⣷⠀⠀⣀⡀⠀⠉⠻⣦⠀⢿⣿⡿⠁⣠⡶⠟⠋⠉⠹⣆⣸⣿⣿⠀⣀⡤⣤⡀⣿⠇⠀⢸⠳⡜⡇
///⠀⠀⠀⠀⠀⠀⠀⠀⣈⣿⣿⣿⣿⣿⣿⣏⢿⣗⠒⠊⠉⢸⠁⡿⡏⠀⢀⣿⡿⣁⠤⢶⣿⣽⡆⠀⠀⠘⢷⡈⠉⣡⠾⠋⠀⠀⣠⣆⢠⣿⣿⣿⡟⢀⣷⠒⢺⣧⡏⠀⠀⢸⠀⢹⣹
///⠀⠀⠀⠀⠀⠀⡠⢪⠟⡽⠙⢶⣾⣿⣿⣿⣷⡻⣦⡀⠀⠀⢣⣇⡇⢀⡞⣸⠏⠁⠀⠀⡇⢻⡀⠀⠀⣾⣶⡟⣿⣥⡄⠀⠀⢠⣇⣼⡶⣿⣿⠋⣸⣾⣷⣚⣽⡟⠀⠀⠀⣏⠀⡼⣿
///⠀⠀⠀⠀⢀⠎⡴⣣⣾⠟⣡⠞⢹⡿⣿⢿⣿⣿⣿⣷⣄⠀⠈⠻⡹⣼⠀⣿⡄⠀⠀⠀⠉⠻⣷⡀⠀⠙⠿⠇⣿⠿⠇⠀⠀⢠⡿⠋⢇⢹⣟⢷⠫⣿⣟⡿⠋⠀⠀⣠⣾⢞⡜⠁⡿
///⠀⠀⠀⠀⡼⡼⣵⠏⡏⣰⠃⠀⢾⡇⠈⠻⣿⣮⡉⠹⣿⣧⣄⡀⠙⣇⠀⠸⣿⣄⡀⠀⠀⠀⠈⢉⣧⡴⠀⠠⡄⣀⡤⠤⠴⠋⠁⠀⠈⢻⣿⣾⣤⡿⠋⠀⠀⠀⣉⣽⠿⠋⠀⣰⠃
///⠀⠀⠀⠀⣿⣽⠋⠀⡇⡇⠀⠀⠘⣷⢠⣶⢮⣻⣿⣦⠈⠛⠙⠹⣷⠘⢦⣤⣿⣳⣭⣑⣒⣒⣺⣿⢿⣀⣀⣀⣿⣧⣀⣀⣀⡤⠴⠒⣶⣿⣏⣾⡿⠁⠀⠀⠀⠉⠉⠀⠀⠀⠀⠀⠀
///⠀⠀⠀⠀⢻⡏⠀⠀⢳⣇⠀⠀⠀⠈⠈⣿⣾⣿⣿⣮⣿⣦⠀⠀⢿⣶⡫⣿⣿⣿⣿⣿⡹⣯⣊⠁⠉⠉⠉⠉⢙⣮⣷⣶⡤⣤⣶⣿⣿⣟⣾⢿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
///⠀⠀⠀⠀⠸⣿⣦⡀⠀⠙⠦⠀⠀⢀⣼⠿⣽⣿⣯⣷⣼⡷⢾⣻⣾⣿⠞⢿⢻⡷⠻⣿⣏⡙⢝⣻⡾⡖⠒⣻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⣎⠣⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
///⠀⠀⠀⠀⠀⠀⠈⠁⠀⠀⠀⠀⣴⣋⣉⣩⣿⣿⢿⣟⣷⣾⣯⡟⢱⡇⠀⠘⣿⠣⡀⣈⣻⣿⣿⣿⣷⣷⣶⣿⣿⣟⠋⡿⣹⣿⣿⣿⣿⢟⣏⠺⠿⠶⠭⠷⠂⠀⠀⠀⠀⠀⠀⠀⠀
///⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⣿⣿⣿⣿⣿⣿⣿⢹⣮⣾⣿⡿⢋⣶⢸⡇⠀⠀⠈⢷⡑⠈⢻⣟⠛⠛⠿⠋⠙⠓⣭⣿⣹⣵⣿⣿⣿⣿⣿⠈⠻⣷⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
///⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠙⢟⣛⡭⠶⢾⡿⠃⠀⠀⢸⢹⣾⣇⠀⠀⠀⠀⠻⣟⣿⡏⠀⠀⠀⠀⢰⣿⣿⢿⡇⣿⣿⣿⣿⣟⡏⠀⠀⠀⠉⠙⠓⠒⠂⠀⠀⠀⠀⠀⠀⠀⠀
///⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⡟⠀⠀⠀⢰⣿⢸⣿⢿⡀⠀⠀⠀⠀⢸⣿⣣⠀⠀⠀⢠⣿⡟⣷⣾⣿⢿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
///⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣿⠁⠀⠀⠀⠘⡿⡿⢿⣏⣧⠀⠀⠀⢀⣾⣿⠿⠀⢀⣴⣿⣿⢿⡹⡇⣿⠈⣿⣿⡟⣾⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
///⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⡇⠀⠀⠀⠀⢳⢧⠈⢿⣿⠀⠀⢀⣼⣿⠕⠁⣠⣾⡿⣻⠏⠀⢹⣹⣿⣆⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
///⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣾⣿⣷⠀⠀⠀⠀⠈⣏⢧⠀⢻⣧⠶⣋⠿⠋⣀⣾⣟⣿⠞⠁⠀⠀⠀⢯⣿⣿⣿⣿⣿⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
///⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢻⣿⣿⣇⠀⠀⠀⠀⠸⡜⣆⠈⢷⣿⠀⢠⣾⣿⠟⢻⡏⠀⠀⠀⠀⠀⠘⣿⣿⠏⣿⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
///⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡻⣿⣿⣦⡀⠀⠀⠀⢧⠘⣆⠈⢷⠒⠛⢻⡿⠄⠘⣧⠀⠀⠀⠀⠀⢰⣷⣹⠀⠙⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
///⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣷⣝⣿⣿⣷⣄⠀⠀⠈⢇⠸⡄⠈⣇⠀⠀⢻⣆⠀⠘⣇⠀⠀⣠⣾⣽⢹⡟⠀⢰⣷⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
///⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢻⣾⢻⠙⢿⣿⡇⠀⠀⠈⢧⢳⠀⢸⡀⠀⠀⢻⣆⠀⢻⡄⢠⣿⣯⣽⣓⣧⣤⠾⢹⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
///⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣼⡇⠀⠙⣿⠀⠀⠀⠈⢏⢧⠀⣇⠀⠀⠀⢻⣆⠀⢷⠘⣿⣮⡻⣿⠁⠀⢀⣯⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
///⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢿⣿⣧⡀⠀⠀⠀⠀⠀⠀⠘⡾⡄⢸⠀⠀⠀⠈⢻⣆⠈⢷⣷⣾⣟⣻⣶⣿⡿⠛⢿⣷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
///⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀⢳⣇⠘⡆⠀⠀⠀⠀⠻⣶⢺⡏⢹⡟⠀⠉⠁⠀⠀⠀⢩⣍⠙⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
///⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⣟⣿⣿⣿⣧⠀⢀⣤⣤⡸⣸⠀⡇⠀⠀⠀⠀⠀⠙⣿⣷⢡⣿⣶⣄⠀⠀⣄⠀⣦⣍⠙⢳⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
///⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⡿⢿⡙⠿⠀⢸⡟⢲⣷⡿⡄⢿⠀⠀⠀⠀⠀⠀⠘⣏⢸⣇⣍⢻⣷⣀⢻⣦⣤⣌⡙⣦⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
///⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⣯⢷⠀⠀⠸⡇⠀⢿⣧⡇⢸⠀⠀⠀⠀⠀⠀⠀⣼⢸⣿⣯⠀⣿⣿⣷⣝⣿⣻⣿⣼⣷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
///⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢻⣎⣧⠀⠐⣇⠀⠘⣽⣿⡸⡆⠀⠀⠀⠀⠀⠀⠈⠋⠈⠻⣼⣿⢶⢿⣿⣯⡻⣿⣿⣾⣷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
///⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢻⡼⡆⠀⣿⡀⠀⣿⢿⡇⢷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣿⣾⢧⠈⠙⠿⣮⠟⠉⠙⢦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
///⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢿⢻⢠⣿⡇⠀⠹⣄⢳⣜⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⡏⠪⠳⢤⣄⣀⠀⠀⠀⠈⢣⠀⠀⠀⠀⠀⠀⠀⠀⠀
///⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣎⣿⡟⡇⠀⠀⠈⢻⣿⣷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢳⡄⠀⠀⠀⠙⢧⡀⢀⡄⠈⡇⠀⠀⠀⠀⠀⠀⠀⠀

Compilation message

Main.cpp: In function 'lli count_hash(str&)':
Main.cpp:30:21: warning: comparison of integer expressions of different signedness: 'lli' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |  for (lli i = 0 ; i < s1.sz ; i++){
      |                     ^
Main.cpp: In function 'str combine(str&, str&)':
Main.cpp:47:21: warning: comparison of integer expressions of different signedness: 'lli' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |  for (lli i = 0 ; i < s1.sz ; i++){
      |                     ^
Main.cpp: In function 'int main()':
Main.cpp:143:13: warning: iteration 800099 invokes undefined behavior [-Waggressive-loop-optimizations]
  143 |      pwr[i] = pwr[i - 1] * p;
      |      ~~~~~~~^~~~~~~~~~~~~~~~
Main.cpp:142:24: note: within this loop
  142 |     for (lli i = 1 ; i <= N ; i++){
      |                      ~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 105 ms 16460 KB Output is correct
2 Correct 122 ms 17344 KB Output is correct
3 Correct 100 ms 10896 KB Output is correct
4 Correct 130 ms 17332 KB Output is correct
5 Correct 124 ms 17348 KB Output is correct
6 Correct 105 ms 16540 KB Output is correct
7 Correct 110 ms 16884 KB Output is correct
8 Correct 127 ms 17592 KB Output is correct
9 Correct 139 ms 17156 KB Output is correct
10 Correct 137 ms 18700 KB Output is correct
11 Correct 123 ms 17892 KB Output is correct
12 Correct 121 ms 18676 KB Output is correct
13 Correct 124 ms 17920 KB Output is correct
14 Correct 174 ms 18696 KB Output is correct
15 Correct 118 ms 18024 KB Output is correct
16 Correct 153 ms 18692 KB Output is correct
17 Correct 135 ms 18020 KB Output is correct
18 Correct 94 ms 9120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 105 ms 16460 KB Output is correct
2 Correct 122 ms 17344 KB Output is correct
3 Correct 100 ms 10896 KB Output is correct
4 Correct 130 ms 17332 KB Output is correct
5 Correct 124 ms 17348 KB Output is correct
6 Correct 105 ms 16540 KB Output is correct
7 Correct 110 ms 16884 KB Output is correct
8 Correct 127 ms 17592 KB Output is correct
9 Correct 139 ms 17156 KB Output is correct
10 Correct 137 ms 18700 KB Output is correct
11 Correct 123 ms 17892 KB Output is correct
12 Correct 121 ms 18676 KB Output is correct
13 Correct 124 ms 17920 KB Output is correct
14 Correct 174 ms 18696 KB Output is correct
15 Correct 118 ms 18024 KB Output is correct
16 Correct 153 ms 18692 KB Output is correct
17 Correct 135 ms 18020 KB Output is correct
18 Correct 94 ms 9120 KB Output is correct
19 Correct 283 ms 30136 KB Output is correct
20 Correct 291 ms 27744 KB Output is correct
21 Correct 252 ms 31748 KB Output is correct
22 Correct 210 ms 29680 KB Output is correct
23 Correct 205 ms 20412 KB Output is correct
24 Correct 176 ms 19188 KB Output is correct
25 Correct 257 ms 32588 KB Output is correct
26 Correct 259 ms 30612 KB Output is correct
27 Correct 270 ms 32976 KB Output is correct
28 Correct 293 ms 30516 KB Output is correct
29 Correct 263 ms 32608 KB Output is correct
30 Correct 209 ms 20400 KB Output is correct
31 Correct 307 ms 32908 KB Output is correct
32 Correct 244 ms 30340 KB Output is correct
33 Correct 165 ms 19112 KB Output is correct
34 Correct 278 ms 30592 KB Output is correct
35 Correct 291 ms 30476 KB Output is correct
36 Correct 155 ms 19272 KB Output is correct
37 Correct 210 ms 19148 KB Output is correct
38 Correct 212 ms 25212 KB Output is correct
39 Correct 146 ms 22704 KB Output is correct
40 Correct 227 ms 24532 KB Output is correct
41 Correct 196 ms 20884 KB Output is correct
42 Correct 57 ms 16724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 105 ms 16460 KB Output is correct
2 Correct 122 ms 17344 KB Output is correct
3 Correct 100 ms 10896 KB Output is correct
4 Correct 130 ms 17332 KB Output is correct
5 Correct 124 ms 17348 KB Output is correct
6 Correct 105 ms 16540 KB Output is correct
7 Correct 110 ms 16884 KB Output is correct
8 Correct 127 ms 17592 KB Output is correct
9 Correct 139 ms 17156 KB Output is correct
10 Correct 137 ms 18700 KB Output is correct
11 Correct 123 ms 17892 KB Output is correct
12 Correct 121 ms 18676 KB Output is correct
13 Correct 124 ms 17920 KB Output is correct
14 Correct 174 ms 18696 KB Output is correct
15 Correct 118 ms 18024 KB Output is correct
16 Correct 153 ms 18692 KB Output is correct
17 Correct 135 ms 18020 KB Output is correct
18 Correct 94 ms 9120 KB Output is correct
19 Correct 121 ms 16860 KB Output is correct
20 Correct 89 ms 10808 KB Output is correct
21 Correct 121 ms 18148 KB Output is correct
22 Correct 105 ms 16200 KB Output is correct
23 Correct 155 ms 18252 KB Output is correct
24 Correct 109 ms 17128 KB Output is correct
25 Correct 115 ms 18100 KB Output is correct
26 Correct 132 ms 16732 KB Output is correct
27 Correct 121 ms 18088 KB Output is correct
28 Correct 113 ms 17016 KB Output is correct
29 Correct 114 ms 17448 KB Output is correct
30 Correct 104 ms 16432 KB Output is correct
31 Correct 119 ms 18380 KB Output is correct
32 Correct 148 ms 18224 KB Output is correct
33 Correct 133 ms 17696 KB Output is correct
34 Correct 106 ms 16732 KB Output is correct
35 Correct 121 ms 18660 KB Output is correct
36 Correct 131 ms 17912 KB Output is correct
37 Correct 173 ms 18720 KB Output is correct
38 Correct 125 ms 17932 KB Output is correct
39 Correct 138 ms 18724 KB Output is correct
40 Correct 126 ms 17920 KB Output is correct
41 Correct 123 ms 18764 KB Output is correct
42 Correct 129 ms 17976 KB Output is correct
43 Correct 116 ms 17336 KB Output is correct
44 Correct 123 ms 17728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 105 ms 16460 KB Output is correct
2 Correct 122 ms 17344 KB Output is correct
3 Correct 100 ms 10896 KB Output is correct
4 Correct 130 ms 17332 KB Output is correct
5 Correct 124 ms 17348 KB Output is correct
6 Correct 105 ms 16540 KB Output is correct
7 Correct 110 ms 16884 KB Output is correct
8 Correct 127 ms 17592 KB Output is correct
9 Correct 139 ms 17156 KB Output is correct
10 Correct 137 ms 18700 KB Output is correct
11 Correct 123 ms 17892 KB Output is correct
12 Correct 121 ms 18676 KB Output is correct
13 Correct 124 ms 17920 KB Output is correct
14 Correct 174 ms 18696 KB Output is correct
15 Correct 118 ms 18024 KB Output is correct
16 Correct 153 ms 18692 KB Output is correct
17 Correct 135 ms 18020 KB Output is correct
18 Correct 94 ms 9120 KB Output is correct
19 Correct 283 ms 30136 KB Output is correct
20 Correct 291 ms 27744 KB Output is correct
21 Correct 252 ms 31748 KB Output is correct
22 Correct 210 ms 29680 KB Output is correct
23 Correct 205 ms 20412 KB Output is correct
24 Correct 176 ms 19188 KB Output is correct
25 Correct 257 ms 32588 KB Output is correct
26 Correct 259 ms 30612 KB Output is correct
27 Correct 270 ms 32976 KB Output is correct
28 Correct 293 ms 30516 KB Output is correct
29 Correct 263 ms 32608 KB Output is correct
30 Correct 209 ms 20400 KB Output is correct
31 Correct 307 ms 32908 KB Output is correct
32 Correct 244 ms 30340 KB Output is correct
33 Correct 165 ms 19112 KB Output is correct
34 Correct 278 ms 30592 KB Output is correct
35 Correct 291 ms 30476 KB Output is correct
36 Correct 155 ms 19272 KB Output is correct
37 Correct 210 ms 19148 KB Output is correct
38 Correct 212 ms 25212 KB Output is correct
39 Correct 146 ms 22704 KB Output is correct
40 Correct 227 ms 24532 KB Output is correct
41 Correct 196 ms 20884 KB Output is correct
42 Correct 57 ms 16724 KB Output is correct
43 Correct 121 ms 16860 KB Output is correct
44 Correct 89 ms 10808 KB Output is correct
45 Correct 121 ms 18148 KB Output is correct
46 Correct 105 ms 16200 KB Output is correct
47 Correct 155 ms 18252 KB Output is correct
48 Correct 109 ms 17128 KB Output is correct
49 Correct 115 ms 18100 KB Output is correct
50 Correct 132 ms 16732 KB Output is correct
51 Correct 121 ms 18088 KB Output is correct
52 Correct 113 ms 17016 KB Output is correct
53 Correct 114 ms 17448 KB Output is correct
54 Correct 104 ms 16432 KB Output is correct
55 Correct 119 ms 18380 KB Output is correct
56 Correct 148 ms 18224 KB Output is correct
57 Correct 133 ms 17696 KB Output is correct
58 Correct 106 ms 16732 KB Output is correct
59 Correct 121 ms 18660 KB Output is correct
60 Correct 131 ms 17912 KB Output is correct
61 Correct 173 ms 18720 KB Output is correct
62 Correct 125 ms 17932 KB Output is correct
63 Correct 138 ms 18724 KB Output is correct
64 Correct 126 ms 17920 KB Output is correct
65 Correct 123 ms 18764 KB Output is correct
66 Correct 129 ms 17976 KB Output is correct
67 Correct 116 ms 17336 KB Output is correct
68 Correct 123 ms 17728 KB Output is correct
69 Correct 316 ms 30384 KB Output is correct
70 Correct 356 ms 29320 KB Output is correct
71 Correct 162 ms 19200 KB Output is correct
72 Correct 187 ms 19312 KB Output is correct
73 Correct 203 ms 19236 KB Output is correct
74 Correct 228 ms 31576 KB Output is correct
75 Correct 204 ms 20540 KB Output is correct
76 Correct 281 ms 32900 KB Output is correct
77 Correct 250 ms 30156 KB Output is correct
78 Correct 182 ms 19280 KB Output is correct
79 Correct 159 ms 19336 KB Output is correct
80 Correct 301 ms 31736 KB Output is correct
81 Correct 170 ms 20500 KB Output is correct
82 Correct 378 ms 34120 KB Output is correct
83 Correct 258 ms 31624 KB Output is correct
84 Correct 191 ms 19216 KB Output is correct
85 Correct 187 ms 19456 KB Output is correct
86 Correct 240 ms 30784 KB Output is correct
87 Correct 278 ms 32112 KB Output is correct
88 Correct 220 ms 18760 KB Output is correct
89 Correct 243 ms 31332 KB Output is correct
90 Correct 299 ms 32400 KB Output is correct
91 Correct 164 ms 18732 KB Output is correct
92 Correct 259 ms 31724 KB Output is correct
93 Correct 170 ms 19276 KB Output is correct
94 Correct 197 ms 19300 KB Output is correct
95 Correct 166 ms 19240 KB Output is correct
96 Correct 215 ms 24984 KB Output is correct
97 Correct 176 ms 25660 KB Output is correct
98 Correct 261 ms 25492 KB Output is correct
99 Correct 230 ms 22896 KB Output is correct
100 Correct 82 ms 18840 KB Output is correct