Submission #1604195


Source Code Expand

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int CalcTotal(vector<vector<int>> &source, int x, int y, int rangex, int rangey)
{
    int total = 0;
    for(int i = 0; i < rangex; i++)
    {
        for(int j = 0; j< rangey; j++)
        {
            total += source[x + i][y + j];
        }
    }
    return total;
}
void d()
{
    int n;
    cin >> n;
    vector<vector<int>> d(n);
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < n; j++)
        {
            int temp;
            cin >> temp;
            d[i].push_back(temp);
        }
    }
    int q;
    cin >> q;
    vector<int> p(q);
    for(int i = 0; i < q; i++)
    {
        cin >> p[i];
    }
    int result[251] = {0};
    for(int i = 1; i <= n * n; i++)
    {
        vector<pair<int, int>> can;
        for(int j = 1; j <= n; j++)
        {
            for(int k = 1; k <= n; k++)
            {
                if(i == j * k)
                {
                    can.push_back(make_pair(j, k));
                }
            }
        }
        int maxv = 0;
        for(auto e : can)
        {
            for(int x = 0; x <= n - e.first; x++)
            {
                for(int y = 0; y <= n - e.second; y++)
                {
                    int tempv = CalcTotal(d, x, y, e.first, e.second);
                    maxv = maxv < tempv ? tempv : maxv;
                }
            }
        }
        if(result[i - 1] > maxv)
        {
            result[i] = result[i -1];
        }else{
            result[i] = maxv;
        }
    }
    /*for(int i = 0; i <=9; i++)
    {
        cout << result[i] << endl;
    }*/
    for(auto e : p)
    {
        cout << result[e] << endl;
    }
    /*for(int i = 0; i < q; i++)
    {
        vector<pair<int, int>> can;
        for(int j = 1; j <= n; j++)
        {
            for(int k = 1; k <= n; k++)
            {
                if(p[i] == j * k)
                {
                    can.push_back(make_pair(j, k));
                }
            }
        }
        int maxv = 0;
        for(auto e : can)
        {
            for(int x = 0; x <= n - e.first; x++)
            {
                for(int y = 0; y <= n - e.second; y++)
                {
                    int tempv = CalcTotal(d, x, y, e.first, e.second);
                    maxv = maxv < tempv ? tempv : maxv;
                }
            }
        }
        if(p[i] > n)
        {
           int range = p[i] / n;
            for(int x = 0; x <= n -range; x++)
            {
                int tempv = CalcTotal(d, x, 0, range, n);
                maxv = maxv < tempv ? tempv : maxv;
            }
            for(int y = 0; y <= n -range; y++)
            {
                int tempv = CalcTotal(d, 0, y, n, range);
                maxv = maxv < tempv ? tempv : maxv;
            }
        }
        cout << maxv << endl;
    }*/
}

int main() {
    d();
    return 0;
}

Submission Info

Submission Time
Task D - おいしいたこ焼きの焼き方
User umisan
Language C++14 (GCC 5.4.1)
Score 50
Code Size 3048 Byte
Status RE
Exec Time 463 ms
Memory 256 KB

Judge Result

Set Name Subtask1 Subtask2
Score / Max Score 50 / 50 0 / 50
Status
AC × 18
AC × 11
RE × 9
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 RE 250 ms 256 KB
rand1.txt RE 164 ms 256 KB
rand2.txt RE 225 ms 256 KB
rand3.txt RE 110 ms 256 KB
rand4.txt AC 1 ms 256 KB
rand_max0.txt RE 463 ms 256 KB
rand_max1.txt RE 451 ms 256 KB
rand_max2.txt RE 389 ms 256 KB
rand_max3.txt RE 340 ms 256 KB
rand_max4.txt RE 439 ms 256 KB
s1.txt AC 1 ms 256 KB
s2.txt AC 1 ms 256 KB
sub0.txt AC 1 ms 256 KB
sub1.txt AC 1 ms 256 KB
sub2.txt AC 1 ms 256 KB
sub_rand_max0.txt AC 1 ms 256 KB
sub_rand_max1.txt AC 1 ms 256 KB
sub_rand_max2.txt AC 1 ms 256 KB
sub_rand_max3.txt AC 1 ms 256 KB
sub_rand_min0.txt AC 1 ms 256 KB