All editorial codes contain solutions wrapped in classes. I'll only paste the important part (namespace solution
in C++, class Solution
in Python 3) as plaintext in the solution code section (along with the corresponding AC submission link). You might want to see the code template here.
#include <bits/stdc++.h>
using namespace std;
namespace solution {
bool hasMultipleTests = true;
void preprocess() {
// something
}
void input(int testcase) {
// something
}
void solve(int testcase) {
// something
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
solution::preprocess();
int t = 1;
if (solution::hasMultipleTests) cin >> t;
for (int testcase=1; testcase<=t; testcase++) {
solution::input(testcase);
solution::solve(testcase);
}
return 0;
}
import sys
input = sys.stdin.readline
class Solution:
hasMultipleTests = True
@classmethod
def preprocess(cls):
pass
@classmethod
def input(cls, testcase):
pass
@classmethod
def solve(cls, testcase):
pass
# end Solution
if __name__ == '__main__':
Solution.preprocess()
t = int(input()) if Solution.hasMultipleTests else 1
for testcase in range(1, t+1):
Solution.input(testcase)
Solution.solve(testcase)
Also, per my own custom ever since 2019, solution codes will only be published after system testing, to ensure all codes used here guarantee AC. Thank you for your patience.
Author: AkiLotus
Development: AkiLotus
Hinter: AkiLotus
Editorialist: AkiLotus
In which cases would a light be on?
Imagine that you have $$$x$$$ white socks and $$$y$$$ black socks. What would you do to make the maximum pairs of matched socks?
Imagine that you have $$$x$$$ white socks and $$$y$$$ black socks. What would you do to make the maximum pairs of unmatched socks?
Submission link: TBD
// TBD
Submission link: TBD
# TBD
Author: Kuroni
Development: AkiLotus
Hinter: Kuroni
Editorialist: AkiLotus
There is always exactly one solution for $$$n = 1$$$. For $$$n \ge 3$$$, for which $$$k$$$ should there be no solution at all?
Try to find a solution with $$$k = 2$$$ and $$$k = 4$$$, assuming $$$n$$$ allows at least one solution to exist. Can you find a pattern and generalize it for all even $$$k$$$?
Try to find a solution with $$$k = 3$$$ and $$$k = 5$$$, assuming $$$n$$$ allows at least one solution to exist. Can you find a pattern and generalize it for all odd $$$k$$$?
Submission link: TBD
// TBD
Submission link: TBD
# TBD
Author: AkiLotus
Development: AkiLotus
Hinter: AkiLotus
Editorialist: AkiLotus
Without loss of generality, you can rewrite the triangle inequality into a much more compacted form if the side lengths are properly ordered.
Given four integers $$$a \le b \le c \le d$$$, if $$$(a, b, d)$$$ are side lengths of a non-degenerate triangle, so does $$$(a, b, c)$$$.
Given four integers $$$a \le b \le c \le d$$$, if $$$(a, b, d)$$$ are side lengths of a non-degenerate triangle, so does $$$(a, c, d)$$$.
Given four integers $$$a \le b \le c \le d$$$, if $$$(a, b, d)$$$ are side lengths of a non-degenerate triangle, so does $$$(b, c, d)$$$.
To make a sorted array $$$[b_1, b_2, \ldots, b_m] \space (m \ge 3)$$$ satisfy the problem, we must ensure that $$$b_1 + b_2 > b_m$$$.
Fix the result array to have two minimas and one maxima at respectively $$$a_x$$$, $$$a_y$$$ and $$$a_z$$$. How many operations are required to do so?
Is there a fast and optimal way to try all possible $$$(a_x, a_y, a_z)$$$ triplets?
Submission link: TBD
// TBD
Submission link: TBD
# TBD
Author: AkiLotus
Development: AkiLotus
Hinter: AkiLotus
Editorialist: AkiLotus
There are many specific constraints on the system tree.
First, notice that $$$1 \le x \le y \le n-1$$$ if and only if $$$p_x \le p_y$$$. Draw a few trees with this constraint and start pointing your finger on the nodes from $$$0$$$ to $$$n-1$$$. Notice the pattern your finger is making.
Incorporate hint #1 with the fact that the "tentacles" of the Genokraken are just paths. Try to draw more detailed conclusion about that pattern.
Is there a way to know how many tentacles there are?
What use could we make of the fact that node $$$1$$$ has exactly two adjacent nodes?
The query limit is very small. Is there a way to query that the information obtained in each query should (at least partially) determine a node?
For each "tentacle", can we know when its path has ended? How many queries should it take?
Submission link: TBD
// TBD
Submission link: TBD
# TBD
Author: thanhchauns2
Development: thanhchauns2, Sagita_Phoenix
Editorialist: AkiLotus
TBD
Submission link: TBD
// TBD
Submission link: TBD
# TBD
Author: MofK
Development: MofK, AkiLotus
Editorialist: MofK, AkiLotus
TBD
Submission link: TBD
// TBD
Submission link: TBD
# TBD