Codeforces Round #412 Div.2

Posted p0ny^v^

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Codeforces Round #412 Div.2相关的知识,希望对你有一定的参考价值。

A.模拟

技术分享
 1 #include<cstdio>
 2 #include<iostream>
 3 using namespace std;
 4 
 5 inline void read(int &ans) {
 6     static char ch = getchar();
 7     register int neg = 1;
 8     ans = 0;
 9     for (; !isdigit(ch); ch = getchar())
10         if (ch == -) neg = -1;
11     for (; isdigit(ch); ch = getchar())
12         ans = ans * 10 + ch - 0;
13     ans *= neg;
14 }
15 
16 const int N = 1001;
17 int a[N], b[N], n;
18 
19 int main() {
20     read(n); bool flag = false;
21     for (int i = 0; i < n; ++i) {
22         read(a[i]), read(b[i]);
23         if (a[i] != b[i]) {
24             flag = true;
25             break;
26         }
27     }
28     if (flag) {
29         puts("rated"); return 0;
30     }
31     for (int i = 0; i < n; ++i) {
32         for (int j = i + 1; j < n; ++j) {
33             if (a[i] < a[j]) {
34                 flag = true;
35                 break;
36             }
37         }
38     }
39     if (flag)
40         puts("unrated");
41     else
42         puts("maybe");
43     return 0;
44 }
View Code

 

B.搜索

技术分享
 1 #include<cstdio>
 2 #include<set>
 3 #include<queue>
 4 #include<vector>
 5 #include<iostream>
 6 using namespace std;
 7 
 8 inline void read(int &ans) {
 9     static char ch = getchar();
10     register int neg = 1;
11     ans = 0;
12     for (; !isdigit(ch); ch = getchar())
13         if (ch == -) neg = -1;
14     for (; isdigit(ch); ch = getchar())
15         ans = ans * 10 + ch - 0;
16     ans *= neg;
17 }
18 
19 inline void get(int s, set < int > &si) {
20     int i = (s / 50) % 475;
21     for (int j = 0; j < 25; ++j) {
22         i = (i * 96 + 42) % 475;
23         si.insert(i + 26);
24     }
25 }
26 
27 int p, x, y, ans = ~0U >> 2;
28 set < int > ss[30000];
29 struct Node {
30     int s, m;
31     inline bool operator< (const Node &rhs) const {
32         return s < rhs.s;
33     }
34 };
35 set < Node > e;
36 
37 inline void bfs() {
38     queue < Node > q;
39     q.push((Node) {x, 0});
40     while (!q.empty()) {
41         Node c = q.front(); q.pop();
42         if (c.s < y || c.m >= ans) continue;
43         if (ss[c.s].empty()) get(c.s, ss[c.s]);
44         if (ss[c.s].count(p)) {
45             ans = min(ans, c.m);
46             continue;
47         }
48         q.push((Node) {c.s - 50, c.m});
49     }
50 
51     if (!ans) return;
52     while (!q.empty()) q.pop();
53     q.push((Node) {x, 0});
54 
55     while (!q.empty()) {
56         Node c = q.front(); q.pop();
57         if (c.s < y || c.m >= ans) continue;
58         e.insert(c);
59         if (ss[c.s].empty()) get(c.s, ss[c.s]);
60         if (ss[c.s].count(p)) {
61             ans = min(ans, c.m);
62             return;
63         }
64         if (!e.count((Node) {c.s + 100, c.m + 1})) q.push((Node) {c.s + 100, c.m + 1});
65         if (!e.count((Node) {c.s + 50, c.m + 1})) q.push((Node) {c.s + 50, c.m + 1});
66     }
67 }
68 
69 
70 int main() {
71     read(p); read(x); read(y);
72     bfs();
73     printf("%d\n", ans);
74     return 0;
75 }
View Code

 

CDE 太弱了,不会。

以上是关于Codeforces Round #412 Div.2的主要内容,如果未能解决你的问题,请参考以下文章

Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) B. T-Shirt Hunt

Codeforces Round #412 C. Success Rate

VK Cup 2017 Round 3 + Codeforces Round #412

Codeforces Round #705 (Div. 2)

Codeforces Round #774 (Div. 2)

Codeforces Round #808 (Div. 1)(A~C)