Submission #516791

# Submission time Handle Problem Language Result Execution time Memory
516791 2022-01-22T06:30:33 Z pragmatist New Home (APIO18_new_home) C++17
5 / 100
5000 ms 27888 KB
#include <bits/stdc++.h>                             

#define sz(v) v.size()                                
#define pb push_back
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define x first
#define y second
#define int long long
#define nl "\n"
 
using namespace std;

typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair <ll, ll> pii;

const int N = (int)3e5 + 7;
const int M = (int)15e6 + 7;
const ll MOD = (ll)1e9 + 7;                    
const int inf = (ll)1e9 + 7;
const ll INF = (ll)3e18 + 7;

pii dir[] = {{-1, 0}, {1, 0}, {0, 1}, {0, -1}};

int n, q, k, x[N], a[N], b[N], t[N];

vector<pair<int, pii> > g[N];

void solve() {                              
	cin >> n >> k >> q;
	for(int i = 1; i <= n; ++i) {
		cin >> x[i] >> t[i] >> a[i] >> b[i];
		g[t[i]].pb({x[i], {a[i], b[i]}});	
	}
	while(q--) {
		int l, x;
		cin >> l >> x;
		int ans = -1;
		for(int i = 1; i <= k; ++i) {
			int cur = inf;
			for(auto e : g[i]) {
				int p = e.x, L = e.y.x, R = e.y.y;
				if(x >= L && x <= R) cur = min(cur, abs(p - l));
			}
			ans = max(ans, cur);
		}
		cout << (ans == inf ? -1 : ans) << nl;
	}
}

signed main() {                   
	ios_base::sync_with_stdio(NULL);
    cin.tie(0);
    cout.tie(0);
    int test = 1;
	//cin >> test;
	for(int i = 1; i <= test; ++i) {
        //cout << "Case " << i << ": ";
        solve();
    }
    return 0;
}
/*
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
*/

/*
2 1 3
1 1 1 4
1 1 2 6
1 3
1 5
1 7
*/

