Time limit for this test was 1 hour
150 points
200 points
250 points
My solution for 250 points (sorry for bad formatting)
Comments
Feel free to share your ideas/code on how to solve them.
# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 150 |
Time limit for this test was 1 hour
const vector<vector> M = { {21,1,0,0,0,0}, {5,21,2,0,0,0}, {0,4,21,3,0,0}, {0,0,3,21,4,0}, {0,0,0,2,21,5}, {0,0,0,0,1,21} };
const vector<vector> I = { {1,0,0,0,0,0}, {0,1,0,0,0,0}, {0,0,1,0,0,0}, {0,0,0,1,0,0}, {0,0,0,0,1,0}, {0,0,0,0,0,1}, };
const int MOD = 1e9 + 7;
vector<vector> multiply(vector<vector> a,vector<vector> b){ vector<vector> c(6,vector(6,0)); for(int i = 0; i < 6; ++i) for(int j = 0; j < 6; ++j) for(int k = 0; k < 6; ++k) c[i][j] += a[i][k] * b[k][j], c[i][j] %= MOD; return c; }
vector<vector> power(int N){
vector<vector> ret = I, a = M;
while(N > 0){ if(N&1) ret = multiply(ret,a); N /= 2; a = multiply(a,a); }
return ret; }
int solve(int N){
auto M = power(N);
return M[5][0];
}
I was only able to solve 250 pointer using Matrix exponentiation, 150 pointer seemed like DP but was not able to implement. I have no idea about 200 pointer.
Feel free to share your ideas/code on how to solve them.
Name |
---|
I think the second problem(200 points) can be solved by compressing the graph into a bridge tree and then using binary lifting to obtain the bitwise or of all nodes on the path from the component of u to the component of v.
How to solve the first problem?
Notice how for every position i in our process we end up either at i , either at i+1 ( this is because the values are <= 2 ).
let dp[i][true/false][true/false] be the number of subsets such that in the process we end up at position i in the first string ( if true ) and at position i+1 ( if false ), similarly for the third state in the second string.
How to transition ?
just take some cases , if we reach position i in the first string and s[i] = 2 then this will go to dp[i+1][false][k].
This way , we have an O(N) solution.
Problem A has been asked in Media.net previously.
Couldn't find a solution earlier too.
Problem A
Round 2 (same Problem)
Second question can be solved with help of DSU. As we can visit any vertex multiple times, so if the OR of whole component will be < w then the answer will be NO. Also problem statement was not correct, it should be greater than or equal to w to pass all the testcases.
The statement is very vague in its definition of what exactly path is, I assumed path to be one where we cannot visit edges twice, Which makes it a way tougher question for a coding test (The solution above using bridge tree seems to be correct).
We can even convert the graph into a weighted one where the cost to go from node a to node b is a bitwise OR b similar for the reverse direction and simply run tweaked Dijkstra to find the maximum distance from every query, but it would get TLE, cuz of O(q*(v+e)*logE). But we can simply take OR of all vertices from 1 to n and address each query in O(1) by checking if it's greater than w or not. There is no use for DSU right, it's greedy.
codebuster_10 , how did you get these 21's in your matrix, for the 250 points question. I am getting the same matrix without the 21's along the diagonal.
21 stands for case when we choose consonants
Ahh I see, I completely forgot about considering consonants.
Was this an on campus test or off campus one?
Off campus
what was your dp state for 250 points problem? codebuster_10
UPD: got it dp[i][j] -> # of ways to get j vowels odd number of times with i as the string length
I think overall every task seems copied or classic. I have seen each one of them before.
task 1 copied from cc , task 3 copied from techgig final round 2019 or 2020 maybe , but doesn't matter due to being so classic , task 2 i have seen before but not sure where. its parade of copied task lol.
task 1] https://www.codechef.com/problems-old/CHEFTWOS
task 2] seems classic
task 3] can be solved with exponential generating functions easily,
it would be coeffiecient of x^N in the below polynomial
$$$ {(\frac{e^{x} - e^{-x}} { 2}})^5 * e^{21x}$$$
multiplied by N!
even though N! would be large but it also would be divided by some K! K would be very large too.