//Dennis Matveyev for SER 2013 //TextRoll #include #include #include using namespace std; /* Idea: One idea was to create a giant matrix, and then guide the ball through it. But nah,.. it was easier to read entire line into memory (a string) then keep a "pointer" to current ball location. If the ball is above a space, it would "drop" to the next line. Otherwise, we advance the pointer while checking for the next drop location. Idea for the problem came from wanting to do something very closely with the problem text itself. */ int main() { int n; while (cin >> n && n>0) { string s; getline(cin, s); //eat white space. needed for peaceful cin/getline cohabitation int currentSpace = 0; //count the column position in the text for (int i = 0; i