2020-11-16から1日間の記事一覧

Python(C++)でJOI難易度5を埋める #32

これで難易度5はおしまい B - たのしいカードゲーム (Card Game is Fun) Bは前から何枚取り除くかを考えればよいので,取り除くBの枚数と,そのときのAとの共通部分を調べればいい. #include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; </bits/stdc++.h>…

PythonでJOI難易度5を埋める #31

A - JJOOII (JJOOII) 連続するJ,O,I を数える.JJOOOIIIのようなケースに気をつける. s = input() cnt_j, cnt_o, cnt_i = 0, 0, 0 ans = [0] for i in range(len(s)): if cnt_i != 0 and s[i] != 'I': cnt_j, cnt_o, cnt_i = 0, 0, 0 if s[i] == 'J': if …

Python(C++)でJOI難易度5を埋める #30

A - 惑星探査 (Planetary Exploration) PythonだとTLE,PyPyだとMLEで死ぬので,C++で解く.許して.二次元累積和 #include <bits/stdc++.h> using namespace std; int main() { int m, n, k; cin >> m >> n >> k; vector<string> geo(m); vector<vector<int>> query(k, vector<int>(4)); for (int i </int></vector<int></string></bits/stdc++.h>…

PythonでJOI難易度5を埋める #29

B - 共通部分文字列 文字列sを前から1つずつ除いたものと文字列tを比べる,文字列tを前から1つずつ除いたものと文字列sを比べれば最大の共通部分が分かります. #include <bits/stdc++.h> using namespace std; int main() { string s1, s2; cin >> s1 >> s2; int l1, l2, c</bits/stdc++.h>…