QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#316864 | #8176. Next TTPC 3 | ucup-team2894# | AC ✓ | 280ms | 101200kb | C++20 | 9.0kb | 2024-01-28 05:00:08 | 2024-01-28 05:00:08 |
Judging History
answer
#include <bits/stdc++.h>
#define fr first
#define sc second
#define all(a) (a).begin(), (a).end()
#define unique(a) a.resize(unique(a.begin(), a.end()) - a.begin())
using namespace std;
#ifdef ONPC
mt19937 rnd(223);
#else
mt19937 rnd(chrono::high_resolution_clock::now()
.time_since_epoch().count());
#endif
#define TIME (clock() * 1.0 / CLOCKS_PER_SEC)
using ll = long long;
using ld = double;
const int maxn = 1e5 + 100, inf = 1e9 + 100;
ll lcm(ll a,ll b) {
return a/gcd(a,b)*b;
}
namespace fft {
using dbl = double; // works for max value (max(a)*max(b)*n) up to 1e14 (multiply_mod with n up to 1e5)
// using dbl = long double; // works for max value (max(a)*max(b)*n) up to 1e17
const dbl PI = acosl(-1.0l);
struct Complex {
dbl x, y;
Complex(dbl x = 0, dbl y = 0) : x(x), y(y) {}
Complex conj() const {
return Complex(x, -y);
}
};
Complex operator * (const Complex &a, const Complex &b) { return Complex(a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x); }
void operator /= ( Complex &a, int n) { a.x /= n; a.y /= n; }
Complex operator / (const Complex &a, int n) { return Complex(a.x / n, a.y / n); }
Complex operator + (const Complex &a, const Complex &b) { return Complex(a.x + b.x, a.y + b.y); }
Complex operator - (const Complex &a, const Complex &b) { return Complex(a.x - b.x, a.y - b.y); }
string to_string ( const Complex &x) { return (string)"(" + std::to_string(x.x) + ", " + std::to_string(x.y) + ")"; };
ostream& operator << (ostream &o, const Complex &x) { return o << to_string(x); }
vector<Complex> buf1;
vector<Complex> buf2;
vector<Complex> w = {1, 1};
vector<int> reversed = {0};
void update_n(int n) {
assert((n & (n - 1)) == 0);
int cur = reversed.size();
if (n <= cur) return;
reversed.resize(n);
w.resize(n + 1);
while (cur < n) {
for (int i = 0; i < cur; ++i)
reversed[i] <<= 1;
for (int i = cur; i < (cur << 1); ++i)
reversed[i] = reversed[i - cur] ^ 1;
for (int i = (cur << 1) - 2; i > 0; i -= 2)
w[i] = w[i / 2];
for (int i = 1; i < (cur << 1); i += 2)
w[i] = Complex(cos(PI * i / cur), sin(PI * i / cur));
cur *= 2;
}
w.back() = 1;
}
void fft_internal(vector<Complex> &v, int from, int n, bool inv) {
update_n(n);
int N = reversed.size();
int d = __lg(N) - __lg(n);
for (int i = 1; i < n; ++i)
if (i < (reversed[i] >> d))
swap(v[from + i], v[from + (reversed[i] >> d)]);
for (int ln = 1; ln < n; ln <<= 1) {
int step = (inv ? -N : N) / (ln * 2);
for (int i = 0; i < n; i += (ln << 1)) {
int ind = (inv ? N : 0);
for (int j = 0; j < ln; ++j) {
Complex y = v[from + i + j + ln] * w[ind];
ind += step;
v[from + i + j + ln] = v[from + i + j] - y;
v[from + i + j] = v[from + i + j] + y;
}
}
}
if (inv)
for (int i = 0; i < n; ++i)
v[from + i] /= n;
}
// only if you need this
vector<Complex> fft(const vector<int> &v, int n = -1) {
if (n == -1) {
n = 1;
while (n < v.size()) n <<= 1;
}
assert(v.size() <= n);
buf1.assign(n, {0, 0});
for (int i = 0; i < v.size(); ++i)
buf1[i].x = v[i];
fft_internal(buf1, 0, n, false);
return vector<Complex>(buf1.begin(), buf1.end());
}
// only if you need this
vector<long long> fft(const vector<Complex> &v) {
assert(!v.empty() && (v.size() & (v.size() - 1)) == 0);
buf1.resize(v.size());
for (int i = 0; i < v.size(); ++i)
buf1[i] = v[i];
fft_internal(buf1, 0, buf1.size(), true);
vector<long long> result(v.size());
for (int i = 0; i < result.size(); ++i)
result[i] = llround(buf1[i].x);
return result;
}
vector<long long> multiply(const vector<int> &a, const vector<int> &b) {
if (a.empty() || b.empty()) return {};
int n = 2;
while (n < a.size() + b.size() - 1) n <<= 1;
buf1.assign(n, {0, 0});
for (int i = 0; i < a.size(); ++i)
buf1[i].x = a[i];
for (int i = 0; i < b.size(); ++i)
buf1[i].y = b[i];
fft_internal(buf1, 0, n, false);
for (int i = 0; i <= (n >> 1); ++i) {
// a --fft--> a1 + a2*i
// b --fft--> b1 + b2*i
// fact: FFT(a)[k] = FFT(a)[n - k].conj()
// using this we can get formulas for FFT(a) and FFT(b) from FFT(a+bi)
int j = (n - i) & (n - 1);
auto v = (buf1[i] + buf1[j].conj()) * (buf1[i] - buf1[j].conj()) / 4;
swap(v.x, v.y);
buf1[i] = v.conj();
buf1[j] = v;
}
fft_internal(buf1, 0, n, true);
vector<long long> result(a.size() + b.size() - 1);
for (int i = 0; i < result.size(); ++i)
result[i] = llround(buf1[i].x);
return result;
}
vector<int> multiply_mod(const vector<int> &a, const vector<int> &b, int mod) {
if (a.empty() || b.empty()) return {};
int n = 2;
while (n < a.size() + b.size() - 1) n <<= 1;
buf1.assign(n * 2, {0, 0});
for (int i = 0; i < a.size(); ++i) {
buf1[i].x = a[i] & ((1 << 15) - 1);
buf1[i].y = a[i] >> 15;
}
buf2.assign(n * 2, {0, 0});
for (int i = 0; i < b.size(); ++i) {
buf2[i].x = b[i] & ((1 << 15) - 1);
buf2[i].y = b[i] >> 15;
}
fft_internal(buf1, 0, n, false);
fft_internal(buf2, 0, n, false);
for (int i = 0; i <= (n >> 1); ++i) {
int j = (n - i) & (n - 1);
Complex as = (buf1[i] + buf1[j].conj()) / 2;
Complex bs = (buf2[i] + buf2[j].conj()) / 2;
Complex al = (buf1[i] - buf1[j].conj()) / 2;
Complex bl = (buf2[i] - buf2[j].conj()) / 2;
Complex asbs = as * bs;
Complex albs = al * bs;
Complex asbl = as * bl; swap(asbl.x, asbl.y);
Complex albl = al * bl; swap(albl.x, albl.y);
buf1[i] = asbs + albl.conj();
buf1[j] = asbs.conj() - albl;
buf2[i] = asbl.conj() + albs;
buf2[j] = asbl - albs.conj();
}
fft_internal(buf1, 0, n, true);
fft_internal(buf2, 0, n, true);
vector<int> result(a.size() + b.size() - 1);
for (int i = 0; i < result.size(); ++i) {
long long asbs = llround(buf1[i].x);
long long albl = llround(buf1[i].y);
long long asbl = llround(buf2[i].x);
long long albs = llround(buf2[i].y);
result[i] = (((albl % mod) << 30) + (((asbl + albs) % mod) << 15) + asbs) % mod;
}
return result;
}
} // fft
void solve() {
int n;
cin >> n;
string s[4];
vector<bool> good[4];
string tar = "TTPC";
for(int i=0;i<4;i++)cin >> s[i],good[i].resize(s[i].size());
for(int i=0;i<4;i++){
for(int j=0;j<s[i].size();j++) {
if(s[i][j]==tar[i])good[i][j]=1;
}
}
vector<int> num[2];
for(int pa=0;pa<2;pa++){
ll len = lcm(s[2*pa].size(),s[2*pa+1].size());
num[pa].resize(len);
for(int i = 0; i < len; ++i){
num[pa][i]=(good[2*pa][i%good[2*pa].size()]&&good[2*pa+1][i%good[2*pa+1].size()]);
}
}
auto rnum1 = num[1];
reverse(all(rnum1));
auto diffs = fft::multiply(num[0],rnum1);
ll g = gcd(num[0].size(), num[1].size());
ll prd = lcm(num[0].size(), num[1].size());
ll eff = 0;
for(int i=0;i<diffs.size();i++){
if((i-(ll(num[1].size())-1))%g==0)eff += diffs[i];
}
if(eff==0){
cout << "-1\n";
return;
}
ll cur=(n-1)/eff*prd;
n-=(n-1)/eff*eff;
ll na[2]={cur+(ll)num[0].size(),cur+(ll)num[1].size()};
while(true) {
ll d = cur%num[0].size()-cur%num[1].size() + num[1].size()-1;
// cerr << n << " " << d << " " << diffs[d] << endl;
if(diffs[d]>=n) {
while(true) {
if(num[0][cur%num[0].size()]&&num[1][cur%num[1].size()]){
n--;
if(n==0){
cout << cur+1 << "\n";
return;
}
}
cur++;
}
}
else {
n-=diffs[d];
if(na[0]<na[1]){
cur=na[0];
na[0]+=num[0].size();
}
else {
cur=na[1];
na[1]+=num[1].size();
}
}
}
}
int main() {
#ifdef ONPC
freopen("../a.in", "r", stdin);
// freopen("../a.out", "w", stdout);
#endif
ios::sync_with_stdio(0);
cin.tie(0);
cout << fixed;
cout.precision(20);
solve();
cerr << "\n\nConsumed " << TIME << endl;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 4232kb
input:
3 TTPC TLE P AC
output:
34
result:
ok "34"
Test #2:
score: 0
Accepted
time: 1ms
memory: 4384kb
input:
670055 TF OITFKONTO GFPPNPWTZP CCZFB
output:
-1
result:
ok "-1"
Test #3:
score: 0
Accepted
time: 1ms
memory: 4284kb
input:
910359 TOKYO TECH PROGRAMMING CONTEST
output:
1401951321
result:
ok "1401951321"
Test #4:
score: 0
Accepted
time: 8ms
memory: 9660kb
input:
518530 TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT...
output:
518530
result:
ok "518530"
Test #5:
score: 0
Accepted
time: 41ms
memory: 28280kb
input:
252288 TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT...
output:
252288
result:
ok "252288"
Test #6:
score: 0
Accepted
time: 48ms
memory: 27584kb
input:
1000000 TTJLTTPNTTQNTTBJTTHZTTJSTTRUTTVWTTJXTTMGTTZHTTRWTTNHTTDWTTMGTTIDTTSYTTPPTTGQTTXYTTOETTYMTTZATTAOTTJNTTHHTTYLTTJBTTLLTTNNTTCITTCBTTDOTTNGTTPZTTUETTFHTTODTTCETTKXTTGUTTZSTTECTTFSTTHOTTESTTNQTTHJTTDPTTFKTTCMTTNMTTGRTTYPTTKQTTYCTTUITTYCTTWWTTZDTTCPTTRSTTLFTTPKTTEXTTUPTTXWTTDATTVUTTLCTTEGTTOLTTRI...
output:
-1
result:
ok "-1"
Test #7:
score: 0
Accepted
time: 45ms
memory: 27496kb
input:
359869 TTXTTTYTTTITTTHTTTRTTTOTTTETTTKTTTZTTTYTTTBTTTUTTTBTTTJTTTDTTTYTTTJTTTKTTTYTTTLTTTATTTLTTTITTTHTTTUTTTMTTTDTTTITTTPTTTITTTCTTTCTTTRTTTZTTTVTTTETTTGTTTNTTTUTTTGTTTYTTTJTTTKTTTQTTTSTTTPTTTWTTTPTTTZTTTETTTJTTTVTTTGTTTUTTTBTTTCTTTCTTTXTTTWTTTETTTFTTTGTTTDTTTATTTCTTTITTTWTTTWTTTITTTSTTTRTTTYTTTETT...
output:
-1
result:
ok "-1"
Test #8:
score: 0
Accepted
time: 49ms
memory: 27220kb
input:
856943 QNTJMTFRTNDTXOTJRTNNTCXTZNTQMTSBTMRTDMTMOTEATOXTHWTOJTQQTLITKRTNSTNITSMTRVTLLTKBTSATYVTHXTEZTRXTPNTEQTQDTVZTMOTJVTESTRQTBBTAXTMNTUBTULTFPTXQTIBTCMTXXTMZTOWTYVTPVTDSTMWTZDTGQTVMTRFTKDTQITKSTCQTOPTSRTJWTFCTEFTCKTISTELTWGTHOTODTQHTLETRCTSHTJITQGTSUTFDTFZTFYTBJTKNTMHTHWTOZTARTZGTQETRITMSTXVTZATKJ...
output:
-1
result:
ok "-1"
Test #9:
score: 0
Accepted
time: 38ms
memory: 26944kb
input:
12 TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT...
output:
-1
result:
ok "-1"
Test #10:
score: 0
Accepted
time: 43ms
memory: 27524kb
input:
1000000 WTTTNTTTLTTTZTTTWTTTKTTTDTTTATTTNTTTMTTTZTTTHTTTVTTTVTTTITTTSTTTNTTTSTTTPTTTVTTTWTTTJTTTRTTTQTTTFTTTQTTTMTTTMTTTYTTTWTTTLTTTMTTTNTTTCTTTWTTTSTTTVTTTDTTTUTTTLTTTCTTTCTTTZTTTQTTTQTTTWTTTDTTTQTTTZTTTUTTTQTTTITTTYTTTATTTATTTGTTTITTTWTTTYTTTYTTTFTTTHTTTPTTTDTTTWTTTRTTTLTTTNTTTFTTTNTTTNTTTCTTTBTTT...
output:
-1
result:
ok "-1"
Test #11:
score: 0
Accepted
time: 44ms
memory: 27564kb
input:
506084 TPTGTATITNTJTPTBTZTDTRTVTJTVTSTFTWTNTATYTKTJTCTBTPTPTJTSTQTGTPTKTYTBTMTXTVTMTUTFTPTRTYTVTFTATCTLTITVTUTNTATCTJTYTOTOTMTKTBTMTMTKTQTWTBTHTITATUTYTNTETRTYTWTDTLTCTPTGTKTMTETGTCTWTMTNTKTMTATDTQTWTWTPTMTRTYTQTMTJTCTGTXTDTUTSTBTYTFTKTGTYTHTNTOTOTXTQTITITSTGTUTMTNTPTETJTDTJTRTBTKTXTCTSTRTZTSTWTUTJT...
output:
-1
result:
ok "-1"
Test #12:
score: 0
Accepted
time: 43ms
memory: 27224kb
input:
95378 JTTGTTYTTMTTFTTSTTUTTBTTNTTSTTVTTKTTYTTUTTITTFTTYTTKTTSTTSTTATTMTTQTTMTTLTTRTTWTTQTTLTTWTTPTTYTTGTTPTTNTTUTTRTTKTTWTTHTTVTTGTTMTTQTTUTTXTTCTTZTTUTTBTTDTTPTTJTTETTZTTNTTOTTKTTITTOTTGTTSTTQTTVTTZTTATTBTTATTOTTYTTZTTZTTZTTDTTPTTHTTMTTDTTLTTNTTNTTITTETTRTTYTTOTTWTTZTTGTTGTTRTTXTTKTTGTTVTTDTTSTTWTT...
output:
27097032
result:
ok "27097032"
Test #13:
score: 0
Accepted
time: 48ms
memory: 28072kb
input:
12 TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT...
output:
10636
result:
ok "10636"
Test #14:
score: 0
Accepted
time: 50ms
memory: 28004kb
input:
1000000 LTTTWTTTLTTTWTTTITTTQTTTWTTTKTTTSTTTGTTTLTTTHTTTXTTTFTTTYTTTPTTTBTTTFTTTYTTTBTTTZTTTYTTTHTTTNTTTVTTTKTTTMTTTITTTQTTTYTTTYTTTZTTTGTTTBTTTLTTTMTTTJTTTYTTTVTTTITTTYTTTRTTTCTTTHTTTRTTTUTTTWTTTQTTTITTTVTTTWTTTMTTTRTTTFTTTITTTYTTTETTTFTTTHTTTOTTTYTTTOTTTXTTTFTTTLTTTRTTTFTTTGTTTETTTBTTTVTTTETTTWTTT...
output:
907999396
result:
ok "907999396"
Test #15:
score: 0
Accepted
time: 46ms
memory: 27488kb
input:
713716 BTTCTTOTTZTTWTTOTTHTTITTITTITTWTTGTTFTTJTTMTTWTTRTTGTTFTTLTTJTTDTTWTTITTRTTMTTQTTDTTJTTWTTHTTKTTRTTQTTSTTETTKTTYTTRTTSTTGTTQTTYTTOTTCTTLTTSTTOTTETTUTTRTTETTLTTQTTYTTYTTITTUTTXTTZTTXTTJTTQTTWTTWTTMTTRTTATTNTTSTTJTTKTTGTTHTTVTTSTTRTTXTTMTTUTTNTTPTTQTTHTTJTTHTTETTQTTGTTGTTATTITTATTBTTQTTWTTHTTWT...
output:
563121569
result:
ok "563121569"
Test #16:
score: 0
Accepted
time: 41ms
memory: 28116kb
input:
11522 TXTTTHTTTVTTTOTTTFTTTZTTTKTTTZTTTJTTTDTTTPTTTRTTTHTTTOTTTXTTTCTTTWTTTNTTTDTTTSTTTWTTTCTTTHTTTXTTTFTTTSTTTOTTTHTTTCTTTWTTTUTTTXTTTSTTTZTTTXTTTLTTTETTTKTTTLTTTXTTTLTTTVTTTATTTLTTTHTTTDTTTITTTQTTTLTTTKTTTETTTATTTHTTTYTTTOTTTDTTTSTTTCTTTVTTTRTTTITTTITTTMTTTPTTTNTTTJTTTXTTTKTTTXTTTGTTTCTTTUTTTCTTTW...
output:
11152921
result:
ok "11152921"
Test #17:
score: 0
Accepted
time: 47ms
memory: 28392kb
input:
1000000 YHTTKJTTFNTTMITTNWTTOETTWJTTCFTTIRTTVJTTJMTTHOTTBITTLXTTRLTTVLTTOFTTMYTTOGTTAYTTVLTTCRTTENTTLKTTKETTXPTTSFTTCZTTGLTTJZTTGFTTOYTTSFTTLHTTNMTTANTTSGTTKKTTXETTABTTSBTTLLTTQOTTNDTTWATTERTTAUTTMWTTISTTASTTZJTTPXTTONTTVGTTEATTVBTTXGTTSITTPNTTLITTLQTTHVTTKOTTQGTTVLTTDQTTLHTTJETTWFTTDFTTIQTTIETTKHTT...
output:
-1
result:
ok "-1"
Test #18:
score: 0
Accepted
time: 48ms
memory: 27860kb
input:
1000000 TTXZTTYMTTVYTTASTTUPTTABTTLRTTEPTTQPTTMKTTCOTTPKTTPGTTSITTDRTTQSTTCPTTXWTTXBTTJDTTZNTTIPTTIOTTKJTTQITTEJTTJRTTAQTTIBTTAETTUOTTUETTDRTTNFTTPZTTYHTTMZTTQDTTCDTTVDTTHNTTXKTTUPTTFPTTYFTTIUTTUBTTJATTYFTTJWTTGUTTPXTTIPTTHSTTVATTHWTTWZTTMSTTJRTTYWTTSRTTUPTTDQTTKJTTIUTTVBTTNOTTBGTTINTTAMTTRNTTAXTTDW...
output:
-1
result:
ok "-1"
Test #19:
score: 0
Accepted
time: 42ms
memory: 27816kb
input:
367325 TSITTGUTTPJTTVDTTSSTTIJTTZATTKGTTPATTCKTTBWTTYKTTRUTTMOTTUQTTEDTTFLTTYOTTRITTYVTTGXTTVJTTWPTTVDTTAFTTSOTTJZTTDKTTBUTTSPTTFSTTHXTTKDTTVJTTCUTTALTTRHTTAJTTZHTTZDTTAOTTJVTTLKTTSXTTFITTDPTTGSTTXRTTEITTOQTTEPTTVCTTSITTJUTTPXTTZWTTPKTTUZTTLWTTYBTTFETTJYTTLDTTGSTTIITTKFTTKHTTUGTTVPTTXNTTFCTTLZTTYXTT...
output:
-1
result:
ok "-1"
Test #20:
score: 0
Accepted
time: 47ms
memory: 28648kb
input:
1000000 TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT...
output:
-1
result:
ok "-1"
Test #21:
score: 0
Accepted
time: 50ms
memory: 28700kb
input:
1000000 NTTNWTTJFTTLMTTSATTRWTTEXTTBETTPBTTEBTTXPTTUDTTWVTTWMTTWZTTCATTSBTTKBTTEKTTNHTTPBTTCATTVITTPJTTCYTTAPTTVLTTDHTTVQTTJUTTCFTTLXTTODTTFMTTXRTTRLTTNPTTVNTTYMTTOXTTDUTTVZTTSDTTMPTTYCTTLKTTFATTCETTUFTTGDTTKVTTGYTTVATTYZTTQRTTWQTTMGTTFXTTLDTTXRTTGFTTPLTTQQTTOVTTEOTTJSTTXSTTQKTTRVTTWZTTKXTTRBTTRRTTM...
output:
-1
result:
ok "-1"
Test #22:
score: 0
Accepted
time: 48ms
memory: 27524kb
input:
1000000 DTTTATTTBTTTUTTTUTTTNTTTDTTTITTTATTTRTTTFTTTJTTTZTTTDTTTRTTTETTTWTTTCTTTHTTTFTTTBTTTJTTTUTTTWTTTJTTTCTTTETTTYTTTHTTTWTTTETTTWTTTCTTTZTTTWTTTYTTTKTTTRTTTLTTTVTTTETTTOTTTDTTTPTTTLTTTMTTTWTTTCTTTXTTTDTTTPTTTVTTTFTTTATTTKTTTWTTTOTTTUTTTPTTTZTTTMTTTETTTWTTTRTTTPTTTRTTTHTTTFTTTYTTTRTTTKTTTJTTTETTT...
output:
452272320
result:
ok "452272320"
Test #23:
score: 0
Accepted
time: 44ms
memory: 28600kb
input:
1000000 CTITITNTHTTTBTZTNTMTFTCTZTJTRTBTUTPTWTWTNTUTMTUTETITITATKTMTRTPTVTXTPTHTNTGTSTMTUTWTKTWTITBTCTHTFTWTDTHTWTBTSTNTNTCTGTVTVTVTMTVTITWTJTRTYTETMTKTFTGTPTXTHTGTXTVTPTHTKTSTMTUTMTLTCTDTHTGTUTVTPTYTQTOTBTMTZTZTWTOTFTGTATBTFTQTNTPTGTLTYTKTPTCTFTATSTDTQTBTXTATVTRTGTITSTITDTKTPTNTKTKTBTATWTKTRTBTMTDT...
output:
975999035
result:
ok "975999035"
Test #24:
score: 0
Accepted
time: 97ms
memory: 53084kb
input:
11 WHLKKWTICHLBXNJKGGFGQLTLEHQUIYKLQZVWFFAVIDVCVJHUSJTYQTIJECJNQCLEJNZPKMPVBPKZHENYFXCSXZEUVJAFLMWIZPDWQDNRPBIGBTMNQKQOGJFEQYDHQYIBZXHBMWTJZJJWYWCQLEDVCUVCDMPEWOXGRADJQGRANTLNMTMHALLKTZYLFZPOPTOGKSTJBGJEGKBONVGJUSQDPBTECDEDGHAZCZOMZBMXVVTNMLPPLBVHLZXASGFRAIBAULIYDEHASZNGQDUBZCRTZYIXBDYWAGOIGCOAAPPON...
output:
6385324
result:
ok "6385324"
Test #25:
score: 0
Accepted
time: 274ms
memory: 93752kb
input:
14 UCBNFDDWTZCYVRYRQCEWBIVBQADDGNHJDJIPZMHCDWLAJDEJXIJIQTUOSNEUONNQIMOCRLSQXBPHDPQYBJLRQMANSCKNMCORGLIGAVBZQWQJKZFYDARHAZWYQOWYBKTWYESJAXNWDEEITRMCAPWAVVQQCCKQBSIPEGYZQXHYLWFOIYQBFESGUABSXJTOLACYNAUGFXJIBICEDPFLCUGQPDVZVGXRBKSHIDMFGEAAAPVCEBZJIZJQJTXQEPLZXFUQYWWPBQIDQDAXCGSBJNMBVOQTPWMTVVIZZTZZNOLBN...
output:
3768074
result:
ok "3768074"
Test #26:
score: 0
Accepted
time: 111ms
memory: 52944kb
input:
621991 PHSWLBLHWDNEUDLSMTKUPSYGZVVTXZVDFLIJERLKFTKBCPATGFTPXCYHAHBCPCFDBHHJMGDDIHSCNHNJMDPGMXXBSVCQMWALQNVOVWESQDBUTDPUMOUFTIHPQPYFUSWARGPFZFVUNNRUBOTHERYQVKCODQOMKXOAKSQEOVEXDNCHYNIVKEJJVJSZSSCQKXDWVMSWEXXKOYMQZSGCLTFQIRZMVVXXPJSGDZWRZYIJOLGGZCAHKUGSMEOHLJZKYZGIEHQDAIGBAPTJQIXUCMZDTDPAWACGFJWUWPRVS...
output:
285656877012
result:
ok "285656877012"
Test #27:
score: 0
Accepted
time: 272ms
memory: 97716kb
input:
681065 BPEIWKXAPGASDFYOVYWFZIFZJCTSZOHAXWADMHJQZAVYZDMYUEBGJMPIFDQIHSWKJZKXDJGLUMRGBSVFLDRWGSDWDXBBNMQFDJLVGSEHCFWYINVJGCGIOXIFVVQWYPVHSMOTSCJLYFNHBWNZHHYBGZKRZBPAYJFRZOICJOOBOVXGEIUXMGEUVYSFUPITQGHGFUPHCPJLBRRXUBLQRQVDSFHCYODJXQJZJKDZWEHLQRJIONJGGDJHXJUTJSXYKXHCAXRLXVRQZNXNZWMUCVXQLUPCIILGAXCDZMQHV...
output:
640624135227
result:
ok "640624135227"
Test #28:
score: 0
Accepted
time: 109ms
memory: 53396kb
input:
36576 IRMNJPGAQZMFDZACMEVLGQSDJLXFAZDQRXSIDMSYFRDHZVQRDZBVXMMMGAPYFJBSHVDQVASDYGLCWKADPAEFHBAXIZWXSMNJYEKSKKNAKESFUQEDOLDZYOIPVSEXKVJPHMZGXOYLWDNJBPRIISSWDYPGICCCERHMHCRYNZFPMYXXUPMAWPUIVGKHCJIQBQPPEDZDXZNUFQOCKZRSRAKCMVMSCBVFAJXUAVFZVUFERGHDXFMHUBOLXCJCNSHIEHNBWJYKOEUTXMKBPGQKWQZRLXYDFTCWLBBIYBFTYS...
output:
1631600024900756
result:
ok "1631600024900756"
Test #29:
score: 0
Accepted
time: 99ms
memory: 53052kb
input:
870492 ADNCVEKYFEDDSBIFJBFNAIHWGFWXLWYGROVNMWHJPTPCHMMFBYAXZFOUBOOCXQLEHLQCHJVJVGSMNPFNHHWOJBMDEASWBBALXBSFXXFVLIBEUMXGSNSKLEKOQGYHRLENMRRKNIURCFVQSXLNJJJNAYYSPFCILXCGCRFCBZDQAHKACQNFDSNKBFYDROLJPDKWZVLAJCUVIFXEHVGKXXKDKOOXFHKSARJMVWXGUYWUCDZOXNFHMYPJOECWNOXQBBWDOSSYUMCMZWSNSXMCBXNZHISVKLDJXABDKOVQH...
output:
2249019642670992
result:
ok "2249019642670992"
Test #30:
score: 0
Accepted
time: 109ms
memory: 52360kb
input:
699084 DMSSXMPXNYSUSGIHNSJDADZYKFGERGBHUVBJQLNZPBQSVFKZNAEGQJCGBAQVBMCFOWAZEJOEPIYSAKEEIDKVBMHVZGUWIGWGHDWMRCXDVAAWHSVMBCVCFLBMMKEJMMUSGWKXZXLKRQVDLUGLKBXCKOQLUOAOXMKUCIMNYVITJYFQPYCAISGUXPPXJJXBWRHCUQSBOXFMZDHUOMIRODDJVQIINHHSDKLDZLZOAOQXVJGCIYWVFLNLRQYLKSDZJVQNNRILUZISWYYKYGESNBPIWDRQKAFVZMUJZKJAC...
output:
2238903359576856
result:
ok "2238903359576856"
Test #31:
score: 0
Accepted
time: 280ms
memory: 101200kb
input:
1 YBBQHUMUHPCOXASQLWBRXUPEORMGCOFIVNDFSNGFJRWRYPACZSVJGKMMLJRUVOVXDVPAFCFXOAXMDGNPCXLZCHGBFCVYYOBEEOIFSNGFRINXEXUGSWOIZUJFFBVOEXPRSOIONPWYRQDKAHUKOVUJKXZCSLVIBWISZLDMXXICKVSEUALMNDLHNHMFBGXSSXJPBEPRBLJXBUIUGEZGUEHNEQAMENIDVJJYHZCPRFUKLRYFGPVYRDIQSEKKEZFZGQUFPSHQLZFMQVQXOMHDRXFMFOFVLWBMNJPIAFYWMFSQDQ...
output:
42737103431
result:
ok "42737103431"
Test #32:
score: 0
Accepted
time: 101ms
memory: 50320kb
input:
1000000 MJIRPODODXHXEGOQKDVQXFKONESHJFWAKFOURAPYCPHRCLUDISEFAOAWWMINVAMUFUWJEWCWYZJDPAVQJPULSSKPNLFHXLNXCYDYCJAYBIHSEHVCWBFXPFQVVRDGMCLPQQSRXDMEOGXPYNXHFIXDVXZRCYOEHUVSEIURMHSPILBWKCZFEYVGZGJAPUMIJIUGQJHESQMLXYKPHHQNGYMVOLJUGLLIWBNPYJMKVLUSLNFWAHFMENNLIDDELSWTKPWRSDXQDSDPAPQSWQLKXODALELSLZSELOQLXKEW...
output:
3392859102435868
result:
ok "3392859102435868"
Test #33:
score: 0
Accepted
time: 100ms
memory: 49564kb
input:
350208 TLTHTUTTTIECTJTTTTNTTTTDTZTHJXSZTVTTTATTJHTKTVDTTXTTTTTTBATTTTTTXTTKTTTTKTTDTTTTNTLYXTTTTTTTFJTTVTTTCTOTZNWKTRPTKTEKETTTTVRTVWCUTTTKDZWVPVMMTTTISJTTTQTTTETTTTTMTTTTRTTITTTLTTMVTTMTTKQTTTWTTTBTWTIGTCTZTTTTTTNVTYUTTTTTTIOVTTHITTSTNZTTTOTTRHTTTTDHTTTUVPWTTTTTUTTTHMLFWNTQTTTFHTPTTRFITNDFTJNCKESTI...
output:
1248723
result:
ok "1248723"
Test #34:
score: 0
Accepted
time: 262ms
memory: 97704kb
input:
343585 TRTTTTTRTETTTTQTTTTAOTTTTWTTSTHTXSTLTTSITTTDTTTHTGTTTTTTTTTBTTTTTTCTVTTTTNTTTZTTTTTNTTTUTZTMTVJTTFTDTTTTTTTYLTTTTNXTTTETMTTTTTOTTTTTTTTBTPTTTTXVWTTLTITINTTTTTZTTTATTTPUTTTTTTTOTTTTTTTTTSHTLTTTTTTTTTTTTTTTTTPXTTTTYFTTAYTPZETTTFTHTAOTTTTTTTTTTTRTTOTTTTTKTTTTTTTTATTTTXTTSTTTTTTTTTTOTTTRTTTTTLTTL...
output:
1468088
result:
ok "1468088"
Test #35:
score: 0
Accepted
time: 102ms
memory: 55076kb
input:
1 TTTTTTTTTTTTTTTTTTTTTTTTTTTQTTTTSTTTTTTOTTTTTTTTTTTTTTUTTITBTTTTTTTSTTTTTTGTTTTTTQTTTTTTTTTTTTTTTTITTTTTTTTTTTTTTRTTTTTTTTTTTFTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTMTTTTTTTTTTTMTTYTTTTTSTETTTTTTTTTSTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTETTTKTTTTTTTTTTTTSTTTTTTTOTTTTTTTT...
output:
1
result:
ok "1"
Test #36:
score: 0
Accepted
time: 103ms
memory: 54796kb
input:
1000000 IHTTXXQVDVKETTPPWTTLLTYATTBCETCLTSEIXTTGTTJTTXBTXTTVTTTTIFYTASPDBTWVHTMVBTLTHTTQWTTTZAIATTDTTTTHGJTSTEZVTYPTTXTTTOLWTEFTEIHUATPTTQWTBVYTTCTVXZTDZTTTZZTMULPUSATTTITTEWFXTZNPTETDTLTUTNTDCTPLITDTYMWCTJTHZTTFTHJNATMBSDJTQTZTYDWFTTQAJTOKTTQKTTCUVTTAVXXUTRTULOTTTUUUZMRMITTTXHTTGTTTOBUTKTMTBPHTTTTT...
output:
4223102
result:
ok "4223102"
Test #37:
score: 0
Accepted
time: 109ms
memory: 50564kb
input:
345046 YHNYBBTUCRWJTYITEQDYYTEHAGBWBETO KT JNFETZVTCUHLGMPNGVMWZZFIXNFGUVSSEBSKMZUJSCFVCDTWPCPBPSPYTKLDOAOLRJJLESLGLOVQLDJMHYSQACKIMABZVTMLCPCAQEXDTJFBLNYCNJWJDDSAXEEICBXVYQGYBPXVNFCHIIXKUMMQXOEMNDYBGNGEJJCQIHHLYFUIZNJHUGSRKVXFRRTEYTCLVWTOSBNFBLZPSSPUFGMMLVYTADJGUGJYGKQCHOCNIZCPDNFLFVNBAHTGJAFKGPJLL...
output:
3140057680
result:
ok "3140057680"
Test #38:
score: 0
Accepted
time: 39ms
memory: 27856kb
input:
990105 T T FTBLKZUGHSNFTKEUEFRULGLILYCTYPKXZJGPQTUUYNZEOVXWTHZDKUMINCMNMZVQDLVVFLKBBFAWUQRFJLHKBRZFNKDOBNVKWQEKCBFXCUJGEGTUPKJHGQEDFEVXTNVUTJEMIIYWJMHVXDABJPUAXZLHXFRMKFMOFUPKTNELPOGHIABOSMCKQPQHEWKCKGGXTAXMAGXSCKXBMHSVMORIDRLLXWCUCYTUIROUNUNBIDNAXBQSDYWNVTYKRPWEJDWJRIIACNIUPXJUKAMPAVULCAKXGVEAXYTDT...
output:
866652802
result:
ok "866652802"
Test #39:
score: 0
Accepted
time: 104ms
memory: 48924kb
input:
749386 DUGGXTKUUHOZRLDPEVBNGEZUQPUDQFGHYQNMPMJRMPSFVFLECMGXNFDPQZIQCIUDUBNVIRAMTDMDDQRMJZEMKVEDQWTJIUUQOMHGEQETZUWIIOXPRUMAYLEGQDNRATLWXLYSYWMNOCBPITAKFYBMXDPOSHNZIEOWXCWDUNBSPNVONUBUPANOITVOIRJNEXUIWWLJJNJAMIMHLFMVHISWXDXNAYGTTKXRNEYTLKBKDULTHDBMSLTRHTAYRCGCCTPZEYHLYEWOFNQXOOIOGSHANWZGGEZJPVNJDFJVS...
output:
5798101706
result:
ok "5798101706"
Test #40:
score: 0
Accepted
time: 45ms
memory: 27268kb
input:
866202 UXTLRNTHESMXDHIJJQMRBZTFUVPADFGJWOEYLEDDHYCBJXXCHWTUWBDSKUDMFBHOQEFTPECMBFTSJKAPNTJLWSJCTHDKPLEKAZGZBXFZBNURENZXPJDSGMCTLAJNWKPZRWNDNJUAEOBZLYWFUSDCEVVADQZMVZVMFWNBBMSGOTDHGVOPBFLEYIQEKHOMADATVMIKFJUSNUCMZKFTTLQDNGCFNXYVMHEEFQUVPCCGKPXBXDPUVHWPYVGMOBAQDANKOWKTDATEPPINMNRQLRWPIJPHMJEMRINZZDDQI...
output:
23920713675
result:
ok "23920713675"
Test #41:
score: 0
Accepted
time: 0ms
memory: 6696kb
input:
610175 LMSBGVAMNSLAUVFWKDZOQFMBUDYXLKPRYOKNBWNPNNGNOMHAJZKXKIURGJQYZFOAKUAAMOENJFADLHXRLAXCXZEMUFRJAFDOGNIYZIQLPFKJGRJZUHSWECQRVACLYXDBRZAJRANHCFCRWPXRVNJSYCXBBMSXFSIRSBNBVGNAQCPQNLZMUIHYKJYWCDHHKANZUXWWCAVPSVSLEJSCCUAUEORRMADXIAIXUSLEUQRUDGHXIPDVPEZRADAXXVENMHGSOXPKKZGKNNCVSKGCKSZLZWVJIHMLAZXFVRUQH...
output:
-1
result:
ok "-1"
Test #42:
score: 0
Accepted
time: 105ms
memory: 53524kb
input:
756402 XSCBCBAPCCEYMGHJSUVDLMSSKUWBEQWFBWGEORUIKDAEKLGMAZRZJSARWQJNJGADAUVAJCMJJLHUWUCRDXSLBIGARBXRBONWZYPFXLNLUCLIIJMWVLAVXPBSJHCBXAPHGGIQDSGKOXJCALHCALARIKDNYPSHCKIESGSMULRBRJSAMFPOYVZOPNAYPCGBHVVWDDMNOUXWAFDVXORXMAYPYZAYUCDFLGKJERDJZZZDAVBDQPBOXEWUBNECAPJJXWKHHRIQVQRJVQOPJDAUYLNLPZDMYKRFGFLIMGYNO...
output:
-1
result:
ok "-1"
Test #43:
score: 0
Accepted
time: 248ms
memory: 94580kb
input:
919744 USJEGOJVYQVJIGPJCGEIMWJIPVBISYGBFEQXUFEIICJUNOLOKGNFJODMSRFRRKJXLJWQBPFFVJIHAWXZEWUJDXUHYEJHODCQFHUHZGIRKBJDPHDZARJZZZXULFVUJCWAKDEHWQIZDGKXEWIOIXXDRSAYJPVFVEDSFDVGHNWYRFLWHBWDDYBCRYDWWWQGCPOXLCQEUYXGNLOMXWPYQAZCMFGDZYZNKUKGWCMPDGZKQDQPNBOLRDPQUWMFOCNRRLXUDESUCDHQSPLXCGXHRXVFWQCPCLXDPJDIXQASG...
output:
-1
result:
ok "-1"
Test #44:
score: 0
Accepted
time: 44ms
memory: 25924kb
input:
178094 HZWHPASQGCMRKYNSKGRXRJSSNSOLLIGZEENWSGMGLOTSKUELOFMOEHRAOSOOMPTEYRNLCOKTZGMOORBSCTKEPBRSMMVCSIYDCLHYRNRBMNIZWAPEBXANQGFDCIUWYXXMSOTGLBYBUWPOZJMSRSBVYMUKJECRZOZPSILNUOTXNISNQYCGQVYIEHNLLLKLEWONDQLRTGQNTFIPEJNYTKFCOZNCCQBGXTABPJWFJGGUUFRJKDMUBXQWWIMOZMNMMURSTVIKZFNSTJFUJVUVGJVOWCZDNJQQIDCDZXFOY...
output:
101851007373
result:
ok "101851007373"
Test #45:
score: 0
Accepted
time: 23ms
memory: 16276kb
input:
39543 AQPXLJNTTQLCKBXEYORIHKWPLZLRDSIOGTQLDQRLOZKCNFOAJSVRSWQZRJPKLJPUNGYTUWNRXBMDONTILKYKYLGNKGBFTTOKQWYDDULORMCAEEIDPJLBHKHLULTTRQLOPONMWUFZWSRFHHHNVKUVMRNALCTKSJUPC SLUDMGAUPMFSUYJLEATOTPVLJIRRVFXXUVPKYUINMHEUXHLHCSAAFCJUSMPLUOABQUCZPUIDIDDSCDDOGALBXTVHZONATVYSYOIQWAIZFGPBLCBUAMAXTRQQGGMJAGETSVBM...
output:
10428475413
result:
ok "10428475413"
Test #46:
score: 0
Accepted
time: 43ms
memory: 25668kb
input:
513749 FTFAAVVEXZFCJHJLRTXHZBMFWRZZJFGCAFKJCRLJGXNCGNWTHEIMSNFDNREGTRKBYPBQFOGHIIXXQHALXTQFKQUVQJDUSNQFEUENDGMMHKTRFHQTYCAOWJWVNCVYIBKHXMAGDXXIOARCQZZFMRKPRYYPOVFSPCRCBNEPIVSFLMCRAFFXTAVBLQDFXWCFIFSMPOHRZPVAWZFXKSMQNXDIDCVBKKATUEJFUIENPGRCLJMBUJADEUAYAZPACDTKUUMUKMXKEAKJMFDBQWMKZSDEPZIPWRKKOJQONPKCZ...
output:
297904535175
result:
ok "297904535175"
Test #47:
score: 0
Accepted
time: 43ms
memory: 26008kb
input:
323568 HPCBEXJKHBICZDFYOPUZNIQSKEYEYGWNWNOUBKXZMPPYMIGWASAESQDCQELHRDQZHDNVBJVAOPSRCBQIYPLSQJXMFZXSYESFHXPXIABQLIKDZZKTFXEOIFWLJXHPKXUJGGUQLMRAOBQDQRKHQFMOUAVFBCIDFHCMRREKMXDJRYBFJNDDQCZAJRLVMZFEMFVYKOSIWAXUHSKEHKONJGSOUBLAAEAMBOGYVIDHBTPDPGJKWMBNNOEUCPWLEBHSHLISZMLSNKQQPIMJKMWIGINMCXBNJHWIJKFQAJPYQ...
output:
195139073323688
result:
ok "195139073323688"
Test #48:
score: 0
Accepted
time: 19ms
memory: 16140kb
input:
999097 JMLDZBUFHJCMCBZYSICXVXSAMWHRXBKGLRINYIVJFMREUNGWXGJHXJCRIBDPCCYBPSNUAGERMXJHRVPLHVGFGBZBXEDZZXYVXNQRLDNOLJMHALPKLOWTZVTYVDAVSJXGDAQNSGHHMNEAXBKBVCVUMAPUUJKLUQIYVMIZDGOCWOAFXNRQNSJNCHLHMJGBQBFCQMHFNKUABXPNEINEZMWCG XKZOCCLIDPCRBKZUZVWNYHEKNEOUEJMSRFYCLLKPBPSSCXXZIXQQQOGYVDYXJOGPPIROKXONZLBKUJR...
output:
-1
result:
ok "-1"
Test #49:
score: 0
Accepted
time: 100ms
memory: 49648kb
input:
655651 CIXDKABYGNOFBFJPZMQHEVRRUGCIVXAADZKVXLGXRKWSOKESCXMGJYRHAVKRHGNWRQIUWRHHQMYKULBFOEVUDSIGGNVABJFXWQOTDUSRDEYQZOHNPKJEZCIOJIBLSYKOXCSYRBPNKWZZBIRZLRBVKJXFXQUQRPCQKGMOKOBTYYQWKJILUCZQLIYLLWDOLRZEQUEDYHQLXSXCBWRFMZHPUWPRMSHIROBBEVXRSFCWOUULSZWRGHJKSKWMIISEIGYMXQHKKBCKGIVWJOHWQPVUFGNJQUYJXHCKYSYCW...
output:
2634424714338390
result:
ok "2634424714338390"
Test #50:
score: 0
Accepted
time: 2ms
memory: 4600kb
input:
622657 BOEINRYGECRHNYPWZVYUZBIHUFQESGGOBLRUGOIDJEJZFSANFJRXLCKZPVBJCARZEZBXVEFSBPIJSJWXEMWDXOXPPHDLVQKKJDDKCSKNNHFASMSBOHOMABBBNZKSYIASGIUEWLMLVOXDFOFSIVOGWFYFMDEXJANBURYSWVBXZHRIYQLVPDMNKJQKNJRXCSMSOOIXELGDLKHSPVVLDHJIZKYAQRXHVJBDUNBUCIPPBSXXZLIVJRLSIPFGRYJOSEXQJIAYWAAJDPQISAVYBZFKAPWJFBGJXVQVVIMSW...
output:
-1
result:
ok "-1"
Test #51:
score: 0
Accepted
time: 1ms
memory: 4460kb
input:
1000000 TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT TTTTTTTTTTTTTTTTTTTTTTTTTTT PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
output:
1000000
result:
ok "1000000"
Test #52:
score: 0
Accepted
time: 1ms
memory: 4332kb
input:
1000000 GTTTQTTTNTTTXTTTQTTTLTTTZTTTBTTTKTTTBTTTDTTT TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT PERYPSRBPGFUPTIAPBWNPVLLPJCYPGTHPSHL CCCCCCCCCCCCCCCCCCCCCCCCCCCC
output:
-1
result:
ok "-1"
Test #53:
score: 0
Accepted
time: 0ms
memory: 4308kb
input:
929626 TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT ATILTXVTOBTSXTNVTHUTUSTCWTBGTKSTWMTOJTVPTS PWPPAPPKPPQPPVP CCCCCCCCCCCCCCCCCCCCCCCCCCC
output:
-1
result:
ok "-1"
Test #54:
score: 0
Accepted
time: 1ms
memory: 4400kb
input:
1000000 TTTTTTTTTTTTTTTTTTTT MTTMOTTULTTOITTWJTTAOTTGMTTBXTTB PFUPPKTPPOWPPLZPPNOPPKGPPLIPPGBPPQGP CCCCCCCCCCCCCCCCCCCCCCCCCCCC
output:
-1
result:
ok "-1"
Test #55:
score: 0
Accepted
time: 1ms
memory: 4296kb
input:
5633 TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT TULTWITPZTXJTXQTGFTPDTHVTKB XPPIPPTPPVPPOPPIPPAPPLPPPPPTPPWPPMPPEPPKPPHPP CCCCCCCCCCCCCCCCCCCCC
output:
253465
result:
ok "253465"
Test #56:
score: 0
Accepted
time: 1ms
memory: 4308kb
input:
1000000 TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT TQYFTPAZTCWHTSHRTWKVTTBCTVTJTNVU PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP BCCCXCCCXCCCWCCCPCCC
output:
15999995
result:
ok "15999995"
Test #57:
score: 0
Accepted
time: 1ms
memory: 4416kb
input:
1000000 ZBXHCHSZMLVPLQGGTJDROEZBFDEQ DKDOKMUWXYLODPABTHGCFRYICACVVDMICSOHBUBPHUWOI CIBJMYEHQHLLWFYSPJJCGTDAYNNWUAISUYUZEDOGRCD ANOJKQAXPJTNDGSHCQSDSAFBXWDDKRVHEQROPZKZS
output:
2221377778637
result:
ok "2221377778637"
Test #58:
score: 0
Accepted
time: 1ms
memory: 4544kb
input:
1000000 WZENZHGEFMTHAZKSMODUCBNFDDWZCYVRYRQCEWBIV BQADDGNHJDJIPZMHCDWLAJDEJXIJIQUTSNEUONNQIMOCRLSQXB HDQYBJLRQMANSCKNMCORGLIGPVBZQWQ JKZFCDARHAZWYQOWY
output:
1080349150532
result:
ok "1080349150532"
Test #59:
score: 0
Accepted
time: 1ms
memory: 4456kb
input:
999931 YZQXHYLTFOIYQBFESGUABSXJOLACYNAUGFXJIBICE DPFLCUGQPDVZVGXRBKSHIDMFGEAAAPTCEBZJIZJQJXQEPLZXFU QYWWBQIDQDAXCGSBJNPBVOQTWMTVVIZZTZZNOLBNUVDGDBHAL SEAMROELTNSNJHCSUONPLHIWTILGSKZZSKZEBVS
output:
3917276603931
result:
ok "3917276603931"
Test #60:
score: 0
Accepted
time: 1ms
memory: 4492kb
input:
1000000 BIHBPVPHYTWZXITHWCEXISNZDNTCZEBTNHZFWIOAEPZCOBUNWL OLIBUOONULIOXSTJTQGSUQDIQEJFOTOTIDKIWZRAP ENGELUGMJLBACDRYPHEKPPVPXQIURFGOYOMUOVEKYLQUIMWF APRFKDFOUVYYOAAMCTYWCHFITGVIMCCEQUZDPJR
output:
13324982182
result:
ok "13324982182"
Test #61:
score: 0
Accepted
time: 0ms
memory: 4420kb
input:
757219 SWEXJTINTTWDVHGIRGRWKBXJLSEHPLHTHTDUDSR KEHMUTHUGBTTACTTG EEYLFRCHPVUCUPTNKCEIYJWCKRCFLJDPPBPXTIJI AIETPYGASHCOOXKHCCRPXCJFKDFIYXC
output:
996058294
result:
ok "996058294"
Test #62:
score: 0
Accepted
time: 0ms
memory: 4324kb
input:
629201 TT VTTTT PUTLPFRQRP C
output:
3146005
result:
ok "3146005"
Test #63:
score: 0
Accepted
time: 1ms
memory: 4232kb
input:
147204 T TTTTTTTTT PGFQGLP ZKLCQ
output:
2576064
result:
ok "2576064"
Test #64:
score: 0
Accepted
time: 1ms
memory: 4324kb
input:
805507 TTTTDCVT TTT PPPPPJNPP CZCPVKPCB
output:
3866419
result:
ok "3866419"
Test #65:
score: 0
Accepted
time: 1ms
memory: 4448kb
input:
524954 TPBTKTTGTZTYPTJTTZOTTSFGLTTLKTTTTTTTTTOJ TTTTTTTTTTTTTTVTTTTTTTTTLTPTTTTTTTTTTTTTTTBTTTTTT PAPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP ZDOCSCCBCLWUCJCFCEMCANCKCCCSUCC
output:
2352475
result:
ok "2352475"
Test #66:
score: 0
Accepted
time: 1ms
memory: 4472kb
input:
127002 NCBTQETTQTLTTTTXT TTTTTTTTTTTTTTTTTTTTTTT PPGPPPPPPPPPPPPPPPPPPPPPGPPPP GICCBDGADCCTCCJXNCMMCJFCCGLRJXCZCZANYCCFSAXPWEFGC
output:
841691
result:
ok "841691"
Test #67:
score: 0
Accepted
time: 0ms
memory: 4416kb
input:
1000000 KTTFJIMTODIDGTDJDTPTKMDTTIPBUTTGWGSPRXNJUKT TTTTTUSTTTWTTTBTTTMCTTCTTTTVGDJTTWTYTTTTTTFPTT PSPPGWPPSPNAQPYPFUPPPEPPPPPXPRPXJPYPHPU ECCCACLCZCCCCWCAXCYUCGCAHVYJSFCMD
output:
26472458
result:
ok "26472458"
Test #68:
score: 0
Accepted
time: 1ms
memory: 4300kb
input:
936720 TTCTOGTB TTSVEZEWXWTQYRTOTNAZGZLNNOCXTHTTMQN BHOIRHPUNP OQGMCHXRC
output:
147533297
result:
ok "147533297"
Test #69:
score: 0
Accepted
time: 1ms
memory: 4192kb
input:
1000000 TTTDYJTTT FIZTUUTTTTTTVITTDNTTHOITXTTYTFTKTFTDTBHXTK PLPPPPPPPPPPVPPPPZPPP J
output:
-1
result:
ok "-1"
Extra Test:
score: 0
Extra Test Passed