Submission #5821378


Source Code Expand

using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using Debug;
//using static System.Globalization.CultureInfo;
//using Edge = Pair<long, int>;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        var str = ReadLine().ToCharArray();
        var res = 0L;
        var ct = new int[Input.Alfa.Length];
        for (var i = 0; i < str.Length; i++)
            ct[str[i] - 'a']++;
        foreach (var v in ct)
            res += v * (v - 1L) / 2;
        WriteLine(str.Length * (str.Length - 1L) / 2 - res + 1);
    }
}

public class Input
{
    public static string read => ReadLine().Trim();
    public static int[] ar => read.Split(' ').Select(int.Parse).ToArray();
    public  static int num => ToInt32(read);
    public static long[] arL => read.Split(' ').Select(long.Parse).ToArray();
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(_ => read.ToCharArray()).ToArray();
    public static int[] ar1D(int n)
        => Enumerable.Repeat(0, n).Select(_ => num).ToArray();
    public static long[] arL1D(int n)
        => Enumerable.Repeat(0, n).Select(_ => numL).ToArray();
    public static string[] strs(int n)
        => Enumerable.Repeat(0, n).Select(_ => read).ToArray();
    public static int[][] ar2D(int n)
        => Enumerable.Repeat(0, n).Select(_ => ar).ToArray();
    public static long[][] arL2D(int n)
        => Enumerable.Repeat(0, n).Select(_ => arL).ToArray();
    public static T getValue<T>(string g)
    {
        var t = typeof(T);
        if (t == typeof(int))
            return (T)(object)int.Parse(g);
        if (t == typeof(long))
            return (T)(object)long.Parse(g);
        if (t == typeof(string))
            return (T)(object)g;
        if (t == typeof(char))
            return (T)(object)char.Parse(g);
        if (t == typeof(double))
            return (T)(object)double.Parse(g);
        if (t == typeof(bool))
            return (T)(object)bool.Parse(g);
        return default(T);
    }
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}

Submission Info

Submission Time
Task B - Reverse and Compare
User hibatibati
Language C# (Mono 4.6.2.0)
Score 500
Code Size 2484 Byte
Status AC
Exec Time 22 ms
Memory 13140 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 23
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All sample_01.txt, sample_02.txt, sample_03.txt, sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt, subtask_1_16.txt, subtask_1_17.txt
Case Name Status Exec Time Memory
sample_01.txt AC 20 ms 9044 KB
sample_02.txt AC 19 ms 9044 KB
sample_03.txt AC 20 ms 11092 KB
subtask_1_01.txt AC 20 ms 11092 KB
subtask_1_02.txt AC 22 ms 10080 KB
subtask_1_03.txt AC 20 ms 13140 KB
subtask_1_04.txt AC 19 ms 9044 KB
subtask_1_05.txt AC 20 ms 9044 KB
subtask_1_06.txt AC 20 ms 9044 KB
subtask_1_07.txt AC 20 ms 9048 KB
subtask_1_08.txt AC 21 ms 10080 KB
subtask_1_09.txt AC 21 ms 10080 KB
subtask_1_10.txt AC 21 ms 10080 KB
subtask_1_11.txt AC 21 ms 10080 KB
subtask_1_12.txt AC 22 ms 12128 KB
subtask_1_13.txt AC 22 ms 12128 KB
subtask_1_14.txt AC 22 ms 12128 KB
subtask_1_15.txt AC 22 ms 12128 KB
subtask_1_16.txt AC 22 ms 12128 KB
subtask_1_17.txt AC 22 ms 12128 KB