Submission #837084


Source Code Expand

Copy
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <deque>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>
#include <complex>
#include <cstring>
#include <iomanip>
#include <bitset>

using namespace std;
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define repd(i, a, b) for(int i = (a); i > (b); i--)
#define forIt(it, a) for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define forRev(it, a) for(__typeof((a).rbegin()) it = (a).rbegin(); it != (a).rend(); it++)
#define ft(a) __typeof((a).begin())
#define ll long long
#define ld long double
#define fi first
#define se second
#define mk make_pair
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define bitcount(n) __builtin_popcountll(n)


typedef complex<ld> cplex;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef pair<ll, ll> pll;

const int N = 1000 + 7;
const int M = 30;
const int inf = 1e9 + 7;
const long long linf = (ll) inf * inf + 7;
const double pi = acos(-1);
const double eps = 1e-20;
const bool multipleTest = false;

set<ii> st[26];
string s;

int sum[26];


void solve() {
    cin >> s;
    
    
    int n = sz(s);
    
    for(int i = 1; i <= n; ++i) {
        int u = s[i - 1] - 'a';
        sum[u] ++;
        if (i > 1) {
            int cur = i - 2 * sum[u];
            typeof(st[u].begin()) it = st[u].upper_bound(mk(cur, n + 1));
            if (it != st[u].end() && i - it->second > 1) {
                cout << it->second + 1 << " " << i;
                return;
            }
        }
        for(int j = 0; j < 26; ++j) {
            if (j != u) st[j].insert(mk(i - 1 - 2 * sum[j], i - 1));
            else st[j].insert(mk(i - 1 - 2 * (sum[j] - 1), i - 1));
        }
    }
    
    cout << "-1 -1";
    
}

int main() {
//#ifndef ONLINE_JUDGE
//    freopen("in.txt", "r", stdin);
//    auto t1 = clock();
//#endif
//
    
    int Test = 1;
    if (multipleTest) {
        cin >> Test;
    }
    
    for(int i = 0; i < Test; ++i) {
        solve();
    }
    
//#ifndef ONLINE_JUDGE
//    printf("\n%.9lf\n", (0.0 + clock() - t1) / CLOCKS_PER_SEC);
//#endif
}

Submission Info

Submission Time
Task D - Unbalanced
User creatnx
Language C++14 (GCC 5.4.1)
Score 400
Code Size 2396 Byte
Status AC
Exec Time 1405 ms
Memory 122240 KB

Judge Result

Set Name Sample Sub1 Sub2
Score / Max Score 0 / 0 200 / 200 200 / 200
Status
AC × 2
AC × 14
AC × 24
Set Name Test Cases
Sample 0_01, 0_02
Sub1 0_01, 0_02, 1_03, 1_04, 1_05, 1_06, 1_07, 1_08, 1_09, 1_10, 1_11, 1_12, 1_13, 1_14
Sub2 0_01, 0_02, 1_03, 1_04, 1_05, 1_06, 1_07, 1_08, 1_09, 1_10, 1_11, 1_12, 1_13, 1_14, 2_15, 2_16, 2_17, 2_18, 2_19, 2_20, 2_21, 2_22, 2_23, 2_24
Case Name Status Exec Time Memory
0_01 AC 4 ms 256 KB
0_02 AC 4 ms 256 KB
1_03 AC 4 ms 256 KB
1_04 AC 4 ms 256 KB
1_05 AC 4 ms 256 KB
1_06 AC 4 ms 384 KB
1_07 AC 4 ms 256 KB
1_08 AC 4 ms 256 KB
1_09 AC 4 ms 256 KB
1_10 AC 4 ms 256 KB
1_11 AC 4 ms 256 KB
1_12 AC 4 ms 384 KB
1_13 AC 4 ms 384 KB
1_14 AC 4 ms 384 KB
2_15 AC 504 ms 48000 KB
2_16 AC 1035 ms 91776 KB
2_17 AC 1051 ms 89344 KB
2_18 AC 1050 ms 91648 KB
2_19 AC 99 ms 11392 KB
2_20 AC 387 ms 38272 KB
2_21 AC 10 ms 512 KB
2_22 AC 1382 ms 122240 KB
2_23 AC 1401 ms 122240 KB
2_24 AC 1405 ms 122240 KB