Submission #502586

# Submission time Handle Problem Language Result Execution time Memory
502586 2022-01-06T09:55:56 Z cig32 Food Court (JOI21_foodcourt) C++17
9 / 100
941 ms 524292 KB
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define int long long
 
const int MAXN = 2.5e5 + 10;
const int MOD = 1e9 + 7;
mt19937_64 rng((int)std::chrono::steady_clock::now().time_since_epoch().count());
int rnd(int x, int y) {
    int u = uniform_int_distribution<int>(x, y)(rng);
    return u;
}

int N, M, Q;
vector<pair<int, int> > v[MAXN];
int ptr[MAXN];

void join(int l, int r, int c, int k) {
    for(int i=l; i<=r; i++) {
        v[i].push_back({c, k});
    }
}

void leave(int l, int r, int k) {
    for(int i=l; i<=r; i++) {
        ptr[i] += k;
        ptr[i] = min(ptr[i], (int)v[i].size());
    }
}

int service(int a, int b) {
    if(v[a].size() > 0 && ptr[a] + b - 1 <= v[a].size() - 1) return v[a][ptr[a] + b - 1].first;
    else return 0;
}

void solve(int tc) {
    int N, M, Q;
    cin >> N >> M >> Q;
    while(Q--) {
        int t;
        cin >> t;
        if(t == 1) {
            int l, r, c, k;
            cin >> l >> r >> c >> k;
            join(l, r, c, k);
        }
        else if(t == 2) {
            int l, r, k;
            cin >> l >> r >> k;
            leave(l, r, k);
        }
        else {
            int a, b;
            cin >> a >> b;
            cout << service(a, b) << "\n";
        }
    }
}
int32_t main(){
    ios::sync_with_stdio(0); cin.tie(0);
    int t = 1; //cin >> t;
    for(int i=1; i<=t; i++) {
        solve(i);
    }
}

Compilation message

foodcourt.cpp: In function 'long long int service(long long int, long long int)':
foodcourt.cpp:32:42: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     if(v[a].size() > 0 && ptr[a] + b - 1 <= v[a].size() - 1) return v[a][ptr[a] + b - 1].first;
      |                           ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 8 ms 11980 KB Output is correct
