# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
133291 |
2019-07-20T11:23:37 Z |
tdwn |
Jetpack (COCI16_jetpack) |
C++17 |
|
116 ms |
10460 KB |
#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 |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
504 KB |
Output is correct |
4 |
Correct |
3 ms |
504 KB |
Output is correct |
5 |
Correct |
7 ms |
892 KB |
Output is correct |
6 |
Runtime error |
11 ms |
1372 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
7 |
Runtime error |
25 ms |
2680 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
8 |
Runtime error |
57 ms |
5464 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
9 |
Runtime error |
89 ms |
7928 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
10 |
Runtime error |
116 ms |
10460 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |