Skip to content

Commit 3826080

Browse files
committed
⚡️ 精進
1 parent 60ffd08 commit 3826080

File tree

21 files changed

+540
-0
lines changed

21 files changed

+540
-0
lines changed

Diff for: atcoder/abc/abc201-300/abc252/a.py

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
n = int(input())
2+
print(chr(n))

Diff for: atcoder/abc/abc201-300/abc252/b.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
n, k = map(int, input().split())
2+
a = list(map(int, input().split()))
3+
b = list(map(int, input().split()))
4+
b = set(b)
5+
6+
max_a = max(a)
7+
ab = []
8+
flag = True
9+
10+
for i, ai in enumerate(a, start=1):
11+
print(i, ai)
12+
if ai == max_a and i in b:
13+
flag = False
14+
break
15+
if flag:
16+
print("No")
17+
else:
18+
print("Yes")

Diff for: atcoder/abc/abc201-300/abc252/c.py

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
n = int(input())
2+
s = []
3+
4+
for i in range(n):
5+
si = list(map(int, list(input())))
6+
for _ in range(4):
7+
si = si + si
8+
s.append(si)
9+
10+
ans = float("inf")
11+
for i in range(10):
12+
t = 0
13+
for j in range(n):
14+
while True:
15+
if s[j][t] == i:
16+
if j < n - 1:
17+
t += 1
18+
break
19+
else:
20+
t += 1
21+
ans = min(ans, t)
22+
print(ans)
23+
24+
25+

