Submission #116265

#TimeUsernameProblemLanguageResultExecution timeMemory
116265emilemTreasure (different grader from official contest) (CEOI13_treasure2)C++14
0 / 100
3 ms384 KiB
#include "treasure.h" #include <vector> inline int CountTreasures(size_t minI, size_t maxI, size_t minJ, size_t maxJ) { return countTreasure(minI + 1, minJ + 1, maxI + 1, maxJ + 1); } void findTreasure(int n) { std::vector< std::vector<int> > sumToClosestCorner(n, std::vector<int>(n)); for (size_t i = 0; i < n; ++i) for (size_t j = 0; j < n; ++j) { int minI, maxI, minJ, maxJ; if (i >= n - i + 1) { minI = 0; maxI = i; } else { minI = i; maxI = n - 1; } if (j >= n - j + 1) { minJ = 0; maxJ = j; } else { minJ = j; maxJ = n - 1; } sumToClosestCorner[i][j] = CountTreasures(minI, maxI, minJ, maxJ); } for (size_t i = 0; i < n; ++i) for (size_t j = 0; j < n; ++j) { int iDir, jDir; iDir = (i >= n - i + 1) ? -1 : 1; jDir = (j >= n - j + 1) ? -1 : 1; int cur = sumToClosestCorner[i][j]; if (i + iDir >= 0 && i + iDir < n) cur -= sumToClosestCorner[i + iDir][j]; if (j + jDir >= 0 && j + jDir < n) cur -= sumToClosestCorner[i][j + jDir]; if (i + iDir >= 0 && i + iDir < n && j + jDir >= 0 && j + jDir < n) cur += sumToClosestCorner[i + iDir][j + jDir]; if (cur) Report(i + 1, j + 1); } }

Compilation message (stderr)

treasure.cpp: In function 'void findTreasure(int)':
treasure.cpp:11:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (size_t i = 0; i < n; ++i)
                     ~~^~~
treasure.cpp:12:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (size_t j = 0; j < n; ++j)
                      ~~^~~
treasure.cpp:21:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (size_t i = 0; i < n; ++i)
                     ~~^~~
treasure.cpp:22:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (size_t j = 0; j < n; ++j)
                      ~~^~~
treasure.cpp:28:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if (i + iDir >= 0 && i + iDir < n)
                         ~~~~~~~~~^~~
treasure.cpp:30:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if (j + jDir >= 0 && j + jDir < n)
                         ~~~~~~~~~^~~
treasure.cpp:32:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if (i + iDir >= 0 && i + iDir < n && j + jDir >= 0 && j + jDir < n)
                         ~~~~~~~~~^~~
treasure.cpp:32:67: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if (i + iDir >= 0 && i + iDir < n && j + jDir >= 0 && j + jDir < n)
                                                          ~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...