Submission #980483

#TimeUsernameProblemLanguageResultExecution timeMemory
980483vjudge1Hexagonal Territory (APIO21_hexagon)C++17
Compilation error
0 ms0 KiB
#include "jumps.h" #include<bits/stdc++.h> using namespace std; #define ll long long #define ff first #define ss second const int mod = 1e9 + 7; const int inf = 1e9; const int logn = 20; template<typename T> int len(T &a){return a.size();} vector<vector<int>> up; int n; bool sub1 = 1; struct Segtree{ vector<int> t; int n; void init(int _n){ n = _n; t.resize(2 * n); } int merge(const int &a, const int &b){ return max(a, b); } void build(vector<int> &a){ init(len(a)); for(int i = 0; i < n; i ++) t[i + n] = a[i]; for(int i = n - 1; i > 0; i --) t[i] = merge(t[i << 1], t[i << 1 | 1]); } int get(int l, int r){ l += n; r += n; int res = -1; while(l <= r){ if(l % 2) res = merge(res, t[l ++]); if(r % 2 == 0) res = merge(res, t[r --]); l /= 2; r /= 2; } return res; } } t; vector<int> h; vector<int> pos; void init(int N, vector<int> H) { h = H; n = N; pos.resize(n); for(int i = 0; i < n; i ++) h[i] --; for(int i = 0; i < n; i ++) pos[h[i]] = i; vector<int> st; vector<int> lef(n), rig(n); for(int i = 0; i < n; i ++){ if(h[i] != i + 1) sub1 = 0; while(!st.empty() && st.back() <= h[i]) st.pop_back(); if(st.empty()) lef[i] = -1; else lef[i] = st.back(); st.push_back(h[i]); } if(sub1) return; st.clear(); for(int i = n - 1; i >= 0; i --){ while(!st.empty() && st.back() <= h[i]) st.pop_back(); if(st.empty()) rig[i] = -1; else rig[i] = st.back(); st.push_back(h[i]); } up.assign(logn, vector<int> (n, -1)); for(int i = 0; i < n; i ++){ up[0][h[i]] = max(lef[i], rig[i]); } t.build(h); for(int j = 1; j < logn; j ++){ for(int i = 0; i < n; i ++){ if(up[j - 1][i] == -1) continue; //cout << (up[j][i]) << endl; up[j][i] = up[j - 1][up[j - 1][i]]; } } } int minimum_jumps(int A, int B, int C, int D) { if(sub1) return C - B; if(t.get(B, C - 1) >= t.get(C, D)){ return -1; } int l = A - 1, r = B; while(r - l > 1){ int m = (l + r) / 2; if(t.get(m, C - 1) < h[C]){ r = m; }else l = m; } int st = t.get(r, B); int ans = 0; for(int j = logn - 1; j >= 0; j --){ if(up[j][st] != -1 && up[j][st] < h[C]){ st = up[j][st]; ans |= 1 << j; } } return ans + 1; }

Compilation message (stderr)

hexagon.cpp:1:10: fatal error: jumps.h: No such file or directory
    1 | #include "jumps.h"
      |          ^~~~~~~~~
compilation terminated.