Submission #42883

#TimeUsernameProblemLanguageResultExecution timeMemory
42883dimash241Cultivation (JOI17_cultivation)C++14
0 / 100
2 ms492 KiB
#pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx") //#include<bits/stdc++.h> #include <map> #include <set> #include <list> #include <cmath> #include <ctime> #include <deque> #include <queue> #include <stack> #include <string> #include <bitset> #include <cstdio> #include <limits> #include <vector> #include <climits> #include <cstring> #include <cstdlib> #include <fstream> #include <numeric> #include <sstream> #include <cassert> #include <iomanip> #include <iostream> #include <algorithm> #include <unordered_set> #include <unordered_map> #define _USE_MATH_DEFINES #define ll long long #define ins Not Needed Thing #define ull unsigned long long #define ld long double #define Accepted 0 #define pb push_back #define pii pair<int,int> #define pll pair<ll,ll> #define mp make_pair #define sz(x) (int)(x.size()) #define all(x) x.begin(),x.end() #define F first #define S second #define SORRY FUL Accepted #define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0) #define Toktama Kazakhstan using namespace std; const double eps = 0.000001; const ld pi = acos(-1); const int maxn = 1e7 + 9; const int mod = 1e9 + 7; const ll MOD = 1e18 + 9; const ll INF = 1e18 + 123; const int inf = 2e9 + 11; const int mxn = 1e6 + 9; const int N = 3e5 + 123; const int PRI = 555557; const int pri = 997; const int dx[] = {1, -1, 0, 0}; const int dy[] = {0, 0, -1, 1}; int tests = 1; int dp[45][45]; inline void Solve () { //easy for (int i = 1 ; i <= 44; i ++) { for (int j = 1; j <= 44; j ++) dp[i][j] = inf; } int n, m; cin >> n >> m; int k; cin >> k; queue < pair < int, int > > q; while (k --) { int x, y; cin >> x >> y; dp[x][y] = 0; q.push(mp(x, y)); } int ans = 0; while (q.size()) { auto v = q.front(); q.pop(); for (int i = 0; i < 4; i ++) { int ni = v.F + dx[i], nj = v.S + dy[i]; if (ni <= 0 || nj <= 0 || ni > n || nj > m) continue; if (dp[ni][nj] > dp[v.F][v.S] + 1) { dp[ni][nj] = dp[v.F][v.S] + 1; q.push(mp(ni, nj)); } } } for (int i = 1; i <= n; i ++) for (int j = 1; j <= m; j ++) ans = max(ans, dp[i][j]); cout << ans; } int main () { SpeedForce; // freopen(".in", "r", stdin); // freopen(".out", "w", stdout); //cin >> tests; while(tests --) { Solve (); // Ee Zadrot } return Accepted + 1 - 2 + 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...