Submission #165663

# Submission time Handle Problem Language Result Execution time Memory
165663 2019-11-28T06:43:58 Z egekabas Jetpack (COCI16_jetpack) C++14
0 / 80
33 ms 11764 KB
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long   ll;
typedef unsigned long long   ull;
typedef long double ld;
typedef pair<ll, ll>    pll;
typedef pair<ull, ull>    pull;
typedef pair<ll, ll>  pii;
typedef pair<ld, ld>  pld;
ll n;
string fi[10];
ll dp[10][200009];
ll boost[200009];
vector<pll> ans;
void func(ll i, ll j){
    //cout << i << " " << j << "\n";
    if(i == 0)
        return;
    if(j != 0 &&  dp[j-1][i-1] == 1){
        func(i-1, j-1);
    }
    else if(j == 0 && dp[j][i-1] == 1){
        boost[i-1] = 1;
        func(i-1, j);
    }
    else if(j != 9 && dp[j+1][i-1] == 1){
        boost[i-1] = 1;
        func(i-1, j+1); 
    }
    else if(j == 9 && dp[j][i-1] == 1){
        func(i-1, j);
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    cin >> n;
    for(ll i = 0; i < 10; ++i)
        cin >> fi[i];
    dp[9][0] = 1;
    for(ll i = 0; i < n; ++i){
        for(ll j = 0; j < 10; ++j){
            if(fi[j][i] == 'X')
                dp[j][i] = 0;
            if(dp[j][i] == 0)
                continue;
            if(j != 9)
                dp[j+1][i+1] = 1;
            else
                dp[j][i+1] = 1;
            if(j != 0)
                dp[j-1][i+1] = 1;
            else
                dp[j][i+1] = 1;
        }
    }
    for(ll j = 0; j < 10; ++j)
        if(dp[j][n-1] == 1)
            func(n-1, j);

    ll last = -1;
    for(ll i = 0; i < n; ++i){
        //cout << i << " " << boost[i] << "\n";
        if(last != -1 && boost[i] == 0){
            ans.pb({last, i-last+1});
            last = -1;
        }
        else if(last == -1 && boost[i] == 1){
            last = i+1;
        }
    }
    cout << ans.size() << "\n";
    for(auto u : ans)
        cout << u.ff << " " << u.ss << "\n";
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Crashed with an obstacle
2 Incorrect 2 ms 376 KB Crashed with an obstacle
3 Incorrect 2 ms 420 KB Crashed with an obstacle
4 Incorrect 2 ms 504 KB Crashed with an obstacle
5 Incorrect 3 ms 912 KB Crashed with an obstacle
6 Incorrect 4 ms 1116 KB Crashed with an obstacle
7 Incorrect 7 ms 2556 KB Crashed with an obstacle
8 Incorrect 13 ms 5752 KB Crashed with an obstacle
9 Incorrect 22 ms 8680 KB Crashed with an obstacle
10 Incorrect 33 ms 11764 KB Crashed with an obstacle