Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <iostream>
- #include <stdlib.h>
- #include <string>
- #include <xstring>
- #include <vector>
- #include <cmath>
- #include <queue>
- #include <math.h>
- #include <algorithm>
- #include <map>
- #include <set>
- #include <conio.h>
- #include <stack>
- #define _USE_MATH_DEFINES
- #define TASK "taskname"
- #define MAXN 555555
- using namespace std;
- vector<vector<int>>vec;
- int k, st, x, y;
- pair<int,int>turn[3] = { make_pair(1,0), make_pair(1,1), make_pair(1,-1) };
- bool ok(int x, int y, int hx, int hy){
- if(!(y>0 && x>0 && x<=k & y<=k)) return false;
- if(x-hx == y-hy)return false;
- if(x-hx == hy-y)return false;
- return true;
- }
- int main(){
- //freopen(TASK ".in", "r", stdin);freopen(TASK ".out", "w", stdout);
- //freopen("input.txt", "r", stdin);freopen("output", "w", stdout);
- cin >> k;
- cin >> st;
- cin >> x >> y;
- int currx,curry;
- currx=1;
- curry=st;
- while(true){
- if(currx==k){
- return 0;
- }
- for(int i=0; i<3; ++i){
- if(ok(currx+turn[i].first, curry+turn[i].second,x,y)){
- currx = currx+turn[i].first;
- curry = curry+turn[i].second;
- cout << currx << " ";
- fflush(stdout);
- cout << curry << endl;
- fflush(stdout);
- break;
- }
- }
- if(currx==k){
- return 0;
- }
- cin >> x >> y;
- fflush(stdout);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement