結果
問題 | No.179 塗り分け |
ユーザー | ytqm3 |
提出日時 | 2021-11-19 20:01:03 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 9,935 bytes |
コンパイル時間 | 2,382 ms |
コンパイル使用メモリ | 220,648 KB |
実行使用メモリ | 10,400 KB |
最終ジャッジ日時 | 2024-06-10 05:32:34 |
合計ジャッジ時間 | 7,962 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
10,400 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 1 ms
5,376 KB |
testcase_05 | AC | 529 ms
5,376 KB |
testcase_06 | AC | 10 ms
5,376 KB |
testcase_07 | WA | - |
testcase_08 | AC | 5 ms
5,376 KB |
testcase_09 | AC | 5 ms
5,376 KB |
testcase_10 | AC | 127 ms
5,376 KB |
testcase_11 | AC | 103 ms
5,376 KB |
testcase_12 | TLE | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
testcase_43 | -- | - |
testcase_44 | -- | - |
testcase_45 | -- | - |
ソースコード
#include<bits/stdc++.h> typedef uint64_t u64; typedef int64_t i64; using namespace std; void solve(); int main(){ cout<<fixed<<setprecision(15); bool is_multicase=false; int T=1; if(is_multicase){ cin>>T; } for(int i=0;i<T;++i){ solve(); } return 0; } template<typename T> void turtle_in(T& n){ cin>>n; } template<typename T,typename U> void turtle_in(pair<T,U>& p){ turtle_in(p.first); turtle_in(p.second); } template<typename T> void turtle_in(vector<T>& v){ for(auto& u:v){ turtle_in(u); } } template<typename T> void turtle_out(T& n){ cout<<n; } template<typename T,typename U> void turtle_out(pair<T,U>& p){ cout<<"{"; turtle_out(p.first); cout<<", "; turtle_out(p.second); cout<<"}"; } template<typename T> void turtle_out(vector<T>& v){ for(int i=0;i<int(v.size());++i){ turtle_out(v[i]); if(i!=v.size()-1){ cout<<" "; } } cout<<endl; } template<typename T> void turtle_out(vector<vector<T>>& v){ for(int i=0;i<int(v.size());++i){ turtle_out(v[i]); } } void scan(){} template<typename T,class... Args> void scan(T& n,Args&... args){ turtle_in(n); scan(args...); } void print(){} template<typename T,class... Args> void print(T n,Args... args){ turtle_out(n); print(args...); } template<typename T> void println(T n){ turtle_out(n); cout<<endl; } template<typename T,class... Args> void println(T n,Args... args){ turtle_out(n); cout<<" "; println(args...); } template<u64 mod> struct modint{ u64 val; modint(i64 val_=0):val((val_%i64(mod)+i64(mod))%i64(mod)){} modint operator-(){ return modint(mod-val); } modint operator+(modint rhs){ return modint(*this)+=rhs; } modint operator-(modint rhs){ return modint(*this)-=rhs; } modint operator*(modint rhs){ return modint(*this)*=rhs; } modint operator/(modint rhs){ return modint(*this)/=rhs; } modint &operator+=(modint rhs){ val+=rhs.val; val-=((val>=mod)?mod:0); return (*this); } modint &operator-=(modint rhs){ val+=((val<rhs.val)?mod:0); val-=rhs.val; return (*this); } modint &operator*=(modint rhs){ val=val*rhs.val%mod; return (*this); } modint &operator/=(modint rhs){ u64 ex=mod-2; modint now=1; while(ex){ now*=((ex&1)?rhs:1); rhs*=rhs,ex>>=1; } return (*this)*=now; } bool operator==(modint rhs){ return val==rhs.val; } bool operator!=(modint rhs){ return val!=rhs.val; } friend std::ostream &operator<<(std::ostream& os,modint x){ return os<<(x.val); } friend std::istream &operator>>(std::istream& is,modint& x){ u64 t; is>>t,x=t; return is; } }; template<typename T,typename U> T power(T a,U n){ T res=1; while(n>0){ if(n%2==1){ res*=a; } a*=a; n/=2; } return res; } template<typename T> struct genrand{ uniform_int_distribution<T> gen; mt19937 engine; genrand(T a,T b):gen(a,b){ random_device seed_gen; engine.seed(seed_gen()); } T operator()(){ return gen(engine); } }; template<typename T> struct comb{ vector<T> dat,idat; comb(int mx=3000000):dat(mx+1,1),idat(mx+1,1){ for(int i=1;i<=mx;++i){ dat[i]=dat[i-1]*i; } idat[mx]/=dat[mx]; for(int i=mx;i>0;--i){ idat[i-1]=idat[i]*i; } } T operator()(int n,int k){ if(n<0||k<0||n<k){ return 0; } return dat[n]*idat[k]*idat[n-k]; } }; template<u64 mod> struct NTT{ typedef modint<mod> mint; mint g=getg_(); vector<int> rev; mint getg_(){ for(mint i=2;;i+=1){ if(power_(i,(mod-1)>>1)!=1){ return i; } } } mint power_(mint a,u64 n){ mint res=1; while(n){ res*=((n&1)?a:1); a*=a; n>>=1; } return res; } void dft(vector<mint>& f){ int siz=f.size(); for(int i=0;i<siz;++i){ if(i<rev[i]){ swap(f[i],f[rev[i]]); } } for(int b=1;b<siz;b<<=1){ mint now=1,zeta=power_(g,(mod-1)/(2*b)); for(int j=0;j<b;++j){ for(int k=0;k<siz;k+=2*b){ mint s=f[k+j],t=f[k+j+b]*now; f[k+j]=s+t,f[k+j+b]=s-t; } now*=zeta; } } } vector<mint> operator()(vector<mint> a,vector<mint> b){ int cnt=0,siz=1,mxsiz=a.size()+b.size()-1; while(siz<mxsiz){ siz<<=1,++cnt; } rev.resize(siz); for(uint32_t i=0;i<siz;++i){ rev[i]=(rev[i>>1]>>1)+(1<<cnt-1)*(i&1); } a.resize(siz),b.resize(siz); dft(a),dft(b); for(int i=0;i<siz;++i){ a[i]*=b[i]; } dft(a); reverse(a.begin()+1,a.end()); mint isiz=mint(1)/siz; for(int i=0;i<siz;++i){ a[i]*=isiz; } rev.resize(0); a.resize(mxsiz); return a; } }; template<u64 mod> struct Poly{ typedef modint<mod> mint; NTT<mod> ntt; vector<mint> val; Poly():val({0}){} Poly(mint t):val({t}){} Poly(int siz):val(max(1,siz)){} Poly(initializer_list<modint<mod>> init):val(init){} Poly(vector<mint> init):val(init){} mint &operator[](int i){ return val[i]; } int size(){ return val.size(); } void resize(int siz){ val.resize(siz); } Poly operator+(Poly rhs){ return Poly(*this)+=rhs; } Poly operator-(Poly rhs){ return Poly(*this)-=rhs; } Poly operator*(Poly rhs){ return Poly(*this)*=rhs; } Poly operator/(Poly rhs){ return Poly(*this)/=rhs; } Poly operator%(Poly rhs){ return Poly(*this)%=rhs; } Poly operator-(){ for(mint& v:val){ v=mint(0)-v; } return (*this); } Poly operator+=(Poly rhs){ resize(max(this->size(),rhs.size())); for(int i=0;i<int(rhs.size());++i){ (*this)[i]+=rhs[i]; } shrink(); return (*this); } Poly operator-=(Poly rhs){ resize(max(this->size(),rhs.size())); for(int i=0;i<int(rhs.size());++i){ (*this)[i]-=rhs[i]; } shrink(); return (*this); } Poly operator*=(Poly rhs){ val=ntt(val,rhs.val); return (*this); } Poly operator/=(Poly rhs){ if(val.size()<rhs.size()){ val.resize(0); return (*this); } int rsiz=val.size()-rhs.size()+1; reverse(val.begin(),val.end()); reverse(rhs.val.begin(),rhs.val.end()); val.resize(rsiz),rhs.inv(rsiz); (*this)*=rhs; val.resize(rsiz); reverse(val.begin(),val.end()); return (*this); } Poly operator%=(Poly rhs){ if(val.size()<rhs.size()){ return (*this); } (*this)-=(*this)/rhs*rhs; val.resize(rhs.size()-1); shrink(); return (*this); } mint eval(mint a){ mint t=1,res=0; int n=(*this).size(); for(int i=0;i<n;++i){ res+=val[i]*t; t*=a; } return res; } void diffrent(){ Poly f(val.size()-1); for(int i=1;i<val.size();++i){ f[i-1]=val[i]*i; } (*this)=f; } void integral(){ Poly f(val.size()+1); for(int i=0;i<val.size();++i){ f[i+1]=val[i]/(i+1); } (*this)=f; } void inv(int mx){ Poly g({mint(1)/val[0]}); int now=1; while(now<mx){ now<<=1; Poly t=(*this); t.resize(now); t*=g,t=-t; t[0]+=2,g*=t; g.resize(now); } g.resize(mx); (*this)=g; } void shrink(){ for(int i=val.size()-1;i>0;--i){ if(val[i]==0){ val.pop_back(); } else{ return; } } } vector<mint> multieval(vector<modint<mod>> a){ int siz=1; while(siz<int(a.size())){ siz<<=1; } vector<Poly<mod>> t(siz*2-1,{1}); for(int i=0;i<int(a.size());++i){ t[i+siz-1]={-a[i],1}; } for(int i=siz-2;i>=0;--i){ t[i]=t[2*i+1]*t[2*i+2]; } vector<Poly<mod>> g(siz*2-1); g[0]=(*this)%t[0]; for(int i=1;i<siz*2-1;++i){ g[i]=g[(i-1)/2]%t[i]; } vector<modint<mod>> res(a.size()); for(int i=0;i<int(a.size());++i){ res[i]=g[i+siz-1][0]; } return res; } void product(vector<Poly<mod>> a){ int siz=1; while(siz<int(a.size())){ siz<<=1; } vector<Poly<mod>> res(siz*2-1,{1}); for(int i=0;i<int(a.size());++i){ res[i+siz-1]=a[i]; } for(int i=siz-2;i>=0;--i){ res[i]=res[2*i+1]*res[2*i+2]; } (*this)=res[0]; } void lagrange_interpolation(vector<mint> x,vector<mint> y){ int N=x.size(); vector<Poly<mod>> h(N); for(int i=0;i<N;++i){ h[i]={-x[i],1}; } Poly<mod> g; g.product(h); Poly<mod> g_=g; g_.diffrent(); vector<mint> t=g_.multieval(x); for(int i=0;i<N;++i){ t[i]=y[i]/t[i]; } vector<Poly<mod>> den(2*N-1),num(2*N-1,{1}); for(int i=0;i<N;++i){ den[i+N-1]={-x[i],1}; num[i+N-1]={t[i]}; } for(int i=N-2;i>=0;--i){ den[i]=den[2*i+1]*den[2*i+2]; num[i]=num[2*i+1]*den[2*i+2]+num[2*i+2]*den[2*i+1]; } (*this)=num[0]; } }; void solve(){ int H,W; scan(H,W); vector<string> S(H); scan(S); set<pair<int,int>> all; for(int i=0;i<H;++i){ for(int j=0;j<W;++j){ if(S[i][j]=='#'){ all.insert({i,j}); } } } for(int I=0;I<=H-1;++I){ for(int J=-W+1;J<=W-1;++J){ if(I==0 && J==0){ continue; } set<pair<int,int>> st=all; vector<vector<int>> tmp; while(st.size()){ auto p=(*st.begin()); st.erase(st.begin()); tmp.emplace_back(); tmp.back().emplace_back(0); for(int t=-50;t<=50;++t){ if(st.count({p.first+I*t,p.second+J*t})){ st.erase({p.first+I*t,p.second+J*t}); tmp.back().emplace_back(t); } } } bool f=1; for(auto v:tmp){ while(2<=v.size()){ int n=v.size(); if(v[n-2]+1==v[n-1]){ v.resize(n-2); } else{ break; } } if(v.size()!=0){ f=0; } } if(f){ println("YES"); return; } } } println("NO"); }