提出 #40869759


ソースコード 拡げる

#include <iostream>
#include <string>

using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;

    int ans = -1;
    for (int l = 1; l < n; l++) {
        bool ok = true;
        for (int i = 0; i + l < n; i++) {
            if (s[i] == 'o' && s[i + l] == '-') {
                for (int j = i + 1; j < i + l; j++) {
                    if (s[j] != 'o') {
                        ok = false;
                        break;
                    }
                }
                if (ok) {
                  ans = l;
                  break;
                }
                else ok = true; 
            }
            else if (s[i] == '-' && s[i + l] == 'o') {
                for (int j = i + 1; j < i + l; j++) {
                    if (s[j] != 'o') {
                        ok = false;
                        break;
                    }
                }
                if (ok){
                  ans = l;
                  break;
                }
                else ok = true;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

提出情報

提出日時
問題 C - Dango
ユーザ KondoRyohei
言語 C++ (GCC 9.2.1)
得点 0
コード長 1132 Byte
結果 TLE
実行時間 2205 ms
メモリ 3680 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 0 / 300
結果
AC × 3
AC × 11
TLE × 18
セット名 テストケース
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_small_03.txt, 01_small_04.txt, 01_small_05.txt, 01_small_06.txt, 01_small_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 02_random_11.txt, 02_random_12.txt, 02_random_13.txt, 02_random_14.txt, 02_random_15.txt, 02_random_16.txt, 03_handmade_17.txt, 03_handmade_18.txt, 03_handmade_19.txt, 03_handmade_20.txt, 03_handmade_21.txt, 03_handmade_22.txt, 03_handmade_23.txt, 03_handmade_24.txt, 03_handmade_25.txt, 03_handmade_26.txt, 03_handmade_27.txt, 03_handmade_28.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 15 ms 3480 KiB
00_sample_01.txt AC 1 ms 3396 KiB
00_sample_02.txt AC 2 ms 3504 KiB
01_small_03.txt AC 2 ms 3380 KiB
01_small_04.txt AC 2 ms 3364 KiB
01_small_05.txt AC 2 ms 3540 KiB
01_small_06.txt AC 2 ms 3484 KiB
01_small_07.txt AC 2 ms 3540 KiB
02_random_08.txt TLE 2205 ms 3584 KiB
02_random_09.txt TLE 2205 ms 3612 KiB
02_random_10.txt TLE 2205 ms 3680 KiB
02_random_11.txt TLE 2205 ms 3464 KiB
02_random_12.txt TLE 2205 ms 3372 KiB
02_random_13.txt TLE 2205 ms 3388 KiB
02_random_14.txt AC 298 ms 3472 KiB
02_random_15.txt TLE 2205 ms 3440 KiB
02_random_16.txt TLE 2205 ms 3456 KiB
03_handmade_17.txt TLE 2205 ms 3460 KiB
03_handmade_18.txt AC 211 ms 3588 KiB
03_handmade_19.txt AC 426 ms 3648 KiB
03_handmade_20.txt TLE 2205 ms 3568 KiB
03_handmade_21.txt TLE 2205 ms 3500 KiB
03_handmade_22.txt TLE 2205 ms 3584 KiB
03_handmade_23.txt TLE 2205 ms 3532 KiB
03_handmade_24.txt TLE 2205 ms 3680 KiB
03_handmade_25.txt TLE 2205 ms 3552 KiB
03_handmade_26.txt TLE 2205 ms 3564 KiB
03_handmade_27.txt TLE 2205 ms 3460 KiB
03_handmade_28.txt TLE 2205 ms 3428 KiB