agc034

A: meaning of the questions: Do you have a 1 * n grid, in some places a barrier. You have two people, respectively, from a to b and from c to d, can only jump one step or two steps to the right. Demand is feasible.

Solution: first determine there is no two consecutive obstacles, and then determine whether the wrong car.

 1 #include <bits/stdc++.h>
 2 
 3 const int N = 200010;
 4 
 5 char str[N];
 6 
 7 int main() {
 8     int n, a, b, c, d;
 9     scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
10     scanf("%s", str + 1);
11     if(c < d) {
12         for(int i = a; i < d; i++) {
13             if(str[i] == '#' && str[i + 1] == '#') {
14                 printf("No\n");
15                 return 0;
16             }
17         }
18         printf("Yes\n");
19         return 0;
20     }
21     else {
22         for(int i = a; i < c; i++) {
23             if(str[i] == '#' && str[i + 1] == '#') {
24                 printf("No\n");
25                 return 0;
26             }
27         }
28         for(int i = b; i <= d; i++) {
29             if(str[i - 1] == '.' && str[i] == '.' && str[i + 1] == '.') {
30                 printf("Yes\n");
31                 return 0;
32             }
33         }
34         printf("No\n");
35         return 0;
36     }
37     return 0;
38 }
AC Code

B:

Guess you like

Origin www.cnblogs.com/huyufeifei/p/10983191.html