Submission #795978

# Submission time Handle Problem Language Result Execution time Memory
795978 2023-07-28T02:43:16 Z Cookie Mobitel (COCI19_mobitel) C++14
26 / 130
1103 ms 3556 KB
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
ifstream fin("VNOICUP.INP");
ofstream fout("VNOICUP.OUT");
#define sz(a) (int)a.size()
#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
const ld PI = 3.14159265359;
using u128 = __uint128_t;
//const int x[4] = {1, -1, 0, 0};
//const int y[4] = {0, 0, 1, -1};
const ll mod = 1e9 + 7;
const int mxn = 1e6 + 5, mxq = 2e5 + 5, sq = 400, mxv = 2e7 + 5;
//const int base = (1 << 18);
int r, s, n;
int a[505][505];
int dp[305][1005], id[mxn + 1], predp[305][1005];
int cc(int u, int v){
    return((u - 1) / v + 1);
}
void add(int &a, int b){
    a += b;
    if(a >= mod)a -= mod;
}
signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> r >> s >> n;
    for(int i = 1; i <= r; i++){
        for(int j = 1; j <= s; j++){
            cin >> a[i][j];
        }
    }
    vt<int>care;
    for(int i = 1; i <= n;){
        int cand = cc(n, i);
        id[cand] = sz(care);
        care.pb(cand);
        if(i == n)break;
        i = cc(n, cc(n, i) - 1);
    }
    dp[1][id[cc(n, a[1][1])]] = 1;
    for(int i = 1; i <= r; i++){
        for(int j = 1; j <= s; j++){
            for(int k = 0; k < sz(care); k++){
                int nwid = id[cc(care[k], a[i][j])];
                
                if(i > 1){
                    add(dp[j][nwid], predp[j][k]); 
                }if(j > 1){
                    add(dp[j][nwid], dp[j - 1][k]);
                }
                
            }
            
        }
        for(int j = 1; j <= s; j++){
            for(int k = 0; k < sz(care);  k++){
                predp[j][k] = dp[j][k]; dp[j][k] = 0;
            }
        }
    }
   
    cout << predp[s][sz(care) - 1];
    return(0);
}
# Verdict Execution time Memory Grader output
1 Correct 22 ms 3156 KB Output is correct
2 Correct 25 ms 3304 KB Output is correct
3 Incorrect 111 ms 1492 KB Output isn't correct
4 Incorrect 118 ms 1600 KB Output isn't correct
5 Incorrect 122 ms 1600 KB Output isn't correct
6 Incorrect 120 ms 1596 KB Output isn't correct
7 Incorrect 57 ms 1236 KB Output isn't correct
8 Incorrect 589 ms 2776 KB Output isn't correct
9 Incorrect 1103 ms 3540 KB Output isn't correct
10 Incorrect 1088 ms 3556 KB Output isn't correct