File tree Expand file tree Collapse file tree 4 files changed +126
-1
lines changed
Educational Codeforces Round 33 (Rated for Div. 2) Expand file tree Collapse file tree 4 files changed +126
-1
lines changed Original file line number Diff line number Diff line change
1
+ // http://codeforces.com/contest/893/problem/A
2
+ #include < bits/stdc++.h>
3
+ using namespace std ;
4
+
5
+ #define endl ' \n '
6
+ #define D (x ) cout << #x << " = " << (x) << endl;
7
+
8
+ int main () {
9
+ #ifdef ONLINEJUDGE
10
+ ios_base::sync_with_stdio (0 ); cin.tie (0 );
11
+ #endif
12
+
13
+ int n;
14
+ cin >> n;
15
+
16
+ bool ok = true ;
17
+ vector<int > v = {1 , 1 , 0 };
18
+ for (int i = 0 ; i < n; ++i) {
19
+ int x;
20
+ cin >> x; x--;
21
+
22
+ if (!v[x]) ok = false ;
23
+
24
+ v[x] ++;
25
+ for (int j = 0 ; j < 3 ; ++j) {
26
+ if (!v[j]) {
27
+ v[j] = v[x];
28
+ }
29
+ }
30
+
31
+ for (int i = 0 ; i < 3 ; ++i) v[i] --;
32
+ }
33
+
34
+ cout << (ok ? " YES" : " NO" ) << endl;
35
+
36
+ return 0 ;
37
+ }
Original file line number Diff line number Diff line change
1
+ // http://codeforces.com/contest/893/problem/B
2
+ #include < bits/stdc++.h>
3
+ using namespace std ;
4
+
5
+ #define endl ' \n '
6
+ #define D (x ) cout << #x << " = " << (x) << endl;
7
+
8
+ int main () {
9
+ #ifdef ONLINEJUDGE
10
+ ios_base::sync_with_stdio (0 ); cin.tie (0 );
11
+ #endif
12
+
13
+ int n;
14
+ cin >> n;
15
+
16
+ long long ans = 0 ;
17
+ int i = 1 ;
18
+ while (true ) {
19
+ long long a = (1LL << i) - 1 ;
20
+ long long b = 1LL << (i - 1 );
21
+ if (a * b > n) break ;
22
+ if (n % (a * b) == 0 ) {
23
+ ans = max (ans, a * b);
24
+ }
25
+
26
+ i ++;
27
+ }
28
+
29
+ cout << ans << endl;
30
+ return 0 ;
31
+ }
Original file line number Diff line number Diff line change
1
+ // http://codeforces.com/contest/893/problem/C
2
+ #include < bits/stdc++.h>
3
+ using namespace std ;
4
+
5
+ #define endl ' \n '
6
+ #define D (x ) cout << #x << " = " << (x) << endl;
7
+
8
+ const int MX = 1e5 + 100 ;
9
+ vector<int > G[MX];
10
+ vector<long long > v (MX);
11
+ vector<int > visited (MX, 0 );
12
+ long long mm;
13
+
14
+ void dfs (int cur) {
15
+ if (!visited[cur]) {
16
+ mm = min (v[cur], mm);
17
+ visited[cur] = true ;
18
+ for (int i = 0 ; i < G[cur].size (); ++i) {
19
+ int next = G[cur][i];
20
+ mm = min (mm, v[next]);
21
+ dfs (next);
22
+ }
23
+
24
+ }
25
+ }
26
+
27
+ int main () {
28
+ #ifdef ONLINEJUDGE
29
+ ios_base::sync_with_stdio (0 ); cin.tie (0 );
30
+ #endif
31
+
32
+ int n, m;
33
+ while (cin >> n >> m) {
34
+ for (int i = 1 ; i <= n; ++i) cin >> v[i];
35
+
36
+ for (int i = 0 ; i < m; ++i) {
37
+ int a, b;
38
+ cin >> a >> b;
39
+ G[a].push_back (b);
40
+ G[b].push_back (a);
41
+ }
42
+
43
+ long long ans = 0 ;
44
+ for (int i = 1 ; i <= n; ++i) {
45
+ if (!visited[i]) {
46
+ mm = INT_MAX;
47
+ dfs (i);
48
+ ans += mm;
49
+ }
50
+ }
51
+
52
+ cout << ans << endl;
53
+ }
54
+
55
+ return 0 ;
56
+ }
Original file line number Diff line number Diff line change 1066
1066
32302138
1067
1067
32161457
1068
1068
31878123
1069
- 31910741
1069
+ 31910741
1070
+ 32605600
You can’t perform that action at this time.
0 commit comments