結果
問題 | No.13 囲みたい! |
ユーザー | togari_takamoto |
提出日時 | 2015-12-14 02:04:58 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,218 bytes |
コンパイル時間 | 941 ms |
コンパイル使用メモリ | 89,520 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-15 12:03:57 |
合計ジャッジ時間 | 1,769 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 3 ms
5,376 KB |
testcase_06 | WA | - |
testcase_07 | AC | 3 ms
5,376 KB |
testcase_08 | AC | 4 ms
5,376 KB |
testcase_09 | WA | - |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 3 ms
5,376 KB |
testcase_12 | AC | 2 ms
5,376 KB |
testcase_13 | AC | 3 ms
5,376 KB |
testcase_14 | AC | 3 ms
5,376 KB |
testcase_15 | AC | 1 ms
5,376 KB |
コンパイルメッセージ
In file included from /usr/include/c++/11/bits/char_traits.h:39, from /usr/include/c++/11/ios:40, from /usr/include/c++/11/ostream:38, from /usr/include/c++/11/iostream:39, from main.cpp:1: In function ‘typename __gnu_cxx::__enable_if<std::__is_scalar<_Tp>::__value, void>::__type std::__fill_a1(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = bool*; _Tp = bool]’, inlined from ‘void std::__fill_a(_FIte, _FIte, const _Tp&) [with _FIte = bool*; _Tp = bool]’ at /usr/include/c++/11/bits/stl_algobase.h:969:21, inlined from ‘void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = bool*; _Tp = bool]’ at /usr/include/c++/11/bits/stl_algobase.h:999:20, inlined from ‘int main()’ at main.cpp:47:6: /usr/include/c++/11/bits/stl_algobase.h:924:18: warning: ‘void* __builtin_memset(void*, int, long unsigned int)’ writing 10201 bytes into a region of size 10000 overflows the destination [-Wstringop-overflow=] 924 | *__first = __tmp; | ~~~~~~~~~^~~~~~~ main.cpp: In function ‘int main()’: main.cpp:31:6: note: destination object ‘visited’ of size 10000 31 | bool visited[100][100]; | ^~~~~~~ In file included from /usr/include/c++/11/bits/char_traits.h:39, from /usr/include/c++/11/ios:40, from /usr/include/c++/11/ostream:38, from /usr/include/c++/11/iostream:39, from main.cpp:1: In function ‘typename __gnu_cxx::__enable_if<std::__is_scalar<_Tp>::__value, void>::__type std::__fill_a1(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = bool*; _Tp = bool]’, inlined from ‘void std::__fill_a(_FIte, _FIte, const _Tp&) [with _FIte = bool*; _Tp = bool]’ at /usr/include/c++/11/bits/stl_algobase.h:969:21, inlined from ‘void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&) [with _Forward
ソースコード
#include <iostream> #include <vector> #include <array> #include <algorithm> #include <string> #include <map> #include <queue> #include <iomanip> #include <numeric> #include <memory> #include <set> #include <cassert> #include <cmath> #include <bitset> #include <functional> #include <limits> using namespace std; typedef long long ll; typedef unsigned long long ull; #define REP(i,n) for(ll i=0; i<(n); ++i) #define TEN(x) ((ll)1e##x) #define ALL(v) (v).begin(), (v).end() // 0 1 2 3 ll dx[] = { 1, 0, 0, -1 }; ll dy[] = { 0, 1, -1, 0 }; ll m[100][100]; // m[h][w]; ll w, h; bool visited[100][100]; bool is_inner(ll x, ll y) { return !(x < 0 || w <= x || y < 0 || h <= y); } bool bfs(ll x, ll y, ll d) { if (visited[y][x]) return true; visited[y][x] = true; REP(i, 4) if (i != d) if (is_inner(x + dx[i], y + dy[i])) if (m[y][x] == m[y + dy[i]][x + dx[i]]) { if (bfs(x + dx[i], y + dy[i], 3 - i)) return true; } return false; } int main(){ cin >> w >> h; REP(y, h) REP(x, w) cin >> m[y][x]; fill(visited[0], visited[0] + 101 * 101, false); REP(y, h) REP(x, w) if (!visited[y][x]) if (bfs(x, y, -1)) { cout << "possible" << endl; return 0; } cout << "impossible" << endl; return 0; }