Submission #682296

# Submission time Handle Problem Language Result Execution time Memory
682296 2023-01-16T05:53:31 Z vjudge1 Food Court (JOI21_foodcourt) C++17
7 / 100
956 ms 27336 KB
#include "bits/stdc++.h"
using namespace std;

// #define ORD_SET
// #define ROPE
#ifdef ORD_SET
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    using namespace __gnu_pbds;
    template<typename T>
    using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#endif
#ifdef ROPE
    #include <ext/rope>
    using namespace __gnu_cxx;
#endif        

// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")

using ll = long long;
using ld = long double;
#define pb push_back
#define ff first
#define ss second
#define sz(x) (ll)(x).size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
// #define ll int
void freopen(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); }
void NotInteractive() { ios_base::sync_with_stdio(false); cin.tie(NULL); }
void pre(ll a) { cout<<fixed<<setprecision(a); }
ll bit(ll x) { return __builtin_popcountll(x); }
ll binpow(ll x, ll y, ll z) { ll pow = 1; while(y) { if(y&1) pow *= x, pow %= z; x *= x, x %= z; y >>= 1; } return pow; }
template<typename T> T gcd(T a, T b) { if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b) { return a/gcd(a, b)*b; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

struct sn { ll l, r, x; }; // a.swap(b)
ll B = 316;
const ll mod = (ll)1e9+7;
const ll inf = (ll)1e18+7;
const ll MX = LLONG_MAX;
const ll MN = LLONG_MIN;
const ld P = acos(-1.0);
const ll N = (ll)3e5+5;
vector<pair<ll, ll>> v[N];
vector<ll> len(N);
ll t[N], l[N], r[N], c[N], k[N];

void kigash() {
    ll n, m, q;
    cin>>n>>m>>q;
    if(n>2000 && q>2000) assert(0);
    for(ll i=1; i<=q; i++) {
        ll tmp = -1, lmp = -1, rmp = -1, cmp = -1, kmp = -1;
        cin>>tmp;
        if(tmp==1) cin>>lmp>>rmp>>cmp>>kmp;
        else if(tmp==2) cin>>lmp>>rmp>>kmp;
        else cin>>cmp>>kmp;
        t[i] = tmp, l[i] = lmp, r[i] = rmp, c[i] = cmp, k[i] = kmp;
    }
    for(ll tt=1; tt<=q; tt++) {
        // if(tt==3) {
        //     for(ll i=1; i<=n; i++) {
        //         for(auto x: v[i]) cout<<x.ff<<" "<<x.ss<<"\n";
        //         cout<<"\n";
        //     }
        //     return;
        // }
        if(t[tt]==1) {
            for(ll i=l[tt]; i<=r[tt]; i++) v[i].pb({k[tt], c[tt]}), len[i] += k[tt];
        }
        else if(t[tt]==2) {
            for(ll i=l[tt]; i<=r[tt]; i++) {
                if(len[i]<=k[tt]) len[i] = 0, v[i].clear();
                else {
                    vector<pair<ll, ll>> tmp;
                    ll f = 0;
                    len[i] -= k[tt];
                    for(ll j=0, sum = 0; j<sz(v[i]); j++) {
                        if(f) {
                            tmp.pb(v[i][j]);
                            continue;
                        }
                        sum += v[i][j].ff;
                        if(sum==k[tt]) f = 1;
                        else if(sum>k[tt]) {
                            tmp.pb({v[i][j].ff-(k[tt]-sum+v[i][j].ff), v[i][j].ss});
                            f = 1;
                        }
                    }
                    v[i] = tmp;
                }
            }
        }
        else {
            if(len[c[tt]]>=k[tt]) {
                for(ll i=0, sum = 0; i<sz(v[c[tt]]); i++) {
                    sum += v[c[tt]][i].ff;
                    if(sum>=k[tt]) {
                        cout<<v[c[tt]][i].ss<<"\n";
                        break;
                    }
                }
            }
            else cout<<"0\n";
        }
    }
    return;
}

signed main(/**/) {
    // freopen("");
    NotInteractive();
    // precalc();
    
    ll tt = 1;
    // cin>>tt;
    for(ll i=1; i<=tt; i++) kigash();
    
    exit(0);
}

Compilation message

foodcourt.cpp: In function 'void freopen(std::string)':
foodcourt.cpp:31:33: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 | void freopen(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); }
      |                          ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
