update
This commit is contained in:
		
							parent
							
								
									211c7ea96b
								
							
						
					
					
						commit
						3d9398ff69
					
				| @ -19,6 +19,28 @@ ostream&operator<<(ostream &os,const pair<T,P> &p){ | ||||
|     return os; | ||||
| } | ||||
| 
 | ||||
| // ostream&operator<<(ostream&os,ll num){
 | ||||
| //     if(num<0){
 | ||||
| //         cout<<'-';
 | ||||
| //         num=-num;
 | ||||
| //     }
 | ||||
| //     string str;
 | ||||
| //     while(num!=0){
 | ||||
| //         str=str+char(int(num%10)+'0');
 | ||||
| //         num/=10;
 | ||||
| //     }
 | ||||
| //     reverse(str.begin(),str.end());
 | ||||
| //     cout<<str;
 | ||||
| //     return os;
 | ||||
| // }
 | ||||
| 
 | ||||
| // istream&operator>>(istream &is,ll &num){
 | ||||
| //     int64_t tmp;
 | ||||
| //     cin>>tmp;
 | ||||
| //     num=tmp;
 | ||||
| //     return is;
 | ||||
| // }
 | ||||
| 
 | ||||
| void pnm(const ll (&a)[maxn][maxn]){ | ||||
|     for(ll i{1};i<=n;i++){ | ||||
|         cout<<"[DEBUG] "; | ||||
| @ -30,11 +52,35 @@ void pnm(const ll (&a)[maxn][maxn]){ | ||||
|     cout<<'\n'; | ||||
| } | ||||
| 
 | ||||
| template<class T> | ||||
| void clear(T (&a)[maxn][maxn]){ | ||||
|     for(ll i{0};i<=n+1;i++){ | ||||
|         for(ll j{0};j<=m+1;j++){ | ||||
|             a[i][j]=0; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| // template<class T>
 | ||||
| // void clear(T &a){
 | ||||
| //     for(ll i{0};i<=n+1;i++){
 | ||||
| //         for(ll j{0};j<=m+1;j++){
 | ||||
| //             a[i][j]=0;
 | ||||
| //         }
 | ||||
| //     }
 | ||||
| // }
 | ||||
| template<class T,class ...Args> | ||||
| void clear(T&&t,Args&&...args){ | ||||
|     clear(t); | ||||
|     clear(args...); | ||||
| } | ||||
| 
 | ||||
| int main(){ | ||||
|     iostream::sync_with_stdio(0),cin.tie(0),cout.tie(0); | ||||
| 
 | ||||
|     cin>>t>>id; | ||||
|     while(t--){ | ||||
|         clear(tor,tou,ptor,tod); | ||||
|         cin>>n>>m>>c>>f; | ||||
|         totc=0; | ||||
|         totf=0; | ||||
| @ -49,7 +95,7 @@ int main(){ | ||||
| 
 | ||||
|         // look right
 | ||||
|         for(ll i{1};i<=n;i++){ | ||||
|             tor[i][m+1]=0; | ||||
|             // tor[i][m+1]=0;
 | ||||
|             for(ll j{m};j>=0;j--){ | ||||
|                 if(g[i][j]){ | ||||
|                     tor[i][j]=0; | ||||
| @ -65,7 +111,7 @@ int main(){ | ||||
| 
 | ||||
|         //look up
 | ||||
|         for(ll j{1};j<=m;j++){ | ||||
|             tou[0][j]=0; | ||||
|             // tou[0][j]=0;
 | ||||
|             for(ll i{1};i<=n;i++){ | ||||
|                 if(g[i][j]){ | ||||
|                     tou[i][j]=0; | ||||
| @ -77,9 +123,9 @@ int main(){ | ||||
|         // pnm(tou);
 | ||||
| 
 | ||||
|         //look down
 | ||||
|         for(ll j{1};j<=m;j++){ | ||||
|             tod[n+1][j]=0; | ||||
|         } | ||||
|         // for(ll j{1};j<=m;j++){
 | ||||
|         //     tod[n+1][j]=0;
 | ||||
|         // }
 | ||||
|         for(ll i{n};i>=0;i--){ | ||||
|             for(ll j{1};j<=m;j++){ | ||||
|                 if(g[i][j]){ | ||||
| @ -99,12 +145,12 @@ int main(){ | ||||
|                     // cout<<make_pair(i,j)<<'\n';
 | ||||
|                     totc = (totc+(ptor[i-2][j]*(tor[i][j]-1))%mod)%mod; | ||||
|                     if(tod[i][j]-1>0){ | ||||
|                         totf = (totf+(ptor[i-1][j]*(tor[i][j]-1)*(tod[i][j]-1))%mod)%mod; | ||||
|                         totf = (totf+(((ptor[i-1][j]*(tor[i][j]-1))%mod)*(tod[i][j]-1))%mod)%mod; | ||||
|                     } | ||||
|                     // pt(totc,totf);
 | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         cout<<totc<<' '<<totf<<'\n'; | ||||
|         cout<<(c*totc)%mod<<' '<<(f*totf)%mod<<'\n'; | ||||
|     } | ||||
| } | ||||
| @ -1,6 +1,19 @@ | ||||
| 1 0 | ||||
| 3 0 | ||||
| 4 3 1 1 | ||||
| 001 | ||||
| 010 | ||||
| 000 | ||||
| 000 | ||||
| 4 3 1 1 | ||||
| 001 | ||||
| 010 | ||||
| 000 | ||||
| 000 | ||||
| 1 0 | ||||
| 6 6 1 1 | ||||
| 000010 | ||||
| 011000 | ||||
| 000110 | ||||
| 010000 | ||||
| 011000 | ||||
| 000000 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user