Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int main(){
- int N = 0, D = 0, L = 0, R = 0, C = 0;
- bool flag = false;
- int Matriz[11][11];
- for(int i = 0; i < 10; i++){
- for(int j = 0; j < 10; j++){
- Matriz[i][j]=0;
- }
- }
- cin>>N;
- //NUMERO DE BARCOS
- for(int i = 0; i < N; i++){
- cin >> D >> L >> R >> C;
- if(D == 0){
- if( (C+L-1) > 10){ //NAVIO HORIZONTAL FORA DO TABULEIRO
- flag = true;
- }
- else{
- for(int j = C; j <= C+L-1; j++)
- Matriz[R][j]++;
- }
- }else if(D == 1){
- if( (R+L-1) > 10){ //NAVIO VERTICAL FORA DO TABULEIRO
- flag = true;
- }
- else{
- for(int j = R; j <= R+L-1; j++)
- Matriz[j][C]++;
- }
- }
- }
- //SE TA DEBOA, PERCORRE A MATRIZ
- if(flag == false){
- for(int i = 0; i < 10; i++)
- for(int j = 0; j < 10; j++){
- if(Matriz[i][j] > 1) //TITANIC
- flag = true;
- }
- }
- if(flag == true)
- cout << "N" << endl;
- else
- cout << "Y" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement