Submission #43647339


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 E
    {
        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>();
            long answer = 0;
            var (c0, c1) = (0L, 0L);
            foreach (var c in S)
            {
                (c0, c1) = c == '0' ? (1, c0 + c1) : (c1, c0 + 1);
                answer += c1;
            }

            Console.WriteLine(answer);
        }

        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 E - NAND repeatedly
User AconCavy
Language C# (.NET Core 3.1.201)
Score 450
Code Size 3323 Byte
Status AC
Exec Time 98 ms
Memory 31176 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 450 / 450
Status
AC × 2
AC × 32
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt
All 00_sample_00.txt, 00_sample_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, 02_handmade_12.txt, 02_handmade_13.txt, 02_handmade_14.txt, 02_handmade_15.txt, 02_handmade_16.txt, 02_handmade_17.txt, 02_handmade_18.txt, 02_handmade_19.txt, 02_handmade_20.txt, 02_handmade_21.txt, 02_handmade_22.txt, 02_handmade_23.txt, 02_handmade_24.txt, 02_handmade_25.txt, 02_handmade_26.txt, 02_handmade_27.txt, 02_handmade_28.txt, 02_handmade_29.txt, 02_handmade_30.txt, 02_handmade_31.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 76 ms 27196 KiB
00_sample_01.txt AC 71 ms 27140 KiB
01_random_02.txt AC 92 ms 30916 KiB
01_random_03.txt AC 89 ms 31128 KiB
01_random_04.txt AC 93 ms 31096 KiB
01_random_05.txt AC 90 ms 31008 KiB
01_random_06.txt AC 86 ms 31020 KiB
01_random_07.txt AC 85 ms 30476 KiB
01_random_08.txt AC 88 ms 29972 KiB
01_random_09.txt AC 98 ms 30280 KiB
01_random_10.txt AC 91 ms 29864 KiB
01_random_11.txt AC 78 ms 27944 KiB
02_handmade_12.txt AC 85 ms 29828 KiB
02_handmade_13.txt AC 84 ms 29840 KiB
02_handmade_14.txt AC 86 ms 31116 KiB
02_handmade_15.txt AC 82 ms 31096 KiB
02_handmade_16.txt AC 86 ms 31176 KiB
02_handmade_17.txt AC 83 ms 30936 KiB
02_handmade_18.txt AC 74 ms 27192 KiB
02_handmade_19.txt AC 73 ms 27256 KiB
02_handmade_20.txt AC 75 ms 27180 KiB
02_handmade_21.txt AC 81 ms 27148 KiB
02_handmade_22.txt AC 81 ms 27496 KiB
02_handmade_23.txt AC 79 ms 27156 KiB
02_handmade_24.txt AC 77 ms 27496 KiB
02_handmade_25.txt AC 70 ms 27024 KiB
02_handmade_26.txt AC 82 ms 27160 KiB
02_handmade_27.txt AC 71 ms 27120 KiB
02_handmade_28.txt AC 83 ms 27560 KiB
02_handmade_29.txt AC 77 ms 27012 KiB
02_handmade_30.txt AC 89 ms 27148 KiB
02_handmade_31.txt AC 85 ms 27028 KiB