Contest Duration: - (local time) (100 minutes) Back to Home

Submission #836893

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;
}
}
//st[u].insert(mk(cur, u));
for(int j = 0; j < 26; ++j) {
if (j != u) st[j].insert(mk(i - 1 - 2 * sum[i], i - 1));
else st[j].insert(mk(i - 1 - 2 * (sum[i] - 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 2016-08-13 21:24:22+0900 D - Unbalanced creatnx C++14 (GCC 5.4.1) 0 2439 Byte WA 10 ms 512 KB

#### Judge Result

Set Name Sample Sub1 Sub2
Score / Max Score 0 / 0 0 / 200 0 / 200
Status
 AC × 2
 AC × 5 WA × 9
 AC × 5 WA × 19
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 WA 4 ms 256 KB
1_06 WA 4 ms 256 KB
1_07 WA 4 ms 256 KB
1_08 AC 4 ms 256 KB
1_09 WA 4 ms 256 KB
1_10 WA 4 ms 256 KB
1_11 WA 4 ms 256 KB
1_12 WA 4 ms 256 KB
1_13 WA 4 ms 256 KB
1_14 WA 4 ms 256 KB
2_15 WA 10 ms 512 KB
2_16 WA 10 ms 512 KB
2_17 WA 10 ms 512 KB
2_18 WA 9 ms 512 KB
2_19 WA 10 ms 512 KB
2_20 WA 10 ms 512 KB
2_21 WA 9 ms 512 KB
2_22 WA 9 ms 512 KB
2_23 WA 10 ms 512 KB
2_24 WA 10 ms 512 KB