Submission #4627227


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 static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var hw = Input.ar;
        var gred = Enumerable.Repeat(0, hw[0]).Select(v => ReadLine()).ToArray();
        var g = new[] { 0, 0, hw[0]/2 * (hw[1] /2)  };
        if (hw[0] % 2 == 1 && hw[1] % 2 == 1)
            g[0] = 1;
        if (hw[0] % 2 == 1)
            g[1] += hw[1] / 2;
        if (hw[1] % 2 == 1)
            g[1] += hw[0] / 2;
        var dic = new Dictionary<char, int>();
        for (var i = 0; i < hw[0]; i++)
            for (var j = 0; j < hw[1]; j++)
                if (dic.ContainsKey(gred[i][j]))
                    dic[gred[i][j]]++;
                else dic[gred[i][j]] = 1;
        for(var i=0;i<3;i++)
            for(var j = 0; j < g[i]; j++)
            {
                foreach (var pair in dic)
                {
                    if (pair.Value == 0) continue;
                    if (i == 0 && pair.Value % 4 % 2 == 1)
                    {
                        dic[pair.Key] -= 1;
                        break;
                    }
                    if (i == 1 && pair.Value % 4 == 2)
                    {
                        dic[pair.Key] -= 2;
                        break;
                    }
                    if (i == 2 && pair.Value % 4 == 0)
                    {
                        dic[pair.Key] -= 4;
                        break;
                    }
                }
            }
        foreach (var pair in dic)
            if (pair.Value != 0)
            {
                WriteLine("No");
                return;
            }
        WriteLine("Yes");
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}

Submission Info

Submission Time
Task C - Palindromic Matrix
User hibatibati
Language C# (Mono 4.6.2.0)
Score 0
Code Size 2518 Byte
Status WA
Exec Time 33 ms
Memory 13408 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 5
AC × 28
WA × 4
Set Name Test Cases
Sample 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt
All 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt
Case Name Status Exec Time Memory
0_00.txt AC 33 ms 9812 KB
0_01.txt AC 26 ms 9312 KB
0_02.txt AC 27 ms 11360 KB
0_03.txt AC 27 ms 11360 KB
0_04.txt AC 26 ms 9312 KB
1_00.txt AC 27 ms 11356 KB
1_01.txt WA 27 ms 11360 KB
1_02.txt AC 27 ms 11360 KB
1_03.txt WA 27 ms 11360 KB
1_04.txt AC 26 ms 9312 KB
1_05.txt WA 27 ms 11360 KB
1_06.txt AC 27 ms 11360 KB
1_07.txt WA 27 ms 11360 KB
1_08.txt AC 28 ms 13396 KB
1_09.txt AC 28 ms 11360 KB
1_10.txt AC 28 ms 11360 KB
1_11.txt AC 28 ms 13408 KB
1_12.txt AC 28 ms 11360 KB
1_13.txt AC 29 ms 13396 KB
1_14.txt AC 28 ms 9312 KB
1_15.txt AC 27 ms 11360 KB
1_16.txt AC 27 ms 9312 KB
1_17.txt AC 27 ms 9312 KB
1_18.txt AC 28 ms 13408 KB
1_19.txt AC 27 ms 9312 KB
1_20.txt AC 28 ms 11360 KB
1_21.txt AC 27 ms 11360 KB
1_22.txt AC 27 ms 11360 KB
1_23.txt AC 27 ms 13408 KB
1_24.txt AC 27 ms 11360 KB
1_25.txt AC 26 ms 9312 KB
1_26.txt AC 27 ms 11360 KB