Skip to content

Commit

Permalink
new: Codeforces Round 981 (Div. 3)
Browse files Browse the repository at this point in the history
  • Loading branch information
omar-besbes committed Oct 24, 2024
1 parent 677fc0a commit 72e3b45
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 0 deletions.
18 changes: 18 additions & 0 deletions solutions/Codeforces/Codeforces Round 981 (Div. 3)/A.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <bits/stdc++.h>
using namespace std;

void solve() {
int n;
cin >> n;
cout << (n % 2 ? "Kosuke" : "Sakurako") << "\n";
}

int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);

int t = 1;
cin >> t;
while (t--) solve();
}
31 changes: 31 additions & 0 deletions solutions/Codeforces/Codeforces Round 981 (Div. 3)/B.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <bits/stdc++.h>
using namespace std;

void solve() {
int n;
cin >> n;
vector<int> a(2 * n);
long long ans = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
int x;
cin >> x;
a[n + i - j] = max(a[n + i - j], -x);
}
}
for (int i = 0; i < 2 * n; i++) {
// cout << a[i] << " ";
ans += a[i];
}
cout << ans << "\n";
}

int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);

int t = 1;
cin >> t;
while (t--) solve();
}
32 changes: 32 additions & 0 deletions solutions/Codeforces/Codeforces Round 981 (Div. 3)/D.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include <bits/stdc++.h>
using namespace std;

void solve() {
int n;
cin >> n;
vector<int> a(n);
for (auto &i : a) cin >> i;
int ans = a[0] == 0;
long long sum = a[0];
set<int> seen;
seen.insert(a[0]);
seen.insert(0);
for (int i = 1; i < n; i++) {
sum += a[i];
if (seen.count(sum))
ans++, sum = 0, seen.clear(), seen.insert(0);
else
seen.insert(sum);
};
cout << ans << "\n";
}

int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);

int t = 1;
cin >> t;
while (t--) solve();
}
37 changes: 37 additions & 0 deletions solutions/Codeforces/Codeforces Round 981 (Div. 3)/E.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include <bits/stdc++.h>
using namespace std;

void solve() {
int n;
cin >> n;
vector<int> a(n);
for (auto &i : a) {
cin >> i;
i--;
}

vector<int> vis(n, false);
int d = 0, ans = 0;
for (int i = 0; i < n; i++) {
int j = i;
while (!vis[j]) {
vis[j] = true;
d++;
j = a[j];
}
ans += max(0, (d - 1) / 2);
d = 0;
}

cout << ans << "\n";
}

int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);

int t = 1;
cin >> t;
while (t--) solve();
}
14 changes: 14 additions & 0 deletions solutions/Codeforces/Codeforces Round 981 (Div. 3)/F.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <bits/stdc++.h>
using namespace std;

void solve() {}

int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);

int t = 1;
cin >> t;
while (t--) solve();
}

0 comments on commit 72e3b45

Please sign in to comment.