답안 #978870

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
978870 2024-05-09T20:54:40 Z Mr_Husanboy 푸드 코트 (JOI21_foodcourt) C++17
0 / 100
1 ms 604 KB
//#pragma GCC optimize("Ofast,O3")
//#pragma GCC target("avx,avx2")
#include <bits/stdc++.h>
using namespace std;



#ifdef LOCAL
#include "debugger.cpp"
#else
#define debug(...)
#endif
template<class T>
int len(T &a){
    return a.size();
}

using ll = long long;
using pii = pair<int,int>;
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
string fileio = "";

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
const int MOD = 1e9 + 7;
const int inf = 1e9;
const ll infl = 1e18;
const int maxn = 100;//1048576;

int n;
ll t[maxn];

void apply(int x, ll B){
    t[x] = max(B, t[x] + B);
}

void push(int x){
    if(t[x]){
        apply(x << 1, t[x]);
        apply(x << 1 | 1, t[x]);
        t[x] = 0;
    }
}

void upd(const int &ql, const int &qr, const ll &k, const int &x = 1, const int &l = 0, const int &r = n - 1){
    if(ql <= l && r <= qr){
        apply(x, k);
        return;
    }
    push(x);
    int m = (l + r) / 2;
    if(m >= ql) upd(ql, qr, k, x << 1, l, m);
    if(m + 1 <= qr) upd(ql, qr, k, x << 1 | 1, m + 1, r);
}

ll get(const int &ind, const int &x = 1, const int &l = 0, const int &r = n - 1){
    if(l == r){
        return max(0ll, t[x]);
    }
    push(x);
    int m = (l + r) / 2;
    if(ind <= m) return get(ind, x << 1, l, m);
    return get(ind, x << 1 | 1, m + 1, r);
}


void solve(){
    int m, q; cin >> n >> m >> q;
    assert(m == 1);
    while(q --){
        int tt; cin >> tt;
        if(tt == 1){
            int l, r, c; ll k;
            cin >> l >> r >> c >> k;
            l --;  r --; c --;
            upd(l, r, k);
        }else if(tt == 2){
            int l, r; ll k; cin >> l >> r >> k;
            l --; r --;
            upd(l, r, -k);
        }else{
            int a; ll b; cin >> a >> b;
            a --;
            cout << (get(a) >= b ? 1 : 0) << '\n';
        }

        //t.out();
    }
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    auto start = chrono::high_resolution_clock::now();
    #ifndef LOCAL
    if(fileio.size()){
        freopen((fileio + ".in").c_str(), "r", stdin);
        freopen((fileio + ".out").c_str(), "w", stdout);
    }
    #endif
    int testcases = 1;
    #ifdef Tests
    cin >> testcases;
    #endif
    while(testcases --){
        solve();
        if(testcases) cout << '\n';
        #ifdef LOCAL
        else cout << '\n';
        cout << "_________________________" << endl;
        #endif
    }
    #ifdef LOCAL
    auto duration = chrono::duration_cast<chrono::microseconds>(chrono::high_resolution_clock::now() - start);
    
    cout << "time: " << (double)duration.count()/1000.0 << " milliseconds" << endl;
    #endif
    return 0;
}   

Compilation message

foodcourt.cpp: In function 'int main()':
foodcourt.cpp:94:10: warning: variable 'start' set but not used [-Wunused-but-set-variable]
   94 |     auto start = chrono::high_resolution_clock::now();
      |          ^~~~~
foodcourt.cpp:97:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   97 |         freopen((fileio + ".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
foodcourt.cpp:98:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   98 |         freopen((fileio + ".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -