답안 #1117089

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1117089 2024-11-22T20:08:43 Z mmk 무지개나라 (APIO17_rainbow) C++14
0 / 100
2 ms 2384 KB
#include "rainbow.h"
#include<bits/stdc++.h>
using namespace std;

const int MAXN = 2e5 + 10;

int grid[3][MAXN];
int psum[MAXN][3];
int last[MAXN][3];

void init(int R, int C, int sr, int sc, int M, char *S)
{
    int x = sr, y = sc;
    grid[sr][sc] = -1;
    for(int i = 0; i < M; i++)
    {
        x -= (S[i] == 'N');
        x += (S[i] == 'S');


        y -= (S[i] == 'W');
        y += (S[i] == 'E');

        // cerr << x << " " << y << " COBRA \n";
        grid[x][y] = -1;
    }

    for(int i = 1; i <= C; i++)
    {
        if(grid[1][i] == -1)
        {
            psum[i][0] = psum[i-1][0];
            last[i][0] = i;
        }
        else
        {
            psum[i][0] = psum[i-1][0]++;
            last[i][0] = last[i-1][0];
        }

        if(grid[2][i] == -1)
        {
            psum[i][1] = psum[i-1][1];
            last[i][1] = i;
        }
        else
        {
            psum[i][1] = psum[i-1][1] + 1;
            last[i][1] = last[i-1][1];
        }

        if(grid[1][i] == -1 && grid[2][i] == -1)
        {
            psum[i][2] = psum[i-1][2];
            last[i][2] = i;
        }
        else
        {
            psum[i][2] = psum[i-1][2] + 1;
            last[i][2] = last[i-1][2];
        }
    }
}

int calc(int ini, int fim, int type)
{
    return psum[fim][type] - psum[last[ini][type]][type];
}

int colour(int ar, int ac, int br, int bc)
{
    if(ar == br && ar == 1) return calc(ac,bc,0);
    if(ar == br && ar == 2) return calc(ac,bc,1);
    if(ar != br) return calc(ac,bc,2);
}

Compilation message

rainbow.cpp: In function 'int colour(int, int, int, int)':
rainbow.cpp:75:1: warning: control reaches end of non-void function [-Wreturn-type]
   75 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 336 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Incorrect 1 ms 2384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Runtime error 2 ms 592 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 336 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 336 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -