답안 #172861

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
172861 2020-01-02T17:03:39 Z dndhk 무지개나라 (APIO17_rainbow) C++14
0 / 100
22 ms 1648 KB
#include "rainbow.h"
#include <bits/stdc++.h>

#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define uniqv(v) (v).erase(unique(all(v)), (v).end())
#define pb push_back
#define FI first
#define SE second
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define test 1
#define TEST if(test)

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

const int MOD = 1000000007; // 998244353
const int INF = 2e9;
const ll INFLL = 1e18;
const int MAX_N1 = 50;

vector<pii> stage;

int N, M;

bool chk[MAX_N1+1][MAX_N1+1];
int type;

bool vst[MAX_N1+1][MAX_N1+1];
pii s, e;

void pro1(){
	type = 1;
	for(int i=0; i<stage.size(); i++){
		chk[stage[i].first][stage[i].second] = true;
	}
}
int dx[4] = {1, -1, 0, 0}, dy[4] = {0, 0, 1, -1};

void dfs(int x, int y){
	if(x<s.first || x>e.first || y<s.second || y>e.second)	return;
	if(chk[x][y] || vst[x][y])	return;
	vst[x][y] = true;
	for(int i=0; i<4; i++){
		dfs(x+dx[i], y+dy[i]);
	}
}

void pro2(){
	type = 2;
}

void pro3(){
	type = 3;
}


void init(int R, int C, int sr, int sc, int l, char *S) {
	N = R; M = C;
	stage.pb({sr, sc});
	for(int i=0; i<l; i++){
		if(S[i]=='N'){
			sr--;
		}else if(S[i]=='E'){
			sc++;
		}else if(S[i]=='W'){
			sc--;
		}else{
			sr++;
		}
		stage.pb({sr, sc});
	}
	if(R==2){
		pro2();
	}else if(R<=50 && C<=50){
		pro1();
	}else{
		pro3();
	}
}

int colour(int ar, int ac, int br, int bc) {
	if(type==1){
		int ans = 0;
		s = {ar, ac}; e = {br, bc};
		for(int i=1; i<=N; i++){
			for(int j=1; j<=M; j++){
				vst[i][j] = false;
			}
		}
		for(int i=ar; i<=br; i++){
			for(int j=ac; j<=bc; j++){
				if(!vst[i][j] && !chk[i][j]){
					dfs(i, j);
					ans++;
				}
			}
		}
		return ans;
	}
    return 0;
}

Compilation message

rainbow.cpp: In function 'void pro1()':
rainbow.cpp:40:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<stage.size(); i++){
               ~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 376 KB Output is correct
2 Correct 11 ms 376 KB Output is correct
3 Correct 21 ms 376 KB Output is correct
4 Correct 22 ms 376 KB Output is correct
5 Correct 11 ms 376 KB Output is correct
6 Correct 2 ms 360 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 19 ms 376 KB Output is correct
12 Correct 17 ms 504 KB Output is correct
13 Correct 14 ms 376 KB Output is correct
14 Correct 10 ms 504 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Incorrect 2 ms 376 KB Output isn't correct
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 5 ms 1648 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 376 KB Output is correct
2 Correct 11 ms 376 KB Output is correct
3 Correct 21 ms 376 KB Output is correct
4 Correct 22 ms 376 KB Output is correct
5 Correct 11 ms 376 KB Output is correct
6 Correct 2 ms 360 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 19 ms 376 KB Output is correct
12 Correct 17 ms 504 KB Output is correct
13 Correct 14 ms 376 KB Output is correct
14 Correct 10 ms 504 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Incorrect 2 ms 376 KB Output isn't correct
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 376 KB Output is correct
2 Correct 11 ms 376 KB Output is correct
3 Correct 21 ms 376 KB Output is correct
4 Correct 22 ms 376 KB Output is correct
5 Correct 11 ms 376 KB Output is correct
6 Correct 2 ms 360 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 19 ms 376 KB Output is correct
12 Correct 17 ms 504 KB Output is correct
13 Correct 14 ms 376 KB Output is correct
14 Correct 10 ms 504 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Incorrect 2 ms 376 KB Output isn't correct
17 Halted 0 ms 0 KB -