Submission #995024

# Submission time Handle Problem Language Result Execution time Memory
995024 2024-06-08T10:46:53 Z thelegendary08 Hexagonal Territory (APIO21_hexagon) C++14
9 / 100
1 ms 348 KB
#include "hexagon.h"
#include<bits/stdc++.h>
#define ll long long int
#define f0r(i,n) for(int i = 0;i<n;i++)
using namespace std;
const ll mod = 1e9 + 7;
ll binexp(ll a, ll b){
	ll r = 1;
	f0r(i, 32){
		if(b & (1<<i)){
			r *= a;
			r %= mod;
		}
		a *= a;
		a %= mod;
	}
	return r;
}
int draw_territory(int N, int A, int B, std::vector<int> D, std::vector<int> L) {
    ll n = L[0] + 1;
    ll sz = n * (n + 1)/2;
    sz %= mod;
    n--;
    ll sdist = 0;
    sdist += n * (n+1) % mod;
    sdist *= (2*n+1) % mod;
    sdist %= mod;
    sdist *= binexp(6, mod-2);
    sdist %= mod;
    
    ll b = n * (n+1) % mod;
    b *= binexp(2, mod - 2);
    b %= mod;
    sdist += b;
    sdist %= mod;
	ll ans = (sz * A % mod) + (sdist * B % mod);
	return ans % mod;
}
# 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 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 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 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 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 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
# 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 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 1 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 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 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -