Thank you for participating in our contest! We hope you enjoyed it. Implementations will be added soon.↵
↵
[problem:1627A]↵
↵
<spoiler summary="Hint 1">↵
When is the answer $-1$? When is the answer $0$? When is the answer $1$?↵
</spoiler>↵
↵
<spoiler summary="Hint 2">↵
Can you do all remaining cases in $2$ steps?↵
</spoiler>↵
↵
<spoiler summary="Solution">↵
[tutorial:1627A]↵
</spoiler>↵
↵
<spoiler summary="Implementation (C++)">↵
Soon[submission:142882991]↵
</spoiler>↵
↵
<spoiler summary="Implementation (Java)">↵
Soon[submission:142882684]↵
</spoiler>↵
↵
<spoiler summary="Implementation (Python)">↵
Soon↵
</spoiler>↵
↵
<spoiler summary="Video Editorial">↵
https://www.youtube.com/watch?v=j_oe8DA4hhM↵
</spoiler>↵
↵
[problem:1627B]↵
↵
<spoiler summary="Hint">↵
If the classroom was one-dimensional, i.e. $n = 1$, where would the best place for Tina to sit be?↵
</spoiler>↵
↵
<spoiler summary="Hint Solution">↵
The best place for Tina to sit a grid where $n = 1$ would be either $(1, 1)$, or $(1, m)$.↵
</spoiler>↵
↵
<spoiler summary="Solution">↵
[tutorial:1627B]↵
</spoiler>↵
↵
<spoiler summary="Implementation (C++)">↵
```#include <bits/stdc++.h>↵
using namespace std;↵
↵
void solve() {↵
int n, m, k;↵
cin >> n >> m;↵
vector<int> v;↵
for (int i = 0; i < n; ++i)↵
for (int j = 0; j < m; ++j)↵
v.push_back(max(i, n - i - 1) + max(j, m - j - 1));↵
sort(v.begin(), v.end());↵
for (int i = 0; i < n * m; ++i) ↵
cout << v[i] << " ";↵
cout << "\n";↵
}↵
↵
int main() {↵
ios_base::sync_with_stdio(0); cin.tie(0);↵
int t;↵
cin >> t;↵
while (t--)↵
solve();↵
return 0;↵
}↵
```[submission:142882828]↵
</spoiler>↵
↵
<spoiler summary="Implementation (Java)">↵
Soon[submission:142882836]↵
</spoiler>↵
↵
<spoiler summary="Implementation (Python)">↵
Soon↵
</spoiler>↵
↵
<spoiler summary="Video Editorial">↵
https://www.youtube.com/watch?v=rwSzE-V-2V4↵
</spoiler>↵
↵
[problem:1627C]↵
↵
<spoiler summary="Hint">↵
When does a valid assignment not exist?↵
</spoiler>↵
↵
<spoiler summary="Solution">↵
[tutorial:1627C]↵
</spoiler>↵
↵
<spoiler summary="Implementation (C++)">↵
Soon[submission:142882592]↵
</spoiler>↵
↵
<spoiler summary="Implementation (Java)">↵
Soon[submission:142882888]↵
</spoiler>↵
↵
<spoiler summary="Implementation (Python)">↵
Soon↵
</spoiler>↵
↵
<spoiler summary="Video Editorial">↵
https://www.youtube.com/watch?v=0TigYx222pY↵
</spoiler>↵
↵
[problem:1627D]↵
↵
<spoiler summary="Hint">↵
After applying operations, all elements in the array will be between $1$ and $A$ inclusive, where $A$ is the maximum element of the initial array.↵
</spoiler>↵
↵
<spoiler summary="Solution">↵
[tutorial:1627D]↵
</spoiler>↵
↵
<spoiler summary="Implementation (C++)">↵
Soon[submission:142883054]↵
</spoiler>↵
↵
<spoiler summary="Implementation (Java)">↵
Soon[submission:142882944]↵
</spoiler>↵
↵
<spoiler summary="Implementation (Python)">↵
Soon↵
</spoiler>↵
↵
<spoiler summary="Video Editorial">↵
https://www.youtube.com/watch?v=VdbUkNgjiy0↵
</spoiler>↵
↵
[problem:1627E]↵
↵
<spoiler summary="Hint">↵
Try solving for $n, m, k \le 1000$.↵
</spoiler>↵
↵
<spoiler summary="Hint 2">↵
Do we need to account for all $n \cdot m$ rooms?↵
</spoiler>↵
↵
<spoiler summary="Hint 3">↵
Solve for each row independently.↵
</spoiler>↵
↵
<spoiler summary="Solution">↵
[tutorial:1627E]↵
</spoiler>↵
↵
<spoiler summary="Implementation (C++)">↵
Soon[submission:142882988]↵
</spoiler>↵
↵
<spoiler summary="Implementation (Java)">↵
Soon[submission:142883027]↵
</spoiler>↵
↵
<spoiler summary="Implementation (Python)">↵
Soon↵
</spoiler>↵
↵
[problem:1627F]↵
↵
<spoiler summary="Hint 1">↵
What can you say about all valid cuts?↵
</spoiler>↵
↵
↵
<spoiler summary="Hint 2">↵
The cuts are rotationally symmetric about the center. How do we find the cut that breaks the fewest edges?↵
</spoiler>↵
↵
↵
<spoiler summary="Hint 3">↵
Shortest paths.↵
</spoiler>↵
↵
<spoiler summary="Solution">↵
[tutorial:1627F]↵
</spoiler>↵
↵
<spoiler summary="Implementation (C++)">↵
Soon[submission:142882843]↵
</spoiler>↵
↵
<spoiler summary="Implementation (Java)">↵
Soon[submission:142883089]↵
</spoiler>↵
↵
<spoiler summary="Implementation (Python)">↵
Soon↵
</spoiler>↵
↵
<spoiler summary="Author Notes">↵
The problem was originally written as problem E, with a harder F, but we decided that the other F was too hard and moved this problem to F.↵
↵
Sorry for the statement of the problem initially. It was correct throughout testing, but during translation it seems that it might have been changed from subsequence to subarray accidentally.↵
</spoiler>↵
↵
↵
[problem:1627A]↵
↵
<spoiler summary="Hint 1">↵
When is the answer $-1$? When is the answer $0$? When is the answer $1$?↵
</spoiler>↵
↵
<spoiler summary="Hint 2">↵
Can you do all remaining cases in $2$ steps?↵
</spoiler>↵
↵
<spoiler summary="Solution">↵
[tutorial:1627A]↵
</spoiler>↵
↵
<spoiler summary="Implementation (C++)">↵
</spoiler>↵
↵
<spoiler summary="Implementation (Java)">↵
</spoiler>↵
↵
<spoiler summary="Implementation (Python)">↵
Soon↵
</spoiler>↵
↵
<spoiler summary="Video Editorial">↵
https://www.youtube.com/watch?v=j_oe8DA4hhM↵
</spoiler>↵
↵
[problem:1627B]↵
↵
<spoiler summary="Hint">↵
If the classroom was one-dimensional, i.e. $n = 1$, where would the best place for Tina to sit be?↵
</spoiler>↵
↵
<spoiler summary="Hint Solution">↵
The best place for Tina to sit a grid where $n = 1$ would be either $(1, 1)$, or $(1, m)$.↵
</spoiler>↵
↵
<spoiler summary="Solution">↵
[tutorial:1627B]↵
</spoiler>↵
↵
<spoiler summary="Implementation (C++)">↵
using namespace std;↵
↵
void solve() {↵
int n, m, k;↵
cin >> n >> m;↵
vector<int> v;↵
for (int i = 0; i < n; ++i)↵
for (int j = 0; j < m; ++j)↵
v.push_back(max(i, n - i - 1) + max(j, m - j - 1));↵
sort(v.begin(), v.end());↵
for (int i = 0; i < n * m; ++i) ↵
cout << v[i] << " ";↵
cout << "\n";↵
}↵
↵
int main() {↵
ios_base::sync_with_stdio(0); cin.tie(0);↵
int t;↵
cin >> t;↵
while (t--)↵
solve();↵
return 0;↵
}↵
```
</spoiler>↵
↵
<spoiler summary="Implementation (Java)">↵
</spoiler>↵
↵
<spoiler summary="Implementation (Python)">↵
Soon↵
</spoiler>↵
↵
<spoiler summary="Video Editorial">↵
https://www.youtube.com/watch?v=rwSzE-V-2V4↵
</spoiler>↵
↵
[problem:1627C]↵
↵
<spoiler summary="Hint">↵
When does a valid assignment not exist?↵
</spoiler>↵
↵
<spoiler summary="Solution">↵
[tutorial:1627C]↵
</spoiler>↵
↵
<spoiler summary="Implementation (C++)">↵
</spoiler>↵
↵
<spoiler summary="Implementation (Java)">↵
</spoiler>↵
↵
<spoiler summary="Implementation (Python)">↵
Soon↵
</spoiler>↵
↵
<spoiler summary="Video Editorial">↵
https://www.youtube.com/watch?v=0TigYx222pY↵
</spoiler>↵
↵
[problem:1627D]↵
↵
<spoiler summary="Hint">↵
After applying operations, all elements in the array will be between $1$ and $A$ inclusive, where $A$ is the maximum element of the initial array.↵
</spoiler>↵
↵
<spoiler summary="Solution">↵
[tutorial:1627D]↵
</spoiler>↵
↵
<spoiler summary="Implementation (C++)">↵
</spoiler>↵
↵
<spoiler summary="Implementation (Java)">↵
</spoiler>↵
↵
<spoiler summary="Implementation (Python)">↵
Soon↵
</spoiler>↵
↵
<spoiler summary="Video Editorial">↵
https://www.youtube.com/watch?v=VdbUkNgjiy0↵
</spoiler>↵
↵
[problem:1627E]↵
↵
<spoiler summary="Hint">↵
Try solving for $n, m, k \le 1000$.↵
</spoiler>↵
↵
<spoiler summary="Hint 2">↵
Do we need to account for all $n \cdot m$ rooms?↵
</spoiler>↵
↵
<spoiler summary="Hint 3">↵
Solve for each row independently.↵
</spoiler>↵
↵
<spoiler summary="Solution">↵
[tutorial:1627E]↵
</spoiler>↵
↵
<spoiler summary="Implementation (C++)">↵
</spoiler>↵
↵
<spoiler summary="Implementation (Java)">↵
</spoiler>↵
↵
<spoiler summary="Implementation (Python)">↵
Soon↵
</spoiler>↵
↵
[problem:1627F]↵
↵
<spoiler summary="Hint 1">↵
What can you say about all valid cuts?↵
</spoiler>↵
↵
↵
<spoiler summary="Hint 2">↵
The cuts are rotationally symmetric about the center. How do we find the cut that breaks the fewest edges?↵
</spoiler>↵
↵
↵
<spoiler summary="Hint 3">↵
Shortest paths.↵
</spoiler>↵
↵
<spoiler summary="Solution">↵
[tutorial:1627F]↵
</spoiler>↵
↵
<spoiler summary="Implementation (C++)">↵
</spoiler>↵
↵
<spoiler summary="Implementation (Java)">↵
</spoiler>↵
↵
<spoiler summary="Implementation (Python)">↵
Soon↵
</spoiler>↵
↵
<spoiler summary="Author Notes">↵
The problem was originally written as problem E, with a harder F, but we decided that the other F was too hard and moved this problem to F.↵
↵
Sorry for the statement of the problem initially. It was correct throughout testing, but during translation it seems that it might have been changed from subsequence to subarray accidentally.↵
</spoiler>↵
↵