답안 #925224

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
925224 2024-02-11T06:21:20 Z irmuun 무지개나라 (APIO17_rainbow) C++17
0 / 100
1 ms 648 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]
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 444 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 1 ms 648 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 -