Advertisement
Guest User

Untitled

a guest
Feb 27th, 2020
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. #include <iostream> #include <bits/stdc++.h> using namespace std; ifstream in("cartite.in"); ofstream out("cartite.out"); typedef pair < bool , pair < int, int > > Pair; const int NMAX=210, dX[]= {-1, 0, 1, 0, -2, -1, 0, 1, 2, 1, 0, -1}, dY[]= {0, 1, 0, -1, 0, 1, 2, 1, 0, -1, -2, -1}; int Question, n, m, xc, yc, K, G, Mat[NMAX][NMAX], a[NMAX][NMAX], rX, rY; deque < pair < int, int > > Q; map < pair < int, int >, vector < pair < bool, pair < int, int > > > > MAP; vector < pair < int, int > > R; void Mark(int x, int y, int c) { int z=-1, NewX, NewY; Mat[x][y] = -1; if(c == 1) z = 3; if(c == 2) z = 11; for(int i = 0; i <=z; i++) { NewX = x + dX[i]; NewY = y + dY[i]; if(NewX < 1 || NewX > n || NewY < 1 || NewY > m) continue; Mat[NewX][NewY] = -1; } } bool INSIDE(int x, int y) { if(x < 1 || x > n || y < 1 || y > m) return 0; return 1; } void Lee(int x, int y) { if(Mat[x][y] == 1) { rX = x; rY = y; return; } a[x][y]=1; int NewX, NewY; Q.push_back(make_pair(x, y)); while(!Q.empty()) { x = Q.front().first; y = Q.front().second; Q.pop_front(); for(int z = 0; z < 4; z++) { NewX = x + dX[z]; NewY = y + dY[z]; if(INSIDE(NewX, NewY) && !a[NewX][NewY] && Mat[NewX][NewY]!=-1) { Q.push_back(make_pair(NewX, NewY)); a[NewX][NewY] = a[x][y] + 1; if(Mat[NewX][NewY] == 1) { rX = NewX; rY = NewY; return; } } } } } void DFS(int x, int y) { for(Pair it : MAP[{x, y}]) if(it.first) { it.first = 0; for(Pair i : MAP[{it.second.first, it.second.second}]) if(i.second.first == x && i.second.second == y) { i.first = 0;...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement