Submission #951236

# Submission time Handle Problem Language Result Execution time Memory
951236 2024-03-21T13:10:39 Z Nhoksocqt1 Hexagonal Territory (APIO21_hexagon) C++17
0 / 100
1 ms 604 KB
#include<bits/stdc++.h>
using namespace std;

#define inf 0x3f3f3f3f
#define sz(x) int((x).size())
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> ii;

template<class X, class Y>
	inline bool maximize(X &x, const Y &y) {return (x < y ? x = y, 1 : 0);}
template<class X, class Y>
	inline bool minimize(X &x, const Y &y) {return (x > y ? x = y, 1 : 0);}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int Random(int l, int r) {
    return uniform_int_distribution<int>(l, r)(rng);
}

const int MAXN = 200005;
const int MOD = 1e9+7;

struct Move {
    int dir, len;
} p[MAXN];

int numMove, costA, costB;

inline ll C2(int n) {
    return 1LL * n * (n + 1) / 2;
}

ll powermod(ll a, int exponent) {
    ll res(1);
    while(exponent > 0) {
        if(exponent & 1)
            res = res * a % MOD;

        a = a * a % MOD;
        exponent >>= 1;
    }

    return res;
}

int inv6 = powermod(6, MOD - 2);
inline ll T2(int n) {
    return 1LL * n * (n + 1) % MOD * (2 * n + 1) % MOD * inv6 % MOD;
}

int subn3(void) {
    assert(p[1].len == p[2].len && p[2].len == p[3].len);

    ll ans = C2(p[1].len) * costA % MOD;
    ans = (ans - C2(p[1].len) * costB % MOD + MOD) % MOD;
    ans = (ans + T2(p[1].len) * costB) % MOD;
    return ans;
}

int draw_territory(int _N, int _A, int _B, vector<int> _D, vector<int> _L) {
    numMove = _N, costA = _A, costB = _B;
    for (int i = 1; i <= numMove; ++i)
        p[i] = {_D[i - 1], _L[i - 1]};

    if(numMove == 3)
        return subn3();
}

#ifdef Nhoksocqt1

int main(void) {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    #define TASK "hexagon"
    if(fopen(TASK".inp", "r")) {
        freopen(TASK".inp", "r", stdin);
        freopen(TASK".out", "w", stdout);
    }

    vector<int> d, l;
    int n, a, b;
    cin >> n >> a >> b;

    d.resize(n), l.resize(n);
    for (int i = 0; i < n; ++i)
        cin >> d[i] >> l[i];

    int answer = draw_territory(n, a, b, d, l);
    cout << "ANSWER: " << answer << '\n';

    return 0;
}

#endif // Nhoksocqt1

Compilation message

hexagon.cpp: In function 'int draw_territory(int, int, int, std::vector<int>, std::vector<int>)':
hexagon.cpp:68:1: warning: control reaches end of non-void function [-Wreturn-type]
   68 | }
      | ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 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 -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 6
2 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 Runtime error 1 ms 604 KB Execution killed with signal 6
2 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 Runtime error 1 ms 604 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -