Submission #1120116

#TimeUsernameProblemLanguageResultExecution timeMemory
1120116Yang8onMobitel (COCI19_mobitel)C++17
26 / 130
38 ms3412 KiB
#include <bits/stdc++.h> #define Y8o "Mobitel" #define maxn (int) 305 #define ll long long #define pii pair<int, int> #define gb(i, j) ((i >> j) & 1) #define all(x) x.begin(), x.end() #define _left id * 2, l, mid #define _right id * 2 + 1, mid + 1, r #define fi(i, a, b) for(int i = a; i <= b; i ++) #define fid(i, a, b) for(int i = a; i >= b; i --) //#define f first //#define s second using namespace std; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll GetRandom(ll l, ll r) { return uniform_int_distribution<ll> (l, r) (rng); } void iof() { ios_base::sync_with_stdio(0); cin.tie(NULL), cout.tie(NULL); if(fopen(Y8o".inp", "r")) { freopen(Y8o".inp", "r", stdin); // freopen(Y8o".out", "w", stdout); } } void ctime() { cerr << "\n" << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n"; } const int mod = 1e9 + 7; void Add(int &x, int y) { x += y; if(x >= mod) x -= mod; if(x < 0) x += mod; } int m, n, k; int a[maxn][maxn], vir[2005]; int dp[2][maxn][2005]; vector<int> val; int need(int x, int y) { return (x - 1) / y + 1; } void solve() { cin >> m >> n >> k; fi(i, 1, m) fi(j, 1, n) cin >> a[i][j]; fi(x, 1, k) { int tmp = need(k, x); if(val.empty() || val.back() != tmp) { vir[tmp] = val.size(); val.push_back(tmp); } } dp[0][1][vir[k]] = 1; fi(i, 1, m) { fi(j, 1, n) { for(int pre : val) { int tmp = vir[need(pre, a[i][j])]; Add(dp[1][j][tmp], dp[0][j][vir[pre]]); Add(dp[1][j][tmp], dp[1][j - 1][vir[pre]]); } } fi(j, 1, n) { for(int pre : val) { dp[0][j][vir[pre]] = dp[1][j][vir[pre]], dp[1][j][vir[pre]] = 0; } } } cout << dp[0][n][vir[1]]; // dp[0][1][vir[k]] = 1; // fi(i, 1, m) { // fi(j, 1, n) { // for(int pre : val) { // int tmp = vir[need(pre, a[i][j])]; // Add(dp[i][j][tmp], dp[i - 1][j][vir[pre]]); // Add(dp[i][j][tmp], dp[i][j - 1][vir[pre]]); // } // } // } // cout << dp[m][n][vir[1]]; } int main() { iof(); int nTest = 1; // cin >> nTest; while(nTest --) { solve(); } ctime(); return 0; }

Compilation message (stderr)

mobitel.cpp: In function 'void iof()':
mobitel.cpp:27:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |         freopen(Y8o".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...