답안 #9589

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
9589 2014-09-28T07:30:10 Z shashack On grid (kriii2_O) C++
컴파일 오류
0 ms 0 KB
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <functional>
#include <bitset>
#include <limits.h>

using namespace std;

#define MP make_pair
#define REP(v, repeat) for(int v=0; v<(repeat); ++v)
#define REPD(v, repeat) for(int v=(repeat)-1; v>=0; --v)
#define FOR(v, pos, end) for(int v=(pos); v<=(end); ++v)
#define FORD(v, pos, end) for(int v=(pos); v>=(end); --v)
#define ROUNDING(x, dig) (floor((x) * pow(10, dig) + 0.11f) / pow(10, dig))

typedef pair<int, int> PI;
typedef vector <bool> VB;
typedef vector <int> VI;
typedef vector <VI> VVI;
typedef vector <vector <PI>> ADJ;
typedef vector <string> VS;
typedef long long ll;
typedef unsigned long long ull;

const int INF = 987654321;
int r, c;
VVI table;
int cache[301][301][301];

int maxScore(const int y, const int x, int cnt)
{
	if (x == 1 || y == 1) return table[y][x];

	int & ret = cache[y][x][cnt];
	if (ret != -INF) return ret;

	FOR(i, 1, y - 1)
	{
		FOR(j, 1, x - 1)
		{
			ret = max(ret, maxScore(i, j, cnt+1) + (table[y][x] - table[i][x] - table[y][j] + table[i][j]));
		}
	}
	return ret;
}

int main()
{
#ifdef _CONSOLE
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w+", stdout);
#endif

	scanf("%d%d", &r, &c);
	table = VVI(r + 1, VI(c + 1, 0));
	for (int i = 0; i < 301; i++)
		for (int j = 0; j < 301; j++)
			for (int k = 0; k < 301; k++)
				cache[i][j][k] = -INF;

	FOR(i, 1, r) FOR(j, 1, c) scanf("%d", &table[i][j]);
	FOR(i, 1, r) FOR(j, 1, c) table[i][j] = table[i][j] + table[i - 1][j] + table[i][j - 1] - table[i - 1][j - 1];

	printf("%d\n", maxScore(r, c, 0));

	return 0;
}

Compilation message

O.cpp:29:27: warning: '>>' operator will be treated as two right angle brackets in C++0x [-Wc++0x-compat]
O.cpp:29:27: note: suggest parentheses around '>>' expression
O.cpp:29:30: error: 'ADJ' was not declared in this scope
O.cpp:29:27: error: '>>' should be '> >' within a nested template argument list
O.cpp: In function 'int main()':
O.cpp:63:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
O.cpp:70:53: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]