Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <vector> #include <algorithm> #include <string> #include <map> #include <set> #include <queue> #include <stack> #include <climits> #include <sstream> #include <functional> #include <complex> #include <cassert> using n...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <cstdio> #include <algorithm> #include <vector> #include <cstring> #include <string> #define FOR(i, n) for (int i = 0; i < n; i++) typedef long long ll; typedef std::pair<int, int> pii; const int MAXN = 500100; const int inf = 1e9; int n, q; pii queries[MAXN]; char s[MAXN]; void load() { scanf("%s", s); ...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include<cstdio> #include<cstring> using namespace std; char s[500005]; int n,m; int ne[500005][27],Ne[500005][20]; inline int read(){ int ret=0;char c=getchar(); while((c>'9')||(c<'0'))c=getchar(); while((c>='0')&&(c<='9'))ret=(ret<<1)+(ret<<3)+c-'0',c=getchar(); return ret; } void pre(){ for(int i=1;...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <bits/stdc++.h> using namespace std; const int maxn = 500050, alp = 27; int nxt[maxn][alp], p[alp][maxn]; int main(){ string s; cin >> s; int len = s.size(); for(int i = 0; i <= len; i++) for(int j = 0; j < alp; j++) p[j][i] = nxt[i][j] = maxn; for(int i = 0; i < len; i++) nxt[i][s[i] - 'a'] = i + 1; for(...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <bits/stdc++.h> using namespace std; #define sz(x) ((int) (x).size()) #define forn(i,n) for (int i = 0; i < int(n); ++i) typedef long long ll; typedef long long i64; typedef long double ld; const int inf = int(1e9) + int(1e5); const ll infl = ll(2e18) + ll(1e10); const int maxn = 500100; int n; char s[maxn];...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
//by yjz #include<bits/stdc++.h> using namespace std; #define FF first #define SS second #define PB push_back #define MP make_pair typedef long long ll; const ll INF=1<<28; const ll LINF=1ll<<61; int n,q,dfn[500111],dfnr[500111],dfnt; vector<int>con[500111]; char s[500111]; int go[500111][27],g[500111]; void dfs(int x...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#ifdef AlCash #define ASSERT(...) assert(__VA_ARGS__) #else #define ASSERT(...) true #endif #include <stdexcept> #include <iostream> #include <iomanip> #include <fstream> #include <sstream> #include <cassert> #include <cstdarg> #include <cstring> #include <cstdio> #include <memory> #include <random> #include <cmath> #...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <cstdio> #include <cstring> const int N=500010; char c[N]; int q,l,r,f[N][30],d[N][25],n,j,h,i; int main(){ scanf("%s",c+1); n=strlen(c+1); for(i=1;i<=n;++i)f[i][c[i]-'a']=i; for(i=n;i;--i){ for(j=c[i]+1-'a';j<=26;++j){ if(f[i][j-1])f[i][j]=f[f[i][j-1]+1][j-1]; //printf("f[%d][%d]=%d\n",i,j,f[i][...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include<bits/stdc++.h> #define For(i,j,k) for(int i=j;i<=k;++i) #define Dow(i,j,k) for(int i=k;i>=j;--i) #define ll long long #define PI acos(-1) using namespace std; inline ll read() { ll t=0,f=1;char c=getchar(); while(!isdigit(c)) {if(c=='-') f=-1;c=getchar();} while(isdigit(c)) t=t*10+c-48,c=getchar(); retur...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
// <string.cpp> - Sat Mar 25 20:06:07 2017 // This file is created by XuYike's black technology automatically. // Copyright (C) 2015 ChangJun High School, Inc. // I don't know what this program is. #include <iostream> #include <vector> #include <algorithm> #include <cstring> #include <cstdio> #include <cmath> using na...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
// #include {{{ #include <iostream> #include <cassert> #include <cstring> #include <cstdlib> #include <cstdio> #include <cctype> #include <cmath> #include <ctime> #include <queue> #include <set> #include <map> #include <stack> #include <string> #include <bitset> #include <vector> #include <complex> #include <algorithm>...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <bits/stdc++.h> using namespace std; //make_tuple emplace_back next_permutation push_back make_pair second first #if MYDEBUG #include "lib/mydebug.h" #else #define DBG(...) ; #endif using LL = long long; constexpr LL LINF=334ll<<53; constexpr int INF=15<<26; constexpr LL MOD=1E9+7; struct Problem{ stri...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
/* Date: 2017/02/25 19:33:12 Saturday */ #include<bits/stdc++.h> using namespace std; #define X first #define Y second #define mp make_pair #define pb push_back #define rep(i,a,n) for(int i=(a);i<=(n);++i) #define dep(i,a,n) for(int i=(a);i>=(n);--i) #define eps 1e-8 #define pi 3.1415926535897 #define sqr(x) ((x)*(x)) ...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <cstdio> #include <algorithm> #include <numeric> #include <stack> #include <cstring> #include <set> using namespace std; char s[500001]; int fst[26][500002]; int nxt[19][500002]; char st[500000]; int main() { int q; scanf("%s %d", s, &q); int n = strlen(s); for(int i = 0; i < 26; i++) f...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
// ba mei zi ! #include<bits/stdc++.h> #define HEAP priority_queue #define rep(i, n) for(int i = 0; i < (n); ++i) #define per(i, n) for(int i = (n) - 1; i >= 0 ; --i) #define forn(i, l, r) for(int i = (l); i <= (r); ++i) #define nrof(i, r, l) for(int i = (r); i >= (l); --i) #define FOR(a, b) for(auto (a): (b)) #defin...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include<bits/stdc++.h> using namespace std; int n,len; int dp[1000010][27],DP[1000010][24]; char s[1000010]; void pre(){ for(int i=1;i<=len+2;i++){ for(int j=0;j<=26;j++) dp[i][j]=len+2; for(int j=0;j<20;j++) DP[i][j]=len+2; } for(int i=len;i;i--){ dp[i][s[i]-'a']=i+1; for(int j=s[i]-'a'+1;j<=26;j++) dp[i][...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include<bits/stdc++.h> using namespace std; #define SS 500000 int f[SS+10][30]; char str[SS+10]; int g[SS+10][30]; int main(){ scanf("%s",str); int len=strlen(str); for(int i=0;i<=len+5;i++) for(int j=0;j<=28;j++) g[i][j]=len+2,f[i][j]=len+2; for(int i=len-1;i>=0;i--){ int sr=str[i]-'a'; f[i][sr]=i; for...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vll = vector<ll>; using vvi = vector<vector<int>>; using vvl = vector<vector<ll>>; int dp[500004][27] = {0}; string s; int n; int p[500004][19] = {0}; int dfs(int i, int j, int l) { if (dp[i][j] < n + 2) return dp[i]...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> P; typedef pair<int,P> P1; typedef pair<P,P> P2; typedef pair<double,int>Q; #define pu push #define pb push_back #define mp make_pair #define eps 1e-7 #define INF 1000000000 #define mod 1000000007 #define fi first #define sc secon...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <iostream> #include <vector> #include <cstdio> #include <algorithm> #include <set> #include <map> #include <cassert> #include <numeric> #include <string> #include <cstring> #include <cmath> using namespace std; #ifdef LOCAL #define eprintf(...) fprintf(stderr, __VA_ARGS__) #else #define eprintf(...) 42 #end...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <algorithm> #include <cassert> #include <iostream> #include <vector> #include <cstdio> #include <complex> #include <cstring> using namespace std; const int N = 500000 + 5; const int C = 26; int n, m; int root, tot; int ch[N][C]; char s[N]; int p[N + N]; int ans[N]; vector<pair<int, int>> vec[N]; int getp(i...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include<iostream> #include<cmath> #include<cstdio> #include<algorithm> #include<cstring> using namespace std; char ch[510000]; int dp[510000][27],n,m,r[510000],go[510000][19]; int main(){ scanf("%s",ch+1); n=strlen(ch+1); scanf("%d",&m); for (int i=n+1;i<=n+10;i++) for (int j=0;j<27;j++) dp[i][j]=n+1; for (int ...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include<cstdio> #include<algorithm> #include<cstring> #include<iostream> #include<vector> #include<set> #include<map> #include<bitset> #include<cmath> #include<string> #define ls (t<<1) #define rs ((t<<1)+1) #define mid ((l+r)>>1) #define fi first #define se second #define mk make_pair #define pb push_back #define N...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <bits/stdc++.h> using namespace std; template <typename T> using Matrix = vector<vector<T>>; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); string s; cin >> s; const auto n = int(s.size()); auto f = Matrix<int>(n+2, vector<int>(27, n+1)); for (auto i = n-1; i >= 0; i--)...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <cstdio> #include <algorithm> static const int MAXN = 5e5 + 4; static const int LOGN = 20; static const int ALPHABET = 26; int n, q; char s[MAXN]; // f[position][token or ALPHABET - empty string] - first index where the shrunk string equals a given character int f[MAXN][ALPHABET + 1]; // g[position][power of ...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define pii pair<int,int> #define pll pair<ll,ll> #define pdd pair<double,double> #define X first #define Y second #define REP(i,a) for(int i=0;i<a;++i) #define REPP(i,a,b) for(int i=a;i<b;++i) #define FILL(a,x) memset(a,x,sizeof(a)) #define foreach( g...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <iostream> #include <cstdio> #include <algorithm> #include <cmath> #include <vector> #include <cstring> using namespace std; #define X first #define Y second #define mp make_pair #define pb push_back typedef long long ll; typedef pair <int, int> pii; typedef pair <int, pii> pip; typedef pair <pii, int> ppi; ...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <iostream> #include <vector> #include <string> #include <cstring> using namespace std; int dp[500000][26]; int z[500000][20]; void makeTable(const string& s){ int n = s.size(); memset(dp, -1, sizeof(dp)); memset(z, -1, sizeof(z)); for(int i=n-1;i>=0;i--){ dp[i][s[i]-'a'] = i+1; int dst = i+1; for(...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <iostream> #include <cstdio> #include <vector> #include <string> #include <algorithm> #include <utility> #include <map> #include <set> #include <cmath> #include <cstdlib> using namespace std; void out() { cout.flush(); cerr << endl << "OUT" << endl; int bred; cin >> bred; } const int MOD ...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <iostream> #include <vector> #include <map> #include <set> #include <stack> #include <queue> #include <algorithm> #include <cassert> #include <random> #include <iomanip> #include <bitset> #define FOR(i, n, m) for(ll i = n; i < (int)m; i++) #define REP(i, n) FOR(i, 0, n) #define ALL(v) v.begin(), v.end() #defin...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <bits/stdc++.h> using namespace std; const int MX = 500000; char s[MX + 1]; int f[MX + 1][27]; int g[MX + 1][20]; void prepare() { int n = strlen(s); for (int i = 0; i < n; i++) s[i] -= 'a'; for (int i = 0; i < 27; i++) f[n][i] = n; for (int i = n - 1; i >= 0; i--) { f[i][s[i]] = i; for (in...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
//http://mujin-pc-2017.contest.atcoder.jp/tasks/mujin_pc_2017_c #include <bits/stdc++.h> using namespace std; const int maxn = 500100; const int maxj = 30; int nextc[maxn][30],f[maxn][maxj],a[maxn],n,q; string s; int main() { ios_base::sync_with_stdio(0); // freopen("in.txt","r",stdin); cin>>s; int n...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author RiaD */ #include <iostream> #include <fstream> #include <iostream> #include <vector> #include <type_traits> template <typename T, size_t N> struct MakeVector { template < typename... Args, typename R = std:...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; typedef long long ll; typedef vector<int> vi; #define pb push_back #define eb emplace_back #define mp make_pair #define fi first #define se second #define rep(i,n) rep2(i,0,n) #define rep2(i,m,n) for(int i=m;i<(n);i++) #define ALL(c) (c).begin(...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#define DEB #include<bits/stdc++.h> #define REP(i,m) for(int i=0;i<(m);++i) #define REPN(i,m,in) for(int i=(in);i<(m);++i) #define ALL(t) (t).begin(),(t).end() #define CLR(a) memset((a),0,sizeof(a)) #define pb push_back #define mp make_pair #define fr first #define sc second using namespace std; #ifdef DEB #define d...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <bits/stdc++.h> #define FOR(i,n) for(lli i=0;i<(lli)(n);++i) #define FORU(i,j,k) for(lli i=(j);i<=(lli)(k);++i) #define FORD(i,j,k) for(lli i=(j);i>=(lli)(k);--i) #define pb push_back #define mt make_tuple using namespace std; using lli = long long int; using pll = pair<lli, lli>; using vi = vector<lli...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include<stdio.h> #include<iostream> #include<algorithm> #include<stdlib.h> #include<string.h> #include<queue> #define LL long long using namespace std; inline int read( ) { int sum=0;char c=getchar( );bool f=0; while(c<'0'||c>'9') {if(c=='-') f=1;c=getchar( );} while(c>='0'&&c<='9') {sum=sum*10+c-'0';c=getchar( ...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <iostream> #include <cstdio> #include <map> #include <set> #include <queue> #include <vector> #include <cstring> #include <cstdlib> #include <algorithm> #define rep(i,a,b) for(int i = a; i <= b; i++) #define dep(i,a,b) for(int i = a; i >= b; i--) #define Rep(i,a) for(int i = 0; i < a; i++) #define pb(a) push_...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <cstdio> #include <cstring> #include <map> #include <queue> #include <climits> #include <vector> #include <algorithm> using namespace std; const int MAX_N = 500000; char dat[MAX_N + 1]; int afterChar[MAX_N][27]; // 26 is empty int jumpTable[MAX_N][20]; int main() { scanf("%s", dat); int n = strlen(dat)...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define mp make_pair #define inf 1000000005 #define all(a) (a).begin(), (a).end() #define ms(a,x) memset(a, x, sizeof(a)) #define mod 1000000007 #define sz(a) ((ll)(a).size()) template<class T> int getbit(T s, int i) ...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #define ALL(a) (a.begin()),(a.end()) #define ZER...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <bits/stdc++.h> #define FOR(i,n) for(lli i=0;i<(lli)(n);++i) #define FORU(i,j,k) for(lli i=(j);i<=(lli)(k);++i) #define FORD(i,j,k) for(lli i=(j);i>=(lli)(k);--i) #define pb push_back #define mt make_tuple using namespace std; using lli = long long int; using pll = pair<lli, lli>; using vi = vector<lli...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <bits/stdc++.h> using namespace std; const int inf = (int)1e9+7; const int N = 500005; const int M = 20 * 5 * 100000; int cnt[M], l[M], r[M]; int g[27][N]; struct Task { int n, q; string s; vector<vector<pair<int,int>>> que; vector<int> result; vector<int> good; int cur = 0; Task() { cur = 0; ...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <iostream> #include <vector> #include <stack> #include <queue> #include <algorithm> #include <cmath> #include <string> #include <map> #include <set> #include <list> #define ll long long #define fornum(A,B,C) for(A=B;A<C;A++) using namespace std; int i,j,k,l,m,n; /////////////////////////////////////////////...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include<stdio.h> #include<cstring> #include<cstdlib> #include<cmath> #include<iostream> #include<algorithm> #include<vector> #include<map> #include<set> #include<queue> #include<bitset> #include<utility> #include<functional> #include<iomanip> #include<sstream> #include<ctime> #include<cassert> using namespace std; #de...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <bits/stdc++.h> using namespace std; using LL = long long; constexpr LL LINF=334ll<<53; constexpr int INF=15<<26; constexpr LL MOD=1E9+7; struct Problem{ string s; int q; void solve(){ cin >> s >> q; int l=(int)s.size(); vector<vector<int>> dp (l,vector<int>(27,INF)), ...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <bits/stdc++.h> using namespace std; //using namespace atcoder; struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_; #define FOR(i, begin, end) for(int i=(begin);i<(end);i++) #define REP(i, n) FOR(i,0,n) #define IFOR(i, begin, end) for(int i=...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <stdio.h> #include <iostream> #include <cstring> const int N=500005; const int M=30; int n,q,f[N][M],st[N][19]; char s[N]; using namespace std; int main() { #ifdef Kay freopen ("mujin_pc_2017_c.in","r",stdin); freopen ("mujin_pc_2017_c.out","w",stdout); #endif scanf ("\n%s",s+1),n=strlen(s+1); int i,j...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include<bits/stdc++.h> using namespace std; int nr, N, M, leftEnd[500009], rightEnd[500009], t[500009], first[500009][26]; char s[500009]; vector < int > v[500009]; void dfs (int nod) { leftEnd[nod] = ++nr; for (auto it : v[nod]) dfs (it); rightEnd[nod] = nr; } bool isAncestor (int up, int down...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <cstdio> #include <cstring> using namespace std; const int N = 5e5 + 500; const int ALP = 26; int n, dp[N][ALP + 1], q; int par[N][ALP]; char s[N]; int main(){ scanf("%s", s); n = strlen(s); for(int i = 0;i <= ALP;i++) dp[n][i] = n + 1, dp[n + 1][i] = n + 1; dp[n][ALP] = n; for(...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include<stdio.h> #include<math.h> #include<algorithm> #include<queue> #include<deque> #include<string> #include<string.h> #include<vector> #include<set> #include<map> #include<stdlib.h> using namespace std; const long long mod=1000000007; const long long inf=mod*mod; char in[1100000]; int to[1100000][27]; vector<int>g...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include<bits/stdc++.h> using namespace std; #define FOR(i,a,b) for (int i=(a);i<(b);i++) #define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--) #define REP(i,n) for (int i=0;i<(n);i++) #define RREP(i,n) for (int i=(n)-1;i>=0;i--) #define MAX_A 28 #define MAX_S 500002 int dp[MAX_A][MAX_S]; int dp2[20][MAX_S]; string s; int S...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include<bits/stdc++.h> using namespace std; const int N=600000; int f[N][30],g[N][21],das; char s[N]; int q; #define idx(x) x-'a'+1 int main(){ scanf("%s",s+1); int n=strlen(s+1); f[n][idx(s[n])]=n+1;; for (int i=n-1;i>=1;i--){ f[i][idx(s[i])]=i+1; for (int j=idx(s[i])+1;j<=27;j++) f[i][j]=f[f[i][j-1]][j-1]; ...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include<bits/stdc++.h> using namespace std; #define ll long long #define f(i, x, n) for(int i = x; i < (int)(n); ++i) char s[500001]; int nxt[500000][27], go[500000][20]; int main(){ scanf("%s", s); int n = strlen(s); f(i, 0, n)f(j, 0, 27)nxt[i][j] = 1e6; f(i, 0, n)f(j, 0, 20)go[i][j] = 1e6; for (int i = n - 1;...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <bits/stdc++.h> #define xx first #define yy second #define mp make_pair #define pb push_back #define fill(x, y) memset(x, y, sizeof x) #define copy(x, y) memcpy(x, y, sizeof x) using namespace std; typedef long long LL; typedef pair < int, int > pa; inline int read() { int sc = 0, f = 1; char ch = getchar()...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include<bits/stdc++.h> #define rep(i,a,b) for(int i=(a);i<=(b);i++) #define per(i,a,b) for(int i=(a);i>=(b);i--) #define REP(i,n) for(int i=0;i<(n);i++) #define fi first #define se second #define pb push_back #define mp make_pair using namespace std; typedef pair<int,int> pii; typedef vector<int> vi; typedef long long...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include<bits/stdc++.h> using namespace std; const int MAXN = 5e5 + 10; const int C = 26 + 1; const int LOG = 19; int n, nxt[MAXN][C], ss[MAXN][LOG]; string s; bool check(int l, int r){ for (int w = LOG - 1; ~w; w--) if (ss[l][w] != -1 && ss[l][w] <= r) l = ss[l][w]; return l == r; } int main(){ ios::sync_...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <stdio.h> #include <iostream> #include <fstream> #include <vector> #include <math.h> #include <algorithm> #include <string> #include <set> using namespace std; int main() { string str; cin >> str; int N = str.length(); int n = N, levels = 1; while ((n >>= 1) > 0) levels++; vector<vector<int>> next(N...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <bits/stdc++.h> using namespace std; const int MAXL=500005; char s[MAXL]; int nxt[MAXL][27],maxbit,d[20][MAXL]; int main() { scanf("%s",s); int l=strlen(s); fill(nxt[l],nxt[l]+26,l+1); nxt[l][26]=l; fill(nxt[l+1],nxt[l+1]+27,l+1); for (int i=l-1;i>=0;i--) { int c=s[i]-'a'; nxt[i][c]=i+1; for (i...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper...
JAVA
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
/*{{{*/ #include <vector> #include <list> #include <map> #include <set> #include <queue> #include <deque> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #incl...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <cstdio> #include <cstring> #define IL inline #define N 500007 #define K 20 #define REP(a,b,c) for(a=b;a<=c;a++) using namespace std; char s[N]; int f[N][27],fa[K][N]; IL int rd(){ int res=0;char c;while((c=getchar())<'0'||c>'9'); while(c>='0'&&c<='9')res=res*10+c-'0',c=getchar();return res; } int main(){ ...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <bits/stdc++.h> using namespace std; #define forn(i,n) for(int i=0;i<(int)(n);i++) #define si(c) ((int)(c).size()) #define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++) #define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--) #define all(c) (c).begin(), (c).end() #define D(a) cerr << #a << "=" <<...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 7; const int LOG = 20; const int C = 26; char s[N]; int n; int finish[N], go[N][C], jump[N][LOG]; int main() { scanf("%s", s + 1); n = strlen(s + 1); for (int c = 0; c < C; c++) { go[n + 1][c] = -1; } for (int i = 0; i < LOG; i++) { jump[n +...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <bits/stdc++.h> using namespace std; const int N = 500005; int n, q; int nxt[N][30]; int rmq[N][20]; string s; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> s >> q; n = s.size(); for (int j = 0; j <= 26; ++j) nxt[n][j] = nxt[n + 1][j] = n + 1; for (int i = n - 1; i >= 0; --i) { ...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include<iostream> #include<cstdio> #include<cstring> #define N 500005 using namespace std; int n,m,l,r,a[N],dp[N][27],f[N],p[N][27]; char s[N]; int main() { scanf("%s",s+1); n=strlen(s+1); for (int i=1;i<=n;i++) a[i]=s[i]-'a'+1; for (int i=0;i<=26;i++) dp[n+1][i]=10000000; f[n+1]=n+1; for (int i=n;i>=1;i--) {...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <cstdio> #include <cstring> #include <cassert> #include <algorithm> #include <iostream> #include <vector> using namespace std; #define TRACE(x) cerr << #x << " = " << x << endl #define REP(i, n) for (int i=0; i<n; i++) #define FOR(i, a, b) for (int i=(a); i<(b); i++) #define _ << " " << typedef long long ll...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include<vector> #include<cmath> #include<map> #include<cstdlib> #include<iostream> #include<sstream> #include<fstream> #include<string> #include<algorithm> #include<cstring> #include<cstdio> #include<set> #include<stack> #include<bitset> #include<functional> #include<ctime> #include<queue> #include<deque> #include<com...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <vector> #include <string> #include <algorithm> #include <stack> #include <queue> #include <set> #include <map> using namespace std; #define MOD @ #define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD) typedef long long i64; typedef vector<int...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <cstdio> #include <cstring> const int N = 500000 + 10, S = 26; int n; char s[N]; int m, succ[N][S + 1], mem[S][N]; int anc[N]; int find(int x) { return anc[x] == x ? x : (anc[x] = find(anc[x])); } inline void check(int &lhs, int rhs) { lhs = (!lhs || (rhs && rhs < lhs) ? rhs : lhs); } void meld(int x,...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <iostream> #include <vector> #include <cstdio> #include <sstream> #include <map> #include <string> #include <algorithm> #include <queue> #include <cmath> #include <functional> #include <set> #include <ctime> #include <random> #include <chrono> #include <cassert> #include <tuple> #include <utility> using namesp...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include<vector> #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; const int N = 500005; int n, m; char s[N]; vector<pair<int, int> > q[N]; bool ans[N]; int fa[N]; struct Node { int id; Node* next[26]; Node(int id) : id(id) { for (int i = 0; i < 26; ++i) { ne...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include<bits/stdc++.h> #define For(i,j,k) for(int i=j;i<=k;++i) #define Dow(i,j,k) for(int i=k;i>=j;--i) #define ll long long #define PI acos(-1) using namespace std; inline ll read() { ll t=0,f=1;char c=getchar(); while(!isdigit(c)) {if(c=='-') f=-1;c=getchar();} while(isdigit(c)) t=t*10+c-48,c=getchar(); retur...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include<cstdio> #include<iostream> #include<vector> #include<algorithm> #include<numeric> #include<functional> #include<string> using namespace std; const long long int mod = 1000000007; const long long int big = 1152921504606846976; int main(void) { int Q,h,i,j,x,l,r; int c; static int next[500010][27]; static i...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <bits/stdc++.h> #define x first #define y second using namespace std; typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int,int> ii; typedef pair<ll,ll> pll; const int mod=1000000000+7; int addm(int& a,int b) {return (a+=b)<mod?a:a-=mod;} template<...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <bits/stdc++.h> typedef long long LL; #define FOR(i, a, b) for (int i = (a), i##_END_ = (b); i <= i##_END_; i++) #define DNF(i, a, b) for (int i = (a), i##_END_ = (b); i >= i##_END_; i--) template <typename Tp> void in(Tp &x) { char ch = getchar(), f = 1; x = 0; while (ch != '-' && (ch < '0' || ch > '9'))...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <algorithm> #include <iostream> #include <sstream> #include <string> #include <cstring> #include <vector> #include <queue> #include <set> #include <map> #include <cstdio> #include <cstdlib> #include <cctype> #include <cmath> #include <list> #include <cassert> #include <ctime> #include...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
/*{{{*/ #include <vector> #include <list> #include <map> #include <set> #include <queue> #include <deque> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #incl...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; typedef complex<double> point; #define xx real() #define yy imag() #define REP(i, a, b) for(int i = (a); i < (int)(b); i++) #define REPN(i, a, b) for(int i ...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <bits/stdc++.h> #define fi first #define se second #define pii pair<int,int> #define mp make_pair #define pb push_back #define space putchar(' ') #define enter putchar('\n') #define eps 1e-10 #define MAXN 500005 //#define ivorysi using namespace std; typedef long long int64; typedef unsigned int u32; typedef d...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <bits/stdc++.h> using namespace std; using ll=long long; #define int ll #define rng(i,a,b) for(int i=int(a);i<int(b);i++) #define rep(i,b) rng(i,0,b) #define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--) #define per(i,b) gnr(i,0,b) #define pb push_back #define eb emplace_back #define a first #define b second ...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include<bits/stdc++.h> using namespace std; const int MAXN = 500005; const int LOG = 20; int n, q; string s; int dp[26][MAXN], p[MAXN], par[LOG][MAXN]; void precompute () { for (int i = 1; i <= n; i++) { if (p[i - 1] == n) par[0][i] = 0; else par[0][i] = p[i - 1] + 2; } for (int i = 1; i < LOG;...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <sstream> #include <cassert> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <iostream> #include <iomanip> #include <algorithm> #include <vector> #include <set> #include <stack> #include <map> #include <string> #include <queue> #include <bitset> using namespace std; #define ...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
/*#pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/ #include<bits/stdc++.h> #define ll long long #define N 500005 #define inf 1000000005 #define mod 1000000007 #define put putchar('\n') #define F(i,a,b) for (int i=(a);i<...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include<bits/stdc++.h> #define st first #define nd second #define pb push_back #define pf push_front #define ppb pop_back #define ppf pop_front #define umax(x,y) x=max(x,y) #define umin(x,y) x=min(x,y) #define ll long long #define ii pair<int,int> #define iii pair<int,ii> #define iiii pair<ii,ii> #define sz(x) ((int)...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <bits/stdc++.h> using namespace std; const int maxn = 5e5+10; const int logo = 23; const int off = 1 << logo; const int treesiz = off << 1; int n, q; char niz[maxn]; int dp[maxn][30]; int ne[logo + 10][maxn]; int main() { scanf("%s%d", niz, &q); n = strlen(niz); for (int i = 0; i < 27; i++) ...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; void Get_Val(int &Ret) { Ret = 0; char ch; while (ch = getchar(), ch > '9' || ch < '0') ; do { (Ret *= 10) += ch - '0'; } while (ch = getchar(), ch >= '0' && ch <= '9'); } const int Max_N(500050); int N, F[Max_N][27], Anc[20]...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include<bits/stdc++.h> #define idx(x) (x-'a') const int maxn=5e5+10; const int inf=1061109567; char s[maxn]; int n,q,next[maxn][27]; int main() { int i,j,k; scanf("%s%d",s+1,&q); memset(next,inf,sizeof(next)); for(n=0;s[n+1];n++); for(i=1;i<=n;i++) next[i][idx(s[i])]=i; for(i=n;i;i--){...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include<bits/stdc++.h> using namespace std; #define N 600000 int n,m,f[N][30],go[N][30]; char s[N]; int main(){ scanf("%s",s+1); n=strlen(s+1); for (int i=n;i;--i){ f[i][s[i]-'a']=i+1; for (int j=s[i]-'a'+1;j<26;++j) f[i][j]=f[f[i][j-1]][j-1]; go[i][0]=f[f[i][25]][25]; for (int j=1;j<=20;++j) go[i]...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <iostream> #include <vector> #include <stack> #include <queue> #include <algorithm> #include <cmath> #include <string> #include <map> #include <set> #include <list> #define ll long long #define fornum(A,B,C) for(A=B;A<C;A++) using namespace std; int i,j,k,l,m,n; /////////////////////////////////////////////...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <vector> #include <string> #include <algorithm> #include <stack> #include <queue> #include <set> #include <map> using namespace std; #define MOD @ #define ADD(X,Y) ((X) = ((X) + (...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define pii pair<int,int> #define pll pair<ll,ll> #define pdd pair<double,double> #define X first #define Y second #define REP(i,a) for(int i=0;i<a;++i) #define REPP(i,a,b) for(int i=a;i<b;++i) #define FILL(a,x) memset(a,x,sizeof(a)) #define foreach( g...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <iostream> #include <string> using namespace std; string S; int dp[500009][27], nex[500009][22]; int main() { cin >> S; for (int i = 0; i <= S.size(); i++) { for (int j = 0; j < 27; j++) dp[i][j] = (1 << 30); } for (int i = S.size() - 1; i >= 0; i--) { int A = S[i] - 'a'; for (int j = 0; j <= 26; j...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include<cstdio> #include<cstring> const int M=500009,INF=100000000; int n,i,j,q,l,r,a[M],f[M][20],dp[M][30]; char s[M]; int read() { int x=0; char ch=getchar(); while (ch<48 || ch>57) ch=getchar(); while (ch>=48 && ch<=57) x=(x<<1)+(x<<3)+ch-48,ch=getchar(); return x; } int main() { scanf("%s",s+1),n=strlen(s+1...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> char s[524288]; int a[524288]; int n; int f[524288][27]; int e[524288][20]; int main() { //freopen("C.in", "r", stdin); scanf("%s", s); n = strlen(s); memset(f, -1, sizeof(f)); memset(e, -1, sizeof(e)); for (int i = n...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <cstdio> #include <cstring> #include <set> using namespace std; char s[500001]; int a[500001][27]; int b[20][500001]; set <int> se[500000]; bool in(int x, int y) { int i; for (i = 19; i >= 0; i--) { if (b[i][x] == -1 || b[i][x] > y) continue; if (b[i][x] == y) return tr...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include<bits/stdc++.h> #define maxn 500100 using namespace std; char s[maxn]; int nxt[maxn][27],f[20][maxn],n,q; int main(){ scanf("%s",s+1); n=strlen(s+1); for(int i=0;i<=26;++i)nxt[n+1][i]=n+2,nxt[n+2][i]=n+2; for(int i=0;i<=18;++i)f[i][n+2]=n+2,f[i][n+1]=n+2; for(int i=n;i>=1;--i){ nxt[i][s[i]-'a']=i+1; fo...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <cstdio> #include <iostream> #include <algorithm> #include <string> #include <cstring> #include <vector> #include <queue> #include <set> #include <map> #include <cmath> #include <iomanip> #include <cassert> #include <bitset> using namespace std; typedef pair<int, int> P; #define rep(i, n) for (int i=0; i<(n);...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include <bits/stdc++.h> #define debug(x) cout << #x" = " << x; #define st first #define nd second using namespace std; using namespace placeholders; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> PII; typedef pair<ll, ll> PLL; const int MAXN = 5E5 + 10, SIGMA = 26, D = 18; char s[MA...
CPP
p03793 Mujin Programming Challenge 2017 - Robot and String
You are developing a robot that processes strings. When the robot is given a string t consisting of lowercase English letters, it processes the string by following the procedure below: 1. Let i be the smallest index such that t_i = t_{i + 1}. If such an index does not exist, terminate the procedure. 2. If t_i is `z`, ...
6
0
#include<cstring> #include<cstdlib> #include<cstdio> #include<cmath> #include<iostream> #define N 510000 using namespace std; struct node{int y,nex;}a[N]; int nex[N][27],n,inf,id,fir[N],len,dfn[N],las[N],m; char s[N]; void ins(int x,int y) { a[++len].y=y;a[len].nex=fir[x];fir[x]=len; } void dfs(int x) { dfn[x]=++id; ...
CPP