Submission #7467186


Source Code Expand

Copy
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace kp
{
    public class Program
    {
        //static long[,] cmb;
        static int MAX_INT = 1000000007;
        static void Main(string[] args)
        {
            //int N = Int32.Parse(Console.ReadLine());
            int[] input = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
            int R = input[0];
            int C = input[1];
            input = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
            int X = input[0];
            int Y = input[1];
            input = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
            int D = input[0];
            int L = input[1];

            // R*Cの区画の中にX*Yの区画の取り方は
            int a = (R-X+1)*(C-Y+1);
//Console.WriteLine(a + " math");
            // X*YのますからDを置く場所を決める
            // → X*Y[Comb]D
        //  Console.WriteLine((X*Y) + " " + D);
            int b = Combination(X*Y, D);
            // 残りの X*Y-DのますからLを置く場所を決める
            // → X*Y-D[Comb]L

          //Console.WriteLine((X*Y-D) + " " +  L);
            int c = Combination(X*Y-D, L);
//Console.WriteLine(a + " " + b + " " + c);
            // a*b*cが答えだけど・・・
            long ret = (long)a%MAX_INT;
            ret = (ret*(long)b)%MAX_INT;
            ret = (ret*(long)c)%MAX_INT;

            Console.WriteLine(ret + "");
        }

        static int Combination(int i, int j)
        {
          // iCjを求める
          long[,] comb = new long[i+2, i+2];
          comb[0,0] = 1;
          comb[1,0] = 1;
          comb[1,1] = 1;
          for(int k = 2; k<=i; k++)
          {
            for(int l = 0; l<= k; l++)
            {
              if(l==0)
              {
                comb[k,l] = 1;
              }
              else
              {
                comb[k,l] = (comb[k-1, l-1] + comb[k-1, l])%MAX_INT;
              }
            }
          }
          /*
Console.WriteLine("comb");
          for(int ii = 0; ii<=i; ii++)
          {
            for(int jj = 0; jj<=i; jj++)
            {
              Console.Write(comb[ii,jj] + " ");
            }
            Console.WriteLine();
          }*/
          return (int)comb[i,j];
        }

    }
}

Submission Info

Submission Time
Task D - AtCoder社の冬
User kyokochan
Language C# (Mono 4.6.2.0)
Score 100
Code Size 2523 Byte
Status
Exec Time 42 ms
Memory 25696 KB

Judge Result

Set Name Score / Max Score Test Cases
sub 100 / 100 00_sample_01E.txt, 00_sample_02E.txt, 00_sample_03E.txt, test_03E.txt, test_04E.txt, test_07E.txt, test_08E.txt, test_11E.txt, test_12E.txt, test_15E.txt, test_16E.txt, test_19E.txt, test_20E.txt, test_23E.txt, test_24E.txt, test_27E.txt, test_28E.txt, test_31E.txt, test_32E.txt, test_36E.txt, test_37E.txt, test_38E.txt, test_39E.txt, test_45E.txt, test_47E.txt
All 0 / 1 00_sample_01E.txt, 00_sample_02E.txt, 00_sample_03E.txt, 00_sample_04.txt, test_01.txt, test_02.txt, test_03E.txt, test_04E.txt, test_05.txt, test_06.txt, test_07E.txt, test_08E.txt, test_09.txt, test_10.txt, test_11E.txt, test_12E.txt, test_13.txt, test_14.txt, test_15E.txt, test_16E.txt, test_17.txt, test_18.txt, test_19E.txt, test_20E.txt, test_21.txt, test_22.txt, test_23E.txt, test_24E.txt, test_25.txt, test_26.txt, test_27E.txt, test_28E.txt, test_29.txt, test_30.txt, test_31E.txt, test_32E.txt, test_33.txt, test_34.txt, test_35.txt, test_36E.txt, test_37E.txt, test_38E.txt, test_39E.txt, test_40.txt, test_41.txt, test_42.txt, test_43.txt, test_44.txt, test_45E.txt, test_46.txt, test_47E.txt, test_48.txt
Case Name Status Exec Time Memory
00_sample_01E.txt 24 ms 13268 KB
00_sample_02E.txt 23 ms 9300 KB
00_sample_03E.txt 24 ms 11344 KB
00_sample_04.txt 29 ms 14432 KB
test_01.txt 24 ms 13356 KB
test_02.txt 23 ms 11348 KB
test_03E.txt 24 ms 11348 KB
test_04E.txt 28 ms 15584 KB
test_05.txt 23 ms 9300 KB
test_06.txt 33 ms 17120 KB
test_07E.txt 24 ms 11332 KB
test_08E.txt 25 ms 13792 KB
test_09.txt 25 ms 10080 KB
test_10.txt 29 ms 12640 KB
test_11E.txt 25 ms 11616 KB
test_12E.txt 27 ms 13024 KB
test_13.txt 23 ms 9284 KB
test_14.txt 42 ms 25696 KB
test_15E.txt 29 ms 16224 KB
test_16E.txt 41 ms 20832 KB
test_17.txt 23 ms 9300 KB
test_18.txt 23 ms 11356 KB
test_19E.txt 23 ms 11220 KB
test_20E.txt 24 ms 11284 KB
test_21.txt 24 ms 11340 KB
test_22.txt 30 ms 14688 KB
test_23E.txt 23 ms 9300 KB
test_24E.txt 34 ms 17760 KB
test_25.txt 24 ms 11488 KB
test_26.txt 24 ms 11276 KB
test_27E.txt 27 ms 13152 KB
test_28E.txt 31 ms 15584 KB
test_29.txt 40 ms 21600 KB
test_30.txt 42 ms 21600 KB
test_31E.txt 25 ms 13792 KB
test_32E.txt 42 ms 23008 KB
test_33.txt 23 ms 11348 KB
test_34.txt 24 ms 11248 KB
test_35.txt 24 ms 13268 KB
test_36E.txt 24 ms 11348 KB
test_37E.txt 23 ms 9300 KB
test_38E.txt 24 ms 11348 KB
test_39E.txt 24 ms 11348 KB
test_40.txt 24 ms 11236 KB
test_41.txt 23 ms 11220 KB
test_42.txt 24 ms 11256 KB
test_43.txt 24 ms 13396 KB
test_44.txt 24 ms 11308 KB
test_45E.txt 24 ms 11348 KB
test_46.txt 23 ms 11348 KB
test_47E.txt 24 ms 11220 KB
test_48.txt 24 ms 13396 KB