| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 160072 | RedNextCentury | Mobitel (COCI19_mobitel) | C++14 | 4245 ms | 10616 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll mod = 1000000007;
vector<pair<int,int> > dp[2][303];
int a[303][303];
int main()
{
    int n,m,k;
    scanf("%d%d%d",&n,&m,&k);
    k--;
    for (int i=1;i<=n;i++){
        for (int j=1;j<=m;j++) {
            scanf("%d",&a[i][j]);
        }
    }
    dp[1][1].emplace_back(k/a[1][1],1);
    for (int i=1;i<=n;i++) {
        for (int j=1;j<=m;j++) {
            if (i==1 && j==1)continue;
            if (i==1){
                for (auto x:dp[i%2][j-1]){
                    dp[i%2][j].emplace_back(x.first/a[i][j],x.second);
                }
            }
            else if (j==1){
                for (auto x:dp[(i+1)%2][j]){
                    dp[i%2][j].emplace_back(x.first/a[i][j],x.second);
                }
            }
            else {
                int l=0,r=0;
                vector<pair<int,int> >& L = dp[(i+1)%2][j];
                vector<pair<int,int> >& R = dp[i%2][j-1];
                while(l<L.size() && r<R.size()) {
                    if (L[l].first==R[r].first) {
                        dp[i%2][j].emplace_back(L[l].first/a[i][j],(L[l].second+R[r].second)%mod);
                        l++,r++;
                    } else if (L[l].first<R[r].first) {
                        dp[i%2][j].emplace_back(L[l].first/a[i][j],L[l].second);
                        l++;
                    } else {
                        dp[i%2][j].emplace_back(R[r].first/a[i][j],R[r].second);
                        r++;
                    }
                }
                while(l<L.size()) {
                    dp[i%2][j].emplace_back(L[l].first/a[i][j],L[l].second);
                    l++;
                }
                while(r<R.size()) {
                    dp[i%2][j].emplace_back(R[r].first/a[i][j],R[r].second);
                    r++;
                }
            }
            vector<pair<int, int> > tmp;
            for (auto x:dp[i % 2][j]) {
                if (tmp.empty())tmp.push_back(x);
                else if (tmp.back().first ==x.first) {
                    tmp[tmp.size() - 1].second = (tmp[tmp.size() - 1].second + x.second) % mod;
                } else {
                    tmp.push_back(x);
                }
            }
            dp[i % 2][j] = tmp;
        }
        for (int j=1;j<=m;j++) dp[(i+1)%2][j].clear();
    }
    ll ret=0;
    for (auto x:dp[n%2][m])
        if (x.first==0)
            ret = x.second;
    printf("%lld\n",ret);
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
