Summer school more than 2019 cattle off first training camp

Cattle off more school still quite hard. Three people to a variety of white.

Topic links: https://ac.nowcoder.com/acm/contest/881#question


A:

Meaning of the questions is to find two arrays minimum position is not the same situation for the first time. Take Sample is: a = {3,1,5,2,4}, b = {5 2 4 3 1}. an array of a minimum appears in the fourth position, and the array is not the minimum value b appears in the fourth position.

Therefore, increase monotonically with two stacks to maintain the minimum value of the most convenient location. As long as the number two stack pop is not the same situation it indicates that a minimum of varying location.

 1 /* basic header */
 2 #include <bits/stdc++.h>
 3 /* define */
 4 #define ll long long
 5 #define dou double
 6 #define pb emplace_back
 7 #define mp make_pair
 8 #define sot(a,b) sort(a+1,a+1+b)
 9 #define rep1(i,a,b) for(int i=a;i<=b;++i)
10 #define rep0(i,a,b) for(int i=a;i<b;++i)
11 #define eps 1e-8
12 #define int_inf 0x3f3f3f3f
13 #define ll_inf 0x7f7f7f7f7f7f7f7f
14 #define lson (curpos<<1)
15 #define rson (curpos<<1|1)
16 #define mid (curl+curr>>1)
17 /* namespace */
18 using namespace std;
19 /* header end */
20 
21 const int maxn = 1e5 + 10;
22 int n, a[maxn], b[maxn];
23 stack<int>s1, s2;
24 
25 int main() {
26     a[0] = b[0] = 0;
27     while (~scanf("%d", &n)) {
28         rep1(i, 1, n) scanf("%d", &a[i]);
29         rep1(i, 1, n) scanf("%d", &b[i]);
30         while (!s1.empty()) s1.pop();
31         while (!s2.empty()) s2.pop();
32         s1.push(1); s2.push(1);
33         int p;
34         for (p = 2; p <= n; p++) {
35             int num = 0;
36             while (!s1.empty() && a[p] < a[s1.top()]) num++, s1.pop();
37             while (!s2.empty() && b[p] < b[s2.top()]) num--, s2.pop();
38             if (num) break;
39             s1.push(p); s2.push(p);
40         }
41         printf("%d\n", p - 1);
42     }
43     return 0;
44 }
View Code

 

D:

Immortal title.

F:

The sample for the three sets of data are useless, full of malice.

The fastest approach is to set up a large triangle (0,0), (10000,0), (0,10000), enumerate all the whole point of a triangle and maintain the final answer. Answers and then calculated the ratio of area of ​​the triangle, just calculated approximation 11/2.

11/2 The number actually hard to see. Compute answers and twice the area of ​​the triangle (to S. This can be done with the cross product is not only convenient but also high precision Bi Hailun formula, the formula will burst Helen long long) ratio, get 21. ×××××, try again output 10.5S and 11S, the answer is just 11S.

 1 /* basic header */
 2 #include <bits/stdc++.h>
 3 /* define */
 4 #define ll long long
 5 #define dou double
 6 #define pb emplace_back
 7 #define mp make_pair
 8 #define sot(a,b) sort(a+1,a+1+b)
 9 #define rep1(i,a,b) for(int i=a;i<=b;++i)
10 #define rep0(i,a,b) for(int i=a;i<b;++i)
11 #define eps 1e-8
12 #define int_inf 0x3f3f3f3f
13 #define ll_inf 0x7f7f7f7f7f7f7f7f
14 #define lson (curpos<<1)
15 #define rson (curpos<<1|1)
16 #define mid (curl+curr>>1)
17 /* namespace */
18 using namespace std;
19 /* header end */
20 
21 ll p1, q1, p2, q2, p3, q3;
22 
23 int main() {
24     while (~scanf("%lld%lld%lld%lld%lld%lld", &p1, &q1, &p2, &q2, &p3, &q3)) {
25         pair<ll, ll> x = mp(p2 - p1, q2 - q1), y = mp(p3 - p1, q3 - q1);
26         ll ans = x.first * y.second - y.first * x.second;
27         printf("%lld\n", (ll)abs(ans) * 11);
28     }
29     return 0;
30 }
View Code

G:

Immortal title.

J:

Compare the size of the two scores. Python problem, Java title, __ int128 title.

 1 import sys
 2  
 3 for line in sys.stdin:
 4     (x, y, a, b) = line.split()
 5     x = int(x)
 6     y = int(y)
 7     a = int(a)
 8     b = int(b)
 9     if (x * b == a * y):
10         print("=")
11     elif (x * b < a * y):
12         print("<")
13     else:
14         print(">")
View Code

Guess you like

Origin www.cnblogs.com/JHSeng/p/11209641.html