Submission #48850

# Submission time Handle Problem Language Result Execution time Memory
48850 2018-05-19T10:27:57 Z model_code New Home (APIO18_new_home) C++17
5 / 100
5000 ms 15120 KB
#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1.01e9;

void print(vector<int> v) {
    for (int x : v) printf("%d\n", x);
}

struct Shop {
    int x, type, a, b;
};

struct Query {
    int x, time;
};

vector<int> slow(vector<Shop> a, int k, vector<Query> b) {
    vector<int> ans;
    for (auto o : b) {
        vector<int> d(k, INF);
        for (auto s : a) {
            if (s.a <= o.time && o.time <= s.b) {
                d[s.type] = min(d[s.type], abs(s.x - o.x));
            }
        }
        int cans = *max_element(d.begin(), d.end());
        if (cans == INF) cans = -1;
        ans.push_back(cans);
    }
    return ans;
}

int main() {
    int n, k, q;
    scanf("%d%d%d", &n, &k, &q);
    vector<Shop> a(n);
    for (int i = 0; i < n; i++) {
        scanf("%d%d%d%d", &a[i].x, &a[i].type, &a[i].a, &a[i].b);
        a[i].type--;
    }
    vector<Query> b(q);
    for (int i = 0; i < q; i++) scanf("%d%d", &b[i].x, &b[i].time);

    print(slow(a, k, b));
}

Compilation message

new_home.cpp: In function 'int main()':
new_home.cpp:35:10: 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:38:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d%d", &a[i].x, &a[i].type, &a[i].a, &a[i].b);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
new_home.cpp:42:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (int i = 0; i < q; i++) scanf("%d%d", &b[i].x, &b[i].time);
                                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 476 KB Output is correct
