답안 #165398

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
165398 2019-11-26T20:48:17 Z sans Jetpack (COCI16_jetpack) C++14
16 / 80
26 ms 860 KB
#include <iostream>
#include <numeric>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

#define sp ' '
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define forn(YY, yy) for(long long int yy = 0; yy < YY; ++yy)
#define prn(XX) cout << XX << endl
#define prs(XX) cout << XX << " "

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;

const int MOD = 1e9 + 7;
const int INF = 2e9 + 13;
const int mINF = -2e9 - 13;
const double PI = 3.14159265358979;
const double EPS = 1e-9;


#define UC   1
#define DUS  2
#define YURU 3
#define TAVAN 4

vector<vector<bool>> field; int N;
vector<pair<int, int>> ans;

bool oldu = false;
void simulate(int r, int c, int t, int x, int Mode, int timer){
    if(field[r][c]) return;
    if(c == N){ oldu = true; if(Mode == UC) ans.pb(mp(t, x)); return; }

    if(r <= 0){
        simulate(r, c+1, t, x+1, UC, timer+1);
        if(oldu) return;

        ans.pb(mp(t, x));
        simulate(r+1, c+1, -1, -1, DUS, timer+1); if(!oldu) ans.pop_back();
        
        return; 
    }

    if(Mode == UC){
        simulate(r-1, c+1, t, x+1, UC, timer+1);
        if(oldu) return;
        
        ans.pb(mp(t, x));
        simulate(r+1, c+1, -1, -1, DUS, timer+1);
        if(oldu) return;
    }
    if(Mode == DUS){
        simulate(r+1, c+1, -1, -1, DUS, timer+1);
        if(oldu) return;

        simulate(r-1, c+1, timer, 1, UC, timer+1);
        if(oldu) return;
    }
    if(Mode == YURU){
        simulate(r, c+1, -1, -1, YURU, timer+1);
        if(oldu) return;

        simulate(r-1, c+1, timer, 1, UC, timer+1);
        if(oldu) return;
    }
    return;
}

int main(int argc, char **argv){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    cin >> N;
    field.resize(10, vector<bool>(N));

    for(int i = 0; i < 10; ++i){
        for(int j = 0; j < N; ++j){
            char c; cin >> c;
            field[i][j] = (c == 'X');
        }
    }
    
    simulate(9, 0, -1, -1, YURU, 0);

    cout << (int)ans.size() << endl;
    for(int i = 0; i < (int)ans.size(); ++i){
        cout << ans[i].st << sp << ans[i].nd << endl;
    }

    return 0;
}

//cikisir

# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 4 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 7 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 13 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 19 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 26 ms 860 KB Execution killed with signal 11 (could be triggered by violating memory limits)