Submission #743394

# Submission time Handle Problem Language Result Execution time Memory
743394 2023-05-17T11:12:08 Z saayan007 Hexagonal Territory (APIO21_hexagon) C++17
9 / 100
1 ms 340 KB
/* #include "hexagon.h" */
#include "bits/stdc++.h"
using namespace std;

#define ll long long
#define fr first
#define sc second
#define eb emplace_back
#define nl '\n';

const ll mod = 1000000007;

ll mul(ll a, ll b) {
    return ((a * b) % mod + mod) % mod;
}

ll sum(ll a, ll b) {
    return ((a + b) % mod + mod) % mod;
}

int draw_territory(int N, int A, int B, vector<int> D, vector<int> L) {
    /* int sz = 10; */
    /* int dist[sz + 2][sz + 2]; */
    /* for(int i = 0; i < sz + 2; ++i) for(int j = 0; j < sz + 2; ++j) if(i > 0 && i <= sz && j > 0 && j <= sz) dist[i][j] = -1; else dist[i][j] = 0; */

    /* dist[sz/2][sz/2] = 0; */
    /* queue<pair<int, int>> q; */
    /* q.emplace(sz/2, sz/2); */
    /* while(!q.empty()) { */
    /*     int x = q.front().fr, y = q.front().sc; */
    /*     q.pop(); */
    /*     for(int dx : {-1, 0, 1}) for(int dy : {-1, 0, 1}) if(dx * dy != 1) { */
    /*         int nx = x + dx, ny = y + dy; */
    /*         if(dist[nx][ny] == -1) { */
    /*             dist[nx][ny] = dist[x][y] + 1; */
    /*             q.emplace(nx, ny); */
    /*         } */
    /*     } */
    /* } */

/*     for(int i = 1; i <= sz; ++i) { */
/*         for(int j = 1; j <= sz; ++j) { */
/*             cout << dist[i][j] << ' '; */
/*         } */
/*         cout << nl; */
/*     } */

/*     cout << "INPUT" << nl; */
/*     cout << N << ' ' << A << ' ' << B << nl; */
/*     for(int i = 0; i < N; ++i) { */
/*         cout << D[i] << ' ' << L[i] << nl; */
/*     } */
/*     for(int i = 0; i < N; ++i) { */
/*         --D[i]; */
/*         if(D[i] >= 3) D[i] = 8 - D[i]; */
/*     } */

    /* int res = 0; */

    ll n = L[0];
    ll res = 0;
    if(n & 1) {
        res = mul(A, mul((n + 1) / 2, n + 2));
    }
    else {
        res = mul(A, mul((n + 2) / 2, n + 1));
    }
    int add = 1;
    for(int i = 0; i < 3; ++i) {
        if((n + i) % 3 == 0) add = mul(add, (n + i) / 3);
        else add = mul(add, (n + i));
    }
    add = mul(add, B);
    res = sum(res, add);
    /* cout << (n * (n + 1) * (n + 2)) / 3 << nl; */
    return res;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 276 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -