結果
問題 | No.1056 2D Lamps |
ユーザー | kcvlex |
提出日時 | 2020-05-15 23:05:42 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 4,870 bytes |
コンパイル時間 | 1,644 ms |
コンパイル使用メモリ | 155,952 KB |
実行使用メモリ | 13,880 KB |
最終ジャッジ日時 | 2024-09-19 13:04:16 |
合計ジャッジ時間 | 6,785 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
13,760 KB |
testcase_01 | AC | 3 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | TLE | - |
testcase_04 | -- | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
ソースコード
#include <limits> #include <initializer_list> #include <utility> #include <bitset> #include <tuple> #include <type_traits> #include <functional> #include <string> #include <array> #include <deque> #include <list> #include <queue> #include <stack> #include <vector> #include <map> #include <set> #include <unordered_map> #include <unordered_set> #include <iterator> #include <algorithm> #include <complex> #include <random> #include <numeric> #include <iostream> #include <iomanip> #include <sstream> #include <regex> #include <cassert> #include <cstddef> #include <variant> // Yay!! #define endl codeforces // macros for iterator #define ALL(v) std::begin(v), std::end(v) #define ALLR(v) std::rbegin(v), std::rend(v) // alias using ll = std::int64_t; using ull = std::uint64_t; using pii = std::pair<int, int>; using tii = std::tuple<int, int, int>; using pll = std::pair<ll, ll>; using tll = std::tuple<ll, ll, ll>; template <typename T> using vec = std::vector<T>; template <typename T> using vvec = vec<vec<T>>; // variadic min/max template <typename T> const T& var_min(const T &t) { return t; } template <typename T> const T& var_max(const T &t) { return t; } template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); } template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); } // variadic chmin/chmax template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); } template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); } // multi demension array template <typename T, std::size_t Head, std::size_t... Tail> struct multi_dim_array { using type = std::array<typename multi_dim_array<T, Tail...>::type, Head>; }; template <typename T, std::size_t Head> struct multi_dim_array<T, Head> { using type = std::array<T, Head>; }; template <typename T, std::size_t... Args> using mdarray = typename multi_dim_array<T, Args...>::type; // fill container template <typename T, typename F, typename... Args> void fill_seq(T &t, F f, Args... args) { if constexpr (std::is_invocable<F, Args...>::value) { t = f(args...); } else { for (ssize_t i = 0; i < t.size(); i++) fill_seq(t[i], f, args..., i); } } // make multi dimension vector template <typename T> vec<T> make_v(ssize_t sz) { return vec<T>(sz); } template <typename T, typename... Tail> auto make_v(ssize_t hs, Tail&&... ts) { auto v = std::move(make_v<T>(std::forward<Tail>(ts)...)); return vec<decltype(v)>(hs, v); } // init namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; } constexpr std::size_t SIZE = 200 * 200; using bs_type = std::bitset<SIZE>; using matrix_type = vec<bs_type>; std::pair<matrix_type, ll> gauss_elim(matrix_type mat) { ll upper_row = 0; ll rank = 0; for (ll col = 0; col < SIZE && upper_row < mat.size(); col++) { ll row = -1; for (ll r = upper_row; r < mat.size(); r++) { if (mat[r].test(col)) { row = r; break; } } if (row == -1) continue; rank++; std::swap(mat[upper_row], mat[row]); for (ll r = 0; r < mat.size(); r++) { if (r == upper_row) continue; if (!mat[r].test(col)) continue; mat[r] ^= mat[upper_row]; } upper_row++; } return std::make_pair(std::move(mat), rank); } int main() { ll n, m; std::cin >> n >> m; auto av = make_v<bs_type>(m); for (auto &&e : av) { for (ll i = 0; i < n; i++) { std::string s; std::cin >> s; for (ll j = 0; j < n; j++) if (s[j] == '#') e.set(i * n + j, 1); } } vec<std::string> ans(m - 1); for (ll i = 0; i < m - 1; i++) ans[i] = std::string(m - i - 1, '0'); matrix_type op_mat(2 * n + 2 * (2 * n - 1)); for (ll i = 0; i < n; i++) for (ll j = 0; j < n; j++) { ll idx = i * n + j; op_mat[i].set(idx, 1); op_mat[j + n].set(idx, 1); ll k1 = i + j; op_mat[k1 + 2 * n].set(idx, 1); ll k2 = i - j; k2 += n - 1; op_mat[k2 + 2 * n + 2 * n - 1].set(idx, 1); } { auto [ tmp, rank ] = gauss_elim(op_mat); op_mat = std::move(tmp); op_mat.erase(op_mat.begin() + rank, op_mat.end()); } for (ll i = 0; i < m; i++) for (ll j = i + 1; j < m; j++) { bs_type bs = av[i] ^ av[j]; auto cpy = op_mat; cpy.push_back(bs); auto [ ign, rank ] = gauss_elim(cpy); if (rank == op_mat.size()) ans[i][j - i - 1] = '1'; } for (auto &&s : ans) std::cout << s << "\n"; return 0; }