Submission #855406

# Submission time Handle Problem Language Result Execution time Memory
855406 2023-10-01T08:24:28 Z dayalk Tracks in the Snow (BOI13_tracks) C++17
6.04167 / 100
869 ms 131400 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) {
			if (a[i / w][i % w]) res = max(res, d[i]);
		}
		cout << res << endl;
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 1628 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 1424 KB Output isn't correct
5 Incorrect 4 ms 860 KB Output isn't correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Incorrect 0 ms 348 KB Output isn't correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Incorrect 1 ms 348 KB Output isn't correct
10 Incorrect 3 ms 856 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 856 KB Output isn't correct
14 Incorrect 3 ms 860 KB Output isn't correct
15 Incorrect 11 ms 1884 KB Output isn't correct
16 Incorrect 11 ms 1712 KB Output isn't correct
17 Incorrect 10 ms 1628 KB Output isn't correct
18 Incorrect 6 ms 1372 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 600 KB Output isn't correct
2 Incorrect 56 ms 11096 KB Output isn't correct
3 Incorrect 570 ms 131400 KB Output isn't correct
4 Incorrect 139 ms 19280 KB Output isn't correct
5 Incorrect 324 ms 81644 KB Output isn't correct
6 Correct 669 ms 90700 KB Output is correct
7 Incorrect 2 ms 604 KB Output isn't correct
8 Incorrect 2 ms 756 KB Output isn't correct
9 Incorrect 2 ms 860 KB Output isn't correct
10 Incorrect 1 ms 604 KB Output isn't correct
11 Incorrect 2 ms 604 KB Output isn't correct
12 Incorrect 1 ms 604 KB Output isn't correct
13 Incorrect 59 ms 11088 KB Output isn't correct
14 Incorrect 33 ms 6492 KB Output isn't correct
15 Incorrect 39 ms 7512 KB Output isn't correct
16 Incorrect 25 ms 4700 KB Output isn't correct
17 Incorrect 152 ms 28856 KB Output isn't correct
18 Incorrect 167 ms 29148 KB Output isn't correct
19 Incorrect 141 ms 19284 KB Output isn't correct
20 Incorrect 120 ms 27732 KB Output isn't correct
21 Incorrect 333 ms 64292 KB Output isn't correct
22 Incorrect 317 ms 81496 KB Output isn't correct
23 Incorrect 291 ms 53620 KB Output isn't correct
24 Incorrect 310 ms 69892 KB Output isn't correct
25 Incorrect 869 ms 116632 KB Output isn't correct
26 Incorrect 416 ms 110620 KB Output isn't correct
27 Incorrect 576 ms 121936 KB Output isn't correct
28 Correct 668 ms 90696 KB Output is correct
29 Incorrect 655 ms 90048 KB Output isn't correct
30 Incorrect 628 ms 97000 KB Output isn't correct
31 Incorrect 450 ms 50920 KB Output isn't correct
32 Incorrect 583 ms 101640 KB Output isn't correct