답안 #483948

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
483948 2021-11-01T14:20:25 Z ymm Dango Maker (JOI18_dango_maker) C++17
100 / 100
508 ms 128352 KB
///
///   You fell for it, fool!
///   Thunder Cross Split Attack!
///

#include <bits/stdc++.h>
#define Loop(x,l,r) for(ll x = ll(l); x < ll(r); ++x)
typedef long long ll;
typedef std::pair<int,int> pii;
using namespace std;

const int N = 3009;
int ch, cv;
char a[N][N];
int n, m;
int mch[N*N];
pair<int,int> par[N*N];
bitset<N*N> vis;
vector<int> dard;

bool gdh(int i, int j){return 0 <= i && i < n && 0 <= j && j+3 <= m && a[i][j] == 'R' && a[i][j+1] == 'G' && a[i][j+2] == 'W';}
bool gdv(int i, int j){return 0 <= i && i+2 <= n && 0 <= j && j < m && a[i][j] == 'R' && a[i+1][j] == 'G' && a[i+2][j] == 'W';}

bool bfs(int s)
{
	par[s] = {-1, -1};
	vector<int> q;
	q.push_back(s); vis[s] = 1;
	for(int i = 0; i < q.size(); ++i)
	{
		auto v = q[i];
		Loop(i,0,3)
		{
			if(!gdv(v/N-i,v%N+i)) continue;
			int u = v-i*(N-1);
			if(mch[u] == -1){
				while(v != -1){
					mch[u] = v;
					u = par[v].second;
					v = par[v].first;
				}
				for(int z : q) vis[z] = 0;
				return 1;
			}
			if(vis[mch[u]]) continue;
			q.push_back(mch[u]);
			vis[mch[u]] = 1;
			par[mch[u]] = {v, u};
		}
	}
	return 0;
}

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m;
	Loop(i,0,n) cin >> a[i];
	int ans = 0;
	Loop(i,0,n) Loop(j,0,m) {
		if(gdh(i,j)) dard.push_back(N*i+j);
		if(gdv(i,j)) ++ans;
	}
	ans += dard.size();
	srand(time(0));
	//random_shuffle(dard.begin(), dard.end());
	memset(mch, -1, sizeof mch);
	for(int v : dard)
	{
		ans -= bfs(v);
	}
	cout << ans << '\n';
}

Compilation message

dango_maker.cpp: In function 'bool bfs(int)':
dango_maker.cpp:29:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |  for(int i = 0; i < q.size(); ++i)
      |                 ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 35660 KB Output is correct
2 Correct 13 ms 35660 KB Output is correct
3 Correct 13 ms 35660 KB Output is correct
4 Correct 13 ms 35676 KB Output is correct
5 Correct 13 ms 35724 KB Output is correct
6 Correct 16 ms 35788 KB Output is correct
7 Correct 15 ms 35692 KB Output is correct
8 Correct 13 ms 35712 KB Output is correct
9 Correct 13 ms 35716 KB Output is correct
10 Correct 13 ms 35772 KB Output is correct
11 Correct 13 ms 35712 KB Output is correct
12 Correct 14 ms 35660 KB Output is correct
13 Correct 12 ms 35788 KB Output is correct
14 Correct 13 ms 35660 KB Output is correct
15 Correct 13 ms 35684 KB Output is correct
16 Correct 13 ms 35676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 35660 KB Output is correct
2 Correct 13 ms 35660 KB Output is correct
3 Correct 13 ms 35660 KB Output is correct
4 Correct 13 ms 35676 KB Output is correct
5 Correct 13 ms 35724 KB Output is correct
6 Correct 16 ms 35788 KB Output is correct
7 Correct 15 ms 35692 KB Output is correct
8 Correct 13 ms 35712 KB Output is correct
9 Correct 13 ms 35716 KB Output is correct
10 Correct 13 ms 35772 KB Output is correct
11 Correct 13 ms 35712 KB Output is correct
12 Correct 14 ms 35660 KB Output is correct
13 Correct 12 ms 35788 KB Output is correct
14 Correct 13 ms 35660 KB Output is correct
15 Correct 13 ms 35684 KB Output is correct
16 Correct 13 ms 35676 KB Output is correct
17 Correct 13 ms 35788 KB Output is correct
18 Correct 13 ms 35752 KB Output is correct
19 Correct 13 ms 35788 KB Output is correct
20 Correct 17 ms 35804 KB Output is correct
21 Correct 16 ms 35924 KB Output is correct
22 Correct 13 ms 35788 KB Output is correct
23 Correct 14 ms 35804 KB Output is correct
24 Correct 15 ms 35680 KB Output is correct
25 Correct 13 ms 35788 KB Output is correct
26 Correct 14 ms 35788 KB Output is correct
27 Correct 13 ms 35848 KB Output is correct
28 Correct 13 ms 35804 KB Output is correct
29 Correct 13 ms 35788 KB Output is correct
30 Correct 13 ms 35788 KB Output is correct
31 Correct 13 ms 35788 KB Output is correct
32 Correct 13 ms 35788 KB Output is correct
33 Correct 13 ms 35748 KB Output is correct
34 Correct 13 ms 35800 KB Output is correct
35 Correct 13 ms 35788 KB Output is correct
36 Correct 13 ms 35736 KB Output is correct
37 Correct 13 ms 35788 KB Output is correct
38 Correct 13 ms 35824 KB Output is correct
39 Correct 13 ms 35788 KB Output is correct
40 Correct 14 ms 35756 KB Output is correct
41 Correct 13 ms 35840 KB Output is correct
42 Correct 13 ms 35788 KB Output is correct
43 Correct 13 ms 35768 KB Output is correct
44 Correct 13 ms 35840 KB Output is correct
45 Correct 15 ms 35808 KB Output is correct
46 Correct 13 ms 35752 KB Output is correct
47 Correct 13 ms 35788 KB Output is correct
48 Correct 14 ms 35812 KB Output is correct
49 Correct 13 ms 35788 KB Output is correct
50 Correct 13 ms 35788 KB Output is correct
51 Correct 13 ms 35744 KB Output is correct
52 Correct 13 ms 35788 KB Output is correct
53 Correct 14 ms 35792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 35660 KB Output is correct
2 Correct 13 ms 35660 KB Output is correct
3 Correct 13 ms 35660 KB Output is correct
4 Correct 13 ms 35676 KB Output is correct
5 Correct 13 ms 35724 KB Output is correct
6 Correct 16 ms 35788 KB Output is correct
7 Correct 15 ms 35692 KB Output is correct
8 Correct 13 ms 35712 KB Output is correct
9 Correct 13 ms 35716 KB Output is correct
10 Correct 13 ms 35772 KB Output is correct
11 Correct 13 ms 35712 KB Output is correct
12 Correct 14 ms 35660 KB Output is correct
13 Correct 12 ms 35788 KB Output is correct
14 Correct 13 ms 35660 KB Output is correct
15 Correct 13 ms 35684 KB Output is correct
16 Correct 13 ms 35676 KB Output is correct
17 Correct 13 ms 35788 KB Output is correct
18 Correct 13 ms 35752 KB Output is correct
19 Correct 13 ms 35788 KB Output is correct
20 Correct 17 ms 35804 KB Output is correct
21 Correct 16 ms 35924 KB Output is correct
22 Correct 13 ms 35788 KB Output is correct
23 Correct 14 ms 35804 KB Output is correct
24 Correct 15 ms 35680 KB Output is correct
25 Correct 13 ms 35788 KB Output is correct
26 Correct 14 ms 35788 KB Output is correct
27 Correct 13 ms 35848 KB Output is correct
28 Correct 13 ms 35804 KB Output is correct
29 Correct 13 ms 35788 KB Output is correct
30 Correct 13 ms 35788 KB Output is correct
31 Correct 13 ms 35788 KB Output is correct
32 Correct 13 ms 35788 KB Output is correct
33 Correct 13 ms 35748 KB Output is correct
34 Correct 13 ms 35800 KB Output is correct
35 Correct 13 ms 35788 KB Output is correct
36 Correct 13 ms 35736 KB Output is correct
37 Correct 13 ms 35788 KB Output is correct
38 Correct 13 ms 35824 KB Output is correct
39 Correct 13 ms 35788 KB Output is correct
40 Correct 14 ms 35756 KB Output is correct
41 Correct 13 ms 35840 KB Output is correct
42 Correct 13 ms 35788 KB Output is correct
43 Correct 13 ms 35768 KB Output is correct
44 Correct 13 ms 35840 KB Output is correct
45 Correct 15 ms 35808 KB Output is correct
46 Correct 13 ms 35752 KB Output is correct
47 Correct 13 ms 35788 KB Output is correct
48 Correct 14 ms 35812 KB Output is correct
49 Correct 13 ms 35788 KB Output is correct
50 Correct 13 ms 35788 KB Output is correct
51 Correct 13 ms 35744 KB Output is correct
52 Correct 13 ms 35788 KB Output is correct
53 Correct 14 ms 35792 KB Output is correct
54 Correct 14 ms 35688 KB Output is correct
55 Correct 17 ms 44492 KB Output is correct
56 Correct 13 ms 35840 KB Output is correct
57 Correct 17 ms 47436 KB Output is correct
58 Correct 35 ms 50848 KB Output is correct
59 Correct 179 ms 117840 KB Output is correct
60 Correct 191 ms 117688 KB Output is correct
61 Correct 178 ms 117684 KB Output is correct
62 Correct 14 ms 35788 KB Output is correct
63 Correct 182 ms 117768 KB Output is correct
64 Correct 403 ms 128352 KB Output is correct
65 Correct 420 ms 128184 KB Output is correct
66 Correct 508 ms 128180 KB Output is correct
67 Correct 72 ms 44468 KB Output is correct
68 Correct 70 ms 44764 KB Output is correct
69 Correct 80 ms 56388 KB Output is correct
70 Correct 53 ms 52212 KB Output is correct
71 Correct 54 ms 52288 KB Output is correct
72 Correct 54 ms 52312 KB Output is correct
73 Correct 54 ms 52308 KB Output is correct
74 Correct 55 ms 52268 KB Output is correct
75 Correct 56 ms 52348 KB Output is correct
76 Correct 60 ms 52272 KB Output is correct
77 Correct 60 ms 52276 KB Output is correct
78 Correct 55 ms 52216 KB Output is correct
79 Correct 54 ms 52280 KB Output is correct
80 Correct 54 ms 52276 KB Output is correct
81 Correct 57 ms 52284 KB Output is correct
82 Correct 54 ms 52236 KB Output is correct
83 Correct 55 ms 52376 KB Output is correct
84 Correct 59 ms 52356 KB Output is correct
85 Correct 55 ms 52196 KB Output is correct
86 Correct 64 ms 52260 KB Output is correct
87 Correct 55 ms 52236 KB Output is correct
88 Correct 52 ms 52280 KB Output is correct
89 Correct 55 ms 52308 KB Output is correct
90 Correct 57 ms 52280 KB Output is correct