Submission #156233

# Submission time Handle Problem Language Result Execution time Memory
156233 2019-10-04T15:50:51 Z mdn2002 Jetpack (COCI16_jetpack) C++14
0 / 80
169 ms 15992 KB
#include<bits/stdc++.h>
using namespace std;
long long mod=1e9+7;
int n,dp[14][100005];
char gr[14][100005];
int f(int x,int y,int up)
{
    if(y==n)return true;
    if(gr[x][y]=='X')return false;
    if(dp[x][y]!=-1)return dp[x][y];
    int pos=false;
    pos=max(pos,f(max(0,x-1),y+1,1));
    pos=max(pos,f(min(9,x+1),y+1,0));
    return dp[x][y]=pos;
}
vector<int>a,b;
void dfs(int x,int y,int up,int time)
{
    if(y==n-1)
    {
        cout<<a.size()<<endl;
        if(time!=0)b.push_back(time);
        for(int i=0;i<a.size();i++)cout<<a[i]<<' '<<b[i]<<endl;
        exit(0);
    }
    int nx=max(0,x-1),ny=y+1;
    if(dp[nx][ny]==1)
    {
        if(up==1)dfs(nx,ny,1,time+1);
        else
        {
            a.push_back(y+1);
            dfs(nx,ny,1,time+1);
        }
    }
    nx=min(9,x+1),ny=y+1;
    if(dp[nx][ny]==1)
    {
        if(up==1)
        {
            b.push_back(time);
            dfs(nx,ny,0,0);
        }
        else dfs(nx,ny,0,0);
    }
}
int main()
{
    memset(dp,-1,sizeof dp);
    cin>>n;
    for(int i=0;i<10;i++)
    {
        for(int j=0;j<n;j++)cin>>gr[i][j];
    }
    f(9,0,0);
    dfs(9,0,0,0);
}

Compilation message

jetpack.cpp: In function 'void dfs(int, int, int, int)':
jetpack.cpp:23:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i=0;i<a.size();i++)cout<<a[i]<<' '<<b[i]<<endl;
                     ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 5880 KB Crashed with an obstacle
2 Incorrect 7 ms 5880 KB Crashed with an obstacle
3 Incorrect 7 ms 5880 KB Crashed with an obstacle
4 Incorrect 8 ms 5880 KB Crashed with an obstacle
5 Incorrect 14 ms 6268 KB Crashed with an obstacle
6 Incorrect 15 ms 6392 KB Crashed with an obstacle
7 Incorrect 34 ms 7800 KB Crashed with an obstacle
8 Incorrect 75 ms 10616 KB Crashed with an obstacle
9 Incorrect 114 ms 13036 KB Crashed with an obstacle
10 Incorrect 169 ms 15992 KB Crashed with an obstacle