Submission #162003

# Submission time Handle Problem Language Result Execution time Memory
162003 2019-11-05T16:24:49 Z Minnakhmetov Land of the Rainbow Gold (APIO17_rainbow) C++14
0 / 100
6 ms 632 KB
#include "rainbow.h"
#include <bits/stdc++.h>

using namespace std;

#define all(aaa) aaa.begin(), aaa.end()

string dir = "NSEW";
const int dx[4] = {-1, 1, 0, 0},
		  dy[4] = {0, 0, 1, -1};

const int N = 52;
int a[N][N];
int r, c;

void init(int R, int C, int sr, int sc, int M, char *S) {
	r = R;
	c = C;

	a[sr][sc] = 1;

	int x = sr, y = sc;
	for (int i = 0; i < M; i++) {
		int k = find(all(dir), S[i]) - dir.begin();
		x += dx[k];
		y += dy[k];
		a[x][y] = 1;
	}

	// for (int i = 1; i <= R; i++) {
	// 	for (int j = 1; j <= C; j++) {
	// 		cout << a[i][j];
	// 	}
	// 	cout << "\n";
	// }
}

int colour(int ar, int ac, int br, int bc) {
	// int ans = 1;

	// for (int i = ar; i <= br; i++) {
	// 	for (int j = ac; j < bc; j++) {
	// 		ans += (a[i][j] && a[i][j + 1]);
	// 	}
	// }

	// for (int i = ar; i < br; i++) {
	// 	for (int j = ac; j <= bc; j++) {
	// 		ans += (a[i + 1][j] && a[i][j]);
	// 	}
	// }

	// for (int i = ar; i <= br; i++) {
	// 	for (int j = ac; j <= bc; j++) {
	// 		ans -= a[i][j];
	// 	}
	// }

	// for (int i = ar; i <= br; i++) {
	// 	ans += a[i][ac] + a[i][bc];
	// }

	// for (int i = ac; i <= bc; i++) {
	// 	ans += a[ar][i] + a[br][i];
	// }

	// for (int i = ar; i < br; i++) {
	// 	ans -= (a[i][ac] && a[i + 1][ac]);
	// 	ans -= (a[i][bc] && a[i + 1][bc]);
	// }

	// for (int i = ac; i < bc; i++) {
	// 	ans -= (a[ar][i] && a[ar][i + 1]);
	// 	ans -= (a[br][i] && a[br][i + 1]);
	// }

	// for (int i = ar; i < br; i++) {
	// 	for (int j = ac; j < bc; j++) {
	// 		ans -= (a[i][j] && a[i + 1][j] && 
	// 			a[i][j + 1] && a[i + 1][j + 1]);
	// 	}
	// }

	// ans -= a[ar][ac] + a[ar][bc] + a[br][ac] + a[br][bc];

	int ans = 1;

	int b[N][N];

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			b[i][j] = 1;
		}
	}

	for (int i = ar; i <= br; i++) {
		for (int j = ac; j <= bc; j++) {
			b[i][j] = a[i][j];
		}
	}

	ac--;
	bc++;
	ar--;
	br++;

	for (int i = ar; i <= br; i++) {
		for (int j = ac; j <= bc; j++) {
			ans -= b[i][j];
		}
	}

	for (int i = ar; i <= br; i++) {
		for (int j = ac; j < bc; j++) {
			ans += (b[i][j] && b[i][j + 1]);
		}
	}

	for (int i = ar; i < br; i++) {
		for (int j = ac; j <= bc; j++) {
			ans += (b[i + 1][j] && b[i][j]);
		}
	}

	for (int i = ar; i < br; i++) {
		for (int j = ac; j < bc; j++) {
			ans -= (b[i + 1][j + 1] && b[i + 1][j] 
				&& b[i][j + 1] && b[i][j]);
		}
	}


	/*cout << "\n";
	for (int i = ar; i <= br; i++) {
		for (int j = ac; j <= bc; j++) {
			cout << b[i][j];
		}
		cout << "\n";
	}*/

	return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -