結果
問題 | No.1916 Making Palindrome on Gird |
ユーザー | cureskol |
提出日時 | 2022-04-29 22:18:21 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,424 bytes |
コンパイル時間 | 2,231 ms |
コンパイル使用メモリ | 191,776 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-29 03:51:13 |
合計ジャッジ時間 | 25,749 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | WA | - |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 3 ms
5,376 KB |
testcase_09 | WA | - |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 184 ms
5,376 KB |
testcase_15 | WA | - |
testcase_16 | AC | 339 ms
5,376 KB |
testcase_17 | AC | 1,159 ms
5,376 KB |
testcase_18 | AC | 1,467 ms
5,376 KB |
testcase_19 | AC | 1,467 ms
5,376 KB |
testcase_20 | AC | 1,470 ms
5,376 KB |
testcase_21 | AC | 1,472 ms
5,376 KB |
testcase_22 | AC | 1,462 ms
5,376 KB |
testcase_23 | AC | 1,238 ms
5,376 KB |
testcase_24 | AC | 1,237 ms
5,376 KB |
testcase_25 | AC | 1,238 ms
5,376 KB |
testcase_26 | AC | 1,258 ms
5,376 KB |
testcase_27 | AC | 2 ms
5,376 KB |
testcase_28 | AC | 1,698 ms
5,376 KB |
testcase_29 | AC | 1,701 ms
5,376 KB |
testcase_30 | AC | 1,705 ms
5,376 KB |
testcase_31 | AC | 1,705 ms
5,376 KB |
testcase_32 | AC | 1,701 ms
5,376 KB |
コンパイルメッセージ
main.cpp:30:3: warning: inline variables are only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 30 | inline static constexpr T mod = MOD; | ^~~~~~ main.cpp: In function 'int main()': main.cpp:113:20: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 113 | for(const auto&[key,val]:mp){ | ^ main.cpp:114:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 114 | const auto&[y1,y2] = key; | ^ main.cpp:129:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 129 | for(const auto&[key,val]:mp) | ^
ソースコード
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int i=0;i<(n);i++) #define ALL(v) v.begin(),v.end() #define debug(a) cerr<<#a<<":"<<a<<endl; #define debug2(a,b) cerr<<"("<<#a<<","<<#b<<"):("<<a<<","<<b<<")"<<endl; #define debug3(a,b,c) cerr<<"("<<#a<<","<<#b<<","<<#c<<"):("<<a<<","<<b<<","<<c<<")"<<endl; #define debug4(a,b,c,d) cerr<<"("<<#a<<","<<#b<<","<<#c<<","<<#d<<"):("<<a<<","<<b<<","<<c<<","<<d<<")"<<endl; template<typename T> istream& operator>>(istream&is,vector<T>&v){ for(T&p:v)is>>p; return is; } template<typename T> ostream& operator<<(ostream&os,const vector<T>&v){ if(&os==&cerr)os<<"["; for(int i=0;i<v.size();i++){ os<<v[i]; if(i+1<v.size())os<<(&os==&cerr?",":" "); } if(&os==&cerr)os<<"]"; return os; } template<typename T,T MOD=998244353> struct Mint{ inline static constexpr T mod = MOD; T v; Mint():v(0){} Mint(signed v):v(v){} Mint(long long t){v=t%MOD;if(v<0)v+=MOD;} Mint pow(long long k){ Mint res(1),tmp(v); while(k){ if(k&1)res*=tmp; tmp*=tmp; k>>=1; } return res; } static Mint add_identity(){return Mint(0);} static Mint mul_identity(){return Mint(1);} Mint inv(){return pow(MOD-2);} Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;} Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;} Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;} Mint& operator/=(Mint a){return (*this)*=a.inv();} Mint operator+(Mint a) const{return Mint(v)+=a;} Mint operator-(Mint a) const{return Mint(v)-=a;} Mint operator*(Mint a) const{return Mint(v)*=a;} Mint operator/(Mint a) const{return Mint(v)/=a;} Mint operator+() const{return *this;} Mint operator-() const{return v?Mint(MOD-v):Mint(v);} bool operator==(const Mint a)const{return v==a.v;} bool operator!=(const Mint a)const{return v!=a.v;} static Mint comb(long long n,int k){ Mint num(1),dom(1); for(int i=0;i<k;i++){ num*=Mint(n-i); dom*=Mint(i+1); } return num/dom; } friend ostream& operator<<(ostream&os,const Mint &m){os<<m.v;return os;} friend istream& operator>>(istream&is,Mint &m){is>>m.v;m.v%=MOD;if(m.v<0)m.v+=MOD;return is;} }; using mint=Mint<long long,1000000007>; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int h,w;cin>>h>>w; vector<string> s(h); cin>>s; map<pair<int,int>,mint> mp; int a=-1,b=-1; if((h+w-1)&1) REP(i,h)REP(j,w)if((i+1+j+1-1)*2-1 == h+w-1){ mp[{i,i}]=1; a=i+j,b=i+j; } else REP(i,h)REP(j,w)if((i+1+j+1-1)*2 == h+w-1){ if(i+1<h and s[i+1][j]==s[i][j])mp[{i,i+1}]=1; if(j+1<w and s[i][j+1]==s[i][j])mp[{i,j+1}]=1; a=i+j,b=i+j+1; } if(a<0 and b<0){ cout<<0<<endl; return 0; } while(a){ map<pair<int,int>,mint> nxt; for(const auto&[key,val]:mp){ const auto&[y1,y2] = key; int x1=a-y1; int x2=b-y2; //debug4(y1,x1,y2,x2); //debug(val); if(x1 and x2+1<w and s[y1][x1-1]==s[y2][x2+1])nxt[{y1,y2}]+=val; if(x1 and y2+1<h and s[y1][x1-1]==s[y2+1][x2])nxt[{y1,y2+1}]+=val; if(y1 and x2+1<w and s[y1-1][x1]==s[y2][x2+1])nxt[{y1-1,y2}]+=val; if(y1 and y2+1<h and s[y1-1][x1]==s[y2+1][x2])nxt[{y1-1,y2+1}]+=val; } mp=nxt; a--;b++; } mint ans=0; for(const auto&[key,val]:mp) ans+=val; cout<<ans<<endl; }