Submission #855401

# Submission time Handle Problem Language Result Execution time Memory
855401 2023-10-01T08:19:48 Z dayalk Tracks in the Snow (BOI13_tracks) C++14
6.04167 / 100
791 ms 146068 KB
#include <bits/stdc++.h>
#define mod 1000000007
#define init(arr, val) memset(arr, val, sizeof(arr))
#define fr(a,b) for(ll i = a; i < b; i++)
#define loop(i, a, b) for (ll i = a; i < b; i++)
#define loopr(i, a, b) for (ll i = a; i >= b; i--)
#define loops(i, a, b, step) for (ll i = a; i < b; i += step)
#define looprs(i, a, b, step) for (ll i = a; i >= b; i -= step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define pll pair<long long, long long>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define fast_io                       \
	ios_base::sync_with_stdio(false); \
	cin.tie();                        \
	cout.tie()
#define FILE_READ_IN freopen("input.txt", "r", stdin);
#define FILE_READ_OUT freopen("output.txt", "w", stdout);
#define prDouble(x) cout << fixed << setprecision(10) << x
#define all(a) a.begin(), a.end()
#define ld long double
#define inf (1LL<<60)
using namespace std;
const ll maxn = 2e5 + 1;
const double pi = acos(-1);

vector<pii> dir = { {1,0}, {0,1}, {0, -1}, {-1, 0} };

int main() {
	fast_io;
	int tests = 1;
	// cin >> tests;
	for (int test_case = 1; test_case <= tests; test_case++) {
		int h, w; cin >> h >> w;
		char a[h][w];
		fr(0, h) {
			loop(j, 0, w) cin >> a[i][j];
		}
		vector<int> d(h * w, 1e9);
		d[(h - 1) * w] = 0;
		deque<pair<int, int>> q;
		q.push_back(make_pair(h - 1, 0));
		int res = 0;
		while (!q.empty()) {
			auto cur = q.front();
			int curf = cur.first;
			int curs = cur.second;
			q.pop_front();
			auto dis = d[curf * w + curs];
			for (auto i : dir) {
				// pii j = cur + i;
				int jf = curf + i.first;
				int js = curs + i.second;
				if (jf < 0) continue;
				if (jf >= h) continue;
				if (js < 0) continue;
				if (js >= w) continue;
				int e = 0;
				// if (a[curf][curs] != '.') {
				e = (a[curf][curs] != a[jf][js]);
				// }
				if (dis + e < d[jf * w + js]) {
					d[jf * w + js] = dis + e;
					if (e == 0) q.push_front({ jf,js });
					else q.push_back({ jf,js });
				}
			}
		}
		fr(0, h * w)
			res = max(res, d[i]);
		cout << res << endl;
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 1884 KB Output isn't correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Incorrect 6 ms 1372 KB Output isn't correct
5 Incorrect 3 ms 852 KB Output isn't correct
6 Incorrect 0 ms 452 KB Output isn't correct
7 Incorrect 0 ms 348 KB Output isn't correct
8 Incorrect 1 ms 456 KB Output isn't correct
9 Incorrect 1 ms 460 KB Output isn't correct
10 Incorrect 2 ms 860 KB Output isn't correct
11 Correct 2 ms 604 KB Output is correct
12 Incorrect 4 ms 860 KB Output isn't correct
13 Incorrect 3 ms 860 KB Output isn't correct
14 Incorrect 3 ms 980 KB Output isn't correct
15 Incorrect 10 ms 2140 KB Output isn't correct
16 Incorrect 10 ms 1884 KB Output isn't correct
17 Incorrect 10 ms 2040 KB Output isn't correct
18 Incorrect 5 ms 1372 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 604 KB Output isn't correct
2 Incorrect 50 ms 12544 KB Output isn't correct
3 Incorrect 492 ms 146068 KB Output isn't correct
4 Incorrect 127 ms 22772 KB Output isn't correct
5 Incorrect 281 ms 89604 KB Output isn't correct
6 Correct 590 ms 105408 KB Output is correct
7 Incorrect 2 ms 604 KB Output isn't correct
8 Incorrect 2 ms 812 KB Output isn't correct
9 Incorrect 2 ms 860 KB Output isn't correct
10 Incorrect 1 ms 724 KB Output isn't correct
11 Incorrect 2 ms 860 KB Output isn't correct
12 Incorrect 1 ms 604 KB Output isn't correct
13 Incorrect 50 ms 12580 KB Output isn't correct
14 Incorrect 29 ms 7256 KB Output isn't correct
15 Incorrect 36 ms 9052 KB Output isn't correct
16 Incorrect 22 ms 5208 KB Output isn't correct
17 Incorrect 132 ms 32804 KB Output isn't correct
18 Incorrect 152 ms 32984 KB Output isn't correct
19 Incorrect 123 ms 22764 KB Output isn't correct
20 Incorrect 105 ms 31056 KB Output isn't correct
21 Incorrect 284 ms 72824 KB Output isn't correct
22 Incorrect 280 ms 89688 KB Output isn't correct
23 Incorrect 250 ms 60660 KB Output isn't correct
24 Incorrect 270 ms 78084 KB Output isn't correct
25 Incorrect 791 ms 131144 KB Output isn't correct
26 Incorrect 369 ms 121440 KB Output isn't correct
27 Incorrect 503 ms 136184 KB Output isn't correct
28 Correct 585 ms 105004 KB Output is correct
29 Incorrect 580 ms 104384 KB Output isn't correct
30 Incorrect 559 ms 110740 KB Output isn't correct
31 Incorrect 407 ms 60328 KB Output isn't correct
32 Incorrect 501 ms 115776 KB Output isn't correct