/* Subject: Contest submission for problem #1, file 1.cc */ /* koulchin@imail.EECS.Berkeley.EDU */ /* Thu Sep 11 13:48:13 PDT 2003 */ /*___CONTEST_SUBMISSION___ koulchin 1 */ // Triangles. // Estimated time: 40 minutes // Starting time: 12:15 // Ending time: 1:35, with 5 minutes break // Actual time: 1:15 // 32 minutes coding, the rest debugging my math #include char matrix[20][21]; // given N<=20, one extra character for null terminator int size; int triangles[26]; // retrieve the letter at the position, with bounds checking char GetLetter(int x, int y); // check if triangle of given type exists at given position int CountTriangles(int x, int y, int type); int main() { int n, k, j, sum, count; scanf("%d", &size); while (size > 0) { for (n=0; n<26; n++) triangles[n] = 0; // init counters sum = 0; for (n=0; n=size || y>=size) return 0; else return matrix[y][x]; }