Submission #925225

# Submission time Handle Problem Language Result Execution time Memory
925225 2024-02-11T06:23:30 Z irmuun Land of the Rainbow Gold (APIO17_rainbow) C++17
12 / 100
53 ms 4692 KB
#include<bits/stdc++.h>
#include "rainbow.h"
 
using namespace std;
 
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
 
bool water[3][200005],sub2=false;
 
vector<int>v[3],u[3];
 
void init(int R,int C,int sr,int sc,int M,char *S){
    water[sr][sc]=true;
    for(int i=0;i<M;i++){
        if(S[i]=='N') sr--;
        if(S[i]=='S') sr++;
        if(S[i]=='W') sc--;
        if(S[i]=='E') sc++;
        water[sr][sc]=true;
    }
    if(R==2){
        for(int i=0;i<3;i++){
            v[i].pb(-1);
            u[i].pb(-1);
        }
        for(int j=1;j<=C;j++){
            if(water[1][j]==false||water[2][j]==false){
                int r=j;
                while(r<C&&((water[1][r]|water[1][r+1])==false||(water[2][r]|water[2][r+1])==false)){
                    r++;
                }
                v[0].pb(j);
                u[0].pb(r);
                j=r+1;
            }
        }
        for(int j=1;j<=C;j++){
            if(water[1][j]==false){
                int r=j;
                while(r<C&&(water[1][r]|water[1][r+1])==false){
                    r++;
                }
                v[1].pb(j);
                u[1].pb(r);
                j=r+1;
            }
        }
        for(int j=1;j<=C;j++){
            if(water[2][j]==false){
                int r=j;
                while(r<C&&(water[2][r]|water[2][r+1])==false){
                    r++;
                }
                v[2].pb(j);
                u[2].pb(r);
                j=r+1;
            }
        }
        for(int i=0;i<3;i++){
            v[i].pb(C+1);
            u[i].pb(C+1);
        }
    }
}
 
int colour(int ar,int ac,int br,int bc){
    int x,y;
    if(ar==1&&br==1){
        x=upper_bound(all(v[1]),bc)-v[1].begin();
        y=lower_bound(all(u[1]),ac)-u[1].begin();
    }
    if(ar==2&&br==2){
        x=upper_bound(all(v[2]),bc)-v[2].begin();
        y=lower_bound(all(u[2]),ac)-u[2].begin();
    }
    if(ar==1&&br==2){
        x=upper_bound(all(v[0]),bc)-v[0].begin();
        y=lower_bound(all(u[0]),ac)-u[0].begin();
    }
    return x-y;
}

Compilation message

rainbow.cpp: In function 'int colour(int, int, int, int)':
rainbow.cpp:85:14: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized]
   85 |     return x-y;
      |              ^
rainbow.cpp:85:14: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
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 348 KB Output is correct
3 Correct 43 ms 3848 KB Output is correct
4 Correct 48 ms 4172 KB Output is correct
5 Correct 51 ms 4344 KB Output is correct
6 Correct 47 ms 4436 KB Output is correct
7 Correct 50 ms 4692 KB Output is correct
8 Correct 46 ms 3924 KB Output is correct
9 Correct 48 ms 4176 KB Output is correct
10 Correct 53 ms 4296 KB Output is correct
11 Correct 48 ms 4436 KB Output is correct
12 Correct 40 ms 3924 KB Output is correct
13 Correct 42 ms 4180 KB Output is correct
14 Correct 42 ms 4432 KB Output is correct
15 Correct 43 ms 4396 KB Output is correct
16 Correct 42 ms 3924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Runtime error 1 ms 600 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -