Submission #698641

# Submission time Handle Problem Language Result Execution time Memory
698641 2023-02-14T06:32:24 Z vjudge1 New Home (APIO18_new_home) C++17
5 / 100
5000 ms 18668 KB
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
 
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
 
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
 
 
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <fstream>
#define int long long
#define endl '\n'
#define mod 1000000007;
using namespace std;

int seg[1000001][2];
int fin[1000001];
int N,Left,Right,T;

void Update(int Pos, int Val, int Type){
    int ind = N + Pos - 1 ;
    if(Type) {
        seg[ind][Type] = min(seg[ind][Type], Val);
        cout << seg[ind][Type] << endl;
        while(ind /= 2) seg[ind][Type] = min(seg[ind * 2][Type], seg[ind * 2 + 1][Type]);
    }
    else {
        seg[ind][Type] = max(seg[ind][Type], Val);
        while(ind /= 2) seg[ind][Type] = max(seg[ind * 2][Type], seg[ind * 2 + 1][Type]);
    }
}



int Query(int l = 1, int r = N, int ind = 1){
    if(l > Right or r < Left){
        if(T) return 1e18;
        else return -1;
    }
    if(l >= Left && r <= Right) return seg[ind][T];
    int mid = (l + r) / 2;
    if(T) return min(Query(l, mid, ind * 2), Query(mid + 1, r, ind * 2 + 1));
    else return max(Query(l, mid, ind * 2), Query(mid + 1, r, ind * 2 + 1));
}
using namespace std;
signed main() {
    int n,k,q; cin >> n >> k >> q;
    vector<pair<pair<int,int>,pair<int,int>>>x(n);
    vector<pair<int,pair<int,int>>>y;
    
    
    int cnt = 0;
    set<int>u;
    map<int,int>o;
    for(int i = 0; i < n; i++){
        cin >> x[i].first.first >> x[i].first.second >> x[i].second.first >> x[i].second.second;
        u.insert(x[i].first.second);
    }
    for(auto s: u) o[s] = cnt++;
    
    for(int i = 0; i < q; i++){
        int a,b; cin >> a >> b;
        vector<int>y(n, 1e18);
        int ans = -1;
        for(int j = 0; j < n; j++){
            if(b >= x[j].second.first && b <= x[j].second.second){
                int tt = o[x[j].first.second];
                if(abs(a - x[j].first.first) < abs(y[tt] - a)) y[tt] = x[j].first.first;
            }
        }
        int cnt = 0;
        for(int j = 0; j < n; j++){
            if(y[j] == 1e18) {
                y[j] = a;
                continue;
            }
            ans = max(ans, abs(a - y[j]));
            cnt++;
        }
        if(cnt < k) ans = -1;
        cout << ans << endl;
    }
    /*for(int i = 0; i < n; i++){
        int a,b,c,d; cin >> a >> b >> c >> d;
        x.push_back({{c, a}, {b, -1}});
        x.push_back({{d, a}, {b, 1}});
    }
    for(int i = 0; i < q; i++){
        int a,b; cin >> a >> b;
        y.push_back({b, {a, i}});
        vector<pair<int,int>>d;
        for(int j = 0; j < n; j++){
            if(a >= x[j].first.second
        }
    }*/
    
    /*sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    vector<set<int>>d(k);
    set<pair<int,int>>u;
    
    int j = 0, i = 0;
    while(i < q){
        while(j < n && x[j].first.first <= y[j].first){
            if(x[j].second.second < 0){ // add
                d[k].insert({x[j].first.second});
            }
            j++;
        }
       
    }
    for(int i = 0; i < q; i++) cout << fin[i] << endl;*/
    
    
    return 0;
    
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 4 ms 212 KB Output is correct
6 Correct 3 ms 212 KB Output is correct
7 Correct 5 ms 340 KB Output is correct
8 Correct 6 ms 340 KB Output is correct
9 Correct 6 ms 340 KB Output is correct
10 Correct 4 ms 212 KB Output is correct
11 Correct 3 ms 212 KB Output is correct
12 Correct 2 ms 212 KB Output is correct
13 Correct 3 ms 212 KB Output is correct
14 Correct 2 ms 212 KB Output is correct
15 Correct 3 ms 340 KB Output is correct
16 Correct 5 ms 340 KB Output is correct
17 Correct 4 ms 212 KB Output is correct
18 Correct 3 ms 340 KB Output is correct
19 Correct 4 ms 340 KB Output is correct
20 Correct 3 ms 340 KB Output is correct
21 Correct 5 ms 340 KB Output is correct
22 Correct 5 ms 300 KB Output is correct
23 Correct 5 ms 340 KB Output is correct
24 Correct 5 ms 340 KB Output is correct
25 Correct 3 ms 212 KB Output is correct
26 Correct 2 ms 212 KB Output is correct
27 Correct 2 ms 212 KB Output is correct
28 Correct 2 ms 212 KB Output is correct
29 Correct 2 ms 212 KB Output is correct
30 Correct 2 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 4 ms 212 KB Output is correct
6 Correct 3 ms 212 KB Output is correct
7 Correct 5 ms 340 KB Output is correct
8 Correct 6 ms 340 KB Output is correct
9 Correct 6 ms 340 KB Output is correct
10 Correct 4 ms 212 KB Output is correct
11 Correct 3 ms 212 KB Output is correct
12 Correct 2 ms 212 KB Output is correct
13 Correct 3 ms 212 KB Output is correct
14 Correct 2 ms 212 KB Output is correct
15 Correct 3 ms 340 KB Output is correct
16 Correct 5 ms 340 KB Output is correct
17 Correct 4 ms 212 KB Output is correct
18 Correct 3 ms 340 KB Output is correct
19 Correct 4 ms 340 KB Output is correct
20 Correct 3 ms 340 KB Output is correct
21 Correct 5 ms 340 KB Output is correct
22 Correct 5 ms 300 KB Output is correct
23 Correct 5 ms 340 KB Output is correct
24 Correct 5 ms 340 KB Output is correct
25 Correct 3 ms 212 KB Output is correct
26 Correct 2 ms 212 KB Output is correct
27 Correct 2 ms 212 KB Output is correct
28 Correct 2 ms 212 KB Output is correct
29 Correct 2 ms 212 KB Output is correct
30 Correct 2 ms 212 KB Output is correct
31 Execution timed out 5046 ms 2832 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5037 ms 18668 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5089 ms 12748 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 4 ms 212 KB Output is correct
6 Correct 3 ms 212 KB Output is correct
7 Correct 5 ms 340 KB Output is correct
8 Correct 6 ms 340 KB Output is correct
9 Correct 6 ms 340 KB Output is correct
10 Correct 4 ms 212 KB Output is correct
11 Correct 3 ms 212 KB Output is correct
12 Correct 2 ms 212 KB Output is correct
13 Correct 3 ms 212 KB Output is correct
14 Correct 2 ms 212 KB Output is correct
15 Correct 3 ms 340 KB Output is correct
16 Correct 5 ms 340 KB Output is correct
17 Correct 4 ms 212 KB Output is correct
18 Correct 3 ms 340 KB Output is correct
19 Correct 4 ms 340 KB Output is correct
20 Correct 3 ms 340 KB Output is correct
21 Correct 5 ms 340 KB Output is correct
22 Correct 5 ms 300 KB Output is correct
23 Correct 5 ms 340 KB Output is correct
24 Correct 5 ms 340 KB Output is correct
25 Correct 3 ms 212 KB Output is correct
26 Correct 2 ms 212 KB Output is correct
27 Correct 2 ms 212 KB Output is correct
28 Correct 2 ms 212 KB Output is correct
29 Correct 2 ms 212 KB Output is correct
30 Correct 2 ms 212 KB Output is correct
31 Execution timed out 5046 ms 2832 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 4 ms 212 KB Output is correct
6 Correct 3 ms 212 KB Output is correct
7 Correct 5 ms 340 KB Output is correct
8 Correct 6 ms 340 KB Output is correct
9 Correct 6 ms 340 KB Output is correct
10 Correct 4 ms 212 KB Output is correct
11 Correct 3 ms 212 KB Output is correct
12 Correct 2 ms 212 KB Output is correct
13 Correct 3 ms 212 KB Output is correct
14 Correct 2 ms 212 KB Output is correct
15 Correct 3 ms 340 KB Output is correct
16 Correct 5 ms 340 KB Output is correct
17 Correct 4 ms 212 KB Output is correct
18 Correct 3 ms 340 KB Output is correct
19 Correct 4 ms 340 KB Output is correct
20 Correct 3 ms 340 KB Output is correct
21 Correct 5 ms 340 KB Output is correct
22 Correct 5 ms 300 KB Output is correct
23 Correct 5 ms 340 KB Output is correct
24 Correct 5 ms 340 KB Output is correct
25 Correct 3 ms 212 KB Output is correct
26 Correct 2 ms 212 KB Output is correct
27 Correct 2 ms 212 KB Output is correct
28 Correct 2 ms 212 KB Output is correct
29 Correct 2 ms 212 KB Output is correct
30 Correct 2 ms 212 KB Output is correct
31 Execution timed out 5046 ms 2832 KB Time limit exceeded
32 Halted 0 ms 0 KB -