Submission #60043871


Source Code Expand

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <atcoder/all>
using namespace std;

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, l, r) for (int i = l; i <= r; i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<VI>;
using VVL = vector<VL>;

ll op(ll a, ll b) { return a + b; }
ll e() { return 0; }

int calc(int n, string s)
{
    int ans = 0;
    REP(i,n){
        if (s[i] != '/') continue;
        int x = 1;
        while (i - x >= 0 && i + x < n && s[i - x] == '1' && s[i + x] == '2'){
            x++;
        }
        chmax(ans, x - 1);
    }
    return 2 * ans + 1;
}

int main()
{
    int n;
    string s;
    cin >> n >> s;
    cout << calc(n, s) << endl;
}

Submission Info

Submission Time
Task C - 11/22 Substring
User TangentDay
Language C++ 20 (gcc 12.2)
Score 300
Code Size 890 Byte
Status AC
Exec Time 4 ms
Memory 3952 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 25
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 02_corner_00.txt, 02_corner_01.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3484 KiB
00_sample_01.txt AC 1 ms 3600 KiB
00_sample_02.txt AC 1 ms 3568 KiB
01_random_00.txt AC 4 ms 3852 KiB
01_random_01.txt AC 4 ms 3884 KiB
01_random_02.txt AC 4 ms 3852 KiB
01_random_03.txt AC 4 ms 3796 KiB
01_random_04.txt AC 4 ms 3832 KiB
01_random_05.txt AC 4 ms 3816 KiB
01_random_06.txt AC 4 ms 3952 KiB
01_random_07.txt AC 4 ms 3712 KiB
01_random_08.txt AC 4 ms 3808 KiB
01_random_09.txt AC 4 ms 3868 KiB
01_random_10.txt AC 4 ms 3804 KiB
01_random_11.txt AC 4 ms 3816 KiB
01_random_12.txt AC 4 ms 3856 KiB
01_random_13.txt AC 4 ms 3860 KiB
01_random_14.txt AC 4 ms 3860 KiB
01_random_15.txt AC 4 ms 3804 KiB
01_random_16.txt AC 3 ms 3788 KiB
01_random_17.txt AC 3 ms 3788 KiB
01_random_18.txt AC 4 ms 3744 KiB
01_random_19.txt AC 4 ms 3836 KiB
02_corner_00.txt AC 3 ms 3852 KiB
02_corner_01.txt AC 1 ms 3680 KiB