Submission #984069

# Submission time Handle Problem Language Result Execution time Memory
984069 2024-05-16T09:49:22 Z Unforgettablepl Land of the Rainbow Gold (APIO17_rainbow) C++17
12 / 100
49 ms 4940 KB
#include <bits/stdc++.h>
using namespace std;

//#define int long long

bool water[3][200002];
vector<pair<int,int>> row1,row2,rowboth;

void init(int32_t R, int32_t C, int32_t sr, int32_t sc, int32_t M, char *S) {
    water[sr][sc]=true;
    for(int i=0;i<M;i++){
        if(S[i]=='N')sr--;
        else if(S[i]=='S')sr++;
        else if(S[i]=='E')sc++;
        else if(S[i]=='W')sc--;
        water[sr][sc]=true;
    }
    int c = 0;
    water[1][0]=true;
    water[2][0]=true;
    water[1][C+1]=true;
    water[2][C+1]=true;
    for(int i=1;i<=C+1;i++){
        if(water[1][i]==water[1][i-1])continue;
        if(water[1][i])row1.emplace_back(i-1,c);
        else row1.emplace_back(i,++c);
    }
    for(int i=1;i<=C+1;i++){
        if(water[2][i]==water[2][i-1])continue;
        if(water[2][i])row2.emplace_back(i-1,c);
        else row2.emplace_back(i,++c);
    }
    for(int i=1;i<=C+1;i++){
        if(water[1][i] and water[2][i] and !(water[1][i-1] and water[2][i-1]))rowboth.emplace_back(i-1,c);
        else if(water[1][i-1] and water[2][i-1] and !(water[1][i] and water[2][i]))rowboth.emplace_back(i,++c);
    }
}

int32_t colour(int32_t ar, int32_t ac, int32_t br, int32_t bc) {
    if(ar==2){
        if(row2.empty() or bc<row2.front().first or row2.back().first<ac)return 0;
        auto lo = (lower_bound(row2.begin(), row2.end(), make_pair(ac,0))->second)-1;
        auto hi = (--lower_bound(row2.begin(), row2.end(), make_pair(bc,(int)1e6)))->second;
        return hi-lo;
    } else if(br==1){
        if(row1.empty() or bc<row1.front().first or row1.back().first<ac)return 0;
        auto lo = (lower_bound(row1.begin(), row1.end(), make_pair(ac,0))->second)-1;
        auto hi = (--lower_bound(row1.begin(), row1.end(), make_pair(bc,(int)1e6)))->second;
        return hi-lo;
    } else {
        if(rowboth.empty() or bc<rowboth.front().first or rowboth.back().first<ac)return 0;
        auto lo = (lower_bound(rowboth.begin(), rowboth.end(), make_pair(ac,0))->second)-1;
        auto hi = (--lower_bound(rowboth.begin(), rowboth.end(), make_pair(bc,(int)1e6)))->second;
        return hi-lo;
    }
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 41 ms 3924 KB Output is correct
4 Correct 46 ms 4176 KB Output is correct
5 Correct 49 ms 4560 KB Output is correct
6 Correct 47 ms 4640 KB Output is correct
7 Correct 49 ms 4940 KB Output is correct
8 Correct 39 ms 3960 KB Output is correct
9 Correct 47 ms 4144 KB Output is correct
10 Correct 49 ms 4560 KB Output is correct
11 Correct 48 ms 4560 KB Output is correct
12 Correct 38 ms 4176 KB Output is correct
13 Correct 40 ms 4180 KB Output is correct
14 Correct 42 ms 4432 KB Output is correct
15 Correct 42 ms 4560 KB Output is correct
16 Correct 40 ms 4180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Runtime error 1 ms 860 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -