답안 #925222

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
925222 2024-02-11T06:09:40 Z irmuun 무지개나라 (APIO17_rainbow) C++17
0 / 100
1 ms 860 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])==true||(water[2][r]&water[2][r+1])==true){
                    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])==true){
                    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])==true){
                    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){
    if(ar==1&&br==1){
        ll x=lower_bound(all(v[1]),bc)-v[1].begin();
        ll y=lower_bound(all(u[1]),bc)-u[1].begin();
        return x-y;
    }
    if(ar==2&&br==2){
        ll x=lower_bound(all(v[2]),bc)-v[2].begin();
        ll y=lower_bound(all(u[2]),bc)-u[2].begin();
        return x-y;
    }
    if(ar==1&&br==2){
        ll x=lower_bound(all(v[0]),bc)-v[0].begin();
        ll y=lower_bound(all(u[0]),bc)-u[0].begin();
        return x-y;
    }
    return 0;
}

Compilation message

rainbow.cpp: In function 'void init(int, int, int, int, int, char*)':
rainbow.cpp:33:26: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   33 |                 while(r<C&&(water[1][r]&water[1][r+1])==true||(water[2][r]&water[2][r+1])==true){
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 1 ms 860 KB Execution killed with signal 11
3 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 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -