Submission #586738

# Submission time Handle Problem Language Result Execution time Memory
586738 2022-06-30T15:30:29 Z xynex Wall (IOI14_wall) C++17
100 / 100
552 ms 70008 KB
#include <bits/stdc++.h>
#include "wall.h"
using namespace std;

#define ll long long
#define dl double long
#define ull unsigned long long
#define pr pair
#define vt vector
#define ff first
#define ss second
#define mp make_pair
#define sz(a) (int)a.size()
#define pb push_back
#define pf push_front
#define popB pop_back
#define popF pop_front
#define bit_count __builtin_popcount
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed << setprecision(x)

template<typename T> T get_rand(T l, T r) {
  random_device rd;
  mt19937 gen(rd());
  return uniform_int_distribution<T>(l, r)(gen);
}
template<typename T> T lcm(T a, T b) { return a * (b / __gcd(a, b)); }

template<class A> void read(vt<A>& v);
template<class A, size_t S> void read(array<A, S>& a);
template<class T> void read(T& x) { cin >> x; }
void read(double& d) { string t; read(t); d = stod(t); }
void read(long double& d) { string t; read(t); d = stold(t); }
template<class H, class... T> void read(H& h, T&... t) { read(h); read(t...); }
template<class A> void read(vt<A>& x) { for (auto& a : x) read(a); }
template<class A, size_t S> void read(array<A, S>& x) { for (auto& a : x) read(a); }

string to_string(char c) { return string(1, c); }
string to_string(bool b) { return b ? "true" : "false"; }
string to_string(const char* s) { return string(s); }
string to_string(string s) { return s; }
string to_string(vt<bool> v) { string res; for (int i = 0; i < sz(v); ++i) res += char('0' + v[i]); return res; }
template<size_t S> string to_string(bitset<S> b) { string res; for (int i = 0; i < S; ++i) res += char('0' + b[i]); return res; }
template<class T> string to_string(T v) { bool f = 1; string res; for (auto x : v) { if (!f) res += ' '; f = 0; res += to_string(x); } return res; }

template<class A> void write(A x) { cout << to_string(x); }
template<class H, class... T> void write(const H& h, const T&... t) { write(h); write(t...); }

void print() { write("\n"); }
template<class H, class... T> void print(const H& h, const T&... t) { write(h); if (sizeof...(t)) write(' '); print(t...); }

void freop(string s) {
  freopen((s + ".in").c_str(), "r", stdin);
  freopen((s + ".out").c_str(), "w", stdout);
}

const int MOD = 1e9 + 7;
const int N = 8e6 + 5;
const ll INF = 9e18;
const int M = 3e3 + 5;
const dl pi = acos(-1);
const dl eps = 1e-12;
const int sq = 700;

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};
/* ll vs int*/
int mn[N], mx[N], n;
void upd(int l, int r, int val, bool whr, int tl = 0, int tr = n - 1, int v = 1) {
  val = max(mx[v], val);
  val = min(mn[v], val);
  if(tl > r || tr < l) return;
  if(tl >= l && tr <= r) {
    if(whr) mn[v] = val;
    else mx[v] = val;
    return;
  }
  int mid = (tl + tr) >> 1;
  upd(l, r, val, whr, tl, mid, v * 2); upd(l, r, val, whr, mid + 1, tr, v * 2 + 1);
}
void get(int *arr, int cur = 0, int tl = 0, int tr = n - 1, int v = 1) {
  cur = max(mx[v], cur);
  cur = min(mn[v], cur);
  if(tl == tr) {
    arr[tl] = cur;
    return;
  }
  int mid = (tl + tr) >> 1;
  get(arr, cur, tl, mid, v * 2); get(arr, cur, mid + 1, tr, v * 2 + 1);
}
void buildWall(int N, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
  n = N;
  for(int i = 1; i <= 4 * n; ++i) mn[i] = MOD;
  for(int i = k - 1; i >= 0; --i) {
    upd(left[i], right[i], height[i], op[i] - 1);
  }
  get(finalHeight);
  return;
}
/*
int main()
{
  int n;
  int k;

  int i, j;
  int status = 0;

  status = scanf("%d%d", &n, &k);
  assert(status == 2);

  int* op = (int*)calloc(sizeof(int), k);
  int* left = (int*)calloc(sizeof(int), k);
  int* right = (int*)calloc(sizeof(int), k);
  int* height = (int*)calloc(sizeof(int), k);
  int* finalHeight = (int*)calloc(sizeof(int), n);

  for (i = 0; i < k; i++){
    status = scanf("%d%d%d%d", &op[i], &left[i], &right[i], &height[i]);
    assert(status == 4);
  }

  buildWall(n, k, op, left, right, height, finalHeight);

  for (j = 0; j < n; j++)
    printf("%d\n", finalHeight[j]);

  return 0;
}*/

Compilation message

wall.cpp: In function 'void freop(std::string)':
wall.cpp:54:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |   freopen((s + ".in").c_str(), "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
wall.cpp:55:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   55 |   freopen((s + ".out").c_str(), "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 4 ms 724 KB Output is correct
5 Correct 4 ms 724 KB Output is correct
6 Correct 4 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 134 ms 8180 KB Output is correct
3 Correct 124 ms 4168 KB Output is correct
4 Correct 346 ms 11256 KB Output is correct
5 Correct 238 ms 11904 KB Output is correct
6 Correct 218 ms 11780 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 5 ms 716 KB Output is correct
5 Correct 4 ms 724 KB Output is correct
6 Correct 4 ms 724 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 132 ms 8096 KB Output is correct
9 Correct 126 ms 4172 KB Output is correct
10 Correct 315 ms 11300 KB Output is correct
11 Correct 234 ms 11896 KB Output is correct
12 Correct 255 ms 11760 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 130 ms 8068 KB Output is correct
15 Correct 21 ms 1344 KB Output is correct
16 Correct 323 ms 11512 KB Output is correct
17 Correct 223 ms 11536 KB Output is correct
18 Correct 224 ms 11564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 4 ms 724 KB Output is correct
5 Correct 4 ms 724 KB Output is correct
6 Correct 4 ms 724 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 132 ms 8060 KB Output is correct
9 Correct 119 ms 4128 KB Output is correct
10 Correct 326 ms 11276 KB Output is correct
11 Correct 231 ms 11772 KB Output is correct
12 Correct 217 ms 11724 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 135 ms 8128 KB Output is correct
15 Correct 19 ms 1364 KB Output is correct
16 Correct 316 ms 11572 KB Output is correct
17 Correct 217 ms 11528 KB Output is correct
18 Correct 213 ms 11460 KB Output is correct
19 Correct 544 ms 69880 KB Output is correct
20 Correct 513 ms 67348 KB Output is correct
21 Correct 552 ms 69848 KB Output is correct
22 Correct 514 ms 67356 KB Output is correct
23 Correct 532 ms 67360 KB Output is correct
24 Correct 534 ms 67416 KB Output is correct
25 Correct 521 ms 67388 KB Output is correct
26 Correct 535 ms 70008 KB Output is correct
27 Correct 532 ms 69916 KB Output is correct
28 Correct 538 ms 67400 KB Output is correct
29 Correct 521 ms 67420 KB Output is correct
30 Correct 535 ms 67424 KB Output is correct