Submission #836553


Source Code Expand

Copy
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <queue>

using namespace std;

#define pb push_back
#define pbk pop_back
#define fs first
#define sc second
#define sz(s) ((int) (s).size())
#define all(x) (x).begin(), (x).end()
#define mt make_tuple
#define mp make_pair
#define next hunext
#define prev huprev

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long double ld;

const int inf = 1e9;
const double pi = 4 * atan(1.0);
const double eps = 1e-9;
const int N = int(1e5) + 100;

char s[N];
vi pos[30];

int main() {
#ifdef LOCAL42
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    scanf("%s", s);
    int n = strlen(s);
    for (int i = 0; i < n; ++i) {
        pos[s[i] - 'a'].pb(i);
    }
    for (int i = 0; i < 26; ++i) {
        pii best(inf, -1);
        for (int j = 0; j < sz(pos[i]); ++j) {
            if (best.fs < 2 * j - pos[i][j] + 1) {
                cout << best.sc + 1 << " " << pos[i][j] + 1 << endl;
                return 0;
            }
            best = min(best, mp(2 * j - pos[i][j], pos[i][j]));
        }
    }
    cout << "-1 -1" << endl;
    return 0;
}

Submission Info

Submission Time
Task D - Unbalanced
User sankear
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1516 Byte
Status CE

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:51:21: error: ‘strlen’ was not declared in this scope
     int n = strlen(s);
                     ^
./Main.cpp:50:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s", s);
                   ^