Submission #710011

# Submission time Handle Problem Language Result Execution time Memory
710011 2023-03-15T03:12:12 Z vjudge1 New Home (APIO18_new_home) C++17
12 / 100
5000 ms 64240 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
typedef pair<ii,ii> iiii;
#define ff first
#define ss second

const int maxn = 3e5 + 10;
int n,k,m;
multiset<int> ms[maxn];
vector <iiii> d;
int res[maxn];
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    cin>>n>>k>>m;
    for (int i=1; i<=n; i++)
    {
        int x,y,l,r; cin>>x>>y>>l>>r;
        d.push_back({{l,-1},{x,y}});
        d.push_back({{r,1},{x,y}});
    }
    for (int i=1; i<=m; i++)
    {
        int x,l; cin>>x>>l;
        d.push_back({{l,0},{x,i}});
    }
    sort(d.begin(),d.end());
    for (iiii i:d)
    {
//        cout<<i.ff.ff<<' '<<i.ff.ss<<" : "<<i.ss.ff<<' '<<i.ss.ss<<endl;
        if (i.ff.ss == -1) ms[i.ss.ss].insert(i.ss.ff);
        else if (i.ff.ss == 1) ms[i.ss.ss].erase(ms[i.ss.ss].find(i.ss.ff));
        else
        {
            bool check = 1;
            int ans = 0;
            for (int j=1; j<=k; j++) if (!ms[j].empty())
            {
                int temp = 1e9;
                auto x = ms[j].upper_bound(i.ss.ff);
                if (x!=ms[j].end()) temp = min(temp , (*x) - i.ss.ff);
                if (x!=ms[j].begin())
                {
                    x--;
                    temp = min(temp, i.ss.ff - (*x));
                }
                ans = max(ans,temp);
            }
            else
            {
                check=0;
                break;
            }
            if (check) res[i.ss.ss] = ans;
            else res[i.ss.ss] = -1;
        }
    }
    for (int i=1; i<=m; i++) cout<<res[i]<<'\n';
}
/**
4 2 4
3 1 1 10
9 2 2 4
7 2 5 7
4 1 8 10
5 3
5 6
5 9
1 10
**/
# Verdict Execution time Memory Grader output
1 Correct 9 ms 14292 KB Output is correct
2 Correct 7 ms 14292 KB Output is correct
3 Correct 8 ms 14292 KB Output is correct
4 Correct 7 ms 14420 KB Output is correct
5 Correct 8 ms 14416 KB Output is correct
6 Correct 9 ms 14484 KB Output is correct
7 Correct 8 ms 14420 KB Output is correct
8 Correct 9 ms 14548 KB Output is correct
9 Correct 8 ms 14420 KB Output is correct
10 Correct 8 ms 14548 KB Output is correct
11 Correct 8 ms 14432 KB Output is correct
12 Correct 8 ms 14428 KB Output is correct
13 Correct 8 ms 14548 KB Output is correct
14 Correct 8 ms 14432 KB Output is correct
15 Correct 10 ms 14428 KB Output is correct
16 Correct 10 ms 14424 KB Output is correct
17 Correct 9 ms 14428 KB Output is correct
18 Correct 8 ms 14548 KB Output is correct
19 Correct 8 ms 14428 KB Output is correct
20 Correct 8 ms 14488 KB Output is correct
21 Correct 10 ms 14492 KB Output is correct
22 Correct 9 ms 14424 KB Output is correct
23 Correct 8 ms 14420 KB Output is correct
24 Correct 9 ms 14424 KB Output is correct
25 Correct 8 ms 14428 KB Output is correct
26 Correct 8 ms 14548 KB Output is correct
27 Correct 10 ms 14420 KB Output is correct
28 Correct 9 ms 14428 KB Output is correct
29 Correct 8 ms 14492 KB Output is correct
30 Correct 7 ms 14420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 14292 KB Output is correct
2 Correct 7 ms 14292 KB Output is correct
3 Correct 8 ms 14292 KB Output is correct
4 Correct 7 ms 14420 KB Output is correct
5 Correct 8 ms 14416 KB Output is correct
6 Correct 9 ms 14484 KB Output is correct
7 Correct 8 ms 14420 KB Output is correct
8 Correct 9 ms 14548 KB Output is correct
9 Correct 8 ms 14420 KB Output is correct
10 Correct 8 ms 14548 KB Output is correct
11 Correct 8 ms 14432 KB Output is correct
12 Correct 8 ms 14428 KB Output is correct
13 Correct 8 ms 14548 KB Output is correct
14 Correct 8 ms 14432 KB Output is correct
15 Correct 10 ms 14428 KB Output is correct
16 Correct 10 ms 14424 KB Output is correct
17 Correct 9 ms 14428 KB Output is correct
18 Correct 8 ms 14548 KB Output is correct
19 Correct 8 ms 14428 KB Output is correct
20 Correct 8 ms 14488 KB Output is correct
21 Correct 10 ms 14492 KB Output is correct
22 Correct 9 ms 14424 KB Output is correct
23 Correct 8 ms 14420 KB Output is correct
24 Correct 9 ms 14424 KB Output is correct
25 Correct 8 ms 14428 KB Output is correct
26 Correct 8 ms 14548 KB Output is correct
27 Correct 10 ms 14420 KB Output is correct
28 Correct 9 ms 14428 KB Output is correct
29 Correct 8 ms 14492 KB Output is correct
30 Correct 7 ms 14420 KB Output is correct
31 Correct 1766 ms 26676 KB Output is correct
32 Correct 87 ms 23616 KB Output is correct
33 Correct 161 ms 24860 KB Output is correct
34 Correct 1391 ms 25020 KB Output is correct
35 Correct 841 ms 26688 KB Output is correct
36 Correct 180 ms 26584 KB Output is correct
37 Correct 151 ms 24924 KB Output is correct
38 Correct 113 ms 24892 KB Output is correct
39 Correct 83 ms 24884 KB Output is correct
40 Correct 80 ms 24808 KB Output is correct
41 Correct 244 ms 24932 KB Output is correct
42 Correct 179 ms 25020 KB Output is correct
43 Correct 462 ms 26120 KB Output is correct
44 Correct 184 ms 25024 KB Output is correct
45 Correct 110 ms 24876 KB Output is correct
46 Correct 69 ms 24860 KB Output is correct
47 Correct 68 ms 24892 KB Output is correct
48 Correct 65 ms 24816 KB Output is correct
49 Correct 81 ms 24892 KB Output is correct
50 Correct 154 ms 24920 KB Output is correct
51 Correct 80 ms 24912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 5048 ms 63864 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5007 ms 64240 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 14292 KB Output is correct
2 Correct 7 ms 14292 KB Output is correct
3 Correct 8 ms 14292 KB Output is correct
4 Correct 7 ms 14420 KB Output is correct
5 Correct 8 ms 14416 KB Output is correct
6 Correct 9 ms 14484 KB Output is correct
7 Correct 8 ms 14420 KB Output is correct
8 Correct 9 ms 14548 KB Output is correct
9 Correct 8 ms 14420 KB Output is correct
10 Correct 8 ms 14548 KB Output is correct
11 Correct 8 ms 14432 KB Output is correct
12 Correct 8 ms 14428 KB Output is correct
13 Correct 8 ms 14548 KB Output is correct
14 Correct 8 ms 14432 KB Output is correct
15 Correct 10 ms 14428 KB Output is correct
16 Correct 10 ms 14424 KB Output is correct
17 Correct 9 ms 14428 KB Output is correct
18 Correct 8 ms 14548 KB Output is correct
19 Correct 8 ms 14428 KB Output is correct
20 Correct 8 ms 14488 KB Output is correct
21 Correct 10 ms 14492 KB Output is correct
22 Correct 9 ms 14424 KB Output is correct
23 Correct 8 ms 14420 KB Output is correct
24 Correct 9 ms 14424 KB Output is correct
25 Correct 8 ms 14428 KB Output is correct
26 Correct 8 ms 14548 KB Output is correct
27 Correct 10 ms 14420 KB Output is correct
28 Correct 9 ms 14428 KB Output is correct
29 Correct 8 ms 14492 KB Output is correct
30 Correct 7 ms 14420 KB Output is correct
31 Correct 1766 ms 26676 KB Output is correct
32 Correct 87 ms 23616 KB Output is correct
33 Correct 161 ms 24860 KB Output is correct
34 Correct 1391 ms 25020 KB Output is correct
35 Correct 841 ms 26688 KB Output is correct
36 Correct 180 ms 26584 KB Output is correct
37 Correct 151 ms 24924 KB Output is correct
38 Correct 113 ms 24892 KB Output is correct
39 Correct 83 ms 24884 KB Output is correct
40 Correct 80 ms 24808 KB Output is correct
41 Correct 244 ms 24932 KB Output is correct
42 Correct 179 ms 25020 KB Output is correct
43 Correct 462 ms 26120 KB Output is correct
44 Correct 184 ms 25024 KB Output is correct
45 Correct 110 ms 24876 KB Output is correct
46 Correct 69 ms 24860 KB Output is correct
47 Correct 68 ms 24892 KB Output is correct
48 Correct 65 ms 24816 KB Output is correct
49 Correct 81 ms 24892 KB Output is correct
50 Correct 154 ms 24920 KB Output is correct
51 Correct 80 ms 24912 KB Output is correct
52 Correct 87 ms 26488 KB Output is correct
53 Correct 74 ms 25092 KB Output is correct
54 Correct 132 ms 26532 KB Output is correct
55 Execution timed out 5046 ms 25020 KB Time limit exceeded
56 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 14292 KB Output is correct
2 Correct 7 ms 14292 KB Output is correct
3 Correct 8 ms 14292 KB Output is correct
4 Correct 7 ms 14420 KB Output is correct
5 Correct 8 ms 14416 KB Output is correct
6 Correct 9 ms 14484 KB Output is correct
7 Correct 8 ms 14420 KB Output is correct
8 Correct 9 ms 14548 KB Output is correct
9 Correct 8 ms 14420 KB Output is correct
10 Correct 8 ms 14548 KB Output is correct
11 Correct 8 ms 14432 KB Output is correct
12 Correct 8 ms 14428 KB Output is correct
13 Correct 8 ms 14548 KB Output is correct
14 Correct 8 ms 14432 KB Output is correct
15 Correct 10 ms 14428 KB Output is correct
16 Correct 10 ms 14424 KB Output is correct
17 Correct 9 ms 14428 KB Output is correct
18 Correct 8 ms 14548 KB Output is correct
19 Correct 8 ms 14428 KB Output is correct
20 Correct 8 ms 14488 KB Output is correct
21 Correct 10 ms 14492 KB Output is correct
22 Correct 9 ms 14424 KB Output is correct
23 Correct 8 ms 14420 KB Output is correct
24 Correct 9 ms 14424 KB Output is correct
25 Correct 8 ms 14428 KB Output is correct
26 Correct 8 ms 14548 KB Output is correct
27 Correct 10 ms 14420 KB Output is correct
28 Correct 9 ms 14428 KB Output is correct
29 Correct 8 ms 14492 KB Output is correct
30 Correct 7 ms 14420 KB Output is correct
31 Correct 1766 ms 26676 KB Output is correct
32 Correct 87 ms 23616 KB Output is correct
33 Correct 161 ms 24860 KB Output is correct
34 Correct 1391 ms 25020 KB Output is correct
35 Correct 841 ms 26688 KB Output is correct
36 Correct 180 ms 26584 KB Output is correct
37 Correct 151 ms 24924 KB Output is correct
38 Correct 113 ms 24892 KB Output is correct
39 Correct 83 ms 24884 KB Output is correct
40 Correct 80 ms 24808 KB Output is correct
41 Correct 244 ms 24932 KB Output is correct
42 Correct 179 ms 25020 KB Output is correct
43 Correct 462 ms 26120 KB Output is correct
44 Correct 184 ms 25024 KB Output is correct
45 Correct 110 ms 24876 KB Output is correct
46 Correct 69 ms 24860 KB Output is correct
47 Correct 68 ms 24892 KB Output is correct
48 Correct 65 ms 24816 KB Output is correct
49 Correct 81 ms 24892 KB Output is correct
50 Correct 154 ms 24920 KB Output is correct
51 Correct 80 ms 24912 KB Output is correct
52 Execution timed out 5048 ms 63864 KB Time limit exceeded
53 Halted 0 ms 0 KB -