Pagini: [1]   În jos
  Imprimă  
Ajutor Subiect: 1527 Betasah  (Citit de 930 ori)
0 Utilizatori şi 1 Vizitator pe acest subiect.
Teodor94
Echipa infoarena
Nu mai tace
*****

Karma: 63
Deconectat Deconectat

Mesaje: 558



Vezi Profilul
« : Mai 23, 2014, 10:59:14 »

Aici puteti discuta despre problema Betasah.
Memorat
mihai.alpha
Strain


Karma: 0
Deconectat Deconectat

Mesaje: 16



Vezi Profilul
« Răspunde #1 : 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;
}
« Ultima modificare: Ianuarie 08, 2017, 01:57:18 de către mihai craciun » Memorat
Pagini: [1]   În sus
  Imprimă  
 
Schimbă forumul:  

Powered by SMF 1.1.19 | SMF © 2006-2013, Simple Machines