Submission #42887

# Submission time Handle Problem Language Result Execution time Memory
42887 2018-03-06T06:28:19 Z dimash241 Cultivation (JOI17_cultivation) C++14
0 / 100
2 ms 608 KB
#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], ans = inf;
int u[45], n, m;

void rec (int x) {
	if (x > 10001) return ;
	if ( x > ans) return ;
	bool ch = 1;
	int now[45][45] = {inf};
	for (int i = 1; i <= n; i ++)
		for (int j = 1; j <= m; j ++) {
			if(dp[i][j] == inf) ch = 0;
			now[i][j] = dp[i][j];
		}

   	if(ch) {
   		ans = min(ans, x);
   		return ;
   	}

   	for (int l = 0; l < 4; l ++) {
     	for (int i = 1; i <= n; i ++) {
     		for (int j = 1; j <= m; j ++) {
     			dp[i][j] = min(dp[i][j], now[i + dx[l]][j + dy[l]] + 1);
     		}
     	}
     	rec (x + 1);
     	for (int i = 1; i <= n; i ++)
     		for (int j = 1; j <= m; j ++)
     			dp[i][j] = now[i][j];
   	}
}

inline void Solve () {
	//easy
	for (int i = 0 ; i <= 44; i ++) {
		for (int j = 0; 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;
	}
//	int ans = 0;
	rec(0);

	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 time Memory Grader output
1 Incorrect 1 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 608 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 608 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -