Submission #51551415


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 B
{
    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 (W, B) = Scanner.Scan<int, int>();
        var S = "wbwbwwbwbwbw";
        while (S.Length < 300)
        {
            S += S;
        }

        var cumW = new int[S.Length + 1];
        var cumB = new int[S.Length + 1];
        for (var i = 0; i < S.Length; i++)
        {
            cumW[i + 1] += cumW[i];
            cumB[i + 1] += cumB[i];
            if (S[i] == 'w') cumW[i + 1]++;
            else cumB[i + 1]++;
        }

        var L = W + B;
        for (var i = 0; i + L <= S.Length; i++)
        {
            if (cumW[i + L] - cumW[i] == W && cumB[i + L] - cumB[i] == B)
            {
                Console.WriteLine("Yes");
                return;
            }
        }

        Console.WriteLine("No");
    }

    public static class Scanner
    {
        public static T Scan<T>() where T : IConvertible => Convert<T>(ScanStringArray()[0]);
        public static (T1, T2) Scan<T1, T2>() where T1 : IConvertible where T2 : IConvertible
        {
            var input = ScanStringArray();
            return (Convert<T1>(input[0]), Convert<T2>(input[1]));
        }
        public static (T1, T2, T3) Scan<T1, T2, T3>() where T1 : IConvertible where T2 : IConvertible where T3 : IConvertible
        {
            var input = ScanStringArray();
            return (Convert<T1>(input[0]), Convert<T2>(input[1]), Convert<T3>(input[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 input = ScanStringArray();
            return (Convert<T1>(input[0]), Convert<T2>(input[1]), Convert<T3>(input[2]), Convert<T4>(input[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 input = ScanStringArray();
            return (Convert<T1>(input[0]), Convert<T2>(input[1]), Convert<T3>(input[2]), Convert<T4>(input[3]), Convert<T5>(input[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 input = ScanStringArray();
            return (Convert<T1>(input[0]), Convert<T2>(input[1]), Convert<T3>(input[2]), Convert<T4>(input[3]), Convert<T5>(input[4]), Convert<T6>(input[5]));
        }
        public static IEnumerable<T> ScanEnumerable<T>() where T : IConvertible => ScanStringArray().Select(Convert<T>);
        private static string[] ScanStringArray()
        {
            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 B - Piano
User AconCavy
Language C# 11.0 (.NET 7.0.7)
Score 200
Code Size 3532 Byte
Status AC
Exec Time 46 ms
Memory 24964 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 3
AC × 22
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_yes_00.txt, 01_random_yes_01.txt, 02_random_yes_2_00.txt, 02_random_yes_2_01.txt, 02_random_yes_2_02.txt, 02_random_yes_2_03.txt, 03_random_no_00.txt, 03_random_no_01.txt, 04_random_no_2_00.txt, 04_random_no_2_01.txt, 04_random_no_2_02.txt, 04_random_no_2_03.txt, 05_handmade_00.txt, 05_handmade_01.txt, 05_handmade_02.txt, 05_handmade_03.txt, 05_handmade_04.txt, 05_handmade_05.txt, 05_handmade_06.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 36 ms 24812 KiB
00_sample_01.txt AC 34 ms 24940 KiB
00_sample_02.txt AC 39 ms 24820 KiB
01_random_yes_00.txt AC 41 ms 24664 KiB
01_random_yes_01.txt AC 35 ms 24820 KiB
02_random_yes_2_00.txt AC 36 ms 24936 KiB
02_random_yes_2_01.txt AC 29 ms 24656 KiB
02_random_yes_2_02.txt AC 34 ms 24816 KiB
02_random_yes_2_03.txt AC 38 ms 24660 KiB
03_random_no_00.txt AC 36 ms 24800 KiB
03_random_no_01.txt AC 46 ms 24948 KiB
04_random_no_2_00.txt AC 45 ms 24908 KiB
04_random_no_2_01.txt AC 37 ms 24964 KiB
04_random_no_2_02.txt AC 31 ms 24648 KiB
04_random_no_2_03.txt AC 41 ms 24776 KiB
05_handmade_00.txt AC 33 ms 24840 KiB
05_handmade_01.txt AC 35 ms 24840 KiB
05_handmade_02.txt AC 40 ms 24640 KiB
05_handmade_03.txt AC 33 ms 24576 KiB
05_handmade_04.txt AC 38 ms 24932 KiB
05_handmade_05.txt AC 37 ms 24828 KiB
05_handmade_06.txt AC 46 ms 24808 KiB