Submission #600668

# Submission time Handle Problem Language Result Execution time Memory
600668 2022-07-21T06:49:27 Z 장태환(#8468) JOI15_building3 (JOI15_building3) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
int dp[1000100][3];
int ma[1000100];
vector<int>x;
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >>N;
    int i;
    for(i=1;i<N;i++)
    {
        int a;
        cin >>a;
        x.push_back(a);
    }
    x.push_back(0);
    dp[0][0]=1;
    if(x[0]>2)
    {
        cout <<0;
        return 0;
    }
    for(i=0;i<N;i++)
    {
        ma[i+1]=max(ma[i],x[i]);
    }
    for(i=1;i<=N;i++)
    {
        if(ma[i-1]+1>=x[i-1])
        {
            dp[i][0]=dp[i-1][0];
            dp[i][2]+=dp[i-1][0];
            dp[i][1]+=(ma[i-1]-1)*dp[i-1][0];
            if(ma[i-1]+1==x[i-1])
            {
                dp[i][2]-=dp[i-1][0];
                dp[i][1]+=dp[i-1][0];
            }
        }
        else
        {
            if(ma[i-1]+2>=x[i-1])
            {
                dp[i][2]=dp[i-1][0];
            }
            else
            {
                cout <<0;
                return 0;
            }
        }
        else
        {
            if(ma[i-2]+1>=x[i-2])
            {
                dp[i][1]+=dp[i-1][1];
            }
            if(ma[i-2]+2>=x[i-2])
            {
                if(ma[i-2]+1<=ma[i-1])
                    dp[i][1]+=dp[i-1][2];
                else
                    dp[i][2]+=dp[i-1][2];
            }
        }
    }
    cout <<dp[N][1]+dp[N][2]+dp[N][0];
}

Compilation message

building3.cpp: In function 'int main()':
building3.cpp:56:9: error: 'else' without a previous 'if'
   56 |         else
      |         ^~~~