Submission #50799830


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 D
{
    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, T) = Scanner.Scan<int, int>();
        var dp = new Dictionary<long, HashSet<int>>();
        dp[0] = Enumerable.Range(0, N).ToHashSet();
        var P = new long[N];
        for (var i = 0; i < T; i++)
        {
            var (A, B) = Scanner.Scan<int, int>();
            A--;
            var curr = P[A];
            var next = curr + B;
            if (!dp.ContainsKey(next)) dp[next] = new HashSet<int>();
            dp[next].Add(A);
            dp[curr].Remove(A);
            P[A] = next;
            if (dp[curr].Count == 0) dp.Remove(curr);
            Console.WriteLine(dp.Count);
        }

    }

    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 D - Diversity of Scores
User AconCavy
Language C# 11.0 (.NET 7.0.7)
Score 400
Code Size 3403 Byte
Status AC
Exec Time 369 ms
Memory 90220 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
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_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, 02_max_00.txt, 02_max_01.txt, 03_killer_00.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 50 ms 26524 KiB
00_sample_01.txt AC 55 ms 26800 KiB
00_sample_02.txt AC 43 ms 26712 KiB
01_random_00.txt AC 204 ms 67308 KiB
01_random_01.txt AC 183 ms 58344 KiB
01_random_02.txt AC 263 ms 71320 KiB
01_random_03.txt AC 258 ms 68572 KiB
01_random_04.txt AC 271 ms 73592 KiB
01_random_05.txt AC 286 ms 74084 KiB
01_random_06.txt AC 308 ms 79016 KiB
01_random_07.txt AC 307 ms 75596 KiB
01_random_08.txt AC 310 ms 80928 KiB
01_random_09.txt AC 315 ms 78728 KiB
01_random_10.txt AC 309 ms 81588 KiB
01_random_11.txt AC 296 ms 81580 KiB
01_random_12.txt AC 369 ms 89936 KiB
01_random_13.txt AC 224 ms 66260 KiB
01_random_14.txt AC 361 ms 90220 KiB
01_random_15.txt AC 295 ms 81468 KiB
02_max_00.txt AC 173 ms 61964 KiB
02_max_01.txt AC 199 ms 68056 KiB
03_killer_00.txt AC 162 ms 61908 KiB