Submission #1604092


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];
    }
    for(int i = 0; i < q; i++)
    {
        vector<pair<int, int>> can;
        for(int j = 1; j <= n * n; j++)
        {
            for(int k = 1; k <= n * 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 0
Code Size 2008 Byte
Status WA
Exec Time 5255 ms
Memory 384 KB

Judge Result

Set Name Subtask1 Subtask2
Score / Max Score 0 / 50 0 / 50
Status
AC × 4
WA × 14
AC × 3
WA × 12
TLE × 5
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 WA 545 ms 256 KB
rand1.txt WA 1073 ms 256 KB
rand2.txt WA 3673 ms 384 KB
rand3.txt WA 115 ms 256 KB
rand4.txt WA 2 ms 256 KB
rand_max0.txt TLE 5255 ms 384 KB
rand_max1.txt TLE 5255 ms 256 KB
rand_max2.txt TLE 5255 ms 384 KB
rand_max3.txt TLE 5255 ms 256 KB
rand_max4.txt TLE 5255 ms 256 KB
s1.txt AC 1 ms 256 KB
s2.txt AC 1 ms 256 KB
sub0.txt WA 1 ms 256 KB
sub1.txt WA 1 ms 256 KB
sub2.txt WA 1 ms 256 KB
sub_rand_max0.txt WA 1 ms 256 KB
sub_rand_max1.txt WA 1 ms 256 KB
sub_rand_max2.txt WA 1 ms 256 KB
sub_rand_max3.txt WA 1 ms 256 KB
sub_rand_min0.txt AC 1 ms 256 KB