/*
1 1 1
100000000 1 1 1 1
1 1
*/
# Verdict Execution time Memory Grader output
1 Correct 4 ms 7372 KB Output is correct
2 Correct 4 ms 7372 KB Output is correct
3 Correct 5 ms 7372 KB Output is correct
4 Correct 4 ms 7372 KB Output is correct
5 Correct 5 ms 7372 KB Output is correct
6 Correct 4 ms 7372 KB Output is correct
7 Correct 5 ms 7408 KB Output is correct
8 Correct 5 ms 7372 KB Output is correct
9 Correct 5 ms 7404 KB Output is correct
10 Correct 6 ms 7384 KB Output is correct
11 Correct 6 ms 7372 KB Output is correct
12 Correct 5 ms 7372 KB Output is correct
13 Correct 4 ms 7372 KB Output is correct
14 Correct 4 ms 7372 KB Output is correct
15 Correct 4 ms 7372 KB Output is correct
16 Correct 5 ms 7372 KB Output is correct
17 Correct 5 ms 7372 KB Output is correct
18 Correct 5 ms 7372 KB Output is correct
19 Correct 4 ms 7372 KB Output is correct
20 Correct 4 ms 7372 KB Output is correct
21 Correct 4 ms 7372 KB Output is correct
22 Correct 7 ms 7392 KB Output is correct
23 Correct 6 ms 7372 KB Output is correct
24 Correct 5 ms 7372 KB Output is correct
25 Correct 4 ms 7372 KB Output is correct
26 Correct 4 ms 7412 KB Output is correct
27 Correct 4 ms 7372 KB Output is correct
28 Correct 5 ms 7372 KB Output is correct
29 Correct 4 ms 7372 KB Output is correct
30 Correct 5 ms 7372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 7372 KB Output is correct
2 Correct 4 ms 7372 KB Output is correct
3 Correct 5 ms 7372 KB Output is correct
4 Correct 4 ms 7372 KB Output is correct
5 Correct 5 ms 7372 KB Output is correct
6 Correct 4 ms 7372 KB Output is correct
7 Correct 5 ms 7408 KB Output is correct
8 Correct 5 ms 7372 KB Output is correct
9 Correct 5 ms 7404 KB Output is correct
10 Correct 6 ms 7384 KB Output is correct
11 Correct 6 ms 7372 KB Output is correct
12 Correct 5 ms 7372 KB Output is correct
13 Correct 4 ms 7372 KB Output is correct
14 Correct 4 ms 7372 KB Output is correct
15 Correct 4 ms 7372 KB Output is correct
16 Correct 5 ms 7372 KB Output is correct
17 Correct 5 ms 7372 KB Output is correct
18 Correct 5 ms 7372 KB Output is correct
19 Correct 4 ms 7372 KB Output is correct
20 Correct 4 ms 7372 KB Output is correct
21 Correct 4 ms 7372 KB Output is correct
22 Correct 7 ms 7392 KB Output is correct
23 Correct 6 ms 7372 KB Output is correct
24 Correct 5 ms 7372 KB Output is correct
25 Correct 4 ms 7372 KB Output is correct
26 Correct 4 ms 7412 KB Output is correct
27 Correct 4 ms 7372 KB Output is correct
28 Correct 5 ms 7372 KB Output is correct
29 Correct 4 ms 7372 KB Output is correct
30 Correct 5 ms 7372 KB Output is correct
31 Execution timed out 5056 ms 12132 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5021 ms 27888 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5056 ms 26992 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 7372 KB Output is correct
2 Correct 4 ms 7372 KB Output is correct
3 Correct 5 ms 7372 KB Output is correct
4 Correct 4 ms 7372 KB Output is correct
5 Correct 5 ms 7372 KB Output is correct
6 Correct 4 ms 7372 KB Output is correct
7 Correct 5 ms 7408 KB Output is correct
8 Correct 5 ms 7372 KB Output is correct
9 Correct 5 ms 7404 KB Output is correct
10 Correct 6 ms 7384 KB Output is correct
11 Correct 6 ms 7372 KB Output is correct
12 Correct 5 ms 7372 KB Output is correct
13 Correct 4 ms 7372 KB Output is correct
14 Correct 4 ms 7372 KB Output is correct
15 Correct 4 ms 7372 KB Output is correct
16 Correct 5 ms 7372 KB Output is correct
17 Correct 5 ms 7372 KB Output is correct
18 Correct 5 ms 7372 KB Output is correct
19 Correct 4 ms 7372 KB Output is correct
20 Correct 4 ms 7372 KB Output is correct
21 Correct 4 ms 7372 KB Output is correct
22 Correct 7 ms 7392 KB Output is correct
23 Correct 6 ms 7372 KB Output is correct
24 Correct 5 ms 7372 KB Output is correct
25 Correct 4 ms 7372 KB Output is correct
26 Correct 4 ms 7412 KB Output is correct
27 Correct 4 ms 7372 KB Output is correct
28 Correct 5 ms 7372 KB Output is correct
29 Correct 4 ms 7372 KB Output is correct
30 Correct 5 ms 7372 KB Output is correct
31 Execution timed out 5056 ms 12132 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 7372 KB Output is correct
2 Correct 4 ms 7372 KB Output is correct
3 Correct 5 ms 7372 KB Output is correct
4 Correct 4 ms 7372 KB Output is correct
5 Correct 5 ms 7372 KB Output is correct
6 Correct 4 ms 7372 KB Output is correct
7 Correct 5 ms 7408 KB Output is correct
8 Correct 5 ms 7372 KB Output is correct
9 Correct 5 ms 7404 KB Output is correct
10 Correct 6 ms 7384 KB Output is correct
11 Correct 6 ms 7372 KB Output is correct
12 Correct 5 ms 7372 KB Output is correct
13 Correct 4 ms 7372 KB Output is correct
14 Correct 4 ms 7372 KB Output is correct
15 Correct 4 ms 7372 KB Output is correct
16 Correct 5 ms 7372 KB Output is correct
17 Correct 5 ms 7372 KB Output is correct
18 Correct 5 ms 7372 KB Output is correct
19 Correct 4 ms 7372 KB Output is correct
20 Correct 4 ms 7372 KB Output is correct
21 Correct 4 ms 7372 KB Output is correct
22 Correct 7 ms 7392 KB Output is correct
23 Correct 6 ms 7372 KB Output is correct
24 Correct 5 ms 7372 KB Output is correct
25 Correct 4 ms 7372 KB Output is correct
26 Correct 4 ms 7412 KB Output is correct
27 Correct 4 ms 7372 KB Output is correct
28 Correct 5 ms 7372 KB Output is correct
29 Correct 4 ms 7372 KB Output is correct
30 Correct 5 ms 7372 KB Output is correct
31 Execution timed out 5056 ms 12132 KB Time limit exceeded
32 Halted 0 ms 0 KB -