Skip to content

Commit 3226be9

Browse files
committed
Change tabs to spaces
1 parent 55f3532 commit 3226be9

33 files changed

Lines changed: 688 additions & 688 deletions

APIO/APIO 10-commando.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,30 @@ bool case1(long long x, long long y, long long i) {
1010
}
1111

1212
bool case2(long long x, long long y, long long i) {
13-
return ((dp[y] - dp[x] + a * (pref[y] * pref[y] - pref[x] * pref[x])) * (pref[i] - pref[y]) < (dp[i] - dp[y] + a * (pref[i] * pref[i] - pref[y] * pref[y])) * (pref[y] - pref[x]));
13+
return ((dp[y] - dp[x] + a * (pref[y] * pref[y] - pref[x] * pref[x])) * (pref[i] - pref[y]) < (dp[i] - dp[y] + a * (pref[i] * pref[i] - pref[y] * pref[y])) * (pref[y] - pref[x]));
1414
}
1515

1616
int main() {
1717
cin >> n >> a >> b >> c;
1818
FOR(i, 0, n) {
19-
long long x;
20-
cin >> x;
21-
pref[i + 1] = pref[i] + x;
19+
long long x;
20+
cin >> x;
21+
pref[i + 1] = pref[i] + x;
2222
}
2323

2424
deque<long long> q;
2525
q.push_back(0);
2626
dp[0] = 0;
2727
FOR(i, 1, n + 1) {
28-
while (q.size() > 1 && case1(q[0], q[1], i)) q.pop_front();
28+
while (q.size() > 1 && case1(q[0], q[1], i)) q.pop_front();
2929

30-
long long x = q[0];
31-
long long y = pref[i] - pref[x];
32-
dp[i] = dp[x] + a * y * y + b * y + c;
30+
long long x = q[0];
31+
long long y = pref[i] - pref[x];
32+
dp[i] = dp[x] + a * y * y + b * y + c;
3333

34-
while (q.size() > 1 && case2(q[q.size() - 2], q.back(), i)) q.pop_back();
34+
while (q.size() > 1 && case2(q[q.size() - 2], q.back(), i)) q.pop_back();
3535

36-
q.push_back(i);
36+
q.push_back(i);
3737
}
3838

3939
cout << dp[n] << '\n';

Balkan/Balkan 15-happiness.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ bool check() {
5656
bool init(int coinsCount, long long maxCoinSize, long long coins[]) {
5757
root = new Node(1, maxCoinSize);
5858
for (int i = 0; i < coinsCount; i++) root->update(coins[i], coins[i]);
59-
return check();
59+
return check();
6060
}
6161

6262
bool is_happy(int event, int coinsCount, long long coins[]) {
63-
for (int i = 0; i < coinsCount; i++) root->update(coins[i], event * coins[i]);
63+
for (int i = 0; i < coinsCount; i++) root->update(coins[i], event * coins[i]);
6464
return check();
6565
}

Baltic/Baltic 09-candy.cpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,27 @@ pair<pair<int, int>, int> out[100001];
77
vector<int> wagons;
88

99
int main() {
10-
int n;
11-
cin >> n;
12-
FOR(i, 0, n) {
13-
int s, t;
14-
cin >> s >> t;
15-
candies[i] = {t + s, t - s};
16-
}
17-
sort(candies, candies + n);
18-
19-
FOR(i, 0, n) {
20-
int a = candies[i].first, b = -candies[i].second;
21-
int pos = lower_bound(wagons.begin(), wagons.end(), b) - wagons.begin();
22-
if (pos == wagons.size()) wagons.push_back(b);
23-
else wagons[pos] = b;
24-
25-
out[i] = {{(a + b) / 2, (a - b) / 2}, pos + 1};
26-
}
27-
28-
cout << wagons.size() << '\n';
29-
FOR(i, 0, n) {
30-
cout << out[i].first.first << ' ' << out[i].first.second << ' ' << out[i].second << '\n';
31-
}
32-
return 0;
10+
int n;
11+
cin >> n;
12+
FOR(i, 0, n) {
13+
int s, t;
14+
cin >> s >> t;
15+
candies[i] = {t + s, t - s};
16+
}
17+
sort(candies, candies + n);
18+
19+
FOR(i, 0, n) {
20+
int a = candies[i].first, b = -candies[i].second;
21+
int pos = lower_bound(wagons.begin(), wagons.end(), b) - wagons.begin();
22+
if (pos == wagons.size()) wagons.push_back(b);
23+
else wagons[pos] = b;
24+
25+
out[i] = {{(a + b) / 2, (a - b) / 2}, pos + 1};
26+
}
27+
28+
cout << wagons.size() << '\n';
29+
FOR(i, 0, n) {
30+
cout << out[i].first.first << ' ' << out[i].first.second << ' ' << out[i].second << '\n';
31+
}
32+
return 0;
3333
}

Baltic/Baltic 11-lamp.cpp

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,42 +9,42 @@ int visited[501][501], dx[4]{-1, -1, 1, 1}, dy[4]{-1, 1, -1, 1};
99
pair<int, int> dz[4]{{-1, -1}, {-1, 0}, {0, -1}, {0, 0}};
1010

1111
bool inside(int x, int y) {
12-
return (~x && x <= n && ~y && y <= m);
12+
return (~x && x <= n && ~y && y <= m);
1313
}
1414

1515
int main() {
16-
cin >> n >> m;
16+
cin >> n >> m;
1717

18-
FOR(i, 0, n) FOR(j, 0, m) {
19-
char c;
20-
cin >> c;
21-
if (c == orientation[(i + j) & 1]) correct[i][j] = true;
22-
else correct[i][j] = false;
23-
}
18+
FOR(i, 0, n) FOR(j, 0, m) {
19+
char c;
20+
cin >> c;
21+
if (c == orientation[(i + j) & 1]) correct[i][j] = true;
22+
else correct[i][j] = false;
23+
}
2424

25-
deque<pair<int, pair<int, int>>> dq;
26-
dq.push_back({1, {0, 0}});
27-
while (dq.size()) {
28-
int x, y, z;
29-
tie(x, y) = dq.front().second;
25+
deque<pair<int, pair<int, int>>> dq;
26+
dq.push_back({1, {0, 0}});
27+
while (dq.size()) {
28+
int x, y, z;
29+
tie(x, y) = dq.front().second;
3030
z = dq.front().first;
31-
dq.pop_front();
31+
dq.pop_front();
3232
if (visited[x][y]) continue;
3333
visited[x][y] = z;
3434

35-
FOR(i, 0, 4) {
36-
int nx = x + dx[i], ny = y + dy[i];
37-
if (inside(nx, ny) && !visited[nx][ny]) {
38-
if (correct[x + dz[i].first][y + dz[i].second]) {
39-
dq.push_front({z, {nx, ny}});
40-
} else {
41-
dq.push_back({z + 1, {nx, ny}});
42-
}
43-
}
44-
}
45-
}
35+
FOR(i, 0, 4) {
36+
int nx = x + dx[i], ny = y + dy[i];
37+
if (inside(nx, ny) && !visited[nx][ny]) {
38+
if (correct[x + dz[i].first][y + dz[i].second]) {
39+
dq.push_front({z, {nx, ny}});
40+
} else {
41+
dq.push_back({z + 1, {nx, ny}});
42+
}
43+
}
44+
}
45+
}
4646

47-
if (visited[n][m]) cout << visited[n][m] - 1;
48-
else cout << "NO SOLUTION";
49-
return 0;
47+
if (visited[n][m]) cout << visited[n][m] - 1;
48+
else cout << "NO SOLUTION";
49+
return 0;
5050
}

Baltic/Baltic 15-net.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@ using namespace std;
44
vector<int> graph[500001], leaves;
55

66
void dfs(int node = 1, int parent = 0) {
7-
if (graph[node].size() == 1) leaves.push_back(node);
8-
for (int i : graph[node]) {
9-
if (i != parent) dfs(i, node);
10-
}
7+
if (graph[node].size() == 1) leaves.push_back(node);
8+
for (int i : graph[node]) {
9+
if (i != parent) dfs(i, node);
10+
}
1111
}
1212

1313
int main() {
14-
int n;
15-
cin >> n;
16-
for (int i = 1; i < n; i++) {
17-
int a, b;
18-
cin >> a >> b;
19-
graph[a].push_back(b);
20-
graph[b].push_back(a);
21-
}
22-
dfs();
14+
int n;
15+
cin >> n;
16+
for (int i = 1; i < n; i++) {
17+
int a, b;
18+
cin >> a >> b;
19+
graph[a].push_back(b);
20+
graph[b].push_back(a);
21+
}
22+
dfs();
2323

24-
cout << (leaves.size() + 1) / 2 << '\n';
25-
for (int i = 0; i + leaves.size() / 2 < leaves.size(); i++) cout << leaves[i] << ' ' << leaves[i + leaves.size() / 2] << '\n';
26-
return 0;
24+
cout << (leaves.size() + 1) / 2 << '\n';
25+
for (int i = 0; i + leaves.size() / 2 < leaves.size(); i++) cout << leaves[i] << ' ' << leaves[i + leaves.size() / 2] << '\n';
26+
return 0;
2727
}

CEOI/CEOI 14-question.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ int sets[925][12];
55

66
void Init(int N){
77
for (int i = 0, cnt = 1; i < (1<<12); i++) {
8-
if (__builtin_popcount(i) == 6) {
9-
for (int j = 0; j < 12; j++) if (i & (1<<j)) sets[cnt][j] = 1; else sets[cnt][j] = 0;
10-
cnt++;
11-
}
12-
}
8+
if (__builtin_popcount(i) == 6) {
9+
for (int j = 0; j < 12; j++) if (i & (1<<j)) sets[cnt][j] = 1; else sets[cnt][j] = 0;
10+
cnt++;
11+
}
12+
}
1313
}
1414

1515
int Alice(int x,int y){

CEOI/CEOI 16-kangaroo.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ const long long MOD = 1e9 + 7;
1717
long long dp[2001][2001];
1818

1919
int main() {
20-
int n, a, b;
21-
scanf("%d %d %d", &n, &a, &b);
22-
dp[0][0] = 1;
23-
for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) {
24-
if (i == a || i == b)
25-
dp[i][j] = (dp[i - 1][j] + dp[i - 1][j - 1]) % MOD;
26-
else
27-
dp[i][j] = (dp[i - 1][j + 1] * j + dp[i - 1][j - 1] * (j - (i > a) - (i > b))) % MOD;
28-
}
29-
printf("%lld\n", dp[n][1]);
30-
return 0;
20+
int n, a, b;
21+
scanf("%d %d %d", &n, &a, &b);
22+
dp[0][0] = 1;
23+
for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) {
24+
if (i == a || i == b)
25+
dp[i][j] = (dp[i - 1][j] + dp[i - 1][j - 1]) % MOD;
26+
else
27+
dp[i][j] = (dp[i - 1][j + 1] * j + dp[i - 1][j - 1] * (j - (i > a) - (i > b))) % MOD;
28+
}
29+
printf("%lld\n", dp[n][1]);
30+
return 0;
3131
}