2 Correct 13 ms 17672 KB Output is correct
3 Correct 15 ms 19532 KB Output is correct
4 Correct 23 ms 30152 KB Output is correct
5 Correct 4 ms 6220 KB Output is correct
6 Correct 4 ms 6220 KB Output is correct
7 Correct 19 ms 23596 KB Output is correct
8 Correct 18 ms 23048 KB Output is correct
9 Correct 22 ms 23168 KB Output is correct
10 Correct 19 ms 24148 KB Output is correct
11 Correct 20 ms 24652 KB Output is correct
12 Correct 19 ms 23628 KB Output is correct
13 Correct 25 ms 31976 KB Output is correct
14 Correct 33 ms 37100 KB Output is correct
15 Correct 19 ms 21708 KB Output is correct
16 Correct 30 ms 36880 KB Output is correct
17 Correct 11 ms 15128 KB Output is correct
18 Correct 16 ms 19932 KB Output is correct
19 Correct 5 ms 6348 KB Output is correct
20 Correct 5 ms 6476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 11980 KB Output is correct
2 Correct 13 ms 17672 KB Output is correct
3 Correct 15 ms 19532 KB Output is correct
4 Correct 23 ms 30152 KB Output is correct
5 Correct 4 ms 6220 KB Output is correct
6 Correct 4 ms 6220 KB Output is correct
7 Correct 19 ms 23596 KB Output is correct
8 Correct 18 ms 23048 KB Output is correct
9 Correct 22 ms 23168 KB Output is correct
10 Correct 19 ms 24148 KB Output is correct
11 Correct 20 ms 24652 KB Output is correct
12 Correct 19 ms 23628 KB Output is correct
13 Correct 25 ms 31976 KB Output is correct
14 Correct 33 ms 37100 KB Output is correct
15 Correct 19 ms 21708 KB Output is correct
16 Correct 30 ms 36880 KB Output is correct
17 Correct 11 ms 15128 KB Output is correct
18 Correct 16 ms 19932 KB Output is correct
19 Correct 5 ms 6348 KB Output is correct
20 Correct 5 ms 6476 KB Output is correct
21 Incorrect 12 ms 16460 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 593 ms 10092 KB Output is correct
2 Correct 469 ms 13052 KB Output is correct
3 Correct 583 ms 13900 KB Output is correct
4 Correct 593 ms 13980 KB Output is correct
5 Correct 470 ms 17104 KB Output is correct
6 Correct 451 ms 16964 KB Output is correct
7 Correct 19 ms 7496 KB Output is correct
8 Correct 22 ms 7876 KB Output is correct
9 Correct 916 ms 11744 KB Output is correct
10 Correct 928 ms 11772 KB Output is correct
11 Correct 941 ms 11924 KB Output is correct
12 Correct 922 ms 11848 KB Output is correct
13 Correct 171 ms 12996 KB Output is correct
14 Correct 276 ms 14112 KB Output is correct
15 Correct 66 ms 16612 KB Output is correct
16 Correct 76 ms 16832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 683 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 11980 KB Output is correct
2 Correct 13 ms 17672 KB Output is correct
3 Correct 15 ms 19532 KB Output is correct
4 Correct 23 ms 30152 KB Output is correct
5 Correct 4 ms 6220 KB Output is correct
6 Correct 4 ms 6220 KB Output is correct
7 Correct 19 ms 23596 KB Output is correct
8 Correct 18 ms 23048 KB Output is correct
9 Correct 22 ms 23168 KB Output is correct
10 Correct 19 ms 24148 KB Output is correct
11 Correct 20 ms 24652 KB Output is correct
12 Correct 19 ms 23628 KB Output is correct
13 Correct 25 ms 31976 KB Output is correct
14 Correct 33 ms 37100 KB Output is correct
15 Correct 19 ms 21708 KB Output is correct
16 Correct 30 ms 36880 KB Output is correct
17 Correct 11 ms 15128 KB Output is correct
18 Correct 16 ms 19932 KB Output is correct
19 Correct 5 ms 6348 KB Output is correct
20 Correct 5 ms 6476 KB Output is correct
21 Correct 593 ms 10092 KB Output is correct
22 Correct 469 ms 13052 KB Output is correct
23 Correct 583 ms 13900 KB Output is correct
24 Correct 593 ms 13980 KB Output is correct
25 Correct 470 ms 17104 KB Output is correct
26 Correct 451 ms 16964 KB Output is correct
27 Correct 19 ms 7496 KB Output is correct
28 Correct 22 ms 7876 KB Output is correct
29 Correct 916 ms 11744 KB Output is correct
30 Correct 928 ms 11772 KB Output is correct
31 Correct 941 ms 11924 KB Output is correct
32 Correct 922 ms 11848 KB Output is correct
33 Correct 171 ms 12996 KB Output is correct
34 Correct 276 ms 14112 KB Output is correct
35 Correct 66 ms 16612 KB Output is correct
36 Correct 76 ms 16832 KB Output is correct
37 Runtime error 585 ms 524292 KB Execution killed with signal 9
38 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 598 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 11980 KB Output is correct
2 Correct 13 ms 17672 KB Output is correct
3 Correct 15 ms 19532 KB Output is correct
4 Correct 23 ms 30152 KB Output is correct
5 Correct 4 ms 6220 KB Output is correct
6 Correct 4 ms 6220 KB Output is correct
7 Correct 19 ms 23596 KB Output is correct
8 Correct 18 ms 23048 KB Output is correct
9 Correct 22 ms 23168 KB Output is correct
10 Correct 19 ms 24148 KB Output is correct
11 Correct 20 ms 24652 KB Output is correct
12 Correct 19 ms 23628 KB Output is correct
13 Correct 25 ms 31976 KB Output is correct
14 Correct 33 ms 37100 KB Output is correct
15 Correct 19 ms 21708 KB Output is correct
16 Correct 30 ms 36880 KB Output is correct
17 Correct 11 ms 15128 KB Output is correct
18 Correct 16 ms 19932 KB Output is correct
19 Correct 5 ms 6348 KB Output is correct
20 Correct 5 ms 6476 KB Output is correct
21 Incorrect 12 ms 16460 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 11980 KB Output is correct
2 Correct 13 ms 17672 KB Output is correct
3 Correct 15 ms 19532 KB Output is correct
4 Correct 23 ms 30152 KB Output is correct
5 Correct 4 ms 6220 KB Output is correct
6 Correct 4 ms 6220 KB Output is correct
7 Correct 19 ms 23596 KB Output is correct
8 Correct 18 ms 23048 KB Output is correct
9 Correct 22 ms 23168 KB Output is correct
10 Correct 19 ms 24148 KB Output is correct
11 Correct 20 ms 24652 KB Output is correct
12 Correct 19 ms 23628 KB Output is correct
13 Correct 25 ms 31976 KB Output is correct
14 Correct 33 ms 37100 KB Output is correct
15 Correct 19 ms 21708 KB Output is correct
16 Correct 30 ms 36880 KB Output is correct
17 Correct 11 ms 15128 KB Output is correct
18 Correct 16 ms 19932 KB Output is correct
19 Correct 5 ms 6348 KB Output is correct
20 Correct 5 ms 6476 KB Output is correct
21 Incorrect 12 ms 16460 KB Output isn't correct
22 Halted 0 ms 0 KB -