답안 #564102

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
564102 2022-05-18T14:47:32 Z SeDunion Dango Maker (JOI18_dango_maker) C++17
13 / 100
3 ms 3856 KB
#include <iostream>
#include <cassert>
#include <algorithm>
#include <string>
#include <bitset> 
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#ifndef LOCAL
	#include <bits/stdc++.h>
	#define cerr if(false)cerr
#endif
 
using namespace std;
using ll = long long;

const int M = 222;

const int N = M*M*3 + 66;

vector<pair<int,int>>v1,v2;

int a[M][M];

int id1(int x, int y) {
	return x * M + y;
}

int id2(int x, int y) {
	return x * M + y + M*M;
}

int u12[N], used[N];

vector<int>g[N];

void dfs(int v, int &x, int &y) {
	used[v] = 1;
	x++;
	for (int to : g[v]) if (!used[to]) {
		dfs(to, y, x);
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	for (int i = 1 ; i <= n ; ++ i) {
		for (int j = 1 ; j <= m ; ++ j) {
			char c;
			cin >> c;
			if (c == 'R') a[i][j] = 0;
			else if (c == 'G') a[i][j] = 1;
			else a[i][j] = 2;
		}
	}
	for (int i = 1 ; i + 2 <= n ; ++ i) {
		for (int j = 1 ; j <= m ; ++ j) {
			if (a[i][j] == 0 && a[i + 1][j] == 1 && a[i + 2][j] == 2) {
				cerr << i << " " << j << " v1\n";
				u12[id1(i, j)] = 1;
				v1.emplace_back(i, j);
			}
		}
	}
	for (int i = 1 ; i <= n ; ++ i) {
		for (int j = 1 ; j + 2 <= m ; ++ j) {
			if (a[i][j] == 0 && a[i][j + 1] == 1 && a[i][j + 2] == 2) {
				cerr << i << " " << j << " v2\n";
				u12[id2(i, j)] = 1;
				v2.emplace_back(i, j);
			}
		}
	}
	for (auto [x1, y1] : v1) {
		for (auto [x2, y2] : v2) {
			if (x1 <= x2 && x2 <= x1 + 2 && y2 <= y1 && y1 <= y2 + 2) {
				cerr << x1 << " " << y1 << " | " << x2 << " " << y2 << endl;
				g[id1(x1,y1)].emplace_back(id2(x2,y2));
				g[id2(x2,y2)].emplace_back(id1(x1,y1));
			}
		}
	}
	int ans = 0;
	for (int i = 0 ; i < N ; ++ i) {
		if (!u12[i] || used[i]) continue;
		int x = 0, y = 0;
		dfs(i, x, y);
		ans += max(x, y);
	}
	cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3796 KB Output is correct
2 Correct 3 ms 3796 KB Output is correct
3 Correct 2 ms 3796 KB Output is correct
4 Correct 2 ms 3796 KB Output is correct
5 Correct 2 ms 3796 KB Output is correct
6 Correct 2 ms 3796 KB Output is correct
7 Correct 2 ms 3796 KB Output is correct
8 Correct 2 ms 3796 KB Output is correct
9 Correct 2 ms 3796 KB Output is correct
10 Correct 2 ms 3796 KB Output is correct
11 Correct 2 ms 3796 KB Output is correct
12 Correct 2 ms 3796 KB Output is correct
13 Correct 2 ms 3796 KB Output is correct
14 Correct 2 ms 3796 KB Output is correct
15 Correct 2 ms 3796 KB Output is correct
16 Correct 2 ms 3796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3796 KB Output is correct
2 Correct 3 ms 3796 KB Output is correct
3 Correct 2 ms 3796 KB Output is correct
4 Correct 2 ms 3796 KB Output is correct
5 Correct 2 ms 3796 KB Output is correct
6 Correct 2 ms 3796 KB Output is correct
7 Correct 2 ms 3796 KB Output is correct
8 Correct 2 ms 3796 KB Output is correct
9 Correct 2 ms 3796 KB Output is correct
10 Correct 2 ms 3796 KB Output is correct
11 Correct 2 ms 3796 KB Output is correct
12 Correct 2 ms 3796 KB Output is correct
13 Correct 2 ms 3796 KB Output is correct
14 Correct 2 ms 3796 KB Output is correct
15 Correct 2 ms 3796 KB Output is correct
16 Correct 2 ms 3796 KB Output is correct
17 Correct 2 ms 3796 KB Output is correct
18 Correct 2 ms 3796 KB Output is correct
19 Correct 2 ms 3796 KB Output is correct
20 Correct 2 ms 3796 KB Output is correct
21 Correct 2 ms 3796 KB Output is correct
22 Correct 3 ms 3856 KB Output is correct
23 Correct 2 ms 3796 KB Output is correct
24 Correct 3 ms 3808 KB Output is correct
25 Correct 3 ms 3800 KB Output is correct
26 Correct 2 ms 3796 KB Output is correct
27 Correct 2 ms 3796 KB Output is correct
28 Correct 2 ms 3796 KB Output is correct
29 Correct 2 ms 3804 KB Output is correct
30 Correct 2 ms 3800 KB Output is correct
31 Correct 2 ms 3796 KB Output is correct
32 Correct 2 ms 3800 KB Output is correct
33 Correct 2 ms 3796 KB Output is correct
34 Incorrect 3 ms 3796 KB Output isn't correct
35 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3796 KB Output is correct
2 Correct 3 ms 3796 KB Output is correct
3 Correct 2 ms 3796 KB Output is correct
4 Correct 2 ms 3796 KB Output is correct
5 Correct 2 ms 3796 KB Output is correct
6 Correct 2 ms 3796 KB Output is correct
7 Correct 2 ms 3796 KB Output is correct
8 Correct 2 ms 3796 KB Output is correct
9 Correct 2 ms 3796 KB Output is correct
10 Correct 2 ms 3796 KB Output is correct
11 Correct 2 ms 3796 KB Output is correct
12 Correct 2 ms 3796 KB Output is correct
13 Correct 2 ms 3796 KB Output is correct
14 Correct 2 ms 3796 KB Output is correct
15 Correct 2 ms 3796 KB Output is correct
16 Correct 2 ms 3796 KB Output is correct
17 Correct 2 ms 3796 KB Output is correct
18 Correct 2 ms 3796 KB Output is correct
19 Correct 2 ms 3796 KB Output is correct
20 Correct 2 ms 3796 KB Output is correct
21 Correct 2 ms 3796 KB Output is correct
22 Correct 3 ms 3856 KB Output is correct
23 Correct 2 ms 3796 KB Output is correct
24 Correct 3 ms 3808 KB Output is correct
25 Correct 3 ms 3800 KB Output is correct
26 Correct 2 ms 3796 KB Output is correct
27 Correct 2 ms 3796 KB Output is correct
28 Correct 2 ms 3796 KB Output is correct
29 Correct 2 ms 3804 KB Output is correct
30 Correct 2 ms 3800 KB Output is correct
31 Correct 2 ms 3796 KB Output is correct
32 Correct 2 ms 3800 KB Output is correct
33 Correct 2 ms 3796 KB Output is correct
34 Incorrect 3 ms 3796 KB Output isn't correct
35 Halted 0 ms 0 KB -