CEOI/CEOI 17-sure.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ using namespace std;
44
double a[100000], b[100000];
55

66
int main() {
7-
int n;
8-
cin >> n;
9-
for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
10-
sort(a, a + n, greater<double>());
11-
sort(b, b + n, greater<double>());
12-
13-
double ans = 0, l = 0, r = 0;
14-
int lptr = 0, rptr = 0;
15-
for (int i = 1; i <= 2 * n; i++) {
16-
if (lptr < n && (rptr == n || l < r)) l += a[lptr++];
17-
else r += b[rptr++];
18-
ans = max(ans, min(l, r) - i);
19-
}
20-
21-
cout << fixed << setprecision(4) << ans;
22-
return 0;
7+
int n;
8+
cin >> n;
9+
for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
10+
sort(a, a + n, greater<double>());
11+
sort(b, b + n, greater<double>());
12+
13+
double ans = 0, l = 0, r = 0;
14+
int lptr = 0, rptr = 0;
15+
for (int i = 1; i <= 2 * n; i++) {
16+
if (lptr < n && (rptr == n || l < r)) l += a[lptr++];
17+
else r += b[rptr++];
18+
ans = max(ans, min(l, r) - i);
19+
}
20+
21+
cout << fixed << setprecision(4) << ans;
22+
return 0;
2323
}

