답안 #900209

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
900209 2024-01-07T21:38:37 Z Lincito_31 무지개나라 (APIO17_rainbow) C++11
0 / 100
507 ms 1048576 KB
#include "rainbow.h"
#include<bits/stdc++.h>
using namespace std;
vector<vector<char>> grid;
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';
    }
    for(int i=0;i<R;i++){
        bool xd=true;
        char ante='0';
        for(int j=0;j<C;j++){
            if(xd && grid[i][j]==' '){
                grid[i][j]=ante+1;
                ante=ante+1;
                xd=false;
            }else{
                xd=true;
            }
        }
    }
}
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());
    if(ar==br){
        if(grid[ar][ac]!='x' && grid[ar][bc]!='x'){
            canti=grid[ar][bc]-grid[ar][ac]+1;
        }else if(grid[ar][ac]=='x' && grid[ar][bc]!='x'){
            for(int i=ac;i<=bc;i++){
                if(grid[ar][i]!='x'){
                    canti=grid[ar][bc]-grid[ar][i]+1;
                    break;
                }
            }
        }else if(grid[ar][ac]!='x' && grid[ar][bc]=='x'){
            for(int i=bc;i>=ac;i--){
                if(grid[ar][i]!='x'){
                    canti=grid[ar][i]-grid[ar][ac]+1;
                    break;
                }
            }
        }else{
            for(int i=bc;i>=ac;i--){
                if(grid[ar][i]!='x'){
                    canti=grid[ar][i];
                    break;
                }
            }
            for(int i=ac;i<=bc;i++){
                if(grid[ar][i]!='x'){
                    canti=canti-grid[ar][i]+1;
                    break;
                }
            }
        }
    }else{
        for(int k=ar;k<=br;k++){
            if(grid[k][ac]!='x' && grid[k][bc]!='x'){
                canti+=grid[k][bc]-grid[k][ac]+1;
            }else if(grid[k][ac]=='x' && grid[k][bc]!='x'){
                for(int i=ac;i<=bc;i++){
                    if(grid[k][i]!='x'){
                        canti+=grid[k][bc]-grid[k][i]+1;
                        break;
                    }
                }
            }else if(grid[k][ac]!='x' && grid[k][bc]=='x'){
                for(int i=bc;i>=ac;i--){
                    if(grid[k][i]!='x'){
                        canti+=grid[k][i]-grid[k][ac]+1;
                        break;
                    }
                }
            }else{
                for(int i=bc;i>=ac;i--){
                    if(grid[k][i]!='x'){
                        canti+=grid[k][i];
                        break;
                    }
                }
                for(int i=ac;i<=bc;i++){
                    if(grid[k][i]!='x'){
                        canti+=canti-grid[k][i]+1;
                        break;
                    }
                }
            }
        }
        if(canti==2){
            if((grid[ar][ac]!='x' && grid[br][ac]!='x') || (grid[ar][bc]!='x' && grid[br][bc]!='x')){
                canti=1;
            }
        }
        if(grid[br][ac]!='x' && grid[ar][ac]!='x'){
            canti--;
        }
        if(grid[br][bc]!='x' && grid[ar][bc]!='x'){
            canti--;
        }
    }
    return canti;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 507 ms 1048576 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -