Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <stdio.h>
- using namespace std;
- typedef struct Punct {
- int l;
- int c;
- int pas;
- } Punct;
- int n, k, **a;
- Punct T, S1, S2, R1, R2, *coada;
- int dl[] = {-1, 0, 1, 0},
- dc[] = {0, 1, 0 , -1};
- void init (int **a) {
- for (int i = 0; i < n+2; i++) {
- a[i][0] = -1;
- a[i][n+1] = -1;
- a[0][i] = -1;
- a[n+1][i] = -1;
- }
- for (int i = 1; i <= n; i++) {
- for (int j = 1; j <= n; j++) {
- a[i][j] = 0;
- }
- }
- }
- void coliniar () {
- }
- void lee (Punct start) {
- int p = 0, u = 0;
- bool exit = false;
- coada[p].l = start.l;
- coada[p].c = start.c;
- coada[p].pas = 1;
- a[coada[p].l][coada[p].c] = coada[p].pas;
- while (p <= u && !exit) {
- for (int i = 0; i < 4; i++) {
- if (a[coada[p].l + dl[i]][coada[p].c + dc[]] == 0) {
- }
- }
- }
- }
- int main()
- {
- freopen("harta1.in", "r", stdin);
- freopen("harta1.out", "w", stdout);
- scanf("%d %d %d %d %d %d %d %d %d %d %d %d", &n, &T.l, &T.c, &S1.l, &S1.c, &S2.l, &S2.c, &R1.l, &R1.c, &R2.l, &R2.c, &k);
- a = (int **) malloc (sizeof(int *) * (n + 2));
- for (int i = 0; i < n+2; i++) {
- a[i] = (int *) malloc (sizeof(int) * (n+2));
- }
- coada = (Punct *) malloc (sizeof(Punct) * n * n);
- init(a);
- Punct obstacol;
- for (int i = 0; i < k; i++) {
- scanf("%d %d", &obstacol.l, &obstacol.c);
- a[obstacol.l][obstacol.c] = -1;
- }
- a[T.l][T.c] = -2;
- int lgmax = 0, lg = 0;
- for (int i = 1; i <= n; i++) {
- for (int j = 1; j <= n; j++) {
- if (a[i][j] == -1) {
- lg++;
- } else if (a[i][j] != -1) {
- if (lg > lgmax) {
- lgmax = lg;
- }
- lg = 0;
- }
- }
- }
- for (int i = 1; i <= n; i++) {
- for (int j = 1; j <= n; j++) {
- if (a[j][i] == -1) {
- lg++;
- } else if (a[j][i] != -1) {
- if (lg > lgmax) {
- lgmax = lg;
- }
- lg = 0;
- }
- }
- }
- printf("%d", lgmax);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement