This question is obviously DP. We must take the most shortcuts with greedy ideas, therefore, DP [I] indicates the maximum number of shortcuts before reaching the current shortcut. The state equation is DP [I] = max (DP [I], DP [J] + 1 ), I had to sort and handle it before, followed by the accuracy of the egg pain, wa a few times, and finally remember to use floor (ANS + 0.5) for processing.
Code:
# Include <vector> # include <list> # include <map> # include <set> # include <queue> # include <string. h> # include <deque> # include <stack> # include <bitset> # include <algorithm> # include <functional> # include <numeric> # include <utility> # include <sstream> # include <iostream> # include <iomanip> # include <cstdio> # include <cmath> # include <cstdlib> # include <limits. h> using namespace STD; int lowbit (INT t) {return T & (-T);} in T countbit (INT t) {return (t = 0 )? 0 :( 1 + countbit (T & (t-1);} int gcd (int A, int B) {return (B = 0 )? A: gcd (B, A % B);} int max (int A, int B) {return A> B? A: B;} int min (int A, int B) {return A> B? B: A ;}# define ll _ int64 # define PI ACOs (-1) # define n 100010 # define INF int_max # define EPS 1e-8struct node {int X; int y; bool operator <(Node B) const {If (X! = B. x) return x <B. x; return Y <B. Y ;}} P [110]; int DP [110]; int main () {// freopen ("a.txt", "r", stdin); int n, m; while (scanf ("% d", & N, & M )! = EOF) {int I, j; int K; scanf ("% d", & K); If (! K) {printf ("% d \ n", 100 * (N + M); continue;} for (I = 0; I <K; I ++) {scanf ("% d", & P [I]. x, & P [I]. y); DP [I] = 0;} Sort (p, p + k); int CNT = 1; DP [0] = 1; for (I = 1; I <K; I ++) {DP [I] = 1; for (j = 0; j <I; j ++) {If (P [I]. x> P [J]. X & P [I]. y> P [J]. y) DP [I] = max (DP [I], DP [J] + 1);} CNT = max (CNT, DP [I]);} // printf ("! % D \ n ", CNT); double an = (n + m-2 * CNT + SQRT (2.0) * CNT) * 100; int ans = floor (An + 0.5 ); // return the maximum integer <= specified expression printf ("% d \ n", ANS);} return 0 ;}