Task: | Manhattan Mornings |
Sender: | KnowYourArchitecture |
Submission time: | 2017-10-24 20:23:32 +0300 |
Language: | C++ |
Status: | READY |
Result: | WRONG ANSWER |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.08 s | details |
#2 | ACCEPTED | 0.04 s | details |
#3 | WRONG ANSWER | 0.05 s | details |
#4 | WRONG ANSWER | 0.05 s | details |
#5 | ACCEPTED | 0.05 s | details |
#6 | ACCEPTED | 0.04 s | details |
#7 | WRONG ANSWER | 0.03 s | details |
#8 | ACCEPTED | 0.04 s | details |
#9 | WRONG ANSWER | 0.04 s | details |
#10 | WRONG ANSWER | 0.03 s | details |
#11 | ACCEPTED | 0.05 s | details |
#12 | WRONG ANSWER | 0.04 s | details |
#13 | WRONG ANSWER | 0.04 s | details |
#14 | WRONG ANSWER | 0.04 s | details |
#15 | ACCEPTED | 0.04 s | details |
#16 | ACCEPTED | 0.05 s | details |
#17 | ACCEPTED | 0.04 s | details |
#18 | ACCEPTED | 0.05 s | details |
#19 | ACCEPTED | 0.29 s | details |
#20 | ACCEPTED | 0.05 s | details |
#21 | WRONG ANSWER | 0.26 s | details |
#22 | WRONG ANSWER | 0.26 s | details |
#23 | WRONG ANSWER | 0.27 s | details |
#24 | WRONG ANSWER | 0.28 s | details |
#25 | WRONG ANSWER | 0.29 s | details |
#26 | ACCEPTED | 0.05 s | details |
#27 | ACCEPTED | 0.04 s | details |
#28 | WRONG ANSWER | 0.43 s | details |
#29 | WRONG ANSWER | 0.42 s | details |
#30 | WRONG ANSWER | 0.31 s | details |
#31 | WRONG ANSWER | 0.25 s | details |
#32 | ACCEPTED | 0.04 s | details |
#33 | WRONG ANSWER | 0.05 s | details |
#34 | WRONG ANSWER | 0.28 s | details |
#35 | WRONG ANSWER | 0.29 s | details |
#36 | WRONG ANSWER | 0.27 s | details |
#37 | WRONG ANSWER | 0.37 s | details |
#38 | WRONG ANSWER | 0.36 s | details |
#39 | WRONG ANSWER | 0.28 s | details |
#40 | WRONG ANSWER | 0.28 s | details |
#41 | WRONG ANSWER | 0.29 s | details |
#42 | WRONG ANSWER | 0.27 s | details |
#43 | WRONG ANSWER | 0.33 s | details |
Code
#include <bits/stdc++.h> #define ll long long using namespace std; typedef long double ld; //typedef pair<ll, ll> P; struct P { ll first, second; int i; }; bool operator<(const P &a, const P &b) { return tie(a.first, a.second, a.i) < tie(b.first, b.second, b.i); } bool ysort(const P &a, const P &b) { if (a.second != b.second) return a.second < b.second; return a.first < b.first; } int main() { int n; cin >> n; ll x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; vector<P> xdir, ydir; for (int i = 0; i < n; i++) { ll x, y; cin >> x >> y; xdir.push_back(P{x, y, i}); ydir.push_back(P{x, y, i}); } if (x1 > x2) { for (int i = 0; i < n; i++) { xdir[i].first *= -1; ydir[i].first *= -1; } x1 *= -1; x2 *= -1; } if (y1 > y2) { for (int i = 0; i < n; i++) { xdir[i].second *= -1; ydir[i].second *= -1; } y1 *= -1; y2 *= -1; } sort(xdir.begin(), xdir.end()); sort(ydir.begin(), ydir.end(), ysort); map<P, int> xi; map<P, int> yi; for (int i = 0; i < n; i++) xi[xdir[i]] = i; for (int i = 0; i < n; i++) yi[ydir[i]] = i; map<P, int> dyn; //cerr<<"p1 "<<x1<<" "<<y1<<endl; //cerr<<"p2 "<<x2<<" "<<y2<<endl; for (int i = 0; i < n; i++) { P cur = xdir[i]; //cerr << "at " << cur.first << " "<<cur.second<<endl; if (cur.first < x1) continue; if (cur.second < y1) continue; int xj = xi[cur]; int yj = yi[cur]; int res = 1; if (i > 0) { if (xdir[xj-1].second <= cur.second) { res = max(res, 1+dyn[xdir[xj-1]]); } } if (yj > 0) { if (ydir[yj-1].first <= cur.first) { res = max(res, 1+dyn[ydir[yj-1]]); } } dyn[cur] = res; } //for (auto f : dyn) //cerr << f.first.first << ", " << f.first.second << ": " << f.second << endl; int best = 0; for (int i = 0; i < n; i++) { P cur = xdir[i]; if (cur.first > x2) continue; if (cur.second > y2) continue; best = max(best, dyn[cur]); } cout << best << endl; return 0; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
10001 100 10100 10100 100 100 100 101 101 102 102 ... |
correct output |
---|
1 |
user output |
---|
1 |
Test 2
Verdict: ACCEPTED
input |
---|
51 100 80 50 130 50 80 51 81 52 82 ... |
correct output |
---|
1 |
user output |
---|
1 |
Test 3
Verdict: WRONG ANSWER
input |
---|
100 100 100 200 200 151 190 102 196 120 198 ... |
correct output |
---|
15 |
user output |
---|
11 |
Test 4
Verdict: WRONG ANSWER
input |
---|
100 100 100 200 200 107 116 106 198 110 110 ... |
correct output |
---|
17 |
user output |
---|
13 |
Test 5
Verdict: ACCEPTED
input |
---|
10001 100 100 10100 10100 100 100 101 101 102 102 ... |
correct output |
---|
10001 |
user output |
---|
10001 |
Test 6
Verdict: ACCEPTED
input |
---|
51 0 80 50 130 0 80 1 81 2 82 ... |
correct output |
---|
51 |
user output |
---|
51 |
Test 7
Verdict: WRONG ANSWER
input |
---|
50 10 10 20 10 21 9 13 9 15 11 ... |
correct output |
---|
16 |
user output |
---|
14 |
Test 8
Verdict: ACCEPTED
input |
---|
50 10 10 10 20 11 13 10 16 11 12 ... |
correct output |
---|
18 |
user output |
---|
18 |
Test 9
Verdict: WRONG ANSWER
input |
---|
1000 20 20 60 60 59 42 34 21 35 41 ... |
correct output |
---|
72 |
user output |
---|
62 |
Test 10
Verdict: WRONG ANSWER
input |
---|
1000 60 20 20 60 59 42 34 21 35 41 ... |
correct output |
---|
70 |
user output |
---|
62 |
Test 11
Verdict: ACCEPTED
input |
---|
50 10 20 10 10 11 13 10 16 11 12 ... |
correct output |
---|
18 |
user output |
---|
18 |
Test 12
Verdict: WRONG ANSWER
input |
---|
1000 20 60 60 20 59 42 34 21 35 41 ... |
correct output |
---|
70 |
user output |
---|
60 |
Test 13
Verdict: WRONG ANSWER
input |
---|
1000 60 60 20 20 59 42 34 21 35 41 ... |
correct output |
---|
72 |
user output |
---|
60 |
Test 14
Verdict: WRONG ANSWER
input |
---|
50 20 10 10 10 21 9 13 9 15 11 ... |
correct output |
---|
16 |
user output |
---|
7 |
Test 15
Verdict: ACCEPTED
input |
---|
100 100 100 200 200 92 116 99 198 95 110 ... |
correct output |
---|
0 |
user output |
---|
0 |
Test 16
Verdict: ACCEPTED
input |
---|
100 100 100 200 200 203 116 210 198 206 110 ... |
correct output |
---|
0 |
user output |
---|
0 |
Test 17
Verdict: ACCEPTED
input |
---|
100 100 100 200 200 151 90 102 91 120 98 ... |
correct output |
---|
0 |
user output |
---|
0 |
Test 18
Verdict: ACCEPTED
input |
---|
100 100 100 200 200 151 201 102 202 120 209 ... |
correct output |
---|
0 |
user output |
---|
0 |
Test 19
Verdict: ACCEPTED
input |
---|
99856 0 0 315 315 0 0 0 1 0 2 ... |
correct output |
---|
631 |
user output |
---|
631 |
Test 20
Verdict: ACCEPTED
input |
---|
121 30 30 40 40 30 30 30 31 30 32 ... |
correct output |
---|
21 |
user output |
---|
21 |
Test 21
Verdict: WRONG ANSWER
input |
---|
100000 0 0 1000000000 1000000000 81777 81727 7139 7165 18678 18626 ... |
correct output |
---|
2000 |
user output |
---|
1009 |
Test 22
Verdict: WRONG ANSWER
input |
---|
100000 0 0 1000000000 1000000000 42065 47939 60860 69144 24315 25689 ... |
correct output |
---|
20 |
user output |
---|
10 |
Test 23
Verdict: WRONG ANSWER
input |
---|
100000 0 0 1000000000 1000000000 24711 24693 27493 27511 58083 58121 ... |
correct output |
---|
1000 |
user output |
---|
502 |
Test 24
Verdict: WRONG ANSWER
input |
---|
100000 0 0 1000000000 1000000000 93337 93167 10108 10396 28728 28776 ... |
correct output |
---|
400 |
user output |
---|
200 |
Test 25
Verdict: WRONG ANSWER
input |
---|
100000 0 0 1000000000 1000000000 299880 999700120 999535510 464490 999907060 92940 ... |
correct output |
---|
4 |
user output |
---|
3 |
Test 26
Verdict: ACCEPTED
input |
---|
100 100 100 200 200 157 200 117 200 142 200 ... |
correct output |
---|
100 |
user output |
---|
100 |
Test 27
Verdict: ACCEPTED
input |
---|
100 100 100 200 200 130 173 130 131 130 118 ... |
correct output |
---|
100 |
user output |
---|
100 |
Test 28
Verdict: WRONG ANSWER
input |
---|
100000 0 0 1000000000 1000000000 897804452 627427519 606065659 628843521 477686514 492734427 ... |
correct output |
---|
622 |
user output |
---|
14 |
Test 29
Verdict: WRONG ANSWER
input |
---|
100000 0 0 100000 100000 95475 11246 59599 37233 71739 19501 ... |
correct output |
---|
615 |
user output |
---|
21 |
Test 30
Verdict: WRONG ANSWER
input |
---|
100000 0 0 300 300 13 285 52 40 158 178 ... |
correct output |
---|
1233 |
user output |
---|
1038 |
Test 31
Verdict: WRONG ANSWER
input |
---|
100000 0 0 10 10 6 4 1 9 8 9 ... |
correct output |
---|
17669 |
user output |
---|
12963 |
Test 32
Verdict: ACCEPTED
input |
---|
10 0 0 10 10 6 4 1 9 8 9 ... |
correct output |
---|
5 |
user output |
---|
5 |
Test 33
Verdict: WRONG ANSWER
input |
---|
1000 1234 76543 1265 76224 1545 76719 1199 76306 1305 76185 ... |
correct output |
---|
2 |
user output |
---|
1 |
Test 34
Verdict: WRONG ANSWER
input |
---|
100000 0 0 1000000000 1000000000 999998482 1518 999999380 620 52008 999947992 ... |
correct output |
---|
2001 |
user output |
---|
3 |
Test 35
Verdict: WRONG ANSWER
input |
---|
100000 0 0 1000000000 1000000000 999960616 39384 39185 999960815 45237 999954763 ... |
correct output |
---|
201 |
user output |
---|
3 |
Test 36
Verdict: WRONG ANSWER
input |
---|
100000 0 0 1000000000 1000000000 999989308 10692 999998647 1353 44068 999955932 ... |
correct output |
---|
21 |
user output |
---|
3 |
Test 37
Verdict: WRONG ANSWER
input |
---|
100000 0 0 1000000000 1000000000 999955327 44673 999932388 67612 11879 999988121 ... |
correct output |
---|
1001 |
user output |
---|
3 |
Test 38
Verdict: WRONG ANSWER
input |
---|
100000 0 0 1000000000 1000000000 0 0 1000000000 1000000000 1 999999999 ... |
correct output |
---|
101 |
user output |
---|
3 |
Test 39
Verdict: WRONG ANSWER
input |
---|
100000 0 0 1000000000 1000000000 62791 999937209 98083 999901917 999902435 97565 ... |
correct output |
---|
801 |
user output |
---|
3 |
Test 40
Verdict: WRONG ANSWER
input |
---|
100000 0 0 1000000000 1000000000 43604 999956396 80721 999919279 999958750 999958750 ... |
correct output |
---|
4001 |
user output |
---|
3 |
Test 41
Verdict: WRONG ANSWER
input |
---|
100000 0 0 1000000000 1000000000 99142 999900858 60558 999939442 44046 999955954 ... |
correct output |
---|
401 |
user output |
---|
3 |
Test 42
Verdict: WRONG ANSWER
input |
---|
100000 0 0 1000000000 1000000000 56902 999943098 7395 999992605 76388 999923612 ... |
correct output |
---|
41 |
user output |
---|
3 |
Test 43
Verdict: WRONG ANSWER
input |
---|
100000 0 0 1000000000 1000000000 11427 999988573 23698 999976302 57515 999942485 ... |
correct output |
---|
5 |
user output |
---|
3 |