# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
795978 | Cookie | Mobitel (COCI19_mobitel) | C++14 | 1103 ms | 3556 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|---|---|---|---|
Fetching results... |