답안 #169259

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
169259 2019-12-19T11:13:51 Z mohammad_kilani 무지개나라 (APIO17_rainbow) C++17
35 / 100
2252 ms 15968 KB
#include "rainbow.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
vector< int > arr[N];

int n , m;

int cnt = 0 , dsu[N << 1];

int Find(int u){
	return (u == dsu[u] ? u : dsu[u] = Find(dsu[u]));
}

void init(int R, int C, int sr, int sc, int M, char *S) {
	n = R,  m = C;
	arr[sr].push_back(sc);
	for(int i = 0 ;i < M;i++){
		if(S[i] == 'N') sr--; else if(S[i] == 'S') sr++; else if(S[i] == 'E') sc++; else sc--;
		arr[sr].push_back(sc);
	}
	for(int i = 1;i <= R;i++){
		sort(arr[i].begin(),arr[i].end());
		arr[i].resize(unique(arr[i].begin(),arr[i].end()) - arr[i].begin());
	}
}

vector < pair<int,int> > cur , pre;


int colour(int ar, int ac, int br, int bc) {
	int ans = 0 , a , b, j;
	cur.clear();
	pre.clear();
	for(int i = ar ;i <= br;i++){
		j = lower_bound(arr[i].begin(),arr[i].end(), ac) - arr[i].begin();
		a = ac - 1;
		while(j < (int)arr[i].size() && arr[i][j] <= bc){
			if(a + 1 <= arr[i][j] - 1){
				cur.push_back(make_pair(a + 1 , arr[i][j] - 1));
			}
			a = arr[i][j];
			j++;
		}
		if(a + 1 <= bc) cur.push_back(make_pair(a + 1,  bc));
		ans += (int)cur.size();
		for(j = 0 ;j < (int)cur.size();j++){
			dsu[cnt + j] = cnt + j;
		}
		j = 0;
		for(int i = 0;i < (int)cur.size();i++){
			while(j < (int)pre.size() && pre[j].second < cur[i].first) j++;
			while(j < (int)pre.size() && pre[j].first <= cur[i].second){
				a = Find(cnt - (int)pre.size() + j);
				b = Find(cnt + i);
				if(a != b){
					ans--;
					dsu[a] = b;
				}
				j++;
			}
			if(j)
				j--;
		}
		cnt += (int)cur.size();
		swap(pre , cur);
		cur.clear();
	}
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 5112 KB Output is correct
2 Correct 9 ms 5368 KB Output is correct
3 Correct 7 ms 5112 KB Output is correct
4 Correct 8 ms 5212 KB Output is correct
5 Correct 10 ms 5292 KB Output is correct
6 Correct 6 ms 4964 KB Output is correct
7 Correct 6 ms 4984 KB Output is correct
8 Correct 6 ms 4984 KB Output is correct
9 Correct 6 ms 4984 KB Output is correct
10 Correct 6 ms 4956 KB Output is correct
11 Correct 8 ms 5240 KB Output is correct
12 Correct 9 ms 5240 KB Output is correct
13 Correct 12 ms 5756 KB Output is correct
14 Correct 10 ms 5756 KB Output is correct
15 Correct 6 ms 4984 KB Output is correct
16 Correct 6 ms 4984 KB Output is correct
17 Correct 6 ms 4984 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 4984 KB Output is correct
2 Correct 6 ms 4984 KB Output is correct
3 Runtime error 2252 ms 15968 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 4984 KB Output is correct
2 Correct 11 ms 6000 KB Output is correct
3 Correct 17 ms 8568 KB Output is correct
4 Correct 15 ms 7032 KB Output is correct
5 Correct 15 ms 7160 KB Output is correct
6 Correct 15 ms 6264 KB Output is correct
7 Correct 15 ms 6236 KB Output is correct
8 Correct 9 ms 5748 KB Output is correct
9 Correct 10 ms 5752 KB Output is correct
10 Correct 8 ms 5368 KB Output is correct
11 Correct 11 ms 5752 KB Output is correct
12 Correct 10 ms 5748 KB Output is correct
13 Correct 14 ms 8312 KB Output is correct
14 Correct 13 ms 6776 KB Output is correct
15 Correct 13 ms 6896 KB Output is correct
16 Correct 14 ms 6264 KB Output is correct
17 Correct 13 ms 6136 KB Output is correct
18 Correct 12 ms 6136 KB Output is correct
19 Correct 14 ms 7412 KB Output is correct
20 Correct 13 ms 7156 KB Output is correct
21 Correct 10 ms 5876 KB Output is correct
22 Correct 11 ms 5880 KB Output is correct
23 Correct 11 ms 5752 KB Output is correct
24 Correct 15 ms 6132 KB Output is correct
25 Correct 15 ms 6384 KB Output is correct
26 Correct 22 ms 9396 KB Output is correct
27 Correct 19 ms 7800 KB Output is correct
28 Correct 19 ms 7924 KB Output is correct
29 Correct 17 ms 6520 KB Output is correct
30 Correct 16 ms 6648 KB Output is correct
31 Correct 15 ms 6776 KB Output is correct
32 Correct 17 ms 7792 KB Output is correct
33 Correct 17 ms 7796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 5112 KB Output is correct
2 Correct 9 ms 5368 KB Output is correct
3 Correct 7 ms 5112 KB Output is correct
4 Correct 8 ms 5212 KB Output is correct
5 Correct 10 ms 5292 KB Output is correct
6 Correct 6 ms 4964 KB Output is correct
7 Correct 6 ms 4984 KB Output is correct
8 Correct 6 ms 4984 KB Output is correct
9 Correct 6 ms 4984 KB Output is correct
10 Correct 6 ms 4956 KB Output is correct
11 Correct 8 ms 5240 KB Output is correct
12 Correct 9 ms 5240 KB Output is correct
13 Correct 12 ms 5756 KB Output is correct
14 Correct 10 ms 5756 KB Output is correct
15 Correct 6 ms 4984 KB Output is correct
16 Correct 6 ms 4984 KB Output is correct
17 Correct 6 ms 4984 KB Output is correct
18 Runtime error 28 ms 14456 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 5112 KB Output is correct
2 Correct 9 ms 5368 KB Output is correct
3 Correct 7 ms 5112 KB Output is correct
4 Correct 8 ms 5212 KB Output is correct
5 Correct 10 ms 5292 KB Output is correct
6 Correct 6 ms 4964 KB Output is correct
7 Correct 6 ms 4984 KB Output is correct
8 Correct 6 ms 4984 KB Output is correct
9 Correct 6 ms 4984 KB Output is correct
10 Correct 6 ms 4956 KB Output is correct
11 Correct 8 ms 5240 KB Output is correct
12 Correct 9 ms 5240 KB Output is correct
13 Correct 12 ms 5756 KB Output is correct
14 Correct 10 ms 5756 KB Output is correct
15 Correct 6 ms 4984 KB Output is correct
16 Correct 6 ms 4984 KB Output is correct
17 Correct 6 ms 4984 KB Output is correct
18 Runtime error 28 ms 14456 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Halted 0 ms 0 KB -