Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- else {
- if (m % 2 == 0) {
- int h = (n - 1)*m ;
- for (q = m; q; q--)
- cout << 1 << " " << q << endl;
- for (int xx = 2, yy = 1, u = 1; h; xx += u,h--) {
- cout << xx << " " << yy << endl;
- if (xx == n || (xx == 2 && yy > 1)) {
- u *= -1;
- yy++;
- if (yy <= m) {
- h--;
- cout << xx << " " << yy << endl;
- }
- }
- }
- }
- else if (n % 2 == 0) {
- int h = (m - 1)*n;
- for (q = n; q; q--)
- cout << q << " " << 1 << endl;
- for (int xx = 1, yy = 2, u = 1; h;h--, yy += u) {
- cout << xx << " " << yy << endl;
- if (yy == m || (yy == 2 && xx > 1)) {
- u *= -1;
- xx++;
- if (xx <= n) {
- h--;
- cout << xx << " " << yy << endl;
- }
- }
- }
- }
- else cout << -1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement