Submission #40844162


Source Code Expand

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;

namespace Tasks
{
    public class C
    {
        public static void Main()
        {
            using var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = Scanner.Scan<int>();
            var S = Scanner.Scan<string>();


            int F(string s)
            {
                var l = 0;
                var result = -1;
                while (l < N)
                {
                    if (s[l] == '-')
                    {
                        l++;
                        continue;
                    }

                    var r = l;
                    while (r < N && s[r] == 'o') r++;
                    if (r < N && s[r] == '-')
                    {
                        result = Math.Max(result, r - l);
                    }
                    l = r;
                }

                return result;
            }

            var answer = F(S);
            var T = new string(S.Reverse().ToArray());
            answer = Math.Max(answer, F(T));
            Console.WriteLine(answer);
        }

        public static class Scanner
        {
            public static T Scan<T>() where T : IConvertible => Convert<T>(Scan()[0]);
            public static (T1, T2) Scan<T1, T2>() where T1 : IConvertible where T2 : IConvertible
            {
                var buffer = Scan();
                return (Convert<T1>(buffer[0]), Convert<T2>(buffer[1]));
            }
            public static (T1, T2, T3) Scan<T1, T2, T3>() where T1 : IConvertible where T2 : IConvertible where T3 : IConvertible
            {
                var buffer = Scan();
                return (Convert<T1>(buffer[0]), Convert<T2>(buffer[1]), Convert<T3>(buffer[2]));
            }
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() where T1 : IConvertible where T2 : IConvertible where T3 : IConvertible where T4 : IConvertible
            {
                var buffer = Scan();
                return (Convert<T1>(buffer[0]), Convert<T2>(buffer[1]), Convert<T3>(buffer[2]), Convert<T4>(buffer[3]));
            }
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() where T1 : IConvertible where T2 : IConvertible where T3 : IConvertible where T4 : IConvertible where T5 : IConvertible
            {
                var buffer = Scan();
                return (Convert<T1>(buffer[0]), Convert<T2>(buffer[1]), Convert<T3>(buffer[2]), Convert<T4>(buffer[3]), Convert<T5>(buffer[4]));
            }
            public static (T1, T2, T3, T4, T5, T6) Scan<T1, T2, T3, T4, T5, T6>() where T1 : IConvertible where T2 : IConvertible where T3 : IConvertible where T4 : IConvertible where T5 : IConvertible where T6 : IConvertible
            {
                var buffer = Scan();
                return (Convert<T1>(buffer[0]), Convert<T2>(buffer[1]), Convert<T3>(buffer[2]), Convert<T4>(buffer[3]), Convert<T5>(buffer[4]), Convert<T6>(buffer[5]));
            }
            public static IEnumerable<T> ScanEnumerable<T>() where T : IConvertible => Scan().Select(Convert<T>);
            private static string[] Scan()
            {
                var line = Console.ReadLine()?.Trim() ?? string.Empty;
                return string.IsNullOrEmpty(line) ? Array.Empty<string>() : line.Split(' ');
            }
            private static T Convert<T>(string value) where T : IConvertible => (T)System.Convert.ChangeType(value, typeof(T));
        }
    }
}

Submission Info

Submission Time
Task C - Dango
User AconCavy
Language C# (.NET Core 3.1.201)
Score 300
Code Size 3809 Byte
Status AC
Exec Time 94 ms
Memory 30244 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 29
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_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
Case Name Status Exec Time Memory
00_sample_00.txt AC 90 ms 27876 KiB
00_sample_01.txt AC 78 ms 27776 KiB
00_sample_02.txt AC 74 ms 28124 KiB
01_small_03.txt AC 83 ms 28072 KiB
01_small_04.txt AC 94 ms 27908 KiB
01_small_05.txt AC 77 ms 27904 KiB
01_small_06.txt AC 73 ms 27880 KiB
01_small_07.txt AC 77 ms 27776 KiB
02_random_08.txt AC 91 ms 30244 KiB
02_random_09.txt AC 81 ms 29908 KiB
02_random_10.txt AC 84 ms 30092 KiB
02_random_11.txt AC 84 ms 28708 KiB
02_random_12.txt AC 83 ms 28556 KiB
02_random_13.txt AC 83 ms 28812 KiB
02_random_14.txt AC 78 ms 28016 KiB
02_random_15.txt AC 91 ms 28624 KiB
02_random_16.txt AC 89 ms 29216 KiB
03_handmade_17.txt AC 81 ms 29028 KiB
03_handmade_18.txt AC 82 ms 28204 KiB
03_handmade_19.txt AC 82 ms 28540 KiB
03_handmade_20.txt AC 83 ms 28984 KiB
03_handmade_21.txt AC 82 ms 29992 KiB
03_handmade_22.txt AC 85 ms 29988 KiB
03_handmade_23.txt AC 86 ms 30124 KiB
03_handmade_24.txt AC 89 ms 29824 KiB
03_handmade_25.txt AC 81 ms 29668 KiB
03_handmade_26.txt AC 78 ms 29480 KiB
03_handmade_27.txt AC 94 ms 29400 KiB
03_handmade_28.txt AC 86 ms 28868 KiB