답안 #897844

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
897844 2024-01-03T19:44:15 Z trMatherz 벽 (IOI14_wall) C++17
컴파일 오류
0 ms 0 KB
#include <iostream> //cin, cout

/*
#include <fstream>
std::ifstream cin ("ex.in");
std::ofstream cout ("ex.out");
*/




// includes
#include <cmath> 
#include <set>
#include <map>
#include <queue>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <unordered_set>
#include <stack>
#include <ext/pb_ds/assoc_container.hpp>
#include <random>
#include <chrono>



//usings 
using namespace std;
using namespace __gnu_pbds;


// misc
#define ll long long
#define pb push_back
#define pq priority_queue
#define ub upper_bound
#define lb lower_bound
template<typename T, typename U> bool emin(T &a, const U &b){ return b < a ? a = b, true : false; }
template<typename T, typename U> bool emax(T &a, const U &b){ return b > a ? a = b, true : false; }
typedef uint64_t hash_t;

// vectors
#define vi vector<int>
#define vvi vector<vi>
#define vvvi vector<vvi>
#define vpii vector<pair<int, int>>
#define vvpii vector<vector<pair<int, int>>>
#define vppipi vector<pair<int, pair<int, int>>>
#define vl vector<ll>
#define vvl vector<vl>
#define vvvl vector<vvl>
#define vpll vector<pair<ll, ll>>
#define vb vector<bool>
#define vvb vector<vb>
#define vs vector<string>
#define sz(x) (int)x.size()
#define rz(x,y) x.resize(y)
#define all(x) x.begin(), x.end()


// pairs
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mp make_pair
#define f first
#define s second

// sets
#define si set<int>
#define sl set<ll>
#define ss set<string>
#define in insert
template <class T> using iset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// maps
#define mii map<int, int>
#define mll map<ll, ll>

// loops
#define FR(x, z, y) for (int x = z; x < y; x++)
#define FRe(x, z, y) FR(x, z, y + 1)
#define F(x, y) FR(x, 0, y)
#define Fe(x, y) F(x, y + 1)
#define A(x, y) for(auto &x : y)




 
vi seg;
vector<array<int, 3>> lazy;
int s = 1;
int n, k;

void prop(int x, int z, int w, int y){
    if(w == 1) emax(seg[x], z);
    else emin(seg[x], z);
    if(y != -1) seg[x] = z;
    if(x * 2 + 1 < s * 2){
        if(lazy[x * 2][0] == -1) lazy[x * 2] = {z, w, y};
        else {
            if(w == 1){
                if(lazy[x * 2][1] == 1) emax(lazy[x * 2][0], z);
                else if(z > lazy[x * 2][0]) lazy[x * 2] = {z, 1, 0};
            } else {
                if(lazy[x * 2][1] == 1) if(z < lazy[x * 2][0]) lazy[x * 2] = {z, 0, 0};
                else emin(lazy[x * 2][0], z);
            }
        }
        if(lazy[x * 2 + 1][1] == -1) lazy[x * 2 + 1] = {z, w, y};
         else {
            if(w == 1){
                if(lazy[x * 2 + 1][1] == 1) emax(lazy[x * 2 + 1][0], z);
                else if(z > lazy[x * 2 + 1][0]) lazy[x * 2 + 1] = {z, 1, 0};
            } else {
                if(lazy[x * 2 + 1][1] == 1) if(z < lazy[x * 2 + 1][0]) lazy[x * 2 + 1] = {z, 0, 0};
                else emin(lazy[x * 2 + 1][0], z);
            }
        }
    }
    lazy[x] = {-1, -1, -1};
}

void pull(int x){seg[x] = seg[x * 2] + seg[x * 2 + 1];}

void put(int l, int r, int x, int rl, int rr, int z, int w){
    prop(x, lazy[x][0], lazy[x][1], lazy[x][2]);
    if(r < rl || l > rr) return;
    if(rl <= l && r <= rr) {prop(x, z, w, -1); return;}
    int m = (l + r) / 2;
    put(l, m, x * 2, rl, rr, z, w);
    put(m + 1, r, x * 2 + 1, rl, rr, z, w);
    pull(x);
}

int get(int l, int r, int x, int c){
    prop(x, lazy[x][0], lazy[x][1], lazy[x][2]);
    if(r < c || l > c) return 0;
    if(l == r) return seg[x];
    int m = (l + r) / 2;
    return get(0, m, x * 2, c) + get(m + 1, r, x * 2 + 1, c);
}

int main(){
    cin >> n >> k;
    while(s < n) s *= 2;
    seg = vi(s * 2, 0);
    lazy = vector<array<int, 3>>(s * 2, {-1, -1, -1});
    F(i, k){
        int w, x, y, z; cin >> w >> x >> y >> z;
        put(0, s - 1, 1, x, y, z, w);
    }
    F(i, n) cout << get(0, s - 1, 1, i) << endl;
}

Compilation message

wall.cpp: In function 'void prop(int, int, int, int)':
wall.cpp:110:19: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
  110 |                 if(lazy[x * 2][1] == 1) if(z < lazy[x * 2][0]) lazy[x * 2] = {z, 0, 0};
      |                   ^
wall.cpp:120:19: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
  120 |                 if(lazy[x * 2 + 1][1] == 1) if(z < lazy[x * 2 + 1][0]) lazy[x * 2 + 1] = {z, 0, 0};
      |                   ^
/usr/bin/ld: /tmp/ccvrqgWT.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccellgQR.o:wall.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccvrqgWT.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