제출 #1307969

#제출 시각아이디문제언어결과실행 시간메모리
1307969kyrylTracks in the Snow (BOI13_tracks)C++20
84.69 / 100
729 ms1114112 KiB
#include <bits/stdc++.h> #define un unsgined #define rep(i, a, b) for(int i = a; i < b; i++) #define per(i, a, b) for(int i = a; i >= b; i--) #define all(v) begin(v), end(v) #define st first #define nd second using ll = long long; using bigi = __int128; using namespace std; const int N = 4005; vector<pair<int, int>> ruch{ {0, 1}, {0, -1}, {1, 0}, {-1, 0} }; int tab[N][N]; int gle[N][N]; queue<array<int, 3>> odpal; void zaz(int ii, int jj){ for(auto [x, y] : ruch){ if(!tab[ii + x][jj + y] || gle[ii + x][jj + y]) continue; if(tab[ii + x][jj + y] == tab[ii][jj]){ gle[ii + x][jj + y] = gle[ii][jj]; zaz(ii + x, jj + y); } else if(!gle[ii + x][jj + y]){ odpal.push({ii + x, jj + y, gle[ii][jj] + 1}); } } } void dalej(){ odpal.push({1, 1, 1}); while(!odpal.empty()){ auto [ii, jj, g] = odpal.front(); odpal.pop(); if(gle[ii][jj]) continue; gle[ii][jj] = g; zaz(ii, jj); } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; rep(i, 1, n + 1){ rep(j, 1, m + 1){ char c; cin >> c; if(c == '.') tab[i][j] = 0; else if(c == 'F') tab[i][j] = 1; else tab[i][j] = 2; } } dalej(); int maks = 0; rep(i, 1, n + 1){ rep(j, 1, m + 1){ maks = max(maks, gle[i][j]); } } cout << maks << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...