Submission #729135

# Submission time Handle Problem Language Result Execution time Memory
729135 2023-04-23T14:46:48 Z Nahian9696 Hexagonal Territory (APIO21_hexagon) C++17
15 / 100
11 ms 3528 KB
#include "hexagon.h"

#include <vector>
#include <bits/stdc++.h>

using namespace std;

#define f0(i, n)                for(int i = 0; i <  (n); i++)
#define f1(i, n)                for(int i = 1; i <= (n); i++)
#define pb                      push_back
#define ff first
#define ss second


pair<long double, long double> dir[] = {
    {0, 2},
    {sqrt(3), 1},
    {sqrt(3), -1},
    {-0, -2},
    {-sqrt(3), -1},
    {-sqrt(3), 1}
};

const long long MOD = 1e9 + 7;


int draw_territory(int N, int A, int B,
                   std::vector<int> D, std::vector<int> L) {


    if(N == 3) {
        long long l = L[0]+1;
        l = l*(l+1);
        l %= MOD;
        l *= (MOD+1)/2;
        l %= MOD;
        l *= A;
        l %= MOD;
        return l;
    }


    if(B == 0) {
        vector<pair<long double, long double>> coord;
        coord.pb({0, 0});
        pair<long double, long double> cur = {0, 0};
        long long len = 0;
        f0(i, N) {
            cur.ff = cur.ff + L[i]*dir[D[i]-1].ff;
            cur.ss = cur.ss + L[i]*dir[D[i]-1].ss;
            coord.pb(cur);
            len += L[i];
        }

        long double area = 0;
        f0(i, N) {
            area += coord[i].ff*coord[i+1].ss;
            area -= coord[i].ss*coord[i+1].ff;
        }

        area = abs(area)/2;
        // cout << area << endl;

        area += (6/sqrt(3));

        area += (len*3.0/sqrt(3));

        area /= (6/sqrt(3));
        // cout << area << endl;

        return ((((long long)floor(area + 0.5) % MOD)*(A% MOD)) % MOD);

    }

    

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 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 1 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 0 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 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 -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 2 ms 1104 KB Output is correct
3 Correct 2 ms 440 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 2 ms 724 KB Output is correct
6 Correct 3 ms 1072 KB Output is correct
7 Correct 7 ms 2096 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 10 ms 3352 KB Output is correct
12 Correct 10 ms 3376 KB Output is correct
13 Correct 10 ms 3336 KB Output is correct
14 Correct 11 ms 3528 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
# 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 2 ms 1036 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 2 ms 692 KB Output is correct
8 Correct 2 ms 1048 KB Output is correct
9 Correct 7 ms 2092 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 9 ms 3400 KB Output is correct
14 Correct 10 ms 3372 KB Output is correct
15 Correct 9 ms 3408 KB Output is correct
16 Correct 11 ms 3504 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Incorrect 1 ms 212 KB Output isn't correct
20 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 -
# 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 0 ms 212 KB Output isn't correct
4 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 -