답안 #478043

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
478043 2021-10-05T10:23:15 Z flappybird Navigation 2 (JOI21_navigation2) C++17
100 / 100
951 ms 1024 KB
#include "Anna.h"
#include <bits/stdc++.h>

typedef int ll;
using namespace std;

namespace {
	ll N;
	ll mp[200][200];
	ll flag[200][200];
	bool chk(ll i, ll j) {
		return 0 <= i && i < N && 0 <= j && j < N;
	}

} // namespace

void Anna(int N, int K, std::vector<int> R, std::vector<int> C) {
	::N = N;
	ll i, j, k;
	for (i = 0; i < N; i++) {
		for (j = 0; j < N; j++) mp[i][j] = flag[i][j] = 0;
	}
	vector<vector<ll>> v(3, vector<ll>(3));
	v[(R[0] + 1) % 3][(C[0] + 1) % 3] = 1;
	v[(R[1] + 1) % 3][(C[1]) % 3] = 1;
	v[(R[2] + 1) % 3][(C[2] + 2) % 3] = 1;
	v[(R[3]) % 3][(C[3] + 1) % 3] = 1;
	v[(R[4]) % 3][(C[4] + 2) % 3] = 1;
	v[(R[5] + 2) % 3][(C[5] + 1) % 3] = 1;
	v[(R[6] + 2) % 3][(C[6] + 2) % 3] = 1;
	for (i = 0; i < 3; i++) {
		for (j = 0; j < 3; j++) {
			if (!v[i][j]) goto a;
		}
	}
	a:
	ll p = i, q = j;
	for (i = p - 3; i < N + 3; i += 3) {
		for (j = q - 3; j < N + 3; j += 3) {
			if (chk(i, j)) mp[i][j] = 12;
			if (chk(i - 1, j - 1)) mp[i - 1][j - 1] = 0;
			if (chk(i - 1, j)) mp[i - 1][j] = 1;
			if (chk(i - 1, j + 1)) mp[i - 1][j + 1] = 2;
			if (chk(i, j - 1)) mp[i][j - 1] = 3;
			if (chk(i, j + 1)) mp[i][j + 1] = 4;
			if (chk(i + 1, j - 1)) mp[i + 1][j - 1] = 5;
			if (chk(i + 1, j)) mp[i + 1][j] = -1;
			if (chk(i + 1, j + 1)) mp[i + 1][j + 1] = 6;
		}
	}
	vector<ll> asdf(13);
	for (i = 0; i < N; i++) {
		for (j = 0; j < N; j++) {
			ll f;
			if (0 <= mp[i][j] && mp[i][j] <= 6) {
				f = mp[i][j];
				ll r = R[f];
				ll c = C[f];
				if (max(abs(r - i), abs(c - j)) <= 1) {
					if (r == i - 1 && c == j - 1) flag[i][j] = 5;
					else if (r == i - 1 && c == j) flag[i][j] = 6;
					else if (r == i - 1 && c == j + 1) flag[i][j] = 7;
					else if (r == i && c == j - 1) flag[i][j] = 8;
					else if (r == i && c == j + 1) flag[i][j] = 9;
					else if (r == i + 1 && c == j - 1) flag[i][j] = 10;
					else if (r == i + 1 && c == j) flag[i][j] = 11;
					else if (r == i + 1 && c == j + 1) flag[i][j] = 12;
				}
				else {
					if (r + 1 < i) flag[i][j] = 1;
					else if (i + 1 < r) flag[i][j] = 2;
					else if (c < j) flag[i][j] = 3;
					else flag[i][j] = 4;
				}
				asdf[flag[i][j]] = 1;
			}
		}
	}
	ll c;
	for (i = 5; i <= 12; i++) if (asdf[i] == 0) break;
	c = i;
	for (i = 0; i < N; i++) {
		for (j = 0; j < N; j++) {
			if (mp[i][j] == -1) SetFlag(i, j, c - 4);
			else if (flag[i][j] == 0) SetFlag(i, j, 12);
			else if (flag[i][j] > c) SetFlag(i, j, flag[i][j] - 1);
			else SetFlag(i, j, flag[i][j]);
		}
	}
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
typedef int ll;

/*
 3
140
 2
*/

namespace {

int variable_example = 1;

ll f(pair<ll, ll> p) {
	if (!p.first && !p.second) return 4;
	if (p.second < 0) return 1;
	if (p.second > 0) return 0;
	if (p.first > 0) return 2;
	else return 3;
}

} // namespace

std::vector<int> Bruno(int K, std::vector<int> value) {
	vector<ll> ret(7);
	ll c;
	for (c = 0; c < 9; c++) if (value[c] == 12) break;
	ll x = value[(c + 3) % 9] + 4;
	ll xl = (c + 3) % 9;
	ll i;
	vector<pair<ll, ll>> loc(9);
	for (i = 0; i < 9; i++) {
		if (i == c || i == xl) continue;
		if (value[i] >= x) value[i]++;
		if (value[i] == 1) loc[i] = { -3, 0 };
		else if (value[i] == 2) loc[i] = { 3, 0 };
		else if (value[i] == 3) loc[i] = { 0, -3 };
		else if (value[i] == 4) loc[i] = { 0, 3 };
		else {
			if (value[i] == 5) loc[i] = { -1, -1 };
			if (value[i] == 6) loc[i] = { -1, 0 };
			if (value[i] == 7) loc[i] = { -1, 1 };
			if (value[i] == 8) loc[i] = { 0, -1 };
			if (value[i] == 9) loc[i] = { 0, 1 };
			if (value[i] == 10) loc[i] = { 1, -1 };
			if (value[i] == 11) loc[i] = { 1, 0 };
			if (value[i] == 12) loc[i] = { 1, 1 };
			loc[i].first += i / 3;
			loc[i].second += i % 3;
			loc[i].first--;
			loc[i].second--;
		}
	}
	if (c % 3 == 0) {
		ret[0] = f(loc[(c + 8) % 9]);
		ret[1] = f(loc[(c + 6) % 9]);
		ret[2] = f(loc[(c + 7) % 9]);
		ret[3] = f(loc[(c + 2) % 9]);
		ret[4] = f(loc[(c + 1) % 9]);
		ret[5] = f(loc[(c + 5) % 9]);
		ret[6] = f(loc[(c + 4) % 9]);
	}
	if (c % 3 == 1) {
		ret[0] = f(loc[(c + 5) % 9]);
		ret[1] = f(loc[(c + 6) % 9]);
		ret[2] = f(loc[(c + 7) % 9]);
		ret[3] = f(loc[(c + 8) % 9]);
		ret[4] = f(loc[(c + 1) % 9]);
		ret[5] = f(loc[(c + 2) % 9]);
		ret[6] = f(loc[(c + 4) % 9]);
	}
	if (c % 3 == 2) {
		ret[0] = f(loc[(c + 5) % 9]);
		ret[1] = f(loc[(c + 6) % 9]);
		ret[2] = f(loc[(c + 4) % 9]);
		ret[3] = f(loc[(c + 8) % 9]);
		ret[4] = f(loc[(c + 7) % 9]);
		ret[5] = f(loc[(c + 2) % 9]);
		ret[6] = f(loc[(c + 1) % 9]);
	}
	return ret;
}

Compilation message

Anna.cpp: In function 'void Anna(int, int, std::vector<int>, std::vector<int>)':
Anna.cpp:19:11: warning: unused variable 'k' [-Wunused-variable]
   19 |  ll i, j, k;
      |           ^

Bruno.cpp:14:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
   14 | int variable_example = 1;
      |     ^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 392 KB Output is correct
2 Correct 11 ms 392 KB Output is correct
3 Correct 15 ms 392 KB Output is correct
4 Correct 14 ms 392 KB Output is correct
5 Correct 10 ms 472 KB Output is correct
6 Correct 15 ms 392 KB Output is correct
7 Correct 16 ms 392 KB Output is correct
8 Correct 11 ms 520 KB Output is correct
9 Correct 15 ms 392 KB Output is correct
10 Correct 15 ms 392 KB Output is correct
11 Correct 15 ms 476 KB Output is correct
12 Correct 18 ms 480 KB Output is correct
13 Correct 18 ms 392 KB Output is correct
14 Correct 14 ms 392 KB Output is correct
15 Correct 12 ms 392 KB Output is correct
16 Correct 12 ms 392 KB Output is correct
17 Correct 17 ms 392 KB Output is correct
18 Correct 14 ms 392 KB Output is correct
19 Correct 15 ms 392 KB Output is correct
20 Correct 13 ms 388 KB Output is correct
21 Correct 16 ms 392 KB Output is correct
22 Correct 14 ms 392 KB Output is correct
23 Correct 14 ms 392 KB Output is correct
24 Correct 14 ms 392 KB Output is correct
25 Correct 13 ms 392 KB Output is correct
26 Correct 15 ms 392 KB Output is correct
27 Correct 15 ms 392 KB Output is correct
28 Correct 17 ms 392 KB Output is correct
29 Correct 15 ms 392 KB Output is correct
30 Correct 10 ms 472 KB Output is correct
31 Correct 16 ms 476 KB Output is correct
32 Correct 14 ms 392 KB Output is correct
33 Correct 14 ms 388 KB Output is correct
34 Correct 12 ms 392 KB Output is correct
35 Correct 15 ms 392 KB Output is correct
36 Correct 11 ms 392 KB Output is correct
37 Correct 14 ms 392 KB Output is correct
38 Correct 16 ms 392 KB Output is correct
39 Correct 16 ms 392 KB Output is correct
40 Correct 15 ms 392 KB Output is correct
41 Correct 16 ms 392 KB Output is correct
42 Correct 14 ms 392 KB Output is correct
43 Correct 19 ms 392 KB Output is correct
44 Correct 15 ms 392 KB Output is correct
45 Correct 15 ms 392 KB Output is correct
46 Correct 19 ms 392 KB Output is correct
47 Correct 12 ms 392 KB Output is correct
48 Correct 15 ms 392 KB Output is correct
49 Correct 17 ms 392 KB Output is correct
50 Correct 16 ms 392 KB Output is correct
51 Correct 19 ms 392 KB Output is correct
52 Correct 13 ms 392 KB Output is correct
53 Correct 16 ms 400 KB Output is correct
54 Correct 15 ms 392 KB Output is correct
55 Correct 16 ms 392 KB Output is correct
56 Correct 17 ms 472 KB Output is correct
57 Correct 17 ms 392 KB Output is correct
58 Correct 18 ms 392 KB Output is correct
59 Correct 18 ms 392 KB Output is correct
60 Correct 17 ms 480 KB Output is correct
61 Correct 18 ms 392 KB Output is correct
62 Correct 19 ms 392 KB Output is correct
63 Correct 24 ms 392 KB Output is correct
64 Correct 21 ms 392 KB Output is correct
65 Correct 13 ms 392 KB Output is correct
66 Correct 19 ms 392 KB Output is correct
67 Correct 17 ms 392 KB Output is correct
68 Correct 18 ms 392 KB Output is correct
69 Correct 17 ms 392 KB Output is correct
70 Correct 24 ms 392 KB Output is correct
71 Correct 17 ms 392 KB Output is correct
72 Correct 20 ms 392 KB Output is correct
73 Correct 19 ms 392 KB Output is correct
74 Correct 20 ms 392 KB Output is correct
75 Correct 22 ms 480 KB Output is correct
76 Correct 18 ms 392 KB Output is correct
77 Correct 18 ms 392 KB Output is correct
78 Correct 23 ms 392 KB Output is correct
79 Correct 17 ms 392 KB Output is correct
80 Correct 15 ms 392 KB Output is correct
81 Correct 18 ms 480 KB Output is correct
82 Correct 18 ms 392 KB Output is correct
83 Correct 19 ms 392 KB Output is correct
84 Correct 17 ms 392 KB Output is correct
85 Correct 19 ms 392 KB Output is correct
86 Correct 19 ms 392 KB Output is correct
87 Correct 20 ms 392 KB Output is correct
88 Correct 20 ms 392 KB Output is correct
89 Correct 20 ms 392 KB Output is correct
90 Correct 19 ms 392 KB Output is correct
91 Correct 18 ms 392 KB Output is correct
92 Correct 19 ms 392 KB Output is correct
93 Correct 17 ms 392 KB Output is correct
94 Correct 19 ms 392 KB Output is correct
95 Correct 19 ms 392 KB Output is correct
96 Correct 17 ms 392 KB Output is correct
97 Correct 18 ms 392 KB Output is correct
98 Correct 25 ms 392 KB Output is correct
99 Correct 18 ms 392 KB Output is correct
100 Correct 24 ms 392 KB Output is correct
101 Correct 18 ms 392 KB Output is correct
102 Correct 24 ms 392 KB Output is correct
103 Correct 23 ms 392 KB Output is correct
104 Correct 19 ms 392 KB Output is correct
105 Correct 20 ms 392 KB Output is correct
106 Correct 17 ms 392 KB Output is correct
107 Correct 18 ms 392 KB Output is correct
108 Correct 18 ms 392 KB Output is correct
109 Correct 16 ms 392 KB Output is correct
110 Correct 18 ms 496 KB Output is correct
111 Correct 22 ms 392 KB Output is correct
112 Correct 22 ms 392 KB Output is correct
113 Correct 17 ms 392 KB Output is correct
114 Correct 18 ms 472 KB Output is correct
115 Correct 25 ms 392 KB Output is correct
116 Correct 20 ms 392 KB Output is correct
117 Correct 18 ms 392 KB Output is correct
118 Correct 26 ms 392 KB Output is correct
119 Correct 19 ms 392 KB Output is correct
120 Correct 695 ms 836 KB Output is correct
121 Correct 760 ms 840 KB Output is correct
122 Correct 842 ms 760 KB Output is correct
123 Correct 682 ms 872 KB Output is correct
124 Correct 839 ms 856 KB Output is correct
125 Correct 708 ms 876 KB Output is correct
126 Correct 700 ms 900 KB Output is correct
127 Correct 698 ms 848 KB Output is correct
128 Correct 773 ms 840 KB Output is correct
129 Correct 723 ms 796 KB Output is correct
130 Correct 713 ms 764 KB Output is correct
131 Correct 691 ms 872 KB Output is correct
132 Correct 756 ms 792 KB Output is correct
133 Correct 706 ms 772 KB Output is correct
134 Correct 765 ms 848 KB Output is correct
135 Correct 787 ms 780 KB Output is correct
136 Correct 752 ms 904 KB Output is correct
137 Correct 746 ms 864 KB Output is correct
138 Correct 725 ms 896 KB Output is correct
139 Correct 718 ms 916 KB Output is correct
140 Correct 683 ms 876 KB Output is correct
141 Correct 733 ms 900 KB Output is correct
142 Correct 710 ms 660 KB Output is correct
143 Correct 706 ms 752 KB Output is correct
144 Correct 713 ms 900 KB Output is correct
145 Correct 826 ms 872 KB Output is correct
146 Correct 706 ms 760 KB Output is correct
147 Correct 723 ms 784 KB Output is correct
148 Correct 711 ms 856 KB Output is correct
149 Correct 678 ms 864 KB Output is correct
150 Correct 862 ms 856 KB Output is correct
151 Correct 735 ms 700 KB Output is correct
152 Correct 728 ms 744 KB Output is correct
153 Correct 705 ms 1012 KB Output is correct
154 Correct 692 ms 768 KB Output is correct
155 Correct 726 ms 828 KB Output is correct
156 Correct 689 ms 960 KB Output is correct
157 Correct 693 ms 792 KB Output is correct
158 Correct 724 ms 816 KB Output is correct
159 Correct 674 ms 960 KB Output is correct
160 Correct 695 ms 932 KB Output is correct
161 Correct 708 ms 840 KB Output is correct
162 Correct 725 ms 716 KB Output is correct
163 Correct 694 ms 1000 KB Output is correct
164 Correct 707 ms 848 KB Output is correct
165 Correct 697 ms 848 KB Output is correct
166 Correct 736 ms 812 KB Output is correct
167 Correct 704 ms 892 KB Output is correct
168 Correct 690 ms 704 KB Output is correct
169 Correct 684 ms 916 KB Output is correct
170 Correct 683 ms 752 KB Output is correct
171 Correct 701 ms 760 KB Output is correct
172 Correct 680 ms 764 KB Output is correct
173 Correct 718 ms 848 KB Output is correct
174 Correct 797 ms 1008 KB Output is correct
175 Correct 693 ms 964 KB Output is correct
176 Correct 902 ms 884 KB Output is correct
177 Correct 768 ms 1024 KB Output is correct
178 Correct 742 ms 768 KB Output is correct
179 Correct 817 ms 968 KB Output is correct
180 Correct 703 ms 864 KB Output is correct
181 Correct 734 ms 712 KB Output is correct
182 Correct 699 ms 776 KB Output is correct
183 Correct 705 ms 808 KB Output is correct
184 Correct 713 ms 828 KB Output is correct
185 Correct 704 ms 908 KB Output is correct
186 Correct 693 ms 936 KB Output is correct
187 Correct 763 ms 720 KB Output is correct
188 Correct 951 ms 748 KB Output is correct
189 Correct 714 ms 900 KB Output is correct
190 Correct 730 ms 860 KB Output is correct
191 Correct 697 ms 708 KB Output is correct
192 Correct 772 ms 828 KB Output is correct
193 Correct 684 ms 816 KB Output is correct
194 Correct 705 ms 780 KB Output is correct
195 Correct 717 ms 964 KB Output is correct
196 Correct 675 ms 760 KB Output is correct
197 Correct 689 ms 844 KB Output is correct
198 Correct 695 ms 880 KB Output is correct
199 Correct 681 ms 888 KB Output is correct
200 Correct 699 ms 968 KB Output is correct
201 Correct 692 ms 876 KB Output is correct
202 Correct 778 ms 756 KB Output is correct
203 Correct 692 ms 680 KB Output is correct
204 Correct 691 ms 800 KB Output is correct
205 Correct 752 ms 836 KB Output is correct
206 Correct 707 ms 872 KB Output is correct
207 Correct 695 ms 968 KB Output is correct
208 Correct 689 ms 928 KB Output is correct
209 Correct 692 ms 812 KB Output is correct
210 Correct 526 ms 700 KB Output is correct
211 Correct 752 ms 892 KB Output is correct
212 Correct 526 ms 708 KB Output is correct
213 Correct 516 ms 668 KB Output is correct
214 Correct 521 ms 700 KB Output is correct
215 Correct 525 ms 896 KB Output is correct
216 Correct 618 ms 840 KB Output is correct
217 Correct 550 ms 860 KB Output is correct
218 Correct 528 ms 948 KB Output is correct
219 Correct 555 ms 804 KB Output is correct
220 Correct 522 ms 864 KB Output is correct
221 Correct 547 ms 832 KB Output is correct
222 Correct 525 ms 776 KB Output is correct
223 Correct 529 ms 700 KB Output is correct
224 Correct 560 ms 812 KB Output is correct
225 Correct 790 ms 896 KB Output is correct
226 Correct 530 ms 696 KB Output is correct