Advertisement
Guest User

Untitled

a guest
Oct 13th, 2013
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.51 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <iostream>
  3. #include <stdlib.h>
  4. #include <string>
  5. #include <xstring>
  6. #include <vector>
  7. #include <cmath>
  8. #include <queue>
  9. #include <math.h>
  10. #include <algorithm>
  11. #include <map>
  12. #include <set>
  13. #include <conio.h>
  14. #include <stack>
  15.  
  16. #define _USE_MATH_DEFINES
  17. #define TASK "taskname"
  18. #define MAXN 555555
  19. using namespace std;
  20.  
  21. vector<vector<int>>vec;
  22. int k, st, x, y;
  23.  
  24. pair<int,int>turn[3]  = { make_pair(1,0), make_pair(1,1), make_pair(1,-1) };
  25.  
  26. bool ok(int x, int y, int hx, int hy){
  27.     if(!(y>0 && x>0 && x<=k & y<=k)) return false;
  28.     if(x-hx == y-hy)return false;
  29.     if(x-hx == hy-y)return false;
  30.     return true;
  31. }
  32.  
  33. int main(){
  34.     //freopen(TASK ".in", "r", stdin);freopen(TASK ".out", "w", stdout);
  35.     //freopen("input.txt", "r", stdin);freopen("output", "w", stdout);
  36.  
  37.     cin >> k;
  38.     cin >> st;
  39.     cin >> x >> y;
  40.     int currx,curry;
  41.     currx=1;
  42.     curry=st;
  43.  
  44.     while(true){
  45.         if(currx==k){
  46.             return 0;
  47.         }
  48.         for(int i=0; i<3; ++i){
  49.             if(ok(currx+turn[i].first, curry+turn[i].second,x,y)){
  50.                 currx = currx+turn[i].first;
  51.                 curry = curry+turn[i].second;
  52.                 cout << currx << " ";
  53.                 fflush(stdout);
  54.                 cout <<  curry << endl;
  55.                 fflush(stdout);
  56.                 break;
  57.             }
  58.         }
  59.         if(currx==k){
  60.             return 0;
  61.         }
  62.         cin >> x >> y;
  63.         fflush(stdout);
  64.     }
  65.      
  66.     return 0;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement