답안 #316199

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
316199 2020-10-25T17:00:46 Z fcmalkcin Mobitel (COCI19_mobitel) C++17
52 / 130
1530 ms 10136 KB
// I_Love_LPL
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
const int N = 305;
const int mod = 1e9 + 7;
ll dp[2][N][2][1005];
void add(ll &x, ll y){
    x += y;
    if (x >= mod) x -= mod;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    if (fopen("A.inp", "r")){
        freopen("test.inp", "r", stdin);
        freopen("test.out", "w", stdout);
    }
    ll r, s, n;
    cin >> r >> s >> n;
    ll c = sqrt(n);
    dp[0][1][0][1] = 1;
    for (int i = 1; i <= r; i++){
        for (int j = 1; j <= s; j++){
            ll x;
            cin >> x;
            // add to small
            for (int k = 1; k <= c; k++){
                ll p = k * x;
                if (p < c){
                    add(dp[i & 1][j][0][p], dp[(i + 1) & 1][j][0][k]);
                    add(dp[i & 1][j][0][p], dp[i & 1][j - 1][0][k]);
                } else {
                    add(dp[i & 1][j][1][(n - 1) / p + 1], dp[(i + 1) & 1][j][0][k]);
                    add(dp[i & 1][j][1][(n - 1) / p + 1], dp[i & 1][j - 1][0][k]);
                }
            }
            // add to big
            for (int k = 1; k <= c; k++){
                add(dp[i & 1][j][1][(k - 1) / x + 1], dp[(i + 1) & 1][j][1][k]);
                add(dp[i & 1][j][1][(k - 1) / x + 1], dp[i & 1][j - 1][1][k]);
            }
        }
        for (int j = 1; j <= s; j++){
            for (int k = 1; k <= c; k++){
                dp[(i + 1) & 1][j][0][k] = 0;
                dp[(i + 1) & 1][j][1][k] = 0;
            }
        }
    }
    cout << dp[r & 1][s][1][1];
}
/*
*/

Compilation message

mobitel.cpp: In function 'int main()':
mobitel.cpp:17:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   17 |         freopen("test.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
mobitel.cpp:18:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   18 |         freopen("test.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 36 ms 5504 KB Output isn't correct
2 Incorrect 37 ms 5504 KB Output isn't correct
3 Correct 120 ms 3576 KB Output is correct
4 Correct 125 ms 3456 KB Output is correct
5 Incorrect 144 ms 3704 KB Output isn't correct
6 Incorrect 140 ms 3456 KB Output isn't correct
7 Correct 63 ms 2616 KB Output is correct
8 Incorrect 783 ms 7464 KB Output isn't correct
9 Incorrect 1499 ms 9848 KB Output isn't correct
10 Correct 1530 ms 10136 KB Output is correct