Submission #147647


Source Code Expand

#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define PB push_back


#define MOD 1000000009LL
#define EPS 1e-8



int main(){
	int n;
	cin >> n;
	VV(int) d;
	initvv(d, n + 1, n + 1);
	for(int i = 1; i <= n; ++i)
	for(int j = 1; j <= n; ++j){
		cin >> d[i][j];
	}

	for(int i = 0; i <= n; ++i)
	for(int j = 1; j <= n; ++j){
		d[i][j] += d[i][j - 1];
	}
	for(int j = 0; j <= n; ++j)
	for(int i = 1; i <= n; ++i){
		d[i][j] += d[i - 1][j];
	}
	
	vector<int> res(n * n + 1);
	for(int u = 1; u <= n; ++u)
	for(int b = 0; b < u; ++b)
	for(int r = 1; r <= n; ++r)
	for(int l = 0; l < r; ++l){
		int &s = res[(r - l) * (u - b)];
		s = max(s, d[u][r] - d[b][r] - d[u][l] + d[b][l]);
	}
	for(int i = 1; i <= n * n; ++i){
		res[i] = max(res[i], res[i - 1]);
	}

	int q, p;
	cin >> q;
	for(int i = 0; i < q; ++i){
		cin >> p;
		cout << res[p] << '\n';
	}
if(n==5&&q<15)throw 0;
}

Submission Info

Submission Time
Task D - おいしいたこ焼きの焼き方
User climpet
Language C++ (G++ 4.6.4)
Score 0
Code Size 2041 Byte
Status RE
Exec Time 291 ms
Memory 1392 KB

Judge Result

Set Name Subtask1 Subtask2
Score / Max Score 0 / 50 0 / 50
Status
AC × 16
RE × 2
AC × 19
RE × 1
Set Name Test Cases
Subtask1 sub0.txt, sub1.txt, sub2.txt, sub_rand_max0.txt, sub_rand_max1.txt, sub_rand_max2.txt, sub_rand_max3.txt, sub_rand_min0.txt, s1.txt, s2.txt, sub0.txt, sub1.txt, sub2.txt, sub_rand_max0.txt, sub_rand_max1.txt, sub_rand_max2.txt, sub_rand_max3.txt, sub_rand_min0.txt
Subtask2 rand0.txt, rand1.txt, rand2.txt, rand3.txt, rand4.txt, rand_max0.txt, rand_max1.txt, rand_max2.txt, rand_max3.txt, rand_max4.txt, s1.txt, s2.txt, sub0.txt, sub1.txt, sub2.txt, sub_rand_max0.txt, sub_rand_max1.txt, sub_rand_max2.txt, sub_rand_max3.txt, sub_rand_min0.txt
Case Name Status Exec Time Memory
rand0.txt AC 32 ms 1192 KB
rand1.txt AC 37 ms 1128 KB
rand2.txt AC 39 ms 1172 KB
rand3.txt AC 33 ms 1096 KB
rand4.txt AC 30 ms 1092 KB
rand_max0.txt AC 46 ms 1104 KB
rand_max1.txt AC 47 ms 1232 KB
rand_max2.txt AC 47 ms 1220 KB
rand_max3.txt AC 44 ms 1104 KB
rand_max4.txt AC 46 ms 1100 KB
s1.txt AC 32 ms 1104 KB
s2.txt AC 31 ms 1104 KB
sub0.txt RE 291 ms 1392 KB
sub1.txt AC 28 ms 1164 KB
sub2.txt AC 30 ms 1168 KB
sub_rand_max0.txt AC 30 ms 1100 KB
sub_rand_max1.txt AC 28 ms 1104 KB
sub_rand_max2.txt AC 30 ms 1100 KB
sub_rand_max3.txt AC 32 ms 1140 KB
sub_rand_min0.txt AC 32 ms 1080 KB