Submission #366568

#TimeUsernameProblemLanguageResultExecution timeMemory
366568maozkurtJetpack (COCI16_jetpack)C++17
80 / 80
370 ms14700 KiB
#include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <ctime> #include <iostream> #include <algorithm> #include <queue> #include <map> #include <set> #include <vector> #include <string> #include <stack> #include <numeric> #include <cassert> #define endl '\n' #define sp ' ' #define pb push_back #define mp make_pair #define ff first #define ss second using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; const int maxn = 1e5+5; string mat[15]; int ne[maxn][15]; bool nebb[maxn][15]; int n; int start = -1; bool f(int col, int row, bool bastik){ if(row < 0 || row > n-1) return false; if(mat[row][col] == 'X') return false; // cerr << col << sp << row << sp << bastik << endl; if(col == n-1){ return true; } if(bastik){ if(row == 0){ if(f(col+1, row,true)){ ne[col][row] = 0; nebb[col][row] = true; return true; } else if(f(col+1,row+1,false)){ ne[col][row] = 1; nebb[col][row] = false; return true; } } else if(row == 9){ abort(); if(f(col+1,row-1,true)){ ne[col][row] = -1; nebb[col][row] = true; return true; } else if(f(col+1,row,false)){ ne[col][row] = 0; nebb[col][row] = false; return true; } } else{ if(f(col+1,row-1,true)){ ne[col][row] = -1; nebb[col][row] = true; return true; } else if(f(col+1,row+1,false)){ ne[col][row] = 1; nebb[col][row] = false; return true; } } } else{ if(row == 0){ abort(); } else if(row == 9){ if(f(col+1,row,false)){ ne[col][row] = 0; nebb[col][row] = false; return true; } else if(f(col+1, row-1, true)){ ne[col][row] = -1; nebb[col][row] = true; return true; } } else{ if(f(col+1,row+1,false)){ ne[col][row] = 1; nebb[col][row] = false; return true; } else if(f(col+1,row-1,true)){ ne[col][row] = -1; nebb[col][row] = true; return true; } } } return false; } int main(){ ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);cerr.tie(nullptr); cin>>n; for(int i=0;i<10;i++){ cin >> mat[i]; } assert(f(0,9,false)); vector<pii> way; int row = 9; pii cur = {-1,-1}; for(int col=0;col<n;col++){ if(nebb[col][row] && cur.ff == -1){ cur.ff = col; } else if(!nebb[col][row] && cur.ff != -1){ cur.ss = col - cur.ff; way.pb(cur); cur = {-1,-1}; } row += ne[col][row]; } if(cur.ff!=-1){ way.pb({cur.ff,n-cur.ff}); } cout << way.size() << endl; for(pii i : way){ cout << i.ff << sp << i.ss << endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...