正睿20NOIp前冲刺day14

估分:100+100+50=250

实际:100+100+50=250

T1:

  b[i]表示不大于i的在a中的最大值,之后枚举每一个ai,再枚举他的倍数,就得出来了

 1 #include<cstdio>
 2 #include<cstring>
 3 #include<iostream>
 4 #include<algorithm>
 5 using namespace std;
 6 
 7 inline int read()
 8 {
 9     int x = 0, f = 0;
10     char ch = getchar();
11     while (!isdigit(ch)) f = ch == '-', ch = getchar();
12     while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
13     return f ? -x : x;
14 }
15 
16 const int N = 2000010;
17 
18 int n;
19 int a[N], b[N];
20 
21 int main()
22 {
23     n = read();
24     for (int i = 1; i <= n; i++) a[i] = read();
25     sort(a + 1, a + 1 + n);
26 
27     if (n <= 1000)
28     {
29         int ans = 0;
30         for (int i = 1; i <= n; i++)
31         {
32             for (int j = i + 1; j <= n; j++) ans = max(ans, a[j] % a[i]);
33         }
34         printf("%d", ans);
35     }
36     else
37     {
38         n = unique(a + 1, a + 1 + n) - a - 1;
39         for (int i = 2000000, j = n; i; i--)
40         {
41             while (j && a[j] >= i) j--;
42             b[i] = a[j];
43         }
44 
45         int ans = 0;
46         for (int i = 1; i <= n; i++)
47         {
48             for (int j = 2; j * a[i] <= 2000000; j++)
49                 ans = max(ans, b[a[i] * j] % a[i]);
50         }
51         printf("%d", ans);
52     }
53     return 0;
54 }
View Code

T2:

  因为相撞掉头,所以每辆车在序列中的排名是不变的,所以我们把相撞掉头看成直接穿过车辆继续走不掉头,询问的时候看排名就行了,查询就直接二分

 1 #include<cstdio>
 2 #include<cstring>
 3 #include<iostream>
 4 #include<algorithm>
 5 using namespace std;
 6 
 7 inline int read()
 8 {
 9     int x = 0, f = 0;
10     char ch = getchar();
11     while (!isdigit(ch)) f = ch == '-', ch = getchar();
12     while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
13     return f ? -x : x;
14 }
15 
16 const int N = 200010;
17 
18 int n;
19 int a[N], c[N], id[N];
20 int Ld[N], Rd[N], cntr, cntl;
21 char dir[N];
22 
23 bool cmp(int x, int y) { return a[x] < a[y]; }
24 
25 int main()
26 {
27     //freopen("input.txt","r",stdin);
28     int q;
29     n = read(), q = read();
30     for (int i = 1; i <= n; i++) a[i] = read(), c[i] = i;
31     sort(c + 1, c + 1 + n, cmp);
32     sort(a + 1, a + 1 + n);
33     for (int i = 1; i <= n; i++) id[c[i]] = i;
34 
35     scanf("%s", dir + 1);
36     for (int i = 1; i <= n; i++)
37     {
38         if (dir[i] == 'L') Ld[++cntl] = a[id[i]];
39         else Rd[++cntr] = a[id[i]];
40     }
41 
42     sort(Ld + 1, Ld + 1 + cntl);
43     sort(Rd + 1, Rd + 1 + cntr);
44     while (q--)
45     {
46         int x = read(), t = read();
47 
48         x = id[x];
49         int lx = x, rx = 0;
50         if (lx > cntl) lx = cntl, rx = x - cntl;
51         for (int i = 25; ~i; i--)
52         {
53             int la = lx - (1 << i), ra = rx + (1 << i);
54             if (la <= 0 || ra > cntr) continue;
55             if (Ld[la] - t > Rd[ra] + t) lx = la, rx = ra;
56         }
57         
58         int ans = abs(Ld[lx] - t);
59         if (rx > 0 && Ld[lx] - t < Rd[rx] + t) ans = abs(Rd[rx] + t);
60         if (rx + 1 <= cntr && Ld[lx] - t > Rd[rx + 1] + t) ans = abs(Rd[rx + 1] + t);
61         printf("%d\n", ans);
62     }
63     return 0;
64 }
View Code

