답안 #57259

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
57259 2018-07-14T12:14:42 Z MatheusLealV 무지개나라 (APIO17_rainbow) C++17
0 / 100
19 ms 676 KB
#include "rainbow.h"
#include <bits/stdc++.h>
#define N 55
#define f first
#define s second
using namespace std;
typedef pair<int, int> pii;

int n, m, ok[N][N], block[N][N];

int dx[4] = {1, -1, 0, 0}, dy[4] = {0, 0, 1, -1};

int Ni, Mi, Nii, Mii;

int dxy(char c)
{
	if(c == 'N') return 1;

	if(c == 'S') return 0;

	if(c == 'W') return 3;

	return 2;
}

void dfs(int x, int y)
{
	ok[x][y] = 1;

	//cout<<"DFS "<<x<<" "<<y<<"\n";

	for(int i = 0; i < 4; i++)
	{
		int a = x + dx[i], b = y + dy[i];

		if(a < Ni or b < Mi or a > Nii or b > Mii or ok[a][b] == 1 or block[a][b]) continue;

		ok[a][b] = 1;

		dfs(a, b);
	}
}

void init(int R, int C, int sr, int sc, int M, char *S)
{
	int x = sr, y = sc;

	string s;

	for(int i = 0; i < M; i++) s.push_back(S[i]);

	for(int i = 0; i < s.size(); i++)
	{
		block[x][y] = 1;

		int id = dxy(s[i]);

		x = x + dx[id], y = y + dy[id];

		block[x][y] = 1;

		//cout<<"BLOCK "<<x<<" "<<y<<"\n";
	}
}

int colour(int ar, int ac, int br, int bc)
{
    int cnt = 0;

    memset(ok, 0, sizeof ok);

    Nii = br, Ni = ar, Mi = ac, Mii = bc;

    for(int x = ar; x <= br; x++)
    {
    	for(int y = ac; y <= bc; y++)
    	{
    		if(ok[x][y] or block[x][y]) continue;

    		cnt ++;

    		ok[x][y] = 1;

    		dfs(x, y);
    	}
    }

    return cnt;
}

Compilation message

rainbow.cpp: In function 'void init(int, int, int, int, int, char*)':
rainbow.cpp:52:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < s.size(); i++)
                 ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 248 KB Output is correct
2 Correct 7 ms 484 KB Output is correct
3 Correct 16 ms 552 KB Output is correct
4 Correct 19 ms 552 KB Output is correct
5 Correct 10 ms 552 KB Output is correct
6 Correct 2 ms 552 KB Output is correct
7 Incorrect 2 ms 676 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 676 KB Output is correct
2 Incorrect 3 ms 676 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 676 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 248 KB Output is correct
2 Correct 7 ms 484 KB Output is correct
3 Correct 16 ms 552 KB Output is correct
4 Correct 19 ms 552 KB Output is correct
5 Correct 10 ms 552 KB Output is correct
6 Correct 2 ms 552 KB Output is correct
7 Incorrect 2 ms 676 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 248 KB Output is correct
2 Correct 7 ms 484 KB Output is correct
3 Correct 16 ms 552 KB Output is correct
4 Correct 19 ms 552 KB Output is correct
5 Correct 10 ms 552 KB Output is correct
6 Correct 2 ms 552 KB Output is correct
7 Incorrect 2 ms 676 KB Output isn't correct
8 Halted 0 ms 0 KB -