Submission #165664

# Submission time Handle Problem Language Result Execution time Memory
165664 2019-11-28T06:50:53 Z egekabas Jetpack (COCI16_jetpack) C++14
40 / 80
32 ms 10792 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){
    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});
            last = -1;
        }
        else if(last == -1 && boost[i] == 1){
            last = i;
        }
    }
    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 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 376 KB Crashed with an obstacle
4 Correct 4 ms 504 KB Output is correct
5 Correct 3 ms 888 KB Output is correct
6 Correct 3 ms 1016 KB Output is correct
7 Incorrect 7 ms 2424 KB Crashed with an obstacle
8 Correct 13 ms 5240 KB Output is correct
9 Incorrect 20 ms 7800 KB Crashed with an obstacle
10 Incorrect 32 ms 10792 KB Crashed with an obstacle