Submission #836152


Source Code Expand

Copy
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
char s[SIZE];
int main(){
    RS(s+1);
    int n=LEN(s+1);
    REPP(c,'a','z'+1){
        int now=0;
        int mi=MOD,id;
        REPP(i,1,n+1){
            if(s[i]==c){
                if(now<mi){
                    mi=now;
                    id=i;
                }
                now++;
                if(mi<now&&id!=i){
                    printf("%d %d\n",id,i);
                    return 0;
                }
            }
            else now--;
        }
    }
    return 0*puts("-1 -1");
}

Submission Info

Submission Time
Task D - Unbalanced
User dreamoon
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1599 Byte
Status AC
Exec Time 10 ms
Memory 384 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:32:12: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     RS(s+1);
            ^

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 8 ms 384 KB
2_16 AC 8 ms 384 KB
2_17 AC 8 ms 384 KB
2_18 AC 10 ms 384 KB
2_19 AC 7 ms 384 KB
2_20 AC 7 ms 384 KB
2_21 AC 5 ms 384 KB
2_22 AC 7 ms 384 KB
2_23 AC 8 ms 384 KB
2_24 AC 9 ms 384 KB