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[i + 1] = 1, ran = i; for(int i = 0;i < D;i++) { f >> X >> Y; int x = X, y = Y; mat
for(int i = 0;i < K;i++) { int x, y; f >> x >> y; mat
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
} } g << P << std::endl; f.close(); g.close(); return 0; } |