답안 #617936

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
617936 2022-08-01T17:12:28 Z AmirElarbi 육각형 영역 (APIO21_hexagon) C++14
0 / 100
57 ms 57548 KB
#include <bits/stdc++.h>
#define vi vector<int>
#define ve vector
#define ll long long
#define vf vector<float>
#define vll vector<pair<ll,ll>>
#define ii pair<int,int>
#define pll pair<ll,ll>
#define vvi vector<vi>
#define vii vector<ii>
#define gii greater<ii>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF 2e9+5
#define eps 1e-7
#define eps1 1e-25
#define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MAX_A 1e5+5
#define V 450
using namespace std;
const int MOD = 1e9+7;
const int nax = 2e5+5;
const int lg = 20;
//#include "hexagon.h"
int add(int a, int b){
    a += b;
    while(a > MOD) a -= MOD;
    while(a < 0) a += MOD;
    return a;
}
int sub(int a, int b){
    return add(a, MOD-b);
}
int mul(int a, int b){
    return (a*1ll*b)%MOD;
}
int binpow(int x, int y){
    int z = 1;
    while(y > 0){
        if(y%2 == 1) z = mul(x, z);
        x = mul(x,x);
        y /= 2;
    } 
    return z;
}
int inv(int a){
    return binpow(a, MOD-2);
}
int divide(int a, int b){
    return mul(a,inv(b));
}
int y[6] = {2,1,-1,-2,-1,1};
int x[6] = {0,1,1,0,-1,-1};
set<int> cur[nax*2];
int draw_territory(int n, int a, int b, vi d, vi l){
    int curx = nax, cury = 0, mx = nax, mn = nax;
    cur[curx].insert(cury);
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < l[i]; ++j)
        {
            curx += x[d[i]-1], cury += y[d[i]-1];
            cur[curx].insert(cury);
            mx = max(mx, curx);
            mn = min(mn, curx);
        }
    }
    int res = 0;
    for (int i = mn; i <= mx; ++i)
    {
        int lst = -1;
        for(auto x : cur[i]){
            if(lst == -1){
                lst = x;
            } else {
                res = add(res, divide(sub(x,lst),2)+1);
                lst = -1;
            }
        }
        if(lst != -1) res = add(res, 1);
    }
    return mul(a,res);
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 46 ms 57548 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 43 ms 57504 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 19028 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 57 ms 28016 KB Output is correct
2 Incorrect 33 ms 24736 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 50 ms 57540 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 19028 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 44 ms 57532 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 19012 KB Output isn't correct
2 Halted 0 ms 0 KB -