Submission #836577


Source Code Expand

Copy
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstring>
#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 400
Code Size 1536 Byte
Status AC
Exec Time 8 ms
Memory 1024 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:51:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s", s);
                   ^

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 256 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 256 KB
1_13 AC 4 ms 256 KB
1_14 AC 4 ms 256 KB
2_15 AC 6 ms 768 KB
2_16 AC 6 ms 768 KB
2_17 AC 7 ms 768 KB
2_18 AC 6 ms 768 KB
2_19 AC 7 ms 768 KB
2_20 AC 6 ms 768 KB
2_21 AC 6 ms 768 KB
2_22 AC 7 ms 1024 KB
2_23 AC 8 ms 1024 KB
2_24 AC 7 ms 768 KB