Submission #59226

# Submission time Handle Problem Language Result Execution time Memory
59226 2018-07-21T09:17:40 Z Just_Solve_The_Problem New Home (APIO18_new_home) C++11
5 / 100
5000 ms 24780 KB
#include <bits/stdc++.h>

using namespace std;

const int N = (int)3e5 + 7;

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

main() {
	scanf("%d %d %d", &n, &k, &q);
	for (int i = 1; i <= n; i++) {
		scanf("%d %d %d %d", &x[i], &t[i], &a[i], &b[i]);		
	}
	while (q--) {
		int l, y;
		scanf("%d %d", &l, &y);
		memset(mn, 63, sizeof mn);
		for (int i = 1; i <= n; i++) {
			if (a[i] <= y && y <= b[i]) {
				mn[t[i]] = min(mn[t[i]], abs(l - x[i]));
			}
		}
		int ans = -1;
		for (int i = 1; i <= k; i++) {
			if (mn[i] == mn[0]) {
				ans = -1;
				break;
			}
			if (ans == -1 || ans < mn[i]) {
				ans = mn[i];
			}
		}
		printf("%d\n", ans);
	}
}

Compilation message

new_home.cpp:11:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
new_home.cpp: In function 'int main()':
new_home.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d", &n, &k, &q);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
new_home.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d %d", &x[i], &t[i], &a[i], &b[i]);  
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
new_home.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &l, &y);
   ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 480 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 3 ms 596 KB Output is correct
6 Correct 5 ms 816 KB Output is correct
7 Correct 4 ms 856 KB Output is correct
8 Correct 3 ms 856 KB Output is correct
9 Correct 3 ms 856 KB Output is correct
10 Correct 4 ms 856 KB Output is correct
11 Correct 3 ms 856 KB Output is correct
12 Correct 3 ms 860 KB Output is correct
13 Correct 3 ms 940 KB Output is correct
14 Correct 3 ms 940 KB Output is correct
15 Correct 3 ms 1028 KB Output is correct
16 Correct 3 ms 1028 KB Output is correct
17 Correct 3 ms 1036 KB Output is correct
18 Correct 4 ms 1044 KB Output is correct
19 Correct 4 ms 1064 KB Output is correct
20 Correct 3 ms 1084 KB Output is correct
21 Correct 3 ms 1104 KB Output is correct
22 Correct 3 ms 1120 KB Output is correct
23 Correct 3 ms 1140 KB Output is correct
24 Correct 4 ms 1160 KB Output is correct
25 Correct 5 ms 1160 KB Output is correct
26 Correct 3 ms 1160 KB Output is correct
27 Correct 4 ms 1220 KB Output is correct
28 Correct 4 ms 1228 KB Output is correct
29 Correct 4 ms 1252 KB Output is correct
30 Correct 3 ms 1272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 480 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 3 ms 596 KB Output is correct
6 Correct 5 ms 816 KB Output is correct
7 Correct 4 ms 856 KB Output is correct
8 Correct 3 ms 856 KB Output is correct
9 Correct 3 ms 856 KB Output is correct
10 Correct 4 ms 856 KB Output is correct
11 Correct 3 ms 856 KB Output is correct
12 Correct 3 ms 860 KB Output is correct
13 Correct 3 ms 940 KB Output is correct
14 Correct 3 ms 940 KB Output is correct
15 Correct 3 ms 1028 KB Output is correct
16 Correct 3 ms 1028 KB Output is correct
17 Correct 3 ms 1036 KB Output is correct
18 Correct 4 ms 1044 KB Output is correct
19 Correct 4 ms 1064 KB Output is correct
20 Correct 3 ms 1084 KB Output is correct
21 Correct 3 ms 1104 KB Output is correct
22 Correct 3 ms 1120 KB Output is correct
23 Correct 3 ms 1140 KB Output is correct
24 Correct 4 ms 1160 KB Output is correct
25 Correct 5 ms 1160 KB Output is correct
26 Correct 3 ms 1160 KB Output is correct
27 Correct 4 ms 1220 KB Output is correct
28 Correct 4 ms 1228 KB Output is correct
29 Correct 4 ms 1252 KB Output is correct
30 Correct 3 ms 1272 KB Output is correct
31 Execution timed out 5081 ms 5068 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5009 ms 17032 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5047 ms 24780 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 480 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 3 ms 596 KB Output is correct
6 Correct 5 ms 816 KB Output is correct
7 Correct 4 ms 856 KB Output is correct
8 Correct 3 ms 856 KB Output is correct
9 Correct 3 ms 856 KB Output is correct
10 Correct 4 ms 856 KB Output is correct
11 Correct 3 ms 856 KB Output is correct
12 Correct 3 ms 860 KB Output is correct
13 Correct 3 ms 940 KB Output is correct
14 Correct 3 ms 940 KB Output is correct
15 Correct 3 ms 1028 KB Output is correct
16 Correct 3 ms 1028 KB Output is correct
17 Correct 3 ms 1036 KB Output is correct
18 Correct 4 ms 1044 KB Output is correct
19 Correct 4 ms 1064 KB Output is correct
20 Correct 3 ms 1084 KB Output is correct
21 Correct 3 ms 1104 KB Output is correct
22 Correct 3 ms 1120 KB Output is correct
23 Correct 3 ms 1140 KB Output is correct
24 Correct 4 ms 1160 KB Output is correct
25 Correct 5 ms 1160 KB Output is correct
26 Correct 3 ms 1160 KB Output is correct
27 Correct 4 ms 1220 KB Output is correct
28 Correct 4 ms 1228 KB Output is correct
29 Correct 4 ms 1252 KB Output is correct
30 Correct 3 ms 1272 KB Output is correct
31 Execution timed out 5081 ms 5068 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 480 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 3 ms 596 KB Output is correct
6 Correct 5 ms 816 KB Output is correct
7 Correct 4 ms 856 KB Output is correct
8 Correct 3 ms 856 KB Output is correct
9 Correct 3 ms 856 KB Output is correct
10 Correct 4 ms 856 KB Output is correct
11 Correct 3 ms 856 KB Output is correct
12 Correct 3 ms 860 KB Output is correct
13 Correct 3 ms 940 KB Output is correct
14 Correct 3 ms 940 KB Output is correct
15 Correct 3 ms 1028 KB Output is correct
16 Correct 3 ms 1028 KB Output is correct
17 Correct 3 ms 1036 KB Output is correct
18 Correct 4 ms 1044 KB Output is correct
19 Correct 4 ms 1064 KB Output is correct
20 Correct 3 ms 1084 KB Output is correct
21 Correct 3 ms 1104 KB Output is correct
22 Correct 3 ms 1120 KB Output is correct
23 Correct 3 ms 1140 KB Output is correct
24 Correct 4 ms 1160 KB Output is correct
25 Correct 5 ms 1160 KB Output is correct
26 Correct 3 ms 1160 KB Output is correct
27 Correct 4 ms 1220 KB Output is correct
28 Correct 4 ms 1228 KB Output is correct
29 Correct 4 ms 1252 KB Output is correct
30 Correct 3 ms 1272 KB Output is correct
31 Execution timed out 5081 ms 5068 KB Time limit exceeded
32 Halted 0 ms 0 KB -