답안 #559541

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
559541 2022-05-10T06:36:38 Z kappa Jetpack (COCI16_jetpack) C++14
72 / 80
1000 ms 4944 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define st first
#define nd second
#define MOD 1000000007
typedef pair<ll, ll> pii;

const ll maxn = 1e5 + 5;

vector<int> ans;

char d[15][maxn];

int n;

int dfs(int x, int y){
    if(d[x][y] == 'X'){
        return 0;
    }

    if(y == n-1){
        return 1;
    }
    if(dfs(min(9, x+1), y + 1)){
        return 1;
    }
    if(dfs(max(0, x-1), y + 1)){
        ans.pb(y);
        return 1;
    }
    return 0;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for (int j = 0; j < 10; j++)
    {
        for (int i = 0; i < n; i++)
        {
            cin >> d[j][i];
        }
    }

    dfs(9, 0);
    reverse(ans.begin(), ans.end());
    cout << ans.size() << "\n";
    for(auto i : ans){
        cout << i << " 1\n";
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 23 ms 596 KB Output is correct
7 Correct 124 ms 1156 KB Output is correct
8 Correct 359 ms 2508 KB Output is correct
9 Execution timed out 1080 ms 2252 KB Time limit exceeded
10 Correct 24 ms 4944 KB Output is correct