foodcourt.cpp:31:75: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 | void freopen(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); }
      |                                                                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 37 ms 10516 KB Output is correct
2 Correct 84 ms 11008 KB Output is correct
3 Correct 164 ms 21080 KB Output is correct
4 Correct 377 ms 24596 KB Output is correct
5 Correct 5 ms 9812 KB Output is correct
6 Correct 5 ms 9812 KB Output is correct
7 Correct 956 ms 27336 KB Output is correct
8 Correct 606 ms 22248 KB Output is correct
9 Correct 129 ms 11272 KB Output is correct
10 Correct 602 ms 21736 KB Output is correct
11 Correct 370 ms 16588 KB Output is correct
12 Correct 134 ms 11296 KB Output is correct
13 Correct 161 ms 10756 KB Output is correct
14 Correct 226 ms 13820 KB Output is correct
15 Correct 282 ms 13600 KB Output is correct
16 Correct 190 ms 11800 KB Output is correct
17 Correct 46 ms 10460 KB Output is correct
18 Correct 82 ms 10644 KB Output is correct
19 Correct 6 ms 9940 KB Output is correct
20 Correct 6 ms 9940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 10516 KB Output is correct
2 Correct 84 ms 11008 KB Output is correct
3 Correct 164 ms 21080 KB Output is correct
4 Correct 377 ms 24596 KB Output is correct
5 Correct 5 ms 9812 KB Output is correct
6 Correct 5 ms 9812 KB Output is correct
7 Correct 956 ms 27336 KB Output is correct
8 Correct 606 ms 22248 KB Output is correct
9 Correct 129 ms 11272 KB Output is correct
10 Correct 602 ms 21736 KB Output is correct
11 Correct 370 ms 16588 KB Output is correct
12 Correct 134 ms 11296 KB Output is correct
13 Correct 161 ms 10756 KB Output is correct
14 Correct 226 ms 13820 KB Output is correct
15 Correct 282 ms 13600 KB Output is correct
16 Correct 190 ms 11800 KB Output is correct
17 Correct 46 ms 10460 KB Output is correct
18 Correct 82 ms 10644 KB Output is correct
19 Correct 6 ms 9940 KB Output is correct
20 Correct 6 ms 9940 KB Output is correct
21 Correct 57 ms 10944 KB Output is correct
22 Correct 121 ms 11340 KB Output is correct
23 Correct 239 ms 20076 KB Output is correct
24 Correct 316 ms 24528 KB Output is correct
25 Correct 6 ms 9812 KB Output is correct
26 Correct 7 ms 9812 KB Output is correct
27 Correct 789 ms 24652 KB Output is correct
28 Correct 715 ms 22988 KB Output is correct
29 Correct 188 ms 13520 KB Output is correct
30 Correct 497 ms 21472 KB Output is correct
31 Correct 369 ms 16392 KB Output is correct
32 Correct 98 ms 11120 KB Output is correct
33 Correct 111 ms 10676 KB Output is correct
34 Correct 361 ms 13812 KB Output is correct
35 Correct 231 ms 11388 KB Output is correct
36 Correct 235 ms 11848 KB Output is correct
37 Correct 7 ms 9892 KB Output is correct
38 Correct 6 ms 9940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 13 ms 19456 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 13 ms 19540 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 37 ms 10516 KB Output is correct
2 Correct 84 ms 11008 KB Output is correct
3 Correct 164 ms 21080 KB Output is correct
4 Correct 377 ms 24596 KB Output is correct
5 Correct 5 ms 9812 KB Output is correct
6 Correct 5 ms 9812 KB Output is correct
7 Correct 956 ms 27336 KB Output is correct
8 Correct 606 ms 22248 KB Output is correct
9 Correct 129 ms 11272 KB Output is correct
10 Correct 602 ms 21736 KB Output is correct
11 Correct 370 ms 16588 KB Output is correct
12 Correct 134 ms 11296 KB Output is correct
13 Correct 161 ms 10756 KB Output is correct
14 Correct 226 ms 13820 KB Output is correct
15 Correct 282 ms 13600 KB Output is correct
16 Correct 190 ms 11800 KB Output is correct
17 Correct 46 ms 10460 KB Output is correct
18 Correct 82 ms 10644 KB Output is correct
19 Correct 6 ms 9940 KB Output is correct
20 Correct 6 ms 9940 KB Output is correct
21 Runtime error 13 ms 19456 KB Execution killed with signal 6
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 15 ms 19660 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 37 ms 10516 KB Output is correct
2 Correct 84 ms 11008 KB Output is correct
3 Correct 164 ms 21080 KB Output is correct
4 Correct 377 ms 24596 KB Output is correct
5 Correct 5 ms 9812 KB Output is correct
6 Correct 5 ms 9812 KB Output is correct
7 Correct 956 ms 27336 KB Output is correct
8 Correct 606 ms 22248 KB Output is correct
9 Correct 129 ms 11272 KB Output is correct
10 Correct 602 ms 21736 KB Output is correct
11 Correct 370 ms 16588 KB Output is correct
12 Correct 134 ms 11296 KB Output is correct
13 Correct 161 ms 10756 KB Output is correct
14 Correct 226 ms 13820 KB Output is correct
15 Correct 282 ms 13600 KB Output is correct
16 Correct 190 ms 11800 KB Output is correct
17 Correct 46 ms 10460 KB Output is correct
18 Correct 82 ms 10644 KB Output is correct
19 Correct 6 ms 9940 KB Output is correct
20 Correct 6 ms 9940 KB Output is correct
21 Correct 57 ms 10944 KB Output is correct
22 Correct 121 ms 11340 KB Output is correct
23 Correct 239 ms 20076 KB Output is correct
24 Correct 316 ms 24528 KB Output is correct
25 Correct 6 ms 9812 KB Output is correct
26 Correct 7 ms 9812 KB Output is correct
27 Correct 789 ms 24652 KB Output is correct
28 Correct 715 ms 22988 KB Output is correct
29 Correct 188 ms 13520 KB Output is correct
30 Correct 497 ms 21472 KB Output is correct
31 Correct 369 ms 16392 KB Output is correct
32 Correct 98 ms 11120 KB Output is correct
33 Correct 111 ms 10676 KB Output is correct
34 Correct 361 ms 13812 KB Output is correct
35 Correct 231 ms 11388 KB Output is correct
36 Correct 235 ms 11848 KB Output is correct
37 Correct 7 ms 9892 KB Output is correct
38 Correct 6 ms 9940 KB Output is correct
39 Runtime error 13 ms 19456 KB Execution killed with signal 6
40 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 37 ms 10516 KB Output is correct
2 Correct 84 ms 11008 KB Output is correct
3 Correct 164 ms 21080 KB Output is correct
4 Correct 377 ms 24596 KB Output is correct
5 Correct 5 ms 9812 KB Output is correct
6 Correct 5 ms 9812 KB Output is correct
7 Correct 956 ms 27336 KB Output is correct
8 Correct 606 ms 22248 KB Output is correct
9 Correct 129 ms 11272 KB Output is correct
10 Correct 602 ms 21736 KB Output is correct
11 Correct 370 ms 16588 KB Output is correct
12 Correct 134 ms 11296 KB Output is correct
13 Correct 161 ms 10756 KB Output is correct
14 Correct 226 ms 13820 KB Output is correct
15 Correct 282 ms 13600 KB Output is correct
16 Correct 190 ms 11800 KB Output is correct
17 Correct 46 ms 10460 KB Output is correct
18 Correct 82 ms 10644 KB Output is correct
19 Correct 6 ms 9940 KB Output is correct
20 Correct 6 ms 9940 KB Output is correct
21 Correct 57 ms 10944 KB Output is correct
22 Correct 121 ms 11340 KB Output is correct
23 Correct 239 ms 20076 KB Output is correct
24 Correct 316 ms 24528 KB Output is correct
25 Correct 6 ms 9812 KB Output is correct
26 Correct 7 ms 9812 KB Output is correct
27 Correct 789 ms 24652 KB Output is correct
28 Correct 715 ms 22988 KB Output is correct
29 Correct 188 ms 13520 KB Output is correct
30 Correct 497 ms 21472 KB Output is correct
31 Correct 369 ms 16392 KB Output is correct
32 Correct 98 ms 11120 KB Output is correct
33 Correct 111 ms 10676 KB Output is correct
34 Correct 361 ms 13812 KB Output is correct
35 Correct 231 ms 11388 KB Output is correct
36 Correct 235 ms 11848 KB Output is correct
37 Correct 7 ms 9892 KB Output is correct
38 Correct 6 ms 9940 KB Output is correct
39 Runtime error 13 ms 19456 KB Execution killed with signal 6
40 Halted 0 ms 0 KB -