FXCUP/FXCUP4_cross.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ typedef long long ll;
55
using namespace std;
66

77
ll SelectCross(int K, vector<int> I, vector<int> O) {
8-
int N = I.size();
9-
vector<pair<ll, ll>> crosses;
10-
FOR(i, 0, N) crosses.push_back({I[i], O[i]});
11-
sort(crosses.begin(), crosses.end(), greater<pair<ll, ll>>());
8+
int N = I.size();
9+
vector<pair<ll, ll>> crosses;
10+
FOR(i, 0, N) crosses.push_back({I[i], O[i]});
11+
sort(crosses.begin(), crosses.end(), greater<pair<ll, ll>>());
1212

13-
priority_queue<ll> pq;
14-
ll ans = 0;
15-
FOR(i, 0, N) {
16-
pq.push(-crosses[i].second);
17-
if (i >= K) pq.pop();
18-
if (i >= K - 1) ans = max(ans, -pq.top() * crosses[i].first * 2 - crosses[i].first * crosses[i].first);
19-
}
13+
priority_queue<ll> pq;
14+
ll ans = 0;
15+
FOR(i, 0, N) {
16+
pq.push(-crosses[i].second);
17+
if (i >= K) pq.pop();
18+
if (i >= K - 1) ans = max(ans, -pq.top() * crosses[i].first * 2 - crosses[i].first * crosses[i].first);
19+
}
2020

21-
return ans;
21+
return ans;
2222
}

