結果
問題 | No.659 徘徊迷路 |
ユーザー | saxofone111 |
提出日時 | 2021-03-22 10:33:08 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,258 ms / 2,000 ms |
コード長 | 1,870 bytes |
コンパイル時間 | 6,277 ms |
コンパイル使用メモリ | 292,952 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-23 19:55:55 |
合計ジャッジ時間 | 16,545 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 8 ms
5,248 KB |
testcase_01 | AC | 262 ms
5,248 KB |
testcase_02 | AC | 6 ms
5,248 KB |
testcase_03 | AC | 3 ms
5,248 KB |
testcase_04 | AC | 401 ms
5,248 KB |
testcase_05 | AC | 14 ms
5,248 KB |
testcase_06 | AC | 14 ms
5,248 KB |
testcase_07 | AC | 5 ms
5,248 KB |
testcase_08 | AC | 443 ms
5,248 KB |
testcase_09 | AC | 1,058 ms
5,248 KB |
testcase_10 | AC | 1,215 ms
5,248 KB |
testcase_11 | AC | 1,176 ms
5,248 KB |
testcase_12 | AC | 219 ms
5,248 KB |
testcase_13 | AC | 1,053 ms
5,248 KB |
testcase_14 | AC | 1,071 ms
5,248 KB |
testcase_15 | AC | 1,242 ms
5,248 KB |
testcase_16 | AC | 1,258 ms
5,248 KB |
コンパイルメッセージ
In file included from /boost_git/boost/numeric/ublas/traits.hpp:21, from /boost_git/boost/numeric/ublas/storage.hpp:27, from /boost_git/boost/numeric/ublas/vector.hpp:21, from /boost_git/boost/numeric/ublas/matrix.hpp:18, from main.cpp:2: /boost_git/boost/numeric/ublas/detail/iterator.hpp:111:21: warning: 'template<class _Category, class _Tp, class _Distance, class _Pointer, class _Reference> struct std::iterator' is deprecated [-Wdeprecated-declarations] 111 | public std::iterator<IC, T> { | ^~~~~~~~ In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_algobase.h:65, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/specfun.h:45, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/cmath:1935, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/x86_64-pc-linux-gnu/bits/stdc++.h:41, from main.cpp:1: /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_iterator_base_types.h:127:34: note: declared here 127 | struct _GLIBCXX17_DEPRECATED iterator | ^~~~~~~~ /boost_git/boost/numeric/ublas/detail/iterator.hpp:149:21: warning: 'template<class _Category, class _Tp, class _Distance, class _Pointer, class _Reference> struct std::iterator' is deprecated [-Wdeprecated-declarations] 149 | public std::iterator<IC, T> { | ^~~~~~~~ /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_iterator_base_types.h:127:34: note: declared here 127 | struct _GLIBCXX17_DEPRECATED iterator | ^~~~~~~~ /boost_git/boost/numeric/ublas/detail/iterator.hpp:204:21: warning: 'template<class _Category, class _Tp, class _Distance, class _Pointer, class _Reference> struct std::itera
ソースコード
#include "bits/stdc++.h" #include <boost/numeric/ublas/matrix.hpp> #define MOD 1000000007 #define rep(i, n) for(ll i=0; i < (n); i++) #define rrep(i, n) for(ll i=(n)-1; i >=0; i--) #define ALL(v) v.begin(),v.end() #define rALL(v) v.rbegin(),v.rend() #define FOR(i, j, k) for(ll i=j;i<k;i++) #define debug_print(var) cerr << #var << "=" << var <<endl; #define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" " #define fi first #define se second using namespace std; using namespace boost::numeric::ublas; typedef long long int ll; typedef std::vector<ll> llvec; typedef std::vector<double> dvec; typedef pair<ll, ll> P; typedef long double ld; struct edge{ll x, c;}; /************************************** ** A main function starts from here ** ***************************************/ int main(){ ll R, C, T; cin >> R >> C >> T; matrix<ld> A(R*C, R*C); matrix<ld> e(R*C, R*C); rep(i, R*C)e(i, i) = 1.0; P s, g; cin >> s.fi >> s.se; cin >> g.fi >> g.se; std::vector<string> B(R); rep(i, R)cin >> B[i]; auto ind = [R, C](ll i, ll j){return i*C + j;}; rep(i, R){ rep(j, C){ ll cnt = 0; if(B[i][j]!='#'){ if(i-1>0 and B[i-1][j]!='#')cnt++; if(i+1<R and B[i+1][j]!='#')cnt++; if(j-1>0 and B[i][j-1]!='#')cnt++; if(j+1<C and B[i][j+1]!='#')cnt++; if(i-1>0 and B[i-1][j]!='#')A(ind(i, j), ind(i-1, j))+=1./cnt; if(i+1<R and B[i+1][j]!='#')A(ind(i, j), ind(i+1, j))+=1./cnt; if(j-1>0 and B[i][j-1]!='#')A(ind(i, j), ind(i, j-1))+=1./cnt; if(j+1<C and B[i][j+1]!='#')A(ind(i, j), ind(i, j+1))+=1./cnt; if(cnt==0)A(ind(i, j), ind(i, j))=1; } } } while(T>0){ if(T%2==1){ e = prod(A, e); } A = prod(A,A); T/=2; } //s.fi--;s.se--; //g.fi--;g.se--; cout << e(ind(s.fi, s.se), ind(g.fi, g.se))<<endl; return 0; }