Diff for: atcoder/abc/abc201-300/abc253/a.cpp

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
#define endl "\n"
4+
using ll = long long;
5+
using P = pair<ll, ll>;
6+
7+
const ll infll = (1LL << 62) - 1;
8+
const int inf = (1 << 30) - 1;
9+
10+
struct IoSetup {
11+
IoSetup() {
12+
cin.tie(nullptr);
13+
ios::sync_with_stdio(false);
14+
cout << fixed << setprecision(10);
15+
cerr << fixed << setprecision(10);
16+
}
17+
} iosetup;
18+
19+
template< typename T1, typename T2 >
20+
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
21+
22+
template< typename T1, typename T2 >
23+
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
24+
25+
void fail() {
26+
cout << -1 << endl;
27+
exit(0);
28+
}
29+
30+
int main(){
31+
ll a, b, c;
32+
cin >> a >> b >> c;
33+
34+
if ((a <= b && b <= c) || (c <= b && b <= a){
35+
cout << "Yes" << endl;
36+
} else {
37+
cout << "No" << endl;
38+
}
39+
}

Diff for: atcoder/abc/abc201-300/abc253/b.cpp

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
#define endl "\n"
4+
using ll = long long;
5+
using P = pair<ll, ll>;
6+
7+
const ll infll = (1LL << 62) - 1;
8+
const int inf = (1 << 30) - 1;
9+
10+
struct IoSetup {
11+
IoSetup() {
12+
cin.tie(nullptr);
13+
ios::sync_with_stdio(false);
14+
cout << fixed << setprecision(10);
15+
cerr << fixed << setprecision(10);
16+
}
17+
} iosetup;
18+
19+
template< typename T1, typename T2 >
20+
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
21+
22+
template< typename T1, typename T2 >
23+
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
24+
25+
void fail() {
26+
cout << -1 << endl;
27+
exit(0);
28+
}
29+
30+
ll manhattan_distance(ll x1, ll y1, ll x2, ll y2){
31+
return abs(x1 - x2) + abs(y1 - y2);
32+
}
33+
34+
int main(){
35+
ll h, w;
36+
cin >> h >> w;
37+
string s[h];
38+
for(ll i = 0; i < h; i++){
39+
cin >> s[i];
40+
}
41+
vector<tuple<ll, ll>> points;
42+
for(ll i = 0; i < h; i++){
43+
for(ll j = 0; j < w; j++){
44+
if (s[i][j] == 'o'){
45+
points.push_back(make_tuple(i, j));
46+
}
47+
}
48+
}
49+
ll ans = manhattan_distance(get<0>(points[0]), get<1>(points[0]), get<0>(points[1]), get<1>(points[1]));
50+
cout << ans << endl;
51+
}

Diff for: atcoder/abc/abc201-300/abc253/c.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from collections import defaultdict
2+
import heapq
3+
4+
q = int(input())
5+
min_values = []
6+
max_values = []
7+
counter = defaultdict(int)
8+
ans = []
9+
10+
for _ in range(q):
11+
query = list(map(int, input().split()))
12+
if query[0] == 1:
13+
x = query[1]
14+
counter[x] += 1
15+
heapq.heappush(min_values, x)
16+
heapq.heappush(max_values, -x)
17+
elif query[0] == 2:
18+
x, c = query[1], query[2]
19+
counter[x] = max(0, counter[x] - c)
20+
else:
21+
min_v = min_values[0]
22+
while counter[min_v] == 0:
23+
heapq.heappop(min_values)
24+
min_v = min_values[0]
25+
max_v = -max_values[0]
26+
while counter[max_v] == 0:
27+
heapq.heappop(max_values)
28+
max_v = -max_values[0]
29+
ans.append(max_v - min_v)
30+
print(*ans, sep="\n")

Diff for: atcoder/abc/abc201-300/abc253/d.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import math
2+
3+
n, a, b = map(int, input().split())
4+
5+
# 包除原理
6+
# 1からnの和 - aの倍数の合計 - bの倍数の合計 + a*bの倍数の合計
7+
8+
# 1からnの和
9+
s = n * (n + 1) // 2
10+
# aの倍数の合計
11+
sa = a * (n // a) * (n // a + 1) // 2
12+
# bの倍数の合計
13+
sb = b * (n // b) * (n // b + 1) // 2
14+
# a*bの倍数の合計
15+
ab = math.lcm(a, b)
16+
sab = ab * (n // ab) * (n // ab + 1) // 2
17+
18+
print(s - sa - sb + sab)

Diff for: atcoder/abc/abc201-300/abc254/a.cpp

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
#define endl "\n"
4+
using ll = long long;
5+
using P = pair<ll, ll>;
6+
7+
const ll infll = (1LL << 62) - 1;
8+
const int inf = (1 << 30) - 1;
9+
10+
struct IoSetup {
11+
IoSetup() {
12+
cin.tie(nullptr);
13+
ios::sync_with_stdio(false);
14+
cout << fixed << setprecision(10);
15+
cerr << fixed << setprecision(10);
16+
}
17+
} iosetup;
18+
19+
template< typename T1, typename T2 >
20+
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
21+
22+
template< typename T1, typename T2 >
23+
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
24+
25+
void fail() {
26+
cout << -1 << endl;
27+
exit(0);
28+
}
29+
30+
int main(){
31+
ll n;
32+
cin >> n;
33+
if(n % 100 < 10){
34+
cout << "0" << n % 100 << endl;
35+
} else {
36+
cout << n % 100 << endl;
37+
}
38+
}

Diff for: atcoder/abc/abc201-300/abc254/b.cpp

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
#define endl "\n"
4+
using ll = long long;
5+
using P = pair<ll, ll>;
6+
7+
const ll infll = (1LL << 62) - 1;
8+
const int inf = (1 << 30) - 1;
9+
10+
struct IoSetup {
11+
IoSetup() {
12+
cin.tie(nullptr);
13+
ios::sync_with_stdio(false);
14+
cout << fixed << setprecision(10);
15+
cerr << fixed << setprecision(10);
16+
}
17+
} iosetup;
18+
19+
template< typename T1, typename T2 >
20+
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
21+
22+
template< typename T1, typename T2 >
23+
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
24+
25+
void fail() {
26+
cout << -1 << endl;
27+
exit(0);
28+
}
29+
30+
int main(){
31+
ll n;
32+
cin >> n;
33+
ll a[n][n] = {0};
34+
for(ll i = 0; i < n; i++){
35+
for(ll j = 0; j <= i; j++){
36+
if (j > 0) {
37+
cout << " ";
38+
}
39+
if (j == 0 || j == i) {
40+
a[i][j] = 1;
41+
} else {
42+
a[i][j] = a[i - 1][j - 1] + a[i - 1][j];
43+
}
44+
cout << a[i][j];
45+
}
46+
cout << endl;
47+
}
48+
}

Diff for: atcoder/abc/abc201-300/abc254/c.cpp

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
#define endl "\n"
4+
using ll = long long;
5+
using P = pair<ll, ll>;
6+
7+
const ll infll = (1LL << 62) - 1;
8+
const int inf = (1 << 30) - 1;
9+
10+
struct IoSetup {
11+
IoSetup() {
12+
cin.tie(nullptr);
13+
ios::sync_with_stdio(false);
14+
cout << fixed << setprecision(10);
15+
cerr << fixed << setprecision(10);
16+
}
17+
} iosetup;
18+
19+
template< typename T1, typename T2 >
20+
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
21+
22+
template< typename T1, typename T2 >
23+
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
24+
25+
void fail() {
26+
cout << -1 << endl;
27+
exit(0);
28+
}
29+
30+
int main(){
31+
ll n, k;
32+
cin >> n >> k;
33+
vector<ll> a;
34+
vector<vector<ll>> b(n);
35+
36+
for(ll i = 0; i < n; i++){
37+
ll tmp;
38+
cin >> tmp;
39+
b[i % k].push_back(tmp);
40+
}
41+
for(ll i = 0; i < k; i++){
42+
sort(b[i].begin(), b[i].end());
43+
}
44+
45+
string ans = "Yes";
46+
ll pre_value = -1;
47+
for(ll i = 0; i < n; i++){
48+
if (b[i % k][i / k] < pre_value) {
49+
ans = "No";
50+
break;
51+
}
52+
pre_value = b[i % k][i / k];
53+
}
54+
cout << ans << endl;
55+
}

Diff for: atcoder/abc/abc201-300/abc255/a.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
r, c = map(int, input().split())
2+
a = [list(map(int, input().split())) for _ in range(2)]
3+
4+
print(a[r-1][c-1])

Diff for: atcoder/abc/abc201-300/abc255/b.py

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
INF = float("inf")
2+
n, k = map(int, input().split())
3+
a = list(map(int, input().split()))
4+
xy = []
5+
for _ in range(n):
6+
x, y = map(int, input().split())
7+
xy.append((x, y))
8+
9+
def dist(x1, y1, x2, y2):
10+
return ((x2 - x1) ** 2 + (y2 - y1) ** 2) ** 0.5
11+
12+
dists = [INF for _ in range(n)]
13+
for i in range(n):
14+
xi, yi = xy[i]
15+
for ai in a:
16+
dists[i] = min(dists[i], dist(xi, yi, xy[ai - 1][0], xy[ai - 1][1]))
17+
18+
ans = 0
19+
for di in dists:
20+
ans = max(ans, di)
21+
print(ans)

Diff for: atcoder/abc/abc201-300/abc255/c.py

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
GETA = 10 ** 18
2+
x, a, d, n = map(int, input().split())
3+
if d < 0:
4+
min_value = a + d * (n - 1)
5+
a = min_value
6+
d = -d
7+
8+
x += GETA
9+
a += GETA
10+
11+
min_value = a
12+
max_value = a + d * (n - 1)
13+
14+
if x >= max_value:
15+
print(abs(x - max_value))
16+
elif x <= min_value:
17+
print(abs(min_value - x))
18+
else:
19+
y = x - a
20+
print(min(y % d, d - (y % d)))

0 commit comments

Comments
 (0)