infoarena

infoarena - concursuri, probleme, evaluator, articole => Arhiva de probleme => Subiect creat de: Teodor Plop din Mai 23, 2014, 10:59:14



Titlul: 1527 Betasah
Scris de: Teodor Plop din Mai 23, 2014, 10:59:14
Aici puteti discuta despre problema Betasah (http://infoarena.ro/problema/betasah).


Titlul: Răspuns: 1527 Betasah
Scris de: mihai craciun din Ianuarie 08, 2017, 01:42:06
Tot iau 84p, desi am verificat toate testele comisiei. Aveti vreo idee despre ce poate cauza asta?

Uitati sursa:

#include <fstream>
#include <algorithm>

std::ifstream f("betasah.in");
std::ofstream g("betasah.out");

#define MAX 1000
#define Dmax 100

int N, D, K;
int M, P;

char mat[MAX + 2][MAX + 2];
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {1, -1, -1, 1, 0, 0, 1, -1};

int X[Dmax];
int Y[Dmax];
int ran[MAX + 2];

int main()  {

    f >> N >> D >> K;
    for(int i = 0;i <= N + 1;i++)
        mat
  • = mat[N + 1] = 1;
    for(int i = 0;i <= N + 1;i++)
        mat[i + 1] = 1, ran = i;

    for(int i = 0;i < D;i++)  {
        f >> X >> Y;
        int x = X, y = Y;
        mat
  • [y] = 2;
    }

    for(int i = 0;i < K;i++)  {
        int x, y;
        f >> x >> y;
        mat
  • [y] = 2;
        ran
  • --;
    }

    for(int i = 1;i <= N;i++)  {
        M = std::max(M, ran);
    }

    g << M << std::endl;

    for(int i = 0;i < D;i++)  {
        int x = X, y = Y;
        for(int j = 0;j < 8;j++)  {
            x = X, y = Y;
            int xx = dx[j], yy = dy[j];
            while(mat[x + xx][y + yy] != 2 && x + xx >= y + yy && x + xx >= 1 && y + yy >= 1 && x + xx >= 1 && x + xx <= N)  {
                if(!mat[x + xx][y + yy])P++;
                x += xx, y += yy;
                mat
  • [y] = 1;// printf("%d %d\n", x, y);
          //      printf("%d %d %d\n", mat
  • [y] - 0, x, y);
                }
        }
    }

    g << P << std::endl;

    f.close();
    g.close();

    return 0;
}