Submission #762993

#TimeUsernameProblemLanguageResultExecution timeMemory
762993vjudge1Just Long Neckties (JOI20_ho_t1)C++17
Compilation error
0 ms0 KiB
#include <fstream> #include <iostream> #include <limits> #include <unordered_map> // #pragma GCC optimize("O3,no-stack-protector,fast-math,unroll-loops,tree-vectorize") // #pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma") typedef unsigned short u16; typedef short i16; typedef unsigned int u32; typedef int i32; typedef unsigned long long u64; typedef long long i64; typedef float f32; typedef double f64; typedef long double f80; typedef long double f128; namespace std { template <typename T, typename U> struct hash<pair<T, U>> { size_t operator()(const pair<T, U>& x) const { return hash<T>()(x.first) ^ hash<U>()(x.second); } }; } // namespace std template <typename T> using limits = std::numeric_limits<T>; template <typename T, typename U> using pa = std::pair<T, U>; template <typename T, typename U> using umap = std::unordered_map<T, U>; #ifdef LOCAL #include <chrono> #include "tools.hpp" #define here(...) \ std::cerr << __func__ << ':' << __LINE__ << " [" << #__VA_ARGS__ << "] = ["; \ _debug(__VA_ARGS__) #else #define here(...) #endif void solve() { u32 n; std::cin >> n; std::vector<u32> id(n + 1); std::vector<i32> b(n), pr(n + 1), sf(n + 1); std::vector<std::pair<i32, u32>> c(n + 1); for (u32 i = 0; i < n + 1; ++i) { i32 ai; std::cin >> ai; c[i] = std::make_pair(ai, i); } for (auto& i : b) { std::cin >> i; } std::sort(b.begin(), b.end()); std::sort(c.begin(), c.end()); for (u32 i = 0; i < n + 1; ++i) { id[c[i].second] = i; } for (u32 i = 0; i < n + 1; ++i) { pr[i] = std::max(i > 0 ? pr[i - 1] : 0, c[i].first - (i < n ? b[i] : 0)); } for (u32 i = n; i + 1 > 0; i--) { sf[i] = std::max(i < n ? sf[i + 1] : 0, c[i].first - (i > 0 ? b[i - 1] : 0)); } for (auto& i : id) { std::cout << std::max(i > 0 ? pr[i - 1] : 0, i < n ? sf[i + 1] : 0) << ' '; } std::cout << '\n'; } int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); std::cout.tie(nullptr); #ifdef LOCAL using std::chrono::duration_cast; using std::chrono::high_resolution_clock; using std::chrono::microseconds; auto st = high_resolution_clock::now(); std::ifstream input("./in.txt"); std::ofstream output("./log/bsol.txt"); auto cin_buf = std::cin.rdbuf(input.rdbuf()); auto cout_buf = std::cout.rdbuf(output.rdbuf()); #endif solve(); #ifdef LOCAL std::cin.rdbuf(cin_buf); std::cout.rdbuf(cout_buf); input.close(); output.close(); auto ed = high_resolution_clock::now(); std::cerr << "Time elapsed: " << duration_cast<microseconds>(ed - st).count() << " microseconds\n"; #endif return 0; }

Compilation message (stderr)

ho_t1.cpp: In function 'void solve()':
ho_t1.cpp:53:10: error: 'vector' is not a member of 'std'
   53 |     std::vector<u32> id(n + 1);
      |          ^~~~~~
ho_t1.cpp:5:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
    4 | #include <unordered_map>
  +++ |+#include <vector>
    5 | 
ho_t1.cpp:53:20: error: expected primary-expression before '>' token
   53 |     std::vector<u32> id(n + 1);
      |                    ^
ho_t1.cpp:53:22: error: 'id' was not declared in this scope
   53 |     std::vector<u32> id(n + 1);
      |                      ^~
ho_t1.cpp:54:10: error: 'vector' is not a member of 'std'
   54 |     std::vector<i32> b(n), pr(n + 1), sf(n + 1);
      |          ^~~~~~
ho_t1.cpp:54:10: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
ho_t1.cpp:54:20: error: expected primary-expression before '>' token
   54 |     std::vector<i32> b(n), pr(n + 1), sf(n + 1);
      |                    ^
ho_t1.cpp:54:22: error: 'b' was not declared in this scope
   54 |     std::vector<i32> b(n), pr(n + 1), sf(n + 1);
      |                      ^
ho_t1.cpp:54:28: error: 'pr' was not declared in this scope; did you mean 'pa'?
   54 |     std::vector<i32> b(n), pr(n + 1), sf(n + 1);
      |                            ^~
      |                            pa
ho_t1.cpp:54:39: error: 'sf' was not declared in this scope
   54 |     std::vector<i32> b(n), pr(n + 1), sf(n + 1);
      |                                       ^~
ho_t1.cpp:55:10: error: 'vector' is not a member of 'std'
   55 |     std::vector<std::pair<i32, u32>> c(n + 1);
      |          ^~~~~~
ho_t1.cpp:55:10: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
ho_t1.cpp:55:35: error: expected primary-expression before '>' token
   55 |     std::vector<std::pair<i32, u32>> c(n + 1);
      |                                   ^~
ho_t1.cpp:55:38: error: 'c' was not declared in this scope
   55 |     std::vector<std::pair<i32, u32>> c(n + 1);
      |                                      ^
ho_t1.cpp:66:10: error: 'sort' is not a member of 'std'
   66 |     std::sort(b.begin(), b.end());
      |          ^~~~
ho_t1.cpp:67:10: error: 'sort' is not a member of 'std'
   67 |     std::sort(c.begin(), c.end());
      |          ^~~~