File tree 4 files changed +133
-0
lines changed
4 files changed +133
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+
3
+ using namespace std ;
4
+ using ll = long long ;
5
+
6
+ int main () {
7
+ ios_base::sync_with_stdio (false );
8
+ cin.tie (0 ); cout.tie (0 );
9
+
10
+ string s;
11
+ cin >> s;
12
+ s[5 ] = ' ' ;
13
+ s[13 ] = ' ' ;
14
+ cout << s << endl;
15
+
16
+ return 0 ;
17
+ }
Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+
3
+ using namespace std ;
4
+ using ll = long long ;
5
+
6
+ int main () {
7
+ ios_base::sync_with_stdio (false );
8
+ cin.tie (0 ); cout.tie (0 );
9
+
10
+ int K, S;
11
+ cin >> K >> S;
12
+
13
+ int ans = 0 ;
14
+ for (int x = 0 ; x <= K; ++x) {
15
+ for (int y = 0 ; y <=K; ++y) {
16
+ int z = S - (x + y);
17
+ if (z <= K && z >= 0 ) ++ans;
18
+ }
19
+ }
20
+ cout << ans << endl;
21
+
22
+ return 0 ;
23
+ }
Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+
3
+ using namespace std ;
4
+ using ll = long long ;
5
+
6
+ int sx, sy, tx, ty;
7
+
8
+ string solve () {
9
+ int W = tx - sx, H = ty - sy;
10
+ assert (W > 0 && H > 0 );
11
+
12
+ vector<char > route;
13
+ for (int x = 0 ; x < W; ++x) route.push_back (' R' );
14
+ for (int y = 0 ; y < H; ++y) route.push_back (' U' );
15
+ for (int x = 0 ; x < W; ++x) route.push_back (' L' );
16
+ for (int y = 0 ; y < H; ++y) route.push_back (' D' );
17
+ route.push_back (' D' );
18
+ for (int x = 0 ; x < W + 1 ; ++x) route.push_back (' R' );
19
+ for (int y = 0 ; y < H + 1 ; ++y) route.push_back (' U' );
20
+ route.push_back (' L' );
21
+ route.push_back (' U' );
22
+ for (int x = 0 ; x < W + 1 ; ++x) route.push_back (' L' );
23
+ for (int y = 0 ; y < H + 1 ; ++y) route.push_back (' D' );
24
+ route.push_back (' R' );
25
+
26
+ return string (route.begin (), route.end ());
27
+ }
28
+
29
+ int main () {
30
+ ios_base::sync_with_stdio (false );
31
+ cin.tie (0 ); cout.tie (0 );
32
+
33
+ cin >> sx >> sy >> tx >> ty;
34
+ cout << solve () << endl;
35
+
36
+ return 0 ;
37
+ }
Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+
3
+ using namespace std ;
4
+ using ll = long long ;
5
+
6
+ const int inf = 1e7 ;
7
+ int N, M;
8
+ vector<vector<int >> G;
9
+ vector<vector<int >> O;
10
+
11
+ int solve () {
12
+ // COPY
13
+ O = G;
14
+
15
+ for (int k = 0 ; k < N; ++k) {
16
+ for (int i = 0 ; i < N; ++i) {
17
+ for (int j = 0 ; j < N; ++j) {
18
+ if (G[i][k] == inf || G[k][j] == inf) continue ;
19
+ if (G[i][k] + G[k][j] < G[i][j]) {
20
+ G[i][j] = G[i][k] + G[k][j];
21
+ }
22
+ }
23
+ }
24
+ }
25
+
26
+ int ans = 0 ;
27
+ for (int i = 0 ; i < N; ++i) {
28
+ for (int j = i + 1 ; j < N; ++j) {
29
+ if (i == j || O[i][j] == inf) continue ;
30
+ bool use = false ;
31
+ for (int s = 0 ; s < N; ++s) {
32
+ if (G[s][i] + O[i][j] == G[s][j]) use = true ;
33
+ }
34
+ if (!use) ++ans;
35
+ }
36
+ }
37
+ return ans;
38
+ }
39
+
40
+ int main () {
41
+ ios_base::sync_with_stdio (false );
42
+ cin.tie (0 ); cout.tie (0 );
43
+
44
+ cin >> N >> M;
45
+ G.assign (N, vector<int >(N, inf));
46
+ for (int i = 0 ; i < N; ++i) G[i][i] = 0 ;
47
+ for (int i = 0 ; i < M; ++i) {
48
+ int a, b, c;
49
+ cin >> a >> b >> c;
50
+ --a, --b;
51
+ G[a][b] = G[b][a] = c;
52
+ }
53
+ cout << solve () << endl;
54
+
55
+ return 0 ;
56
+ }
You can’t perform that action at this time.
0 commit comments