답안 #795979

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
795979 2023-07-28T02:43:37 Z Cookie Mobitel (COCI19_mobitel) C++14
26 / 130
1103 ms 4740 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][1505], id[mxn + 1], predp[305][1505];
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);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 3412 KB Output is correct
2 Correct 22 ms 3424 KB Output is correct
3 Incorrect 114 ms 1976 KB Output isn't correct
4 Incorrect 124 ms 2000 KB Output isn't correct
5 Incorrect 125 ms 2004 KB Output isn't correct
6 Incorrect 121 ms 2004 KB Output isn't correct
7 Incorrect 57 ms 1576 KB Output isn't correct
8 Incorrect 610 ms 3636 KB Output isn't correct
9 Incorrect 1075 ms 4696 KB Output isn't correct
10 Incorrect 1103 ms 4740 KB Output isn't correct