IOI/IOI 00-median.cpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,35 @@
55
std::vector<int> minmax;
66

77
int quickselect(int pos, std::vector<int> candidates) {
8-
if (candidates.size() == 1) return candidates[0];
9-
10-
int pivot = candidates[rand() % candidates.size()];
11-
std::vector<int> l, g;
12-
l.push_back(pivot);
13-
for (int i : candidates) {
14-
if (i == pivot) continue;
15-
if (Med3(minmax[0], i, pivot) == pivot) g.push_back(i);
16-
else l.push_back(i);
17-
}
18-
19-
if (l.size() >= pos) return quickselect(pos, l);
20-
else return quickselect(pos - l.size(), g);
8+
if (candidates.size() == 1) return candidates[0];
9+
10+
int pivot = candidates[rand() % candidates.size()];
11+
std::vector<int> l, g;
12+
l.push_back(pivot);
13+
for (int i : candidates) {
14+
if (i == pivot) continue;
15+
if (Med3(minmax[0], i, pivot) == pivot) g.push_back(i);
16+
else l.push_back(i);
17+
}
18+
19+
if (l.size() >= pos) return quickselect(pos, l);
20+
else return quickselect(pos - l.size(), g);
2121
}
2222

2323
int Median(int N) {
2424
for (int i = 1; i <= N; i++) {
25-
minmax.push_back(i);
26-
while (minmax.size() > 2) {
27-
int med = Med3(minmax[0], minmax[1], minmax[2]);
28-
if (med == minmax[0]) minmax.erase(minmax.begin());
29-
else if (med == minmax[1]) minmax.erase(minmax.begin() + 1);
30-
else minmax.erase(minmax.begin() + 2);
31-
}
25+
minmax.push_back(i);
26+
while (minmax.size() > 2) {
27+
int med = Med3(minmax[0], minmax[1], minmax[2]);
28+
if (med == minmax[0]) minmax.erase(minmax.begin());
29+
else if (med == minmax[1]) minmax.erase(minmax.begin() + 1);
30+
else minmax.erase(minmax.begin() + 2);
31+
}
3232
}
3333

3434
std::vector<int> candidates;
3535
for (int i = 1; i <= N; i++) if (i != minmax[0] && i != minmax[1])
36-
candidates.push_back(i);
36+
candidates.push_back(i);
3737

3838
return quickselect(N / 2, candidates);
3939
}

0 commit comments

Comments
 (0)