답안 #159886

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
159886 2019-10-25T09:34:20 Z mdn2002 Mobitel (COCI19_mobitel) C++14
0 / 130
6000 ms 25296 KB
#include<bits/stdc++.h>
using namespace std;
int mod=1e9+7;
int r,c,n,a[303][303],dp[303][303][303],all[303][303];
int f(int x,int y,int p)
{
    if(p>=n)return all[x][y];
    if(x==r-1&&y==c-1)return 0;
    if(x>=r||y>=c)return 0;
    if(dp[x][y][p]!=1)return 0;
    long long ans=0;
    ans+=f(x+1,y,p*a[x+1][y]);
    ans%=mod;
    ans+=f(x,y+1,p*a[x][y+1]);
    ans%=mod;
    return ans;
}
bool fuck(int x,int y,int p)
{
    cout<<' '<<x<<' '<<y<<' '<<p<<endl;
    if(p>=n)return 1;
    if(x==r-1&&y==c-1)return 0;
    bool t=false;
    if(x!=r-1)t=max(t,fuck(x+1,y,p*a[x+1][y]));
    if(y!=c-1)t=max(t,fuck(x,y+1,p*a[x][y+1]));
    return dp[x][y][p]=t;
}
int d(int x,int y)
{
    if(x==r-1&&y==c-1)return all[x][y]=1;
    if(x>=r||y>=c)return 0;
    if(all[x][y]!=-1)return all[x][y];
    long long ans=0;
    ans+=d(x+1,y);
    ans+=d(x,y+1);
    return all[x][y]=ans;
}
int main()
{
    memset(all,-1,sizeof all);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>r>>c>>n;
    for(int i=0;i<r;i++)
    {
        for(int j=0;j<c;j++)scanf("%d",&a[i][j]);
    }
    fuck(0,0,a[0][0]);
    d(0,0);
    cout<<f(0,0,a[0][0]);
}

Compilation message

mobitel.cpp: In function 'bool fuck(int, int, int)':
mobitel.cpp:26:23: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
     return dp[x][y][p]=t;
            ~~~~~~~~~~~^~
mobitel.cpp: In function 'int main()':
mobitel.cpp:47:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         for(int j=0;j<c;j++)scanf("%d",&a[i][j]);
                             ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 6084 ms 24572 KB Time limit exceeded
2 Execution timed out 6078 ms 25296 KB Time limit exceeded
3 Execution timed out 6052 ms 20488 KB Time limit exceeded
4 Execution timed out 6042 ms 18972 KB Time limit exceeded
5 Execution timed out 6058 ms 19596 KB Time limit exceeded
6 Execution timed out 6018 ms 19948 KB Time limit exceeded
7 Execution timed out 6058 ms 19704 KB Time limit exceeded
8 Execution timed out 6092 ms 25056 KB Time limit exceeded
9 Execution timed out 6083 ms 25224 KB Time limit exceeded
10 Execution timed out 6092 ms 25152 KB Time limit exceeded