Submission #133299

# Submission time Handle Problem Language Result Execution time Memory
133299 2019-07-20T11:31:06 Z tdwn Jetpack (COCI16_jetpack) C++17
24 / 80
118 ms 11384 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(maze[i+1][j] == 'X' && maze[i+1][j-1] == 'X') {
					if(t[i][j-1] != -1) {
						t[i][j] = t[i][j-1] + 1;
						direction[i][j] = 0;
					}
				}

				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;
				}
			}
		}
	}

	/*for(int i=1;i<=10;i++) {
		for(int j=1;j<=n;j++) {
			cout<<setw(5)<<t[i][j]<<" ";
		} cout<<"\n";
	}*/

	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 508 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Incorrect 2 ms 504 KB Crashed with an obstacle
4 Correct 3 ms 476 KB Output is correct
5 Incorrect 7 ms 888 KB Crashed with an obstacle
6 Runtime error 11 ms 1400 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 26 ms 2764 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 57 ms 5852 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 85 ms 8696 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 118 ms 11384 KB Execution killed with signal 11 (could be triggered by violating memory limits)