# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
133289 | tdwn | Jetpack (COCI16_jetpack) | C++17 | 127 ms | 10860 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 100100;
char maze[11][maxn];
int t[11][maxn];
int direction[11][maxn];
int n;
int main() {
cin>>n;
for(int i=1;i<=10;i++) {
for(int j=1;j<=n;j++) {
cin>>maze[i][j];
t[i][j] = -1;
}
}
t[10][1] = 0;
// Direction:
// 0 -> from left (only last row)
// 1 -> felt from above
// 2 -> from down
for(int j=2;j<=n;j++) {
for(int i=1;i<=10;i++) {
if(maze[i][j] == 'X') continue;
if(i == 10) {
if(t[i][j-1] != -1) {
direction[i][j] = 0;
t[i][j] = t[i][j-1] + 1;
}
if(t[i-1][j-1] != -1) {
direction[i][j] = 1;
t[i][j] = t[i-1][j-1] + 1;
}
}
else if(i == 1) {
if(t[i-1][j-1] != -1) {
t[i][j] = t[i-1][j-1] + 1;
direction[i][j] = 2;
}
}
else {
if(t[i-1][j-1] != -1) {
t[i][j] = t[i-1][j-1] + 1;
direction[i][j] = 1;
}
if(t[i+1][j-1] != -1) {
t[i][j] = t[i+1][j-1] + 1;
direction[i][j] = 2;
}
}
}
}
int ind = -1;
for(int i=1;i<=10;i++) {
if(t[i][n] != -1) {
ind = i;
}
}
vector<pair<int,int> > v;
for(int j=n;j>=1;j--) {
if(direction[ind][j] == 0) {
continue;
}
else if(direction[ind][j] == 1) {
ind--;
}
else if(direction[ind][j] == 2){
v.pb(mp(t[ind+1][j-1],1));
ind++;
}
}
cout<<v.size()<<"\n";
reverse(v.begin(), v.end());
for(auto i:v) {
cout<<i.first<<" "<<i.second<<"\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |