Submission #147459
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]; } if(n==1&&d[1][1]<50)throw 0; 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'; } }
Submission Info
Submission Time | |
---|---|
Task | D - おいしいたこ焼きの焼き方 |
User | climpet |
Language | C++ (G++ 4.6.4) |
Score | 0 |
Code Size | 2050 Byte |
Status | RE |
Exec Time | 403 ms |
Memory | 932 KB |
Judge Result
Set Name | Subtask1 | Subtask2 | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 50 | 0 / 50 | ||||||||
Status |
|
|
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 | 25 ms | 792 KB |
rand1.txt | AC | 26 ms | 920 KB |
rand2.txt | AC | 31 ms | 932 KB |
rand3.txt | AC | 23 ms | 804 KB |
rand4.txt | AC | 22 ms | 932 KB |
rand_max0.txt | AC | 38 ms | 924 KB |
rand_max1.txt | AC | 38 ms | 792 KB |
rand_max2.txt | AC | 38 ms | 932 KB |
rand_max3.txt | AC | 38 ms | 928 KB |
rand_max4.txt | AC | 37 ms | 796 KB |
s1.txt | AC | 21 ms | 804 KB |
s2.txt | AC | 21 ms | 924 KB |
sub0.txt | AC | 21 ms | 800 KB |
sub1.txt | AC | 21 ms | 804 KB |
sub2.txt | AC | 21 ms | 932 KB |
sub_rand_max0.txt | AC | 21 ms | 932 KB |
sub_rand_max1.txt | AC | 21 ms | 804 KB |
sub_rand_max2.txt | AC | 21 ms | 928 KB |
sub_rand_max3.txt | AC | 21 ms | 924 KB |
sub_rand_min0.txt | RE | 403 ms | 932 KB |