2020-07-21から1日間の記事一覧
Quiz https://codeforces.com/contest/1108/problem/D AC https://codeforces.com/contest/1108/submission/87500494 解法 (公式editorialがないので書いておく) dp[i][j] i文字まで見て、そこで使った文字がjであるときの最小の交換回数 dpテーブルサイズは…
Quiz "D. Diverse Garland" https://codeforces.com/contest/1108/problem/D AC https://codeforces.com/contest/1108/submission/87499830 問題の内容は重要ではないのですが、コーディング中のデバッグ表示に以下のコードを使いました void debug_vector(V…
// 正しい括弧列か? bool is_right_parenthesis(string s){ ll L = s.size(); ll a=0; for(char c : s){ if(c=='(') a++; } ll b=L-a; if(a!=b) return false; ll cur=0; for(char c : s){ if(c=='('){ cur++; }else{ cur--; } if(cur<0) return false; } r…