3 Correct 2 ms 476 KB Output is correct
4 Correct 2 ms 476 KB Output is correct
5 Correct 3 ms 520 KB Output is correct
6 Correct 3 ms 520 KB Output is correct
7 Correct 4 ms 544 KB Output is correct
8 Correct 3 ms 616 KB Output is correct
9 Correct 4 ms 616 KB Output is correct
10 Correct 3 ms 744 KB Output is correct
11 Correct 3 ms 744 KB Output is correct
12 Correct 3 ms 744 KB Output is correct
13 Correct 3 ms 744 KB Output is correct
14 Correct 3 ms 744 KB Output is correct
15 Correct 4 ms 744 KB Output is correct
16 Correct 3 ms 744 KB Output is correct
17 Correct 3 ms 744 KB Output is correct
18 Correct 3 ms 744 KB Output is correct
19 Correct 3 ms 744 KB Output is correct
20 Correct 3 ms 744 KB Output is correct
21 Correct 3 ms 744 KB Output is correct
22 Correct 3 ms 744 KB Output is correct
23 Correct 3 ms 744 KB Output is correct
24 Correct 3 ms 744 KB Output is correct
25 Correct 4 ms 744 KB Output is correct
26 Correct 3 ms 744 KB Output is correct
27 Correct 3 ms 744 KB Output is correct
28 Correct 3 ms 744 KB Output is correct
29 Correct 3 ms 744 KB Output is correct
30 Correct 4 ms 744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 476 KB Output is correct
3 Correct 2 ms 476 KB Output is correct
4 Correct 2 ms 476 KB Output is correct
5 Correct 3 ms 520 KB Output is correct
6 Correct 3 ms 520 KB Output is correct
7 Correct 4 ms 544 KB Output is correct
8 Correct 3 ms 616 KB Output is correct
9 Correct 4 ms 616 KB Output is correct
10 Correct 3 ms 744 KB Output is correct
11 Correct 3 ms 744 KB Output is correct
12 Correct 3 ms 744 KB Output is correct
13 Correct 3 ms 744 KB Output is correct
14 Correct 3 ms 744 KB Output is correct
15 Correct 4 ms 744 KB Output is correct
16 Correct 3 ms 744 KB Output is correct
17 Correct 3 ms 744 KB Output is correct
18 Correct 3 ms 744 KB Output is correct
19 Correct 3 ms 744 KB Output is correct
20 Correct 3 ms 744 KB Output is correct
21 Correct 3 ms 744 KB Output is correct
22 Correct 3 ms 744 KB Output is correct
23 Correct 3 ms 744 KB Output is correct
24 Correct 3 ms 744 KB Output is correct
25 Correct 4 ms 744 KB Output is correct
26 Correct 3 ms 744 KB Output is correct
27 Correct 3 ms 744 KB Output is correct
28 Correct 3 ms 744 KB Output is correct
29 Correct 3 ms 744 KB Output is correct
30 Correct 4 ms 744 KB Output is correct
31 Execution timed out 5013 ms 3880 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5050 ms 15120 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5027 ms 15120 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 476 KB Output is correct
3 Correct 2 ms 476 KB Output is correct
4 Correct 2 ms 476 KB Output is correct
5 Correct 3 ms 520 KB Output is correct
6 Correct 3 ms 520 KB Output is correct
7 Correct 4 ms 544 KB Output is correct
8 Correct 3 ms 616 KB Output is correct
9 Correct 4 ms 616 KB Output is correct
10 Correct 3 ms 744 KB Output is correct
11 Correct 3 ms 744 KB Output is correct
12 Correct 3 ms 744 KB Output is correct
13 Correct 3 ms 744 KB Output is correct
14 Correct 3 ms 744 KB Output is correct
15 Correct 4 ms 744 KB Output is correct
16 Correct 3 ms 744 KB Output is correct
17 Correct 3 ms 744 KB Output is correct
18 Correct 3 ms 744 KB Output is correct
19 Correct 3 ms 744 KB Output is correct
20 Correct 3 ms 744 KB Output is correct
21 Correct 3 ms 744 KB Output is correct
22 Correct 3 ms 744 KB Output is correct
23 Correct 3 ms 744 KB Output is correct
24 Correct 3 ms 744 KB Output is correct
25 Correct 4 ms 744 KB Output is correct
26 Correct 3 ms 744 KB Output is correct
27 Correct 3 ms 744 KB Output is correct
28 Correct 3 ms 744 KB Output is correct
29 Correct 3 ms 744 KB Output is correct
30 Correct 4 ms 744 KB Output is correct
31 Execution timed out 5013 ms 3880 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 476 KB Output is correct
3 Correct 2 ms 476 KB Output is correct
4 Correct 2 ms 476 KB Output is correct
5 Correct 3 ms 520 KB Output is correct
6 Correct 3 ms 520 KB Output is correct
7 Correct 4 ms 544 KB Output is correct
8 Correct 3 ms 616 KB Output is correct
9 Correct 4 ms 616 KB Output is correct
10 Correct 3 ms 744 KB Output is correct
11 Correct 3 ms 744 KB Output is correct
12 Correct 3 ms 744 KB Output is correct
13 Correct 3 ms 744 KB Output is correct
14 Correct 3 ms 744 KB Output is correct
15 Correct 4 ms 744 KB Output is correct
16 Correct 3 ms 744 KB Output is correct
17 Correct 3 ms 744 KB Output is correct
18 Correct 3 ms 744 KB Output is correct
19 Correct 3 ms 744 KB Output is correct
20 Correct 3 ms 744 KB Output is correct
21 Correct 3 ms 744 KB Output is correct
22 Correct 3 ms 744 KB Output is correct
23 Correct 3 ms 744 KB Output is correct
24 Correct 3 ms 744 KB Output is correct
25 Correct 4 ms 744 KB Output is correct
26 Correct 3 ms 744 KB Output is correct
27 Correct 3 ms 744 KB Output is correct
28 Correct 3 ms 744 KB Output is correct
29 Correct 3 ms 744 KB Output is correct
30 Correct 4 ms 744 KB Output is correct
31 Execution timed out 5013 ms 3880 KB Time limit exceeded
32 Halted 0 ms 0 KB -