답안 #57272

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
57272 2018-07-14T12:41:29 Z MatheusLealV 무지개나라 (APIO17_rainbow) C++17
11 / 100
22 ms 1172 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;

	block[x][y] = 1;

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

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

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

		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:54:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < s.size(); i++)
                 ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 9 ms 504 KB Output is correct
3 Correct 20 ms 712 KB Output is correct
4 Correct 19 ms 712 KB Output is correct
5 Correct 9 ms 712 KB Output is correct
6 Correct 3 ms 712 KB Output is correct
7 Correct 3 ms 712 KB Output is correct
8 Correct 3 ms 712 KB Output is correct
9 Correct 2 ms 712 KB Output is correct
10 Correct 2 ms 712 KB Output is correct
11 Correct 22 ms 712 KB Output is correct
12 Correct 18 ms 712 KB Output is correct
13 Correct 12 ms 712 KB Output is correct
14 Correct 7 ms 712 KB Output is correct
15 Correct 2 ms 712 KB Output is correct
16 Correct 3 ms 712 KB Output is correct
17 Correct 2 ms 712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 712 KB Output is correct
2 Correct 2 ms 712 KB Output is correct
3 Runtime error 4 ms 1172 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 712 KB Output is correct
2 Runtime error 4 ms 1172 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 9 ms 504 KB Output is correct
3 Correct 20 ms 712 KB Output is correct
4 Correct 19 ms 712 KB Output is correct
5 Correct 9 ms 712 KB Output is correct
6 Correct 3 ms 712 KB Output is correct
7 Correct 3 ms 712 KB Output is correct
8 Correct 3 ms 712 KB Output is correct
9 Correct 2 ms 712 KB Output is correct
10 Correct 2 ms 712 KB Output is correct
11 Correct 22 ms 712 KB Output is correct
12 Correct 18 ms 712 KB Output is correct
13 Correct 12 ms 712 KB Output is correct
14 Correct 7 ms 712 KB Output is correct
15 Correct 2 ms 712 KB Output is correct
16 Correct 3 ms 712 KB Output is correct
17 Correct 2 ms 712 KB Output is correct
18 Runtime error 3 ms 1172 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 9 ms 504 KB Output is correct
3 Correct 20 ms 712 KB Output is correct
4 Correct 19 ms 712 KB Output is correct
5 Correct 9 ms 712 KB Output is correct
6 Correct 3 ms 712 KB Output is correct
7 Correct 3 ms 712 KB Output is correct
8 Correct 3 ms 712 KB Output is correct
9 Correct 2 ms 712 KB Output is correct
10 Correct 2 ms 712 KB Output is correct
11 Correct 22 ms 712 KB Output is correct
12 Correct 18 ms 712 KB Output is correct
13 Correct 12 ms 712 KB Output is correct
14 Correct 7 ms 712 KB Output is correct
15 Correct 2 ms 712 KB Output is correct
16 Correct 3 ms 712 KB Output is correct
17 Correct 2 ms 712 KB Output is correct
18 Runtime error 3 ms 1172 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Halted 0 ms 0 KB -