T3:

  时间不够敲了,就一个随机数

  敲了一下午的7k的代码过了五万八个点

  1 #include<cstdio>
  2 #include<cstring>
  3 #include<iostream>
  4 #include<algorithm>
  5 using namespace std;
  6 
  7 inline int read()
  8 {
  9     int x = 0, f = 0;
 10     char ch = getchar();
 11     while (!isdigit(ch)) f = ch == '-', ch = getchar();
 12     while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
 13     return f ? -x : x;
 14 }
 15 
 16 inline void Stru(int a[10], int sid[][10])
 17 {
 18     sid[1][0] = a[1] * 100 + a[2];
 19     sid[2][0] = a[3] / 100 % 100 *100 + a[4] / 100 % 100;
 20     sid[3][0] = a[5] * 100 + a[6];
 21     sid[4][0] = a[7] * 100 + a[8];
 22     sid[5][0] = a[3] / 10000 % 100 * 100 + a[4] / 10000 % 100;
 23     sid[6][0] = a[3] % 100 *100 + a[4] % 100;
 24 }
 25 
 26 inline void Whi(int sid[])
 27 {
 28     for (int i = 1; i < 4; i++)
 29     {
 30         int x = sid[i - 1];
 31         sid[i] = x % 10 * 10 + x / 10 % 10 * 1000 + x / 100 % 10 + x / 1000 * 100;
 32     }
 33 }
 34 
 35 int sid1[10][10], ned[10][10];
 36 
 37 inline bool check()
 38 {
 39     int sub[10] = { 0 };
 40     for (int i = 1; i <= 6; i++)
 41     {
 42         int a = sid1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     [i][0], b = ned[i][0];
 43         while (a)
 44         {
 45             int x = a % 10, y = b % 10;
 46             a /= 10, b /= 10;
 47             if (!sub[x]) sub[x] = y;
 48             else if (sub[x] != y) return false;
 49         }
 50     }
 51     return true;
 52 }
 53 
 54 inline void Clowise(int x)
 55 {
 56     for (int i = 0; i < 3; i++) swap(sid1[x][i], sid1[x][i + 1]);
 57 }
 58 
 59 inline void Rev_Clowise(int x)
 60 {
 61     for (int i = 3; i; i--) swap(sid1[x][i], sid1[x][i - 1]);
 62 }
 63 
 64 inline void Oper1()
 65 {
 66     swap(sid1[4], sid1[6]);
 67     swap(sid1[5], sid1[4]);
 68     swap(sid1[2], sid1[5]);
 69 
 70     Clowise(2);
 71     Clowise(4);
 72     Clowise(5);
 73     Clowise(6);
 74     Clowise(1);
 75     Rev_Clowise(3);
 76 }
 77 
 78 inline void Oper2()
 79 {
 80     swap(sid1[1], sid1[6]);
 81     swap(sid1[5], sid1[1]);
 82     swap(sid1[3], sid1[5]);
 83 
 84     Clowise(2);
 85     Clowise(4);
 86     Clowise(5);
 87     Clowise(6);
 88     Clowise(1);
 89     Rev_Clowise(4);
 90 }
 91 
 92 inline void Oper3()
 93 {
 94     swap(sid1[4], sid1[1]);
 95     swap(sid1[3], sid1[4]);
 96     swap(sid1[2], sid1[3]);
 97 
 98     Clowise(5);
 99     Rev_Clowise(6);
100 }
101 
102 inline bool Whirling()
103 {
104     for (int a1 = 0; a1 < 4; a1++)
105     {
106         Oper1();
107         for (int b1 = 0; b1 < 4; b1++)
108         {
109             Oper2();
110             for (int c1 = 0; c1 < 4; c1++)
111             {
112                 Oper3();
113                 if (check()) return true;
114             }
115         }
116     }
117 
118     for (int a1 = 0; a1 < 4; a1++)
119     {
120         Oper1();
121         for (int b1 = 0; b1 < 4; b1++)
122         {
123             Oper3();
124             for (int c1 = 0; c1 < 4; c1++)
125             {
126                 Oper2();
127                 if (check()) return true;
128             }
129         }
130     }
131 
132     for (int a1 = 0; a1 < 4; a1++)
133     {
134         Oper2();
135         for (int b1 = 0; b1 < 4; b1++)
136         {
137             Oper1();
138             for (int c1 = 0; c1 < 4; c1++)
139             {
140                 Oper3();
141                 if (check()) return true;
142             }
143         }
144     }
145 
146     for (int a1 = 0; a1 < 4; a1++)
147     {
148         Oper2();
149         for (int b1 = 0; b1 < 4; b1++)
150         {
151             Oper3();
152             for (int c1 = 0; c1 < 4; c1++)
153             {
154                 Oper1();
155                 if (check()) return true;
156             }
157         }
158     }
159 
160     for (int a1 = 0; a1 < 4; a1++)
161     {
162         Oper3();
163         for (int b1 = 0; b1 < 4; b1++)
164         {
165             Oper1();
166             for (int c1 = 0; c1 < 4; c1++)
167             {
168                 Oper2();
169                 if (check()) return true;
170             }
171         }
172     }
173 
174     for (int a1 = 0; a1 < 4; a1++)
175     {
176         Oper3();
177         for (int b1 = 0; b1 < 4; b1++)
178         {
179             Oper2();
180             for (int c1 = 0; c1 < 4; c1++)
181             {
182                 Oper1();
183                 if (check()) return true;
184             }
185         }
186     }
187     return false;
188 }
189 
190 int main()
191 {
192     int T = read();
193     while (T--)
194     {
195         int a[10];
196         for (int i = 1; i <= 8; i++) a[i] = read();
197         Stru(a, sid1);
198         for (int i = 1; i <= 8; i++) a[i] = read();
199         Stru(a, ned);
200 
201         for (int i = 1; i <= 6; i++) Whi(sid1[i]);
202 
203         bool flag = false;
204         for (int a1 = 0; a1 < 2; a1++)
205         {
206             if (a1) swap(sid1[1], sid1[3]);
207             for (int b1 = 0; b1 < 2; b1++)
208             {
209                 if (b1) swap(sid1[2], sid1[4]);
210                 for (int c1 = 0; c1 < 2; c1++)
211                 {
212                     if (c1) swap(sid1[5], sid1[6]);
213                     if (Whirling()) { flag = true; break; }
214                     if (c1) swap(sid1[5], sid1[6]);
215                 }
216                 if (flag) break;
217                 if (b1) swap(sid1[2], sid1[4]);
218             }
219             if (flag) break;
220             if (a1) swap(sid1[1], sid1[3]);
221         }
222         if (flag) puts("yes");
223         else puts("no");
224     }
225     return 0;
226 }
View Code

总结:

  一切正常,没啥说的

posted on 2020-10-29 17:13  ArrogHie  阅读(141)  评论(0编辑  收藏  举报