Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include "bits/stdc++.h"
- using namespace std;
- typedef unsigned int ui;
- typedef long long ll;
- typedef unsigned long long ull;
- typedef long double ld;
- #define endl "\n"
- #define all(a) a.begin(), a.end()
- #define allr(a) a.rbegin(), a.rend()
- #define pb push_back
- #define F first
- #define S second
- struct ANS {
- ll type;
- ll pos;
- char sl;
- };
- ll cnt_of_num(ll num) {
- ll cnt = 0;
- while (num) {
- num /= 10;
- cnt++;
- }
- return cnt;
- }
- bool is_ten(ll dec) {
- ll i = 1;
- while (dec > i) i *= 10;
- if (dec == i)return true;
- return false;
- }
- bool is_ten_min(ll dec) {
- ll i = 1;
- while (dec > i)i *= 10;
- if (dec + 1 == i)return true;
- else return false;
- }
- char no_sim(char c) {
- if (c == 'A' || c == 'G' || c == 'C')return 'T';
- else return 'A';
- //a g c t
- }
- signed main() {
- #ifdef _DEBUG
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- ll t = 1;
- srand(time(NULL));
- string s;
- cin >> s;
- vector<pair<ll, pair<ll, char>>>sub;
- map<ll, ll> posit;
- ll now = 0;
- for (ll i = 0; i < (ll)s.size(); i++) {
- string num = "";
- while (s[i] >= '0' && s[i] <= '9')num += s[i++];
- if (i) {
- if (i >= 1) {
- if (s[i] >= 'A' && s[i] <= 'Z' && s[i - 1] >= '0' && s[i - 1] <= '9') {
- now += stoi(num);
- posit[sub.size()] = now;
- sub.push_back({ (ll)num.size(), { stoi(num),s[i] } });
- }
- if (s[i] >= 'A' && s[i] <= 'Z' && s[i - 1] >= 'A' && s[i - 1] <= 'Z') {
- now++;
- posit[sub.size()] = now;
- sub.push_back({ (ll)1, { (ll)1,s[i] } });
- }
- }
- }
- else if (s[i] >= 'A' && s[i] <= 'Z') {
- now++;
- posit[sub.size()] = now;
- sub.push_back({ (ll)1, { (ll)1,s[i] } });
- }
- }
- char last = '#';
- ANS mn_an, mn_an_jd;
- ll pos = 0;
- bool mn_just_del = false;
- ll plus_from_slianie_delete;
- ll pre_ans_mn = -1e18;
- bool mn = false, mx = false;
- if ((ll)sub.size() >= 3) {
- for (ll i = 0; i < (ll)sub.size(); i += 2) {
- if (sub[i].S.second == last && sub[i - 1].S.first == 1) {
- if (sub[i].first + sub[i - 2].first - cnt_of_num(sub[i].S.first + sub[i - 2].S.F) > pre_ans_mn) {
- pre_ans_mn = sub[i].first + sub[i - 2].first - cnt_of_num(sub[i].S.first + sub[i - 2].S.F);
- mn_an = { 2,posit[i - 1],'#' };
- mn = true;
- }
- }
- else if (i > 0 && sub[i - 1].F == 1) {
- mn_just_del = true;
- mn_an_jd = { 2,posit[i - 1] };
- }
- last = sub[i].S.second;
- }
- last = '#';
- if ((ll)sub.size() >= 4) {
- for (ll i = 1; i < (ll)sub.size(); i += 2) {
- if (sub[i].S.second == last && sub[i - 1].S.first == 1) {
- if (sub[i].first + sub[i - 2].first - cnt_of_num(sub[i].S.first + sub[i - 2].S.F) > pre_ans_mn) {
- pre_ans_mn = sub[i].first + sub[i - 2].first - cnt_of_num(sub[i].S.first + sub[i - 2].S.F);
- mn_an = { 2,posit[i - 1],'#' };
- mn = true;
- }
- }
- else if (sub[i - 1].F == 1) {
- mn_just_del = true;
- mn_an_jd = { 2,posit[i - 1] };
- }
- last = sub[i].S.second;
- }
- pre_ans_mn++;
- }
- }
- if (mn && pre_ans_mn > 0) {
- cout << 2 << ' ' << mn_an.pos << endl;
- }
- else if (mn_just_del) {
- cout << 2 << ' ' << mn_an_jd.pos << endl;
- }
- else {
- ll rem = -1;
- ll dec = 1;
- ll ans = 1;
- bool fublya = false;
- ll rem2 = 1;
- for (ll i = 0; i < (ll)sub.size(); i++) {
- if (is_ten(sub[i].second.first)) {
- fublya = true;
- if (is_ten(sub[i].second.first) >= dec) {
- dec = is_ten(sub[i].second.first);
- ans = posit[i];
- }
- }
- if (sub[i].second.first > 1) {
- rem = posit[i];
- }
- else {
- rem2 = posit[i];
- }
- }
- if (fublya) {
- cout << 2 << ' ' << ans << endl;
- }
- else if (rem != -1)
- cout << 2 << ' ' << rem << endl;
- else {
- cout << 2 << ' ' << rem2 << endl;
- }
- }
- //mx
- ANS mx_ans = { 1,posit[0],sub[0].second.second };
- bool tr = false;
- ll pre_ans = -1e18;
- for (ll i = 0; i < (ll)sub.size(); i++) {
- if (sub[i].S.first > 1) {
- ll f = 1;
- while (f < sub[i].second.first)f *= 10;
- f /= 10;
- ll fir = sub[i].second.first / f;
- fir *= f;
- ll sec = sub[i].second.first - fir;
- ll checker = 0;
- checker += fir == 1;
- checker += sec == 1;
- ll checker2 = 0;
- checker2 += sub[i].second.first / 2 == 1;
- checker2 += sub[i].second.first / 2 + sub[i].second.first % 2 == 1;
- if (fir == 0 || sec == 0 || cnt_of_num(fir) + cnt_of_num(sec) - checker < -checker2 + cnt_of_num(sub[i].second.first / 2) + cnt_of_num(sub[i].second.first / 2 + sub[i].second.first % 2)) {
- if (2 - checker2 + cnt_of_num(sub[i].second.first / 2) + cnt_of_num(sub[i].second.first / 2 + sub[i].second.first % 2) - sub[i].first > pre_ans) {
- pre_ans = 2 - checker2 + cnt_of_num(sub[i].second.first / 2) + cnt_of_num(sub[i].second.first / 2 + sub[i].second.first % 2) - sub[i].first;
- tr = true;
- mx_ans = { 1,posit[i] - (sub[i].second.first) / 2,no_sim(sub[i].second.second) };
- last = sub[i].S.first;
- }
- }
- else {
- if (cnt_of_num(fir) + cnt_of_num(sec) - sub[i].first > pre_ans) {
- pre_ans = 2 + cnt_of_num(fir) + cnt_of_num(sec) - sub[i].first - checker;
- tr = true;
- mx_ans = { 1,posit[i] - sec,no_sim(sub[i].second.second) };
- }
- }
- }
- }
- pair<ll, pair<ll, char>> anss = { (ll)1,{mx_ans.pos, mx_ans.sl} };
- for (ll i = 0; i < sub.size(); i++) {
- if (is_ten_min(sub[i].second.first) && pre_ans < 1) {
- anss.second.first = posit[i];
- anss.second.second = sub[i].second.second;
- }
- }
- cout << anss.F << ' ' << anss.S.F << ' ' << anss.S.S << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement