#include <iostream> #include <queue> #include <vector> using namespace std; int n, k, T; int wartosci[20][20]; void zbierzZPola(int x, int y) { wartosci[x][y] -= 10; cout << "=\n"; while(wartosci[x][y] > 0) { wartosci[x][y] -= 10; cout << "=\n"; } } void wypiszRuch(int x1, int y1, int x2, int y2) { cout << "M" << " " << x1 << " " << y1 << " " << x2 << " " << y2 << "\n"; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> T >> k; for(int test = 0; test < T; test++) { cin >> n; for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { cin >> wartosci[i][j]; } } cout << "R FARMER\n"; int x = 0; int y = 0; while(y < n) { if(y % 2 == 0) { while(x < n - 1) { wypiszRuch(x, y, x+1, y); zbierzZPola(x+1, y); x++; } } else { while(x > 0) { wypiszRuch(x, y, x-1, y); zbierzZPola(x-1, y); x--; } } if(y != n - 1) { wypiszRuch(x, y, x, y+1); zbierzZPola(x, y+1); } y++; } y--; while(x > 0) { wypiszRuch(x, y, x-1, y); x--; cout << "=\n"; } while(y > 0) { wypiszRuch(x, y, x, y-1); y--; cout << "=\n"; } cout << "===\n"; } return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | #include <iostream> #include <queue> #include <vector> using namespace std; int n, k, T; int wartosci[20][20]; void zbierzZPola(int x, int y) { wartosci[x][y] -= 10; cout << "=\n"; while(wartosci[x][y] > 0) { wartosci[x][y] -= 10; cout << "=\n"; } } void wypiszRuch(int x1, int y1, int x2, int y2) { cout << "M" << " " << x1 << " " << y1 << " " << x2 << " " << y2 << "\n"; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> T >> k; for(int test = 0; test < T; test++) { cin >> n; for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { cin >> wartosci[i][j]; } } cout << "R FARMER\n"; int x = 0; int y = 0; while(y < n) { if(y % 2 == 0) { while(x < n - 1) { wypiszRuch(x, y, x+1, y); zbierzZPola(x+1, y); x++; } } else { while(x > 0) { wypiszRuch(x, y, x-1, y); zbierzZPola(x-1, y); x--; } } if(y != n - 1) { wypiszRuch(x, y, x, y+1); zbierzZPola(x, y+1); } y++; } y--; while(x > 0) { wypiszRuch(x, y, x-1, y); x--; cout << "=\n"; } while(y > 0) { wypiszRuch(x, y, x, y-1); y--; cout << "=\n"; } cout << "===\n"; } return 0; } |