Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define ll long long
- #define MOD 1000000007
- using namespace std;
- void solve(){
- int n, m, k;
- cin>>n>>m>>k;
- vector<vector<int>> dp(n, vector<int>(m, 1));
- for(int i=1;i<n;i++){
- for(int j=1;j<m;j++){
- dp[i][j] = (dp[i-1][j] + dp[i][j-1])%MOD;
- }
- }
- ll res = 0;
- int x,y,p;
- while(k--){
- cin>>x>>y>>p;
- res = (res + dp[x-1][y-1]*p)%MOD;
- }
- cout<<res<<endl;
- }
- signed main() {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- int t;
- cin>>t;
- while(t--)
- solve();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement