### chokudai's blog

By chokudai, history, 4 months ago, We will hold パナソニックグループプログラミングコンテスト2023（AtCoder Beginner Contest 301）.

The point values will be 100-200-300-400-475-500-600-625. (Since this ABC, we adjust the point values depending on problems.) We are looking forward to your participation! Comments (36)
 » Finally Atcoder is adjusting point values depending on their difficulties:P
•  » » Moral of this contest: Never use alts to try to consume all the penalties for your main account. (even with unrated register) If so, both accounts will be deleted automatically.
 » 4 months ago, # | ← Rev. 2 →   Perfect, 502 Bad Gateway and 504 Gateway Time-out was all we needed!!
 » DDOS again :(
 » Anti-DDoS is very hard to break!
 » Imagine Naming a problem Anti-DDoS and the server suffers from DDoS problem
 » How to solve D?
•  » » Digit DP
•  » » » it's not digit DP
•  » » » » Can you point out the mistake in this approach? We first replace all '?' with '0' and store indices of all '?' in a vector. Then we iterate on every element x of the vector and check if setting xth bit to 1 would give a number smaller than or equal to N. If you get a valid number, change '0' to '1' at that index. Code#include using namespace std; #define ll long long #define sz(a) (ll)(a.size()) #define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ll binTodec(string x){ ll k = 1, ans = 0; while(!x.empty()){ int b = x.back() - '0'; ans += b*k, k*=2, x.pop_back(); } return ans; } void solve(){ vector v; ll n, k, x; string s; cin >> s; cin >> n; k = sz(s); for(int i=0; i n) {cout << -1; return;} for(auto i: v) if((x | (1 << i)) <= n) x = x | (1 << i); cout << x; } signed main(){ IOS solve(); } 
•  » » » » » Never mind, I got it. It should be 1LL << i instead of 1 << i. Got WA x 2 due to this small mistake. :(
•  » » » » I didn't know that there exists an easier solution, I just said how I solved it.
•  » » » 4 months ago, # ^ | ← Rev. 2 →   You guys did DP? I did it by greedy string s; cin>>s; int n; cin>>n; int val=0; fi(s.size()) { if(s[i]=='1') val+=(1LL<<(s.size()-1-i)); } if(val>n) { cout<<"-1\n"; return; } vi ind; int sz=s.size(); fi(s.size()) { if(s[i]=='?') ind.push_back(sz-1-i); } fi(ind.size()) { if(val+(1LL<
•  » » » » There is no username that goes by "perfect".
•  » » Implementation :( I unwanted memoized it with dp my submission.DDOS didn't get chill with me.. when I play good round gets unrated and when bad gets rated :(
•  » » 4 months ago, # ^ | ← Rev. 3 →   Solution of D#include using namespace std; #define int long long int bin_to_int(string s, int n) { int ans = 0, base = 1; for (int i = n - 1; i >= 0; i--) { if (s[i] == '1') ans += base; // ignoring ? and 0s base *= 2; } return ans; } signed main() { string s; cin >> s; int k; cin >> k; int n = s.size(); int num = bin_to_int(s, n); for (int i = 0; i < n; i++) { if (s[i] == '?') { int t = (1ll << (n - 1 - i)); if (num + t <= k) num += t; } } if (num > k) cout << -1 << "\n"; else cout << num << "\n"; } 
•  » » 4 months ago, # ^ | ← Rev. 5 →   I've solved it with a greedy technique.My Algorithm is:1- Compute the current value of string S in decimal representation and neglect all '?' symbols in it2- Iterate over string S from MSB (most significant bit) and check if the current symbol is '?' and the (value of current value of S + pow (2, size(s)-idx-1)) is less than or equal to N, then I'll flip this symbol to 1 and add pow (2, size(s)-idx-1) to current value of s, else I will flip it to 0.My Source code
•  » » I tried solving it using DP. Here is my solution (in case, you are interested).
 » Can I somehow download the test case? problem E, last test.
•  » » I also was getting WA on that test case. I had a typo in my solution. While checking the distance from the starting point to the goal, I was doing \$
•  » » I faced the same problem,I thought he had to stop once he reached the Goal square (meaning he can't visit the goal square multiple times). This was giving WA.Maybe the wording of the question could have been better :(
•  » » » I thought exactly the same lol, could not figure out what the mistake was for 1 hour.. Thanks!
•  » » » Explanation for sample 1 shows that you can move through the goal square
 » 4 months ago, # | ← Rev. 3 →   Why does my code fail 2 out of 34 cases in problem C? Is there some edge case I am not considering?
•  » » 4 months ago, # ^ | ← Rev. 2 →   Counter: Input: ttttac @@@tac Output: No Correct Output: Yes You should reduce firstone[i] by 1 when firstone[i] > secondone[i] similar for secondone[i].
•  » » » Oh, thank you!Sorry for the late reply, I am not online very much. I appreciate the assistance.
 » I found D much harder to solve than E. 😿
 » My solution to problem E is as follows. use bfs(two times) to find the minimum distance from S to any cell, and from G to any cell; use bfs again, to find the distance between any two cells with candies; use dp[st][last], where st is the state of bitmask whose 1s denote that these candies have been taken, and last denotes the last candy that we take, and this dp could be computed with the help of a queue. from each dp[st][last], we compute the total distance to reach G, and if it is <= T, then we could update the maximum number of candies that we can take. Is this the intended solution or there is some simpler one.
•  » » you just re-invented the traveling salesman problem. Congrats!
•  » » Can't we use recursion on all the candies, because the maximum count is 18. I followed your first and second as it is but my solution got TLE.
 » didnt get in contest but f was fun, thanks to authors
 » Something really weird happened to me in problem C today. I got WA and I lost almost the entire contest trying to find what was wrong with my code. Now I managed to get AC by changing only one line in my code: WA: Link AC: Link The only difference is how I iterate the string "atcoder". I guess in my first code there is some kind of undefined behavior. Does anyone know why iterating with for(auto c:"atcoder") is wrong?
•  » » 4 months ago, # ^ | ← Rev. 3 →   Please run the following snippet in AtCoder's custom test page: Spoiler#include using namespace std; int main() { string p = "atcoder"; int i=0; for(auto c:"atcoder") cout << i++ << " "; cout << "\n"; i = 0; for(auto c:p) cout << i++ << " "; cout << "\n"; } 
•  » » That's because in the first case, "atcoder" is considered as a character array and not as a string.
 » May I ask when the data for abc301 will be available? Thank you.
 » How to solve F? tutorial hard to grasp. I reversed the string and was looking for SoDD, I can maintain capital followed by small letter So but not sure how to maintain two equal capital letters DD in the DP solution? https://atcoder.jp/contests/abc301/tasks/abc301_f