/******************************************************* * Copyright (C) 2015 Haotian Wu * * This file is the solution to the question: * https://www.hackerrank.com/challenges/matrix-rotation-algo * * Redistribution and use in source and binary forms are permitted. *******************************************************/ #include #include #include #include #include #include #include #include #include using namespace std; // The main observation is, we need to figure out the length of each loop, and module R by each length. struct point { int x; int y; }; int main() { int tt; int n, m, r; scanf("%d %d %d",&n,&m,&r); int arr[300][300]; int newarr[300][300]; for (int i=0;i loops[l]; for (int i=0;i= i) { loops[i].push_back((point){a,b}); a--; } a = i; b = m-i-2; while (b >= i) { loops[i].push_back((point){a,b}); b--; } } for (int i=0;i