# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
26210 | 2017-06-28T11:09:15 Z | imsifile | Abduction 2 (JOI17_abduction2) | C++ | 4003 ms | 15932 KB |
#include<stdio.h> #include<algorithm> #include<map> using namespace std; int H, W, Q; int ho[50505], ver[50505]; map<pair<int,int>, int> vd, hd; int verti(int, int); int hori(int, int); int verti(int h, int v){ int gap = vd[make_pair(h,v)]; if(gap) return gap; int val = ver[v]; int i, up=0, down=0; for(i=h+1; i<H; i++){ up=i-h; if(ho[i]>val)break; } if(i<H) up += hori(v, i); for(i=h-1; i>=0; i--){ down=h-i; if(ho[i]>val)break; } if(i>=0) down += hori(v, i); return vd[make_pair(h,v)] = max(up, down); } int hori(int v, int h){ int gap = hd[make_pair(h,v)]; if(gap) return gap; int val = ho[h]; int i, up=0, down=0; for(i=v+1; i<W; i++){ up=i-v; if(ver[i]>val)break; } if(i<W) up += verti(h, i); for(i=v-1; i>=0; i--){ down=v-i; if(ver[i]>val)break; } if(i>=0) down += verti(h, i); return hd[make_pair(h,v)]=max(up, down); } int main(){ scanf("%d%d%d", &H, &W, &Q); for(int i=0; i<H; i++) scanf("%d", &ho[i]); for(int i=0; i<W; i++) scanf("%d", &ver[i]); while(Q--){ int h, v; scanf("%d%d", &h, &v), h--, v--; printf("%d\n", max(verti(h, v), hori(v, h))); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 1568 KB | Output is correct |
2 | Correct | 0 ms | 1568 KB | Output is correct |
3 | Correct | 0 ms | 1568 KB | Output is correct |
4 | Correct | 0 ms | 1568 KB | Output is correct |
5 | Correct | 0 ms | 1568 KB | Output is correct |
6 | Correct | 0 ms | 1568 KB | Output is correct |
7 | Correct | 0 ms | 1568 KB | Output is correct |
8 | Correct | 0 ms | 1568 KB | Output is correct |
9 | Correct | 0 ms | 1568 KB | Output is correct |
10 | Correct | 0 ms | 1568 KB | Output is correct |
11 | Correct | 0 ms | 1568 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 1568 KB | Output is correct |
2 | Correct | 0 ms | 1568 KB | Output is correct |
3 | Correct | 0 ms | 1568 KB | Output is correct |
4 | Correct | 0 ms | 1568 KB | Output is correct |
5 | Correct | 0 ms | 1568 KB | Output is correct |
6 | Correct | 0 ms | 1568 KB | Output is correct |
7 | Correct | 0 ms | 1568 KB | Output is correct |
8 | Correct | 0 ms | 1568 KB | Output is correct |
9 | Correct | 0 ms | 1568 KB | Output is correct |
10 | Correct | 0 ms | 1568 KB | Output is correct |
11 | Correct | 0 ms | 1568 KB | Output is correct |
12 | Correct | 0 ms | 1568 KB | Output is correct |
13 | Correct | 0 ms | 1568 KB | Output is correct |
14 | Correct | 0 ms | 1568 KB | Output is correct |
15 | Correct | 0 ms | 1568 KB | Output is correct |
16 | Correct | 0 ms | 1568 KB | Output is correct |
17 | Correct | 0 ms | 1568 KB | Output is correct |
18 | Correct | 0 ms | 1568 KB | Output is correct |
19 | Correct | 3 ms | 1700 KB | Output is correct |
20 | Correct | 6 ms | 1832 KB | Output is correct |
21 | Correct | 3 ms | 1832 KB | Output is correct |
22 | Correct | 6 ms | 1972 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 1568 KB | Output is correct |
2 | Correct | 0 ms | 1568 KB | Output is correct |
3 | Correct | 0 ms | 1568 KB | Output is correct |
4 | Correct | 0 ms | 1568 KB | Output is correct |
5 | Correct | 0 ms | 1568 KB | Output is correct |
6 | Correct | 0 ms | 1568 KB | Output is correct |
7 | Correct | 0 ms | 1568 KB | Output is correct |
8 | Correct | 0 ms | 1568 KB | Output is correct |
9 | Correct | 0 ms | 1568 KB | Output is correct |
10 | Correct | 0 ms | 1568 KB | Output is correct |
11 | Correct | 0 ms | 1568 KB | Output is correct |
12 | Correct | 0 ms | 1568 KB | Output is correct |
13 | Correct | 0 ms | 1568 KB | Output is correct |
14 | Correct | 0 ms | 1568 KB | Output is correct |
15 | Correct | 0 ms | 1568 KB | Output is correct |
16 | Correct | 0 ms | 1568 KB | Output is correct |
17 | Correct | 0 ms | 1568 KB | Output is correct |
18 | Correct | 0 ms | 1568 KB | Output is correct |
19 | Correct | 3 ms | 1700 KB | Output is correct |
20 | Correct | 6 ms | 1832 KB | Output is correct |
21 | Correct | 3 ms | 1832 KB | Output is correct |
22 | Correct | 6 ms | 1972 KB | Output is correct |
23 | Correct | 23 ms | 1568 KB | Output is correct |
24 | Correct | 16 ms | 1568 KB | Output is correct |
25 | Correct | 19 ms | 1568 KB | Output is correct |
26 | Correct | 16 ms | 1568 KB | Output is correct |
27 | Correct | 19 ms | 1568 KB | Output is correct |
28 | Correct | 889 ms | 6628 KB | Output is correct |
29 | Correct | 193 ms | 2144 KB | Output is correct |
30 | Correct | 2226 ms | 7688 KB | Output is correct |
31 | Correct | 2609 ms | 9576 KB | Output is correct |
32 | Correct | 183 ms | 1832 KB | Output is correct |
33 | Correct | 886 ms | 3432 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1700 KB | Output is correct |
2 | Correct | 3 ms | 1700 KB | Output is correct |
3 | Correct | 3 ms | 1700 KB | Output is correct |
4 | Correct | 3 ms | 1700 KB | Output is correct |
5 | Correct | 0 ms | 1700 KB | Output is correct |
6 | Correct | 0 ms | 1704 KB | Output is correct |
7 | Correct | 3 ms | 1700 KB | Output is correct |
8 | Correct | 6 ms | 1964 KB | Output is correct |
9 | Correct | 6 ms | 1964 KB | Output is correct |
10 | Correct | 6 ms | 1964 KB | Output is correct |
11 | Correct | 9 ms | 2096 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 1568 KB | Output is correct |
2 | Correct | 0 ms | 1568 KB | Output is correct |
3 | Correct | 0 ms | 1568 KB | Output is correct |
4 | Correct | 0 ms | 1568 KB | Output is correct |
5 | Correct | 0 ms | 1568 KB | Output is correct |
6 | Correct | 0 ms | 1568 KB | Output is correct |
7 | Correct | 0 ms | 1568 KB | Output is correct |
8 | Correct | 0 ms | 1568 KB | Output is correct |
9 | Correct | 0 ms | 1568 KB | Output is correct |
10 | Correct | 0 ms | 1568 KB | Output is correct |
11 | Correct | 0 ms | 1568 KB | Output is correct |
12 | Correct | 0 ms | 1568 KB | Output is correct |
13 | Correct | 0 ms | 1568 KB | Output is correct |
14 | Correct | 0 ms | 1568 KB | Output is correct |
15 | Correct | 0 ms | 1568 KB | Output is correct |
16 | Correct | 0 ms | 1568 KB | Output is correct |
17 | Correct | 0 ms | 1568 KB | Output is correct |
18 | Correct | 0 ms | 1568 KB | Output is correct |
19 | Correct | 3 ms | 1700 KB | Output is correct |
20 | Correct | 6 ms | 1832 KB | Output is correct |
21 | Correct | 3 ms | 1832 KB | Output is correct |
22 | Correct | 6 ms | 1972 KB | Output is correct |
23 | Correct | 23 ms | 1568 KB | Output is correct |
24 | Correct | 16 ms | 1568 KB | Output is correct |
25 | Correct | 19 ms | 1568 KB | Output is correct |
26 | Correct | 16 ms | 1568 KB | Output is correct |
27 | Correct | 19 ms | 1568 KB | Output is correct |
28 | Correct | 889 ms | 6628 KB | Output is correct |
29 | Correct | 193 ms | 2144 KB | Output is correct |
30 | Correct | 2226 ms | 7688 KB | Output is correct |
31 | Correct | 2609 ms | 9576 KB | Output is correct |
32 | Correct | 183 ms | 1832 KB | Output is correct |
33 | Correct | 886 ms | 3432 KB | Output is correct |
34 | Correct | 3 ms | 1700 KB | Output is correct |
35 | Correct | 3 ms | 1700 KB | Output is correct |
36 | Correct | 3 ms | 1700 KB | Output is correct |
37 | Correct | 3 ms | 1700 KB | Output is correct |
38 | Correct | 0 ms | 1700 KB | Output is correct |
39 | Correct | 0 ms | 1704 KB | Output is correct |
40 | Correct | 3 ms | 1700 KB | Output is correct |
41 | Correct | 6 ms | 1964 KB | Output is correct |
42 | Correct | 6 ms | 1964 KB | Output is correct |
43 | Correct | 6 ms | 1964 KB | Output is correct |
44 | Correct | 9 ms | 2096 KB | Output is correct |
45 | Correct | 33 ms | 1832 KB | Output is correct |
46 | Correct | 33 ms | 1832 KB | Output is correct |
47 | Correct | 36 ms | 1832 KB | Output is correct |
48 | Correct | 33 ms | 1832 KB | Output is correct |
49 | Correct | 33 ms | 1832 KB | Output is correct |
50 | Correct | 1012 ms | 5996 KB | Output is correct |
51 | Correct | 1036 ms | 6656 KB | Output is correct |
52 | Correct | 3086 ms | 11692 KB | Output is correct |
53 | Correct | 2916 ms | 11356 KB | Output is correct |
54 | Correct | 2829 ms | 10864 KB | Output is correct |
55 | Incorrect | 4003 ms | 15932 KB | Output isn't correct |
56 | Halted | 0 ms | 0 KB | - |