結果
問題 | No.13 囲みたい! |
ユーザー | firiexp |
提出日時 | 2023-03-17 12:58:01 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 2,245 bytes |
コンパイル時間 | 931 ms |
コンパイル使用メモリ | 96,780 KB |
最終ジャッジ日時 | 2024-11-15 03:35:49 |
合計ジャッジ時間 | 1,416 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:68:19: error: variable 'std::array<int, 2> dy' has initializer but incomplete type 68 | array<int, 2> dy {1, 0}, dx {0, 1}; | ^~ main.cpp:68:30: error: variable 'std::array<int, 2> dx' has initializer but incomplete type 68 | array<int, 2> dy {1, 0}, dx {0, 1}; | ^~
ソースコード
#include <iostream> #include <algorithm> #include <map> #include <set> #include <queue> #include <stack> #include <numeric> #include <bitset> #include <cmath> #include <limits> static const int MOD = 998244353; using ll = long long; using uint = unsigned; using ull = unsigned long long; using namespace std; template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208; template <class T, class U> vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); } template<class... Ts, class U> auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); } template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); } template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); } class UnionFind { int n; vector<int> uni; int forest_size; public: explicit UnionFind(int n) : n(n), uni(static_cast<uint>(n), -1), forest_size(n) {}; int root(int a){ if (uni[a] < 0) return a; else return (uni[a] = root(uni[a])); } bool unite(int a, int b) { a = root(a); b = root(b); if(a == b) return false; if(uni[a] > uni[b]) swap(a, b); uni[a] += uni[b]; uni[b] = a; forest_size--; return true; } int size(){ return forest_size; } int size(int i){ return -uni[root(i)]; } bool same(int a, int b) { return root(a) == root(b); } }; int main() { int w, h; cin >> w >> h; auto v = make_v(h+2, w+2, 0); for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) { scanf("%d", &v[i+1][j+1]); } } UnionFind uf(h*w); vector<int> dp(h*w); auto f = [&](int i, int j){ return i*w+j; }; array<int, 2> dy {1, 0}, dx {0, 1}; for (int i = 1; i <= h; ++i) { for (int j = 1; j <= w; ++j) { for (int k = 0; k < 2; ++k) { if(v[i][j] == v[i+dy[k]][j+dx[k]]){ if(!uf.unite(f(i-1, j-1), f(i+dy[k]-1, j+dx[k]-1))){ puts("possible"); return 0; } } } } } puts("impossible"); return 0; }