Submission #1097105

# Submission time Handle Problem Language Result Execution time Memory
1097105 2024-10-06T04:25:48 Z gyg Hexagonal Territory (APIO21_hexagon) C++17
3 / 100
7 ms 3056 KB
#include "hexagon.h"
#include <bits/stdc++.h>
using namespace std;
#define lint long long
#define arr array 
#define vct vector 
#define pll pair<lint, lint>
#define fir first 
#define sec second
const lint MD = 1e9 + 7, INV = 500000004;

lint md(lint x) { return x % MD; } // No + MD

lint gt_bnd(int n, vct<int> lng) {
    lint ans = 0;
    for (int i = 0; i < n; i++) ans = md(ans + lng[i]);
    return ans;
}

pll mv(pll pt, lint drc, lint lng) {
    pll dlt;
    if (drc == 1) dlt = {0, 1};
    if (drc == 2) dlt = {1, 1};
    if (drc == 3) dlt = {1, 0};
    if (drc == 4) dlt = {0, -1};
    if (drc == 5) dlt = {-1, -1};
    if (drc == 6) dlt = {-1, 0};
    return {pt.fir + dlt.fir * lng, pt.sec + dlt.sec * lng};
}
vct<pll> gt_pts(int n, vct<int> drc, vct<int> lng) {
    pll pt = {0, 0};
    vct<pll> ans;
    for (int i = 0; i < n; i++) {
        pt = mv(pt, drc[i], lng[i]);
        ans.push_back(pt);
    }
    return ans;
}
lint gt_tw_ar(vct<pll> pt) { // 2 * area to avoid floats
    lint ans = 0;
    for (int i = 0; i < pt.size(); i++) {
        int j = (i + 1) % pt.size();
        lint inc_ans = md(md(pt[i].fir - pt[j].fir) * md(pt[i].sec + pt[j].sec));
        ans = md(ans + inc_ans);
    }
    ans = abs(ans);
    return ans;
}

int draw_territory(int n, int a, int b, vct<int> drc, vct<int> lng) {
    // assert(b == 0);
    lint bnd = gt_bnd(n, lng);
    lint tw_ar = gt_tw_ar(gt_pts(n, drc, lng));
    lint tw_ins = md(tw_ar - bnd + 2);
    
    lint ans = md(md(tw_ins * INV) + bnd);
    ans = md(a * ans);
    return ans;
}

Compilation message

hexagon.cpp: In function 'long long int gt_tw_ar(std::vector<std::pair<long long int, long long int> >)':
hexagon.cpp:41:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     for (int i = 0; i < pt.size(); i++) {
      |                     ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 352 KB Output is correct
2 Correct 1 ms 440 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 0 ms 432 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 2 ms 860 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 444 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 2 ms 860 KB Output is correct
7 Correct 4 ms 1764 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 7 ms 2840 KB Output is correct
12 Correct 7 ms 3048 KB Output is correct
13 Incorrect 6 ms 2848 KB Output isn't correct
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 860 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 704 KB Output is correct
8 Correct 2 ms 860 KB Output is correct
9 Correct 4 ms 1944 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 7 ms 2840 KB Output is correct
14 Correct 7 ms 3056 KB Output is correct
15 Incorrect 6 ms 2848 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -