Submission #900883

# Submission time Handle Problem Language Result Execution time Memory
900883 2024-01-09T04:52:55 Z svaz Land of the Rainbow Gold (APIO17_rainbow) C++14
0 / 100
3000 ms 1048576 KB
#include "rainbow.h"
#include<bits/stdc++.h>
using namespace std;
vector< vector<bool> >matriz;
void init(int R, int C, int sr, int sc, int M, char *S) {
    for(int i=0;i<R;i++){
        vector<bool> fil(C,false);
        matriz.push_back(fil);
    }
    sr--;
    sc--;
    matriz[sr][sc]=1;
    for(int i=0;i<M;i++){
        int dir=S[i];
        if(dir=='N')sr--;
        if(dir=='W')sc--;
        if(dir=='S')sr++;
        if(dir=='E')sc++;
        if(sr>=0 && sr<R && sc>=0 && sc<C) matriz[sr][sc]=1;
        else{
            if(sr<0)sr=0;
            if(sr>=R)sr=R-1;
            if(sc<0)sc=0;
            if(sc>=C)sc=C-1;
        }
    }
}
int colour(int ar, int ac, int br, int bc) {
    ar--;
    ac--;
    br--;
    bc--;
    int c=0;
    bool ns=false;
    if(ar==br){
        for(int i=ac;i<=bc;i++){
            if(matriz[ar][i]==0 && ns==false){c++;ns=true;}
            else if(matriz[ar][i]==1) ns=false;
        }
    }
    else{
        for(int i=ac;i<=bc;i++){
             if(matriz[ar][i]==0 && ns==false){c++;ns=true;}
            else if(matriz[ar][i]==1){
                if(matriz[ar+1][i])ns=false;
                else if(ns==false){
                    c++;
                    ns=true;
                }
            }
        }
    }
    return c;
    return 0;
}
/*int main(){
    int R,C,M,Q,sr,sc,ar,ac,br,bc;
    string S;
    cin>>R>>C>>M>>Q;
    cin>>sr>>sc;
    cin>>S;
    init(R,C,sr,sc,M,S);
    for(int i=0;i<Q;i++){
        cin>>ar>>ac>>br>>bc;
        int ans=colours(ar,ac,br,bc);
        cout<<ans<<"\n";
    }
    return 0;
}*/
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 444 KB Output is correct
3 Execution timed out 3095 ms 1292 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Runtime error 430 ms 1048576 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -