結果

問題 No.2270 T0空間
ユーザー 👑 kakel-sankakel-san
提出日時 2023-07-05 18:47:33
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 927 ms / 2,000 ms
コード長 2,109 bytes
コンパイル時間 2,368 ms
コンパイル使用メモリ 65,624 KB
実行使用メモリ 71,672 KB
最終ジャッジ日時 2023-09-26 19:08:44
合計ジャッジ時間 10,415 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
21,452 KB
testcase_01 AC 62 ms
21,500 KB
testcase_02 AC 62 ms
21,628 KB
testcase_03 AC 62 ms
21,524 KB
testcase_04 AC 59 ms
21,568 KB
testcase_05 AC 60 ms
23,544 KB
testcase_06 AC 60 ms
19,604 KB
testcase_07 AC 60 ms
21,512 KB
testcase_08 AC 61 ms
21,700 KB
testcase_09 AC 60 ms
21,560 KB
testcase_10 AC 60 ms
23,568 KB
testcase_11 AC 137 ms
28,360 KB
testcase_12 AC 103 ms
27,940 KB
testcase_13 AC 241 ms
38,388 KB
testcase_14 AC 244 ms
34,248 KB
testcase_15 AC 240 ms
36,168 KB
testcase_16 AC 430 ms
47,192 KB
testcase_17 AC 912 ms
69,540 KB
testcase_18 AC 927 ms
71,672 KB
testcase_19 AC 724 ms
71,536 KB
testcase_20 AC 717 ms
71,536 KB
testcase_21 AC 727 ms
71,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static int NN => int.Parse(ReadLine());
    static string[] SList(long n) => Enumerable.Repeat(0, (int)n).Select(_ => ReadLine()).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var n = NN;
        var m = NN;
        var s = SList(m);
        WriteLine(T0(n, m, s) ? "Yes" : "No");
    }
    static bool T0(int n, int m, string[] s)
    {
        var b = new Bitset[n];
        for (var i = 0; i < b.Length; ++i)
        {
            b[i] = new Bitset(n);
            b[i].Set(i, 1);
        }
        foreach (var si in s)
        {
            var zero = new Bitset(n);
            var one = new Bitset(n);
            for (var i = 0; i < si.Length; ++i)
            {
                if (si[i] == '0') zero.Set(i, 1);
                else one.Set(i, 1);
            }
            for (var i = 0; i < si.Length; ++i)
            {
                if (si[i] == '0') b[i].Or(one);
                else b[i].Or(zero);
            }
        }
        foreach (var bi in b)
        {
            if (bi.Expand().Any(i => i == 0)) return false;
        }
        return true;
    }
    class Bitset
    {
        int _length;
        ulong[] data;
        public Bitset(int length)
        {
            _length = length;
            data = new ulong[(length + 63) / 64];
        }
        public void Set(int pos, int val)
        {
            if (val == 0) data[pos / 64] = (data[pos / 64] ^ ((ulong)1 << (pos % 64)));
            else data[pos / 64] = (data[pos / 64] | ((ulong)1 << (pos % 64)));
        }
        public void Or(Bitset b)
        {
            for (var i = 0; i < data.Length; ++i) data[i] = data[i] | b.data[i];
        }
        public int[] Expand()
        {
            var ans = new int[_length];
            for (var i = 0; i < _length; ++i) ans[i] = (int)((data[i / 64] >> (i % 64)) % 2);
            return ans;
        }
    }
}
0