結果
問題 | No.1141 田グリッド |
ユーザー | fgwiebfaoish |
提出日時 | 2020-08-01 01:52:32 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 205 ms / 2,000 ms |
コード長 | 4,097 bytes |
コンパイル時間 | 3,267 ms |
コンパイル使用メモリ | 113,320 KB |
実行使用メモリ | 34,176 KB |
最終ジャッジ日時 | 2024-07-07 00:32:18 |
合計ジャッジ時間 | 8,540 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 25 ms
17,792 KB |
testcase_01 | AC | 26 ms
18,048 KB |
testcase_02 | AC | 26 ms
18,048 KB |
testcase_03 | AC | 25 ms
18,048 KB |
testcase_04 | AC | 26 ms
18,048 KB |
testcase_05 | AC | 26 ms
17,792 KB |
testcase_06 | AC | 25 ms
18,048 KB |
testcase_07 | AC | 25 ms
18,048 KB |
testcase_08 | AC | 29 ms
18,560 KB |
testcase_09 | AC | 27 ms
18,048 KB |
testcase_10 | AC | 28 ms
18,560 KB |
testcase_11 | AC | 30 ms
18,432 KB |
testcase_12 | AC | 29 ms
18,688 KB |
testcase_13 | AC | 191 ms
34,176 KB |
testcase_14 | AC | 205 ms
26,240 KB |
testcase_15 | AC | 177 ms
24,576 KB |
testcase_16 | AC | 177 ms
24,448 KB |
testcase_17 | AC | 170 ms
23,808 KB |
testcase_18 | AC | 122 ms
22,252 KB |
testcase_19 | AC | 127 ms
22,784 KB |
testcase_20 | AC | 129 ms
23,040 KB |
testcase_21 | AC | 179 ms
24,448 KB |
testcase_22 | AC | 178 ms
24,448 KB |
testcase_23 | AC | 177 ms
24,576 KB |
testcase_24 | AC | 128 ms
22,912 KB |
testcase_25 | AC | 141 ms
31,616 KB |
testcase_26 | AC | 125 ms
22,144 KB |
testcase_27 | AC | 124 ms
22,400 KB |
testcase_28 | AC | 138 ms
31,744 KB |
testcase_29 | AC | 130 ms
24,832 KB |
testcase_30 | AC | 122 ms
22,128 KB |
testcase_31 | AC | 130 ms
25,856 KB |
testcase_32 | AC | 129 ms
22,656 KB |
testcase_33 | AC | 128 ms
22,656 KB |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections.Generic; using System.Collections; using System.Collections.Specialized; using System.Linq; using System.Text; using System.IO; using System.Reflection; using static System.Math; using System.Numerics; static class Program{ const int mod=(int)1e9+7; const double eps=1e-11; static void Main(){ Sc sc=new Sc(); var s=sc.Ia; Mint p=1; var w=new Mint[s[0]]; var h=new Mint[s[1]]; var d=new int[s[0]][]; var wb=new int[s[0]]; var hb=new int[s[1]]; int z=0; for(int i = 0;i<s[1];i++) {h[i]=1;} for(int i = 0;i<s[0];i++) { w[i]=1; d[i]=sc.Ia; for(int j = 0;j<s[1];j++) { if(d[i][j]!=0){ w[i]*=d[i][j]; h[j]*=d[i][j]; } else{ wb[i]++; hb[j]++; } } p*=w[i]; z+=wb[i]; } var q=sc.I; StringBuilder sb=new StringBuilder(); for(int i = 0;i<q;i++) { var e=sc.Ia; Mint a=p; int g=wb[e[0]-1]+hb[e[1]-1]; if(d[e[0]-1][e[1]-1]==0){g--;} else{a*=d[e[0]-1][e[1]-1];} sb.Append((z==g?a/w[e[0]-1]/h[e[1]-1]:0)+"\n"); } Console.Write(sb); } } public struct Mint{ const int mod=(int)1e9+7; private long d; public Mint(long d){this.d=d;} public static implicit operator Mint(long d){return new Mint(d%mod);} public static explicit operator long(Mint d){return d.d;} public override string ToString(){return d.ToString();} public static Mint operator+(Mint a,long b){a.d=(a.d+b)%mod;return a;} public static Mint operator+(Mint a,Mint b){a.d=(a.d+b.d)%mod;return a;} public static Mint operator-(Mint a,long b){a.d=(mod+a.d-b)%mod;return a;} public static Mint operator-(Mint a,Mint b){a.d=(mod+a.d-b.d)%mod;return a;} public static Mint operator*(Mint a,long b){a.d=(a.d*b)%mod;return a;} public static Mint operator*(Mint a,Mint b){a.d=(a.d*b.d)%mod;return a;} public static Mint operator/(Mint a,long b){a.d=(a.d*Mi(b))%mod;return a;} public static Mint operator/(Mint a,Mint b){a.d=(a.d*Mi(b.d))%mod;return a;} private static long Mi(long a){ a=(a+mod)%mod; long b=mod,u=1,v=0; while(b>0){ long t=a/b; a-=t*b;(a,b)=(b,a); u-=t*v;(u,v)=(v,u); } u%=mod; if(u<0){u+=mod;} return u%mod; } } public class Sc{ public int I{get{return int.Parse(Console.ReadLine());}} public long L{get{return long.Parse(Console.ReadLine());}} public double D{get{return double.Parse(Console.ReadLine());}} public string S{get{return Console.ReadLine();}} public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}} public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}} public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}} public string[] Sa{get{return Console.ReadLine().Split();}} public object[] Oa{get{return Console.ReadLine().Split();}} public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}} public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);} public int[] Ia3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),int.Parse);} public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}} public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);} public long[] La3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),long.Parse);} public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}} public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);} public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;} public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;} public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;} public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;} }