Submission #217726

# Submission time Handle Problem Language Result Execution time Memory
217726 2020-03-30T14:01:57 Z Vimmer New Home (APIO18_new_home) C++17
12 / 100
2817 ms 26944 KB
#include <bits/stdc++.h>

#define F first
#define S second
#define sz(x) int(x.size())
#define pb push_back
#define N 100005
#define M ll(998244353)

using namespace std;

typedef long double ld;
typedef long long ll;
typedef short int si;


vector <pair <pair <pair <int, int>, int>, int> > sost;

set <int> se[410];

map <pair <int, int>, int > mp;

int main()
{
    ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n, k, q;

    cin >> n >> k >> q;

    for (int i = 0; i < n; i++)
    {
        int x, t, l, r;

        cin >> x >> t >> l >> r;

        sost.pb({{{l, x}, t}, i});

        sost.pb({{{r + 1, x}, -t}, i});
    }

    vector <pair <pair <int, int>, int>  > gr; gr.resize(q);

    for (int i = 0; i < q; i++) {cin >> gr[i].F.S >> gr[i].F.F; gr[i].S = i;}

    sort(sost.begin(), sost.end());

    sort(gr.begin(), gr.end());

    int ans[q];

    int j = 0;

    for (auto it : gr)
    {
        int nm = it.S, x = it.F.S, tr = it.F.F;

        while (j < n + n && sost[j].F.F.F <= tr)
        {
            int tp = abs(sost[j].F.S);

            if (sost[j].F.S > 0) {mp[{tp, sost[j].F.F.S}]++; if (mp[{tp, sost[j].F.F.S}] == 1) se[tp].insert(sost[j].F.F.S);}
               else  {mp[{tp, sost[j].F.F.S}]--; if (mp[{tp, sost[j].F.F.S}] == 0) se[tp].erase(sost[j].F.F.S);}

            j++;
        }

        bool f = 1;

        int mx = 0;

        for (int i = 1; i <= k; i++)
        {
            if (sz(se[i]) == 0) {f = 0; break;}

            auto it = se[i].lower_bound(x);

            int mn = 1e9;

            if (it != se[i].end()) mn = min(mn, abs(*it - x));

            if (it != se[i].begin()) {it--; mn = min(mn, abs(*it - x)); }

            mx = max(mx, mn);
        }

        if (!f) ans[nm] = -1; else ans[nm] = mx;
    }

    for (int i = 0; i < q; i++) cout << ans[i] << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 7 ms 384 KB Output is correct
8 Correct 7 ms 384 KB Output is correct
9 Correct 6 ms 384 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 6 ms 256 KB Output is correct
12 Correct 6 ms 384 KB Output is correct
13 Correct 6 ms 384 KB Output is correct
14 Correct 7 ms 384 KB Output is correct
15 Correct 10 ms 384 KB Output is correct
16 Correct 10 ms 384 KB Output is correct
17 Correct 6 ms 384 KB Output is correct
18 Correct 7 ms 384 KB Output is correct
19 Correct 6 ms 384 KB Output is correct
20 Correct 6 ms 384 KB Output is correct
21 Correct 6 ms 384 KB Output is correct
22 Correct 7 ms 384 KB Output is correct
23 Correct 6 ms 384 KB Output is correct
24 Correct 6 ms 384 KB Output is correct
25 Correct 6 ms 384 KB Output is correct
26 Correct 6 ms 384 KB Output is correct
27 Correct 6 ms 384 KB Output is correct
28 Correct 7 ms 384 KB Output is correct
29 Correct 6 ms 384 KB Output is correct
30 Correct 6 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 7 ms 384 KB Output is correct
8 Correct 7 ms 384 KB Output is correct
9 Correct 6 ms 384 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 6 ms 256 KB Output is correct
12 Correct 6 ms 384 KB Output is correct
13 Correct 6 ms 384 KB Output is correct
14 Correct 7 ms 384 KB Output is correct
15 Correct 10 ms 384 KB Output is correct
16 Correct 10 ms 384 KB Output is correct
17 Correct 6 ms 384 KB Output is correct
18 Correct 7 ms 384 KB Output is correct
19 Correct 6 ms 384 KB Output is correct
20 Correct 6 ms 384 KB Output is correct
21 Correct 6 ms 384 KB Output is correct
22 Correct 7 ms 384 KB Output is correct
23 Correct 6 ms 384 KB Output is correct
24 Correct 6 ms 384 KB Output is correct
25 Correct 6 ms 384 KB Output is correct
26 Correct 6 ms 384 KB Output is correct
27 Correct 6 ms 384 KB Output is correct
28 Correct 7 ms 384 KB Output is correct
29 Correct 6 ms 384 KB Output is correct
30 Correct 6 ms 384 KB Output is correct
31 Correct 2817 ms 10472 KB Output is correct
32 Correct 167 ms 3432 KB Output is correct
33 Correct 373 ms 8552 KB Output is correct
34 Correct 2021 ms 8796 KB Output is correct
35 Correct 1367 ms 10344 KB Output is correct
36 Correct 426 ms 10344 KB Output is correct
37 Correct 351 ms 7656 KB Output is correct
38 Correct 285 ms 7656 KB Output is correct
39 Correct 243 ms 7400 KB Output is correct
40 Correct 245 ms 7400 KB Output is correct
41 Correct 464 ms 7668 KB Output is correct
42 Correct 397 ms 7528 KB Output is correct
43 Correct 248 ms 3944 KB Output is correct
44 Correct 425 ms 7656 KB Output is correct
45 Correct 279 ms 7656 KB Output is correct
46 Correct 237 ms 7656 KB Output is correct
47 Correct 219 ms 7144 KB Output is correct
48 Correct 213 ms 7016 KB Output is correct
49 Correct 248 ms 7272 KB Output is correct
50 Correct 385 ms 7392 KB Output is correct
51 Correct 233 ms 7272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 345 ms 26944 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 338 ms 26688 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 7 ms 384 KB Output is correct
8 Correct 7 ms 384 KB Output is correct
9 Correct 6 ms 384 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 6 ms 256 KB Output is correct
12 Correct 6 ms 384 KB Output is correct
13 Correct 6 ms 384 KB Output is correct
14 Correct 7 ms 384 KB Output is correct
15 Correct 10 ms 384 KB Output is correct
16 Correct 10 ms 384 KB Output is correct
17 Correct 6 ms 384 KB Output is correct
18 Correct 7 ms 384 KB Output is correct
19 Correct 6 ms 384 KB Output is correct
20 Correct 6 ms 384 KB Output is correct
21 Correct 6 ms 384 KB Output is correct
22 Correct 7 ms 384 KB Output is correct
23 Correct 6 ms 384 KB Output is correct
24 Correct 6 ms 384 KB Output is correct
25 Correct 6 ms 384 KB Output is correct
26 Correct 6 ms 384 KB Output is correct
27 Correct 6 ms 384 KB Output is correct
28 Correct 7 ms 384 KB Output is correct
29 Correct 6 ms 384 KB Output is correct
30 Correct 6 ms 384 KB Output is correct
31 Correct 2817 ms 10472 KB Output is correct
32 Correct 167 ms 3432 KB Output is correct
33 Correct 373 ms 8552 KB Output is correct
34 Correct 2021 ms 8796 KB Output is correct
35 Correct 1367 ms 10344 KB Output is correct
36 Correct 426 ms 10344 KB Output is correct
37 Correct 351 ms 7656 KB Output is correct
38 Correct 285 ms 7656 KB Output is correct
39 Correct 243 ms 7400 KB Output is correct
40 Correct 245 ms 7400 KB Output is correct
41 Correct 464 ms 7668 KB Output is correct
42 Correct 397 ms 7528 KB Output is correct
43 Correct 248 ms 3944 KB Output is correct
44 Correct 425 ms 7656 KB Output is correct
45 Correct 279 ms 7656 KB Output is correct
46 Correct 237 ms 7656 KB Output is correct
47 Correct 219 ms 7144 KB Output is correct
48 Correct 213 ms 7016 KB Output is correct
49 Correct 248 ms 7272 KB Output is correct
50 Correct 385 ms 7392 KB Output is correct
51 Correct 233 ms 7272 KB Output is correct
52 Runtime error 71 ms 5864 KB Execution killed with signal 11 (could be triggered by violating memory limits)
53 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 7 ms 384 KB Output is correct
8 Correct 7 ms 384 KB Output is correct
9 Correct 6 ms 384 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 6 ms 256 KB Output is correct
12 Correct 6 ms 384 KB Output is correct
13 Correct 6 ms 384 KB Output is correct
14 Correct 7 ms 384 KB Output is correct
15 Correct 10 ms 384 KB Output is correct
16 Correct 10 ms 384 KB Output is correct
17 Correct 6 ms 384 KB Output is correct
18 Correct 7 ms 384 KB Output is correct
19 Correct 6 ms 384 KB Output is correct
20 Correct 6 ms 384 KB Output is correct
21 Correct 6 ms 384 KB Output is correct
22 Correct 7 ms 384 KB Output is correct
23 Correct 6 ms 384 KB Output is correct
24 Correct 6 ms 384 KB Output is correct
25 Correct 6 ms 384 KB Output is correct
26 Correct 6 ms 384 KB Output is correct
27 Correct 6 ms 384 KB Output is correct
28 Correct 7 ms 384 KB Output is correct
29 Correct 6 ms 384 KB Output is correct
30 Correct 6 ms 384 KB Output is correct
31 Correct 2817 ms 10472 KB Output is correct
32 Correct 167 ms 3432 KB Output is correct
33 Correct 373 ms 8552 KB Output is correct
34 Correct 2021 ms 8796 KB Output is correct
35 Correct 1367 ms 10344 KB Output is correct
36 Correct 426 ms 10344 KB Output is correct
37 Correct 351 ms 7656 KB Output is correct
38 Correct 285 ms 7656 KB Output is correct
39 Correct 243 ms 7400 KB Output is correct
40 Correct 245 ms 7400 KB Output is correct
41 Correct 464 ms 7668 KB Output is correct
42 Correct 397 ms 7528 KB Output is correct
43 Correct 248 ms 3944 KB Output is correct
44 Correct 425 ms 7656 KB Output is correct
45 Correct 279 ms 7656 KB Output is correct
46 Correct 237 ms 7656 KB Output is correct
47 Correct 219 ms 7144 KB Output is correct
48 Correct 213 ms 7016 KB Output is correct
49 Correct 248 ms 7272 KB Output is correct
50 Correct 385 ms 7392 KB Output is correct
51 Correct 233 ms 7272 KB Output is correct
52 Runtime error 345 ms 26944 KB Execution killed with signal 11 (could be triggered by violating memory limits)
53 Halted 0 ms 0 KB -