Cod sursa(job #2199011)

Utilizator osiaccrCristian Osiac osiaccr Data 26 aprilie 2018 11:19:01
Problema A+B Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.95 kb
#include <fstream>
#include <vector>
#define DEF 110

using namespace std;

class block {
public:
    int id;
    bool orientation;
    pair < int, int > pos;
    int length;

    block (int _id, bool _orientation, pair < int, int > _pos, int _length) {
        id = _id; orientation = _orientation; pos = _pos; length = _length;
    }
};

ifstream fin ("file.in");
ofstream fout ("file.out");

vector < block > Blocks;

vector < pair < int, int > > Moves;

int is_Taken[DEF][DEF];

int size_X, size_Y;

int di[] = {1, 0};
int dj[] = {0, 1};

void Start () {
    int id, length, nr_Blocks;
    char orientation;
    pair < int, int > pos;

    fin >> size_X >> size_Y >> nr_Blocks;

    for (int i = 1; i <= nr_Blocks; ++ i){
        fin >> id >> orientation >> pos.first >> pos.second >> length
        block temp = block (id, (orientation != 'h'), pos, length);
        Blocks.push_back (temp);
    }

    while (fin >> id >> length) {
        Moves.push_back ({id, length});
    }
}

int main () {
    Start ();

    for (int k = 0; k < Blocks.size (); ++ k) {
        block current_Block = Blocks[k];
        int new_X = current_Block.pos.first, new_Y = current_Block.pos.second;

        for (int i = 1; i <= current_Block.length; ++ i) {
            if (is_Taken[new_X][new_Y] == false) {
                is_Taken[new_X][new_Y] = true;
            }
            else {
                fout << "true";
                return 0;
            }

            new_X += di[current_Block.orientation];
            new_Y += dj[current_Block.orientation];
        }
    }

    for (pair < int, int > &current_Move : Moves) {
        block current_Block = Blocks[current_Move.id];
        for (int i = 1; i <= current_Move.second; ++ i) {
            is_Taken[current_Block.pos.x] = false;
            is_Taken[current_Block.pos.y] = false;
            if ()
        }
    }

    fout << "false";

    return 0;
}