Submission #699513

#TimeUsernameProblemLanguageResultExecution timeMemory
699513nguyentunglamWall (IOI14_wall)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
#define fi first
#define se second
#define endl "\n"
#define ii pair<int, int>
using namespace std;
const int N = 2e6 + 10;
int a[N], L[N << 2], R[N << 2];
int range(int l, int r, int val) {
    return min(r, max(l, val));
}
void push(int s, int l, int r) {
    if (l == r) return;
    L[s << 1] = range(L[s], R[s], L[s << 1]);
    R[s << 1] = range(L[s], R[s], R[s << 1]);
    L[s << 1 | 1] = range(L[s], R[s], L[s << 1 | 1]);
    R[s << 1 | 1] = range(L[s], R[s], R[s << 1 | 1]);
    L[s] = 0; R[s] = 1e5;
}
void up(int s, int l, int r, int from, int to, int val, int type) {
    push(s, l, r);
    if (l > to || r < from) return;
    if (from <= l && r <= to) {
        if (type == 1) {
            L[s] = max(L[s], val);
            R[s] = max(R[s], val);
        }
        else {
            L[s] = min(L[s], val);
            R[s] = min(R[s], val);
        }
        push(s, l, r);
        return;
    }
    int mid = l + r >> 1;
    up(s << 1, l, mid, from, to, val, type);
    up(s << 1 | 1, mid + 1, r, from, to, val ,type);
}
void get(int s, int l, int r) {
    push(s, l, r);
    if (l == r) {
        a[l] = L[s];
        return;
    }
    int mid = l + r >> 1;
    get(s << 1, l, mid);
    get(s << 1 | 1, mid + 1, r);
}
int main() {
    #define task ""
    cin.tie(0) -> sync_with_stdio(0);
    if (fopen ("task.inp", "r")) {
        freopen ("task.inp", "r", stdin);
        freopen ("task.out", "w", stdout);
    }
    if (fopen (task".inp", "r")) {
        freopen (task".inp", "r", stdin);
        freopen (task".out", "w", stdout);
    }
    int n, k; cin >> n >> k;
    for(int i = 1; i <= 4 * n; i++) R[i] = 1e5;
    while (k--) {
        int op, l, r, h; cin >> op >> l >> r >> h;
        up(1, 0, n - 1, l, r, h, op);
    }
    get(1, 0, n - 1);
    for(int i = 0; i < n; i++) cout << a[i] << " ";
}

Compilation message (stderr)

wall.cpp: In function 'void up(int, int, int, int, int, int, int)':
wall.cpp:35:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   35 |     int mid = l + r >> 1;
      |               ~~^~~
wall.cpp: In function 'void get(int, int, int)':
wall.cpp:45:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   45 |     int mid = l + r >> 1;
      |               ~~^~~
wall.cpp: In function 'int main()':
wall.cpp:53:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   53 |         freopen ("task.inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
wall.cpp:54:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |         freopen ("task.out", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
wall.cpp:57:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   57 |         freopen (task".inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
wall.cpp:58:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   58 |         freopen (task".out", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccj7Q0BE.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccTGPQ4F.o:wall.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccj7Q0BE.o: in function `main':
grader.cpp:(.text.startup+0x133): undefined reference to `buildWall(int, int, int*, int*, int*, int*, int*)'
collect2: error: ld returned 1 exit status