ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 2114. My craft

WA1
Posted by Dyryaev Daniil 15 Nov 2019 01:26
I wrote the solution and had the correct answers on test cases, but i have wa1. Can someone help me or give advice?

This is my solution:

#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <cstring>
#include <cstdlib>

using namespace std;
#define task


void print(int array[], int n) {
     for (int i = 0; i < n; i++) {
          cout << array[i] << ' ';
     }
}

void optimization() {
     cin.tie(nullptr);
     ios_base::sync_with_stdio(false);
}

int factorial(int x) {
     int a = 1;
     for (int i = 2; i < x + 1; i++) {
          a *= i;
     }
     return a;
}


#ifdef task

int main() {
     optimization();

     int n, m;
     cin >> n >> m;
     int **field = new int *[n];
     for (int i = 0; i < n; i++) {
          field[i] = new int[m];
     }

     for (int i = 0; i < n; i++) {
          for (int j = 0; j < m; j++) {
               cin >> field[i][j];
          }
     }
     int q;
     int k;
     int x = 0; int y = 0;
     int max_drop = -1;
     int part_sum = 0;
     int move_to_right = -1;
     cin >> q;
     for (int quest = 0; quest < q; quest++) {
          cin >> k;
          for (int i = 0; i < n; i++) {
               for (int j = 0; j < m; j++) {
                    move_to_right = k + 1;
                    part_sum = 0;
                    for (int down = i; down < i + k + 1; down++) {
                         for (int right = j; right < j + move_to_right; right++) {
                              if (down < n && right < m) {
                                   part_sum += field[down][right];
                              }
                         }
                         move_to_right--;
                    }

                    if (part_sum > max_drop) {
                         max_drop = part_sum;
                         x = i + 1;
                         y = j + 1;
                    }
               }
          }

          cout << max_drop << ' ' << x << ' ' << y << endl;
          max_drop = -1;

     }

     return 0;
}

#endif
Re: WA1
Posted by Dyryaev Daniil 15 Nov 2019 01:31
upd:
Before I used scanf and got wa1. Now with cin // cout i have tle17.