Code Jam to I/O for Women 2019


My solution

#include <iostream>
using namespace std;
int main() {
	int T;
	cin >> T;
	for (int cnt = 1; cnt <= T; cnt++) {

		int R, C, K;
		cin >> R >> C >> K;

		cout << "Case #" << cnt << ": ";

		if (R * C - K == 1) {
			cout << "IMPOSSIBLE" << endl;
			continue;
		}

		cout << "POSSIBLE" << endl;
		int i;
		for (i = 1; i <= R*C - K; i++) {
			if (i <= C) {
				if (i == 1) {
					if (i == C)
						cout << "S";
					else
						cout << "E";
				}
				else if (i == C || i == R * C - K)
					cout << "W";
				else
					cout << "E";
			}
			else
				cout << "N";

			if (i % C == 0)
				cout << endl;
		}
		for (; i <= R * C; i++) {
			cout << "S";
			if (i % C == 0)
				cout << endl;
		}

	}

}


Algorithms

Boustrophedon

A type of bi-directional text. Every other line of writing is flipped or reversed, with reversed letters. It was a common way of writing in stone in Ancient Greece.

example of boustrophedon

Flood Fill

Flood fill, also called seed fill, is an algorithm that determines the area connected to a given node in a multi-dimensional array. It is used in the “bucket” fill tool.


References

Boustrophedon Flood Fill