Submission #383720

#TimeUsernameProblemLanguageResultExecution timeMemory
383720Valera_GrinenkoTracks in the Snow (BOI13_tracks)C++17
100 / 100
785 ms131132 KiB
#pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #pragma GCC optimization ("unroll-loops") #include <iostream> #include <fstream> #include <algorithm> #include <vector> #include <set> #include <stack> #include <map> #include <unordered_map> #include <iomanip> #include <cmath> #include <queue> #include <bitset> #include <numeric> #include <array> #include <cstring> #include <random> #include <chrono> #define fi first #define se second #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin()) typedef long long ll; typedef long double ld; using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; // template<class T> // using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; const int N = 4000; char s[N][N]; int d[N][N]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int h, w; cin >> h >> w; for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) cin >> s[i][j]; deque<pair<int, int> > q; q.push_front(mp(0, 0)); d[0][0] = 1; int dx[4] = {-1, 1, 0, 0}, dy[4] = {0, 0, -1, 1}; int ans = 1; while(!q.empty()) { auto cv = q.front(); q.pop_front(); int x = cv.fi, y = cv.se; ans = max(ans, d[x][y]); for(int mv = 0; mv < 4; mv++) { int cx = x + dx[mv], cy = y + dy[mv]; if(cx >= 0 && cx < h && cy >= 0 && cy < w && d[cx][cy] == 0 && s[cx][cy] != '.') { d[cx][cy] = d[x][y] + (s[cx][cy] != s[x][y]); if(d[cx][cy] > d[x][y]) q.push_back(mp(cx, cy)); else q.push_front(mp(cx, cy)); } } } cout << ans; return 0; } /* */

Compilation message (stderr)

tracks.cpp:3: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    3 | #pragma GCC optimization ("unroll-loops")
      |
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...