답안 #900120

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
900120 2024-01-07T16:47:43 Z Lincito_31 무지개나라 (APIO17_rainbow) C++11
0 / 100
502 ms 1048576 KB
#include "rainbow.h"
#include<bits/stdc++.h>
using namespace std;
vector<vector<char>> grid;
void llenar(vector<vector<char>> &clon,int ar,int ac,int br,int bc,int i,int j){
    if(clon[i][j]=='x'){
        return;
    }
    clon[i][j]='x';
    if(i==ar){
        if(clon[i+1][j]==' '){
            llenar(clon,ar,ac,br,bc,i+1,j);
        }
        if(j==ac){
            if(clon[i][j+1]==' '){
                llenar(clon,ar,ac,br,bc,i,j+1);
            }
        }else if(j==bc){
            if(clon[i][j-1]==' '){
                llenar(clon,ar,ac,br,bc,i,j-1);
            }
        }else{
            if(clon[i][j+1]==' '){
                llenar(clon,ar,ac,br,bc,i,j+1);
            }
            if(clon[i][j-1]==' '){
                llenar(clon,ar,ac,br,bc,i,j-1);
            }
        }
    }else if(i==br){
        if(clon[i-1][j]==' '){
            llenar(clon,ar,ac,br,bc,i-1,j);
        }
        if(j==ac){
            if(clon[i][j+1]==' '){
                llenar(clon,ar,ac,br,bc,i,j+1);
            }
        }else if(j==bc){
            if(clon[i][j-1]==' '){
                llenar(clon,ar,ac,br,bc,i,j-1);
            }
        }else{
            if(clon[i][j+1]==' '){
                llenar(clon,ar,ac,br,bc,i,j+1);
            }
            if(clon[i][j-1]==' '){
                llenar(clon,ar,ac,br,bc,i,j-1);
            }
        }
    }else{
        if(clon[i+1][j]==' '){
            llenar(clon,ar,ac,br,bc,i+1,j);
        }
        if(clon[i-1][j]==' '){
            llenar(clon,ar,ac,br,bc,i-1,j);
        }
        if(j==ac){
            if(clon[i][j+1]==' '){
                llenar(clon,ar,ac,br,bc,i,j+1);
            }
        }else if(j==bc){
            if(clon[i][j-1]==' '){
                llenar(clon,ar,ac,br,bc,i,j-1);
            }
        }else{
            if(clon[i][j+1]==' '){
                llenar(clon,ar,ac,br,bc,i,j+1);
            }
            if(clon[i][j-1]==' '){
                llenar(clon,ar,ac,br,bc,i,j-1);
            }
        }
    }
}
void init(int R, int C, int sr, int sc, int M, char *S) {
    vector<char> auxi(C,' ');
    for(int i=0;i<R;i++){
        grid.push_back(auxi);
    }
    sr--;
    sc--;
    grid[sr][sc]='x';
    for(int i=0;i<M;i++){
        switch(S[i]){
            case 'N':
                sr--;
                break;
            case 'S':
                sr++;
                break;
            case 'W':
                sc--;
                break;
            case 'E':
                sc++;
                break;
        }
        grid[sr][sc]='x';
    }
}
int colour(int ar, int ac, int br, int bc) {
    int canti=0;
    ar--;
    ac--;
    br--;
    bc--;
    vector<vector<char>> clon(grid.begin(),grid.end());
    for(int i=ar;i<=br;i++){
        for(int j=ac;j<=bc;j++){
            if(clon[i][j]==' '){
                canti++;
                llenar(clon,ar,ac,br,bc,i,j);
            }
        }
    }
    return canti;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 5 ms 348 KB Output is correct
3 Runtime error 4 ms 1016 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Runtime error 502 ms 1048576 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 5 ms 348 KB Output is correct
3 Runtime error 4 ms 1016 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 5 ms 348 KB Output is correct
3 Runtime error 4 ms 1016 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -