Datasets:

problem_id
stringlengths
6
6
buggy_code
stringlengths
8
526k
fixed_code
stringlengths
12
526k
labels
listlengths
0
15
buggy_submission_id
int64
1
1.54M
fixed_submission_id
int64
2
1.54M
user_id
stringlengths
10
10
language
stringclasses
8 values
p02939
#include <bits/stdc++.h> using namespace std; const int maxn = 2 * 1e5 + 20; int dp[maxn]; string s; int main() { cin >> s; dp[1] = 1; int l = s.size(); s = '#' + s; if (s[1] == s[2]) { dp[2] = 1; } else dp[2] = 2; for (int i = 3; i <= l; i++) { if (s[i] != s[i - 1]) { dp[i] = dp[i - 1] + 1; } else { dp[i] = dp[i - 2] + 1; } } cout << dp[l] << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 2 * 1e5 + 20; int dp[maxn]; string s; int main() { cin >> s; dp[1] = 1; int l = s.size(); s = '#' + s; if (s[1] == s[2]) { dp[2] = 1; } else dp[2] = 2; for (int i = 3; i <= l; i++) { if (s[i] != s[i - 1]) { dp[i] = dp[i - 1] + 1; } else { dp[i] = dp[i - 3] + 2; } } cout << dp[l] << endl; return 0; }
[ "literal.number.change", "assignment.value.change", "variable_access.subscript.index.change", "expression.operation.binary.change" ]
741,415
741,416
u198880917
cpp
p02939
#include <bits/stdc++.h> #define ll long long #define int long long #define MOD 1000000007 #define MAX 500005 #include <iomanip> #define fast \ ios_base ::sync_with_stdio(0); \ cin.tie(NULL); \ cout.tie(NULL) #define test \ int t; \ cin >> t; \ while (t--) #define inp(n) \ int n; \ cin >> n; #define mp make_pair #define pb push_back #define forl(i, a, b) for (ll i = a; i < b; i++) #define x first #define y second using namespace std; ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } int32_t main() { fast; // test // { // // } string a; cin >> a; ll ans = 1; ll i; for (i = 1; i < a.length(); i++) { if (a[i] == a[i - 1]) { if (i <= a.length() - 2) { i += 2; ans += 2; } else break; } else ans++; } if (i == a.length() - 2) { ans++; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define ll long long #define int long long #define MOD 1000000007 #define MAX 500005 #include <iomanip> #define fast \ ios_base ::sync_with_stdio(0); \ cin.tie(NULL); \ cout.tie(NULL) #define test \ int t; \ cin >> t; \ while (t--) #define inp(n) \ int n; \ cin >> n; #define mp make_pair #define pb push_back #define forl(i, a, b) for (ll i = a; i < b; i++) #define x first #define y second using namespace std; ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } int32_t main() { fast; // test // { // // } string a; cin >> a; ll ans = 1; ll i; for (i = 1; i < a.length(); i++) { if (a[i] == a[i - 1]) { if (i < a.length() - 2) { i += 2; ans += 2; } else break; } else ans++; } if (i == a.length() - 2) { ans++; } cout << ans << endl; return 0; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
741,422
741,423
u677600881
cpp
p02939
#include <iostream> #include <string.h> using namespace std; int main() { string word; int length, poz = 0, numberOfStrings = 0, weHaveAStringWith3 = 0, jumpOver; cin >> word; length = word.length() - 1; while (poz <= length - 1) { poz++; numberOfStrings++; if (word[poz] != word[poz + 1]) { // numberOfStrings++; } else { // numberOfStrings++; if (weHaveAStringWith3 == 0) { weHaveAStringWith3 = 1; poz++; } else { weHaveAStringWith3 = 0; } continue; jumpOver = 0; numberOfStrings--; } if (jumpOver == 1) { weHaveAStringWith3 = 0; } } cout << numberOfStrings; return 0; }
#include <iostream> #include <string.h> using namespace std; int main() { string word; int length, poz = -1, numberOfStrings = 0, weHaveAStringWith3 = 0, jumpOver; cin >> word; length = word.length() - 1; while (poz <= length - 1) { poz++; numberOfStrings++; jumpOver = 1; if (word[poz] != word[poz + 1]) { // numberOfStrings++; } else { // numberOfStrings++; if (weHaveAStringWith3 == 0) { weHaveAStringWith3 = 1; poz++; } else { weHaveAStringWith3 = 0; } continue; jumpOver = 0; numberOfStrings--; } if (jumpOver == 1) { weHaveAStringWith3 = 0; } } cout << numberOfStrings; return 0; }
[ "literal.number.change", "variable_declaration.value.change", "assignment.add" ]
741,424
741,425
u189233751
cpp
p02939
#include <cstring> #include <fstream> #define nmax 200005 using namespace std; char s[nmax]; int dp[nmax][2]; int main() { int i, j; scanf("%s", &s); int n = strlen(s); if (n == 1) { printf("1\n"); return 0; } dp[0][0] = 1; dp[1][1] = 1; if (s[0] != s[1]) dp[1][0] = 1; for (i = 2; i < n; i++) { dp[i][0] = dp[i - 1][1] + 1; if (s[i] != s[i - 1]) dp[i][0] = max(dp[i][0], dp[i - 1][0] + 1); dp[i][1] = dp[i - 2][0] + 1; if (s[i] != s[i - 2] || s[i - 1] != s[i - 3]) dp[i][1] = max(dp[i][1], dp[i - 2][1] + 1); } printf("%d", max(dp[n - 1][0], dp[n - 1][1])); return 0; }
#include <cstring> #include <fstream> #define nmax 200005 using namespace std; char s[nmax]; int dp[nmax][2]; int main() { int i, j; scanf("%s", &s); int n = strlen(s); if (n == 1) { printf("1\n"); return 0; } dp[0][0] = 1; dp[1][1] = 1; if (s[0] != s[1]) dp[1][0] = 2; for (i = 2; i < n; i++) { dp[i][0] = dp[i - 1][1] + 1; if (s[i] != s[i - 1]) dp[i][0] = max(dp[i][0], dp[i - 1][0] + 1); dp[i][1] = dp[i - 2][0] + 1; if (s[i] != s[i - 2] || s[i - 1] != s[i - 3]) dp[i][1] = max(dp[i][1], dp[i - 2][1] + 1); } printf("%d", max(dp[n - 1][0], dp[n - 1][1])); return 0; }
[ "literal.number.change", "assignment.value.change" ]
741,426
741,427
u090950285
cpp
p02939
#include <cstring> #include <fstream> #define nmax 200005 using namespace std; char s[nmax]; int dp[nmax][2]; int main() { int i, j; scanf("%s", &s); int n = strlen(s); if (n == 1) { printf("1\n"); return 0; } dp[0][0] = 1; dp[1][1] = 1; if (s[0] != s[1]) dp[1][0] = 1; for (i = 2; i < n; i++) { dp[i][0] = dp[i - 1][1] + 1; if (s[i] != s[i - 1]) dp[i][0] = max(dp[i][0], dp[i - 1][0] + 1); dp[i][1] = dp[i - 2][0] + 1; if (s[i] != s[i - 2] || s[i - 1] != s[i - 3]) dp[i][1] = max(dp[i][1], dp[i - 2][0] + 1); } printf("%d", max(dp[n - 1][0], dp[n - 1][1])); return 0; }
#include <cstring> #include <fstream> #define nmax 200005 using namespace std; char s[nmax]; int dp[nmax][2]; int main() { int i, j; scanf("%s", &s); int n = strlen(s); if (n == 1) { printf("1\n"); return 0; } dp[0][0] = 1; dp[1][1] = 1; if (s[0] != s[1]) dp[1][0] = 2; for (i = 2; i < n; i++) { dp[i][0] = dp[i - 1][1] + 1; if (s[i] != s[i - 1]) dp[i][0] = max(dp[i][0], dp[i - 1][0] + 1); dp[i][1] = dp[i - 2][0] + 1; if (s[i] != s[i - 2] || s[i - 1] != s[i - 3]) dp[i][1] = max(dp[i][1], dp[i - 2][1] + 1); } printf("%d", max(dp[n - 1][0], dp[n - 1][1])); return 0; }
[ "literal.number.change", "assignment.value.change", "variable_access.subscript.index.change", "call.arguments.change", "expression.operation.binary.change" ]
741,428
741,427
u090950285
cpp
p02939
#include <algorithm> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <math.h> #include <numeric> #include <queue> #include <stack> #include <string> #include <tuple> #include <vector> using namespace std; typedef long long LL; typedef unsigned long long ULL; typedef vector<LL> VLL; typedef vector<ULL> VULL; typedef vector<VLL> VVLL; class Large_Integer { private: // n進数 static const LL shinsuu = 7; //符号付絶対値で表現 LL sign; VLL numbers; //補数表現された整数の足し算 static VLL plusVector(VLL a, VLL b) { VLL ans(max(a.size(), b.size()), 0); for (LL i = 0; i < ans.size(); i++) { if (i < a.size()) ans[i] += a[i]; if (i < b.size()) ans[i] += b[i]; if (i + 1 < ans.size()) { ans[i + 1] += (ans[i] / Large_Integer::shinsuu); } ans[i] %= Large_Integer::shinsuu; } return ans; } //符号付絶対値を補数表現に変換 static VLL ToVLL(Large_Integer const &a, LL const &min) { LL i; VLL ans; if (a.sign == 1) { ans = VLL(max(min, (LL)a.numbers.size()) + 5, 0); for (i = 0; i < a.numbers.size(); i++) { ans[i] += a.numbers[i]; } } else { ans = VLL(max(min, (LL)a.numbers.size()) + 5, Large_Integer::shinsuu - 1); for (i = 0; i < a.numbers.size(); i++) { ans[i] -= a.numbers[i]; } ans = Large_Integer::plusVector(ans, VLL(1, 1)); } return ans; } //補数表現を符号付き絶対値に変換 static Large_Integer ToInteger(VLL const &a) { Large_Integer ans; LL i, j, k, n; n = a.size(); if (a[n - 1] == Large_Integer::shinsuu - 1) { auto temp = VLL(n, Large_Integer::shinsuu - 1); temp = Large_Integer::plusVector(a, temp); //ここから for (i = 0; i < temp.size(); i++) { temp[i] -= Large_Integer::shinsuu; temp[i] *= -1; } ans.sign = -1; ans.numbers = temp; ans.Syusei(); } else { ans.sign = 1; ans.numbers = a; ans.Syusei(); } return ans; } //シフト演算子 Large_Integer operator<<(Large_Integer const &a) const { LL shift = a.to_LongLong(), i; if (shift < 0) { return *this >> (shift * -1); } Large_Integer ans = *this; ans.numbers = VLL(this->numbers.size() + shift, 0); for (i = 0; i < this->numbers.size(); i++) { ans.numbers[i + shift] += this->numbers[i]; } ans.Syusei(); return ans; } Large_Integer operator>>(Large_Integer const &a) const { LL shift = a.to_LongLong(), i; if (shift < 0) { return *this << (shift * -1); } Large_Integer ans = *this; ans.numbers = VLL(max((LL)0, (LL)this->numbers.size() - shift), 0); for (i = 0; i < this->numbers.size(); i++) { if (i - shift >= 0) { ans.numbers[i - shift] = this->numbers[i]; } } ans.Syusei(); return ans; } //掛け算(long long) Large_Integer operator*(LL const &b) const { Large_Integer ans; ans.sign = this->sign; ans.numbers = VLL(this->numbers.size() + 2, 0); LL i, a = b; if (a < 0) { a *= -1; ans.sign *= -1; } for (i = 0; i < this->numbers.size(); i++) { ans.numbers[i] = a * this->numbers[i]; } for (i = 0; i < ans.numbers.size(); i++) { if (i + 1 < ans.numbers.size()) { ans.numbers[i + 1] = (ans.numbers[i] / Large_Integer::shinsuu); } ans.numbers[i] %= Large_Integer::shinsuu; } return ans; } //誤りの検知と修正 void Syusei() { LL i, j, k; if (abs(this->sign) != 1) { j = 0; j = 1 / j; } k = 0; for (i = 0; i < this->numbers.size(); i++) { if (this->numbers[i] < 0) { j = 0; j = 1 / j; } if (i + 1 < this->numbers.size()) { this->numbers[i + 1] += (this->numbers[i] / Large_Integer::shinsuu); } this->numbers[i] %= Large_Integer::shinsuu; if (this->numbers[i] > 0) k = i + 1; } VLL ans(k, 0); for (i = 0; i < k; i++) { ans[i] = this->numbers[i]; } this->numbers = ans; if (this->sign == -1 && this->numbers.size() == 0) { this->sign = 1; } } public: //コンストラクタたち Large_Integer(Large_Integer const &b) { *this = b; } Large_Integer(LL const &b) { if (b < 0) this->sign = -1; else this->sign = 1; auto c = abs(b); while (c > 0) { this->numbers.push_back(c % this->shinsuu); c /= this->shinsuu; } this->Syusei(); } Large_Integer() { this->sign = 1; this->numbers = VLL(0); } // long long型に変換する LL to_LongLong() const { LL ans = 0, i; for (i = this->numbers.size() - 1; i >= 0; i--) { ans *= this->shinsuu; ans += this->numbers[i]; } ans *= this->sign; return ans; } //代入演算子 Large_Integer operator=(Large_Integer const &b) { this->sign = b.sign; this->numbers = b.numbers; return *this; } //足し算 Large_Integer operator+(Large_Integer const &b) const { LL i, j; VLL x, y; LL size = max(this->numbers.size(), b.numbers.size()); x = Large_Integer::ToVLL(*this, size); y = Large_Integer::ToVLL(b, size); x = Large_Integer::plusVector(x, y); auto ans = Large_Integer::ToInteger(x); ans.Syusei(); return ans; } Large_Integer operator+=(Large_Integer const &b) { return *this = (*this + b); } //掛け算 Large_Integer operator*(Large_Integer const &b) const { Large_Integer ans = 0; LL i; for (i = 0; i < b.numbers.size(); i++) { ans += ((*this * b.numbers[i]) << i); } return ans; } Large_Integer operator*=(Large_Integer const &b) { return *this = (*this * b); } Large_Integer operator-(Large_Integer const &b) const { return *this + (b * -1); } Large_Integer operator-=(Large_Integer const &b) { return *this = (*this - b); } //未完成 bool operator<(Large_Integer const &b) const { LL i, j, k; if (this->sign < b.sign) { return true; } if (this->sign > b.sign) { return false; } if (this->sign == 1) { if (this->numbers.size() < b.numbers.size()) { return true; } if (this->numbers.size() > b.numbers.size()) { return false; } for (i = this->numbers.size() - 1; i >= 0; i--) { if (this->numbers[i] < b.numbers[i]) { return true; } if (this->numbers[i] > b.numbers[i]) { return false; } } } } }; //改良vector template <typename T> class ArrayList : public vector<T> { public: ArrayList(long long const &size, T const &a) : vector<T>(size, a) {} ArrayList(long long const &size) : vector<T>(size) {} ArrayList() : vector<T>() {} T &operator[](long long const &index) { return vector<T>::at(index); } }; typedef ArrayList<LL> ALL; typedef ArrayList<ALL> AALL; //剰余整数 class ModInt { private: LL n; static LL modP; public: ModInt(ModInt const &b) { this->n = b.n; } ModInt(LL const &b) { this->n = b % ModInt::modP; } ModInt() { *this = ModInt(0); } LL GetMod() const { return ModInt::modP; } void SetMod(LL const &a) { ModInt::modP = abs(a); } LL getNumber() const { return this->n; } ModInt operator=(ModInt const &b) { this->n = b.n; return *this; } ModInt operator+(ModInt const &b) const { return ModInt(this->n + b.n); } ModInt operator+=(ModInt const &b) { return *this = (*this + b); } ModInt operator-(ModInt const &b) const { LL temp = this->n - b.n + ModInt::modP; return ModInt(temp); } ModInt operator-=(ModInt const &b) { return *this = (*this - b); } ModInt operator*(ModInt const &b) const { LL temp = this->n * b.n; return ModInt(temp); } ModInt operator*=(ModInt const &b) { return *this = (*this * b); } ModInt Pow(ModInt const &b) const { LL p = b.n; ModInt ans = 1; ModInt x = *this; while (p > 0) { if (p % 2 == 1) { ans *= x; } x = x * x; p /= 2; } return ans; } ModInt operator/(ModInt const &b) const { ModInt temp = b.Pow(ModInt::modP - 2); return *this * temp; } ModInt operator/=(ModInt const &b) { return *this = (*this / b); } }; LL ModInt::modP = 1000 * 1000 * 1000 + 7; //関数詰め合わせ class KyoPro { public: static const LL MOD_CONST = (LL)1000 * 1000 * 1000 + 7; static LL DebugFlag; //数値を区切って文字列にする static string MakeString_LongLong(vector<long long> const &numbers, string const &str) { if (numbers.size() == 0) return ""; string result = "" + to_string(numbers[0]); for (long long i = 1; i < numbers.size(); i++) { result += str; result += to_string(numbers[i]); } return result; } //空白で区切る為のオーバーロード static string MakeString_LongLong(vector<long long> const &numbers) { if (numbers.size() == 0) return ""; string result = "" + to_string(numbers[0]); for (long long i = 1; i < numbers.size(); i++) { result += " "; result += to_string(numbers[i]); } return result; } //文字列の配列を改行を挟んでまとめる static string MakeString_VectorString(vector<string> const &str) { string result = ""; for (long long i = 0; i < str.size(); i++) { result += str[i] + "\n"; } return result; } //文字列を必要な個数だけ読み取る static vector<string> MyReadLineSplit(LL n) { vector<string> str(n); for (long long i = 0; i < n; i++) { std::cin >> str[i]; } return str; } //数値を必要な個数だけ読み取る static vector<long long> ReadInts(long long number) { vector<long long> a(number); for (int i = 0; i < number; i++) { std::cin >> a[i]; } return a; } //渡された自然数が素数ならtureを返す static bool PrimeCheck_Int(long long number) { if (number < 2) return false; for (ULL i = 2; i * i <= number; i++) { if (number % i == 0) return false; } return true; } //自然数が平方数か判定する static bool SquareCheck(LL const &number) { if (KyoPro::PrimeCheck_Int(number)) return false; LL m = number; for (LL i = 2; i <= m; i++) { if (m % i == 0) { LL count = 0; while (m % i == 0) { m /= i; count++; } if (count % 2 == 1) return false; } } return true; } //渡された数値以下の素数表を作る static vector<long long> MakePrimeList(long long n) { vector<long long> list; LL i, j, p; bool flag; for (i = 2; i <= n; i++) { flag = true; for (j = 0; j < list.size(); j++) { if (!(list[j] * list[j] <= i)) break; if (i % list[j] == 0) { flag = false; break; } } if (flag) list.push_back(i); } return list; } //文字列の分割 static vector<string> split(string const &str, char sep) { vector<std::string> v; // 分割結果を格納するベクター auto first = str.begin(); // テキストの最初を指すイテレータ while (first != str.end()) { // テキストが残っている間ループ auto last = first; // 分割文字列末尾へのイテレータ while (last != str.end() && *last != sep) // 末尾 or セパレータ文字まで進める last++; v.push_back(string(first, last)); // 分割文字を出力 if (last != str.end()) last++; first = last; // 次の処理のためにイテレータを設定 } return v; } //合計を求める template <typename T> static LL Sum(T const &a) { LL sum = 0; auto itr = a.begin(); while (itr != a.end()) { sum += (*itr); itr++; } return sum; } //小文字ならtrueを返す static bool Komoji(char a) { if (a >= 'a' && a <= 'z') return true; return false; } //大文字ならtrueを返す static bool Oomoji(char a) { if (a >= 'A' && a <= 'Z') return true; return false; } //切り上げの整数値割り算 static LL KiriageWarizan(LL a, LL b) { LL result = a / b; if (a % b > 0) result++; return result; } //最大公約数を求める static LL GreatestCommonFactor(LL a, LL b) { a = KyoPro::abs(a); b = KyoPro::abs(b); LL temp; if (a < b) { temp = b; b = a; a = temp; } while (b > 0) { temp = a % b; a = b; b = temp; } return a; } //最小公倍数を求める static LL LeastCommonMultiple(LL a, LL b) { return (a / GreatestCommonFactor(a, b)) * b; } //二次元配列を行列とみなして転置する static VVLL VVLLturn(VVLL a) { if (a.size() == 0) return VVLL(0); VVLL result(a[0].size(), VLL(a.size())); LL i, j; for (i = 0; i < a.size(); i++) { for (j = 0; j < a[0].size(); j++) { result[j][i] = a[i][j]; } } return result; } //素因数分解、素数、指数の順 static vector<VLL> PrimeFactorization(LL n) { VLL p_list, s_list; LL i, j, k, count; for (i = 2; n > 1; i++) { if (i * i > n) { p_list.push_back(n); s_list.push_back(1); break; } if (n % i == 0) { count = 0; while (n % i == 0) { n /= i; count++; } p_list.push_back(i); s_list.push_back(count); } } vector<VLL> result; result.push_back(p_list); result.push_back(s_list); return KyoPro::VVLLturn(result); } //整数nの約数の配列を作る static VLL MakeYakusuList(LL n) { auto primes = KyoPro::PrimeFactorization(n); VLL ans; VLL roop(primes.size(), 0); LL i, j, k, m, size = roop.size(); while (true) { LL a = 1; for (i = 0; i < size; i++) { for (j = 0; j < roop[i]; j++) { a *= primes[i][0]; } } ans.push_back(a); roop[0]++; for (i = 0; i < size; i++) { if (i + 1 < size) { roop[i + 1] += (roop[i] / (primes[i][1] + 1)); } roop[i] %= (primes[i][1] + 1); } bool flag = true; for (i = 0; i < size; i++) { if (roop[i] != 0) flag = false; } if (flag) break; } return KyoPro::Sort(ans); } //組み合わせ nCrを10^9+7で割った余りを返す static LL Combination(LL n, LL r) { ModInt ans = 1; r = min(r, n - r); for (LL i = 0; i < r; i++) { ans *= (n - i); ans /= (i + 1); } return ans.getNumber(); } //順列 nPrを10^9+7で割った余りを返す static LL Permutation(LL n, LL r) { ModInt ans = 1; for (LL i = 0; i < r; i++) { ans *= (n - i); } return ans.getNumber(); } //重複組み合わせ。n種類からr個重複を許して選ぶ static LL nHr(LL n, LL r) { return KyoPro::Combination(n + r - 1, r); } template <typename T> static T pow(T const &a, LL const &b) { T ans = 1; auto p = b; auto x = a; while (p > 0) { if (p % 2 == 1) { ans *= x; } x = x * x; p /= 2; } return ans; } //符号 template <typename T> static T sign(T const &x) { if (x > 0) return 1; if (x < 0) return -1; return 0; } //絶対値 template <typename T> static T abs(T x) { if (x < 0) { x = x * -1; } return x; } //円周率 static double PI() { return (double)3.1415926535898; } //指定した桁でdoubleを出す。改行はしない。 static void CoutDoubleKeta(double a, LL keta) { cout << setprecision(keta) << a << flush; } //コンテナクラスの出力 template <typename T> static T CoutVector(T const &ls) { LL i, j, k, size = distance(ls.begin(), ls.end()); if (size == 0) return ls; auto itr = ls.begin(); for (i = 0; i < size - 1; i++) { cout << *itr << " " << flush; itr++; } cout << *itr << flush; return ls; } //コンテナクラスをソートする template <typename T> static T Sort(T &ls) { sort(ls.begin(), ls.end()); return ls; } //順序関数付きでコンテナクラスをソートする template <typename T, typename F> static T Sort(T &ls, F const &func) { sort(ls.begin(), ls.end(), func); return ls; } //コンテナクラスを逆順に並び替える template <typename T> static T Reverse(T &ls) { reverse(ls.begin(), ls.end()); return ls; } //コンテナクラスの条件を満たす要素を数え上げる。bool func(S x) template <typename T, typename S> static LL Count(T const &ls, S func) { LL ans = 0; auto itr = ls.begin(); while (itr != ls.end()) { if (func(*itr)) ans++; itr++; } return ans; } //コンテナクラスの要素をすべて更新する。S func(S x) template <typename T, typename S> static T AllUpdate(T &ls, S func) { auto itr = ls.begin(); while (itr != ls.end()) { *itr = func(*itr); itr++; } return ls; } //リストをベクターに変換する template <typename T> static vector<T> FromListToVector(list<T> const &a) { vector<T> ans; for (auto itr = a.begin(); itr != a.end(); itr++) { ans.push_back(*itr); } return ans; } //ベクターをリストに変換する template <typename T> static list<T> FromVectorToList(vector<T> a) { list<T> ans; for (auto itr = a.begin(); itr != a.end(); itr++) { ans.push_back(*itr); } return ans; } //最大値の要素番号を求める template <typename T> static LL MaxElementIndex(T const &ls) { return distance(ls.begin(), max_element(ls.begin(), ls.end())); } //最小値の要素番号を求める template <typename T> static LL MinElementIndex(T const &ls) { return distance(ls.begin(), min_element(ls.begin(), ls.end())); } //デバッグ用出力 template <typename T> static LL DebugPrintf(T output) { if (KyoPro::DebugFlag) { std::cout << output << endl; } return KyoPro::DebugFlag; } //デバッグ用入力 static LL DebugCin() { LL a; if (KyoPro::DebugFlag) { cin >> a; } return a; } }; LL KyoPro::DebugFlag = 0; //累積和を求めるクラス class Ruisekiwa { private: vector<LL> list; public: void MakeArray(vector<LL> data) { LL i; list = data; list.push_back(0); list[0] = 0; for (i = 1; i < list.size(); i++) { list[i] = list[i - 1] + data[i - 1]; } } LL Sum(LL start, LL end) { if (end < start) { std::cout << "startがendより大きいです"; return 0; } if (start < 0 || end >= list.size()) { std::cout << "範囲が異常"; return 0; } return list[end] - list[start]; } }; // n進数を管理するクラス class N_Number { public: N_Number(LL n, LL keta) { this->N_Shinsuu = n; VLL temp(keta, 0); this->numbers = temp; } //数を足す void plus(LL a) { if (a < 0) { a *= (-1); this->minus(a); return; } this->numbers[0] += a; LL size = this->numbers.size(); for (LL i = 0; i < size; i++) { if (i + 1 < size) { this->numbers[i + 1] += this->numbers[i] / this->N_Shinsuu; } this->numbers[i] %= this->N_Shinsuu; } } //全ての桁が同じ数字になっていればその数字を返す。それ以外の場合は -1 を返す LL check() { LL a = this->numbers[0]; for (LL i = 0; i < this->numbers.size(); i++) { if (this->numbers[i] != a) return -1; } return a; } LL getNumber(LL keta) { return this->numbers[keta]; } LL getKeta() { return this->numbers.size(); } LL getShinsuu() { return this->N_Shinsuu; } void setNumber(LL keta, LL number) { if (0 <= number && number < this->getShinsuu()) { if (0 <= keta && keta < this->getKeta()) { this->numbers[keta] = number; return; } } cout << "er" << endl; } void setAllNumbers(LL number) { LL size = this->getKeta(), i; for (i = 0; i < size; i++) { this->setNumber(i, number); } } string to_string_KetaSoroe() { string s = ""; for (LL i = this->getKeta() - 1; i >= 0; i--) { s += to_string(this->getNumber(i)); } return s; } private: void minus(LL a) { LL i, j, k, zettaiti = abs(a); k = KyoPro::KiriageWarizan(zettaiti, this->N_Shinsuu); j = k * (this->N_Shinsuu - 1); for (i = 0; i < this->getKeta(); i++) { this->numbers[i] += j; } this->numbers[0] += k - a; this->plus(0); } VLL numbers; LL N_Shinsuu; }; // UnionFind class Union_Find { private: VLL tree; VLL count; LL root(LL a) { if (this->tree[a] == a) return a; return this->tree[a] = this->root(this->tree[a]); } public: Union_Find(LL n) { VLL set(n); this->tree = set; this->count = set; for (LL i = 0; i < n; i++) { this->tree[i] = i; this->count[i] = 1; } } void unite(LL a, LL b) { LL x, y; if (!this->Check(a, b)) { x = this->getCount(a) + getCount(b); y = this->root(a); this->count[y] = x; y = this->root(b); this->count[y] = x; } x = this->root(a); y = this->root(b); this->tree[x] = y; } bool Check(LL a, LL b) { return this->root(a) == this->root(b); } LL getCount(LL index) { LL temp = this->root(index); return this->count[temp]; } LL getRoot(LL index) { return this->root(index); } VLL getList() { VLL ans(this->tree.size(), 0); for (LL i = 0; i < ans.size(); i++) { ans[i] = this->root(i); } return ans; } }; //プラスマイナス無限に対応したlong long型 class INF_LONG_LONG { private: LL inf, n; public: //コンストラクタ INF_LONG_LONG(LL a) { this->n = a; this->inf = 0; this->Syusei(); } INF_LONG_LONG() { *this = INF_LONG_LONG(0); } INF_LONG_LONG(INF_LONG_LONG const &a) { this->n = a.n; this->inf = a.inf; this->Syusei(); } //ゲッター LL getN() const { return this->n; } LL getInf() const { return this->inf; } //正の無限大生成 static INF_LONG_LONG plus_inf() { INF_LONG_LONG a; a.n = 0; a.inf = 1; a.Syusei(); return a; } //負の無限大生成 static INF_LONG_LONG minus_inf() { INF_LONG_LONG a; a.n = 0; a.inf = -1; a.Syusei(); return a; } //符号を取得 LL sign() const { if (this->inf != 0) { return this->inf; } return KyoPro::sign(this->n); } //代入演算子 INF_LONG_LONG operator=(INF_LONG_LONG const &b) { this->n = b.n; this->inf = b.inf; this->Syusei(); return *this; } INF_LONG_LONG operator=(LL const &b) { *this = INF_LONG_LONG(b); this->Syusei(); return *this; } //比較演算子 bool operator==(INF_LONG_LONG const &b) const { if (this->n == b.n && this->inf == b.inf) return true; return false; } bool operator!=(INF_LONG_LONG const &b) const { return !(*this == b); } bool operator<(INF_LONG_LONG const &b) const { if (this->inf < b.inf) return true; if (this->inf > b.inf) return false; return this->n < b.n; } bool operator>(INF_LONG_LONG const &b) const { return b < *this; } bool operator<=(INF_LONG_LONG const &b) const { return !(*this > b); } bool operator>=(INF_LONG_LONG const &b) const { return !(*this < b); } //算術演算子 INF_LONG_LONG operator+(INF_LONG_LONG const &b) const { if (max(this->inf, b.inf) > 0) return INF_LONG_LONG::plus_inf(); if (min(this->inf, b.inf) < 0) return INF_LONG_LONG::minus_inf(); auto ans = *this; ans.n += b.n; ans.Syusei(); return ans; } INF_LONG_LONG operator*(INF_LONG_LONG const &b) const { if (*this == INF_LONG_LONG(0) || b == INF_LONG_LONG(0)) { return INF_LONG_LONG(0); } if (this->inf != 0 || b.inf != 0) { LL s = this->sign() * b.sign(); INF_LONG_LONG ans(0); ans.n = 0; ans.inf = s; ans.Syusei(); return ans; } INF_LONG_LONG ans(0); ans.n = this->n * b.n; ans.Syusei(); return ans; } INF_LONG_LONG operator-(INF_LONG_LONG const &b) const { auto ans = (*this + (INF_LONG_LONG(-1) * b)); ans.Syusei(); return ans; } INF_LONG_LONG operator/(INF_LONG_LONG const &b) const { if (b == INF_LONG_LONG(0)) { LL a = this->n / b.n; return INF_LONG_LONG(a); } if (b.inf != 0) { return INF_LONG_LONG(0); } if (*this == INF_LONG_LONG(0)) { return INF_LONG_LONG(0); } if (this->inf != 0) { LL s = this->sign() * b.sign(); return INF_LONG_LONG::plus_inf() * INF_LONG_LONG(s); } INF_LONG_LONG ans; ans.n = this->n / b.n; ans.Syusei(); return ans; } INF_LONG_LONG operator%(INF_LONG_LONG const &b) const { if (this->inf == 0 && b.inf == 0) { INF_LONG_LONG ans; ans.n = this->n % b.n; ans.Syusei(); return ans; } auto x = *this / b; x.Syusei(); auto ans = *this - b * x; ans.Syusei(); return ans; } //複合代入演算子 INF_LONG_LONG operator+=(INF_LONG_LONG const &b) { auto ans = *this + b; *this = ans; return *this; } INF_LONG_LONG operator-=(INF_LONG_LONG const &b) { auto ans = *this - b; *this = ans; return *this; } INF_LONG_LONG operator*=(INF_LONG_LONG const &b) { auto ans = *this * b; *this = ans; return *this; } INF_LONG_LONG operator/=(INF_LONG_LONG const &b) { auto ans = *this / b; *this = ans; return *this; } INF_LONG_LONG operator%=(INF_LONG_LONG const &b) { auto ans = *this % b; *this = ans; return *this; } //符号演算子 INF_LONG_LONG operator+() const { return *this; } INF_LONG_LONG operator-() const { return *this * INF_LONG_LONG(-1); } //前置きインクリメント・デクリメント INF_LONG_LONG operator++() { this->n++; this->Syusei(); return *this; } INF_LONG_LONG operator--() { this->n--; this->Syusei(); return *this; } //後置きインクリメント・デクリメント INF_LONG_LONG operator++(int) { auto copy = *this; ++(*this); return copy; } INF_LONG_LONG operator--(int) { auto copy = *this; --(*this); return copy; } //文字列への変換 string ToString() const { if (this->inf == 1) { return "+INF"; } if (this->inf == -1) { return "-INF"; } return to_string(this->n); } private: void Syusei() { if (this->inf != 0) { this->n = 0; } } }; typedef INF_LONG_LONG ILL_TYPE; typedef vector<ILL_TYPE> VILL_TYPE; typedef vector<VILL_TYPE> VVILL_TYPE; //ワーシャルフロイド class WarshallFloyd { public: //最短距離を記録 VVILL_TYPE d; //頂点数 LL v; // vは頂点数、edge_cost_listは辺の情報{始点、終点、コスト}の配列。無向グラフの場合、逆矢印の辺に注意。 WarshallFloyd(LL v, VVLL edge_cost_list) { this->v = v; this->d = VVILL_TYPE(v, VILL_TYPE(v, ILL_TYPE::plus_inf())); LL i, j, k, a, b, c; for (i = 0; i < edge_cost_list.size(); i++) { a = edge_cost_list[i][0]; b = edge_cost_list[i][1]; c = edge_cost_list[i][2]; this->d[a][b] = ILL_TYPE(c); } for (i = 0; i < v; i++) { this->d[i][i] = ILL_TYPE(0); } //ここから計算 for (k = 0; k < v; k++) { for (i = 0; i < v; i++) { for (j = 0; j < v; j++) { d[i][j] = min(d[i][j], d[i][k] + d[k][j]); } } } } }; //ベルマンフォード class BellmanFord { public: //辺のリスト VVILL_TYPE edge; //頂点数、辺数 LL v, e; //始点 LL s; //最短距離 VILL_TYPE d; // vは頂点数、startは始点、edge_cost_listは辺の情報{始点、終点、コスト}の配列。 BellmanFord(LL v, LL start, VVLL edge_cost_list) { this->v = v; this->s = start; this->e = edge_cost_list.size(); this->d = VILL_TYPE(v, ILL_TYPE::plus_inf()); this->d[start] = 0; LL i, j, k; for (i = 0; i < this->e; i++) { VILL_TYPE temp; LL a, b, c; a = edge_cost_list[i][0]; b = edge_cost_list[i][1]; c = edge_cost_list[i][2]; temp.push_back(ILL_TYPE(a)); temp.push_back(ILL_TYPE(b)); temp.push_back(ILL_TYPE(c)); this->edge.push_back(temp); } this->DoUpdata(); auto cpy = this->d; this->DoUpdata(); for (i = 0; i < this->d.size(); i++) { if (this->d[i] != cpy[i]) { this->d[i] = ILL_TYPE::minus_inf(); } } this->DoUpdata(); } private: void DoUpdata() { LL i, j, k; for (i = 0; i <= this->v; i++) { bool update = true; for (j = 0; j < this->e; j++) { ILL_TYPE c; LL a, b; a = this->edge[j][0].getN(); b = this->edge[j][1].getN(); c = this->edge[j][2]; if (this->d[a] < ILL_TYPE::plus_inf()) { if (this->d[a] + c < this->d[b]) { update = false; this->d[b] = this->d[a] + c; } } } if (update) break; } } }; //ダイクストラ class Dijkstra { public: Dijkstra(LL v, LL start, VVLL edge_cost_list) {} }; //ライブラリはここまで //ここから下を書く //ここからメイン int main(void) { KyoPro::DebugFlag = 0; LL i, j, k, n, m; LL count = 0; string s; string a, b; a = ""; i = 0; while (i < s.size()) { b = s.substr(i, 1); if (a == b) { if (i + 1 == s.size()) { break; } b = s.substr(i, 2); count++; i += 2; } else { count++; i++; } a = b; } cout << count << endl; return 0; }
#include <algorithm> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <math.h> #include <numeric> #include <queue> #include <stack> #include <string> #include <tuple> #include <vector> using namespace std; typedef long long LL; typedef unsigned long long ULL; typedef vector<LL> VLL; typedef vector<ULL> VULL; typedef vector<VLL> VVLL; class Large_Integer { private: // n進数 static const LL shinsuu = 7; //符号付絶対値で表現 LL sign; VLL numbers; //補数表現された整数の足し算 static VLL plusVector(VLL a, VLL b) { VLL ans(max(a.size(), b.size()), 0); for (LL i = 0; i < ans.size(); i++) { if (i < a.size()) ans[i] += a[i]; if (i < b.size()) ans[i] += b[i]; if (i + 1 < ans.size()) { ans[i + 1] += (ans[i] / Large_Integer::shinsuu); } ans[i] %= Large_Integer::shinsuu; } return ans; } //符号付絶対値を補数表現に変換 static VLL ToVLL(Large_Integer const &a, LL const &min) { LL i; VLL ans; if (a.sign == 1) { ans = VLL(max(min, (LL)a.numbers.size()) + 5, 0); for (i = 0; i < a.numbers.size(); i++) { ans[i] += a.numbers[i]; } } else { ans = VLL(max(min, (LL)a.numbers.size()) + 5, Large_Integer::shinsuu - 1); for (i = 0; i < a.numbers.size(); i++) { ans[i] -= a.numbers[i]; } ans = Large_Integer::plusVector(ans, VLL(1, 1)); } return ans; } //補数表現を符号付き絶対値に変換 static Large_Integer ToInteger(VLL const &a) { Large_Integer ans; LL i, j, k, n; n = a.size(); if (a[n - 1] == Large_Integer::shinsuu - 1) { auto temp = VLL(n, Large_Integer::shinsuu - 1); temp = Large_Integer::plusVector(a, temp); //ここから for (i = 0; i < temp.size(); i++) { temp[i] -= Large_Integer::shinsuu; temp[i] *= -1; } ans.sign = -1; ans.numbers = temp; ans.Syusei(); } else { ans.sign = 1; ans.numbers = a; ans.Syusei(); } return ans; } //シフト演算子 Large_Integer operator<<(Large_Integer const &a) const { LL shift = a.to_LongLong(), i; if (shift < 0) { return *this >> (shift * -1); } Large_Integer ans = *this; ans.numbers = VLL(this->numbers.size() + shift, 0); for (i = 0; i < this->numbers.size(); i++) { ans.numbers[i + shift] += this->numbers[i]; } ans.Syusei(); return ans; } Large_Integer operator>>(Large_Integer const &a) const { LL shift = a.to_LongLong(), i; if (shift < 0) { return *this << (shift * -1); } Large_Integer ans = *this; ans.numbers = VLL(max((LL)0, (LL)this->numbers.size() - shift), 0); for (i = 0; i < this->numbers.size(); i++) { if (i - shift >= 0) { ans.numbers[i - shift] = this->numbers[i]; } } ans.Syusei(); return ans; } //掛け算(long long) Large_Integer operator*(LL const &b) const { Large_Integer ans; ans.sign = this->sign; ans.numbers = VLL(this->numbers.size() + 2, 0); LL i, a = b; if (a < 0) { a *= -1; ans.sign *= -1; } for (i = 0; i < this->numbers.size(); i++) { ans.numbers[i] = a * this->numbers[i]; } for (i = 0; i < ans.numbers.size(); i++) { if (i + 1 < ans.numbers.size()) { ans.numbers[i + 1] = (ans.numbers[i] / Large_Integer::shinsuu); } ans.numbers[i] %= Large_Integer::shinsuu; } return ans; } //誤りの検知と修正 void Syusei() { LL i, j, k; if (abs(this->sign) != 1) { j = 0; j = 1 / j; } k = 0; for (i = 0; i < this->numbers.size(); i++) { if (this->numbers[i] < 0) { j = 0; j = 1 / j; } if (i + 1 < this->numbers.size()) { this->numbers[i + 1] += (this->numbers[i] / Large_Integer::shinsuu); } this->numbers[i] %= Large_Integer::shinsuu; if (this->numbers[i] > 0) k = i + 1; } VLL ans(k, 0); for (i = 0; i < k; i++) { ans[i] = this->numbers[i]; } this->numbers = ans; if (this->sign == -1 && this->numbers.size() == 0) { this->sign = 1; } } public: //コンストラクタたち Large_Integer(Large_Integer const &b) { *this = b; } Large_Integer(LL const &b) { if (b < 0) this->sign = -1; else this->sign = 1; auto c = abs(b); while (c > 0) { this->numbers.push_back(c % this->shinsuu); c /= this->shinsuu; } this->Syusei(); } Large_Integer() { this->sign = 1; this->numbers = VLL(0); } // long long型に変換する LL to_LongLong() const { LL ans = 0, i; for (i = this->numbers.size() - 1; i >= 0; i--) { ans *= this->shinsuu; ans += this->numbers[i]; } ans *= this->sign; return ans; } //代入演算子 Large_Integer operator=(Large_Integer const &b) { this->sign = b.sign; this->numbers = b.numbers; return *this; } //足し算 Large_Integer operator+(Large_Integer const &b) const { LL i, j; VLL x, y; LL size = max(this->numbers.size(), b.numbers.size()); x = Large_Integer::ToVLL(*this, size); y = Large_Integer::ToVLL(b, size); x = Large_Integer::plusVector(x, y); auto ans = Large_Integer::ToInteger(x); ans.Syusei(); return ans; } Large_Integer operator+=(Large_Integer const &b) { return *this = (*this + b); } //掛け算 Large_Integer operator*(Large_Integer const &b) const { Large_Integer ans = 0; LL i; for (i = 0; i < b.numbers.size(); i++) { ans += ((*this * b.numbers[i]) << i); } return ans; } Large_Integer operator*=(Large_Integer const &b) { return *this = (*this * b); } Large_Integer operator-(Large_Integer const &b) const { return *this + (b * -1); } Large_Integer operator-=(Large_Integer const &b) { return *this = (*this - b); } //未完成 bool operator<(Large_Integer const &b) const { LL i, j, k; if (this->sign < b.sign) { return true; } if (this->sign > b.sign) { return false; } if (this->sign == 1) { if (this->numbers.size() < b.numbers.size()) { return true; } if (this->numbers.size() > b.numbers.size()) { return false; } for (i = this->numbers.size() - 1; i >= 0; i--) { if (this->numbers[i] < b.numbers[i]) { return true; } if (this->numbers[i] > b.numbers[i]) { return false; } } } } }; //改良vector template <typename T> class ArrayList : public vector<T> { public: ArrayList(long long const &size, T const &a) : vector<T>(size, a) {} ArrayList(long long const &size) : vector<T>(size) {} ArrayList() : vector<T>() {} T &operator[](long long const &index) { return vector<T>::at(index); } }; typedef ArrayList<LL> ALL; typedef ArrayList<ALL> AALL; //剰余整数 class ModInt { private: LL n; static LL modP; public: ModInt(ModInt const &b) { this->n = b.n; } ModInt(LL const &b) { this->n = b % ModInt::modP; } ModInt() { *this = ModInt(0); } LL GetMod() const { return ModInt::modP; } void SetMod(LL const &a) { ModInt::modP = abs(a); } LL getNumber() const { return this->n; } ModInt operator=(ModInt const &b) { this->n = b.n; return *this; } ModInt operator+(ModInt const &b) const { return ModInt(this->n + b.n); } ModInt operator+=(ModInt const &b) { return *this = (*this + b); } ModInt operator-(ModInt const &b) const { LL temp = this->n - b.n + ModInt::modP; return ModInt(temp); } ModInt operator-=(ModInt const &b) { return *this = (*this - b); } ModInt operator*(ModInt const &b) const { LL temp = this->n * b.n; return ModInt(temp); } ModInt operator*=(ModInt const &b) { return *this = (*this * b); } ModInt Pow(ModInt const &b) const { LL p = b.n; ModInt ans = 1; ModInt x = *this; while (p > 0) { if (p % 2 == 1) { ans *= x; } x = x * x; p /= 2; } return ans; } ModInt operator/(ModInt const &b) const { ModInt temp = b.Pow(ModInt::modP - 2); return *this * temp; } ModInt operator/=(ModInt const &b) { return *this = (*this / b); } }; LL ModInt::modP = 1000 * 1000 * 1000 + 7; //関数詰め合わせ class KyoPro { public: static const LL MOD_CONST = (LL)1000 * 1000 * 1000 + 7; static LL DebugFlag; //数値を区切って文字列にする static string MakeString_LongLong(vector<long long> const &numbers, string const &str) { if (numbers.size() == 0) return ""; string result = "" + to_string(numbers[0]); for (long long i = 1; i < numbers.size(); i++) { result += str; result += to_string(numbers[i]); } return result; } //空白で区切る為のオーバーロード static string MakeString_LongLong(vector<long long> const &numbers) { if (numbers.size() == 0) return ""; string result = "" + to_string(numbers[0]); for (long long i = 1; i < numbers.size(); i++) { result += " "; result += to_string(numbers[i]); } return result; } //文字列の配列を改行を挟んでまとめる static string MakeString_VectorString(vector<string> const &str) { string result = ""; for (long long i = 0; i < str.size(); i++) { result += str[i] + "\n"; } return result; } //文字列を必要な個数だけ読み取る static vector<string> MyReadLineSplit(LL n) { vector<string> str(n); for (long long i = 0; i < n; i++) { std::cin >> str[i]; } return str; } //数値を必要な個数だけ読み取る static vector<long long> ReadInts(long long number) { vector<long long> a(number); for (int i = 0; i < number; i++) { std::cin >> a[i]; } return a; } //渡された自然数が素数ならtureを返す static bool PrimeCheck_Int(long long number) { if (number < 2) return false; for (ULL i = 2; i * i <= number; i++) { if (number % i == 0) return false; } return true; } //自然数が平方数か判定する static bool SquareCheck(LL const &number) { if (KyoPro::PrimeCheck_Int(number)) return false; LL m = number; for (LL i = 2; i <= m; i++) { if (m % i == 0) { LL count = 0; while (m % i == 0) { m /= i; count++; } if (count % 2 == 1) return false; } } return true; } //渡された数値以下の素数表を作る static vector<long long> MakePrimeList(long long n) { vector<long long> list; LL i, j, p; bool flag; for (i = 2; i <= n; i++) { flag = true; for (j = 0; j < list.size(); j++) { if (!(list[j] * list[j] <= i)) break; if (i % list[j] == 0) { flag = false; break; } } if (flag) list.push_back(i); } return list; } //文字列の分割 static vector<string> split(string const &str, char sep) { vector<std::string> v; // 分割結果を格納するベクター auto first = str.begin(); // テキストの最初を指すイテレータ while (first != str.end()) { // テキストが残っている間ループ auto last = first; // 分割文字列末尾へのイテレータ while (last != str.end() && *last != sep) // 末尾 or セパレータ文字まで進める last++; v.push_back(string(first, last)); // 分割文字を出力 if (last != str.end()) last++; first = last; // 次の処理のためにイテレータを設定 } return v; } //合計を求める template <typename T> static LL Sum(T const &a) { LL sum = 0; auto itr = a.begin(); while (itr != a.end()) { sum += (*itr); itr++; } return sum; } //小文字ならtrueを返す static bool Komoji(char a) { if (a >= 'a' && a <= 'z') return true; return false; } //大文字ならtrueを返す static bool Oomoji(char a) { if (a >= 'A' && a <= 'Z') return true; return false; } //切り上げの整数値割り算 static LL KiriageWarizan(LL a, LL b) { LL result = a / b; if (a % b > 0) result++; return result; } //最大公約数を求める static LL GreatestCommonFactor(LL a, LL b) { a = KyoPro::abs(a); b = KyoPro::abs(b); LL temp; if (a < b) { temp = b; b = a; a = temp; } while (b > 0) { temp = a % b; a = b; b = temp; } return a; } //最小公倍数を求める static LL LeastCommonMultiple(LL a, LL b) { return (a / GreatestCommonFactor(a, b)) * b; } //二次元配列を行列とみなして転置する static VVLL VVLLturn(VVLL a) { if (a.size() == 0) return VVLL(0); VVLL result(a[0].size(), VLL(a.size())); LL i, j; for (i = 0; i < a.size(); i++) { for (j = 0; j < a[0].size(); j++) { result[j][i] = a[i][j]; } } return result; } //素因数分解、素数、指数の順 static vector<VLL> PrimeFactorization(LL n) { VLL p_list, s_list; LL i, j, k, count; for (i = 2; n > 1; i++) { if (i * i > n) { p_list.push_back(n); s_list.push_back(1); break; } if (n % i == 0) { count = 0; while (n % i == 0) { n /= i; count++; } p_list.push_back(i); s_list.push_back(count); } } vector<VLL> result; result.push_back(p_list); result.push_back(s_list); return KyoPro::VVLLturn(result); } //整数nの約数の配列を作る static VLL MakeYakusuList(LL n) { auto primes = KyoPro::PrimeFactorization(n); VLL ans; VLL roop(primes.size(), 0); LL i, j, k, m, size = roop.size(); while (true) { LL a = 1; for (i = 0; i < size; i++) { for (j = 0; j < roop[i]; j++) { a *= primes[i][0]; } } ans.push_back(a); roop[0]++; for (i = 0; i < size; i++) { if (i + 1 < size) { roop[i + 1] += (roop[i] / (primes[i][1] + 1)); } roop[i] %= (primes[i][1] + 1); } bool flag = true; for (i = 0; i < size; i++) { if (roop[i] != 0) flag = false; } if (flag) break; } return KyoPro::Sort(ans); } //組み合わせ nCrを10^9+7で割った余りを返す static LL Combination(LL n, LL r) { ModInt ans = 1; r = min(r, n - r); for (LL i = 0; i < r; i++) { ans *= (n - i); ans /= (i + 1); } return ans.getNumber(); } //順列 nPrを10^9+7で割った余りを返す static LL Permutation(LL n, LL r) { ModInt ans = 1; for (LL i = 0; i < r; i++) { ans *= (n - i); } return ans.getNumber(); } //重複組み合わせ。n種類からr個重複を許して選ぶ static LL nHr(LL n, LL r) { return KyoPro::Combination(n + r - 1, r); } template <typename T> static T pow(T const &a, LL const &b) { T ans = 1; auto p = b; auto x = a; while (p > 0) { if (p % 2 == 1) { ans *= x; } x = x * x; p /= 2; } return ans; } //符号 template <typename T> static T sign(T const &x) { if (x > 0) return 1; if (x < 0) return -1; return 0; } //絶対値 template <typename T> static T abs(T x) { if (x < 0) { x = x * -1; } return x; } //円周率 static double PI() { return (double)3.1415926535898; } //指定した桁でdoubleを出す。改行はしない。 static void CoutDoubleKeta(double a, LL keta) { cout << setprecision(keta) << a << flush; } //コンテナクラスの出力 template <typename T> static T CoutVector(T const &ls) { LL i, j, k, size = distance(ls.begin(), ls.end()); if (size == 0) return ls; auto itr = ls.begin(); for (i = 0; i < size - 1; i++) { cout << *itr << " " << flush; itr++; } cout << *itr << flush; return ls; } //コンテナクラスをソートする template <typename T> static T Sort(T &ls) { sort(ls.begin(), ls.end()); return ls; } //順序関数付きでコンテナクラスをソートする template <typename T, typename F> static T Sort(T &ls, F const &func) { sort(ls.begin(), ls.end(), func); return ls; } //コンテナクラスを逆順に並び替える template <typename T> static T Reverse(T &ls) { reverse(ls.begin(), ls.end()); return ls; } //コンテナクラスの条件を満たす要素を数え上げる。bool func(S x) template <typename T, typename S> static LL Count(T const &ls, S func) { LL ans = 0; auto itr = ls.begin(); while (itr != ls.end()) { if (func(*itr)) ans++; itr++; } return ans; } //コンテナクラスの要素をすべて更新する。S func(S x) template <typename T, typename S> static T AllUpdate(T &ls, S func) { auto itr = ls.begin(); while (itr != ls.end()) { *itr = func(*itr); itr++; } return ls; } //リストをベクターに変換する template <typename T> static vector<T> FromListToVector(list<T> const &a) { vector<T> ans; for (auto itr = a.begin(); itr != a.end(); itr++) { ans.push_back(*itr); } return ans; } //ベクターをリストに変換する template <typename T> static list<T> FromVectorToList(vector<T> a) { list<T> ans; for (auto itr = a.begin(); itr != a.end(); itr++) { ans.push_back(*itr); } return ans; } //最大値の要素番号を求める template <typename T> static LL MaxElementIndex(T const &ls) { return distance(ls.begin(), max_element(ls.begin(), ls.end())); } //最小値の要素番号を求める template <typename T> static LL MinElementIndex(T const &ls) { return distance(ls.begin(), min_element(ls.begin(), ls.end())); } //デバッグ用出力 template <typename T> static LL DebugPrintf(T output) { if (KyoPro::DebugFlag) { std::cout << output << endl; } return KyoPro::DebugFlag; } //デバッグ用入力 static LL DebugCin() { LL a; if (KyoPro::DebugFlag) { cin >> a; } return a; } }; LL KyoPro::DebugFlag = 0; //累積和を求めるクラス class Ruisekiwa { private: vector<LL> list; public: void MakeArray(vector<LL> data) { LL i; list = data; list.push_back(0); list[0] = 0; for (i = 1; i < list.size(); i++) { list[i] = list[i - 1] + data[i - 1]; } } LL Sum(LL start, LL end) { if (end < start) { std::cout << "startがendより大きいです"; return 0; } if (start < 0 || end >= list.size()) { std::cout << "範囲が異常"; return 0; } return list[end] - list[start]; } }; // n進数を管理するクラス class N_Number { public: N_Number(LL n, LL keta) { this->N_Shinsuu = n; VLL temp(keta, 0); this->numbers = temp; } //数を足す void plus(LL a) { if (a < 0) { a *= (-1); this->minus(a); return; } this->numbers[0] += a; LL size = this->numbers.size(); for (LL i = 0; i < size; i++) { if (i + 1 < size) { this->numbers[i + 1] += this->numbers[i] / this->N_Shinsuu; } this->numbers[i] %= this->N_Shinsuu; } } //全ての桁が同じ数字になっていればその数字を返す。それ以外の場合は -1 を返す LL check() { LL a = this->numbers[0]; for (LL i = 0; i < this->numbers.size(); i++) { if (this->numbers[i] != a) return -1; } return a; } LL getNumber(LL keta) { return this->numbers[keta]; } LL getKeta() { return this->numbers.size(); } LL getShinsuu() { return this->N_Shinsuu; } void setNumber(LL keta, LL number) { if (0 <= number && number < this->getShinsuu()) { if (0 <= keta && keta < this->getKeta()) { this->numbers[keta] = number; return; } } cout << "er" << endl; } void setAllNumbers(LL number) { LL size = this->getKeta(), i; for (i = 0; i < size; i++) { this->setNumber(i, number); } } string to_string_KetaSoroe() { string s = ""; for (LL i = this->getKeta() - 1; i >= 0; i--) { s += to_string(this->getNumber(i)); } return s; } private: void minus(LL a) { LL i, j, k, zettaiti = abs(a); k = KyoPro::KiriageWarizan(zettaiti, this->N_Shinsuu); j = k * (this->N_Shinsuu - 1); for (i = 0; i < this->getKeta(); i++) { this->numbers[i] += j; } this->numbers[0] += k - a; this->plus(0); } VLL numbers; LL N_Shinsuu; }; // UnionFind class Union_Find { private: VLL tree; VLL count; LL root(LL a) { if (this->tree[a] == a) return a; return this->tree[a] = this->root(this->tree[a]); } public: Union_Find(LL n) { VLL set(n); this->tree = set; this->count = set; for (LL i = 0; i < n; i++) { this->tree[i] = i; this->count[i] = 1; } } void unite(LL a, LL b) { LL x, y; if (!this->Check(a, b)) { x = this->getCount(a) + getCount(b); y = this->root(a); this->count[y] = x; y = this->root(b); this->count[y] = x; } x = this->root(a); y = this->root(b); this->tree[x] = y; } bool Check(LL a, LL b) { return this->root(a) == this->root(b); } LL getCount(LL index) { LL temp = this->root(index); return this->count[temp]; } LL getRoot(LL index) { return this->root(index); } VLL getList() { VLL ans(this->tree.size(), 0); for (LL i = 0; i < ans.size(); i++) { ans[i] = this->root(i); } return ans; } }; //プラスマイナス無限に対応したlong long型 class INF_LONG_LONG { private: LL inf, n; public: //コンストラクタ INF_LONG_LONG(LL a) { this->n = a; this->inf = 0; this->Syusei(); } INF_LONG_LONG() { *this = INF_LONG_LONG(0); } INF_LONG_LONG(INF_LONG_LONG const &a) { this->n = a.n; this->inf = a.inf; this->Syusei(); } //ゲッター LL getN() const { return this->n; } LL getInf() const { return this->inf; } //正の無限大生成 static INF_LONG_LONG plus_inf() { INF_LONG_LONG a; a.n = 0; a.inf = 1; a.Syusei(); return a; } //負の無限大生成 static INF_LONG_LONG minus_inf() { INF_LONG_LONG a; a.n = 0; a.inf = -1; a.Syusei(); return a; } //符号を取得 LL sign() const { if (this->inf != 0) { return this->inf; } return KyoPro::sign(this->n); } //代入演算子 INF_LONG_LONG operator=(INF_LONG_LONG const &b) { this->n = b.n; this->inf = b.inf; this->Syusei(); return *this; } INF_LONG_LONG operator=(LL const &b) { *this = INF_LONG_LONG(b); this->Syusei(); return *this; } //比較演算子 bool operator==(INF_LONG_LONG const &b) const { if (this->n == b.n && this->inf == b.inf) return true; return false; } bool operator!=(INF_LONG_LONG const &b) const { return !(*this == b); } bool operator<(INF_LONG_LONG const &b) const { if (this->inf < b.inf) return true; if (this->inf > b.inf) return false; return this->n < b.n; } bool operator>(INF_LONG_LONG const &b) const { return b < *this; } bool operator<=(INF_LONG_LONG const &b) const { return !(*this > b); } bool operator>=(INF_LONG_LONG const &b) const { return !(*this < b); } //算術演算子 INF_LONG_LONG operator+(INF_LONG_LONG const &b) const { if (max(this->inf, b.inf) > 0) return INF_LONG_LONG::plus_inf(); if (min(this->inf, b.inf) < 0) return INF_LONG_LONG::minus_inf(); auto ans = *this; ans.n += b.n; ans.Syusei(); return ans; } INF_LONG_LONG operator*(INF_LONG_LONG const &b) const { if (*this == INF_LONG_LONG(0) || b == INF_LONG_LONG(0)) { return INF_LONG_LONG(0); } if (this->inf != 0 || b.inf != 0) { LL s = this->sign() * b.sign(); INF_LONG_LONG ans(0); ans.n = 0; ans.inf = s; ans.Syusei(); return ans; } INF_LONG_LONG ans(0); ans.n = this->n * b.n; ans.Syusei(); return ans; } INF_LONG_LONG operator-(INF_LONG_LONG const &b) const { auto ans = (*this + (INF_LONG_LONG(-1) * b)); ans.Syusei(); return ans; } INF_LONG_LONG operator/(INF_LONG_LONG const &b) const { if (b == INF_LONG_LONG(0)) { LL a = this->n / b.n; return INF_LONG_LONG(a); } if (b.inf != 0) { return INF_LONG_LONG(0); } if (*this == INF_LONG_LONG(0)) { return INF_LONG_LONG(0); } if (this->inf != 0) { LL s = this->sign() * b.sign(); return INF_LONG_LONG::plus_inf() * INF_LONG_LONG(s); } INF_LONG_LONG ans; ans.n = this->n / b.n; ans.Syusei(); return ans; } INF_LONG_LONG operator%(INF_LONG_LONG const &b) const { if (this->inf == 0 && b.inf == 0) { INF_LONG_LONG ans; ans.n = this->n % b.n; ans.Syusei(); return ans; } auto x = *this / b; x.Syusei(); auto ans = *this - b * x; ans.Syusei(); return ans; } //複合代入演算子 INF_LONG_LONG operator+=(INF_LONG_LONG const &b) { auto ans = *this + b; *this = ans; return *this; } INF_LONG_LONG operator-=(INF_LONG_LONG const &b) { auto ans = *this - b; *this = ans; return *this; } INF_LONG_LONG operator*=(INF_LONG_LONG const &b) { auto ans = *this * b; *this = ans; return *this; } INF_LONG_LONG operator/=(INF_LONG_LONG const &b) { auto ans = *this / b; *this = ans; return *this; } INF_LONG_LONG operator%=(INF_LONG_LONG const &b) { auto ans = *this % b; *this = ans; return *this; } //符号演算子 INF_LONG_LONG operator+() const { return *this; } INF_LONG_LONG operator-() const { return *this * INF_LONG_LONG(-1); } //前置きインクリメント・デクリメント INF_LONG_LONG operator++() { this->n++; this->Syusei(); return *this; } INF_LONG_LONG operator--() { this->n--; this->Syusei(); return *this; } //後置きインクリメント・デクリメント INF_LONG_LONG operator++(int) { auto copy = *this; ++(*this); return copy; } INF_LONG_LONG operator--(int) { auto copy = *this; --(*this); return copy; } //文字列への変換 string ToString() const { if (this->inf == 1) { return "+INF"; } if (this->inf == -1) { return "-INF"; } return to_string(this->n); } private: void Syusei() { if (this->inf != 0) { this->n = 0; } } }; typedef INF_LONG_LONG ILL_TYPE; typedef vector<ILL_TYPE> VILL_TYPE; typedef vector<VILL_TYPE> VVILL_TYPE; //ワーシャルフロイド class WarshallFloyd { public: //最短距離を記録 VVILL_TYPE d; //頂点数 LL v; // vは頂点数、edge_cost_listは辺の情報{始点、終点、コスト}の配列。無向グラフの場合、逆矢印の辺に注意。 WarshallFloyd(LL v, VVLL edge_cost_list) { this->v = v; this->d = VVILL_TYPE(v, VILL_TYPE(v, ILL_TYPE::plus_inf())); LL i, j, k, a, b, c; for (i = 0; i < edge_cost_list.size(); i++) { a = edge_cost_list[i][0]; b = edge_cost_list[i][1]; c = edge_cost_list[i][2]; this->d[a][b] = ILL_TYPE(c); } for (i = 0; i < v; i++) { this->d[i][i] = ILL_TYPE(0); } //ここから計算 for (k = 0; k < v; k++) { for (i = 0; i < v; i++) { for (j = 0; j < v; j++) { d[i][j] = min(d[i][j], d[i][k] + d[k][j]); } } } } }; //ベルマンフォード class BellmanFord { public: //辺のリスト VVILL_TYPE edge; //頂点数、辺数 LL v, e; //始点 LL s; //最短距離 VILL_TYPE d; // vは頂点数、startは始点、edge_cost_listは辺の情報{始点、終点、コスト}の配列。 BellmanFord(LL v, LL start, VVLL edge_cost_list) { this->v = v; this->s = start; this->e = edge_cost_list.size(); this->d = VILL_TYPE(v, ILL_TYPE::plus_inf()); this->d[start] = 0; LL i, j, k; for (i = 0; i < this->e; i++) { VILL_TYPE temp; LL a, b, c; a = edge_cost_list[i][0]; b = edge_cost_list[i][1]; c = edge_cost_list[i][2]; temp.push_back(ILL_TYPE(a)); temp.push_back(ILL_TYPE(b)); temp.push_back(ILL_TYPE(c)); this->edge.push_back(temp); } this->DoUpdata(); auto cpy = this->d; this->DoUpdata(); for (i = 0; i < this->d.size(); i++) { if (this->d[i] != cpy[i]) { this->d[i] = ILL_TYPE::minus_inf(); } } this->DoUpdata(); } private: void DoUpdata() { LL i, j, k; for (i = 0; i <= this->v; i++) { bool update = true; for (j = 0; j < this->e; j++) { ILL_TYPE c; LL a, b; a = this->edge[j][0].getN(); b = this->edge[j][1].getN(); c = this->edge[j][2]; if (this->d[a] < ILL_TYPE::plus_inf()) { if (this->d[a] + c < this->d[b]) { update = false; this->d[b] = this->d[a] + c; } } } if (update) break; } } }; //ダイクストラ class Dijkstra { public: Dijkstra(LL v, LL start, VVLL edge_cost_list) {} }; //ライブラリはここまで //ここから下を書く //ここからメイン int main(void) { KyoPro::DebugFlag = 0; LL i, j, k, n, m; LL count = 0; string s; cin >> s; string a, b; a = ""; i = 0; while (i < s.size()) { b = s.substr(i, 1); if (a == b) { if (i + 1 == s.size()) { break; } b = s.substr(i, 2); count++; i += 2; } else { count++; i++; } a = b; } cout << count << endl; return 0; }
[]
741,435
741,436
u304318875
cpp
p02939
// editorialを読んだ #include <iostream> #include <vector> using namespace std; int main() { string s; cin >> s; int n = s.length(); if (n == 1) { cout << 1 << endl; return 0; } vector<vector<int>> dp(2, vector<int>(n, 0)); dp[0][0] = 1; dp[1][1] = 1; dp[1][0] = s[1] != s[0] ? 2 : 0; for (int i = 2; i < n; i++) { dp[0][i] = dp[1][i - 1] + 1; if (s[i] != s[i - 1]) dp[0][i] = max(dp[0][i], dp[0][i - 1] + 1); dp[1][i] = dp[0][i - 2] + 1; if (i - 3 >= 0 && s.substr(i - 3, 2) != s.substr(i - 1, 2)) dp[1][i] = max(dp[1][i], dp[1][i - 2] + 1); } cout << max(dp[0][n - 1], dp[1][n - 1]) << endl; return 0; }
// editorialを読んだ #include <iostream> #include <vector> using namespace std; int main() { string s; cin >> s; int n = s.length(); if (n == 1) { cout << 1 << endl; return 0; } vector<vector<int>> dp(2, vector<int>(n, 0)); dp[0][0] = 1; dp[1][1] = 1; dp[0][1] = s[1] != s[0] ? 2 : 0; for (int i = 2; i < n; i++) { dp[0][i] = dp[1][i - 1] + 1; if (s[i] != s[i - 1]) dp[0][i] = max(dp[0][i], dp[0][i - 1] + 1); dp[1][i] = dp[0][i - 2] + 1; if (i - 3 >= 0 && s.substr(i - 3, 2) != s.substr(i - 1, 2)) dp[1][i] = max(dp[1][i], dp[1][i - 2] + 1); } cout << max(dp[0][n - 1], dp[1][n - 1]) << endl; return 0; }
[ "literal.number.change", "assignment.variable.change", "variable_access.subscript.index.change", "control_flow.loop.for.condition.change", "expression.off_by_one" ]
741,439
741,440
u734519000
cpp
p02939
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <vector> #define ll long long #define pii pair<int, int> #define pp pair<pair<ll, ll>, pair<ll, ll>> #define pll pair<ll, ll> #define vii vector<int> #define vll vector<ll> #define lb lower_bound #define pb push_back #define mp make_pair #define fi first #define sc second #define rep(i, n) for (ll i = 0; i < n; i++) #define rep2(i, a, b) for (ll i = a; i < b; i++) #define repr(i, n) for (ll i = n - 1; i >= 0; i--) #define all(x) x.begin(), x.end() #define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin()) #define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin()) #define ERASE(v) v.erase(unique(v.begin(), v.end()), v.end()) // #define int ll using namespace std; const int INF = (1 << 30) - 1; const ll LLINF = (1LL << 60LL); const int MOD = 1000000007; const int MAX = 510000; const double pi = acos(-1); const double eps = 1e-9; int main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); string s; cin >> s; ll n = s.size(); ll dp[200010][3]; rep(i, n + 1) rep(j, 3) dp[i][j] = 0; dp[0][1] = 1, dp[0][2] = 0; dp[1][2] = 1; if (s[0] == s[1]) dp[1][1] = 0; else dp[1][2] = 2; rep2(i, 2, n) { if (s[i] != s[i - 1]) dp[i][1] = max(dp[i][1], dp[i - 1][1] + 1); dp[i][1] = max(dp[i][1], dp[i - 1][2] + 1); dp[i][2] = max(dp[i][2], dp[i - 2][1] + 1); if (i >= 3 && (s[i] != s[i - 2] || s[i - 1] != s[i - 3])) dp[i][2] = max(dp[i][2], dp[i - 2][2] + 1); } cout << max(dp[n - 1][1], dp[n - 1][2]) << endl; return 0; }
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <vector> #define ll long long #define pii pair<int, int> #define pp pair<pair<ll, ll>, pair<ll, ll>> #define pll pair<ll, ll> #define vii vector<int> #define vll vector<ll> #define lb lower_bound #define pb push_back #define mp make_pair #define fi first #define sc second #define rep(i, n) for (ll i = 0; i < n; i++) #define rep2(i, a, b) for (ll i = a; i < b; i++) #define repr(i, n) for (ll i = n - 1; i >= 0; i--) #define all(x) x.begin(), x.end() #define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin()) #define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin()) #define ERASE(v) v.erase(unique(v.begin(), v.end()), v.end()) // #define int ll using namespace std; const int INF = (1 << 30) - 1; const ll LLINF = (1LL << 60LL); const int MOD = 1000000007; const int MAX = 510000; const double pi = acos(-1); const double eps = 1e-9; int main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); string s; cin >> s; ll n = s.size(); ll dp[200010][3]; rep(i, n + 1) rep(j, 3) dp[i][j] = 0; dp[0][1] = 1, dp[0][2] = 0; dp[1][2] = 1; if (s[0] == s[1]) dp[1][1] = 0; else dp[1][1] = 2; rep2(i, 2, n) { if (s[i] != s[i - 1]) dp[i][1] = max(dp[i][1], dp[i - 1][1] + 1); dp[i][1] = max(dp[i][1], dp[i - 1][2] + 1); dp[i][2] = max(dp[i][2], dp[i - 2][1] + 1); if (i >= 3 && (s[i] != s[i - 2] || s[i - 1] != s[i - 3])) dp[i][2] = max(dp[i][2], dp[i - 2][2] + 1); } cout << max(dp[n - 1][1], dp[n - 1][2]) << endl; return 0; }
[ "literal.number.change", "assignment.variable.change", "variable_access.subscript.index.change" ]
741,443
741,444
u241367243
cpp
p02939
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <vector> #define ll long long #define pii pair<int, int> #define pp pair<pair<ll, ll>, pair<ll, ll>> #define pll pair<ll, ll> #define vii vector<int> #define vll vector<ll> #define lb lower_bound #define pb push_back #define mp make_pair #define fi first #define sc second #define rep(i, n) for (ll i = 0; i < n; i++) #define rep2(i, a, b) for (ll i = a; i < b; i++) #define repr(i, n) for (ll i = n - 1; i >= 0; i--) #define all(x) x.begin(), x.end() #define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin()) #define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin()) #define ERASE(v) v.erase(unique(v.begin(), v.end()), v.end()) // #define int ll using namespace std; const int INF = (1 << 30) - 1; const ll LLINF = (1LL << 60LL); const int MOD = 1000000007; const int MAX = 510000; const double pi = acos(-1); const double eps = 1e-9; int main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); string s; cin >> s; ll n = s.size(); ll dp[200010][3]; rep(i, n + 1) rep(j, 3) dp[i][j] = 0; dp[0][1] = 1, dp[0][2] = 0; dp[1][2] = 1; if (s[0] == s[1]) dp[1][1] = 0; else dp[1][2] = 2; rep2(i, 2, n) { if (s[i] != s[i - 1]) dp[i][1] = max(dp[i][1], dp[i - 1][1] + 1); dp[i][1] = max(dp[i][1], dp[i - 1][2] + 1); dp[i][2] = max(dp[i][2], dp[i - 2][1] + 1); if (i >= 3 && (s[i] != s[i - 2] || s[i - 1] != s[i - 3])) dp[i][2] = max(dp[i][2], dp[i - 2][1] + 1); } cout << max(dp[n - 1][1], dp[n - 1][2]) << endl; return 0; }
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <vector> #define ll long long #define pii pair<int, int> #define pp pair<pair<ll, ll>, pair<ll, ll>> #define pll pair<ll, ll> #define vii vector<int> #define vll vector<ll> #define lb lower_bound #define pb push_back #define mp make_pair #define fi first #define sc second #define rep(i, n) for (ll i = 0; i < n; i++) #define rep2(i, a, b) for (ll i = a; i < b; i++) #define repr(i, n) for (ll i = n - 1; i >= 0; i--) #define all(x) x.begin(), x.end() #define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin()) #define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin()) #define ERASE(v) v.erase(unique(v.begin(), v.end()), v.end()) // #define int ll using namespace std; const int INF = (1 << 30) - 1; const ll LLINF = (1LL << 60LL); const int MOD = 1000000007; const int MAX = 510000; const double pi = acos(-1); const double eps = 1e-9; int main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); string s; cin >> s; ll n = s.size(); ll dp[200010][3]; rep(i, n + 1) rep(j, 3) dp[i][j] = 0; dp[0][1] = 1, dp[0][2] = 0; dp[1][2] = 1; if (s[0] == s[1]) dp[1][1] = 0; else dp[1][1] = 2; rep2(i, 2, n) { if (s[i] != s[i - 1]) dp[i][1] = max(dp[i][1], dp[i - 1][1] + 1); dp[i][1] = max(dp[i][1], dp[i - 1][2] + 1); dp[i][2] = max(dp[i][2], dp[i - 2][1] + 1); if (i >= 3 && (s[i] != s[i - 2] || s[i - 1] != s[i - 3])) dp[i][2] = max(dp[i][2], dp[i - 2][2] + 1); } cout << max(dp[n - 1][1], dp[n - 1][2]) << endl; return 0; }
[ "literal.number.change", "assignment.variable.change", "variable_access.subscript.index.change", "assignment.value.change", "call.arguments.change", "expression.operation.binary.change" ]
741,445
741,444
u241367243
cpp
p02939
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <vector> #define ll long long #define pii pair<int, int> #define pp pair<pair<ll, ll>, pair<ll, ll>> #define pll pair<ll, ll> #define vii vector<int> #define vll vector<ll> #define lb lower_bound #define pb push_back #define mp make_pair #define fi first #define sc second #define rep(i, n) for (ll i = 0; i < n; i++) #define rep2(i, a, b) for (ll i = a; i < b; i++) #define repr(i, n) for (ll i = n - 1; i >= 0; i--) #define all(x) x.begin(), x.end() #define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin()) #define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin()) #define ERASE(v) v.erase(unique(v.begin(), v.end()), v.end()) // #define int ll using namespace std; const int INF = (1 << 30) - 1; const ll LLINF = (1LL << 60LL); const int MOD = 1000000007; const int MAX = 510000; const double pi = acos(-1); const double eps = 1e-9; int main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); string s; cin >> s; ll n = s.size(); ll dp[200010][3]; rep(i, n + 1) rep(j, 3) dp[i][j] = 0; dp[0][1] = 1, dp[0][2] = 0; dp[1][2] = 1; if (s[0] == s[1]) dp[1][1] = 0; else dp[1][2] = 2; rep2(i, 2, n) { if (s[i] != s[i - 1]) dp[i][1] = max(dp[i][1], dp[i - 1][1] + 1); dp[i][1] = max(dp[i][1], dp[i - 1][2] + 1); dp[i][2] = max(dp[i][2], dp[i - 2][1] + 1); if (i >= 3 && s[i] != s[i - 2] && s[i - 1] != s[i - 3]) dp[i][2] = max(dp[i][2], dp[i - 2][1] + 1); } cout << max(dp[n - 1][1], dp[n - 1][2]) << endl; return 0; }
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <vector> #define ll long long #define pii pair<int, int> #define pp pair<pair<ll, ll>, pair<ll, ll>> #define pll pair<ll, ll> #define vii vector<int> #define vll vector<ll> #define lb lower_bound #define pb push_back #define mp make_pair #define fi first #define sc second #define rep(i, n) for (ll i = 0; i < n; i++) #define rep2(i, a, b) for (ll i = a; i < b; i++) #define repr(i, n) for (ll i = n - 1; i >= 0; i--) #define all(x) x.begin(), x.end() #define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin()) #define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin()) #define ERASE(v) v.erase(unique(v.begin(), v.end()), v.end()) // #define int ll using namespace std; const int INF = (1 << 30) - 1; const ll LLINF = (1LL << 60LL); const int MOD = 1000000007; const int MAX = 510000; const double pi = acos(-1); const double eps = 1e-9; int main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); string s; cin >> s; ll n = s.size(); ll dp[200010][3]; rep(i, n + 1) rep(j, 3) dp[i][j] = 0; dp[0][1] = 1, dp[0][2] = 0; dp[1][2] = 1; if (s[0] == s[1]) dp[1][1] = 0; else dp[1][1] = 2; rep2(i, 2, n) { if (s[i] != s[i - 1]) dp[i][1] = max(dp[i][1], dp[i - 1][1] + 1); dp[i][1] = max(dp[i][1], dp[i - 1][2] + 1); dp[i][2] = max(dp[i][2], dp[i - 2][1] + 1); if (i >= 3 && (s[i] != s[i - 2] || s[i - 1] != s[i - 3])) dp[i][2] = max(dp[i][2], dp[i - 2][2] + 1); } cout << max(dp[n - 1][1], dp[n - 1][2]) << endl; return 0; }
[ "literal.number.change", "assignment.variable.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change", "misc.opposites", "assignment.value.change", "call.arguments.change", "expression.operation.binary.change" ]
741,446
741,444
u241367243
cpp
p02939
#include <bits/stdc++.h> using namespace std; int main() { string s; string c, p = ""; int ans = 0; cin >> s; for (int i = 1; i < s.size(); i++) { c += s[i]; if (c == p) { continue; } else { p = c; c = ""; ans++; } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string s; string c, p = ""; int ans = 0; cin >> s; for (int i = 0; i < s.size(); i++) { c += s[i]; if (c == p) { continue; } else { p = c; c = ""; ans++; } } cout << ans << endl; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one" ]
741,447
741,448
u663775885
cpp
p02939
#include "bits/stdc++.h" #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; int main() { string s; cin >> s; int ans = 0, k = 0, l = 0, m; rep(i, s.size() - 1) { if (s[i] == s[i + 1]) { k++; } else { ans += 1 + 2 * (k / 3); if (k % 3 == 2) ans++; m = k % 3; if (l == 1) { if (m == 1) { ans++; m--; } else if (m == 2) m--; } l = m; k = 0; } } ans += 1 + 2 * k / 3; if (k % 3 == 2) ans++; m = k % 3; if (l == 1 && m == 1) ans++; cout << ans << endl; return 0; }
#include "bits/stdc++.h" #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; int main() { string s; cin >> s; int ans = 0, k = 0, l = 0, m; rep(i, s.size() - 1) { if (s[i] == s[i + 1]) { k++; } else { ans += 1 + 2 * (k / 3); if (k % 3 == 2) ans++; m = k % 3; if (l == 1) { if (m == 1) { ans++; m--; } else if (m == 2) m--; } l = m; k = 0; } } ans += 1 + 2 * (k / 3); if (k % 3 == 2) ans++; m = k % 3; if (l == 1 && m == 1) ans++; cout << ans << endl; return 0; }
[]
741,449
741,450
u445015174
cpp
p02939
#include "bits/stdc++.h" #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; int main() { string s; cin >> s; int ans = 0, k = 0, l = 0, m; rep(i, s.size() - 1) { if (s[i] == s[i + 1]) { k++; } else { ans += 1 + 2 * (k / 3); if (k % 3 == 2) ans++; m = k % 3; if (l == 1) { if (m == 1) { ans++; m--; } else if (m == 2) m--; l = m; k = 0; } } } ans += 1 + 2 * k / 3; if (k % 3 == 2) ans++; m = k % 3; if (l == 1 && m == 1) ans++; cout << ans << endl; return 0; }
#include "bits/stdc++.h" #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; int main() { string s; cin >> s; int ans = 0, k = 0, l = 0, m; rep(i, s.size() - 1) { if (s[i] == s[i + 1]) { k++; } else { ans += 1 + 2 * (k / 3); if (k % 3 == 2) ans++; m = k % 3; if (l == 1) { if (m == 1) { ans++; m--; } else if (m == 2) m--; } l = m; k = 0; } } ans += 1 + 2 * (k / 3); if (k % 3 == 2) ans++; m = k % 3; if (l == 1 && m == 1) ans++; cout << ans << endl; return 0; }
[]
741,451
741,450
u445015174
cpp
p02939
#include "bits/stdc++.h" #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; int main() { string s; cin >> s; int ans = 0, k = 0, l = 0, m; rep(i, s.size() - 1) { if (s[i] == s[i + 1]) { k++; } else { ans += 1 + 2 * (k / 3); if (k % 3 == 2) ans++; m = k % 3; if (l == 1) if (m == 1) { ans++; m--; } else if (m == 2) m--; l = m; k = 0; } } ans += 1 + 2 * k / 3; if (k % 3 == 2) ans++; m = k % 3; if (l == 1 && m == 1) ans++; cout << ans << endl; return 0; }
#include "bits/stdc++.h" #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; int main() { string s; cin >> s; int ans = 0, k = 0, l = 0, m; rep(i, s.size() - 1) { if (s[i] == s[i + 1]) { k++; } else { ans += 1 + 2 * (k / 3); if (k % 3 == 2) ans++; m = k % 3; if (l == 1) { if (m == 1) { ans++; m--; } else if (m == 2) m--; } l = m; k = 0; } } ans += 1 + 2 * (k / 3); if (k % 3 == 2) ans++; m = k % 3; if (l == 1 && m == 1) ans++; cout << ans << endl; return 0; }
[]
741,452
741,450
u445015174
cpp
p02939
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int ans = 1; string sub = s.substr(0, 1); for (int i = 1; i < s.size(); ++i) { if (sub == s.substr(i, 1)) { if (i + 1 <= s.size()) { sub = s.substr(i, 2); ++ans; ++i; } } else { sub = s.substr(i, 1); ++ans; } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int ans = 1; string sub = s.substr(0, 1); for (int i = 1; i < s.size(); ++i) { if (sub == s.substr(i, 1)) { if (i + 1 < s.size()) { sub = s.substr(i, 2); ++ans; ++i; } } else { sub = s.substr(i, 1); ++ans; } } cout << ans << endl; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
741,455
741,456
u640800420
cpp
p02939
#include <algorithm> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <string> #include <utility> #include <vector> using namespace std; #define N (1000000000 + 7) #define INF 1e9 typedef long long ll; typedef pair<ll, ll> P; unsigned long long popCount64bitB(unsigned long long x) { x = ((x & 0xaaaaaaaaaaaaaaaaUL) >> 1) + (x & 0x5555555555555555UL); x = ((x & 0xccccccccccccccccUL) >> 2) + (x & 0x3333333333333333UL); x = ((x & 0xf0f0f0f0f0f0f0f0UL) >> 4) + (x & 0x0f0f0f0f0f0f0f0fUL); x = ((x & 0xff00ff00ff00ff00UL) >> 8) + (x & 0x00ff00ff00ff00ffUL); x = ((x & 0xffff0000ffff0000UL) >> 16) + (x & 0x0000ffff0000ffffUL); x = ((x & 0xffffffff00000000UL) >> 32) + (x & 0x00000000ffffffffUL); return x; } int main(void) { int ans = 0; string s; cin >> s; int i = 0; if (s.length() == 1) ans = 1; else { string pre = ""; for (int i = 0; i < s.length(); i++) { if (i + 2 == s.length()) { if (s[i] == s[i + 1]) { ans++; i += 2; continue; } } if (s.substr(i, 2) == pre) { pre = s.substr(i, 2); i++; } else { pre = s.substr(i, 1); } ans++; } } cout << ans << endl; }
#include <algorithm> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <string> #include <utility> #include <vector> using namespace std; #define N (1000000000 + 7) #define INF 1e9 typedef long long ll; typedef pair<ll, ll> P; unsigned long long popCount64bitB(unsigned long long x) { x = ((x & 0xaaaaaaaaaaaaaaaaUL) >> 1) + (x & 0x5555555555555555UL); x = ((x & 0xccccccccccccccccUL) >> 2) + (x & 0x3333333333333333UL); x = ((x & 0xf0f0f0f0f0f0f0f0UL) >> 4) + (x & 0x0f0f0f0f0f0f0f0fUL); x = ((x & 0xff00ff00ff00ff00UL) >> 8) + (x & 0x00ff00ff00ff00ffUL); x = ((x & 0xffff0000ffff0000UL) >> 16) + (x & 0x0000ffff0000ffffUL); x = ((x & 0xffffffff00000000UL) >> 32) + (x & 0x00000000ffffffffUL); return x; } int main(void) { int ans = 0; string s; cin >> s; int i = 0; if (s.length() == 1) ans = 1; else { string pre = ""; for (int i = 0; i < s.length(); i++) { if (i + 2 == s.length()) { if (s[i] == s[i + 1]) { ans++; i += 2; continue; } } if (s.substr(i, 1) == pre) { pre = s.substr(i, 2); i++; } else { pre = s.substr(i, 1); } ans++; } } cout << ans << endl; }
[ "literal.number.change", "control_flow.branch.if.condition.change" ]
741,467
741,468
u744305661
cpp
p02939
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { string S; cin >> S; set<string> s; int n = S.length(); if (n == 1) { cout << "1\n"; return 0; } if (n == 2) { if (S[0] == S[1]) { cout << "1\n"; } else { cout << "2\n"; } return 0; } int dp[n + 1][2]{}; dp[0][0] = 1; dp[0][1] = 0; if (S[0] == S[1]) { dp[1][0] = 1; dp[1][1] = 0; } else { dp[1][0] = 2; dp[1][1] = 1; } for (int i = 2; i < n; i++) { if (S[i] != S[i - 1]) { dp[i][0] = max(dp[i - 1][0], dp[i - 2][0]) + 1; dp[i][1] = dp[i - 2][0] + 1; } else { dp[i][0] = max(dp[i - 1][1], dp[i - 2][1]) + 1; dp[i][1] = dp[i - 2][0] + 1; } } cout << max(dp[n - 1][0], dp[n - 1][1]) << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { string S; cin >> S; set<string> s; int n = S.length(); if (n == 1) { cout << "1\n"; return 0; } if (n == 2) { if (S[0] == S[1]) { cout << "1\n"; } else { cout << "2\n"; } return 0; } int dp[n + 1][2]{}; dp[0][0] = 1; dp[0][1] = 0; if (S[0] == S[1]) { dp[1][0] = 0; dp[1][1] = 1; } else { dp[1][0] = 2; dp[1][1] = 1; } for (int i = 2; i < n; i++) { if (S[i] != S[i - 1]) { dp[i][0] = max(dp[i - 1][0], dp[i - 2][0]) + 1; dp[i][1] = dp[i - 2][0] + 1; } else { dp[i][0] = max(dp[i - 1][1], dp[i - 2][1]) + 1; dp[i][1] = dp[i - 2][0] + 1; } } cout << max(dp[n - 1][0], dp[n - 1][1]) << "\n"; return 0; }
[ "literal.number.change", "assignment.value.change" ]
741,473
741,474
u634209474
cpp
p02939
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { string S; cin >> S; set<string> s; int n = S.length(); if (n == 1) { cout << "1\n"; return 0; } if (n == 2) { if (S[0] == S[1]) { cout << "1\n"; } else { cout << "2\n"; } return 0; } int dp[n + 1][2]{}; dp[0][0] = 1; dp[0][1] = 0; if (S[0] == S[1]) { dp[1][0] = 0; dp[1][1] = 1; } else { dp[1][0] = 2; dp[1][1] = 1; } for (int i = 2; i < n; i++) { if (S[i] != S[i - 1]) { dp[i][0] = dp[i - 1][0] + 1; dp[i][1] = dp[i - 2][0] + 1; } else { dp[i][0] = dp[i - 1][1] + 1; dp[i][1] = dp[i - 2][0] + 1; } } cout << max(dp[n - 1][0], dp[n - 1][1]) << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { string S; cin >> S; set<string> s; int n = S.length(); if (n == 1) { cout << "1\n"; return 0; } if (n == 2) { if (S[0] == S[1]) { cout << "1\n"; } else { cout << "2\n"; } return 0; } int dp[n + 1][2]{}; dp[0][0] = 1; dp[0][1] = 1; if (S[0] == S[1]) { dp[1][0] = 1; dp[1][1] = 1; } else { dp[1][0] = 2; dp[1][1] = 1; } for (int i = 2; i < n; i++) { if (S[i] != S[i - 1]) { dp[i][0] = dp[i - 1][0] + 1; dp[i][1] = dp[i - 2][0] + 1; } else { dp[i][0] = dp[i - 1][1] + 1; dp[i][1] = dp[i - 2][0] + 1; } } cout << max(dp[n - 1][0], dp[n - 1][1]) << "\n"; // for (int i = 0; i < n; i++) { // cout << dp[i][0] << " " << dp[i][1] << "\n"; // } return 0; }
[ "literal.number.change", "assignment.value.change" ]
741,475
741,476
u634209474
cpp
p02939
#include <bits/stdc++.h> #include <cmath> #include <vector> #define REP(i, n) for (int i = 0; i < (int)(n); ++i) #define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i) #define REPR(i, n) for (int i = (n)-1; i >= 0; --i) #define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i) #define REPx(x, a) for (auto x : a) #define ALL(a) a.begin(), a.end() #define SORT(a) sort(ALL(a)) #define SORTR(a) sort(ALL(a), greater<int>()) #define REVERSE(a) reverse(ALL(a)) #define bit_search(bit, n) REP(bit, 1 << (n)) #define bit_check(bit, i) (bit >> (i)) & 1 #define setpre(n) fixed << setprecision((n)) #define UNIQUE(a) \ do { \ SORT(a); \ (a).erase(unique(ALL(a)), (a).end()); \ } while (0) #define MAX(a) *max_element(ALL(a)) #define MIN(a) *min_element(ALL(a)) #define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin() #define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin() #define INPUT(a) REP(i, a.size()) cin >> a[i]; #define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second; #define ENDL cout << endl; using namespace std; using LL = long long; using LD = long double; using PII = pair<int, int>; using VPII = vector<PII>; using PLL = pair<LL, LL>; using VPLL = vector<PLL>; using VI = vector<int>; using VVI = vector<VI>; using VLL = vector<LL>; using VVLL = vector<VLL>; using VC = vector<char>; using VS = vector<string>; using VB = vector<bool>; const LL INF = 1e14; const LL MOD = 1e9 + 7; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } int main() { cin.tie(0); ios::sync_with_stdio(false); string s; cin >> s; int ans = 0; int ct = 0; REP(i, s.size() - 1) { if (ct == 1) ct++; else if (ct == 2) { ans++; ct = 0; } else if (s[i] == s[i + 1]) { ans++; ct++; } else ans++; } if (!ct) ans++; cout << ans << endl; return 0; }
#include <bits/stdc++.h> #include <cmath> #include <vector> #define REP(i, n) for (int i = 0; i < (int)(n); ++i) #define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i) #define REPR(i, n) for (int i = (n)-1; i >= 0; --i) #define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i) #define REPx(x, a) for (auto x : a) #define ALL(a) a.begin(), a.end() #define SORT(a) sort(ALL(a)) #define SORTR(a) sort(ALL(a), greater<int>()) #define REVERSE(a) reverse(ALL(a)) #define bit_search(bit, n) REP(bit, 1 << (n)) #define bit_check(bit, i) (bit >> (i)) & 1 #define setpre(n) fixed << setprecision((n)) #define UNIQUE(a) \ do { \ SORT(a); \ (a).erase(unique(ALL(a)), (a).end()); \ } while (0) #define MAX(a) *max_element(ALL(a)) #define MIN(a) *min_element(ALL(a)) #define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin() #define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin() #define INPUT(a) REP(i, a.size()) cin >> a[i]; #define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second; #define ENDL cout << endl; using namespace std; using LL = long long; using LD = long double; using PII = pair<int, int>; using VPII = vector<PII>; using PLL = pair<LL, LL>; using VPLL = vector<PLL>; using VI = vector<int>; using VVI = vector<VI>; using VLL = vector<LL>; using VVLL = vector<VLL>; using VC = vector<char>; using VS = vector<string>; using VB = vector<bool>; const LL INF = 1e14; const LL MOD = 1e9 + 7; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } int main() { cin.tie(0); ios::sync_with_stdio(false); string s; cin >> s; int ans = 0; int ct = 0; REP(i, s.size() - 1) { if (ct == 1) ct++; else if (ct == 2) { ans++; ct = 0; } else if (s[i] == s[i + 1]) { ans++; ct++; } else ans++; } if (ct != 1) ans++; cout << ans << endl; return 0; }
[ "expression.operation.unary.logical.remove", "control_flow.branch.if.condition.change" ]
741,479
741,480
u442030035
cpp
p02939
#include <bits/stdc++.h> #define REP(i, n) for (decltype(n) i = 0; i < n; i++) #define ALL(c) c.begin(), c.end() #define SORT(c) std::sort(ALL(c)) #define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>()) using namespace std; using ll = long long; const int MOD = (int)1e9 + 7; const int INF = (int)1e9 + 1; const ll LINF = (ll)1e18 + 1; int main() { cin.tie(0); ios::sync_with_stdio(false); string S; std::cin >> S; int ans = 1; string prev = S.substr(1, 1); for (size_t i = 1; i < S.size(); i++) { if (prev != S.substr(i, 1)) { prev = S.substr(i, 1); } else { prev = S.substr(i, 2); i++; } if (i != S.size()) ans++; } std::cout << ans << std::endl; return 0; }
#include <bits/stdc++.h> #define REP(i, n) for (decltype(n) i = 0; i < n; i++) #define ALL(c) c.begin(), c.end() #define SORT(c) std::sort(ALL(c)) #define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>()) using namespace std; using ll = long long; const int MOD = (int)1e9 + 7; const int INF = (int)1e9 + 1; const ll LINF = (ll)1e18 + 1; int main() { cin.tie(0); ios::sync_with_stdio(false); string S; std::cin >> S; int ans = 1; string prev = S.substr(0, 1); for (size_t i = 1; i < S.size(); i++) { if (prev != S.substr(i, 1)) { prev = S.substr(i, 1); } else { prev = S.substr(i, 2); i++; } if (i != S.size()) ans++; } std::cout << ans << std::endl; return 0; }
[ "literal.number.change", "call.arguments.change" ]
741,500
741,501
u403800404
cpp
p02939
#include <bits/stdc++.h> #define REP(i, n) for (decltype(n) i = 0; i < n; i++) #define ALL(c) c.begin(), c.end() #define SORT(c) std::sort(ALL(c)) #define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>()) using namespace std; using ll = long long; const int MOD = (int)1e9 + 7; const int INF = (int)1e9 + 1; const ll LINF = (ll)1e18 + 1; int main() { cin.tie(0); ios::sync_with_stdio(false); string S; std::cin >> S; int ans = 0; string prev = S.substr(1, 0); for (size_t i = 1; i < S.size(); i++) { if (prev != S.substr(i, 1)) { prev = S.substr(i, 1); } else { prev = S.substr(i, 2); i++; } if (i != S.size()) ans++; } std::cout << ans << std::endl; return 0; }
#include <bits/stdc++.h> #define REP(i, n) for (decltype(n) i = 0; i < n; i++) #define ALL(c) c.begin(), c.end() #define SORT(c) std::sort(ALL(c)) #define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>()) using namespace std; using ll = long long; const int MOD = (int)1e9 + 7; const int INF = (int)1e9 + 1; const ll LINF = (ll)1e18 + 1; int main() { cin.tie(0); ios::sync_with_stdio(false); string S; std::cin >> S; int ans = 1; string prev = S.substr(0, 1); for (size_t i = 1; i < S.size(); i++) { if (prev != S.substr(i, 1)) { prev = S.substr(i, 1); } else { prev = S.substr(i, 2); i++; } if (i != S.size()) ans++; } std::cout << ans << std::endl; return 0; }
[ "literal.number.change", "variable_declaration.value.change", "call.arguments.change", "call.arguments.add" ]
741,502
741,501
u403800404
cpp
p02939
#include <bits/stdc++.h> using namespace std; #define fs first #define sc second #define pb push_back #define mp make_pair #define eb emplace_back #define ALL(A) A.begin(), A.end() #define RALL(A) A.rbegin(), A.rend() typedef long long ll; typedef pair<ll, ll> P; const ll mod = 1000000007; const ll LINF = 1LL << 60; const int INF = 1 << 30; int main() { string S; cin >> S; int n = (int)(S.length()); vector<int> dp(n); int i = 0; dp[0] = 0; int tmp = 1; while (i < n - 1) { // cout << i << endl; // for (int j = 0;j < n; j++){ // cout << dp[j] << endl; // } if (tmp == 1) { if (S[i] != S[i + 1]) { dp[i + 1] = dp[i] + 1; i++; tmp = 1; } else { dp[i + 1] = dp[i]; dp[i + 2] = dp[i] + 1; i += 2; tmp = 2; } } else { dp[i + 1] = dp[i] + 1; i++; tmp = 1; } } if (dp[n - 1] == 0) { cout << dp[n - 1] << endl; } else { cout << dp[n - 1] + 1 << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; #define fs first #define sc second #define pb push_back #define mp make_pair #define eb emplace_back #define ALL(A) A.begin(), A.end() #define RALL(A) A.rbegin(), A.rend() typedef long long ll; typedef pair<ll, ll> P; const ll mod = 1000000007; const ll LINF = 1LL << 60; const int INF = 1 << 30; int main() { string S; cin >> S; int n = (int)(S.length()); vector<int> dp(n + 2); int i = 0; dp[0] = 0; int tmp = 1; while (i < n - 1) { // cout << i << endl; // for (int j = 0;j < n; j++){ // cout << dp[j] << endl; // } if (tmp == 1) { if (S[i] != S[i + 1]) { dp[i + 1] = dp[i] + 1; i++; tmp = 1; } else { dp[i + 1] = dp[i]; dp[i + 2] = dp[i] + 1; i += 2; tmp = 2; } } else { dp[i + 1] = dp[i] + 1; i++; tmp = 1; } } if (dp[n - 1] == 0) { cout << dp[n - 1] << endl; } else { cout << dp[n - 1] + 1 << endl; } return 0; }
[ "assignment.change" ]
741,503
741,504
u471212175
cpp
p02939
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> Pii; typedef pair<ll, ll> Pll; #define rep(i, n) for (ll i = 0; i < n; ++i) const ll MOD = 1000000007; int main() { string S; cin >> S; int s = S.size(); int ans = 0; rep(i, s - 1) { if (S[i] != S[i + 1] && i != s - 2) { ans++; } else if (S[i] != S[i - 1] && i == s - 2) { ans += 2; } else if (i != s - 2) { ans += 2; i += 2; if (i == s - 2) { ans++; } } else { ans++; } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> Pii; typedef pair<ll, ll> Pll; #define rep(i, n) for (ll i = 0; i < n; ++i) const ll MOD = 1000000007; int main() { string S; cin >> S; int s = S.size(); int ans = 0; rep(i, s - 1) { if (S[i] != S[i + 1] && i != s - 2) { ans++; } else if (S[i] != S[i + 1] && i == s - 2) { ans += 2; } else if (i != s - 2) { ans += 2; i += 2; if (i == s - 2) { ans++; } } else { ans++; } } cout << ans << endl; }
[ "misc.opposites", "expression.operator.arithmetic.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change" ]
741,505
741,506
u275786410
cpp
p02939
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> Pii; typedef pair<ll, ll> Pll; #define rep(i, n) for (ll i = 0; i < n; ++i) const ll MOD = 1000000007; int main() { string S; cin >> S; int s = S.size(); int ans = 0; rep(i, s - 1) { if (S[i] != S[i + 1] && i != s - 2) { ans++; } else if (S[i] != S[i - 1] && i == s - 2) { ans += 2; } else if (i != s - 2) { ans += 2; i += 2; if (i != s - 2) { ans++; } } else { ans++; } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> Pii; typedef pair<ll, ll> Pll; #define rep(i, n) for (ll i = 0; i < n; ++i) const ll MOD = 1000000007; int main() { string S; cin >> S; int s = S.size(); int ans = 0; rep(i, s - 1) { if (S[i] != S[i + 1] && i != s - 2) { ans++; } else if (S[i] != S[i + 1] && i == s - 2) { ans += 2; } else if (i != s - 2) { ans += 2; i += 2; if (i == s - 2) { ans++; } } else { ans++; } } cout << ans << endl; }
[ "misc.opposites", "expression.operator.arithmetic.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change", "expression.operator.compare.change" ]
741,507
741,506
u275786410
cpp
p02939
#include <algorithm> #include <cstdio> #include <cstring> #define maxn 200005 using namespace std; char s[maxn]; int n, g[maxn]; int main() { scanf("%s", s + 1); n = strlen(s + 1); for (int i = 1; i <= n; i++) { g[i] = 1; if (i > 1 && s[i] != s[i - 1]) g[i] = g[i - 1] + 1; if (i > 3) g[i] = max(g[i], g[i - 3] + 2); } printf("%d", g[n]); return 0; }
#include <algorithm> #include <cstdio> #include <cstring> #define maxn 200005 using namespace std; char s[maxn]; int n, g[maxn]; int main() { scanf("%s", s + 1); n = strlen(s + 1); for (int i = 1; i <= n; i++) { g[i] = 1; if (i > 1 && s[i] != s[i - 1]) g[i] = g[i - 1] + 1; if (i >= 3) g[i] = max(g[i], g[i - 3] + 2); } printf("%d", g[n]); return 0; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
741,521
741,522
u921232185
cpp
p02939
#include <cstdio> #include <cstring> #define RI register int #define CI const int & using namespace std; const int N = 200005; char s[N]; int n, ans, pos; int main() { scanf("%s", s + 1); n = strlen(s + 1); ans = n; pos = 1; for (RI i = 2; i <= n; ++i) if (s[i] == s[pos]) --ans, pos = i + 1, i += 2; else pos = i; return printf("%d", ans), 0; }
#include <cstdio> #include <cstring> #define RI register int #define CI const int & using namespace std; const int N = 200005; char s[N]; int n, ans, pos; int main() { scanf("%s", s + 1); n = strlen(s + 1); ans = n; pos = 1; for (RI i = 2; i <= n; ++i) if (s[i] == s[pos]) --ans, pos = i + 2, i += 2; else pos = i; return printf("%d", ans), 0; }
[ "literal.number.change", "assignment.value.change", "expression.operation.binary.change" ]
741,528
741,529
u803115645
cpp
p02939
#include <bits/stdc++.h> using namespace std; int dp[2][200000]; int main() { string s; cin >> s; int n = s.length(); for (int i = 0; i < n; i++) { dp[0][i] = 0; dp[1][i] = 0; } dp[0][0] = 1; dp[1][1] = 1; dp[0][1] = s[0] != s[1]; for (int i = 2; i < n; i++) { if (s[i] != s[i - 1]) dp[0][i] = dp[0][i - 1] + 1; dp[0][i] = max(dp[1][i - 1] + 1, dp[0][i]); if (i > 3 && s.substr(i - 1, 2) != s.substr(i - 3, 2)) dp[1][i] = dp[1][i - 2] + 1; dp[1][i] = max(dp[0][i - 2] + 1, dp[1][i]); } cout << max(dp[0][n - 1], dp[1][n - 1]) << endl; }
#include <bits/stdc++.h> using namespace std; int dp[2][200000]; int main() { string s; cin >> s; int n = s.length(); for (int i = 0; i < n; i++) { dp[0][i] = 0; dp[1][i] = 0; } dp[0][0] = 1; dp[1][1] = 1; dp[0][1] = (s[0] != s[1]) + 1; for (int i = 2; i < n; i++) { if (s[i] != s[i - 1]) dp[0][i] = dp[0][i - 1] + 1; dp[0][i] = max(dp[1][i - 1] + 1, dp[0][i]); if (i > 3 && s.substr(i - 1, 2) != s.substr(i - 3, 2)) dp[1][i] = dp[1][i - 2] + 1; dp[1][i] = max(dp[0][i - 2] + 1, dp[1][i]); } cout << max(dp[0][n - 1], dp[1][n - 1]) << endl; }
[ "assignment.change" ]
741,530
741,531
u313766957
cpp
p02939
#include <algorithm> #include <bitset> #include <cassert> #include <ciso646> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <unordered_map> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef unsigned long long ul; typedef unsigned int ui; typedef long double ld; const ll mod = 1000000007; const ll INF = mod * mod; #define rep(i, n) for (int i = 0; i < n; i++) #define per(i, n) for (int i = n - 1; i >= 0; i--) #define Rep(i, sta, n) for (int i = sta; i < n; i++) #define rep1(i, n) for (int i = 1; i <= n; i++) #define per1(i, n) for (int i = n; i >= 1; i--) #define Rep1(i, sta, n) for (int i = sta; i <= n; i++) typedef complex<ld> Point; const ld eps = 1e-8; const ld pi = acos(-1.0); typedef pair<int, int> P; typedef pair<ld, ld> LDP; typedef pair<ll, ll> LP; typedef vector<int> vec; typedef vector<string> svec; #define fr first #define sc second #define all(c) c.begin(), c.end() #define pb push_back //#define int long long string s; void solve() { cin >> s; int n = s.size(); int ans = 0; int j = 0; char t = '?'; while (j < n) { if (j == n - 1) { if (t != s[j]) { ans++; j++; } else { j++; } } else if (j == n - 2) { if (s[j] != t && s[j] != s[j + 1]) { ans += 2; j += 2; } else { ans += 1; j++; } } else if (s[j] != t) { ans++; t = s[j]; j++; } else if (s[j] == t) { ans += 2; t = s[j + 2]; j += 3; } } cout << ans << endl; } signed main() { ios::sync_with_stdio(false); cin.tie(0); // cout << fixed << setprecision(10); // init(); solve(); // cout << "finish" << endl; return 0; }
#include <algorithm> #include <bitset> #include <cassert> #include <ciso646> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <unordered_map> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef unsigned long long ul; typedef unsigned int ui; typedef long double ld; const ll mod = 1000000007; const ll INF = mod * mod; #define rep(i, n) for (int i = 0; i < n; i++) #define per(i, n) for (int i = n - 1; i >= 0; i--) #define Rep(i, sta, n) for (int i = sta; i < n; i++) #define rep1(i, n) for (int i = 1; i <= n; i++) #define per1(i, n) for (int i = n; i >= 1; i--) #define Rep1(i, sta, n) for (int i = sta; i <= n; i++) typedef complex<ld> Point; const ld eps = 1e-8; const ld pi = acos(-1.0); typedef pair<int, int> P; typedef pair<ld, ld> LDP; typedef pair<ll, ll> LP; typedef vector<int> vec; typedef vector<string> svec; #define fr first #define sc second #define all(c) c.begin(), c.end() #define pb push_back //#define int long long string s; void solve() { cin >> s; int n = s.size(); int ans = 0; int j = 0; char t = '?'; while (j < n) { if (j == n - 1) { if (t != s[j]) { ans++; j++; } else { j++; } } else if (j == n - 2) { if (s[j] != t && s[j] != s[j + 1]) { ans += 2; j += 2; } else { ans += 1; j += 2; } } else if (s[j] != t) { ans++; t = s[j]; j++; } else if (s[j] == t) { ans += 2; t = s[j + 2]; j += 3; } } cout << ans << endl; } signed main() { ios::sync_with_stdio(false); cin.tie(0); // cout << fixed << setprecision(10); // init(); solve(); // cout << "finish" << endl; return 0; }
[]
741,532
741,533
u508571192
cpp
p02939
#include <algorithm> #include <bitset> #include <cctype> #include <climits> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <string> #include <typeinfo> #include <utility> #include <vector> using namespace std; using ll = long long; template <typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>; const ll inf = 1LL << 60; #define all(x) (x).begin(), (x).end() #define puts(x) cout << x << endl #define rep(i, m, n) for (ll i = m; i < n; ++i) #define pb push_back #define fore(i, a) for (auto &i : a) #define rrep(i, m, n) for (ll i = m; i >= n; --i) int dp[202020][4]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); string s; cin >> s; int N = s.size(); for (int i = 1; i <= N; i++) { for (int j = 1; j <= 3; j++) { if (i - j < 0) continue; for (int k = 0; k <= 3; k++) { if (k != j) dp[i][j] = max(dp[i - j][k] + 1, dp[i][j]); else if (i - 2 * j < 0) continue; else if (s.substr(i - 2 * j + 1, j) != s.substr(i - j + 1, j)) dp[i][j] = max(dp[i - j][k] + 1, dp[i][j]); } } } puts(max(dp[N][1], max(dp[N][2], dp[N][3]))); return 0; }
#include <algorithm> #include <bitset> #include <cctype> #include <climits> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <string> #include <typeinfo> #include <utility> #include <vector> using namespace std; using ll = long long; template <typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>; const ll inf = 1LL << 60; #define all(x) (x).begin(), (x).end() #define puts(x) cout << x << endl #define rep(i, m, n) for (ll i = m; i < n; ++i) #define pb push_back #define fore(i, a) for (auto &i : a) #define rrep(i, m, n) for (ll i = m; i >= n; --i) int dp[202020][4]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); string s; cin >> s; int N = s.size(); for (int i = 1; i <= N; i++) { for (int j = 1; j <= 3; j++) { if (i - j < 0) continue; for (int k = 0; k <= 3; k++) { if (k != j) dp[i][j] = max(dp[i - j][k] + 1, dp[i][j]); else if (i - 2 * j < 0) continue; else if (s.substr(i - 2 * j, j) != s.substr(i - j, j)) dp[i][j] = max(dp[i - j][k] + 1, dp[i][j]); } } } puts(max(dp[N][1], max(dp[N][2], dp[N][3]))); return 0; }
[ "control_flow.loop.for.condition.change", "call.arguments.change" ]
741,534
741,535
u632353278
cpp
p02939
//#pragma GCC optimize("O3") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> #define mem(a, v) memset((a), (v), sizeof(a)) #define enl printf("\n") #define case (t) printf("Case #%d: ", (t)) #define ni(n) scanf("%d", &(n)) #define nl(n) scanf("%lld", &(n)) #define nai(a, n) \ for (int i = 0; i < (n); i++) \ ni(a[i]) #define nal(a, n) \ for (int i = 0; i < (n); i++) \ nl(a[i]) #define pri(n) printf("%d\n", (n)) #define prl(n) printf("%lld\n", (n)) #define pii pair<int, int> #define pil pair<int, long long> #define pll pair<long long, long long> #define vii vector<pii> #define vil vector<pil> #define vll vector<pll> #define vi vector<int> #define vl vector<long long> #define pb push_back #define mp make_pair #define fi first #define se second using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef cc_hash_table<int, int, hash<int>> ht; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset; const double pi = acos(-1); const int MOD = 1e9 + 7; const int INF = 1e9 + 7; const int MAXN = 1e6 + 5; const double eps = 1e-9; char str[MAXN]; int dp[MAXN]; int main() { scanf("%s", str); int n = strlen(str); dp[0] = 1; if (n > 1) { if (str[0] == str[1]) dp[1] = 1; else dp[0] = 2; } for (int i = 2; i < n; i++) { if (str[i - 1] == str[i]) dp[i] = max(dp[i - 2] + 1, dp[i - 3] + 2); else dp[i] = dp[i - 1] + 1; } pri(dp[n - 1]); return 0; }
//#pragma GCC optimize("O3") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> #define mem(a, v) memset((a), (v), sizeof(a)) #define enl printf("\n") #define case (t) printf("Case #%d: ", (t)) #define ni(n) scanf("%d", &(n)) #define nl(n) scanf("%lld", &(n)) #define nai(a, n) \ for (int i = 0; i < (n); i++) \ ni(a[i]) #define nal(a, n) \ for (int i = 0; i < (n); i++) \ nl(a[i]) #define pri(n) printf("%d\n", (n)) #define prl(n) printf("%lld\n", (n)) #define pii pair<int, int> #define pil pair<int, long long> #define pll pair<long long, long long> #define vii vector<pii> #define vil vector<pil> #define vll vector<pll> #define vi vector<int> #define vl vector<long long> #define pb push_back #define mp make_pair #define fi first #define se second using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef cc_hash_table<int, int, hash<int>> ht; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset; const double pi = acos(-1); const int MOD = 1e9 + 7; const int INF = 1e9 + 7; const int MAXN = 1e6 + 5; const double eps = 1e-9; char str[MAXN]; int dp[MAXN]; int main() { scanf("%s", str); int n = strlen(str); dp[0] = 1; if (n > 1) { if (str[0] == str[1]) dp[1] = 1; else dp[1] = 2; } for (int i = 2; i < n; i++) { if (str[i - 1] == str[i]) dp[i] = max(dp[i - 2] + 1, dp[i - 3] + 2); else dp[i] = dp[i - 1] + 1; } pri(dp[n - 1]); return 0; }
[ "literal.number.change", "assignment.variable.change", "variable_access.subscript.index.change" ]
741,536
741,537
u270920804
cpp
p02939
#include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) for (int i = 0; i < (n); ++i) #define REPr(i, n) for (int i = (n)-1; i >= 0; --i) #define FORq(i, m, n) for (int i = (m); i <= (n); ++i) #define FORqr(i, m, n) for (int i = (n); i >= (m); --i) #define PB push_back #define MP make_pair #define DEBUG printf("%s\n", "debug") #define fst first #define snd second #define SIN(x, S) (S.count(x) != 0) #define M0(x) memset(x, 0, sizeof(x)) #define FILL(x, y) memset(x, y, sizeof(x)) #define MM(x) memset(x, -1, sizeof(x)) #define ALL(x) (x).begin(), (x).end() #define SCD(n) scanf("%d", &n) #define SCD2(m, n) scanf("%d%d", &m, &n) #define SCD3(m, n, k) scanf("%d%d%d", &m, &n, &k) #define SCLLD(n) scanf("%lld", &n) #define SCLLD2(m, n) scanf("%lld%lld", &m, &n) #define SCLLD3(m, n, k) scanf("%lld%lld%lld", &m, &n, &k) using namespace std; typedef pair<int, int> PII; typedef pair<long long, long long> PLL; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<long long> VL; typedef long long ll; typedef long long integer; /////////////////////////////////////////////// const ll MOD = 1e9 + 7; ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } /////////////////////////////////////////////// /*(._.)*/ int main() { string s; cin >> s; int N = s.length(); vector<int> dp1(200002); vector<int> dp2(200002); if (N == 1) { cout << 1 << endl; return 0; } if (s[0] == s[1]) { dp1[0] = 1; dp2[0] = 0; dp1[1] = 1; dp2[1] = 1; } else { dp1[0] = 1; dp2[0] = 0; dp1[1] = 2; dp2[1] = 1; } FORq(i, 2, N - 1) { if (s[i] == s[i - 1]) { dp1[i] = dp2[i - 1] + 1; dp2[i] = dp1[i - 1] + 1; } else { dp1[i] = dp1[i - 1] + 1; dp2[i] = dp1[i - 2] + 1; } } cout << max(dp1[N - 1], dp2[N - 1]) << endl; }
#include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) for (int i = 0; i < (n); ++i) #define REPr(i, n) for (int i = (n)-1; i >= 0; --i) #define FORq(i, m, n) for (int i = (m); i <= (n); ++i) #define FORqr(i, m, n) for (int i = (n); i >= (m); --i) #define PB push_back #define MP make_pair #define DEBUG printf("%s\n", "debug") #define fst first #define snd second #define SIN(x, S) (S.count(x) != 0) #define M0(x) memset(x, 0, sizeof(x)) #define FILL(x, y) memset(x, y, sizeof(x)) #define MM(x) memset(x, -1, sizeof(x)) #define ALL(x) (x).begin(), (x).end() #define SCD(n) scanf("%d", &n) #define SCD2(m, n) scanf("%d%d", &m, &n) #define SCD3(m, n, k) scanf("%d%d%d", &m, &n, &k) #define SCLLD(n) scanf("%lld", &n) #define SCLLD2(m, n) scanf("%lld%lld", &m, &n) #define SCLLD3(m, n, k) scanf("%lld%lld%lld", &m, &n, &k) using namespace std; typedef pair<int, int> PII; typedef pair<long long, long long> PLL; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<long long> VL; typedef long long ll; typedef long long integer; /////////////////////////////////////////////// const ll MOD = 1e9 + 7; ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } /////////////////////////////////////////////// /*(._.)*/ int main() { string s; cin >> s; int N = s.length(); vector<int> dp1(200002); vector<int> dp2(200002); if (N == 1) { cout << 1 << endl; return 0; } if (s[0] == s[1]) { dp1[0] = 1; dp2[0] = 0; dp1[1] = 1; dp2[1] = 1; } else { dp1[0] = 1; dp2[0] = 0; dp1[1] = 2; dp2[1] = 1; } FORq(i, 2, N - 1) { if (s[i] == s[i - 1]) { dp1[i] = dp2[i - 1] + 1; dp2[i] = dp1[i - 2] + 1; } else { dp1[i] = dp1[i - 1] + 1; dp2[i] = dp1[i - 2] + 1; } } cout << max(dp1[N - 1], dp2[N - 1]) << endl; }
[ "literal.number.change", "assignment.value.change", "variable_access.subscript.index.change", "expression.operation.binary.change" ]
741,538
741,539
u236433947
cpp
p02939
#include <bits/stdc++.h> typedef long long int ll; typedef long double ld; #define sync \ ios_base::sync_with_stdio(false); \ cin.tie(NULL) #define input(arr, n) \ for (ll i1 = 0; i1 < n; i1++) \ cin >> arr[i1] #define pb(x) push_back(x) #define si(a) scanf("%lld", &a) #define pi(a) printf("%lld", a) #define mod 1000000007 #define f first #define s second #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #pragma GCC optimize("O3") //recursions\ #pragma comment(linker, "/stack:200000000") //loops\ #pragma GCC optimize("unroll-loops") using namespace __gnu_pbds; #define ordered_set \ tree<ll, null_type, greater_equal<ll>, rb_tree_tag, \ tree_order_statistics_node_update> // s.order_of_key(val) // *s.find_by_order(ind) using namespace std; int main() { sync; string s; cin >> s; ll ans = s.length(); for (ll i = 1; i < s.length(); i++) { if (s[i] == s[i + 1]) { ans--; ++i; } } cout << ans; }
#include <bits/stdc++.h> typedef long long int ll; typedef long double ld; #define sync \ ios_base::sync_with_stdio(false); \ cin.tie(NULL) #define input(arr, n) \ for (ll i1 = 0; i1 < n; i1++) \ cin >> arr[i1] #define pb(x) push_back(x) #define si(a) scanf("%lld", &a) #define pi(a) printf("%lld", a) #define mod 1000000007 #define f first #define s second #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #pragma GCC optimize("O3") //recursions\ #pragma comment(linker, "/stack:200000000") //loops\ #pragma GCC optimize("unroll-loops") using namespace __gnu_pbds; #define ordered_set \ tree<ll, null_type, greater_equal<ll>, rb_tree_tag, \ tree_order_statistics_node_update> // s.order_of_key(val) // *s.find_by_order(ind) using namespace std; int main() { sync; string s; cin >> s; ll ans = s.length(); for (ll i = 1; i < s.length(); i++) { if (s[i] == s[i - 1]) { ans--; i += 2; } } cout << ans; }
[ "misc.opposites", "expression.operator.arithmetic.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change", "assignment.change" ]
741,540
741,541
u181228520
cpp
p02939
#include <bits/stdc++.h> #define lli long long int #define pb push_back #define mod 1000000007 #pragma GCC optimize("-O2") #define mod2 998244353 #define MAXN 1000000000 #define v32 vector<int> #define v64 vector<lli> #define v1024 vector<vector<int>> #define v4096 vector<vector<lli>> #define vt vector #define f(x, y, z) for (lli x = y; x < z; x++) #define fd(x, y, z) for (lli x = y; x > z; x--) #define lb lower_bound #define ld long double #define m64 map<lli, lli> #define m32 map<int, int> #define m64it map<lli, lli>::iterator #define m32it map<int, int>::iterator #define fastio \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) #define ist insert #define endl "\n" #include <ext/pb_ds/assoc_container.hpp> #define p_q priority_queue #define min_p_q priority_queue<int, vt<int>, greater<int>> using namespace std; using namespace __gnu_pbds; class UnionFind // rank is equal to number of vertices in a connected component { public: v32 p, rank; // remember: vi is vector<int> UnionFind(int N) { rank.assign(N, 1); p.assign(N, 0); for (int i = 0; i < N; i++) p[i] = i; } int findSet(int i) { return (p[i] == i) ? i : (p[i] = findSet(p[i])); } bool isSameSet(int i, int j) { return findSet(i) == findSet(j); } void unionSet(int i, int j) { if (!isSameSet(i, j)) { // if from different set int x = findSet(i), y = findSet(j); if (rank[x] > rank[y]) p[y] = x, rank[x] += rank[y]; // rank keeps the tree short else { p[x] = y; rank[y] += rank[x]; } } } }; class RMQ // gives index of min-max in a given range { public: struct node { int mn, mx, l, r; }; v32 h; vt<node> st; bool is_intersection(int l, int r, int ll, int rr) { if (r < ll || rr < l) return 0; return 1; } RMQ(v32 a) { h = a; st.resize(4 * h.size()); build(0, h.size() - 1); } void build(int l, int r, int k = 0) { st[k].l = l, st[k].r = r; if (l == r) { st[k].mx = st[k].mn = l; return; } build(l, (l + r) / 2, 2 * k + 1); build((l + r) / 2 + 1, r, 2 * k + 2); if (h[st[2 * k + 1].mn] <= h[st[2 * k + 2].mn]) st[k].mn = st[2 * k + 1].mn; else st[k].mn = st[2 * k + 2].mn; if (h[st[2 * k + 1].mx] >= h[st[2 * k + 2].mx]) st[k].mx = st[2 * k + 1].mx; else st[k].mx = st[2 * k + 2].mx; } int minquery(int l, int r, int k = 0) { if (l > r) return MAXN; int ll = st[k].l, rr = st[k].r, mid = (ll + rr) / 2; if (ll >= l && rr <= r) return st[k].mn; int ans = l; if (!(r < ll || mid < l)) ans = minquery(l, r, 2 * k + 1); if (!(r < mid + 1 || rr < l)) { if (h[ans] > h[minquery(l, r, 2 * k + 2)]) ans = minquery(l, r, 2 * k + 2); } return ans; } int maxquery(int l, int r, int k = 0) { if (l > r) return -MAXN; int ll = st[k].l, rr = st[k].r, mid = (ll + rr) / 2; if (ll >= l && rr <= r) return st[k].mx; int ans = l; if (!(r < ll || mid < l)) ans = maxquery(l, r, 2 * k + 1); if (!(r < mid + 1 || rr < l)) { if (h[ans] < h[maxquery(l, r, 2 * k + 2)]) ans = maxquery(l, r, 2 * k + 2); } return ans; } void update(int id, int val, int k = 0) { int l = st[k].l, r = st[k].r, mid = (l + r) / 2; if (l == r) { h[l] = val; return; } if (id >= l && id <= mid) update(id, val, 2 * k + 1); if (mid + 1 <= id && id <= r) update(id, val, 2 * k + 2); if (h[st[2 * k + 1].mn] <= h[st[2 * k + 2].mn]) st[k].mn = st[2 * k + 1].mn; else st[k].mn = st[2 * k + 2].mn; if (h[st[2 * k + 1].mx] >= h[st[2 * k + 2].mx]) st[k].mx = st[2 * k + 1].mx; else st[k].mx = st[2 * k + 2].mx; } }; class LAZY // currently set to set a given range by a value { public: struct node { int l, r, lazy = 0; lli lazyval = 0; lli sum = 0; }; vt<node> st; v32 h; LAZY(v32 a) { h = a; st.resize(4 * h.size()); cst(0, h.size() - 1); } int intersectiontype1(int l, int r, int ll, int rr) { if (r < ll || rr < l) return 0; return 1; } void cst(int l, int r, int k = 0) { st[k].l = l, st[k].r = r; if (l == r) { st[k].sum = h[l]; return; } cst(l, (l + r) / 2, 2 * k + 1); cst((l + r) / 2 + 1, r, 2 * k + 2); st[k].sum = st[2 * k + 1].sum + st[2 * k + 2].sum; } void shift(int k) { st[k].sum = (st[k].r - st[k].l + 1) * st[k].lazyval; if (st[k].l != st[k].r) { st[2 * k + 1].lazyval = st[k].lazyval; st[2 * k + 2].lazyval = st[k].lazyval; st[2 * k + 1].lazy = st[2 * k + 1].lazy = 1; st[2 * k + 2].lazy = st[2 * k + 2].lazy = 1; } st[k].lazyval = 0; st[k].lazy = 0; } lli query(int l, int r, int k = 0) { if (st[k].lazy != 0) shift(k); int ll = st[k].l, rr = st[k].r, mid = (ll + rr) / 2; if (ll >= l && rr <= r) return st[k].sum; lli ans = 0; if (intersectiontype1(ll, mid, l, r) == 1) ans = query(l, r, 2 * k + 1); if (intersectiontype1(1 + mid, rr, l, r) == 1) ans += query(l, r, 2 * k + 2); return ans; } void update(int l, int r, lli x, int k = 0) { if (l > r) return; int ll = st[k].l, rr = st[k].r, mid = (ll + rr) / 2; if (ll >= l && rr <= r) { st[k].lazyval = x; st[k].lazy = 1; return; } if (st[k].lazy != 0) shift(k); if (st[k].l == st[k].r) return; if (intersectiontype1(ll, mid, l, r) == 1) update(l, r, x, 2 * k + 1); if (intersectiontype1(mid + 1, rr, l, r) == 1) update(l, r, x, 2 * k + 2); if (st[2 * k + 1].lazy != 0) shift(2 * k + 1); if (st[2 * k + 2].lazy != 0) shift(2 * k + 2); st[k].sum = st[2 * k + 1].sum + st[2 * k + 2].sum; } int lower_bound(int l, int r, int val) { while (l != r) { int mid = (l + r) / 2; if (query(mid, mid) >= val) r = mid; else { l = mid + 1; if (mid + 1 < h.size()) if (query(mid + 1, mid + 1) > val) { l = mid; break; } } } return l; } }; class span { public: v32 a; span(){}; v32 max_left_border_without_equality() { int n = a.size(); v32 ta, al(n); f(i, 0, n) { if (ta.size() == 0) { ta.pb(i); al[i] = i; } else { while (a[i] > a[ta[ta.size() - 1]]) { ta.pop_back(); if (ta.size() == 0) break; } if (ta.size() == 0) { ta.pb(i); al[i] = 0; } else { al[i] = ta[ta.size() - 1] + 1; ta.pb(i); } } } return al; } v32 max_left_border_with_equality() { int n = a.size(); v32 ta, al(n); f(i, 0, n) { if (ta.size() == 0) { ta.pb(i); al[i] = i; } else { while (a[i] >= a[ta[ta.size() - 1]]) { ta.pop_back(); if (ta.size() == 0) break; } if (ta.size() == 0) { ta.pb(i); al[i] = 0; } else { al[i] = ta[ta.size() - 1] + 1; ta.pb(i); } } } return al; } v32 min_left_border_without_equality() { int n = a.size(); v32 ta, al(n); f(i, 0, n) { if (ta.size() == 0) { ta.pb(i); al[i] = i; } else { while (a[i] < a[ta[ta.size() - 1]]) { ta.pop_back(); if (ta.size() == 0) break; } if (ta.size() == 0) { ta.pb(i); al[i] = 0; } else { al[i] = ta[ta.size() - 1] + 1; ta.pb(i); } } } return al; } v32 min_left_border_with_equality() { int n = a.size(); v32 ta, al(n); f(i, 0, n) { if (ta.size() == 0) { ta.pb(i); al[i] = i; } else { while (a[i] <= a[ta[ta.size() - 1]]) { ta.pop_back(); if (ta.size() == 0) break; } if (ta.size() == 0) { ta.pb(i); al[i] = 0; } else { al[i] = ta[ta.size() - 1] + 1; ta.pb(i); } } } return al; } v32 max_right_border_without_equality() { int n = a.size(); reverse(a.begin(), a.end()); v32 ans = max_left_border_without_equality(); reverse(ans.begin(), ans.end()); f(i, 0, n) ans[i] = n - 1 - ans[i]; reverse(a.begin(), a.end()); return ans; } v32 max_right_border_with_equality() { int n = a.size(); reverse(a.begin(), a.end()); v32 ans = max_left_border_with_equality(); reverse(ans.begin(), ans.end()); f(i, 0, n) ans[i] = n - 1 - ans[i]; reverse(a.begin(), a.end()); return ans; } v32 min_right_border_without_equality() { int n = a.size(); reverse(a.begin(), a.end()); v32 ans = min_left_border_without_equality(); reverse(ans.begin(), ans.end()); f(i, 0, n) ans[i] = n - 1 - ans[i]; reverse(a.begin(), a.end()); return ans; } v32 min_right_border_with_equality() { int n = a.size(); reverse(a.begin(), a.end()); v32 ans = min_left_border_with_equality(); reverse(ans.begin(), ans.end()); f(i, 0, n) ans[i] = n - 1 - ans[i]; reverse(a.begin(), a.end()); return ans; } }; class merge_sort_tree { public: lli cnt(lli x, vector<int> &arr) { lli n = arr.size(); vector<int>::iterator low, high; low = lower_bound(arr.begin(), arr.end(), x); if (low == (arr.end()) || *low != x) return 0; high = upper_bound(low, arr.end(), x); return high - low; } lli get_last_smaller(vector<int> &v, int x) { lli first = 0, last = v.size() - 1; while (first <= last) { lli mid = (first + last) / 2; if (v[mid] >= x) last = mid - 1; else first = mid + 1; } return first - 1 < 0 ? -1 : first - 1; } struct node { int l, r; vector<pair<int, int>> arr; v32 arr2; }; v32 a; vt<node> st; merge_sort_tree(v32 b) { st.resize(4 * b.size()); a = b; build(0, b.size() - 1); } void build(int l, int r, int k = 0) { st[k].l = l, st[k].r = r; for (int i = l; i < r + 1; i++) st[k].arr.push_back({a[i], i}); sort(st[k].arr.begin(), st[k].arr.end()); f(i, 0, st[k].arr.size()) st[k].arr2.pb(st[k].arr[i].first); if (l == r) return; build(l, (l + r) / 2, 2 * k + 1); build((l + r) / 2 + 1, r, 2 * k + 2); } bool intersection(int l, int r, int ll, int rr) { if (ll > r || l > rr) return 0; return 1; } lli count_val_in_range(int l, int r, int t, int k = 0) { if (l > r) return 0; int ll = st[k].l, rr = st[k].r, mid = (ll + rr) / 2; if (ll >= l && rr <= r) return cnt(t, st[k].arr2); lli ans = 0; if (intersection(l, r, ll, mid) == 1) ans += count_val_in_range(l, r, t, 2 * k + 1); if (intersection(l, r, mid + 1, rr) == 1) ans += count_val_in_range(l, r, t, 2 * k + 2); return ans; } lli count_vals_less_than_given_val(int l, int r, int t, int k, vector<node> &st) { if (l > r) return 0; int ll = st[k].l, rr = st[k].r, mid = (ll + rr) / 2; if (ll >= l && rr <= r) return get_last_smaller(st[k].arr2, t) + 1; lli ans = 0; if (intersection(l, r, ll, mid) == 1) ans += count_vals_less_than_given_val(l, r, t, 2 * k + 1, st); if (intersection(l, r, mid + 1, rr) == 1) ans += count_vals_less_than_given_val(l, r, t, 2 * k + 2, st); return ans; } int find(int l, int r, int x, int k = 0) { if (l > r) return -1; int ll = st[k].l, rr = st[k].r, mid = (ll + rr) / 2; if (ll >= l && rr <= r) { int p = lower_bound(st[k].arr2.begin(), st[k].arr2.end(), x) - st[k].arr2.begin(); if (p == st[k].arr2.size()) return -1; if (st[k].arr2[p] == x) return st[k].arr[p].second; return -1; } int ans = -1; if (intersection(l, r, ll, mid) == 1) ans = find(l, r, x, 2 * k + 1); if (ans == -1 && intersection(l, r, mid + 1, rr) == 1) ans = find(l, r, x, 2 * k + 2); return ans; } }; void DEBUG_ARR(v32 a) { f(i, 0, a.size()) cout << a[i] << " "; cout << "\n"; } lli tmod(lli x, lli m) { return (x % m + m) % m; } // USE AT YOUR OWN RISK lli power(lli x, lli y) { lli res = 1; while (y > 0) { if (y & 1) res = (res * x) % mod; y = y >> 1; x = (x * x) % mod; } if (res < 0) res += mod; return res; } lli modInverse(lli a, lli m) { lli m0 = m; lli y = 0, x = 1; if (m == 1) return 0; while (a > 1) { lli q = a / m; lli t = m; m = a % m, a = t; t = y; y = x - q * y; x = t; } if (x < 0) x += m0; return x; } int dp[200000][2]; int main() { fastio; string s; cin >> s; dp[0][0] = 1; dp[0][1] = 0; if (s.size() > 1) dp[1][0] = (s[1] != s[0]); dp[1][1] = 1; f(i, 2, s.size()) { if (s[i] != s[i - 1]) { dp[i][0] = 1 + max(dp[i - 1][0], dp[i - 1][1]); dp[i][1] = 1 + dp[i - 2][0]; } else { dp[i][0] = max(1 + dp[i - 1][1], 1 + dp[i - 2][0]); dp[i][1] = 1 + dp[i - 2][0]; } } cout << max(dp[s.size() - 1][0], dp[s.size() - 1][1]); return 0; }
#include <bits/stdc++.h> #define lli long long int #define pb push_back #define mod 1000000007 #pragma GCC optimize("-O2") #define mod2 998244353 #define MAXN 1000000000 #define v32 vector<int> #define v64 vector<lli> #define v1024 vector<vector<int>> #define v4096 vector<vector<lli>> #define vt vector #define f(x, y, z) for (lli x = y; x < z; x++) #define fd(x, y, z) for (lli x = y; x > z; x--) #define lb lower_bound #define ld long double #define m64 map<lli, lli> #define m32 map<int, int> #define m64it map<lli, lli>::iterator #define m32it map<int, int>::iterator #define fastio \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) #define ist insert #define endl "\n" #include <ext/pb_ds/assoc_container.hpp> #define p_q priority_queue #define min_p_q priority_queue<int, vt<int>, greater<int>> using namespace std; using namespace __gnu_pbds; class UnionFind // rank is equal to number of vertices in a connected component { public: v32 p, rank; // remember: vi is vector<int> UnionFind(int N) { rank.assign(N, 1); p.assign(N, 0); for (int i = 0; i < N; i++) p[i] = i; } int findSet(int i) { return (p[i] == i) ? i : (p[i] = findSet(p[i])); } bool isSameSet(int i, int j) { return findSet(i) == findSet(j); } void unionSet(int i, int j) { if (!isSameSet(i, j)) { // if from different set int x = findSet(i), y = findSet(j); if (rank[x] > rank[y]) p[y] = x, rank[x] += rank[y]; // rank keeps the tree short else { p[x] = y; rank[y] += rank[x]; } } } }; class RMQ // gives index of min-max in a given range { public: struct node { int mn, mx, l, r; }; v32 h; vt<node> st; bool is_intersection(int l, int r, int ll, int rr) { if (r < ll || rr < l) return 0; return 1; } RMQ(v32 a) { h = a; st.resize(4 * h.size()); build(0, h.size() - 1); } void build(int l, int r, int k = 0) { st[k].l = l, st[k].r = r; if (l == r) { st[k].mx = st[k].mn = l; return; } build(l, (l + r) / 2, 2 * k + 1); build((l + r) / 2 + 1, r, 2 * k + 2); if (h[st[2 * k + 1].mn] <= h[st[2 * k + 2].mn]) st[k].mn = st[2 * k + 1].mn; else st[k].mn = st[2 * k + 2].mn; if (h[st[2 * k + 1].mx] >= h[st[2 * k + 2].mx]) st[k].mx = st[2 * k + 1].mx; else st[k].mx = st[2 * k + 2].mx; } int minquery(int l, int r, int k = 0) { if (l > r) return MAXN; int ll = st[k].l, rr = st[k].r, mid = (ll + rr) / 2; if (ll >= l && rr <= r) return st[k].mn; int ans = l; if (!(r < ll || mid < l)) ans = minquery(l, r, 2 * k + 1); if (!(r < mid + 1 || rr < l)) { if (h[ans] > h[minquery(l, r, 2 * k + 2)]) ans = minquery(l, r, 2 * k + 2); } return ans; } int maxquery(int l, int r, int k = 0) { if (l > r) return -MAXN; int ll = st[k].l, rr = st[k].r, mid = (ll + rr) / 2; if (ll >= l && rr <= r) return st[k].mx; int ans = l; if (!(r < ll || mid < l)) ans = maxquery(l, r, 2 * k + 1); if (!(r < mid + 1 || rr < l)) { if (h[ans] < h[maxquery(l, r, 2 * k + 2)]) ans = maxquery(l, r, 2 * k + 2); } return ans; } void update(int id, int val, int k = 0) { int l = st[k].l, r = st[k].r, mid = (l + r) / 2; if (l == r) { h[l] = val; return; } if (id >= l && id <= mid) update(id, val, 2 * k + 1); if (mid + 1 <= id && id <= r) update(id, val, 2 * k + 2); if (h[st[2 * k + 1].mn] <= h[st[2 * k + 2].mn]) st[k].mn = st[2 * k + 1].mn; else st[k].mn = st[2 * k + 2].mn; if (h[st[2 * k + 1].mx] >= h[st[2 * k + 2].mx]) st[k].mx = st[2 * k + 1].mx; else st[k].mx = st[2 * k + 2].mx; } }; class LAZY // currently set to set a given range by a value { public: struct node { int l, r, lazy = 0; lli lazyval = 0; lli sum = 0; }; vt<node> st; v32 h; LAZY(v32 a) { h = a; st.resize(4 * h.size()); cst(0, h.size() - 1); } int intersectiontype1(int l, int r, int ll, int rr) { if (r < ll || rr < l) return 0; return 1; } void cst(int l, int r, int k = 0) { st[k].l = l, st[k].r = r; if (l == r) { st[k].sum = h[l]; return; } cst(l, (l + r) / 2, 2 * k + 1); cst((l + r) / 2 + 1, r, 2 * k + 2); st[k].sum = st[2 * k + 1].sum + st[2 * k + 2].sum; } void shift(int k) { st[k].sum = (st[k].r - st[k].l + 1) * st[k].lazyval; if (st[k].l != st[k].r) { st[2 * k + 1].lazyval = st[k].lazyval; st[2 * k + 2].lazyval = st[k].lazyval; st[2 * k + 1].lazy = st[2 * k + 1].lazy = 1; st[2 * k + 2].lazy = st[2 * k + 2].lazy = 1; } st[k].lazyval = 0; st[k].lazy = 0; } lli query(int l, int r, int k = 0) { if (st[k].lazy != 0) shift(k); int ll = st[k].l, rr = st[k].r, mid = (ll + rr) / 2; if (ll >= l && rr <= r) return st[k].sum; lli ans = 0; if (intersectiontype1(ll, mid, l, r) == 1) ans = query(l, r, 2 * k + 1); if (intersectiontype1(1 + mid, rr, l, r) == 1) ans += query(l, r, 2 * k + 2); return ans; } void update(int l, int r, lli x, int k = 0) { if (l > r) return; int ll = st[k].l, rr = st[k].r, mid = (ll + rr) / 2; if (ll >= l && rr <= r) { st[k].lazyval = x; st[k].lazy = 1; return; } if (st[k].lazy != 0) shift(k); if (st[k].l == st[k].r) return; if (intersectiontype1(ll, mid, l, r) == 1) update(l, r, x, 2 * k + 1); if (intersectiontype1(mid + 1, rr, l, r) == 1) update(l, r, x, 2 * k + 2); if (st[2 * k + 1].lazy != 0) shift(2 * k + 1); if (st[2 * k + 2].lazy != 0) shift(2 * k + 2); st[k].sum = st[2 * k + 1].sum + st[2 * k + 2].sum; } int lower_bound(int l, int r, int val) { while (l != r) { int mid = (l + r) / 2; if (query(mid, mid) >= val) r = mid; else { l = mid + 1; if (mid + 1 < h.size()) if (query(mid + 1, mid + 1) > val) { l = mid; break; } } } return l; } }; class span { public: v32 a; span(){}; v32 max_left_border_without_equality() { int n = a.size(); v32 ta, al(n); f(i, 0, n) { if (ta.size() == 0) { ta.pb(i); al[i] = i; } else { while (a[i] > a[ta[ta.size() - 1]]) { ta.pop_back(); if (ta.size() == 0) break; } if (ta.size() == 0) { ta.pb(i); al[i] = 0; } else { al[i] = ta[ta.size() - 1] + 1; ta.pb(i); } } } return al; } v32 max_left_border_with_equality() { int n = a.size(); v32 ta, al(n); f(i, 0, n) { if (ta.size() == 0) { ta.pb(i); al[i] = i; } else { while (a[i] >= a[ta[ta.size() - 1]]) { ta.pop_back(); if (ta.size() == 0) break; } if (ta.size() == 0) { ta.pb(i); al[i] = 0; } else { al[i] = ta[ta.size() - 1] + 1; ta.pb(i); } } } return al; } v32 min_left_border_without_equality() { int n = a.size(); v32 ta, al(n); f(i, 0, n) { if (ta.size() == 0) { ta.pb(i); al[i] = i; } else { while (a[i] < a[ta[ta.size() - 1]]) { ta.pop_back(); if (ta.size() == 0) break; } if (ta.size() == 0) { ta.pb(i); al[i] = 0; } else { al[i] = ta[ta.size() - 1] + 1; ta.pb(i); } } } return al; } v32 min_left_border_with_equality() { int n = a.size(); v32 ta, al(n); f(i, 0, n) { if (ta.size() == 0) { ta.pb(i); al[i] = i; } else { while (a[i] <= a[ta[ta.size() - 1]]) { ta.pop_back(); if (ta.size() == 0) break; } if (ta.size() == 0) { ta.pb(i); al[i] = 0; } else { al[i] = ta[ta.size() - 1] + 1; ta.pb(i); } } } return al; } v32 max_right_border_without_equality() { int n = a.size(); reverse(a.begin(), a.end()); v32 ans = max_left_border_without_equality(); reverse(ans.begin(), ans.end()); f(i, 0, n) ans[i] = n - 1 - ans[i]; reverse(a.begin(), a.end()); return ans; } v32 max_right_border_with_equality() { int n = a.size(); reverse(a.begin(), a.end()); v32 ans = max_left_border_with_equality(); reverse(ans.begin(), ans.end()); f(i, 0, n) ans[i] = n - 1 - ans[i]; reverse(a.begin(), a.end()); return ans; } v32 min_right_border_without_equality() { int n = a.size(); reverse(a.begin(), a.end()); v32 ans = min_left_border_without_equality(); reverse(ans.begin(), ans.end()); f(i, 0, n) ans[i] = n - 1 - ans[i]; reverse(a.begin(), a.end()); return ans; } v32 min_right_border_with_equality() { int n = a.size(); reverse(a.begin(), a.end()); v32 ans = min_left_border_with_equality(); reverse(ans.begin(), ans.end()); f(i, 0, n) ans[i] = n - 1 - ans[i]; reverse(a.begin(), a.end()); return ans; } }; class merge_sort_tree { public: lli cnt(lli x, vector<int> &arr) { lli n = arr.size(); vector<int>::iterator low, high; low = lower_bound(arr.begin(), arr.end(), x); if (low == (arr.end()) || *low != x) return 0; high = upper_bound(low, arr.end(), x); return high - low; } lli get_last_smaller(vector<int> &v, int x) { lli first = 0, last = v.size() - 1; while (first <= last) { lli mid = (first + last) / 2; if (v[mid] >= x) last = mid - 1; else first = mid + 1; } return first - 1 < 0 ? -1 : first - 1; } struct node { int l, r; vector<pair<int, int>> arr; v32 arr2; }; v32 a; vt<node> st; merge_sort_tree(v32 b) { st.resize(4 * b.size()); a = b; build(0, b.size() - 1); } void build(int l, int r, int k = 0) { st[k].l = l, st[k].r = r; for (int i = l; i < r + 1; i++) st[k].arr.push_back({a[i], i}); sort(st[k].arr.begin(), st[k].arr.end()); f(i, 0, st[k].arr.size()) st[k].arr2.pb(st[k].arr[i].first); if (l == r) return; build(l, (l + r) / 2, 2 * k + 1); build((l + r) / 2 + 1, r, 2 * k + 2); } bool intersection(int l, int r, int ll, int rr) { if (ll > r || l > rr) return 0; return 1; } lli count_val_in_range(int l, int r, int t, int k = 0) { if (l > r) return 0; int ll = st[k].l, rr = st[k].r, mid = (ll + rr) / 2; if (ll >= l && rr <= r) return cnt(t, st[k].arr2); lli ans = 0; if (intersection(l, r, ll, mid) == 1) ans += count_val_in_range(l, r, t, 2 * k + 1); if (intersection(l, r, mid + 1, rr) == 1) ans += count_val_in_range(l, r, t, 2 * k + 2); return ans; } lli count_vals_less_than_given_val(int l, int r, int t, int k, vector<node> &st) { if (l > r) return 0; int ll = st[k].l, rr = st[k].r, mid = (ll + rr) / 2; if (ll >= l && rr <= r) return get_last_smaller(st[k].arr2, t) + 1; lli ans = 0; if (intersection(l, r, ll, mid) == 1) ans += count_vals_less_than_given_val(l, r, t, 2 * k + 1, st); if (intersection(l, r, mid + 1, rr) == 1) ans += count_vals_less_than_given_val(l, r, t, 2 * k + 2, st); return ans; } int find(int l, int r, int x, int k = 0) { if (l > r) return -1; int ll = st[k].l, rr = st[k].r, mid = (ll + rr) / 2; if (ll >= l && rr <= r) { int p = lower_bound(st[k].arr2.begin(), st[k].arr2.end(), x) - st[k].arr2.begin(); if (p == st[k].arr2.size()) return -1; if (st[k].arr2[p] == x) return st[k].arr[p].second; return -1; } int ans = -1; if (intersection(l, r, ll, mid) == 1) ans = find(l, r, x, 2 * k + 1); if (ans == -1 && intersection(l, r, mid + 1, rr) == 1) ans = find(l, r, x, 2 * k + 2); return ans; } }; void DEBUG_ARR(v32 a) { f(i, 0, a.size()) cout << a[i] << " "; cout << "\n"; } lli tmod(lli x, lli m) { return (x % m + m) % m; } // USE AT YOUR OWN RISK lli power(lli x, lli y) { lli res = 1; while (y > 0) { if (y & 1) res = (res * x) % mod; y = y >> 1; x = (x * x) % mod; } if (res < 0) res += mod; return res; } lli modInverse(lli a, lli m) { lli m0 = m; lli y = 0, x = 1; if (m == 1) return 0; while (a > 1) { lli q = a / m; lli t = m; m = a % m, a = t; t = y; y = x - q * y; x = t; } if (x < 0) x += m0; return x; } int dp[200000][2]; int main() { fastio; string s; cin >> s; dp[0][0] = 1; dp[0][1] = 0; if (s.size() > 1) dp[1][0] = 2 * (s[1] != s[0]); dp[1][1] = 1; f(i, 2, s.size()) { if (s[i] != s[i - 1]) { dp[i][0] = 1 + max(dp[i - 1][0], dp[i - 1][1]); dp[i][1] = 1 + dp[i - 2][0]; } else { dp[i][0] = max(1 + dp[i - 1][1], 1 + dp[i - 2][0]); dp[i][1] = 1 + dp[i - 2][0]; } } cout << max(dp[s.size() - 1][0], dp[s.size() - 1][1]); return 0; }
[ "assignment.change" ]
741,542
741,543
u624171666
cpp
p02939
// AtCoder Grand Contest 037 // A - Dividing String #include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int s_size = s.size() - 1; int k = 1; int cur = 1; string si; string si1; si = s.at(0); si1 = s.at(1); while (cur <= s_size) { while (cur <= s_size) { if (si != si1) { cur++; k++; si = si1; if (cur <= s_size) { si1 = s.at(cur); } break; } else { cur++; if (cur > s_size) { k++; break; } si1 += s.at(cur); } } } cout << k << endl; }
// AtCoder Grand Contest 037 // A - Dividing String #include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int s_size = s.size() - 1; int k = 1; int cur = 1; string si; string si1; si = s.at(0); si1 = s.at(1); while (cur <= s_size) { while (cur <= s_size) { if (si != si1) { cur++; k++; si = si1; if (cur <= s_size) { si1 = s.at(cur); } break; } else { cur++; if (cur > s_size) { break; } si1 += s.at(cur); } } } cout << k << endl; }
[ "expression.unary.arithmetic.remove" ]
741,544
741,545
u370865069
cpp
p02939
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; long int N; N = S.length(); vector<int> a(N); for (int i = 0; i < N; i++) { if (i == 0) { a.at(i) = 1; } if (i == 1) { if (S.at(i - 1) == S.at(i)) { a.at(i) = 1; } else { a.at(i) = 2; } } if (i == 2) { if (S.at(i - 2) == S.at(i - 1) || S.at(i - 1) == S.at(i)) { a.at(i) = 2; } else { a.at(i) = 3; } } else { if (S.at(i - 1) == S.at(i)) { a.at(i) = a.at(i - 3) + 2; } else { a.at(i) = a.at(i - 1) + 1; } } } cout << a.at(N - 1) << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; long int N; N = S.length(); vector<int> a(N); for (int i = 0; i < N; i++) { if (i == 0) { a.at(i) = 1; } else if (i == 1) { if (S.at(i - 1) == S.at(i)) { a.at(i) = 1; } else { a.at(i) = 2; } } else if (i == 2) { if (S.at(i - 2) == S.at(i - 1) || S.at(i - 1) == S.at(i)) { a.at(i) = 2; } else { a.at(i) = 3; } } else { if (S.at(i - 1) == S.at(i)) { a.at(i) = a.at(i - 3) + 2; } else { a.at(i) = a.at(i - 1) + 1; } } } cout << a.at(N - 1) << endl; }
[ "control_flow.branch.else_if.replace.add", "control_flow.branch.if.replace.remove" ]
741,552
741,553
u072774815
cpp
p02939
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; int N; N = S.length(); vector<int> a(N, 0); for (int i = 0; i < N; i++) { if (i == 0) { a.at(i) = 1; } if (i == 1) { if (S.at(i - 1) == S.at(i)) { a.at(i) = 1; } else { a.at(i) = 2; } } if (i == 2) { if (S.at(i - 2) == S.at(i - 1) || S.at(i - 1) == S.at(i)) { a.at(i) = 2; } else { a.at(i) = 3; } } else { if (S.at(i - 1) == S.at(i)) { a.at(i) = a.at(i - 3) + 2; } else { a.at(i) = a.at(i - 1) + 1; } } } cout << a.at(N - 1) << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; long int N; N = S.length(); vector<int> a(N); for (int i = 0; i < N; i++) { if (i == 0) { a.at(i) = 1; } else if (i == 1) { if (S.at(i - 1) == S.at(i)) { a.at(i) = 1; } else { a.at(i) = 2; } } else if (i == 2) { if (S.at(i - 2) == S.at(i - 1) || S.at(i - 1) == S.at(i)) { a.at(i) = 2; } else { a.at(i) = 3; } } else { if (S.at(i - 1) == S.at(i)) { a.at(i) = a.at(i - 3) + 2; } else { a.at(i) = a.at(i - 1) + 1; } } } cout << a.at(N - 1) << endl; }
[ "variable_declaration.type.widen.change", "call.arguments.change", "control_flow.branch.else_if.replace.add", "control_flow.branch.if.replace.remove" ]
741,554
741,553
u072774815
cpp
p02939
// ---------------------------------------------------------- #include <algorithm> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; int main(int argc, const char *argv[]) { cin.tie(0); ios::sync_with_stdio(false); string S; long cnt = 0; int flg = 0; cin >> S; flg = 0; for (int i = 0; i < S.length(); i++) { if (i << S.length() && S[i] == S[i + 1] && flg == 0) { flg = 1; i++; } else { flg = 0; } cnt++; } cout << cnt << endl; return 0; }
// ---------------------------------------------------------- #include <algorithm> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; int main(int argc, const char *argv[]) { cin.tie(0); ios::sync_with_stdio(false); string S; long cnt = 0; int flg = 0; cin >> S; flg = 0; for (int i = 0; i < S.length(); i++) { if (i < S.length() && S[i] == S[i + 1] && flg == 0) { flg = 1; i++; } else { flg = 0; } cnt++; } cout << cnt << endl; return 0; }
[ "misc.typo", "control_flow.branch.if.condition.change" ]
741,583
741,584
u335104842
cpp
p02939
#include <bits/stdc++.h> #include <iostream> #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define ll long long #define pii std::pair<int, int> #define pli std::pair<ll, int> #define pil std::pair<int, ll> #define psi std::pair<string, int> #define pll std::pair<ll, ll> #define pci std::pair<char, int> #define sll(x) scanf("%lld", &x) #define prll(x) printf("%lld ", x) #define pri(x) printf("%d ", x) #define si(x) scanf("%d", &x) #define pb push_back #define vll std::vector<ll> #define vpi std::vector<std::pair<int, int>> #define vi std::vector<int> #define vvi std::vector<std::vector<int>> #define vvpil std::vector<std::vector<std::pair<int, ll>>> #define vlpii std::vector<std::list<pii>> #define vlpil std::vector<std::list<pil>> #define li std::list<int> #define lpil std::list<pil> #define Endl printf("\n") #define vli vector<list<int>> #define vvll vector<vector<ll>> #define mp make_pair #define x first #define y second #define ma 100000000 #define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " const ll INF = 10000000000000; const ll mod = 1e9 + 7; using namespace std; void add(int &a, int b) { a += b; if (a >= mod) a -= mod; } ll mul(ll a, ll b) { return (a * b) % mod; } int solve(string s) { int n = s.length(); if (n == 1) return cout << 1 << endl, 0; vector<string> v; int fin = n - 2; int nb = 1; while (fin >= 0 && s[fin] == s[n - 1]) { fin--; nb++; } bool b = false; for (int i = 0; i <= fin; i++) { string t = ""; t += s[i]; if (!v.size()) v.push_back(t); else { if (v[v.size() - 1] == t && i < fin) { t += s[i + 1]; i++; v.pb(t); } else if (t != v[v.size() - 1]) v.pb(t); else b = true; } } nb -= b; vi verif1; int tmp = nb; while (tmp) { if (!verif1.size()) { verif1.pb(1); tmp--; } else if (verif1[verif1.size() - 1] == 1 && tmp >= 2) { verif1.pb(2); tmp -= 2; } else { verif1.pb(1); tmp--; } } int res = -1; if (verif1.size() == 1 || verif1[verif1.size() - 1] != verif1[verif1.size() - 2]) res = verif1.size(); if (res == -1) { tmp = nb; verif1.clear(); while (tmp) { if (!verif1.size() && tmp >= 2) { verif1.pb(2); tmp -= 2; } else if (verif1[verif1.size() - 1] == 1 && tmp >= 2) { verif1.pb(2); tmp -= 2; } else { verif1.pb(1); tmp--; } } res = verif1.size(); } return res + v.size() + b; } int main() { IOS; string s; cin >> s; int ans1 = solve(s); cout << ans1 << endl; return 0; }
#include <bits/stdc++.h> #include <iostream> #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define ll long long #define pii std::pair<int, int> #define pli std::pair<ll, int> #define pil std::pair<int, ll> #define psi std::pair<string, int> #define pll std::pair<ll, ll> #define pci std::pair<char, int> #define sll(x) scanf("%lld", &x) #define prll(x) printf("%lld ", x) #define pri(x) printf("%d ", x) #define si(x) scanf("%d", &x) #define pb push_back #define vll std::vector<ll> #define vpi std::vector<std::pair<int, int>> #define vi std::vector<int> #define vvi std::vector<std::vector<int>> #define vvpil std::vector<std::vector<std::pair<int, ll>>> #define vlpii std::vector<std::list<pii>> #define vlpil std::vector<std::list<pil>> #define li std::list<int> #define lpil std::list<pil> #define Endl printf("\n") #define vli vector<list<int>> #define vvll vector<vector<ll>> #define mp make_pair #define x first #define y second #define ma 100000000 #define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " const ll INF = 10000000000000; const ll mod = 1e9 + 7; using namespace std; void add(int &a, int b) { a += b; if (a >= mod) a -= mod; } ll mul(ll a, ll b) { return (a * b) % mod; } int solve(string s) { int n = s.length(); if (n == 1) return cout << 1 << endl, 0; vector<string> v; int fin = n - 2; int nb = 1; while (fin >= 0 && s[fin] == s[n - 1]) { fin--; nb++; } bool b = false; for (int i = 0; i <= fin; i++) { string t = ""; t += s[i]; if (!v.size()) v.push_back(t); else { if (v[v.size() - 1] == t && i < fin) { t += s[i + 1]; i++; v.pb(t); } else if (t != v[v.size() - 1]) v.pb(t); else b = true; } } nb -= b; vi verif1; int tmp = nb; while (tmp) { if (!verif1.size()) { verif1.pb(1); tmp--; } else if (verif1[verif1.size() - 1] == 1 && tmp >= 2) { verif1.pb(2); tmp -= 2; } else { verif1.pb(1); tmp--; } } int res = -1; if (verif1.size() <= 1 || verif1[verif1.size() - 1] != verif1[verif1.size() - 2]) res = verif1.size(); if (res == -1) { tmp = nb; verif1.clear(); while (tmp) { if (!verif1.size() && tmp >= 2) { verif1.pb(2); tmp -= 2; } else if (verif1[verif1.size() - 1] == 1 && tmp >= 2) { verif1.pb(2); tmp -= 2; } else { verif1.pb(1); tmp--; } } res = verif1.size(); } return res + v.size() + b; } int main() { IOS; string s; cin >> s; int ans1 = solve(s); cout << ans1 << endl; return 0; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
741,585
741,586
u752814744
cpp
p02939
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < int(n); ++i) #define rep1(i, n) for (int i = 1; i <= int(n); ++i) int dp[200010][3]; int main(void) { string s; cin >> s; int n = s.size(); s += "_"; rep(i, n) { rep1(d, 2) { if (i >= d) { if (s.substr(i - d, d) != s.substr(i, d)) { dp[i + d][d] = max(dp[i + d][d], dp[i][d] + d); } } } dp[i + 1][1] = max(dp[i + 1][1], dp[i][2]); dp[i + 2][2] = max(dp[i + 2][2], dp[i][1]); } cout << max(dp[n][1], dp[n][2]) << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < int(n); ++i) #define rep1(i, n) for (int i = 1; i <= int(n); ++i) int dp[200010][3]; int main(void) { string s; cin >> s; int n = s.size(); s += "_"; rep(i, n) { rep1(d, 2) { if (i >= d) { if (s.substr(i - d, d) != s.substr(i, d)) { dp[i + d][d] = max(dp[i + d][d], dp[i][d] + 1); } } } dp[i + 1][1] = max(dp[i + 1][1], dp[i][2] + 1); dp[i + 2][2] = max(dp[i + 2][2], dp[i][1] + 1); } cout << max(dp[n][1], dp[n][2]) << endl; return 0; }
[ "assignment.value.change", "identifier.replace.remove", "literal.replace.add", "call.arguments.change", "expression.operation.binary.change", "assignment.change" ]
741,591
741,592
u241615199
cpp
p02939
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <limits> #include <map> #include <memory> #include <numeric> #include <queue> #include <set> #include <string> #include <thread> #include <tuple> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; int main() { ios_base::sync_with_stdio(false); string s; cin >> s; int n = s.length(); vector<int> dp1(n, -1), dp2(n, -1); if (n >= 1) dp1[0] = 1; if (n >= 2) dp2[1] = 1; for (int i = 0; i < n; i++) { if (dp1[i] >= 0) { if (i + 1 < n && s[i] != s[i + 1]) { dp1[i + 1] = max(dp1[i + 1], dp1[i] + 1); } else if (i + 2 < n) { dp2[i + 2] = max(dp2[i + 2], dp1[i] + 1); } } if (dp2[i] >= 0) { if (i + 1 < n) { dp1[i + 1] = max(dp1[i + 1], dp2[i] + 1); } else if (i + 2 < n && (s[i] != s[i + 2] || s[i - 1] != s[i + 1])) { dp2[i + 2] = max(dp2[i + 2], dp2[i] + 1); } } } int ans = -1; if (n >= 1) ans = max(dp1[n - 1], dp2[n - 1]); cout << ans << "\n"; return 0; }
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <limits> #include <map> #include <memory> #include <numeric> #include <queue> #include <set> #include <string> #include <thread> #include <tuple> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; int main() { ios_base::sync_with_stdio(false); string s; cin >> s; int n = s.length(); vector<int> dp1(n, -1), dp2(n, -1); if (n >= 1) dp1[0] = 1; if (n >= 2) dp2[1] = 1; for (int i = 0; i < n; i++) { if (dp1[i] >= 0) { if (i + 1 < n && s[i] != s[i + 1]) { dp1[i + 1] = max(dp1[i + 1], dp1[i] + 1); } if (i + 2 < n) { dp2[i + 2] = max(dp2[i + 2], dp1[i] + 1); } } if (dp2[i] >= 0) { if (i + 1 < n) { dp1[i + 1] = max(dp1[i + 1], dp2[i] + 1); } if (i + 2 < n && (s[i] != s[i + 2] || s[i - 1] != s[i + 1])) { dp2[i + 2] = max(dp2[i + 2], dp2[i] + 1); } } } int ans = 1; if (n >= 1) ans = max(dp1[n - 1], dp2[n - 1]); cout << ans << "\n"; return 0; }
[ "control_flow.branch.if.replace.add", "control_flow.branch.else_if.replace.remove", "expression.operation.unary.arithmetic.remove" ]
741,595
741,596
u801094318
cpp
p02939
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vll = vector<ll>; using vvi = vector<vector<int>>; using vvl = vector<vector<ll>>; ll dp[202020][3] = {0}; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); string s; cin >> s; int n = s.size(); string t = "^ " + s; for (int i = 0; i < n; i++) { if (s[i + 2] != s[i + 1]) { dp[i + 1][0] = dp[i][0] + 1; } if (i > 1 && (s[i + 2] != s[i] || s[i + 1] != s[i - 1])) { dp[i + 1][1] = dp[i - 1][1] + 1; } dp[i + 1][0] = max(dp[i + 1][0], dp[i][1] + 1); if (i > 0) { dp[i + 1][1] = max(dp[i + 1][1], dp[i - 1][0] + 1); } } cout << max(dp[n][0], dp[n][1]) << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vll = vector<ll>; using vvi = vector<vector<int>>; using vvl = vector<vector<ll>>; ll dp[202020][3] = {0}; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); string s; cin >> s; int n = s.size(); string t = "^ " + s; for (int i = 0; i < n; i++) { if (t[i + 2] != t[i + 1]) { dp[i + 1][0] = dp[i][0] + 1; } if (i > 1 && (t[i + 2] != t[i] || t[i + 1] != t[i - 1])) { dp[i + 1][1] = dp[i - 1][1] + 1; } dp[i + 1][0] = max(dp[i + 1][0], dp[i][1] + 1); if (i > 0) { dp[i + 1][1] = max(dp[i + 1][1], dp[i - 1][0] + 1); } } cout << max(dp[n][0], dp[n][1]) << endl; return 0; }
[ "identifier.change", "control_flow.branch.if.condition.change" ]
741,615
741,616
u656572785
cpp
p02939
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; long long ans = 1LL; auto tmp1 = string() + s[0]; auto tmp2 = string() + s[1]; bool flag = false; int i = 1; for (i; i < s.size() - 1; ++i) { tmp2 = string() + s[i]; if (tmp1 == tmp2) { ++i; tmp2 += s[i]; ans++; } else { ans++; } tmp1 = tmp2; } if (i == s.size() - 2 && tmp1 != string() + s[s.size() - 1]) { ans++; } if (s.size() == 1) { ans = 1; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; long long ans = 1LL; auto tmp1 = string() + s[0]; auto tmp2 = string() + s[1]; bool flag = false; int i = 1; for (i; i < s.size() - 1; i++) { tmp2 = string() + s[i]; if (tmp1 == tmp2) { ++i; tmp2 += s[i]; ans++; } else { ans++; } tmp1 = tmp2; } if (i == s.size() - 1 && tmp1 != string() + s[s.size() - 1]) { ans++; } if (s.size() == 1) { ans = 1; } cout << ans << endl; }
[ "literal.number.change", "control_flow.branch.if.condition.change" ]
741,629
741,630
u449758089
cpp
p02939
#include <algorithm> #include <deque> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> #define vv(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c)) #define vvi std::vector<std::vector<int>> #define vvl std::vector<std::vector<ll>> #define MODs 1000000007; typedef long long int ll; using namespace std; int main(int argc, char const *argv[]) { string S; std::cin >> S; std::vector<pair<char, int>> ans; char now = 'A'; for (int i = 0; i < S.size(); i++) { if (now != S[i]) { ans.push_back(make_pair(S[i], 1)); now = S[i]; } else ans[ans.size() - 1].second++; } int count = 0; for (int i = 0; i < ans.size() - 1; i++) { if (ans[i].second >= 2 && ans[i - 1].second >= 2 && ans[i].second % 3 != 1) { ans[i].second--, ans[i + 1].second--; count++; } } for (int i = 0; i < ans.size(); i++) { if (ans[i].second >= 1) { if (ans[i].second % 3 == 0) count += 2 * (ans[i].second / 3); else if (ans[i].second % 3 == 1) count += 2 * (ans[i].second / 3) + 1; else count += 2 * (ans[i].second / 3) + 1; } // std::cout << count << " " << i << " "<< ans[i].second<< '\n'; } std::cout << count << '\n'; return 0; }
#include <algorithm> #include <deque> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> #define vv(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c)) #define vvi std::vector<std::vector<int>> #define vvl std::vector<std::vector<ll>> #define MODs 1000000007; typedef long long int ll; using namespace std; int main(int argc, char const *argv[]) { string S; std::cin >> S; std::vector<pair<char, int>> ans; char now = 'A'; for (int i = 0; i < S.size(); i++) { if (now != S[i]) { ans.push_back(make_pair(S[i], 1)); now = S[i]; } else ans[ans.size() - 1].second++; } int count = 0; for (int i = 0; i < ans.size() - 1; i++) { if (ans[i].second >= 2 && ans[i + 1].second >= 2 && ans[i].second % 3 == 2) { ans[i].second--, ans[i + 1].second--; count++; } } for (int i = 0; i < ans.size(); i++) { if (ans[i].second >= 1) { if (ans[i].second % 3 == 0) count += 2 * (ans[i].second / 3); else if (ans[i].second % 3 == 1) count += 2 * (ans[i].second / 3) + 1; else count += 2 * (ans[i].second / 3) + 1; } } std::cout << count << '\n'; return 0; }
[ "misc.opposites", "expression.operator.arithmetic.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change" ]
741,631
741,632
u816587940
cpp
p02939
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define all(a) (a).begin(), (a).end() #define ll long long int main() { string S, T; cin >> S; T = S[S.size() - 1]; rep(i, S.size() - 2) T += S[S.size() - 2 - i]; string SS; SS = S[0]; int ans = 0, c = 0; string TT; TT = T[0]; int ans2 = 0, c2 = 0; if (S.size() == 1) cout << 1 << endl; else { rep(i, S.size() - 1) { if (i) { if (SS.size() > 1 || SS[0] != S[i]) SS = S[i]; else { SS = S[i]; SS += S[++i]; } c = i; } ans++; } if (c == S.size() - 2 && SS.size() != 1 || S[S.size() - 2] != S[S.size() - 1]) ans++; rep(i, T.size() - 1) { if (i) { if (TT.size() > 1 || TT[0] != T[i]) TT = T[i]; else { TT = T[i]; TT += T[++i]; } c2 = i; } ans2++; } if (c2 == T.size() - 2 && TT.size() != 1 || T[T.size() - 2] != T[T.size() - 1]) ans2++; cout << max(ans, ans2) << endl; } }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define all(a) (a).begin(), (a).end() #define ll long long int main() { string S, T; cin >> S; T = S[S.size() - 1]; rep(i, S.size() - 1) T += S[S.size() - 2 - i]; string SS; SS = S[0]; int ans = 0, c = 0; string TT; TT = T[0]; int ans2 = 0, c2 = 0; if (S.size() == 1) cout << 1 << endl; else { rep(i, S.size() - 1) { if (i) { if (SS.size() > 1 || SS[0] != S[i]) SS = S[i]; else { SS = S[i]; SS += S[++i]; } c = i; } ans++; } if (c == S.size() - 2 && SS.size() != 1 || S[S.size() - 2] != S[S.size() - 1]) ans++; rep(i, T.size() - 1) { if (i) { if (TT.size() > 1 || TT[0] != T[i]) TT = T[i]; else { TT = T[i]; TT += T[++i]; } c2 = i; } ans2++; } if (c2 == T.size() - 2 && TT.size() != 1 || T[T.size() - 2] != T[T.size() - 1]) ans2++; cout << min(ans, ans2) << endl; } }
[ "literal.number.change", "assignment.variable.change", "call.arguments.change", "expression.operation.binary.change", "misc.opposites", "identifier.change", "call.function.change", "io.output.change" ]
741,640
741,641
u154756110
cpp
p02939
#include <algorithm> #include <cmath> #include <functional> #include <iomanip> #include <iostream> #include <numeric> #include <queue> #include <stack> #include <string> #include <vector> #define repd(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, n) repd(i, 0, n) typedef long long ll; using namespace std; int inputValue() { int a; cin >> a; return a; }; void inputArray(int *p, int a){rep(i, a){cin >> p[i]; } } ; void inputVector(vector<int> *p, int a) { rep(i, a) { int input; cin >> input; p->push_back(input); } } template <typename T> void output(T a, int precision) { if (precision > 0) { cout << setprecision(precision) << a << "\n"; } else { cout << a << "\n"; } } int main(int argc, const char *argv[]) { // source code string ss; cin >> ss; int vccount = 0; vector<string> vc; rep(i, ss.length()) { vc.push_back(&ss[i]); if (vc.size() > 1 && (vc.at(vc.size() - 2) == string() + ss[i])) { if (i == ss.length() - 1) { cout << vc.size() - 1; return 0; } else { vc.at(vc.size() - 1) = vc.at(vc.size() - 1) + ss[i + 1]; i++; } } } cout << vc.size(); return 0; }
#include <algorithm> #include <cmath> #include <functional> #include <iomanip> #include <iostream> #include <numeric> #include <queue> #include <stack> #include <string> #include <vector> #define repd(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, n) repd(i, 0, n) typedef long long ll; using namespace std; int inputValue() { int a; cin >> a; return a; }; void inputArray(int *p, int a){rep(i, a){cin >> p[i]; } } ; void inputVector(vector<int> *p, int a) { rep(i, a) { int input; cin >> input; p->push_back(input); } } template <typename T> void output(T a, int precision) { if (precision > 0) { cout << setprecision(precision) << a << "\n"; } else { cout << a << "\n"; } } int main(int argc, const char *argv[]) { // source code string ss; cin >> ss; int vccount = 0; vector<string> vc; rep(i, ss.length()) { vc.push_back(string() + ss[i]); if (vc.size() > 1 && (vc.at(vc.size() - 2) == string() + ss[i])) { if (i == ss.length() - 1) { cout << vc.size() - 1; return 0; } else { vc.at(vc.size() - 1) = vc.at(vc.size() - 1) + ss[i + 1]; i++; } } } cout << vc.size(); return 0; }
[ "call.arguments.change" ]
741,665
741,666
u647592933
cpp
p02939
#include <cstdio> #include <iostream> #include <string> using namespace std; int main() { string str; cin >> str; int sum = 0, len = str.size(); bool judge = false; //标记前一个子串是否为两个字符,true为是 int i; sum++; for (i = 1; i < len - 1; i++) { if (str[i] == str[i - 1] && judge == false) { judge = true; sum++; i++; } else { judge = false; sum++; } } if (i == (len - 1)) //最后剩一个字符 { if (str[len - 2] == str[len - 1]) ; else sum++; } printf("%d\n", sum); return 0; }
#include <cstdio> #include <iostream> #include <string> using namespace std; int main() { string str; cin >> str; int sum = 0, len = str.size(); bool judge = false; //标记前一个子串是否为两个字符,true为是 int i; sum++; for (i = 1; i < len - 1; i++) { if (str[i] == str[i - 1] && judge == false) { judge = true; sum++; i++; } else { judge = false; sum++; } } if (i == (len - 1)) //最后剩一个字符 { if (str[len - 2] == str[len - 1] && judge == false) ; else sum++; } printf("%d\n", sum); return 0; }
[ "control_flow.branch.if.condition.change" ]
741,673
741,674
u286704543
cpp
p02939
/** * Name: Ajay * Institute: IIITH */ #include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string.h> #include <vector> #define ll long long #define inf 0x7fffffff #define mod 1000000007 #define pb push_back #define ppi pair<int, int> #define vi vector<int> #define vvi vector<vector<int>> #define vii vector<ppi> #define vll vector<ll> #define mp make_pair #define fi first #define se second using namespace std; void fastio() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); } void input() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif } int main() { fastio(); input(); string s; cin >> s; int n, i, k = 0; n = s.size(); string temp = "", prev = ""; for (i = 0; i < n; i++) { if (temp + s[i] != prev) { prev = temp + s[i]; k++; temp = ""; } else temp += s[i]; } if (temp.size() > 0 && temp != prev) k++; cout << k; return 0; }
/** * Name: Ajay * Institute: IIITH */ #include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string.h> #include <vector> #define ll long long #define inf 0x7fffffff #define mod 1000000007 #define pb push_back #define ppi pair<int, int> #define vi vector<int> #define vvi vector<vector<int>> #define vii vector<ppi> #define vll vector<ll> #define mp make_pair #define fi first #define se second using namespace std; void fastio() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); } void input() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif } int main() { fastio(); string s; cin >> s; int n, i, k = 0; n = s.size(); string temp = "", prev = ""; for (i = 0; i < n; i++) { if (temp + s[i] != prev) { prev = temp + s[i]; k++; temp = ""; } else temp += s[i]; } if (temp.size() > 0 && temp != prev) k++; cout << k; return 0; }
[ "call.remove" ]
741,675
741,676
u139573956
cpp
p02939
#include <bits/stdc++.h> #define SORT(a) sort(a.begin(), a.end()) #define RSORT(a) sort(a.rbegin(), a.rend()) #define REP(i, n) for (long long i = 0; i < n; i++) #define RREP(i, n) for (long long i = n - 1; 0 <= i; i--) #define FOR(i, start, end) for (long long i = start; i < end; i++) #define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--) #define ALL(a) a.begin(), a.end() using ll = long long; using namespace std; const int INF32 = 1'050'000'000; const long long INF64 = 4'000'000'000'000'000'000; const int MOD7 = 1'000'000'007; const int MOD9 = 1'000'000'009; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } void print() { std::cout << '\n'; } template <class H, class... T> void print(H &&head, T &&...args) { std::cout << head; sizeof...(args) == 0 ? std::cout << "" : std::cout << ' '; print(std::forward<T>(args)...); } template <class T> void print(std::vector<T> &v) { for (int i = 0; i < v.size(); i++) { std::cout << v[i]; i == v.size() - 1 ? std::cout << '\n' : std::cout << ' '; } } template <class T> void print(std::vector<std::vector<T>> &v) { for (int i = 0; i < v.size(); i++) { for (int j = 0; j < v[i].size(); j++) { std::cout << v[i][j]; j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' '; } } } int main() { cin.tie(0); ios::sync_with_stdio(false); string s; cin >> s; int ans = 0; bool f = true; bool one = true; REP(i, s.size() - 1) { if (i == s.size() - 2) { one = f; } if (s[i] == s[i + 1] && f) { f = false; ans++; } else if (!f) { ans++; i++; f = true; } else { ans++; f = true; } } if ((one && f) || s[s.size() - 1] != s[s.size() - 2]) ans++; print(ans); return 0; }
#include <bits/stdc++.h> #define SORT(a) sort(a.begin(), a.end()) #define RSORT(a) sort(a.rbegin(), a.rend()) #define REP(i, n) for (long long i = 0; i < n; i++) #define RREP(i, n) for (long long i = n - 1; 0 <= i; i--) #define FOR(i, start, end) for (long long i = start; i < end; i++) #define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--) #define ALL(a) a.begin(), a.end() using ll = long long; using namespace std; const int INF32 = 1'050'000'000; const long long INF64 = 4'000'000'000'000'000'000; const int MOD7 = 1'000'000'007; const int MOD9 = 1'000'000'009; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } void print() { std::cout << '\n'; } template <class H, class... T> void print(H &&head, T &&...args) { std::cout << head; sizeof...(args) == 0 ? std::cout << "" : std::cout << ' '; print(std::forward<T>(args)...); } template <class T> void print(std::vector<T> &v) { for (int i = 0; i < v.size(); i++) { std::cout << v[i]; i == v.size() - 1 ? std::cout << '\n' : std::cout << ' '; } } template <class T> void print(std::vector<std::vector<T>> &v) { for (int i = 0; i < v.size(); i++) { for (int j = 0; j < v[i].size(); j++) { std::cout << v[i][j]; j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' '; } } } int main() { cin.tie(0); ios::sync_with_stdio(false); string s; cin >> s; int ans = 0; bool f = true; bool one = true; REP(i, s.size() - 1) { if (i == s.size() - 2) { one = f; } if (s[i] == s[i + 1] && f) { f = false; ans++; } else if (!f) { ans++; i++; f = true; } else { ans++; f = true; } } if ((one && f) || (s[s.size() - 1] != s[s.size() - 2] && one)) ans++; print(ans); return 0; }
[ "control_flow.branch.if.condition.change" ]
741,679
741,680
u324303263
cpp
p02939
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // freopen("in.inp", "r", stdin); // freopen("ou.out", "w", stdout); string s; cin >> s; int nho = 1; int kq = 1; int i = 1; while (i < s.size()) { if (nho == 1) { if (s[i] != s[i - 1]) { kq++; i++; } else { if (i + 2 < s.size()) { nho = 2; kq++; i = i + 2; } else break; } } else { kq++; i++; nho = 1; } } cout << kq; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // freopen("in.inp", "r", stdin); // freopen("ou.out", "w", stdout); string s; cin >> s; int nho = 1; int kq = 1; int i = 1; while (i < s.size()) { if (nho == 1) { if (s[i] != s[i - 1]) { kq++; i++; } else { if (i + 2 <= s.size()) { nho = 2; kq++; i = i + 2; } else break; } } else { kq++; i++; nho = 1; } } cout << kq; return 0; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
741,681
741,682
u504660719
cpp
p02939
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <ctime> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> using namespace std; #define rg register #define LL long long #define __endl putchar('\n') #define __space putchar(' ') template <typename qwq> inline void read(qwq &x) { x = 0; rg int f = 1; rg char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); } x *= f; } template <typename qaq> inline void print(qaq x) { if (x < 0) { putchar('-'); x = -x; } if (x > 9) print(x / 10); putchar(x % 10 + '0'); } int cnt = 1, ans, flag; char last; int tmp[233333]; char s[233333]; int main() { // freopen("data.in", "r", stdin); scanf("%s", s + 1); rg int len = strlen(s + 1); rg int tmplen = 1; for (rg int i = 1; i <= len; ++i) { if (s[i] == s[i + 1]) { if (tmplen == 1) { if (i == len - 2) { ++ans; break; } ++ans; ++tmplen; } else { ++i, ++ans; tmplen = 1; } } else { if (tmplen == 1) ++ans; else ++ans, tmplen = 1, ++i; } } print(ans); return 0; }
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <ctime> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> using namespace std; #define rg register #define LL long long #define __endl putchar('\n') #define __space putchar(' ') template <typename qwq> inline void read(qwq &x) { x = 0; rg int f = 1; rg char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); } x *= f; } template <typename qaq> inline void print(qaq x) { if (x < 0) { putchar('-'); x = -x; } if (x > 9) print(x / 10); putchar(x % 10 + '0'); } int cnt = 1, ans, flag; char last; int tmp[233333]; char s[233333]; int main() { // freopen("data.in", "r", stdin); scanf("%s", s + 1); rg int len = strlen(s + 1); rg int tmplen = 1; for (rg int i = 1; i <= len; ++i) { if (s[i] == s[i + 1]) { if (tmplen == 1) { if (i == len - 1) { ++ans; break; } ++ans; ++tmplen; } else { ++i, ++ans; tmplen = 1; } } else { if (tmplen == 1) ++ans; else ++ans, tmplen = 1, ++i; } } print(ans); return 0; }
[ "literal.number.change", "control_flow.branch.if.condition.change" ]
741,687
741,688
u764660839
cpp
p02939
#include <algorithm> #include <cmath> #include <iostream> #include <vector> using namespace std; int main() { string s; cin >> s; int c = 0, p = 0, pc = 1, ppc = 0, n = s.size(); for (; p + pc <= n;) { if (pc == 2) { p += 2; c++; ppc = pc; pc = 1; } else { c++; ppc = pc; if (s[p] == s[p + 1]) pc = 2; else pc = 1; p += 1; } } if (ppc == 1 && pc == 1 && s[n - 1] == s[n - 2]) c--; cout << c << endl; }
#include <algorithm> #include <cmath> #include <iostream> #include <vector> using namespace std; int main() { string s; cin >> s; int c = 0, p = 0, pc = 1, ppc = 0, n = s.size(); for (; p + pc <= n;) { if (pc == 2) { p += 2; c++; ppc = pc; pc = 1; } else { c++; ppc = pc; if (s[p] == s[p + 1]) pc = 2; else pc = 1; p += 1; } } if (ppc == 1 && pc == 1 && s[n - 1] == s[n - 2] && p != n) c--; cout << c << endl; }
[ "control_flow.branch.if.condition.change" ]
741,692
741,693
u601082779
cpp
p02939
#include <cstdio> #include <cstring> using namespace std; char s[200005]; int main(void) { int i, n, ans = 1, cnt; scanf("%s", s); n = strlen(s); for (i = 1; i < n;) { if (s[i] == s[i - 1]) { if (i + 1 < n) { i++; ans++; if (i + 1 < n) { i += 2; ans++; } } else { break; } } else { ans++; i++; } } printf("%d", ans); return 0; }
#include <cstdio> #include <cstring> using namespace std; char s[200005]; int main(void) { int i, n, ans = 1, cnt; scanf("%s", s); n = strlen(s); for (i = 1; i < n;) { if (s[i] == s[i - 1]) { if (i + 1 < n) { i++; ans++; if (i + 1 < n) { i += 2; ans++; } else { break; } } else { break; } } else { ans++; i++; } } printf("%d", ans); return 0; }
[ "control_flow.branch.else.add" ]
741,696
741,697
u997390882
cpp
p02939
#include <bits/stdc++.h> using namespace std; #define sz(x) ((int)((x).size())) typedef long long ll; typedef long double ld; const int inf = 1 << 25; string s; int dp[300000][2]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(10); cin >> s; int n = sz(s); if (n == 1) { cout << 1 << "\n"; return 0; } dp[0][0] = 1, dp[0][1] = -inf; dp[1][1] = 1, dp[0][0] = (s[0] != s[1] ? 2 : -inf); for (int i = 2; i < n; i++) { for (int j = 0; j < 2; j++) { dp[i][j] = -inf; for (int k = 0; k < 2; k++) if (i - j - 1 - k >= 0 && (j != k || s[i] != s[i - j - 1] && (j < 1 || s[i - 1] == s[i - j - 2]))) dp[i][j] = max(dp[i][j], dp[i - j - 1][k] + 1); } } cout << max(dp[n - 1][0], dp[n - 1][1]) << "\n"; }
#include <bits/stdc++.h> using namespace std; #define sz(x) ((int)((x).size())) typedef long long ll; typedef long double ld; const int inf = 1 << 25; string s; int dp[300000][2]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(10); cin >> s; int n = sz(s); if (n == 1) { cout << 1 << "\n"; return 0; } dp[0][0] = 1, dp[0][1] = -inf; dp[1][1] = 1, dp[1][0] = (s[0] != s[1] ? 2 : -inf); for (int i = 2; i < n; i++) { for (int j = 0; j < 2; j++) { dp[i][j] = -inf; for (int k = 0; k < 2; k++) if (i - j - 1 - k >= 0 && (j != k || s[i] != s[i - j - 1] || (j == 1 && s[i - 1] != s[i - j - 2]))) dp[i][j] = max(dp[i][j], dp[i - j - 1][k] + 1); } } cout << max(dp[n - 1][0], dp[n - 1][1]) << "\n"; }
[ "literal.number.change", "assignment.variable.change", "variable_access.subscript.index.change", "misc.opposites", "control_flow.branch.if.condition.change", "expression.operator.compare.change" ]
741,712
741,713
u395070007
cpp
p02939
#include <bits/stdc++.h> using namespace std; string s; int main() { cin >> s; int l = 0; int bj = 0; int ans = 0; while (l < s.size()) { if (bj == 0) { l++; ans++; bj = 1; } else { if (s[l] == s[l - 1]) { l = l + 2; if (l >= s.size()) break; ans++; bj = 0; } else { l++; ans++; } } } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; string s; int main() { cin >> s; int l = 0; int bj = 0; int ans = 0; while (l < s.size()) { if (bj == 0) { l++; ans++; bj = 1; } else { if (s[l] == s[l - 1]) { l = l + 2; if (l > s.size()) break; ans++; bj = 0; } else { l++; ans++; } } } printf("%d\n", ans); return 0; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
741,714
741,715
u642435852
cpp
p02939
#include <bits/stdc++.h> using namespace std; #define MN 200005 char ch[MN]; int f[MN][2]; int main() { scanf("%s", ch + 1); int ln = strlen(ch + 1); f[1][0] = 1; for (int i = 2; i <= ln; ++i) { f[i][0] = f[i - 1][1] + 1; f[i][1] = f[i - 2][0] + 1; if (ch[i] != ch[i - 1]) f[i][0] = max(f[i][0], f[i - 1][0] + 1); if (i > 2 && ch[i - 1] != ch[i - 3] && ch[i] != ch[i - 2]) f[i][1] = max(f[i][1], f[i - 1][1] + 1); // cout<<"HI "<<i<<" "<<f[i][0]<<" "<<f[i][1]<<endl; } printf("%d", max(f[ln][0], f[ln][1])); return 0; }
#include <bits/stdc++.h> using namespace std; #define MN 200005 char ch[MN]; int f[MN][2]; int main() { scanf("%s", ch + 1); int ln = strlen(ch + 1); f[1][0] = 1; for (int i = 2; i <= ln; ++i) { f[i][0] = f[i - 1][1] + 1; f[i][1] = f[i - 2][0] + 1; if (ch[i] != ch[i - 1]) f[i][0] = max(f[i][0], f[i - 1][0] + 1); if (i > 2 && ch[i - 1] != ch[i - 3] && ch[i] != ch[i - 2]) f[i][1] = max(f[i][1], f[i - 2][1] + 1); // cout<<"HI "<<i<<" "<<f[i][0]<<" "<<f[i][1]<<endl; } printf("%d", max(f[ln][0], f[ln][1])); return 0; }
[ "literal.number.change", "assignment.value.change", "variable_access.subscript.index.change", "call.arguments.change", "expression.operation.binary.change" ]
741,723
741,724
u215375907
cpp
p02939
#include <algorithm> #include <bitset> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <stack> #include <time.h> #include <vector> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<ll, ll> P; #define pb push_back #define rep(i, a, n) for (int i = (a); i < (n); i++) #define dep(i, a, n) for (int i = (a); i >= (n); i--) #define mod (ll)(1e9 + 7) #define int ll __attribute__((constructor)) void initial() { cin.tie(0); ios::sync_with_stdio(false); } signed main() { string s; cin >> s; int ans = 0; bool f = false; for (int i = 0; i < s.length(); i++) { ans++; if (i > 0 && s[i] == s[i - 1]) { if (f) f = false; else { i++, f = true; if (i == s.length() - 1) ans--; } } else f = false; } cout << ans << endl; }
#include <algorithm> #include <bitset> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <stack> #include <time.h> #include <vector> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<ll, ll> P; #define pb push_back #define rep(i, a, n) for (int i = (a); i < (n); i++) #define dep(i, a, n) for (int i = (a); i >= (n); i--) #define mod (ll)(1e9 + 7) #define int ll __attribute__((constructor)) void initial() { cin.tie(0); ios::sync_with_stdio(false); } signed main() { string s; cin >> s; int ans = 0; bool f = false; for (int i = 0; i < s.length(); i++) { ans++; if (i > 0 && s[i] == s[i - 1]) { if (f) f = false; else { i++, f = true; if (i == s.length()) ans--; } } else f = false; } cout << ans << endl; }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
741,725
741,726
u986898382
cpp
p02939
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; bool x = 0; int sum = s.size(); for (int i = 1; i < s.size(); i++) { if (x) x = !x; if (s[i] == s[i - 1]) { i++; sum--; x = 1; } } cout << sum << '\n'; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; bool x = 0; int sum = s.size(); for (int i = 1; i < s.size(); i++) { if (x) { x = !x; continue; } if (s[i] == s[i - 1]) { i++; sum--; x = 1; } } cout << sum << '\n'; }
[]
741,729
741,730
u166147681
cpp
p02939
/** ������������ Author : Avi J Patel ������������ ������������ University : DA-IICT ������������ **/ #include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define pb push_back #define pf push_front #define mp make_pair #define mt make_tuple #define N 100000 #define ff first #define ss second #define si size() #define MOD 1000000007 #define Mod 998244353 #define N 1000005 #define large 10000000000000001 #define For(i, m, n) for (long long i = m; i < n; i++) #define st(x) sort(x.begin(), x.end()) #define re(x, i) reverse(x.begin() + i, x.end()) #define FAST \ ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); \ srand(time(NULL)); /* bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) { return (a.second < b.second); }*/ int main() { string s, cur; cin >> s; int cnt = 1, i = 1; int n = s.size(); cur = s[i]; // cout<<cur<<endl; while (i < n) { string s1 = ""; s1 += s[i]; i++; while (i < n && s1 == cur) { s1 += s[i]; i++; } cnt++; if (i == n && s1 == cur) cnt--; // cout<<s1<<endl; cur = s1; } cout << cnt; return 0; }
/** ������������ Author : Avi J Patel ������������ ������������ University : DA-IICT ������������ **/ #include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define pb push_back #define pf push_front #define mp make_pair #define mt make_tuple #define N 100000 #define ff first #define ss second #define si size() #define MOD 1000000007 #define Mod 998244353 #define N 1000005 #define large 10000000000000001 #define For(i, m, n) for (long long i = m; i < n; i++) #define st(x) sort(x.begin(), x.end()) #define re(x, i) reverse(x.begin() + i, x.end()) #define FAST \ ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); \ srand(time(NULL)); /* bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) { return (a.second < b.second); }*/ int main() { string s, cur; cin >> s; int cnt = 1, i = 1; int n = s.size(); cur = s[0]; // cout<<cur<<endl; while (i < n) { string s1 = ""; s1 += s[i]; i++; while (i < n && s1 == cur) { s1 += s[i]; i++; } cnt++; if (i == n && s1 == cur) cnt--; // cout<<s1<<endl; cur = s1; } cout << cnt; return 0; }
[ "assignment.value.change", "identifier.replace.remove", "literal.replace.add", "variable_access.subscript.index.change" ]
741,731
741,732
u589330060
cpp
p02939
#include <cstring> #include <iostream> using namespace std; char c[200003]; int f[200003][3], ans; int main() { memset(f, 0xaf, sizeof(f)); cin >> c; f[1][1] = f[2][2] = 1; for (int i = 1; c[i]; i++) { if (c[i - 1] != c[i]) if (f[i][1] < f[i - 1][1] + 1) { f[i][1] = f[i - 1][1] + 1; } if (f[i][1] < f[i - 1][2] + 1) { f[i][1] = f[i - 1][2] + 1; } if (i >= 2) { if (f[i][2] < f[i - 2][1] + 1) { f[i][2] = f[i - 2][1] + 1; } if (i >= 3) if (c[i - 2] != c[i] && c[i - 3] != c[i - 1]) { if (f[i][2] < f[i - 2][2] + 1) { f[i][2] = f[i - 2][2] + 1; } } } ans = max(f[i][1], f[i][2]); } cout << ans << endl; }
#include <cstring> #include <iostream> using namespace std; char c[200003]; int f[200003][3], ans = 1; int main() { memset(f, 0xaf, sizeof(f)); cin >> c; f[0][1] = f[1][2] = 1; for (int i = 1; c[i]; i++) { if (c[i - 1] != c[i]) if (f[i][1] < f[i - 1][1] + 1) { f[i][1] = f[i - 1][1] + 1; } if (f[i][1] < f[i - 1][2] + 1) { f[i][1] = f[i - 1][2] + 1; } if (i >= 2) { if (f[i][2] < f[i - 2][1] + 1) { f[i][2] = f[i - 2][1] + 1; } if (i >= 3) if (c[i - 2] != c[i] && c[i - 3] != c[i - 1]) { if (f[i][2] < f[i - 2][2] + 1) { f[i][2] = f[i - 2][2] + 1; } } } ans = max(f[i][1], f[i][2]); } cout << ans << endl; }
[ "variable_declaration.value.change", "literal.number.change", "assignment.variable.change", "variable_access.subscript.index.change" ]
741,736
741,737
u300590099
cpp
p02939
#include <bits/stdc++.h> #define rep(i, n) REP(i, 0, n) #define REP(i, l, r) for (int i = l; i < r; ++i) #define int long long #ifdef DEBUG #define dout cout #else std::stringstream dout; #endif using namespace std; typedef pair<int, int> P; // other libs signed main(int argc, char *argv[]) { string s; bool b = false, bback = false; cin >> s; int ans = 1; rep(i, s.size() - 1) { if (s[i] == s[i + 1] && bback == false) { bback = b; b = true; } else { bback = b; b = false; ans++; } } cout << ans << endl; }
#include <bits/stdc++.h> #define rep(i, n) REP(i, 0, n) #define REP(i, l, r) for (int i = l; i < r; ++i) #define int long long #ifdef DEBUG #define dout cout #else std::stringstream dout; #endif using namespace std; typedef pair<int, int> P; // other libs signed main(int argc, char *argv[]) { string s; bool b = false, bback = false; cin >> s; int ans = 1; rep(i, s.size() - 1) { if (s[i] == s[i + 1] && b == false && bback == false) { bback = b; b = true; } else { bback = b; b = false; ans++; } } cout << ans << endl; }
[ "control_flow.branch.if.condition.change" ]
741,738
741,739
u073057072
cpp
p02939
#include <bits/stdc++.h> using namespace std; #define F first #define S second #define mp make_pair #define pb push_back #define f(i, x, n) for (int i = x; i < n; i++) #define all(c) c.begin(), c.end() #define int ll #define print(x) cerr << (#x) << "is " << x << "\n" using ll = long long; using pii = pair<int, int>; const int MOD = 1e9 + 7, N = 1e5 + 10; int32_t main() { ios::sync_with_stdio(false); cin.tie(NULL); // #ifndef ONLINE_JUDGE // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); // #endif string s; cin >> s; int n = s.length(); string res = "", prv = "" + s[0]; int ans = 0; f(i, 1, n) { res += s[i]; if (res != prv) { ans++; prv = res; res = ""; } } cout << ans << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; #define F first #define S second #define mp make_pair #define pb push_back #define f(i, x, n) for (int i = x; i < n; i++) #define all(c) c.begin(), c.end() #define int ll #define print(x) cerr << (#x) << "is " << x << "\n" using ll = long long; using pii = pair<int, int>; const int MOD = 1e9 + 7, N = 1e5 + 10; int32_t main() { ios::sync_with_stdio(false); cin.tie(NULL); // #ifndef ONLINE_JUDGE // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); // #endif string s; cin >> s; int n = s.length(); string res = "", prv = ""; prv += s[0]; int ans = 1; f(i, 1, n) { res += s[i]; if (res != prv) { ans++; // cout << res << ' ' << prv<< '\n'; prv = res; res = ""; } } cout << ans << '\n'; return 0; }
[ "expression.operation.binary.change", "assignment.change", "literal.number.change", "variable_declaration.value.change" ]
741,740
741,741
u676247559
cpp
p02939
#include <bits/stdc++.h> #define MOD 1000000007LL using namespace std; typedef long long ll; typedef pair<int, int> P; string s; int main(void) { cin >> s; int n = s.size(); int cnt = 1; int len = 1; for (int i = 2; i < n; i++) { if (len == 1) { if (s[i - 1] == s[i]) { if ((i + 1) != n) { cnt++; } len = 2; i++; } else { cnt++; len = 1; } } else { cnt++; len = 1; } } printf("%d\n", cnt); return 0; }
#include <bits/stdc++.h> #define MOD 1000000007LL using namespace std; typedef long long ll; typedef pair<int, int> P; string s; int main(void) { cin >> s; int n = s.size(); int cnt = 1; int len = 1; for (int i = 1; i < n; i++) { if (len == 1) { if (s[i - 1] == s[i]) { if ((i + 1) != n) { cnt++; } len = 2; i++; } else { cnt++; len = 1; } } else { cnt++; len = 1; } } printf("%d\n", cnt); return 0; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one" ]
741,742
741,743
u854869949
cpp
p02939
#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; typedef long double ld; typedef long long ll; const int maxN = 2 * (int)1e5 + 100; string s; const int BUBEN = 5; int dp[maxN][BUBEN + 2]; int n; const int INF = 5000000; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); // freopen("input.txt", "r", stdin); cin >> s; n = s.size(); for (int i = 0; i <= n; i++) { for (int j = 0; j < BUBEN; j++) { dp[i][j] = -INF; } } for (int i = 0; i < min(BUBEN, n); i++) { dp[i][i + 1] = 1; } for (int i = 1; i <= n; i++) { for (int j = 0; j < BUBEN; j++) { if (dp[i][j] < 0) continue; for (int take = i + 1; take <= min(i + BUBEN, n); take++) { if (s.substr(i - j + 1, j) != s.substr(i + 1, take - i)) { dp[take][take - i] = max(dp[take][take - i], dp[i][j] + 1); } } } } int best = -INF; for (int i = 0; i < BUBEN; i++) { best = max(best, dp[n - 1][i]); } cout << best; return 0; }
#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; typedef long double ld; typedef long long ll; const int maxN = 2 * (int)1e5 + 100; string s; const int BUBEN = 5; int dp[maxN][BUBEN + 2]; int n; const int INF = 5000000; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); // freopen("input.txt", "r", stdin); cin >> s; n = s.size(); for (int i = 0; i <= n; i++) { for (int j = 0; j < BUBEN; j++) { dp[i][j] = -INF; } } for (int i = 0; i < min(BUBEN, n); i++) { dp[i][i + 1] = 1; } for (int i = 0; i < n; i++) { for (int j = 0; j < BUBEN; j++) { if (dp[i][j] < 0) continue; for (int take = i + 1; take <= min(i + BUBEN, n); take++) { if (s.substr(i - j + 1, j) != s.substr(i + 1, take - i)) { dp[take][take - i] = max(dp[take][take - i], dp[i][j] + 1); } } } } int best = -INF; for (int i = 0; i < BUBEN; i++) { best = max(best, dp[n - 1][i]); } cout << best; return 0; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one", "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
741,744
741,745
u720150053
cpp
p02939
#include <bits/stdc++.h> using namespace std; #define ll long long #define rep(i, n) for (ll i = 0; i < n; i++) #define rep2(i, start, end) for (ll i = start; i < end; i++) #define dwn(i, n) for (int i = n; i >= 0; i--) #define dwn2(i, start, end) for (ll i = start; i >= end; i--) #define pll pair<ll, ll> #define mk(x, y) make_pair(x, y) #define pdl pair<double, ll> const ll N = 4e5 + 200; const ll INF = 0x3f3f3f; const ll Mode = 1e9 + 7; int main() { ll n, m; string s; cin >> s; ll len = s.length(); ll sum = 0; string tmp = ""; string now = ""; rep2(i, 1, len) { now += s[i]; if (now != tmp) { sum++; tmp = now; now = ""; } } cout << sum << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long #define rep(i, n) for (ll i = 0; i < n; i++) #define rep2(i, start, end) for (ll i = start; i < end; i++) #define dwn(i, n) for (int i = n; i >= 0; i--) #define dwn2(i, start, end) for (ll i = start; i >= end; i--) #define pll pair<ll, ll> #define mk(x, y) make_pair(x, y) #define pdl pair<double, ll> const ll N = 4e5 + 200; const ll INF = 0x3f3f3f; const ll Mode = 1e9 + 7; int main() { ll n, m; string s; cin >> s; ll len = s.length(); ll sum = 0; string tmp = ""; string now = ""; rep2(i, 0, len) { now += s[i]; if (now != tmp) { sum++; tmp = now; now = ""; } } cout << sum << endl; return 0; }
[ "literal.number.change", "call.arguments.change" ]
741,746
741,747
u624688258
cpp
p02939
#include <bits/stdc++.h> #include <string.h> using namespace std; #define rep(i, s, n) for (int i = s; i < n; i++) int main() { int c = 0; string s, tmp; cin >> s; tmp = s.substr(1, 1); for (int i = 2; i <= s.length(); i++) { if (i == s.length()) { c++; } else if (s.substr(i, 1) != tmp) { c++; tmp = s.substr(i, 1); } else { c++; tmp = s.substr(i, 2); i++; } } cout << c << endl; return 0; }
#include <bits/stdc++.h> #include <string.h> using namespace std; #define rep(i, s, n) for (int i = s; i < n; i++) int main() { int c = 0; string s, tmp; cin >> s; tmp = s.substr(0, 1); // cout << tmp << " 0"<< endl; for (int i = 1; i <= s.length(); i++) { if (i >= s.length()) { c++; // cout << tmp << " 1"<< endl; } else if (s.substr(i, 1) != tmp) { c++; // cout << tmp << " 2" << endl; tmp = s.substr(i, 1); } else { c++; // cout << tmp << " 3" << endl; tmp = s.substr(i, 2); i++; } } cout << c << endl; return 0; }
[ "literal.number.change", "assignment.value.change", "call.arguments.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
741,754
741,755
u311660576
cpp
p02939
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; using ll = long long int; const int INF = 1e9; int main() { string s; cin >> s; int n = s.size(); if (n == 1) { cout << 1 << endl; return 0; } vector<array<int, 2>> t(n); t[0][0] = 1; t[0][1] = -INF; t[1][0] = s[0] == s[1] ? 1 : -INF; t[1][1] = 1; for (int i = 2; i < n; ++i) { t[i][0] = t[i - 1][1] + 1; t[i][1] = t[i - 2][0] + 1; if (s[i - 1] != s[i]) t[i][0] = max(t[i][0], t[i - 1][0] + 1); if (i > 2 && s.substr(i - 3, 2) != s.substr(i - 1, 2)) t[i][1] = max(t[i][1], t[i - 2][1] + 1); } cout << max(t[n - 1][0], t[n - 1][1]) << endl; return 0; }
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; using ll = long long int; const int INF = 1e9; int main() { string s; cin >> s; int n = s.size(); if (n == 1) { cout << 1 << endl; return 0; } vector<array<int, 2>> t(n); t[0][0] = 1; t[0][1] = -INF; t[1][0] = s[0] == s[1] ? -INF : 2; t[1][1] = 1; for (int i = 2; i < n; ++i) { t[i][0] = t[i - 1][1] + 1; t[i][1] = t[i - 2][0] + 1; if (s[i - 1] != s[i]) t[i][0] = max(t[i][0], t[i - 1][0] + 1); if (i > 2 && s.substr(i - 3, 2) != s.substr(i - 1, 2)) t[i][1] = max(t[i][1], t[i - 2][1] + 1); } cout << max(t[n - 1][0], t[n - 1][1]) << endl; return 0; }
[]
741,764
741,765
u158253287
cpp
p02939
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define MOD 1000000007 #define PI 3.141592653589793 int dx[] = {0, 1, -1, 0, 1, -1, 1, -1}; int dy[] = {1, 0, 0, -1, 1, -1, -1, 1}; int main() { string s; cin >> s; int ans = 0; int len = 1; string tmp = ""; for (int i = 0; i < (int)s.size();) { string str = s.substr(i, len); if (tmp != str) { ans++; tmp = str; i += len; } else { len++; if (len + i >= (int)s.size()) break; continue; } len = 1; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define MOD 1000000007 #define PI 3.141592653589793 int dx[] = {0, 1, -1, 0, 1, -1, 1, -1}; int dy[] = {1, 0, 0, -1, 1, -1, -1, 1}; int main() { string s; cin >> s; int ans = 0; int len = 1; string tmp = ""; for (int i = 0; i < (int)s.size();) { string str = s.substr(i, len); if (tmp != str) { ans++; tmp = str; i += len; } else { len++; if (len + i > (int)s.size()) break; continue; } len = 1; } cout << ans << endl; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
741,766
741,767
u874723578
cpp
p02939
//#pragma comment(linker, "/stack:200000000") //#pragma GCC optimize("Ofast,no-stack-protector") //#pragma GCC optimize("Ofast") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //#pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> #define int long long #define ll long long #define ull unsigned long long #define ld long double #define rep(i, l, r) for (int i = l; i < r; i++) #define repb(i, r, l) for (int i = r; i > l; i--) #define sz(a) (int)a.size() #define fi first #define se second #define all(x) x.begin(), x.end() #define pb push_back #define mp(a, b) make_pair(a, b) #define ret(a) return cout << a, 0; using namespace std; mt19937 mrand(random_device{}()); const ll mod = 1000000007; int rnd(int x) { return mrand() % x; } ll powmod(ll a, ll b, ll mod) { ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1) res = res * a % mod; a = a * a % mod; } return res; } typedef pair<int, int> pii; typedef pair<long long, long long> pll; const int N = 2e5 + 123; int n, m, k; string s; int a[N]; int dp[N][5]; main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> s; int ans = 0, n = sz(s); s = '$' + s; dp[1][1] = 1; if (s[1] != s[2]) dp[1][1] = 2; dp[2][2] = 1; for (int i = 3; i <= n; i++) { if (s[i] != s[i - 1]) dp[i][1] = dp[i - 1][1] + 1; dp[i][1] = max(dp[i][1], dp[i - 1][2] + 1); if (i != 3 && (s[i - 3] != s[i - 1] || s[i - 2] != s[i])) dp[i][2] = dp[i - 2][2] + 1; dp[i][2] = max(dp[i][2], dp[i - 2][1] + 1); // cout << dp[i][1] << ' ' << dp[i][2] << '\n'; } cout << max(dp[n][1], dp[n][2]); // cout << dp[n][1] << ' ' << dp[n][2] << ' '; }
//#pragma comment(linker, "/stack:200000000") //#pragma GCC optimize("Ofast,no-stack-protector") //#pragma GCC optimize("Ofast") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //#pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> #define int long long #define ll long long #define ull unsigned long long #define ld long double #define rep(i, l, r) for (int i = l; i < r; i++) #define repb(i, r, l) for (int i = r; i > l; i--) #define sz(a) (int)a.size() #define fi first #define se second #define all(x) x.begin(), x.end() #define pb push_back #define mp(a, b) make_pair(a, b) #define ret(a) return cout << a, 0; using namespace std; mt19937 mrand(random_device{}()); const ll mod = 1000000007; int rnd(int x) { return mrand() % x; } ll powmod(ll a, ll b, ll mod) { ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1) res = res * a % mod; a = a * a % mod; } return res; } typedef pair<int, int> pii; typedef pair<long long, long long> pll; const int N = 2e5 + 123; int n, m, k; string s; int a[N]; int dp[N][3]; main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> s; int ans = 0, n = sz(s); s = '$' + s; dp[1][1] = 1; if (s[1] != s[2]) dp[2][1] = 2; dp[2][2] = 1; for (int i = 3; i <= n; i++) { if (s[i] != s[i - 1]) dp[i][1] = dp[i - 1][1] + 1; dp[i][1] = max(dp[i][1], dp[i - 1][2] + 1); if (i != 3 && (s[i - 3] != s[i - 1] || s[i - 2] != s[i])) dp[i][2] = dp[i - 2][2] + 1; dp[i][2] = max(dp[i][2], dp[i - 2][1] + 1); // cout << dp[i][1] << ' ' << dp[i][2] << '\n'; } cout << max(dp[n][1], dp[n][2]); // cout << dp[n][1] << ' ' << dp[n][2] << ' '; }
[ "literal.number.change", "variable_declaration.array_dimensions.change", "assignment.variable.change", "variable_access.subscript.index.change" ]
741,768
741,769
u072528456
cpp
p02939
//#pragma comment(linker, "/stack:200000000") //#pragma GCC optimize("Ofast,no-stack-protector") //#pragma GCC optimize("Ofast") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //#pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> #define int long long #define ll long long #define ull unsigned long long #define ld long double #define rep(i, l, r) for (int i = l; i < r; i++) #define repb(i, r, l) for (int i = r; i > l; i--) #define sz(a) (int)a.size() #define fi first #define se second #define all(x) x.begin(), x.end() #define pb push_back #define mp(a, b) make_pair(a, b) #define ret(a) return cout << a, 0; using namespace std; mt19937 mrand(random_device{}()); const ll mod = 1000000007; int rnd(int x) { return mrand() % x; } ll powmod(ll a, ll b, ll mod) { ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1) res = res * a % mod; a = a * a % mod; } return res; } typedef pair<int, int> pii; typedef pair<long long, long long> pll; const int N = 2e5 + 123; int n, m, k; string s; int a[N]; int dp[N][3]; main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> s; int ans = 0, n = sz(s); s = '$' + s; dp[1][1] = 1; if (s[1] != s[2]) dp[1][1] = 2; dp[2][2] = 1; for (int i = 3; i <= n; i++) { if (s[i] != s[i - 1]) dp[i][1] = dp[i - 1][1] + 1; dp[i][1] = max(dp[i][1], dp[i - 1][2] + 1); if (i != 3 && s[i - 3] != s[i - 1] || s[i - 2] != s[i]) dp[i][2] = dp[i - 2][2] + 1; dp[i][2] = max(dp[i][2], dp[i - 2][1] + 1); // cout << dp[i][1] << ' ' << dp[i][2] << '\n'; } cout << max(dp[n][1], dp[n][2]); // cout << dp[n][1] << ' ' << dp[n][2] << ' '; }
//#pragma comment(linker, "/stack:200000000") //#pragma GCC optimize("Ofast,no-stack-protector") //#pragma GCC optimize("Ofast") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //#pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> #define int long long #define ll long long #define ull unsigned long long #define ld long double #define rep(i, l, r) for (int i = l; i < r; i++) #define repb(i, r, l) for (int i = r; i > l; i--) #define sz(a) (int)a.size() #define fi first #define se second #define all(x) x.begin(), x.end() #define pb push_back #define mp(a, b) make_pair(a, b) #define ret(a) return cout << a, 0; using namespace std; mt19937 mrand(random_device{}()); const ll mod = 1000000007; int rnd(int x) { return mrand() % x; } ll powmod(ll a, ll b, ll mod) { ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1) res = res * a % mod; a = a * a % mod; } return res; } typedef pair<int, int> pii; typedef pair<long long, long long> pll; const int N = 2e5 + 123; int n, m, k; string s; int a[N]; int dp[N][3]; main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> s; int ans = 0, n = sz(s); s = '$' + s; dp[1][1] = 1; if (s[1] != s[2]) dp[2][1] = 2; dp[2][2] = 1; for (int i = 3; i <= n; i++) { if (s[i] != s[i - 1]) dp[i][1] = dp[i - 1][1] + 1; dp[i][1] = max(dp[i][1], dp[i - 1][2] + 1); if (i != 3 && (s[i - 3] != s[i - 1] || s[i - 2] != s[i])) dp[i][2] = dp[i - 2][2] + 1; dp[i][2] = max(dp[i][2], dp[i - 2][1] + 1); // cout << dp[i][1] << ' ' << dp[i][2] << '\n'; } cout << max(dp[n][1], dp[n][2]); // cout << dp[n][1] << ' ' << dp[n][2] << ' '; }
[ "literal.number.change", "assignment.variable.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change" ]
741,770
741,769
u072528456
cpp
p02939
#include <bits/stdc++.h> using namespace std; // Define using ll = long long; using ull = unsigned long long; using ld = long double; const ll dx[4] = {1, 0, -1, 0}; const ll dy[4] = {0, 1, 0, -1}; const ll MOD = 1e9 + 7; const ll mod = 998244353; const ll inf = 1 << 30; const ll LINF = LONG_MAX; const ll INF = 1LL << 60; const ull MAX = ULONG_MAX; #define mp make_pair #define pb push_back #define elif else if #define endl '\n' #define space ' ' #define def inline auto #define func inline constexpr ll #define run(a) __attribute__((constructor)) def _##a() #define all(v) begin(v), end(v) #define rall(v) rbegin(v), rend(v) #define input(a) scanf("%lld", &(a)) #define print(a) printf("%lld\n", (a)) #define fi first #define se second #define ok(a, b) (0 <= (a) && (a) < (b)) template <class T> using vvector = vector<vector<T>>; template <class T> using pvector = vector<pair<T, T>>; template <class T> using rpriority_queue = priority_queue<T, vector<T>, greater<T>>; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; } // Debug #define debug(...) \ { \ cerr << __LINE__ << ": " << #__VA_ARGS__ << " = "; \ for (auto &&X : {__VA_ARGS__}) \ cerr << "[" << X << "] "; \ cerr << endl; \ } #define dump(a, h, w) \ { \ cerr << __LINE__ << ": " << #a << " = [" << endl; \ rep(__i, h) { \ rep(__j, w) { cerr << a[__i][__j] << space; } \ cerr << endl; \ } \ cerr << "]" << endl; \ } #define vdump(a, n) \ { \ cerr << __LINE__ << ": " << #a << " = ["; \ rep(__i, n) if (__i) cerr << space << a[__i]; \ else cerr << a[__i]; \ cerr << "]" << endl; \ } // Loop #define inc(i, a, n) for (ll i = (a), _##i = (n); i <= _##i; ++i) #define dec(i, a, n) for (ll i = (a), _##i = (n); i >= _##i; --i) #define rep(i, n) for (ll i = 0, _##i = (n); i < _##i; ++i) #define each(i, a) for (auto &&i : a) #define loop() for (;;) // Stream #define fout(n) cout << fixed << setprecision(n) #define fasten cin.tie(0), ios::sync_with_stdio(0) run(0) { fasten, fout(10); } // Speed #pragma GCC optimize("O3") #pragma GCC target("avx") // Math func gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } func lcm(ll a, ll b) { return a * b / gcd(a, b); } func sign(ll a) { return a ? abs(a) / a : 0; } inline constexpr ll modulo(const ll n, const ll m = MOD) { ll k = n % m; return k + m * (k < 0); } inline constexpr ll chmod(ll &n, const ll m = MOD) { n %= m; return n += m * (n < 0); } inline constexpr ll mpow(ll a, ll n, const ll m = MOD) { ll r = 1; while (n) { if (n & 1) r *= a; chmod(r, m); a *= a; chmod(a, m); n >>= 1; } return r; } inline ll inv(const ll n, const ll m) { ll a = n, b = m, x = 1, y = 0; while (b) { ll t = a / b; a -= t * b; swap(a, b); x -= t * y; swap(x, y); } return x % m; } struct Factor { inline vector<ll> factors(ll N) { vector<ll> A; ll i = 2; while (i * i <= N) { if (N % i == 0) { A.push_back(i); N /= i; } else { i++; } } if (N != 1) A.push_back(N); sort(all(A)); return A; } inline vector<ll> divisor(ll N) { vector<ll> A = factors(N), B; ll a = A.size(); rep(i, 1 << a) { ll d = 1; rep(j, a) if (i & (1 << j)) d *= A[j]; B.push_back(d); } sort(all(B)), B.erase(unique(all(B)), B.end()); return B; } }; struct csum { ll N; vector<ll> A, S; csum(vector<ll> v) : A(v), S(1) { each(k, v) S.push_back(k + S.back()); } ll sum(ll l, ll r) { return S[r] - S[l]; } ll lsum(ll r) { return S[r]; } ll rsum(ll l) { return S.back() - S[l]; } }; ll DP[200000 + 1][2]; signed main() { string S; cin >> S; ll N = S.size(); rep(i, N + 1) rep(j, 2) DP[i][j] = -1; DP[0][0] = 0; rep(i, N) rep(j, 2) { if (DP[i][j] == -1) continue; if (j != 0 || i == 0 || S[i] != S[i - 1]) { chmax(DP[i + 1][0], DP[i][j] + 1); } if (i != 0 && (i - 2 < 0 || i + 1 >= N)) continue; if (j == 0 || i == 0 || (S[i] != S[i - 2] || S[i + 1] != S[i - 1])) { chmax(DP[i + 2][1], DP[i][j] + 1); } } ll res = 0; rep(i, 2) chmax(res, DP[N][i]); cout << res << endl; }
#include <bits/stdc++.h> using namespace std; // Define using ll = long long; using ull = unsigned long long; using ld = long double; const ll dx[4] = {1, 0, -1, 0}; const ll dy[4] = {0, 1, 0, -1}; const ll MOD = 1e9 + 7; const ll mod = 998244353; const ll inf = 1 << 30; const ll LINF = LONG_MAX; const ll INF = 1LL << 60; const ull MAX = ULONG_MAX; #define mp make_pair #define pb push_back #define elif else if #define endl '\n' #define space ' ' #define def inline auto #define func inline constexpr ll #define run(a) __attribute__((constructor)) def _##a() #define all(v) begin(v), end(v) #define rall(v) rbegin(v), rend(v) #define input(a) scanf("%lld", &(a)) #define print(a) printf("%lld\n", (a)) #define fi first #define se second #define ok(a, b) (0 <= (a) && (a) < (b)) template <class T> using vvector = vector<vector<T>>; template <class T> using pvector = vector<pair<T, T>>; template <class T> using rpriority_queue = priority_queue<T, vector<T>, greater<T>>; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; } // Debug #define debug(...) \ { \ cerr << __LINE__ << ": " << #__VA_ARGS__ << " = "; \ for (auto &&X : {__VA_ARGS__}) \ cerr << "[" << X << "] "; \ cerr << endl; \ } #define dump(a, h, w) \ { \ cerr << __LINE__ << ": " << #a << " = [" << endl; \ rep(__i, h) { \ rep(__j, w) { cerr << a[__i][__j] << space; } \ cerr << endl; \ } \ cerr << "]" << endl; \ } #define vdump(a, n) \ { \ cerr << __LINE__ << ": " << #a << " = ["; \ rep(__i, n) if (__i) cerr << space << a[__i]; \ else cerr << a[__i]; \ cerr << "]" << endl; \ } // Loop #define inc(i, a, n) for (ll i = (a), _##i = (n); i <= _##i; ++i) #define dec(i, a, n) for (ll i = (a), _##i = (n); i >= _##i; --i) #define rep(i, n) for (ll i = 0, _##i = (n); i < _##i; ++i) #define each(i, a) for (auto &&i : a) #define loop() for (;;) // Stream #define fout(n) cout << fixed << setprecision(n) #define fasten cin.tie(0), ios::sync_with_stdio(0) run(0) { fasten, fout(10); } // Speed #pragma GCC optimize("O3") #pragma GCC target("avx") // Math func gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } func lcm(ll a, ll b) { return a * b / gcd(a, b); } func sign(ll a) { return a ? abs(a) / a : 0; } inline constexpr ll modulo(const ll n, const ll m = MOD) { ll k = n % m; return k + m * (k < 0); } inline constexpr ll chmod(ll &n, const ll m = MOD) { n %= m; return n += m * (n < 0); } inline constexpr ll mpow(ll a, ll n, const ll m = MOD) { ll r = 1; while (n) { if (n & 1) r *= a; chmod(r, m); a *= a; chmod(a, m); n >>= 1; } return r; } inline ll inv(const ll n, const ll m) { ll a = n, b = m, x = 1, y = 0; while (b) { ll t = a / b; a -= t * b; swap(a, b); x -= t * y; swap(x, y); } return x % m; } struct Factor { inline vector<ll> factors(ll N) { vector<ll> A; ll i = 2; while (i * i <= N) { if (N % i == 0) { A.push_back(i); N /= i; } else { i++; } } if (N != 1) A.push_back(N); sort(all(A)); return A; } inline vector<ll> divisor(ll N) { vector<ll> A = factors(N), B; ll a = A.size(); rep(i, 1 << a) { ll d = 1; rep(j, a) if (i & (1 << j)) d *= A[j]; B.push_back(d); } sort(all(B)), B.erase(unique(all(B)), B.end()); return B; } }; struct csum { ll N; vector<ll> A, S; csum(vector<ll> v) : A(v), S(1) { each(k, v) S.push_back(k + S.back()); } ll sum(ll l, ll r) { return S[r] - S[l]; } ll lsum(ll r) { return S[r]; } ll rsum(ll l) { return S.back() - S[l]; } }; ll DP[200000 + 1][2]; signed main() { string S; cin >> S; ll N = S.size(); rep(i, N + 1) rep(j, 2) DP[i][j] = -1; DP[0][0] = 0; rep(i, N) rep(j, 2) { if (DP[i][j] == -1) continue; if (j != 0 || i == 0 || S[i] != S[i - 1]) { chmax(DP[i + 1][0], DP[i][j] + 1); } if (j != 0 && i != 0 && (i - 2 < 0 || i + 1 >= N)) continue; if (j == 0 || i == 0 || (S[i] != S[i - 2] || S[i + 1] != S[i - 1])) { chmax(DP[i + 2][1], DP[i][j] + 1); } } ll res = 0; rep(i, 2) chmax(res, DP[N][i]); cout << res << endl; }
[ "control_flow.branch.if.condition.change" ]
741,773
741,774
u398942100
cpp
p02939
// 1_agc037_a #include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #include <memory> #include <new> #include <numeric> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <streambuf> #include <string> #include <typeinfo> #include <utility> #include <valarray> #include <vector> // C++ #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep1(i, n) for (int i = 1; i <= (int)(n); i++) #define SZ(x) ((int)(x).size()) #define INF (1e16) #define MOD (1000000007) typedef long long ll; int main() { cin.tie(0); ios::sync_with_stdio(false); string s; cin >> s; int n = s.length(); if (n == 1) { cout << n << endl; return 0; } else if (n == 2) { if (s[0] == s[1]) cout << 1 << endl; else cout << 2 << endl; return 0; } vector<ll> dp1(n); vector<ll> dp2(n); dp1[0] = 0; if (s[0] == s[1]) dp1[1] = -INF; else dp1[1] = 2; dp2[0] = -INF; dp2[1] = 1; for (int i = 2; i < n; i++) { if (s[i] != s[i - 1]) { dp1[i] = max(dp1[i - 1], dp2[i - 1]) + 1; } else { dp1[i] = dp2[i - 1] + 1; } if (i == 2) { dp2[i] = dp1[i - 2] + 1; continue; } if (s.substr(i - 3, 2) != s.substr(i - 1, 2)) { dp2[i] = max(dp1[i - 2], dp2[i - 2]) + 1; } else { dp2[i] = dp1[i - 2] + 1; } } cout << max(dp1[n - 1], dp2[n - 1]) << endl; return 0; }
// 1_agc037_a #include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #include <memory> #include <new> #include <numeric> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <streambuf> #include <string> #include <typeinfo> #include <utility> #include <valarray> #include <vector> // C++ #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep1(i, n) for (int i = 1; i <= (int)(n); i++) #define SZ(x) ((int)(x).size()) #define INF (1e16) #define MOD (1000000007) typedef long long ll; int main() { cin.tie(0); ios::sync_with_stdio(false); string s; cin >> s; int n = s.length(); if (n == 1) { cout << n << endl; return 0; } else if (n == 2) { if (s[0] == s[1]) cout << 1 << endl; else cout << 2 << endl; return 0; } vector<ll> dp1(n); vector<ll> dp2(n); dp1[0] = 1; if (s[0] == s[1]) dp1[1] = -INF; else dp1[1] = 2; dp2[0] = -INF; dp2[1] = 1; for (int i = 2; i < n; i++) { if (s[i] != s[i - 1]) { dp1[i] = max(dp1[i - 1], dp2[i - 1]) + 1; } else { dp1[i] = dp2[i - 1] + 1; } if (i == 2) { dp2[i] = dp1[i - 2] + 1; continue; } if (s.substr(i - 3, 2) != s.substr(i - 1, 2)) { dp2[i] = max(dp1[i - 2], dp2[i - 2]) + 1; } else { dp2[i] = dp1[i - 2] + 1; } } cout << max(dp1[n - 1], dp2[n - 1]) << endl; return 0; }
[ "literal.number.change", "assignment.value.change" ]
741,775
741,776
u811561461
cpp
p02939
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; typedef vector<ll> vl; typedef vector<vl> vvl; template <typename T> using pq = priority_queue<T>; template <typename T> using minpq = priority_queue<T, vector<T>, greater<T>>; template <typename T, typename K> using ump = unordered_map<T, K>; const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; const ll mod = 1000000007; const ll inf = ll(1e9); const ll e5 = ll(1e5); const ll ll_inf = ll(1e9) * ll(1e9); #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define repr(i, n) for (ll i = n - 1; i >= 0; i--) #define repone(i, n) for (ll i = 1; i <= (ll)(n); i++) #define each(i, mp) for (auto &i : mp) #define eb emplace_back #define F first #define S second #define all(obj) (obj).begin(), (obj).end() template <class T> void dump_debug(T list) { #ifdef MY_DEBUG each(e, list) cout << e << " "; printf("\n"); #endif } /* ------------- ANSWER ------------- */ /* ---------------------------------- */ int main() { #ifdef MY_DEBUG while (true) { string s; cin >> s; ll n = s.size(); ll ans = 0; bool two = false; for (ll i = 0; i < n; ++i) { if (!two && i < n - 1 && s[i] == s[i + 1]) { two = true; i++; } else { two = false; } ans++; } cout << ans << endl; #endif #ifdef MY_DEBUG } #endif return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; typedef vector<ll> vl; typedef vector<vl> vvl; template <typename T> using pq = priority_queue<T>; template <typename T> using minpq = priority_queue<T, vector<T>, greater<T>>; template <typename T, typename K> using ump = unordered_map<T, K>; const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; const ll mod = 1000000007; const ll inf = ll(1e9); const ll e5 = ll(1e5); const ll ll_inf = ll(1e9) * ll(1e9); #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define repr(i, n) for (ll i = n - 1; i >= 0; i--) #define repone(i, n) for (ll i = 1; i <= (ll)(n); i++) #define each(i, mp) for (auto &i : mp) #define eb emplace_back #define F first #define S second #define all(obj) (obj).begin(), (obj).end() template <class T> void dump_debug(T list) { #ifdef MY_DEBUG each(e, list) cout << e << " "; printf("\n"); #endif } /* ------------- ANSWER ------------- */ /* ---------------------------------- */ int main() { #ifdef MY_DEBUG while (true) { #endif string s; cin >> s; ll n = s.size(); ll ans = 0; bool two = false; for (ll i = 0; i < n; ++i) { if (!two && i < n - 1 && s[i] == s[i + 1]) { two = true; i++; } else { two = false; } ans++; } cout << ans << endl; #ifdef MY_DEBUG } #endif return 0; }
[]
741,790
741,791
u136378781
cpp
p02939
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; #define INF (1 << 29) #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(v) v.begin(), v.end() #define uniq(v) v.erase(unique(all(v)), v.end()) int dp[200001][2]; int main() { ios::sync_with_stdio(0); cin.tie(0); string s; cin >> s; if (s.size() == 1) { cout << 1 << endl; return 0; } memset(dp, -1, sizeof(dp)); dp[1][0] = 1; dp[2][1] = 1; for (int i = 2; i < s.size(); i++) { rep(j, 2) if (dp[i][j] != -1) { if (j == 1 || s[i - 1] != s[i]) { dp[i + 1][0] = max(dp[i + 1][0], dp[i][j] + 1); } if (i + 2 <= s.size() && (j == 0 || s[i - 2] != s[i] || s[i - 1] != s[i + 1])) { dp[i + 2][1] = max(dp[i + 2][1], dp[i][j] + 1); } } } cout << max(dp[s.size()][0], dp[s.size()][1]) << endl; return 0; }
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; #define INF (1 << 29) #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(v) v.begin(), v.end() #define uniq(v) v.erase(unique(all(v)), v.end()) int dp[200001][2]; int main() { ios::sync_with_stdio(0); cin.tie(0); string s; cin >> s; if (s.size() == 1) { cout << 1 << endl; return 0; } memset(dp, -1, sizeof(dp)); dp[1][0] = 1; dp[2][1] = 1; for (int i = 1; i < s.size(); i++) { rep(j, 2) if (dp[i][j] != -1) { if (j == 1 || s[i - 1] != s[i]) { dp[i + 1][0] = max(dp[i + 1][0], dp[i][j] + 1); } if (i + 2 <= s.size() && (j == 0 || s[i - 2] != s[i] || s[i - 1] != s[i + 1])) { dp[i + 2][1] = max(dp[i + 2][1], dp[i][j] + 1); } } } cout << max(dp[s.size()][0], dp[s.size()][1]) << endl; return 0; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one" ]
741,792
741,793
u085110627
cpp
p02939
#include <algorithm> #include <complex> #include <fstream> #include <iostream> #include <queue> #include <set> #include <string> #include <vector> using namespace std; typedef long long ll; const int NMAX = 2 * 1e5 + 2; string s; int n, dp[2][NMAX]; // 1 si i est dans une pair et 0 sinon osef du reste int main() { ios::sync_with_stdio(false); cin >> s; n = s.size(); dp[0][0] = 1; dp[1][0] = 0; dp[1][1] = 1; if (n == 0 || s[1] != s[0]) dp[0][1] = 1; for (int i = 2; i < n; i++) { if (s[i] != s[i - 1]) { // on alterne sans pb dp[0][i] = max(dp[0][i], 1 + dp[0][i - 1]); } dp[0][i] = max(dp[0][i], 1 + dp[1][i - 1]); dp[1][i] = max(dp[1][i], 1 + dp[0][i - 2]); if (i >= 3 && (s[i] != s[i - 2] || s[i - 1] != s[i - 3])) dp[1][i] = max(dp[1][i], 1 + dp[1][i - 2]); } cout << max(dp[0][n - 1], dp[1][n - 1]) << '\n'; return 0; }
#include <algorithm> #include <complex> #include <fstream> #include <iostream> #include <queue> #include <set> #include <string> #include <vector> using namespace std; typedef long long ll; const int NMAX = 2 * 1e5 + 2; string s; int n, dp[2][NMAX]; // 1 si i est dans une pair et 0 sinon osef du reste int main() { ios::sync_with_stdio(false); cin >> s; n = s.size(); dp[0][0] = 1; dp[1][0] = 0; dp[1][1] = 1; if (n >= 2 && s[1] != s[0]) dp[0][1] = 2; for (int i = 2; i < n; i++) { if (s[i] != s[i - 1]) { // on alterne sans pb dp[0][i] = max(dp[0][i], 1 + dp[0][i - 1]); } dp[0][i] = max(dp[0][i], 1 + dp[1][i - 1]); dp[1][i] = max(dp[1][i], 1 + dp[0][i - 2]); if (i >= 3 && (s[i] != s[i - 2] || s[i - 1] != s[i - 3])) dp[1][i] = max(dp[1][i], 1 + dp[1][i - 2]); } cout << max(dp[0][n - 1], dp[1][n - 1]) << '\n'; return 0; }
[ "literal.number.change", "assignment.value.change" ]
741,796
741,797
u558431380
cpp
p02939
#include <bits/stdc++.h> #define int long long #define REP(i, l, r) REPEAT(i, l, r, true) // [l, r) #define rep(i, n) REP(i, 0, n) // [0, n) #define REPEAT(i, l, r, condition) \ for (int i = (condition) ? l : r - 1; (condition) ? i < r : i >= l; \ (condition) ? ++i : --i) // false<-[l, r)->true #define all(e) e.begin(), e.end() #define rall(e) e.rbegin(), e.rend() #define pb push_back #define fs first #define sc second #ifdef LOCAL #define show(...) \ cerr << #__VA_ARGS__ << " = "; \ _DEBUG(__VA_ARGS__) #define showlr(n, l, r) \ cerr << #n << " = "; \ for (int i = l; i < r; i++) { \ cerr << n[i] << ", "; \ } \ cerr << endl // [l, r) #else #define show(...) true #define showlr(n, l, r) true #endif #define YN(condition) puts((condition) ? "YES" : "NO") #define Yn(condition) puts((condition) ? "Yes" : "No") #define yn(condition) puts((condition) ? "yes" : "no") #define YES puts("YES") #define Yes puts("Yes") #define yes puts("yes") #define NO puts("NO") #define No puts("No") #define no puts("no") #define case (i) printf("Case #%lld: ", i) using namespace std; using vi = vector<int>; using pint = pair<int, int>; struct io { io() { cin.tie(0); ios::sync_with_stdio(false); cout.tie(0); cout << fixed << setprecision(20); } } io; template <class T> istream &operator>>(istream &is, vector<T> &v) { for (T &e : v) is >> e; return is; } template <class T> ostream &operator<<(ostream &os, vector<T> v) { os << "{"; for (T &e : v) os << e << (v.size() - (int)(&e - &v[0]) > 1 ? ", " : ""); os << "}"; return os; } void _DEBUG() {} template <typename H, typename... T> void _DEBUG(H a, T... b) { cerr << a << (sizeof...(b) ? "," : "\n"); _DEBUG(b...); } inline void in() {} template <typename H, typename... T> void in(H &a, T &...b) { cin >> a; in(b...); } inline void out() {} template <typename H, typename... T> void out(H a, T... b) { cout << a << (sizeof...(b) ? " " : "\n"); out(b...); } template <class T> void resz(int n, T &v) { v.resize(n); } template <class H, class... T> void resz(int n, H &a, T &...b) { a.resize(n); resz(n, b...); } template <typename V, typename H> void resize(vector<V> &v, const H a) { v.resize(a); } template <typename V, typename H, typename... T> void resize(vector<V> &v, const H &a, const T... b) { v.resize(a); for (auto &v : v) resize(v, b...); } const int INF = 1LL << 55; const int MOD = 1000000007; const double EPS = 1e-8; /*------------end of definitions------------*/ string S; int ans = 1; signed main() { in(S); string preview = S.substr(0, 1); int i = 0; for (; i < S.size(); i++) { string current = S.substr(i, 1); show(preview, current); if (preview == current) { current = S.substr(i, 2); i++; } preview = current; ans++; } if (i >= S.size()) ans--; out(ans); return 0; }
#include <bits/stdc++.h> #define int long long #define REP(i, l, r) REPEAT(i, l, r, true) // [l, r) #define rep(i, n) REP(i, 0, n) // [0, n) #define REPEAT(i, l, r, condition) \ for (int i = (condition) ? l : r - 1; (condition) ? i < r : i >= l; \ (condition) ? ++i : --i) // false<-[l, r)->true #define all(e) e.begin(), e.end() #define rall(e) e.rbegin(), e.rend() #define pb push_back #define fs first #define sc second #ifdef LOCAL #define show(...) \ cerr << #__VA_ARGS__ << " = "; \ _DEBUG(__VA_ARGS__) #define showlr(n, l, r) \ cerr << #n << " = "; \ for (int i = l; i < r; i++) { \ cerr << n[i] << ", "; \ } \ cerr << endl // [l, r) #else #define show(...) true #define showlr(n, l, r) true #endif #define YN(condition) puts((condition) ? "YES" : "NO") #define Yn(condition) puts((condition) ? "Yes" : "No") #define yn(condition) puts((condition) ? "yes" : "no") #define YES puts("YES") #define Yes puts("Yes") #define yes puts("yes") #define NO puts("NO") #define No puts("No") #define no puts("no") #define case (i) printf("Case #%lld: ", i) using namespace std; using vi = vector<int>; using pint = pair<int, int>; struct io { io() { cin.tie(0); ios::sync_with_stdio(false); cout.tie(0); cout << fixed << setprecision(20); } } io; template <class T> istream &operator>>(istream &is, vector<T> &v) { for (T &e : v) is >> e; return is; } template <class T> ostream &operator<<(ostream &os, vector<T> v) { os << "{"; for (T &e : v) os << e << (v.size() - (int)(&e - &v[0]) > 1 ? ", " : ""); os << "}"; return os; } void _DEBUG() {} template <typename H, typename... T> void _DEBUG(H a, T... b) { cerr << a << (sizeof...(b) ? "," : "\n"); _DEBUG(b...); } inline void in() {} template <typename H, typename... T> void in(H &a, T &...b) { cin >> a; in(b...); } inline void out() {} template <typename H, typename... T> void out(H a, T... b) { cout << a << (sizeof...(b) ? " " : "\n"); out(b...); } template <class T> void resz(int n, T &v) { v.resize(n); } template <class H, class... T> void resz(int n, H &a, T &...b) { a.resize(n); resz(n, b...); } template <typename V, typename H> void resize(vector<V> &v, const H a) { v.resize(a); } template <typename V, typename H, typename... T> void resize(vector<V> &v, const H &a, const T... b) { v.resize(a); for (auto &v : v) resize(v, b...); } const int INF = 1LL << 55; const int MOD = 1000000007; const double EPS = 1e-8; /*------------end of definitions------------*/ string S; int ans = 1; signed main() { in(S); string preview = S.substr(0, 1); int i = 1; for (; i < S.size(); i++) { string current = S.substr(i, 1); show(preview, current); if (preview == current) { current = S.substr(i, 2); i++; } preview = current; ans++; } if (i > S.size()) ans--; out(ans); return 0; }
[ "literal.number.change", "variable_declaration.value.change", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
741,798
741,799
u810724221
cpp
p02939
#include <algorithm> #include <iomanip> #include <iostream> #include <queue> #include <set> #include <string> #include <vector> using namespace std; int main() { string s; cin >> s; char bef; int ans = 1; bef = s[0]; for (int i = 1; i < s.size(); i++) { if (bef == '0') { ans++; bef = '1'; } else if (bef == s[i]) { bef = '0'; } else { ans++; bef = s[i]; } } if (bef == '0') ans = 0; int ansan = ans; ans = 2; bef = s[2]; for (int i = 3; i < s.size(); i++) { if (bef == '0') { ans++; bef = '1'; } else if (bef == s[i]) { bef = '0'; } else { ans++; bef = s[i]; } } cout << max(ans, ansan) << endl; // cout << ans << ":" << ansan << endl; }
#include <algorithm> #include <iomanip> #include <iostream> #include <queue> #include <set> #include <string> #include <vector> using namespace std; int main() { string s; cin >> s; char bef; int ans = 1; bef = s[0]; for (int i = 1; i < s.size(); i++) { if (bef == '0') { ans++; bef = '1'; } else if (bef == s[i]) { bef = '0'; } else { ans++; bef = s[i]; } } if (bef == '0') ans = ans; int ansan = ans; ans = 2; bef = s[2]; for (int i = 3; i < s.size(); i++) { if (bef == '0') { ans++; bef = '1'; } else if (bef == s[i]) { bef = '0'; } else { ans++; bef = s[i]; } } cout << max(ans, ansan) << endl; // cout << ans << ":" << ansan << endl; }
[ "assignment.value.change", "identifier.replace.add", "literal.replace.remove" ]
741,808
741,809
u990764614
cpp
p02940
#include <cstdio> #include <cstring> #include <iostream> using namespace std; const int mod = 998244353; #define N 300030 inline int read() { int x = 0, f = 1; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { x = (x << 1) + (x << 3) + c - '0'; c = getchar(); } return x * f; } int cnt[6], n, ans; char s[N]; inline int Get(char c) { return c == 'R' ? 0 : (c == 'G' ? 1 : 2); } int main() { n = read(); scanf("%s", s + 1); ans = 1; for (int i = 1; i <= 3 * n; ++i) { int x = Get(s[i]); bool flag = true; if (cnt[5 - x]) { ans = 1LL * ans * (cnt[5 - x]--) % mod; flag = false; } else { switch (x) { case 0: if (!cnt[1] && !cnt[2]) break; ans = 1LL * ans * (cnt[1] + cnt[2]) % mod; if (cnt[1]) --cnt[1], ++cnt[3]; if (cnt[2]) --cnt[2], ++cnt[4]; flag = false; break; case 1: if (!cnt[0] && !cnt[2]) break; ans = 1LL * ans * (cnt[0] + cnt[2]) % mod; if (cnt[0]) --cnt[0], ++cnt[3]; if (cnt[2]) --cnt[2], ++cnt[5]; flag = false; break; case 2: if (!cnt[0] && !cnt[1]) break; ans = 1LL * ans * (cnt[0] + cnt[2]) % mod; if (cnt[0]) --cnt[0], ++cnt[4]; if (cnt[1]) --cnt[1], ++cnt[5]; flag = false; break; } } if (flag) { ++cnt[x]; } } for (int i = 1; i <= n; ++i) { ans = 1LL * ans * i % mod; } printf("%d\n", ans); return 0; }
#include <cstdio> #include <cstring> #include <iostream> using namespace std; const int mod = 998244353; #define N 300030 inline int read() { int x = 0, f = 1; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { x = (x << 1) + (x << 3) + c - '0'; c = getchar(); } return x * f; } int cnt[6], n, ans; char s[N]; inline int Get(char c) { return c == 'R' ? 0 : (c == 'G' ? 1 : 2); } int main() { n = read(); scanf("%s", s + 1); ans = 1; for (int i = 1; i <= 3 * n; ++i) { int x = Get(s[i]); bool flag = true; if (cnt[5 - x]) { ans = 1LL * ans * (cnt[5 - x]--) % mod; flag = false; } else { switch (x) { case 0: if (!cnt[1] && !cnt[2]) break; ans = 1LL * ans * (cnt[1] + cnt[2]) % mod; if (cnt[1]) --cnt[1], ++cnt[3]; if (cnt[2]) --cnt[2], ++cnt[4]; flag = false; break; case 1: if (!cnt[0] && !cnt[2]) break; ans = 1LL * ans * (cnt[0] + cnt[2]) % mod; if (cnt[0]) --cnt[0], ++cnt[3]; if (cnt[2]) --cnt[2], ++cnt[5]; flag = false; break; case 2: if (!cnt[0] && !cnt[1]) break; ans = 1LL * ans * (cnt[0] + cnt[1]) % mod; if (cnt[0]) --cnt[0], ++cnt[4]; if (cnt[1]) --cnt[1], ++cnt[5]; flag = false; break; } } if (flag) { ++cnt[x]; } } for (int i = 1; i <= n; ++i) { ans = 1LL * ans * i % mod; } printf("%d\n", ans); return 0; }
[ "literal.number.change", "assignment.value.change", "variable_access.subscript.index.change", "expression.operation.binary.change" ]
741,957
741,958
u979500307
cpp
p02940
#include <bits/stdc++.h> using namespace std; #pragma region macros_and_aliases #define rep(i, n) for (long long i = 0; i < (n); i++) #define rrep(i, n) for (long long i = (n)-1; i > -1; i--) #define Rep(i, m, n) for (long long i = (m); i < (n); i++) #define rRep(i, m, n) for (long long i = (n)-1; i >= (m); i--) #define REP(i, m, n, p) for (long long i = m; i < n; i += p) #define foa(s, v) for (auto &s : v) #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define pq priority_queue #define bcnt(n) __builtin_popcountll(n) #define endk endl #define ednl endl #define enld endl using ll = long long; using ld = long double; using vb = vector<bool>; using vll = vector<ll>; using vvll = vector<vll>; using vvvll = vector<vvll>; using mll = map<long long, long long>; using pll = pair<long long, long long>; using qll = queue<long long>; using sll = set<long long>; using vpll = vector<pair<long long, long long>>; template <class T = ll> using V = vector<T>; template <class T = ll> using VV = V<V<T>>; template <class T = ll> using VVV = V<V<V<T>>>; //昇順pq(小さい方から取り出す) template <class T = ll> using pqup = priority_queue<T, vector<T>, greater<T>>; //降順pq(大きい方から取り出す) template <class T = ll> using pqdn = priority_queue<T>; #define debug(var) \ std::cout << #var << " : "; \ view(var) template <typename T> void view(T e) { std::cout << e << std::endl; } template <typename T> void view(const std::vector<T> &v) { for (const auto &e : v) { std::cout << e << " "; } std::cout << std::endl; } template <typename T> void view(const std::vector<std::vector<T>> &vv) { cout << "\n"; for (const auto &v : vv) { view(v); } } template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << p.first << " " << p.second; return os; } template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; } #pragma endregion #pragma region constants long long const limLL = 9223372036854775807; // POW(2,63)-1 ~ 9.22e18 long long const dekai = 3e16; const long double pi = acos(-1); int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; int ddx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}; int ddy[8] = {-1, 0, 1, -1, 1, -1, 0, 1}; // const int mod = 1000000007; const int mod = 998244353; #pragma endregion #pragma region basic_procedure template <class T> inline bool isin(T x, T lef, T rig) { return ((lef <= x) && (x < rig)); } template <class T> inline bool isin(T x, T y, T lef, T rig) { return isin(x, lef, rig) && isin(y, lef, rig); } template <class T> inline bool isin(T X, T lefX, T rigX, T Y, T lefY, T rigY) { return isin(X, lefX, rigX) && isin(Y, lefY, rigY); } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } void Yes(bool f = 1) { cout << (f ? "Yes" : "No") << "\n"; } void No() { cout << "No\n"; } void YES(bool f = 1) { cout << (f ? "YES" : "NO") << "\n"; } void NO() { cout << "NO\n"; } void err() { cout << -1 << "\n"; } vector<long long> vin(long long n) { //整数n個の入力を受け取ってベクトルに突っ込んで返す vector<long long> v(n); for (long long i = 0; i < n; i++) { cin >> v[i]; } return v; } //ベクトルの出力(検証済) // vectorの中身を出力する 答えの出力に利用可能 template <class T> void vout(vector<T> &v, bool tate = 0) { if (v.size() > 0) { for (auto it = v.begin(); it < v.end(); it++) { cout << *it; if (it != v.end() - 1) { if (tate) cout << endl; else cout << " "; } } } cout << endl; } template <class T> void add(vector<T> &v, T val) { //ベクトルの各要素に加算 for (auto &a : v) a += val; return; } // vectorの中身を数える map<要素,個数>を返す template <class T> map<T, long long> cntv(vector<T> v) { map<T, long long> m; for (auto &g : v) { if (m.count(g)) m[g]++; else m[g] = 1; } return m; } //配列圧縮(検証済) //{1,36,1,3,8,-2,-92}を //{2, 5,2,3,4, 1, 0}にする template <class T> vector<long long> press(vector<T> &v) { long long n = v.size(); vector<long long> w(n); map<T, long long> m; for (T &p : v) m[p] = 0; long long i = 0; for (auto &p : m) { p.second = i; i++; } for (long long i = 0; i < n; i++) w.at(i) = m[v.at(i)]; return w; } template <class T> T divup(T a, T b) { //端数繰りあがり割り算 assert(b != 0); T x = abs(a); T y = abs(b); T z = (x + y - 1) / y; if ((a < 0 && b > 0) || (a > 0 && b < 0)) return -z; else if (a == 0) return 0; else return z; } long long POW(long long a, long long n) { // 整数のとき限定の普通のPOW関数 //標準機能のpow(a,n)は整数だとバグるのでこちらを使う long long res = 1; while (n > 0) { if (n & 1) res = res * a; a = a * a; n >>= 1; } return res; } template <class T> int sgn(T x) { //符号関数 if (x < 0) return -1; if (x == 0) return x; return 1; } long long modpow(long long a, long long n, long long mod) { // a^n mod long long res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } long long modinv(long long a, long long mod) { // a^{-1} mod // modとaが互いに素のときのみ有効(数学的に逆元が一意に定まるのがそのときのみ) return modpow(a, mod - 2, mod); } vvll comb(100, vll(100, -1)); long long com(long long n, long long k) { //普通の二項計数(overflowに注意) assert(n < 100 && k < 100); if (n < k || k < 0 || n < 0) return 0; if (comb[n][k] != -1) return comb[n][k]; ll res; if (n - k < k) res = com(n, n - k); else if (k == 0) res = 1; else res = com(n - 1, k - 1) + com(n - 1, k); comb[n][k] = res; return res; } // nCk modを求める const ll MAX = 5100000; // この値は求める二項計数の値に応じて変える // MAX=3*10^7のとき1900msほど、ほぼ比例 // MAX=5*10^6程度ならそれほど気にしなくてよい(300ms程) long long fac[MAX], finv[MAX], inv[MAX]; void cominit() { // テーブルを作る前処理 fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (ll i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % mod; inv[i] = mod - inv[mod % i] * (mod / i) % mod; finv[i] = finv[i - 1] * inv[i] % mod; } } long long commod(ll n, ll k) { // 二項係数計算 if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % mod) % mod; } long long pmod(ll n, ll k) { //順列計算 if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * finv[n - k] % mod; } long long hmod(ll n, ll k) { // nHk計算 // n個の区別しないoを区別するk個の箱に入れる方法の総数 //(n+k-1)C(k-1)と等しい return commod(n + k - 1, n); } #pragma endregion template <class T = long long> struct edge { T len; int from; int to; bool operator<(const edge a) const { if (len != a.len) return len < a.len; if (from != a.from) return from < a.from; return to < a.to; } bool operator>(const edge a) const { if (len != a.len) return len > a.len; if (from != a.from) return from > a.from; return to > a.to; } }; template <class T = long long> struct graph { // 0-indexed T const INF = numeric_limits<T>::max() / 3; vector<vector<edge<T>>> edges; bool directed, weight; int ver; // constructor graph() = default; graph(int vertex, bool direction = 0, bool weigh = 0) : edges(vertex) { ver = vertex; directed = direction; weight = weigh; edges.resize(vertex); } //辺の追加 (0-indexed) void update(int from, int to, T len = 1, bool direction = 1) { edge<T> e; e.len = len; e.from = from; e.to = to; edges[from].push_back(e); if (!direction) { swap(e.to, e.from); edges[to].push_back(e); } } //入力受取 (1-indexed) void input(int edge_num, int index = 1) { for (int i = 0; i < edge_num; i++) { int a; int b; cin >> a >> b; a -= index; b -= index; T c; if (weight) cin >> c; else c = 1; update(a, b, c, directed); } } // 辺の長さを全て1とみたときの単一始点最短経路 (無理なときはINF) vector<T> bfs(int start) { // https://atcoder.jp/contests/abc007/submissions/me vector<T> ret(ver, INF); queue<int> q; q.push(start); ret[start] = 0; while (!q.empty()) { int now = q.front(); q.pop(); for (auto &e : edges[now]) { if (ret[e.to] != INF) continue; q.push(e.to); ret[e.to] = ret[now] + 1; } } return ret; } //長さが負のpathがないときの単一始点最短経路<vll> O((ver)log(ver)+(edge)) vector<T> dijkstra(int start) { vector<T> ret(ver, (T)INF); // pqup<pair<T, int>> p; // //{dist,place} priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> p; //{dist,place} p.push({0, start}); ret[start] = 0; while (!p.empty()) { T dist = p.top().first; int place = p.top().second; p.pop(); if (ret[place] < dist) continue; for (auto &next : edges[place]) { int nextplace = next.to; T dis = next.len; if (ret[nextplace] > dist + dis) { ret[nextplace] = dist + dis; p.push({ret[nextplace], nextplace}); } } } return ret; } //単一始点最短経路 O((ver)*(edge)) //辿り着けないとき ret[i] = INF; //ある頂点までのコストが無限に小さくなり得るとき→ ret[i] = -INF; vector<T> BellmanFord(int start) { // https://onlinejudge.u-aizu.ac.jp/problems/GRL_1_B vector<T> ret(ver, INF); ret[start] = 0; for (int loop = 0; loop < ver - 1; loop++) { for (int v = 0; v < ver; v++) { if (ret[v] == INF) continue; for (auto &e : edges[v]) { ret[e.to] = min(ret[e.to], ret[v] + e.len); } } } //無限降下点の検索 queue<int> q; vector<bool> chk(ver, 0); for (int v = 0; v < ver; v++) { if (ret[v] == INF) continue; for (auto &e : edges[v]) { if (ret[e.to] > ret[v] + e.len) { ret[e.to] = ret[v] + e.len; if (!chk[e.to]) { q.push(e.to); chk[e.to] = 1; } } } } while (!q.empty()) { int now = q.front(); q.pop(); for (auto &e : edges[now]) { if (!chk[e.to]) { chk[e.to] = 1; q.push(e.to); } } } for (int i = 0; i < ver; i++) if (chk[i]) ret[i] = -INF; return ret; } //閉路に含まれない頂点列挙 //要素数がver未満なら閉路が存在、そうでなければ閉路は存在しない vector<int> topo_sort() { // https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/all/GRL_4_A // https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/all/GRL_4_B assert(directed); vector<int> num_input(ver); // 入次数 for (int i = 0; i < ver; i++) { for (auto e : edges[i]) { num_input[e.to]++; } } // 入次数が0のノードをqueueで管理する queue<int> que; for (int i = 0; i < ver; i++) { if (num_input[i] == 0) { que.push(i); } } vector<int> ans; while (!que.empty()) { auto node = que.front(); que.pop(); ans.push_back(node); // 頂点の削除 for (auto e : edges[node]) { num_input[e.to]--; // 行き先の入次数が0になったらqueueに追加 if (num_input[e.to] == 0) { que.push(e.to); } } } return ans; } //{{端点、端点},直径の大きさ} pair<pair<int, int>, T> DiameterOfTree(bool weigh = true) { // https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/all/GRL_5_A vector<T> vec; vec = weigh ? dijkstra(0) : bfs(0); int v1 = -1; T dia = -1; for (int i = 0; i < ver; i++) if ((dia < vec[i])) { dia = vec[i]; v1 = i; } vec = weigh ? dijkstra(v1) : bfs(v1); dia = -1; int v2 = -1; for (int i = 0; i < ver; i++) if ((dia < vec[i])) { v2 = i; dia = vec[i]; } pair<pair<int, int>, T> ans = {{v1, v2}, dia}; return ans; } //無向木構造を根から葉に伸びる有向木構造に書き換える graph<T> RootToLeaf(int root) { // 0-indexed graph<T> ret(ver, 1, weight); vector<bool> chk(ver, 0); chk[root] = 1; function<void(int)> dfs = [&](int now) { for (auto &e : edges[now]) { if (chk[e.to] == 1) continue; chk[e.to] = 1; ret.update(now, e.to, e.len, 1); dfs(e.to); } }; dfs(root); return ret; } //無向木構造を葉から根に伸びる有向木構造に書き換える graph<T> LeafToRoot(int root) { // 0-indexed graph<T> ret(ver, 1, weight); vector<bool> chk(ver, 0); chk[root] = 1; function<void(int)> dfs = [&](int now) { for (auto &e : edges[now]) { if (chk[e.to] == 1) continue; chk[e.to] = 1; ret.update(e.to, now, e.len, 1); dfs(e.to); } }; dfs(root); ret.update(root, root, 0); return ret; } // LeafToRootのvector版.par[i]=iの親の頂点 vector<int> par(int root) { // 0-indexed vector<int> ret(ver, -1); ret[root] = root; // rootの親はroot function<void(int)> dfs = [&](int now) { for (auto &e : edges[now]) { if (ret[e.to] != -1) continue; ret[e.to] = now; dfs(e.to); } }; dfs(root); return ret; } vector<edge<T>> ParentAndDistance(int root) { // 0-indexed vector<edge<T>> ret(ver); for (int i = 0; i < ver; i++) ret[i].to = -1; ret[root].to = root; // rootの親はroot ret[root].len = 0; // rootの親との距離は0 function<void(int)> dfs = [&](int now) { for (auto &e : edges[now]) { if (ret[e.to].to != -1) continue; ret[e.to].to = now; ret[e.to].len = e.len; dfs(e.to); } }; dfs(root); return ret; } //隣接sheet.主にwarshall用 vector<vector<T>> GraphArray(void) { vector<vector<T>> ret(ver, vector<T>(ver, INF)); for (int from = 0; from < ver; from++) { for (auto &e : edges[from]) { ret[from][e.to] = e.len; } ret[from][from] = 0; } return ret; } graph<T> Prim(int start = 0) { // https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/all/GRL_2_A graph<T> ret(ver, 0, 1); priority_queue<edge<T>, vector<edge<T>>, greater<edge<T>>> p; for (auto &e : edges[start]) { p.push(e); } vector<bool> chk(ver, 0); chk[start] = 1; while (!p.empty()) { auto ed = p.top(); p.pop(); if (chk[ed.to]) continue; chk[ed.to] = 1; ret.update(ed.from, ed.to, ed.len); for (auto &e : edges[ed.to]) { p.push(e); } } return ret; } //各頂点を根としたときの木の高さ vector<T> height(int start = 0) { // https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/all/GRL_5_B vector<T> fir(ver, -1), sec(ver, -1); function<T(int, int)> dfs = [&](int now, int par) { T f = 0, s = 0; // startを根としたときのnowからの深さ1番目、2番目 for (auto &e : edges[now]) { if (e.to == par) continue; s = max(s, dfs(e.to, now) + e.len); if (f < s) swap(f, s); } sec[now] = s; return fir[now] = f; }; dfs(start, -1); function<void(int, int, T, T, T)> sol = [&](int now, int par, T parf, T pars, T parlen) { if (fir[now] + parlen == parf) parf = pars; sec[now] = max(sec[now], parf + parlen); if (fir[now] < sec[now]) swap(fir[now], sec[now]); for (auto &e : edges[now]) { if (e.to == par) continue; sol(e.to, now, fir[now], sec[now], e.len); } return; }; sol(start, -1, -1, -1, -1); return fir; } //全方位木DP //マージ関数、上に送るための関数、単位元、はじめの根 // 関数はstd::functionで渡す template <class U> vector<U> zenhoui(function<U(U, U)> f, function<U(U)> g, U unit, int root = 0) { auto tr = RootToLeaf(root); vector<vector<U>> v(ver); vector<U> ret(ver); //求める答 function<U(int)> dfs = [&](int now) { U res = unit; vector<U> vec; for (auto &e : tr.edges[now]) { U k = dfs(e.to); vec.push_back(k); res = f(res, k); } v[now] = vec; return g(res); }; dfs(root); function<void(int, U)> dfs2 = [&](int now, U ans_par) { int sz = v[now].size(); vector<U> mae(sz + 1), rev(sz + 1); mae[0] = rev[sz] = unit; for (int i = 0; i < sz; i++) mae[i + 1] = f(mae[i], v[now][i]); for (int i = sz - 1; i >= 0; i--) rev[i] = f(rev[i + 1], v[now][i]); for (int i = 0; i < sz; i++) { auto nxtans = f(ans_par, f(mae[i], rev[i + 1])); dfs2(tr.edges[now][i].to, g(nxtans)); } ret[now] = f(ans_par, mae[sz]); return; }; dfs2(root, unit); return ret; } // HL分解 }; struct mint { // auto mod int // https://youtu.be/L8grWxBlIZ4?t=9858 // https://youtu.be/ERZuLAxZffQ?t=4807 : optimize // https://youtu.be/8uowVvQ_-Mo?t=1329 : division ll x; // typedef long long ll; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint operator-() const { return mint(-x); } mint &operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint &operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint &operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { return mint(*this) += a; } mint operator-(const mint a) const { return mint(*this) -= a; } mint operator*(const mint a) const { return mint(*this) *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod - 2); } mint &operator/=(const mint a) { return *this *= a.inv(); } mint operator/(const mint a) const { return mint(*this) /= a; } }; istream &operator>>(istream &is, const mint &a) { return is >> a.x; } ostream &operator<<(ostream &os, const mint &a) { return os << a.x; } mint sol(vll v) { mint res = 1; ll k = v.size(); ll cnt = k; rep(i, k - 1) { if (v[i] != v[i + 1]) { cnt = i + 1; break; } } ll lef = v[0]; ll t, s; t = lef + 1, s = lef + 2; t %= 3, s %= 3; ll h = 0; // tの個数ーsの個数 rRep(i, cnt, k) { if (v[i] == t) { if (h < 0) { res *= -h; } h++; } else { if (h > 0) res *= abs(h); h--; } } rep(i, cnt) res *= i + 1; return res; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); // cout << fixed << setprecision(15); ll n; cin >> n; string s; cin >> s; ll n3 = n * 3; vll t(n3); vll chk(n3); mint ans = 1; vll r, g, b; rep(i, n3) { if (s[i] == 'R') { r.push_back(i); t[i] = 0; } else if (s[i] == 'G') { g.push_back(i); t[i] = 1; } else { b.push_back(i); t[i] = 2; } } vll a, c, d; rep(i, n) { ll u, v, w; u = r[i], v = g[i], w = b[i]; ll x, y, z; x = min({u, v, w}); z = max({u, v, w}); y = u + v + w - x - z; a.push_back(x); c.push_back(y); d.push_back(z); } ll it = 0, ti = 0; // debug(a); // debug(c); // debug(d); rep(i, n) { while (it < n && a[it] < c[i]) it++; while (ti < n && d[ti] < c[i]) ti++; // debug(i); // debug(it); // debug(ti); ans *= (it - i) * (n - (n - i) + 1 - ti); debug(ans); } rep(i, n) ans *= i + 1; cout << ans << endl; // while(it < n3) { // vector<ll> vec; // // ll a, c, d; // // a = c = d = 0; // vll cnt(3); // ll h = 0; // ll st = t[it]; // bool f = 1; // Rep(j, it, n3) { // if(chk[j]) continue; // if(f) { // if(t[j] == st) // vec.push_back(st), cnt[st]++, chk[j] = 1; // else { // f = false; // h = cnt[st]; // it = n3; // } // } // if(!f) { // ll k = t[j]; // if(cnt[k] < h) // cnt[k]++, vec.push_back(k), chk[j] = 1; // else // chmin(it, j); // } // if(cnt[0] == cnt[1] && cnt[1] == cnt[2]) break; // } // ans *= sol(vec); // debug(ans); // debug(vec); // } // rep(i, n) ans *= i + 1; // cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #pragma region macros_and_aliases #define rep(i, n) for (long long i = 0; i < (n); i++) #define rrep(i, n) for (long long i = (n)-1; i > -1; i--) #define Rep(i, m, n) for (long long i = (m); i < (n); i++) #define rRep(i, m, n) for (long long i = (n)-1; i >= (m); i--) #define REP(i, m, n, p) for (long long i = m; i < n; i += p) #define foa(s, v) for (auto &s : v) #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define pq priority_queue #define bcnt(n) __builtin_popcountll(n) #define endk endl #define ednl endl #define enld endl using ll = long long; using ld = long double; using vb = vector<bool>; using vll = vector<ll>; using vvll = vector<vll>; using vvvll = vector<vvll>; using mll = map<long long, long long>; using pll = pair<long long, long long>; using qll = queue<long long>; using sll = set<long long>; using vpll = vector<pair<long long, long long>>; template <class T = ll> using V = vector<T>; template <class T = ll> using VV = V<V<T>>; template <class T = ll> using VVV = V<V<V<T>>>; //昇順pq(小さい方から取り出す) template <class T = ll> using pqup = priority_queue<T, vector<T>, greater<T>>; //降順pq(大きい方から取り出す) template <class T = ll> using pqdn = priority_queue<T>; #define debug(var) \ std::cout << #var << " : "; \ view(var) template <typename T> void view(T e) { std::cout << e << std::endl; } template <typename T> void view(const std::vector<T> &v) { for (const auto &e : v) { std::cout << e << " "; } std::cout << std::endl; } template <typename T> void view(const std::vector<std::vector<T>> &vv) { cout << "\n"; for (const auto &v : vv) { view(v); } } template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << p.first << " " << p.second; return os; } template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; } #pragma endregion #pragma region constants long long const limLL = 9223372036854775807; // POW(2,63)-1 ~ 9.22e18 long long const dekai = 3e16; const long double pi = acos(-1); int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; int ddx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}; int ddy[8] = {-1, 0, 1, -1, 1, -1, 0, 1}; // const int mod = 1000000007; const int mod = 998244353; #pragma endregion #pragma region basic_procedure template <class T> inline bool isin(T x, T lef, T rig) { return ((lef <= x) && (x < rig)); } template <class T> inline bool isin(T x, T y, T lef, T rig) { return isin(x, lef, rig) && isin(y, lef, rig); } template <class T> inline bool isin(T X, T lefX, T rigX, T Y, T lefY, T rigY) { return isin(X, lefX, rigX) && isin(Y, lefY, rigY); } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } void Yes(bool f = 1) { cout << (f ? "Yes" : "No") << "\n"; } void No() { cout << "No\n"; } void YES(bool f = 1) { cout << (f ? "YES" : "NO") << "\n"; } void NO() { cout << "NO\n"; } void err() { cout << -1 << "\n"; } vector<long long> vin(long long n) { //整数n個の入力を受け取ってベクトルに突っ込んで返す vector<long long> v(n); for (long long i = 0; i < n; i++) { cin >> v[i]; } return v; } //ベクトルの出力(検証済) // vectorの中身を出力する 答えの出力に利用可能 template <class T> void vout(vector<T> &v, bool tate = 0) { if (v.size() > 0) { for (auto it = v.begin(); it < v.end(); it++) { cout << *it; if (it != v.end() - 1) { if (tate) cout << endl; else cout << " "; } } } cout << endl; } template <class T> void add(vector<T> &v, T val) { //ベクトルの各要素に加算 for (auto &a : v) a += val; return; } // vectorの中身を数える map<要素,個数>を返す template <class T> map<T, long long> cntv(vector<T> v) { map<T, long long> m; for (auto &g : v) { if (m.count(g)) m[g]++; else m[g] = 1; } return m; } //配列圧縮(検証済) //{1,36,1,3,8,-2,-92}を //{2, 5,2,3,4, 1, 0}にする template <class T> vector<long long> press(vector<T> &v) { long long n = v.size(); vector<long long> w(n); map<T, long long> m; for (T &p : v) m[p] = 0; long long i = 0; for (auto &p : m) { p.second = i; i++; } for (long long i = 0; i < n; i++) w.at(i) = m[v.at(i)]; return w; } template <class T> T divup(T a, T b) { //端数繰りあがり割り算 assert(b != 0); T x = abs(a); T y = abs(b); T z = (x + y - 1) / y; if ((a < 0 && b > 0) || (a > 0 && b < 0)) return -z; else if (a == 0) return 0; else return z; } long long POW(long long a, long long n) { // 整数のとき限定の普通のPOW関数 //標準機能のpow(a,n)は整数だとバグるのでこちらを使う long long res = 1; while (n > 0) { if (n & 1) res = res * a; a = a * a; n >>= 1; } return res; } template <class T> int sgn(T x) { //符号関数 if (x < 0) return -1; if (x == 0) return x; return 1; } long long modpow(long long a, long long n, long long mod) { // a^n mod long long res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } long long modinv(long long a, long long mod) { // a^{-1} mod // modとaが互いに素のときのみ有効(数学的に逆元が一意に定まるのがそのときのみ) return modpow(a, mod - 2, mod); } vvll comb(100, vll(100, -1)); long long com(long long n, long long k) { //普通の二項計数(overflowに注意) assert(n < 100 && k < 100); if (n < k || k < 0 || n < 0) return 0; if (comb[n][k] != -1) return comb[n][k]; ll res; if (n - k < k) res = com(n, n - k); else if (k == 0) res = 1; else res = com(n - 1, k - 1) + com(n - 1, k); comb[n][k] = res; return res; } // nCk modを求める const ll MAX = 5100000; // この値は求める二項計数の値に応じて変える // MAX=3*10^7のとき1900msほど、ほぼ比例 // MAX=5*10^6程度ならそれほど気にしなくてよい(300ms程) long long fac[MAX], finv[MAX], inv[MAX]; void cominit() { // テーブルを作る前処理 fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (ll i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % mod; inv[i] = mod - inv[mod % i] * (mod / i) % mod; finv[i] = finv[i - 1] * inv[i] % mod; } } long long commod(ll n, ll k) { // 二項係数計算 if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % mod) % mod; } long long pmod(ll n, ll k) { //順列計算 if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * finv[n - k] % mod; } long long hmod(ll n, ll k) { // nHk計算 // n個の区別しないoを区別するk個の箱に入れる方法の総数 //(n+k-1)C(k-1)と等しい return commod(n + k - 1, n); } #pragma endregion template <class T = long long> struct edge { T len; int from; int to; bool operator<(const edge a) const { if (len != a.len) return len < a.len; if (from != a.from) return from < a.from; return to < a.to; } bool operator>(const edge a) const { if (len != a.len) return len > a.len; if (from != a.from) return from > a.from; return to > a.to; } }; template <class T = long long> struct graph { // 0-indexed T const INF = numeric_limits<T>::max() / 3; vector<vector<edge<T>>> edges; bool directed, weight; int ver; // constructor graph() = default; graph(int vertex, bool direction = 0, bool weigh = 0) : edges(vertex) { ver = vertex; directed = direction; weight = weigh; edges.resize(vertex); } //辺の追加 (0-indexed) void update(int from, int to, T len = 1, bool direction = 1) { edge<T> e; e.len = len; e.from = from; e.to = to; edges[from].push_back(e); if (!direction) { swap(e.to, e.from); edges[to].push_back(e); } } //入力受取 (1-indexed) void input(int edge_num, int index = 1) { for (int i = 0; i < edge_num; i++) { int a; int b; cin >> a >> b; a -= index; b -= index; T c; if (weight) cin >> c; else c = 1; update(a, b, c, directed); } } // 辺の長さを全て1とみたときの単一始点最短経路 (無理なときはINF) vector<T> bfs(int start) { // https://atcoder.jp/contests/abc007/submissions/me vector<T> ret(ver, INF); queue<int> q; q.push(start); ret[start] = 0; while (!q.empty()) { int now = q.front(); q.pop(); for (auto &e : edges[now]) { if (ret[e.to] != INF) continue; q.push(e.to); ret[e.to] = ret[now] + 1; } } return ret; } //長さが負のpathがないときの単一始点最短経路<vll> O((ver)log(ver)+(edge)) vector<T> dijkstra(int start) { vector<T> ret(ver, (T)INF); // pqup<pair<T, int>> p; // //{dist,place} priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> p; //{dist,place} p.push({0, start}); ret[start] = 0; while (!p.empty()) { T dist = p.top().first; int place = p.top().second; p.pop(); if (ret[place] < dist) continue; for (auto &next : edges[place]) { int nextplace = next.to; T dis = next.len; if (ret[nextplace] > dist + dis) { ret[nextplace] = dist + dis; p.push({ret[nextplace], nextplace}); } } } return ret; } //単一始点最短経路 O((ver)*(edge)) //辿り着けないとき ret[i] = INF; //ある頂点までのコストが無限に小さくなり得るとき→ ret[i] = -INF; vector<T> BellmanFord(int start) { // https://onlinejudge.u-aizu.ac.jp/problems/GRL_1_B vector<T> ret(ver, INF); ret[start] = 0; for (int loop = 0; loop < ver - 1; loop++) { for (int v = 0; v < ver; v++) { if (ret[v] == INF) continue; for (auto &e : edges[v]) { ret[e.to] = min(ret[e.to], ret[v] + e.len); } } } //無限降下点の検索 queue<int> q; vector<bool> chk(ver, 0); for (int v = 0; v < ver; v++) { if (ret[v] == INF) continue; for (auto &e : edges[v]) { if (ret[e.to] > ret[v] + e.len) { ret[e.to] = ret[v] + e.len; if (!chk[e.to]) { q.push(e.to); chk[e.to] = 1; } } } } while (!q.empty()) { int now = q.front(); q.pop(); for (auto &e : edges[now]) { if (!chk[e.to]) { chk[e.to] = 1; q.push(e.to); } } } for (int i = 0; i < ver; i++) if (chk[i]) ret[i] = -INF; return ret; } //閉路に含まれない頂点列挙 //要素数がver未満なら閉路が存在、そうでなければ閉路は存在しない vector<int> topo_sort() { // https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/all/GRL_4_A // https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/all/GRL_4_B assert(directed); vector<int> num_input(ver); // 入次数 for (int i = 0; i < ver; i++) { for (auto e : edges[i]) { num_input[e.to]++; } } // 入次数が0のノードをqueueで管理する queue<int> que; for (int i = 0; i < ver; i++) { if (num_input[i] == 0) { que.push(i); } } vector<int> ans; while (!que.empty()) { auto node = que.front(); que.pop(); ans.push_back(node); // 頂点の削除 for (auto e : edges[node]) { num_input[e.to]--; // 行き先の入次数が0になったらqueueに追加 if (num_input[e.to] == 0) { que.push(e.to); } } } return ans; } //{{端点、端点},直径の大きさ} pair<pair<int, int>, T> DiameterOfTree(bool weigh = true) { // https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/all/GRL_5_A vector<T> vec; vec = weigh ? dijkstra(0) : bfs(0); int v1 = -1; T dia = -1; for (int i = 0; i < ver; i++) if ((dia < vec[i])) { dia = vec[i]; v1 = i; } vec = weigh ? dijkstra(v1) : bfs(v1); dia = -1; int v2 = -1; for (int i = 0; i < ver; i++) if ((dia < vec[i])) { v2 = i; dia = vec[i]; } pair<pair<int, int>, T> ans = {{v1, v2}, dia}; return ans; } //無向木構造を根から葉に伸びる有向木構造に書き換える graph<T> RootToLeaf(int root) { // 0-indexed graph<T> ret(ver, 1, weight); vector<bool> chk(ver, 0); chk[root] = 1; function<void(int)> dfs = [&](int now) { for (auto &e : edges[now]) { if (chk[e.to] == 1) continue; chk[e.to] = 1; ret.update(now, e.to, e.len, 1); dfs(e.to); } }; dfs(root); return ret; } //無向木構造を葉から根に伸びる有向木構造に書き換える graph<T> LeafToRoot(int root) { // 0-indexed graph<T> ret(ver, 1, weight); vector<bool> chk(ver, 0); chk[root] = 1; function<void(int)> dfs = [&](int now) { for (auto &e : edges[now]) { if (chk[e.to] == 1) continue; chk[e.to] = 1; ret.update(e.to, now, e.len, 1); dfs(e.to); } }; dfs(root); ret.update(root, root, 0); return ret; } // LeafToRootのvector版.par[i]=iの親の頂点 vector<int> par(int root) { // 0-indexed vector<int> ret(ver, -1); ret[root] = root; // rootの親はroot function<void(int)> dfs = [&](int now) { for (auto &e : edges[now]) { if (ret[e.to] != -1) continue; ret[e.to] = now; dfs(e.to); } }; dfs(root); return ret; } vector<edge<T>> ParentAndDistance(int root) { // 0-indexed vector<edge<T>> ret(ver); for (int i = 0; i < ver; i++) ret[i].to = -1; ret[root].to = root; // rootの親はroot ret[root].len = 0; // rootの親との距離は0 function<void(int)> dfs = [&](int now) { for (auto &e : edges[now]) { if (ret[e.to].to != -1) continue; ret[e.to].to = now; ret[e.to].len = e.len; dfs(e.to); } }; dfs(root); return ret; } //隣接sheet.主にwarshall用 vector<vector<T>> GraphArray(void) { vector<vector<T>> ret(ver, vector<T>(ver, INF)); for (int from = 0; from < ver; from++) { for (auto &e : edges[from]) { ret[from][e.to] = e.len; } ret[from][from] = 0; } return ret; } graph<T> Prim(int start = 0) { // https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/all/GRL_2_A graph<T> ret(ver, 0, 1); priority_queue<edge<T>, vector<edge<T>>, greater<edge<T>>> p; for (auto &e : edges[start]) { p.push(e); } vector<bool> chk(ver, 0); chk[start] = 1; while (!p.empty()) { auto ed = p.top(); p.pop(); if (chk[ed.to]) continue; chk[ed.to] = 1; ret.update(ed.from, ed.to, ed.len); for (auto &e : edges[ed.to]) { p.push(e); } } return ret; } //各頂点を根としたときの木の高さ vector<T> height(int start = 0) { // https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/all/GRL_5_B vector<T> fir(ver, -1), sec(ver, -1); function<T(int, int)> dfs = [&](int now, int par) { T f = 0, s = 0; // startを根としたときのnowからの深さ1番目、2番目 for (auto &e : edges[now]) { if (e.to == par) continue; s = max(s, dfs(e.to, now) + e.len); if (f < s) swap(f, s); } sec[now] = s; return fir[now] = f; }; dfs(start, -1); function<void(int, int, T, T, T)> sol = [&](int now, int par, T parf, T pars, T parlen) { if (fir[now] + parlen == parf) parf = pars; sec[now] = max(sec[now], parf + parlen); if (fir[now] < sec[now]) swap(fir[now], sec[now]); for (auto &e : edges[now]) { if (e.to == par) continue; sol(e.to, now, fir[now], sec[now], e.len); } return; }; sol(start, -1, -1, -1, -1); return fir; } //全方位木DP //マージ関数、上に送るための関数、単位元、はじめの根 // 関数はstd::functionで渡す template <class U> vector<U> zenhoui(function<U(U, U)> f, function<U(U)> g, U unit, int root = 0) { auto tr = RootToLeaf(root); vector<vector<U>> v(ver); vector<U> ret(ver); //求める答 function<U(int)> dfs = [&](int now) { U res = unit; vector<U> vec; for (auto &e : tr.edges[now]) { U k = dfs(e.to); vec.push_back(k); res = f(res, k); } v[now] = vec; return g(res); }; dfs(root); function<void(int, U)> dfs2 = [&](int now, U ans_par) { int sz = v[now].size(); vector<U> mae(sz + 1), rev(sz + 1); mae[0] = rev[sz] = unit; for (int i = 0; i < sz; i++) mae[i + 1] = f(mae[i], v[now][i]); for (int i = sz - 1; i >= 0; i--) rev[i] = f(rev[i + 1], v[now][i]); for (int i = 0; i < sz; i++) { auto nxtans = f(ans_par, f(mae[i], rev[i + 1])); dfs2(tr.edges[now][i].to, g(nxtans)); } ret[now] = f(ans_par, mae[sz]); return; }; dfs2(root, unit); return ret; } // HL分解 }; struct mint { // auto mod int // https://youtu.be/L8grWxBlIZ4?t=9858 // https://youtu.be/ERZuLAxZffQ?t=4807 : optimize // https://youtu.be/8uowVvQ_-Mo?t=1329 : division ll x; // typedef long long ll; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint operator-() const { return mint(-x); } mint &operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint &operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint &operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { return mint(*this) += a; } mint operator-(const mint a) const { return mint(*this) -= a; } mint operator*(const mint a) const { return mint(*this) *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod - 2); } mint &operator/=(const mint a) { return *this *= a.inv(); } mint operator/(const mint a) const { return mint(*this) /= a; } }; istream &operator>>(istream &is, const mint &a) { return is >> a.x; } ostream &operator<<(ostream &os, const mint &a) { return os << a.x; } mint sol(vll v) { mint res = 1; ll k = v.size(); ll cnt = k; rep(i, k - 1) { if (v[i] != v[i + 1]) { cnt = i + 1; break; } } ll lef = v[0]; ll t, s; t = lef + 1, s = lef + 2; t %= 3, s %= 3; ll h = 0; // tの個数ーsの個数 rRep(i, cnt, k) { if (v[i] == t) { if (h < 0) { res *= -h; } h++; } else { if (h > 0) res *= abs(h); h--; } } rep(i, cnt) res *= i + 1; return res; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); // cout << fixed << setprecision(15); ll n; cin >> n; string s; cin >> s; ll n3 = n * 3; vll t(n3); vll chk(n3); mint ans = 1; vll r, g, b; rep(i, n3) { if (s[i] == 'R') { r.push_back(i); t[i] = 0; } else if (s[i] == 'G') { g.push_back(i); t[i] = 1; } else { b.push_back(i); t[i] = 2; } } vll a, c, d; rep(i, n) { ll u, v, w; u = r[i], v = g[i], w = b[i]; ll x, y, z; x = min({u, v, w}); z = max({u, v, w}); y = u + v + w - x - z; a.push_back(x); c.push_back(y); d.push_back(z); } ll it = 0, ti = 0; // debug(a); // debug(c); // debug(d); rep(i, n) { while (it < n && a[it] < c[i]) it++; while (ti < n && d[ti] < c[i]) ti++; // debug(i); // debug(it); // debug(ti); ans *= (it - i) * (n - (n - i) + 1 - ti); // debug(ans); } rep(i, n) ans *= i + 1; cout << ans << endl; // while(it < n3) { // vector<ll> vec; // // ll a, c, d; // // a = c = d = 0; // vll cnt(3); // ll h = 0; // ll st = t[it]; // bool f = 1; // Rep(j, it, n3) { // if(chk[j]) continue; // if(f) { // if(t[j] == st) // vec.push_back(st), cnt[st]++, chk[j] = 1; // else { // f = false; // h = cnt[st]; // it = n3; // } // } // if(!f) { // ll k = t[j]; // if(cnt[k] < h) // cnt[k]++, vec.push_back(k), chk[j] = 1; // else // chmin(it, j); // } // if(cnt[0] == cnt[1] && cnt[1] == cnt[2]) break; // } // ans *= sol(vec); // debug(ans); // debug(vec); // } // rep(i, n) ans *= i + 1; // cout << ans << endl; }
[ "call.remove" ]
741,965
741,966
u513211419
cpp
p02940
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (n); i++) #define rep1(i, n) for (int i = 1; i <= (n); i++) #define co(x) cout << (x) << "\n" #define cosp(x) cout << (x) << " " #define ce(x) cerr << (x) << "\n" #define cesp(x) cerr << (x) << " " #define pb push_back #define mp make_pair #define Would #define you #define please int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; string S; cin >> S; ll P[100001]; P[0] = 1; ll mod = 998244353; rep1(i, N) P[i] = P[i - 1] * i % mod; ll kotae = P[N]; int flag = 0; int a = 0, b = 0; char ca, cb; rep(i, 3 * N) { switch (flag) { case 0: flag = 1; ca = S[i]; a++; break; case 1: if (S[i] == ca) a++; else { cb = S[i]; kotae = kotae * a % mod; a--; b++; if (a) flag = 2; else flag = 3; } break; case 2: if (S[i] == ca) a++; else if (S[i] == cb) { kotae = kotae * a % mod; a--; b++; if (a == 0) flag = 3; } else { kotae = kotae * b % mod; b--; if (b == 0) flag = 1; } break; case 3: if (S[i] == ca) { a++; flag = 2; } if (S[i] == cb) { a++; cb = ca; ca = S[i]; flag = 2; } else { kotae = kotae * b % mod; b--; if (b == 0) flag = 0; } break; } } co(kotae); Would you please return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (n); i++) #define rep1(i, n) for (int i = 1; i <= (n); i++) #define co(x) cout << (x) << "\n" #define cosp(x) cout << (x) << " " #define ce(x) cerr << (x) << "\n" #define cesp(x) cerr << (x) << " " #define pb push_back #define mp make_pair #define Would #define you #define please int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; string S; cin >> S; ll P[100001]; P[0] = 1; ll mod = 998244353; rep1(i, N) P[i] = P[i - 1] * i % mod; ll kotae = P[N]; int flag = 0; int a = 0, b = 0; char ca, cb; rep(i, 3 * N) { switch (flag) { case 0: flag = 1; ca = S[i]; a++; break; case 1: if (S[i] == ca) a++; else { cb = S[i]; kotae = kotae * a % mod; a--; b++; if (a) flag = 2; else flag = 3; } break; case 2: if (S[i] == ca) a++; else if (S[i] == cb) { kotae = kotae * a % mod; a--; b++; if (a == 0) flag = 3; } else { kotae = kotae * b % mod; b--; if (b == 0) flag = 1; } break; case 3: if (S[i] == ca) { a++; flag = 2; } else if (S[i] == cb) { a++; cb = ca; ca = S[i]; flag = 2; } else { kotae = kotae * b % mod; b--; if (b == 0) flag = 0; } break; } // cesp(S[i]); // ce(flag); // cesp(a); // ce(b); // cesp(ca); // ce(cb); ce(""); } co(kotae); Would you please return 0; }
[ "control_flow.branch.else_if.replace.add", "control_flow.branch.if.replace.remove" ]
741,980
741,981
u096883693
cpp
p02940
#include <bits/stdc++.h> using namespace std; using ll = long long; #ifdef tabr #include "library/debug.cpp" #else #define debug(...) #endif template <ll mod> struct modular { ll value; modular(ll x = 0) { value = x % mod; if (value < 0) value += mod; } modular &operator+=(modular other) { if ((value += other.value) >= mod) value -= mod; return *this; } modular &operator-=(modular other) { if ((value -= other.value) < 0) value += mod; return *this; } modular &operator*=(modular other) { value = value * other.value % mod; return *this; } modular &operator/=(modular other) { ll a = 0, b = 1, c = other.value, m = mod; while (c != 0) { ll t = m / c; m -= t * c; swap(c, m); a -= t * b; swap(a, b); } a %= mod; if (a < 0) a += mod; value = value * a % mod; return *this; } modular &operator^=(modular other) { ll r = 1, x = value, n = other.value; while (n > 0) { if (n & 1) r = r * x % mod; x = x * x % mod; n >>= 1; } value = r; return *this; } modular operator+(modular rhs) { return modular(*this) += rhs; } modular operator-(modular rhs) { return modular(*this) -= rhs; } modular operator*(modular rhs) { return modular(*this) *= rhs; } modular operator/(modular rhs) { return modular(*this) /= rhs; } modular operator^(modular rhs) { return modular(*this) ^= rhs; } bool operator==(modular rhs) { return value == rhs.value; }; bool operator!=(modular rhs) { return value != rhs.value; }; bool operator<(modular rhs) { return value < rhs.value; } }; template <ll mod> string to_string(modular<mod> x) { return to_string(x.value); } template <ll mod> ostream &operator<<(ostream &stream, modular<mod> x) { x.value %= mod; if (x.value < 0) x.value += mod; return stream << x.value; } template <ll mod> istream &operator>>(istream &stream, modular<mod> &x) { stream >> x.value; x.value %= mod; if (x.value < 0) x.value += mod; return stream; } const ll mod = 998244353; using mint = modular<mod>; vector<mint> fac, finv; inline void cinit(int n) { fac.resize(n, 1); finv.resize(n, 1); for (int i = 2; i < n; i++) { fac[i] = fac[i - 1] * i; finv[i] = finv[i - 1] / i; } } inline mint C(int n, int k) { if (n < k || k < 0 || n < 0) return 0; return fac[n] * finv[k] * finv[n - k]; } inline mint H(int n, int k) { return C(n + k - 1, k); } int main() { ios::sync_with_stdio(false); cin.tie(0); int n; string s; cin >> n >> s; vector<vector<int>> a(3); // r, g, b for (int i = 0; i < 3 * n; i++) { int t = (s[i] == 'R' ? 0 : (s[i] == 'G' ? 1 : 2)); a[t].emplace_back(i); } vector<vector<pair<int, int>>> z(6); for (int i = 0; i < n; i++) { vector<int> tmp = {a[0][i], a[1][i], a[2][i]}; sort(tmp.begin(), tmp.end()); int t = (tmp[0] == a[0][i] ? 0 : (tmp[0] == a[1][i] ? 1 : 2)); z[t].emplace_back(tmp[0], 1); z[t].emplace_back(tmp[1], -1); t = (tmp[1] == a[0][i] ? 0 : (tmp[1] == a[1][i] ? 1 : 2)); t += 3; z[t].emplace_back(tmp[1], 1); z[t].emplace_back(tmp[2], -1); } mint ans = 1; for (int i = 0; i < 6; i++) { sort(z[i].begin(), z[i].end()); int cnt = 0; for (auto p : z[i]) { if (p.second == 1) { cnt++; } else { ans *= cnt; cnt--; } } } for (int i = 1; i <= n; i++) { ans *= i; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; #ifdef tabr #include "library/debug.cpp" #else #define debug(...) #endif template <ll mod> struct modular { ll value; modular(ll x = 0) { value = x % mod; if (value < 0) value += mod; } modular &operator+=(modular other) { if ((value += other.value) >= mod) value -= mod; return *this; } modular &operator-=(modular other) { if ((value -= other.value) < 0) value += mod; return *this; } modular &operator*=(modular other) { value = value * other.value % mod; return *this; } modular &operator/=(modular other) { ll a = 0, b = 1, c = other.value, m = mod; while (c != 0) { ll t = m / c; m -= t * c; swap(c, m); a -= t * b; swap(a, b); } a %= mod; if (a < 0) a += mod; value = value * a % mod; return *this; } modular &operator^=(modular other) { ll r = 1, x = value, n = other.value; while (n > 0) { if (n & 1) r = r * x % mod; x = x * x % mod; n >>= 1; } value = r; return *this; } modular operator+(modular rhs) { return modular(*this) += rhs; } modular operator-(modular rhs) { return modular(*this) -= rhs; } modular operator*(modular rhs) { return modular(*this) *= rhs; } modular operator/(modular rhs) { return modular(*this) /= rhs; } modular operator^(modular rhs) { return modular(*this) ^= rhs; } bool operator==(modular rhs) { return value == rhs.value; }; bool operator!=(modular rhs) { return value != rhs.value; }; bool operator<(modular rhs) { return value < rhs.value; } }; template <ll mod> string to_string(modular<mod> x) { return to_string(x.value); } template <ll mod> ostream &operator<<(ostream &stream, modular<mod> x) { x.value %= mod; if (x.value < 0) x.value += mod; return stream << x.value; } template <ll mod> istream &operator>>(istream &stream, modular<mod> &x) { stream >> x.value; x.value %= mod; if (x.value < 0) x.value += mod; return stream; } const ll mod = 998244353; using mint = modular<mod>; vector<mint> fac, finv; inline void cinit(int n) { fac.resize(n, 1); finv.resize(n, 1); for (int i = 2; i < n; i++) { fac[i] = fac[i - 1] * i; finv[i] = finv[i - 1] / i; } } inline mint C(int n, int k) { if (n < k || k < 0 || n < 0) return 0; return fac[n] * finv[k] * finv[n - k]; } inline mint H(int n, int k) { return C(n + k - 1, k); } int main() { ios::sync_with_stdio(false); cin.tie(0); int n; string s; cin >> n >> s; vector<vector<int>> a(3); // r, g, b for (int i = 0; i < 3 * n; i++) { int t = (s[i] == 'R' ? 0 : (s[i] == 'G' ? 1 : 2)); a[t].emplace_back(i); } vector<vector<pair<int, int>>> z(6); for (int i = 0; i < n; i++) { vector<int> tmp = {a[0][i], a[1][i], a[2][i]}; sort(tmp.begin(), tmp.end()); int t = (tmp[0] == a[0][i] ? 0 : (tmp[0] == a[1][i] ? 1 : 2)); z[t].emplace_back(tmp[0], 1); z[t].emplace_back(tmp[1], -1); t = (tmp[2] == a[0][i] ? 0 : (tmp[2] == a[1][i] ? 1 : 2)); t += 3; z[t].emplace_back(tmp[1], 1); z[t].emplace_back(tmp[2], -1); } mint ans = 1; for (int i = 0; i < 6; i++) { sort(z[i].begin(), z[i].end()); int cnt = 0; for (auto p : z[i]) { if (p.second == 1) { cnt++; } else { ans *= cnt; cnt--; } } } for (int i = 1; i <= n; i++) { ans *= i; } cout << ans << endl; return 0; }
[ "literal.number.change", "assignment.value.change", "variable_access.subscript.index.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
742,001
742,002
u604231488
cpp
p02940
//#pragma comment(linker, "/stack:200000000") //#pragma GCC optimize("Ofast") //#pragma GCC //target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") #pragme //GCC target("avx2"); #pragma GCC target("avx,avx2,fma") #pragma GCC //optimization ("O3") #pragma GCC optimization ("unroll-loops") //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> //#define int long long #include <bits/stdc++.h> #define ll long long #define ld long double #define pb push_back #define f first #define se second #define pll pair<ll, ll> #define pii pair<int, int> using namespace std; // using namespace __gnu_pbds; /* st.insert(k); st.find_by_order(k); iterator on k-th from 0 st.order_of_key(k); strictly more than k */ // typedef // tree< // ll, // null_type, // less_equal<ll>, // rb_tree_tag, // tree_order_statistics_node_update> // ordered_set; const int N = 4e5 + 19; const int M = 2e6 + 19; const ll mod = 998244353; const int inf = 2e9; const int blocksz = 300; const ll INF = 1e18; inline int modulo(int x) { x %= mod; return (x + mod) % mod; } inline ll mult(ll x, ll y) { ll x1 = modulo(x), y1 = modulo(y); return (x1 * y1) % mod; } inline void add(int &x, int y) { x = modulo(x + y); } inline void Max(int &x, int y) { x = max(x, y); } inline void Min(int &x, int y) { x = min(x, y); } ll n; string s; // int pw(int x, int y) { // if (y == 0) // return 1; // int res; // if (y % 2) { // res = pw(x, y - 1); // return mult(res, x); // } else { // res = pw(x, y / 2); // return mult(res, res); // } //} // // // int C(int n, int k) { // if (n > k) // return 0; // int t1, t2, t3; // t1 = fact[n]; // t2 = pw(fact[k], mod - 2); // t3 = pw(fact[n - k], mod - 2); // return mult(t1, mult(t2, t3)); //} main() { ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL); // freopen("input.txt", "r", stdin); ll R, G, B, RG, RB, GB, ost, ans = 1; R = G = B = RG = RB = GB = 0; cin >> n; cin >> s; ost = n; for (int i = 0; i < s.size(); i++) { if (s[i] == 'R') { if (GB) { ans = mult(ans, GB); GB--; } else if (B) { ans = mult(ans, B); B--; RB++; } else if (G) { ans = mult(ans, G); G--; RG++; } else { ans = mult(ans, ost); R++; ost--; } } else if (s[i] == 'G') { if (RB) { ans = mult(ans, RB); RB--; } else if (R) { ans = mult(ans, R); R--; RG++; } else if (B) { ans = mult(ans, B); B--; GB++; } else { ans = mult(ans, ost); G++; ost--; } } else { if (RG) { ans = mult(ans, RG); RG--; } else if (R) { ans = mult(ans, R); R--; RB++; } else if (G) { ans = mult(ans, G); G--; RB++; } else { ans = mult(ans, ost); B++; ost--; } } } cout << ans; return 0; } /* 3 5 1 3 2 1 3 10 5 7 3 4 2 4 1 3 1 3 5 2 */
//#pragma comment(linker, "/stack:200000000") //#pragma GCC optimize("Ofast") //#pragma GCC //target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") #pragme //GCC target("avx2"); #pragma GCC target("avx,avx2,fma") #pragma GCC //optimization ("O3") #pragma GCC optimization ("unroll-loops") //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> //#define int long long #include <bits/stdc++.h> #define ll long long #define ld long double #define pb push_back #define f first #define se second #define pll pair<ll, ll> #define pii pair<int, int> using namespace std; // using namespace __gnu_pbds; /* st.insert(k); st.find_by_order(k); iterator on k-th from 0 st.order_of_key(k); strictly more than k */ // typedef // tree< // ll, // null_type, // less_equal<ll>, // rb_tree_tag, // tree_order_statistics_node_update> // ordered_set; const int N = 4e5 + 19; const int M = 2e6 + 19; const ll mod = 998244353; const int inf = 2e9; const int blocksz = 300; const ll INF = 1e18; inline int modulo(int x) { x %= mod; return (x + mod) % mod; } inline ll mult(ll x, ll y) { ll x1 = modulo(x), y1 = modulo(y); return (x1 * y1) % mod; } inline void add(int &x, int y) { x = modulo(x + y); } inline void Max(int &x, int y) { x = max(x, y); } inline void Min(int &x, int y) { x = min(x, y); } ll n; string s; // int pw(int x, int y) { // if (y == 0) // return 1; // int res; // if (y % 2) { // res = pw(x, y - 1); // return mult(res, x); // } else { // res = pw(x, y / 2); // return mult(res, res); // } //} // // // int C(int n, int k) { // if (n > k) // return 0; // int t1, t2, t3; // t1 = fact[n]; // t2 = pw(fact[k], mod - 2); // t3 = pw(fact[n - k], mod - 2); // return mult(t1, mult(t2, t3)); //} main() { ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL); // freopen("input.txt", "r", stdin); ll R, G, B, RG, RB, GB, ost, ans = 1; R = G = B = RG = RB = GB = 0; cin >> n; cin >> s; ost = n; for (int i = 0; i < s.size(); i++) { if (s[i] == 'R') { if (GB) { ans = mult(ans, GB); GB--; } else if (B) { ans = mult(ans, B); B--; RB++; } else if (G) { ans = mult(ans, G); G--; RG++; } else { ans = mult(ans, ost); R++; ost--; } } else if (s[i] == 'G') { if (RB) { ans = mult(ans, RB); RB--; } else if (R) { ans = mult(ans, R); R--; RG++; } else if (B) { ans = mult(ans, B); B--; GB++; } else { ans = mult(ans, ost); G++; ost--; } } else { if (RG) { ans = mult(ans, RG); RG--; } else if (R) { ans = mult(ans, R); R--; RB++; } else if (G) { ans = mult(ans, G); G--; GB++; } else { ans = mult(ans, ost); B++; ost--; } } } cout << ans; return 0; } /* 3 5 1 3 2 1 3 10 5 7 3 4 2 4 1 3 1 3 5 2 */
[ "identifier.change" ]
742,005
742,006
u892889246
cpp
p02940
#include <algorithm> #include <assert.h> #include <bitset> #include <complex> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define REP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i) #define rep(i, n) REP(i, 0, n) using ll = long long; const int inf = 1e9 + 7; const ll longinf = 1LL << 60; const ll mod = 1e9 + 7; const ll MOD = 998244353; int main() { int N; cin >> N; string S; cin >> S; int cnt[6] = {}; ll ans = 1; rep(i, 3 * N) { if (S[i] == 'B') { if (cnt[5]) { ans *= cnt[5]; ans %= MOD; cnt[5]--; } else if (cnt[1]) { ans *= cnt[1]; ans %= MOD; cnt[1]--; cnt[3]++; } else if (cnt[2]) { ans *= cnt[2]; ans %= MOD; cnt[2]--; cnt[4]++; } else cnt[0]++; } else if (S[i] == 'G') { if (cnt[3]) { ans *= cnt[3]; ans %= MOD; cnt[3]--; } else if (cnt[0]) { ans *= cnt[0]; ans %= MOD; cnt[0]--; cnt[4]++; } else if (cnt[1]) { ans *= cnt[1]; ans %= MOD; cnt[1]--; cnt[5]++; } else cnt[2]++; } else if (S[i] == 'R') { if (cnt[4]) { ans *= cnt[4]; ans %= MOD; cnt[4]--; } else if (cnt[0]) { ans *= cnt[0]; ans %= MOD; cnt[0]--; cnt[3]++; } else if (cnt[2]) { ans *= cnt[5]; ans %= MOD; cnt[2]--; cnt[5]++; } else cnt[1]++; } } rep(i, N) { ans *= (i + 1); ans %= MOD; } cout << ans << endl; }
#include <algorithm> #include <assert.h> #include <bitset> #include <complex> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define REP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i) #define rep(i, n) REP(i, 0, n) using ll = long long; const int inf = 1e9 + 7; const ll longinf = 1LL << 60; const ll mod = 1e9 + 7; const ll MOD = 998244353; int main() { int N; cin >> N; string S; cin >> S; int cnt[6] = {}; ll ans = 1; rep(i, 3 * N) { if (S[i] == 'B') { if (cnt[5]) { ans *= cnt[5]; ans %= MOD; cnt[5]--; } else if (cnt[1]) { ans *= cnt[1]; ans %= MOD; cnt[1]--; cnt[3]++; } else if (cnt[2]) { ans *= cnt[2]; ans %= MOD; cnt[2]--; cnt[4]++; } else cnt[0]++; } else if (S[i] == 'G') { if (cnt[3]) { ans *= cnt[3]; ans %= MOD; cnt[3]--; } else if (cnt[0]) { ans *= cnt[0]; ans %= MOD; cnt[0]--; cnt[4]++; } else if (cnt[1]) { ans *= cnt[1]; ans %= MOD; cnt[1]--; cnt[5]++; } else cnt[2]++; } else if (S[i] == 'R') { if (cnt[4]) { ans *= cnt[4]; ans %= MOD; cnt[4]--; } else if (cnt[0]) { ans *= cnt[0]; ans %= MOD; cnt[0]--; cnt[3]++; } else if (cnt[2]) { ans *= cnt[2]; ans %= MOD; cnt[2]--; cnt[5]++; } else cnt[1]++; } } rep(i, N) { ans *= (i + 1); ans %= MOD; } cout << ans << endl; }
[ "literal.number.change", "assignment.value.change", "variable_access.subscript.index.change" ]
742,007
742,008
u841131859
cpp
p02940
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll MOD = 998244353; int main() { int n; cin >> n; string s; cin >> s; ll res = 1; int rcnt = 0; int bcnt = 0; int gcnt = 0; for (int i = 0; i < s.size(); i++) { char ch = s[i]; // check the different possible orders if (ch == 'R') { // if green and blue are both more common if ((gcnt <= rcnt) && (bcnt <= rcnt)) { res *= (n - rcnt); } if ((gcnt > rcnt) && (bcnt <= rcnt)) { res *= (gcnt - rcnt); } if ((gcnt <= rcnt) && (bcnt > rcnt)) { res *= (bcnt - rcnt); } if ((gcnt > rcnt) && (bcnt > rcnt)) { res *= (min(gcnt, bcnt) - rcnt); } } if (ch == 'G') { if ((rcnt <= gcnt) && (bcnt <= gcnt)) { res *= (n - gcnt); } if ((rcnt > gcnt) && (bcnt <= gcnt)) { res *= (rcnt - gcnt); } if ((rcnt <= gcnt) && (bcnt > gcnt)) { res *= (bcnt - gcnt); } if ((rcnt > gcnt) && (bcnt > gcnt)) { res *= (min(bcnt, rcnt) - gcnt); } } if (ch == 'B') { if ((gcnt <= bcnt) && (rcnt <= bcnt)) { res *= (n - bcnt); } if ((gcnt > bcnt) && (rcnt <= bcnt)) { res *= (gcnt - bcnt); } if ((gcnt <= bcnt) && (rcnt > bcnt)) { res *= (bcnt - gcnt); } if ((gcnt > bcnt) && (rcnt > bcnt)) { res *= (min(rcnt, gcnt) - bcnt); } } res %= MOD; if (ch == 'R') rcnt++; if (ch == 'B') bcnt++; if (ch == 'G') gcnt++; } cout << res << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll MOD = 998244353; int main() { int n; cin >> n; string s; cin >> s; ll res = 1; int rcnt = 0; int bcnt = 0; int gcnt = 0; for (int i = 0; i < s.size(); i++) { char ch = s[i]; // check the different possible orders if (ch == 'R') { // if green and blue are both more common if ((gcnt <= rcnt) && (bcnt <= rcnt)) { res *= (n - rcnt); } if ((gcnt > rcnt) && (bcnt <= rcnt)) { res *= (gcnt - rcnt); } if ((gcnt <= rcnt) && (bcnt > rcnt)) { res *= (bcnt - rcnt); } if ((gcnt > rcnt) && (bcnt > rcnt)) { res *= (min(gcnt, bcnt) - rcnt); } } if (ch == 'G') { if ((rcnt <= gcnt) && (bcnt <= gcnt)) { res *= (n - gcnt); } if ((rcnt > gcnt) && (bcnt <= gcnt)) { res *= (rcnt - gcnt); } if ((rcnt <= gcnt) && (bcnt > gcnt)) { res *= (bcnt - gcnt); } if ((rcnt > gcnt) && (bcnt > gcnt)) { res *= (min(bcnt, rcnt) - gcnt); } } if (ch == 'B') { if ((gcnt <= bcnt) && (rcnt <= bcnt)) { res *= (n - bcnt); } if ((gcnt > bcnt) && (rcnt <= bcnt)) { res *= (gcnt - bcnt); } if ((gcnt <= bcnt) && (rcnt > bcnt)) { res *= (rcnt - bcnt); } if ((gcnt > bcnt) && (rcnt > bcnt)) { res *= (min(rcnt, gcnt) - bcnt); } } res %= MOD; if (ch == 'R') rcnt++; if (ch == 'B') bcnt++; if (ch == 'G') gcnt++; } cout << res << endl; }
[ "assignment.value.change", "identifier.change", "expression.operation.binary.change" ]
742,021
742,022
u118325325
cpp
p02940
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; #define REP(i, n) for (long long i = 0; i < (n); i++) #define FOR(i, m, n) for (long long i = (m); i < (n); ++i) #define ALL(obj) (obj).begin(), (obj).end() #define SPEED \ cin.tie(0); \ ios::sync_with_stdio(false); template <class T> using V = vector<T>; template <class T, class U> using P = pair<T, U>; template <class T> using PQ = priority_queue<T>; template <class T> using PQR = priority_queue<T, vector<T>, greater<T>>; constexpr long long MOD = (long long)1e9 + 7; constexpr long long MOD2 = 998244353; constexpr long long HIGHINF = (long long)1e18; constexpr long long LOWINF = (long long)1e15; constexpr long double PI = 3.1415926535897932384626433; template <class T> vector<T> multivector(size_t N, T init) { return vector<T>(N, init); } template <class... T> auto multivector(size_t N, T... t) { return vector<decltype(multivector(t...))>(N, multivector(t...)); } template <class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } } template <class T, class U> ostream &operator<<(ostream &o, const map<T, U> &obj) { o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o; } template <class T> ostream &operator<<(ostream &o, const set<T> &obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; } template <class T> ostream &operator<<(ostream &o, const multiset<T> &obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; } template <class T> ostream &operator<<(ostream &o, const vector<T> &obj) { o << "{"; for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o; } template <class T, class U> ostream &operator<<(ostream &o, const pair<T, U> &obj) { o << "{" << obj.first << ", " << obj.second << "}"; return o; } template <template <class tmp> class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; } void print(void) { cout << endl; } template <class Head> void print(Head &&head) { cout << head; print(); } template <class Head, class... Tail> void print(Head &&head, Tail &&...tail) { cout << head << " "; print(forward<Tail>(tail)...); } template <class T> inline void chmax(T &a, const T b) { a = max(a, b); } template <class T> inline void chmin(T &a, const T b) { a = min(a, b); } void YN(bool flg) { cout << (flg ? "YES" : "NO") << endl; } void Yn(bool flg) { cout << (flg ? "Yes" : "No") << endl; } void yn(bool flg) { cout << (flg ? "yes" : "no") << endl; } int main() { int N; cin >> N; string S; cin >> S; ll M = N, r = 0, g = 0, b = 0, rg = 0, gb = 0, br = 0, ans = 1; for (int i = 0; i < 3 * N; ++i) { if (S[i] == 'R') { if (gb) { (ans *= gb) %= MOD2; gb--; } else if (b) { (ans *= b) %= MOD2; b--; br++; } else if (g) { (ans *= g) %= MOD2; g--; rg++; } else { (ans *= M) %= MOD2; M--; r++; } } if (S[i] == 'G') { if (br) { (ans *= br) %= MOD2; br--; } else if (r) { (ans *= r) %= MOD2; r--; rg++; } else if (b) { (ans *= b) %= MOD2; b--; gb++; } else { (ans *= M) %= MOD2; M--; g++; } } if (S[i] == 'B') { if (rg) { (ans *= rg) %= MOD2; rg--; } else if (r) { (ans *= r) %= MOD2; r--; br++; } else if (g) { (ans *= g) %= MOD2; b--; gb++; } else { (ans *= M) %= MOD2; M--; b++; } } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; #define REP(i, n) for (long long i = 0; i < (n); i++) #define FOR(i, m, n) for (long long i = (m); i < (n); ++i) #define ALL(obj) (obj).begin(), (obj).end() #define SPEED \ cin.tie(0); \ ios::sync_with_stdio(false); template <class T> using V = vector<T>; template <class T, class U> using P = pair<T, U>; template <class T> using PQ = priority_queue<T>; template <class T> using PQR = priority_queue<T, vector<T>, greater<T>>; constexpr long long MOD = (long long)1e9 + 7; constexpr long long MOD2 = 998244353; constexpr long long HIGHINF = (long long)1e18; constexpr long long LOWINF = (long long)1e15; constexpr long double PI = 3.1415926535897932384626433; template <class T> vector<T> multivector(size_t N, T init) { return vector<T>(N, init); } template <class... T> auto multivector(size_t N, T... t) { return vector<decltype(multivector(t...))>(N, multivector(t...)); } template <class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } } template <class T, class U> ostream &operator<<(ostream &o, const map<T, U> &obj) { o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o; } template <class T> ostream &operator<<(ostream &o, const set<T> &obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; } template <class T> ostream &operator<<(ostream &o, const multiset<T> &obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; } template <class T> ostream &operator<<(ostream &o, const vector<T> &obj) { o << "{"; for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o; } template <class T, class U> ostream &operator<<(ostream &o, const pair<T, U> &obj) { o << "{" << obj.first << ", " << obj.second << "}"; return o; } template <template <class tmp> class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; } void print(void) { cout << endl; } template <class Head> void print(Head &&head) { cout << head; print(); } template <class Head, class... Tail> void print(Head &&head, Tail &&...tail) { cout << head << " "; print(forward<Tail>(tail)...); } template <class T> inline void chmax(T &a, const T b) { a = max(a, b); } template <class T> inline void chmin(T &a, const T b) { a = min(a, b); } void YN(bool flg) { cout << (flg ? "YES" : "NO") << endl; } void Yn(bool flg) { cout << (flg ? "Yes" : "No") << endl; } void yn(bool flg) { cout << (flg ? "yes" : "no") << endl; } int main() { int N; cin >> N; string S; cin >> S; ll M = N, r = 0, g = 0, b = 0, rg = 0, gb = 0, br = 0, ans = 1; for (int i = 0; i < 3 * N; ++i) { if (S[i] == 'R') { if (gb) { (ans *= gb) %= MOD2; gb--; } else if (b) { (ans *= b) %= MOD2; b--; br++; } else if (g) { (ans *= g) %= MOD2; g--; rg++; } else { (ans *= M) %= MOD2; M--; r++; } } if (S[i] == 'G') { if (br) { (ans *= br) %= MOD2; br--; } else if (r) { (ans *= r) %= MOD2; r--; rg++; } else if (b) { (ans *= b) %= MOD2; b--; gb++; } else { (ans *= M) %= MOD2; M--; g++; } } if (S[i] == 'B') { if (rg) { (ans *= rg) %= MOD2; rg--; } else if (r) { (ans *= r) %= MOD2; r--; br++; } else if (g) { (ans *= g) %= MOD2; g--; gb++; } else { (ans *= M) %= MOD2; M--; b++; } } } cout << ans << endl; }
[ "identifier.change" ]
742,023
742,024
u898651494
cpp
p02940
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; #define pb push_back #define mp make_pair #define ff first #define ss second #define gsort(x) sort(x, x + n, greater<ll>()); #define sync \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) #define sync2 cout << fixed << setprecision(10) const ll inf = 1e9 + 7; #define pi 3.14159265358979323846 #define REP(i, j, n) for (int i = (int)j; i <= (int)n; i++) #define REPD(i, n, j) for (int i = (int)n; i >= (int)j; i--) #define all(vv) vv.begin(), vv.end() // priority_queue <int, vector<int>, greater<int>> mnheap; ll arr[8]; const ll MOD = 998244353; int main() { sync; int n; cin >> n; string st; cin >> st; ll ans = 1; int i = 0; int bit; arr[0] = n; while (i < 3 * n) { if (st[i] == 'R') { bit = 1; } if (st[i] == 'G') { bit = 2; } if (st[i] == 'B') { bit = 4; } for (int j = 7; j >= 0; j--) { if (bit & j) continue; if (arr[j]) { ans = (ans * arr[j]) % MOD; arr[j]--; arr[j | bit]++; } } i++; } cout << ans << endl; } /* 3 RRRGGGBBB */
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; #define pb push_back #define mp make_pair #define ff first #define ss second #define gsort(x) sort(x, x + n, greater<ll>()); #define sync \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) #define sync2 cout << fixed << setprecision(10) const ll inf = 1e9 + 7; #define pi 3.14159265358979323846 #define REP(i, j, n) for (int i = (int)j; i <= (int)n; i++) #define REPD(i, n, j) for (int i = (int)n; i >= (int)j; i--) #define all(vv) vv.begin(), vv.end() // priority_queue <int, vector<int>, greater<int>> mnheap; ll arr[8]; const ll MOD = 998244353; int main() { sync; int n; cin >> n; string st; cin >> st; ll ans = 1; int i = 0; int bit; arr[0] = n; while (i < 3 * n) { if (st[i] == 'R') { bit = 1; } if (st[i] == 'G') { bit = 2; } if (st[i] == 'B') { bit = 4; } for (int j = 7; j >= 0; j--) { if (bit & j) continue; if (arr[j]) { ans = (ans * arr[j]) % MOD; arr[j]--; arr[j | bit]++; break; } } i++; } cout << ans << endl; } /* 3 RRRGGGBBB */
[ "control_flow.break.add" ]
742,031
742,032
u808256772
cpp
p02940
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; #define pb push_back #define mp make_pair #define ff first #define ss second #define gsort(x) sort(x, x + n, greater<ll>()); #define sync \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) #define sync2 cout << fixed << setprecision(10) const ll inf = 1e9 + 7; #define pi 3.14159265358979323846 #define REP(i, j, n) for (int i = (int)j; i <= (int)n; i++) #define REPD(i, n, j) for (int i = (int)n; i >= (int)j; i--) #define all(vv) vv.begin(), vv.end() // priority_queue <int, vector<int>, greater<int>> mnheap; ll arr[8]; const ll MOD = 998244353; int main() { sync; int n; cin >> n; string st; cin >> st; int ans = 1; int i = 0; int bit; arr[0] = n; while (i < 3 * n) { if (st[i] == 'R') { bit = 1; } if (st[i] == 'G') { bit = 2; } if (st[i] == 'B') { bit = 4; } for (int j = 7; j >= 0; j--) { if (bit & j) continue; if (arr[j]) { ans = (ans * arr[j]) % MOD; arr[j]--; arr[j | bit]++; } } i++; } cout << ans << endl; } /* 3 RRRGGGBBB */
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; #define pb push_back #define mp make_pair #define ff first #define ss second #define gsort(x) sort(x, x + n, greater<ll>()); #define sync \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) #define sync2 cout << fixed << setprecision(10) const ll inf = 1e9 + 7; #define pi 3.14159265358979323846 #define REP(i, j, n) for (int i = (int)j; i <= (int)n; i++) #define REPD(i, n, j) for (int i = (int)n; i >= (int)j; i--) #define all(vv) vv.begin(), vv.end() // priority_queue <int, vector<int>, greater<int>> mnheap; ll arr[8]; const ll MOD = 998244353; int main() { sync; int n; cin >> n; string st; cin >> st; ll ans = 1; int i = 0; int bit; arr[0] = n; while (i < 3 * n) { if (st[i] == 'R') { bit = 1; } if (st[i] == 'G') { bit = 2; } if (st[i] == 'B') { bit = 4; } for (int j = 7; j >= 0; j--) { if (bit & j) continue; if (arr[j]) { ans = (ans * arr[j]) % MOD; arr[j]--; arr[j | bit]++; break; } } i++; } cout << ans << endl; } /* 3 RRRGGGBBB */
[ "variable_declaration.type.change" ]
742,033
742,032
u808256772
cpp
p02940
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define all(x) (x).begin(), (x).end() const int mod = 998244353, MAX = 100003, INF = 1 << 30; int main() { int N; cin >> N; string S; cin >> S; ll mu = N, B = 0, R = 0, G = 0, BR = 0, RG = 0, GB = 0; ll ans = 1; for (int i = 0; i < 3 * N; i++) { if (S[i] == 'B') { if (RG) { ans *= RG; RG--; } else if (G) { ans *= G; G--; GB++; } else if (R) { ans *= G; R--; BR++; } else { ans *= mu; mu--; B++; } } if (S[i] == 'R') { if (GB) { ans *= GB; GB--; } else if (G) { ans *= G; G--; RG++; } else if (B) { ans *= B; B--; BR++; } else { ans *= mu; mu--; R++; } } if (S[i] == 'G') { if (BR) { ans *= BR; BR--; } else if (B) { ans *= B; B--; GB++; } else if (R) { ans *= R; R--; RG++; } else { ans *= mu; mu--; G++; } } ans %= mod; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define all(x) (x).begin(), (x).end() const int mod = 998244353, MAX = 100003, INF = 1 << 30; int main() { int N; cin >> N; string S; cin >> S; ll mu = N, B = 0, R = 0, G = 0, BR = 0, RG = 0, GB = 0; ll ans = 1; for (int i = 0; i < 3 * N; i++) { if (S[i] == 'B') { if (RG) { ans *= RG; RG--; } else if (G) { ans *= G; G--; GB++; } else if (R) { ans *= R; R--; BR++; } else { ans *= mu; mu--; B++; } } if (S[i] == 'R') { if (GB) { ans *= GB; GB--; } else if (G) { ans *= G; G--; RG++; } else if (B) { ans *= B; B--; BR++; } else { ans *= mu; mu--; R++; } } if (S[i] == 'G') { if (BR) { ans *= BR; BR--; } else if (B) { ans *= B; B--; GB++; } else if (R) { ans *= R; R--; RG++; } else { ans *= mu; mu--; G++; } } ans %= mod; } cout << ans << endl; }
[ "assignment.value.change", "identifier.change" ]
741,812
741,813
u133391510
cpp
p02940
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define all(x) (x).begin(), (x).end() const int mod = 998244353, MAX = 100003, INF = 1 << 30; int main() { int N; cin >> N; string S; cin >> S; int mu = N, B = 0, R = 0, G = 0, BR = 0, RG = 0, GB = 0; ll ans = 1; for (int i = 0; i < 3 * N; i++) { if (S[i] == 'B') { if (RG) { ans *= RG; RG--; } else if (G) { ans *= G; G--; GB++; } else if (R) { ans *= G; R--; BR++; } else { ans *= mu; mu--; B++; } } if (S[i] == 'R') { if (GB) { ans *= GB; GB--; } else if (G) { ans *= G; G--; RG++; } else if (B) { ans *= B; B--; BR++; } else { ans *= mu; mu--; R++; } } if (S[i] == 'G') { if (BR) { ans *= BR; BR--; } else if (B) { ans *= B; B--; GB++; } else if (R) { ans *= R; R--; RG++; } else { ans *= mu; mu--; G++; } } ans %= mod; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define all(x) (x).begin(), (x).end() const int mod = 998244353, MAX = 100003, INF = 1 << 30; int main() { int N; cin >> N; string S; cin >> S; ll mu = N, B = 0, R = 0, G = 0, BR = 0, RG = 0, GB = 0; ll ans = 1; for (int i = 0; i < 3 * N; i++) { if (S[i] == 'B') { if (RG) { ans *= RG; RG--; } else if (G) { ans *= G; G--; GB++; } else if (R) { ans *= R; R--; BR++; } else { ans *= mu; mu--; B++; } } if (S[i] == 'R') { if (GB) { ans *= GB; GB--; } else if (G) { ans *= G; G--; RG++; } else if (B) { ans *= B; B--; BR++; } else { ans *= mu; mu--; R++; } } if (S[i] == 'G') { if (BR) { ans *= BR; BR--; } else if (B) { ans *= B; B--; GB++; } else if (R) { ans *= R; R--; RG++; } else { ans *= mu; mu--; G++; } } ans %= mod; } cout << ans << endl; }
[ "variable_declaration.type.change", "assignment.value.change", "identifier.change" ]
741,814
741,813
u133391510
cpp
p02940
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> using namespace std; const int N = 100005, mod = 998244353; int n, ans = 1, RG, GB, RB, R, G, B; char s[N * 3]; int main() { scanf("%d%s", &n, s + 1); for (int i = 1; i <= n * 3; i++) { if (s[i] == 'R') { if (GB) { ans = 1LL * ans * GB % mod; GB--; } else if (G) { ans = 1LL * ans * G % mod; G--; RG++; } else if (B) { ans = 1LL * ans * B % mod; B--; RB++; } else { R++; } } else if (s[i] == 'G') { if (RB) { ans = 1LL * ans * RB % mod; RB--; } else if (R) { ans = 1LL * ans * R % mod; R--; RG++; } else if (B) { ans = 1LL * ans * B % mod; B--; GB++; } else { G++; } } else { if (RG) { ans = 1LL * ans * RG % mod; RG--; } else if (R) { ans = 1LL * ans * R % mod; R--; RB++; } else if (G) { ans = 1LL * ans * G % mod; GB++; } else { B++; } } } while (n) { ans = 1LL * ans * n % mod; n--; } printf("%d\n", ans); return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> using namespace std; const int N = 100005, mod = 998244353; int n, ans = 1, RG, GB, RB, R, G, B; char s[N * 3]; int main() { scanf("%d%s", &n, s + 1); for (int i = 1; i <= n * 3; i++) { if (s[i] == 'R') { if (GB) { ans = 1LL * ans * GB % mod; GB--; } else if (G) { ans = 1LL * ans * G % mod; G--; RG++; } else if (B) { ans = 1LL * ans * B % mod; B--; RB++; } else { R++; } } else if (s[i] == 'G') { if (RB) { ans = 1LL * ans * RB % mod; RB--; } else if (R) { ans = 1LL * ans * R % mod; R--; RG++; } else if (B) { ans = 1LL * ans * B % mod; B--; GB++; } else { G++; } } else { if (RG) { ans = 1LL * ans * RG % mod; RG--; } else if (R) { ans = 1LL * ans * R % mod; R--; RB++; } else if (G) { ans = 1LL * ans * G % mod; G--; GB++; } else { B++; } } } while (n) { ans = 1LL * ans * n % mod; n--; } printf("%d\n", ans); return 0; }
[ "expression.unary.arithmetic.add" ]
741,819
741,820
u159112689
cpp
p02940
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> using namespace std; const int N = 100005, mod = 998244353; int n, ans = 1, RG, GB, RB, R, G, B; char s[N]; int main() { scanf("%d%s", &n, s + 1); for (int i = 1; i <= n * 3; i++) { if (s[i] == 'R') { if (GB) { ans = 1LL * ans * GB % mod; GB--; } else if (G) { ans = 1LL * ans * G % mod; G--; RG++; } else if (B) { ans = 1LL * ans * B % mod; B--; RB++; } else { R++; } } else if (s[i] == 'G') { if (RB) { ans = 1LL * ans * RB % mod; RB--; } else if (R) { ans = 1LL * ans * R % mod; R--; RG++; } else if (B) { ans = 1LL * ans * B % mod; B--; GB++; } else { G++; } } else { if (RG) { ans = 1LL * ans * RG % mod; RG--; } else if (R) { ans = 1LL * ans * R % mod; R--; RB++; } else if (G) { ans = 1LL * ans * G % mod; GB++; } else { B++; } } } while (n) { ans = 1LL * ans * n % mod; n--; } printf("%d\n", ans); return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> using namespace std; const int N = 100005, mod = 998244353; int n, ans = 1, RG, GB, RB, R, G, B; char s[N * 3]; int main() { scanf("%d%s", &n, s + 1); for (int i = 1; i <= n * 3; i++) { if (s[i] == 'R') { if (GB) { ans = 1LL * ans * GB % mod; GB--; } else if (G) { ans = 1LL * ans * G % mod; G--; RG++; } else if (B) { ans = 1LL * ans * B % mod; B--; RB++; } else { R++; } } else if (s[i] == 'G') { if (RB) { ans = 1LL * ans * RB % mod; RB--; } else if (R) { ans = 1LL * ans * R % mod; R--; RG++; } else if (B) { ans = 1LL * ans * B % mod; B--; GB++; } else { G++; } } else { if (RG) { ans = 1LL * ans * RG % mod; RG--; } else if (R) { ans = 1LL * ans * R % mod; R--; RB++; } else if (G) { ans = 1LL * ans * G % mod; G--; GB++; } else { B++; } } } while (n) { ans = 1LL * ans * n % mod; n--; } printf("%d\n", ans); return 0; }
[ "expression.unary.arithmetic.add" ]
741,821
741,820
u159112689
cpp
p02940
#include <bits/stdc++.h> using namespace std; #define int long long const int N = 300005, M = 998244353; char s[N]; int r, b, g, rb, rg, bg, n, ans = 1; signed main() { scanf("%lld", &n); scanf("%s", s + 1); for (int i = 1; i <= 3 * n; i++) { if (s[i] == 'R') { if (bg) { (ans *= bg) %= M; bg--; } else if (b) { (ans *= b) %= M; b--; rb++; } else if (g) { (ans *= g) %= M; g--; rg++; } else r++; } if (s[i] == 'G') { if (rb) { (ans *= rb) %= M; rb--; } else if (r) { (ans *= r) %= M; r--; rg++; } else if (b) { (ans *= b) %= M; b--; bg++; } else g++; } if (s[i] == 'B') { if (rg) { (ans *= rg) %= M; rg--; } else if (r) { (ans *= r) %= M; r--; rb++; } else if (g) { (ans *= g) %= M; g--; rg++; } else b++; } } for (int i = 1; i <= n; i++) (ans *= i) %= M; printf("%lld\n", ans); }
#include <bits/stdc++.h> using namespace std; #define int long long const int N = 300005, M = 998244353; char s[N]; int r, b, g, rb, rg, bg, n, ans = 1; signed main() { scanf("%lld", &n); scanf("%s", s + 1); for (int i = 1; i <= 3 * n; i++) { if (s[i] == 'R') { if (bg) { (ans *= bg) %= M; bg--; } else if (b) { (ans *= b) %= M; b--; rb++; } else if (g) { (ans *= g) %= M; g--; rg++; } else r++; } if (s[i] == 'G') { if (rb) { (ans *= rb) %= M; rb--; } else if (r) { (ans *= r) %= M; r--; rg++; } else if (b) { (ans *= b) %= M; b--; bg++; } else g++; } if (s[i] == 'B') { if (rg) { (ans *= rg) %= M; rg--; } else if (r) { (ans *= r) %= M; r--; rb++; } else if (g) { (ans *= g) %= M; g--; bg++; } else b++; } } for (int i = 1; i <= n; i++) (ans *= i) %= M; printf("%lld\n", ans); }
[ "identifier.change" ]
741,839
741,840
u768967683
cpp
p02940
#include <algorithm> #include <bitset> #include <cassert> #include <climits> #include <cmath> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; #define MOD 998244353 #define REP(i, n) for (ll(i) = 0; (i) < (n); (i)++) #define FOR(i, c) \ for (decltype((c).begin()) i = (c).begin(); i != (c).end(); ++i) #define ll long long #define ull unsigned long long #define all(hoge) (hoge).begin(), (hoge).end() typedef pair<ll, ll> P; const long long INF = 1LL << 60; typedef vector<ll> Array; typedef vector<Array> Matrix; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } //グラフ関連 struct Edge { //グラフ ll to, cap, rev; Edge(ll _to, ll _cap, ll _rev) { to = _to; cap = _cap; rev = _rev; } }; typedef vector<Edge> Edges; typedef vector<Edges> Graph; void add_edge(Graph &G, ll from, ll to, ll cap, bool revFlag, ll revCap) { //最大フロー求める Ford-fulkerson G[from].push_back(Edge(to, cap, (ll)G[to].size())); if (revFlag) G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1)); //最大フロー・最小カットの場合逆辺は0にする } ll max_flow_dfs(Graph &G, ll v, ll t, ll f, vector<bool> &used) { if (v == t) return f; used[v] = true; for (int i = 0; i < G[v].size(); ++i) { Edge &e = G[v][i]; if (!used[e.to] && e.cap > 0) { ll d = max_flow_dfs(G, e.to, t, min(f, e.cap), used); if (d > 0) { e.cap -= d; G[e.to][e.rev].cap += d; return d; } } } return 0; } ll max_flow(Graph &G, ll s, ll t) { ll flow = 0; for (;;) { vector<bool> used(G.size()); REP(i, used.size()) used[i] = false; ll f = max_flow_dfs(G, s, t, INF, used); if (f == 0) { return flow; } flow += f; } } //最短経路(負閉路検出) void BellmanFord(Graph &G, ll s, Array &d, Array &negative) { // O(|E||V|) d.resize(G.size()); negative.resize(G.size()); REP(i, d.size()) d[i] = INF; REP(i, d.size()) negative[i] = false; d[s] = 0; REP(k, G.size() - 1) { REP(i, G.size()) { REP(j, G[i].size()) { if (d[i] != INF && d[G[i][j].to] > d[i] + G[i][j].cap) { d[G[i][j].to] = d[i] + G[i][j].cap; } } } } REP(k, G.size() - 1) { REP(i, G.size()) { REP(j, G[i].size()) { if (d[i] != INF && d[G[i][j].to] > d[i] + G[i][j].cap) { d[G[i][j].to] = d[i] + G[i][j].cap; negative[G[i][j].to] = true; } if (negative[i] == true) negative[G[i][j].to] = true; } } } } //最短経路(n>0だとだめ) void Dijkstra(Graph &G, ll s, Array &d) { // O(|E|log|V|) d.resize(G.size()); REP(i, d.size()) d[i] = INF; d[s] = 0; priority_queue<P, vector<P>, greater<P>> q; q.push(make_pair(0, s)); while (!q.empty()) { P a = q.top(); q.pop(); if (d[a.second] < a.first) continue; REP(i, G[a.second].size()) { Edge e = G[a.second][i]; if (d[e.to] > d[a.second] + e.cap) { d[e.to] = d[a.second] + e.cap; q.push(make_pair(d[e.to], e.to)); } } } } //最短経路(n<0でもok) void WarshallFloyd(Graph &G, Matrix &d) { // O(V^3) d.resize(G.size()); REP(i, d.size()) d[i].resize(G.size()); REP(i, d.size()) { REP(j, d[i].size()) { d[i][j] = INF; } } REP(i, G.size()) { REP(j, G[i].size()) { d[i][G[i][j].to] = G[i][j].cap; } } REP(i, G.size()) { REP(j, G.size()) { REP(k, G.size()) { chmin(d[j][k], d[j][i] + d[i][k]); } } } } class UnionFind { vector<int> data; int num; public: UnionFind(int size) : data(size, -1), num(size) {} bool unionSet(int x, int y) { x = root(x); y = root(y); if (x != y) { if (data[y] < data[x]) swap(x, y); data[x] += data[y]; data[y] = x; num--; } return x != y; } bool findSet(int x, int y) { return root(x) == root(y); } int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); } int size(int x) { return -data[root(x)]; } int numSet() { return num; } }; // nCr,nPr,modの逆元 class Combination { public: Array fact; // n! Array inv; // n!の逆元 ll mod; Combination(ll n, ll _mod) { mod = _mod; fact.resize(n + 1); fact[0] = 1; REP(i, n) { fact[i + 1] = (fact[i] * (i + 1LL)) % mod; } inv.resize(n + 1); REP(i, n + 1) { inv[i] = mod_inv(fact[i]); } } // modの逆元 ll mod_inv(ll x) { ll n = mod - 2; ll res = 1LL; while (n > 0) { if (n & 1) res = res * x % mod; x = x * x % mod; n >>= 1; } return res; } ll nCr(ll n, ll r) { return ((fact[n] * inv[r] % mod) * inv[n - r]) % mod; } ll nPr(ll n, ll r) { return (fact[n] * inv[n - r]) % mod; } ll nHr(ll n, ll r) { //重複組み合わせ:n種類のものからr個取り出す組み合わせ return nCr(r + n - 1, r); } }; //約数 void divisor(ll n, vector<ll> &ret) { for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(ret.begin(), ret.end(), greater<ll>()); } //素因数分解 void factoring(ll i, map<ll, ll> &mp) { ll x = i; // cout << x << endl; for (int j = 2; j <= i; j++) { if (x % j == 0) { if (mp.find(j) == mp.end()) { mp[j] = 0; } while (x % j == 0 && x > 1) { mp[j]++; x /= j; // cout << x << " " << j << endl; } } if (x == 1) break; } } //最大公約数 ll gcd(ll m, ll n) { if (n == 0) return m; return gcd(n, m % n); } // gcd //最小公倍数 ll lcm(ll m, ll n) { return m / gcd(m, n) * n; } //繰り返し自乗法 ll pow2(ll x, ll n, ll mod) { // x^n 計算量O(logn) ll ans = 1ll; while (n > 0) { if ((n & 1) == 1) { ans = ans * x % mod; } x = x * x % mod; //一周する度にx, x^2, x^4, x^8となる n >>= 1; //桁をずらす n = n >> 1 } return ans; } vector<ll> lis_fast(const vector<ll> &a) { //最長部分増加列 const ll n = a.size(); vector<ll> A(n, INT_MAX); vector<ll> id(n); for (int i = 0; i < n; ++i) { // id[i] = distance(A.begin(), upper_bound(A.begin(), A.end(), // a[i]));//非減少 id[i] = distance(A.begin(), lower_bound(A.begin(), A.end(), a[i])); A[id[i]] = a[i]; } ll m = *max_element(id.begin(), id.end()); vector<ll> b(m + 1); for (int i = n - 1; i >= 0; --i) if (id[i] == m) b[m--] = a[i]; return b; } // memo // output : fixed << setprecision(n) <<小数点以下n桁出力 // setfill('0') << setw(12) <<num 0埋めで12文字出力 // func // lower_bound(all(a),x):vector aでx以上の要素のイテレータを返す // upper_bound(all(a,x)):vector aでxより大きい要素のイテレータを返す // setやmapの場合は専用関数あり //調和関数はlogn! n/1+n/2+n/3+... int main() { ios::sync_with_stdio(false); cin.tie(0); ll n; cin >> n; string s; cin >> s; ll r = 0; ll g = 0; ll b = 0; ll rg = 0; ll gb = 0; ll rb = 0; ll ans = 1; REP(i, 3 * n) { if (s[i] == 'R') { if (gb > 0) { (ans *= gb) %= MOD; gb--; } else if (g > 0) { (ans *= g) %= MOD; rg++; g--; } else if (b > 0) { (ans *= b) %= MOD; rb++; b--; } else { r++; } } else if (s[i] == 'G') { if (rb > 0) { (ans *= rb) %= MOD; rb--; } else if (r > 0) { (ans *= r) %= MOD; rg++; r--; } else if (b > 0) { (ans *= b) %= MOD; gb++; b--; } else { b++; } } else { if (rg > 0) { (ans *= rg) %= MOD; rg--; } else if (r > 0) { (ans *= r) %= MOD; rb++; r--; } else if (g > 0) { (ans *= g) %= MOD; gb++; g--; } else { b++; } } } REP(i, n) { (ans *= (i + 1)) %= MOD; } cout << ans << endl; return 0; }
#include <algorithm> #include <bitset> #include <cassert> #include <climits> #include <cmath> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; #define MOD 998244353 #define REP(i, n) for (ll(i) = 0; (i) < (n); (i)++) #define FOR(i, c) \ for (decltype((c).begin()) i = (c).begin(); i != (c).end(); ++i) #define ll long long #define ull unsigned long long #define all(hoge) (hoge).begin(), (hoge).end() typedef pair<ll, ll> P; const long long INF = 1LL << 60; typedef vector<ll> Array; typedef vector<Array> Matrix; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } //グラフ関連 struct Edge { //グラフ ll to, cap, rev; Edge(ll _to, ll _cap, ll _rev) { to = _to; cap = _cap; rev = _rev; } }; typedef vector<Edge> Edges; typedef vector<Edges> Graph; void add_edge(Graph &G, ll from, ll to, ll cap, bool revFlag, ll revCap) { //最大フロー求める Ford-fulkerson G[from].push_back(Edge(to, cap, (ll)G[to].size())); if (revFlag) G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1)); //最大フロー・最小カットの場合逆辺は0にする } ll max_flow_dfs(Graph &G, ll v, ll t, ll f, vector<bool> &used) { if (v == t) return f; used[v] = true; for (int i = 0; i < G[v].size(); ++i) { Edge &e = G[v][i]; if (!used[e.to] && e.cap > 0) { ll d = max_flow_dfs(G, e.to, t, min(f, e.cap), used); if (d > 0) { e.cap -= d; G[e.to][e.rev].cap += d; return d; } } } return 0; } ll max_flow(Graph &G, ll s, ll t) { ll flow = 0; for (;;) { vector<bool> used(G.size()); REP(i, used.size()) used[i] = false; ll f = max_flow_dfs(G, s, t, INF, used); if (f == 0) { return flow; } flow += f; } } //最短経路(負閉路検出) void BellmanFord(Graph &G, ll s, Array &d, Array &negative) { // O(|E||V|) d.resize(G.size()); negative.resize(G.size()); REP(i, d.size()) d[i] = INF; REP(i, d.size()) negative[i] = false; d[s] = 0; REP(k, G.size() - 1) { REP(i, G.size()) { REP(j, G[i].size()) { if (d[i] != INF && d[G[i][j].to] > d[i] + G[i][j].cap) { d[G[i][j].to] = d[i] + G[i][j].cap; } } } } REP(k, G.size() - 1) { REP(i, G.size()) { REP(j, G[i].size()) { if (d[i] != INF && d[G[i][j].to] > d[i] + G[i][j].cap) { d[G[i][j].to] = d[i] + G[i][j].cap; negative[G[i][j].to] = true; } if (negative[i] == true) negative[G[i][j].to] = true; } } } } //最短経路(n>0だとだめ) void Dijkstra(Graph &G, ll s, Array &d) { // O(|E|log|V|) d.resize(G.size()); REP(i, d.size()) d[i] = INF; d[s] = 0; priority_queue<P, vector<P>, greater<P>> q; q.push(make_pair(0, s)); while (!q.empty()) { P a = q.top(); q.pop(); if (d[a.second] < a.first) continue; REP(i, G[a.second].size()) { Edge e = G[a.second][i]; if (d[e.to] > d[a.second] + e.cap) { d[e.to] = d[a.second] + e.cap; q.push(make_pair(d[e.to], e.to)); } } } } //最短経路(n<0でもok) void WarshallFloyd(Graph &G, Matrix &d) { // O(V^3) d.resize(G.size()); REP(i, d.size()) d[i].resize(G.size()); REP(i, d.size()) { REP(j, d[i].size()) { d[i][j] = INF; } } REP(i, G.size()) { REP(j, G[i].size()) { d[i][G[i][j].to] = G[i][j].cap; } } REP(i, G.size()) { REP(j, G.size()) { REP(k, G.size()) { chmin(d[j][k], d[j][i] + d[i][k]); } } } } class UnionFind { vector<int> data; int num; public: UnionFind(int size) : data(size, -1), num(size) {} bool unionSet(int x, int y) { x = root(x); y = root(y); if (x != y) { if (data[y] < data[x]) swap(x, y); data[x] += data[y]; data[y] = x; num--; } return x != y; } bool findSet(int x, int y) { return root(x) == root(y); } int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); } int size(int x) { return -data[root(x)]; } int numSet() { return num; } }; // nCr,nPr,modの逆元 class Combination { public: Array fact; // n! Array inv; // n!の逆元 ll mod; Combination(ll n, ll _mod) { mod = _mod; fact.resize(n + 1); fact[0] = 1; REP(i, n) { fact[i + 1] = (fact[i] * (i + 1LL)) % mod; } inv.resize(n + 1); REP(i, n + 1) { inv[i] = mod_inv(fact[i]); } } // modの逆元 ll mod_inv(ll x) { ll n = mod - 2; ll res = 1LL; while (n > 0) { if (n & 1) res = res * x % mod; x = x * x % mod; n >>= 1; } return res; } ll nCr(ll n, ll r) { return ((fact[n] * inv[r] % mod) * inv[n - r]) % mod; } ll nPr(ll n, ll r) { return (fact[n] * inv[n - r]) % mod; } ll nHr(ll n, ll r) { //重複組み合わせ:n種類のものからr個取り出す組み合わせ return nCr(r + n - 1, r); } }; //約数 void divisor(ll n, vector<ll> &ret) { for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(ret.begin(), ret.end(), greater<ll>()); } //素因数分解 void factoring(ll i, map<ll, ll> &mp) { ll x = i; // cout << x << endl; for (int j = 2; j <= i; j++) { if (x % j == 0) { if (mp.find(j) == mp.end()) { mp[j] = 0; } while (x % j == 0 && x > 1) { mp[j]++; x /= j; // cout << x << " " << j << endl; } } if (x == 1) break; } } //最大公約数 ll gcd(ll m, ll n) { if (n == 0) return m; return gcd(n, m % n); } // gcd //最小公倍数 ll lcm(ll m, ll n) { return m / gcd(m, n) * n; } //繰り返し自乗法 ll pow2(ll x, ll n, ll mod) { // x^n 計算量O(logn) ll ans = 1ll; while (n > 0) { if ((n & 1) == 1) { ans = ans * x % mod; } x = x * x % mod; //一周する度にx, x^2, x^4, x^8となる n >>= 1; //桁をずらす n = n >> 1 } return ans; } vector<ll> lis_fast(const vector<ll> &a) { //最長部分増加列 const ll n = a.size(); vector<ll> A(n, INT_MAX); vector<ll> id(n); for (int i = 0; i < n; ++i) { // id[i] = distance(A.begin(), upper_bound(A.begin(), A.end(), // a[i]));//非減少 id[i] = distance(A.begin(), lower_bound(A.begin(), A.end(), a[i])); A[id[i]] = a[i]; } ll m = *max_element(id.begin(), id.end()); vector<ll> b(m + 1); for (int i = n - 1; i >= 0; --i) if (id[i] == m) b[m--] = a[i]; return b; } // memo // output : fixed << setprecision(n) <<小数点以下n桁出力 // setfill('0') << setw(12) <<num 0埋めで12文字出力 // func // lower_bound(all(a),x):vector aでx以上の要素のイテレータを返す // upper_bound(all(a,x)):vector aでxより大きい要素のイテレータを返す // setやmapの場合は専用関数あり //調和関数はlogn! n/1+n/2+n/3+... int main() { ios::sync_with_stdio(false); cin.tie(0); ll n; cin >> n; string s; cin >> s; ll r = 0; ll g = 0; ll b = 0; ll rg = 0; ll gb = 0; ll rb = 0; ll ans = 1; REP(i, 3 * n) { if (s[i] == 'R') { if (gb > 0) { (ans *= gb) %= MOD; gb--; } else if (g > 0) { (ans *= g) %= MOD; rg++; g--; } else if (b > 0) { (ans *= b) %= MOD; rb++; b--; } else { r++; } } else if (s[i] == 'G') { if (rb > 0) { (ans *= rb) %= MOD; rb--; } else if (r > 0) { (ans *= r) %= MOD; rg++; r--; } else if (b > 0) { (ans *= b) %= MOD; gb++; b--; } else { g++; } } else { if (rg > 0) { (ans *= rg) %= MOD; rg--; } else if (r > 0) { (ans *= r) %= MOD; rb++; r--; } else if (g > 0) { (ans *= g) %= MOD; gb++; g--; } else { b++; } } } REP(i, n) { (ans *= (i + 1)) %= MOD; } cout << ans << endl; return 0; }
[ "identifier.change" ]
741,845
741,846
u712993629
cpp
p02940
#include "bits/stdc++.h" using namespace std; int main() { long long N, ANS = 1, RG = 0, GB = 0, BR = 0, R = 0, G = 0, B = 0, MOD = 998244353; string S; cin >> N >> S; for (int i = 0; i < S.size(); i++) { if (S[i] == 'R') { if (GB != 0) { ANS *= GB; ANS %= MOD; GB--; } else if (G != 0) { ANS *= G; ANS %= MOD; G--; RG++; } else if (B != 0) { ANS *= B; ANS %= MOD; B--; BR++; } else { R++; } } if (S[i] == 'G') { if (BR != 0) { ANS *= BR; ANS %= MOD; BR--; } else if (B != 0) { ANS *= B; ANS %= MOD; B--; GB++; } else if (R != 0) { ANS *= R; ANS %= MOD; R--; RG++; } else { G++; } } if (S[i] == 'B') { if (RG != 0) { ANS *= RG; ANS %= MOD; RG--; } else if (R != 0) { ANS *= R; ANS %= MOD; R--; BR++; } else if (G != 0) { ANS *= G; ANS %= MOD; G--; RG++; } else { B++; } } } for (int i = 1; i <= N; i++) { ANS *= i; ANS %= MOD; } cout << ANS << endl; }
#include "bits/stdc++.h" using namespace std; int main() { long long N, ANS = 1, RG = 0, GB = 0, BR = 0, R = 0, G = 0, B = 0, MOD = 998244353; string S; cin >> N >> S; for (int i = 0; i < S.size(); i++) { if (S[i] == 'R') { if (GB != 0) { ANS *= GB; ANS %= MOD; GB--; } else if (G != 0) { ANS *= G; ANS %= MOD; G--; RG++; } else if (B != 0) { ANS *= B; ANS %= MOD; B--; BR++; } else { R++; } } if (S[i] == 'G') { if (BR != 0) { ANS *= BR; ANS %= MOD; BR--; } else if (B != 0) { ANS *= B; ANS %= MOD; B--; GB++; } else if (R != 0) { ANS *= R; ANS %= MOD; R--; RG++; } else { G++; } } if (S[i] == 'B') { if (RG != 0) { ANS *= RG; ANS %= MOD; RG--; } else if (R != 0) { ANS *= R; ANS %= MOD; R--; BR++; } else if (G != 0) { ANS *= G; ANS %= MOD; G--; GB++; } else { B++; } } } for (int i = 1; i <= N; i++) { ANS *= i; ANS %= MOD; } cout << ANS << endl; }
[ "identifier.change" ]
741,863
741,864
u454087021
cpp
p02940
#include <cstdio> int n, i, j, b[3], a = 1, P = 998244353; char c; int main() { scanf("%d\n", &n); for (i = 1; i <= n; ++i) a = 1ll * a * i % P; for (i = 1; i <= 3 * n; ++i) { scanf("%c", &c); int &t = b[(c > 'B') + (c > 'G')], m = 1e9; for (j = 0; j < 2; ++j) if (b[j] > t && b[j] - t < m) m = b[j] - t; if (m <= n) a = 1ll * a * m % P; ++t; } printf("%d\n", a); return 0; }
#include <cstdio> int n, i, j, b[3], a = 1, P = 998244353; char c; int main() { scanf("%d\n", &n); for (i = 1; i <= n; ++i) a = 1ll * a * i % P; for (i = 1; i <= 3 * n; ++i) { scanf("%c", &c); int &t = b[(c > 'B') + (c > 'G')], m = 1e7; for (j = 0; j < 3; ++j) if (b[j] > t && b[j] - t < m) m = b[j] - t; if (m <= n) a = 1ll * a * m % P; ++t; } printf("%d\n", a); return 0; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
741,884
741,885
u847307867
cpp
p02940
#include <iostream> #include <vector> #define llint long long #define mod 998244353 using namespace std; llint n; string s; int main(void) { cin >> n >> s; llint ans = 1; llint r = 0, g = 0, b = 0, R = 0, G = 0, B = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == 'R') { if (R > 0) ans *= R, ans %= mod, R--; else { if (g > 0) ans *= g, ans %= mod, g--, B++; if (b > 0) ans *= b, ans %= mod, b--, G++; else r++; } } if (s[i] == 'G') { if (G > 0) ans *= G, ans %= mod, G--; else { if (b > 0) ans *= b, ans %= mod, b--, R++; if (r > 0) ans *= r, ans %= mod, r--, B++; else g++; } } if (s[i] == 'B') { if (B > 0) ans *= B, ans %= mod, B--; else { if (r > 0) ans *= r, ans %= mod, r--, G++; if (g > 0) ans *= g, ans %= mod, g--, R++; else b++; } } } for (int i = 1; i <= n; i++) ans *= i, ans %= mod; cout << ans << endl; return 0; }
#include <iostream> #include <vector> #define llint long long #define mod 998244353 using namespace std; llint n; string s; int main(void) { cin >> n >> s; llint ans = 1; llint r = 0, g = 0, b = 0, R = 0, G = 0, B = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == 'R') { if (R > 0) ans *= R, ans %= mod, R--; else { if (g > 0) ans *= g, ans %= mod, g--, B++; else if (b > 0) ans *= b, ans %= mod, b--, G++; else r++; } } if (s[i] == 'G') { if (G > 0) ans *= G, ans %= mod, G--; else { if (b > 0) ans *= b, ans %= mod, b--, R++; else if (r > 0) ans *= r, ans %= mod, r--, B++; else g++; } } if (s[i] == 'B') { if (B > 0) ans *= B, ans %= mod, B--; else { if (r > 0) ans *= r, ans %= mod, r--, G++; else if (g > 0) ans *= g, ans %= mod, g--, R++; else b++; } } } for (int i = 1; i <= n; i++) ans *= i, ans %= mod; cout << ans << endl; return 0; }
[ "control_flow.branch.else_if.replace.add", "control_flow.branch.if.replace.remove" ]
741,886
741,887
u319282133
cpp
p02940
#include "bits/stdc++.h" using namespace std; #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0) #define ll long long int #define int ll //#define slld(t) scanf("%lld",&t) //#define sd(t) scanf("%d",&t) //#define pd(t) printf("%d\n",t) //#define plld(t) printf("%lld\n",t) #define vec vector<int> #define vecp vector<pair<int, int>> #define ff first #define ss second #define pb push_back #define mp make_pair #define debug(x) cerr << #x << ": " << x << endl #define pii pair<int, int> #define pll pair<ll, ll> #define debug(x) cerr << #x << ": " << x << endl #define mod 1000000007 #define N 200005 #define MAX 300005 #define mod1 1000000007 #define mod2 998244353 #define bitcnt __builtin_popcount #define PI acos(-1) //#define endl "\n" const int inf = (int)1e18 + 10; void mul(int &a, int b) { a = (a * b) % mod2; } signed main() { fast; int n; cin >> n; string s; cin >> s; int a = n, r = 0, b = 0, g = 0, rb = 0, bg = 0, gr = 0; int ans = 1; for (int i = 0; i < 3 * n; i++) { if (s[i] == 'R') { if (bg > 0) mul(ans, bg), bg--; else if (b > 0) mul(ans, b), b--, rb++; else if (g > 0) mul(ans, g), g--, gr++; else mul(ans, a), a--, r++; } if (s[i] == 'B') { if (gr > 0) mul(ans, gr), gr--; else if (r > 0) mul(ans, r), r--, rb++; else if (g > 0) mul(ans, g), g--, bg++; else mul(ans, a), a--, b++; } if (s[i] == 'G') { if (rb > 0) mul(ans, rb), rb--; else if (r > 0) mul(ans, r), r--, gr++; else if (g > 0) mul(ans, b), b--, bg++; else mul(ans, a), a--, g++; } } cout << ans << endl; }
#include "bits/stdc++.h" using namespace std; #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0) #define ll long long int #define int ll //#define slld(t) scanf("%lld",&t) //#define sd(t) scanf("%d",&t) //#define pd(t) printf("%d\n",t) //#define plld(t) printf("%lld\n",t) #define vec vector<int> #define vecp vector<pair<int, int>> #define ff first #define ss second #define pb push_back #define mp make_pair #define debug(x) cerr << #x << ": " << x << endl #define pii pair<int, int> #define pll pair<ll, ll> #define debug(x) cerr << #x << ": " << x << endl #define mod 1000000007 #define N 200005 #define MAX 300005 #define mod1 1000000007 #define mod2 998244353 #define bitcnt __builtin_popcount #define PI acos(-1) //#define endl "\n" const int inf = (int)1e18 + 10; void mul(int &a, int b) { a = (a * b) % mod2; } signed main() { fast; int n; cin >> n; string s; cin >> s; int a = n, r = 0, b = 0, g = 0, rb = 0, bg = 0, gr = 0; int ans = 1; for (int i = 0; i < 3 * n; i++) { if (s[i] == 'R') { if (bg > 0) mul(ans, bg), bg--; else if (b > 0) mul(ans, b), b--, rb++; else if (g > 0) mul(ans, g), g--, gr++; else mul(ans, a), a--, r++; } if (s[i] == 'B') { if (gr > 0) mul(ans, gr), gr--; else if (r > 0) mul(ans, r), r--, rb++; else if (g > 0) mul(ans, g), g--, bg++; else mul(ans, a), a--, b++; } if (s[i] == 'G') { if (rb > 0) mul(ans, rb), rb--; else if (r > 0) mul(ans, r), r--, gr++; else if (b > 0) mul(ans, b), b--, bg++; else mul(ans, a), a--, g++; } } cout << ans << endl; }
[ "identifier.change", "control_flow.branch.if.condition.change" ]
741,896
741,897
u564412651
cpp
p02940
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vll = vector<ll>; using vvi = vector<vector<int>>; using vvl = vector<vector<ll>>; ll P = 998244353; template <typename T> class tRMQ { vector<T> data; T unit; public: static const long long INF = 100000000000; int n; function<T(const T &, const T &)> f; tRMQ(int _, T u, function<T(T, T)> bi) { unit = u; f = bi; n = 1; while (n < _) { n <<= 1; } data.resize(n * 4); for (int i = 0; i < n * 4; i++) data[i] = unit; } void update(int index, T val) { int i = index + n - 1; data[i] = val; while (i > 0) { i = (i - 1) / 2; data[i] = f(data[i * 2 + 1], data[i * 2 + 2]); } } // [a, b) T query(int a, int b, int k, int l, int r) { if (a < 0 || r <= a || b <= l) return unit; if (a <= l && r <= b) return data[k]; else return f(query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (r + l) / 2, r)); } T query(int a, int b) { return query(a, b, 0, 0, n); } }; tRMQ<ll> minrmq(int n) { return tRMQ<ll>(n, 10000000000000000LL, [](ll r, ll l) { return min(l, r); }); } tRMQ<ll> maxrmq(int n) { return tRMQ<ll>(n, -10000000000000000LL, [](ll r, ll l) { return max(l, r); }); } tRMQ<ll> sumrmq(int n) { return tRMQ<ll>(n, 0, [](ll l, ll r) { return l + r; }); } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); ll fac[101010] = {0}; fac[0] = 1; for (int i = 1; i < 101010; i++) fac[i] = (fac[i - 1] * i) % P; int n; cin >> n; string s; cin >> s; ll ans = fac[n]; ll r = 0, g = 0, b = 0; ll rg = 0, gb = 0, br = 0; for (int i = 0; i < 3 * n; i++) { if (s[i] == 'R') { if (gb) { ans *= gb; ans %= P; gb--; } else if (g) { rg += 1; ans *= g; ans %= P; g--; } else if (b) { br += 1; ans *= b; ans %= P; b--; } else { r++; } } else if (s[i] == 'G') { if (br) { ans *= br; ans %= P; br--; } else if (r) { rg += 1; ans *= r; ans %= P; r--; } else if (b) { gb += 1; ans *= b; ans %= P; b--; } else { g++; } } else { if (rg) { ans *= rg; ans %= P; rg--; } else if (r) { br += 1; ans *= r; ans %= P; r--; } else if (g) { gb += 1; ans *= b; ans %= P; g--; } else { b++; } } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vll = vector<ll>; using vvi = vector<vector<int>>; using vvl = vector<vector<ll>>; ll P = 998244353; template <typename T> class tRMQ { vector<T> data; T unit; public: static const long long INF = 100000000000; int n; function<T(const T &, const T &)> f; tRMQ(int _, T u, function<T(T, T)> bi) { unit = u; f = bi; n = 1; while (n < _) { n <<= 1; } data.resize(n * 4); for (int i = 0; i < n * 4; i++) data[i] = unit; } void update(int index, T val) { int i = index + n - 1; data[i] = val; while (i > 0) { i = (i - 1) / 2; data[i] = f(data[i * 2 + 1], data[i * 2 + 2]); } } // [a, b) T query(int a, int b, int k, int l, int r) { if (a < 0 || r <= a || b <= l) return unit; if (a <= l && r <= b) return data[k]; else return f(query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (r + l) / 2, r)); } T query(int a, int b) { return query(a, b, 0, 0, n); } }; tRMQ<ll> minrmq(int n) { return tRMQ<ll>(n, 10000000000000000LL, [](ll r, ll l) { return min(l, r); }); } tRMQ<ll> maxrmq(int n) { return tRMQ<ll>(n, -10000000000000000LL, [](ll r, ll l) { return max(l, r); }); } tRMQ<ll> sumrmq(int n) { return tRMQ<ll>(n, 0, [](ll l, ll r) { return l + r; }); } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); ll fac[101010] = {0}; fac[0] = 1; for (int i = 1; i < 101010; i++) fac[i] = (fac[i - 1] * i) % P; int n; cin >> n; string s; cin >> s; ll ans = fac[n]; ll r = 0, g = 0, b = 0; ll rg = 0, gb = 0, br = 0; for (int i = 0; i < 3 * n; i++) { if (s[i] == 'R') { if (gb) { ans *= gb; ans %= P; gb--; } else if (g) { rg += 1; ans *= g; ans %= P; g--; } else if (b) { br += 1; ans *= b; ans %= P; b--; } else { r++; } } else if (s[i] == 'G') { if (br) { ans *= br; ans %= P; br--; } else if (r) { rg += 1; ans *= r; ans %= P; r--; } else if (b) { gb += 1; ans *= b; ans %= P; b--; } else { g++; } } else { if (rg) { ans *= rg; ans %= P; rg--; } else if (r) { br += 1; ans *= r; ans %= P; r--; } else if (g) { gb += 1; ans *= g; ans %= P; g--; } else { b++; } } } cout << ans << endl; return 0; }
[ "assignment.value.change", "identifier.change" ]
741,900
741,901
u656572785
cpp
p02940
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> using namespace std; const int Mod = 998244353; int n; #define Maxn 300010 char str[Maxn]; int fact = 1, Ans = 1; int a[7]; // empty R G B RG BG RB int main() { scanf("%d", &n); for (register int i = 1; i <= n; ++i) fact = 1ll * fact * i % Mod; scanf("%s", str + 1); for (register int i = 1; i <= 3 * n; ++i) { if (str[i] == 'R') { if (a[5]) { Ans = 1ll * Ans * a[5] % Mod; a[5]--; continue; } if (a[2]) { Ans = 1ll * Ans * a[2] % Mod; a[2]--; a[4]++; continue; } if (a[3]) { Ans = 1ll * Ans * a[3] % Mod; a[3]--; a[6]++; continue; } a[1]++; } else if (str[i] == 'G') { if (a[6]) { Ans = 1ll * Ans * a[6] % Mod; a[6]--; continue; } if (a[1]) { Ans = 1ll * Ans * a[1] % Mod; a[1]--; a[4]++; continue; } if (a[3]) { Ans = 1ll * Ans * a[3] % Mod; a[3]--; a[5]++; continue; } a[2]++; } else { if (a[4]) { Ans = 1ll * Ans * a[4] % Mod; a[4]--; continue; } if (a[1]) { Ans = 1ll * a[1] % Mod; a[1]--; a[6]++; continue; } if (a[2]) { Ans = 1ll * Ans * a[2] % Mod; a[2]--; a[5]++; continue; } a[3]++; } } printf("%d\n", 1ll * Ans * fact % Mod); return 0; }
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> using namespace std; const int Mod = 998244353; int n; #define Maxn 300010 char str[Maxn]; int fact = 1, Ans = 1; int a[7]; // empty R G B RG BG RB int main() { scanf("%d", &n); for (register int i = 1; i <= n; ++i) fact = 1ll * fact * i % Mod; scanf("%s", str + 1); for (register int i = 1; i <= 3 * n; ++i) { if (str[i] == 'R') { if (a[5]) { Ans = 1ll * Ans * a[5] % Mod; a[5]--; continue; } if (a[2]) { Ans = 1ll * Ans * a[2] % Mod; a[2]--; a[4]++; continue; } if (a[3]) { Ans = 1ll * Ans * a[3] % Mod; a[3]--; a[6]++; continue; } a[1]++; } else if (str[i] == 'G') { if (a[6]) { Ans = 1ll * Ans * a[6] % Mod; a[6]--; continue; } if (a[1]) { Ans = 1ll * Ans * a[1] % Mod; a[1]--; a[4]++; continue; } if (a[3]) { Ans = 1ll * Ans * a[3] % Mod; a[3]--; a[5]++; continue; } a[2]++; } else { if (a[4]) { Ans = 1ll * Ans * a[4] % Mod; a[4]--; continue; } if (a[1]) { Ans = 1ll * Ans * a[1] % Mod; a[1]--; a[6]++; continue; } if (a[2]) { Ans = 1ll * Ans * a[2] % Mod; a[2]--; a[5]++; continue; } a[3]++; } } printf("%d\n", 1ll * Ans * fact % Mod); return 0; }
[ "assignment.change" ]
741,904
741,905
u299340570
cpp
p02940
/* ЗАПУСКАЕМ ░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░ ▄███▀░◐░░░▌░░░░░░░ ░░░░▌░░░░░▐░░░░░░░ ░░░░▐░░░░░▐░░░░░░░ ░░░░▌░░░░░▐▄▄░░░░░ ░░░░▌░░░░▄▀▒▒▀▀▀▀▄ ░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄ ░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄ ░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄ ░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄ ░░░░░░░░░░░▌▌░▌▌░░░░░ ░░░░░░░░░░░▌▌░▌▌░░░░░ ░░░░░░░░░▄▄▌▌▄▌▌░░░░░ */ #include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; template <typename T1, typename T2> inline void chkmin(T1 &x, T2 y) { x = (x > y ? y : x); } template <typename T1, typename T2> inline void chkmax(T1 &x, T2 y) { x = (x < y ? y : x); } #define sz(c) (int)(c).size() #define all(c) (c).begin(), (c).end() #define rall(c) (c).rbegin(), (c).rend() #define left left224 #define right right224 #define next next224 #define rank rank224 #define prev prev224 #define y1 y1224 #define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin) #define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout) #define files(FILENAME) read(FILENAME), write(FILENAME) #define pb push_back #define mp make_pair using ll = long long; const string FILENAME = "input"; const int Mod = 998244353; int n; string s; vector<int> pos[3]; int cnt[8]; int get(char c) { if (c == 'R') { return 0; } if (c == 'G') { return 1; } return 2; } int mul(int a, int b) { return (1LL * a * b) % Mod; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); // read(FILENAME); cin >> n; n *= 3; cin >> s; cnt[0] = n; int ans = 1; for (int i = 0; i < n; i++) { int c = get(s[i]); int cand = -1; for (int j = 0; j < 7; j++) { if (cnt[j]) { if (((1 << c) ^ j) > j) { cand = j; } } } ans = mul(ans, cnt[cand]); cnt[cand]--; cnt[cand ^ (1 << c)]++; } cout << ans << '\n'; return 0; }
/* ЗАПУСКАЕМ ░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░ ▄███▀░◐░░░▌░░░░░░░ ░░░░▌░░░░░▐░░░░░░░ ░░░░▐░░░░░▐░░░░░░░ ░░░░▌░░░░░▐▄▄░░░░░ ░░░░▌░░░░▄▀▒▒▀▀▀▀▄ ░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄ ░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄ ░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄ ░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄ ░░░░░░░░░░░▌▌░▌▌░░░░░ ░░░░░░░░░░░▌▌░▌▌░░░░░ ░░░░░░░░░▄▄▌▌▄▌▌░░░░░ */ #include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; template <typename T1, typename T2> inline void chkmin(T1 &x, T2 y) { x = (x > y ? y : x); } template <typename T1, typename T2> inline void chkmax(T1 &x, T2 y) { x = (x < y ? y : x); } #define sz(c) (int)(c).size() #define all(c) (c).begin(), (c).end() #define rall(c) (c).rbegin(), (c).rend() #define left left224 #define right right224 #define next next224 #define rank rank224 #define prev prev224 #define y1 y1224 #define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin) #define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout) #define files(FILENAME) read(FILENAME), write(FILENAME) #define pb push_back #define mp make_pair using ll = long long; const string FILENAME = "input"; const int Mod = 998244353; int n; string s; vector<int> pos[3]; int cnt[8]; int get(char c) { if (c == 'R') { return 0; } if (c == 'G') { return 1; } return 2; } int mul(int a, int b) { return (1LL * a * b) % Mod; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); // read(FILENAME); cin >> n; n *= 3; cin >> s; cnt[0] = n / 3; int ans = 1; for (int i = 0; i < n; i++) { int c = get(s[i]); int cand = -1; for (int j = 0; j < 7; j++) { if (cnt[j]) { if (((1 << c) ^ j) > j) { cand = j; } } } ans = mul(ans, cnt[cand]); cnt[cand]--; cnt[cand ^ (1 << c)]++; } cout << ans << '\n'; return 0; }
[ "assignment.change" ]
741,917
741,918
u139147798
cpp
p02940
#include <bits/stdc++.h> using namespace std; typedef long long ll; #ifdef iq mt19937 rnd(228); #else mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count()); #endif int main() { #ifdef iq freopen("a.in", "r", stdin); #endif ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; string s; cin >> s; int r = 0, g = 0, b = 0, rg = 0, rb = 0, gb = 0; ll ans = 1; for (int i = 0; i < (int)s.size(); i++) { if (s[i] == 'R') { if (gb) { ans *= gb; gb--; } else { if (g) { ans *= g; g--; rg++; } else if (b) { ans *= b; b--; rb++; } else { r++; } } } else if (s[i] == 'G') { if (rb) { ans *= rb; rb--; } else { if (b) { ans *= b; b--; gb++; } else if (r) { ans *= r; r--; rg++; } else { g++; } } } else { if (rg) { ans *= rg; rg--; } else { if (g) { ans *= g; g--; gb++; } else if (r) { ans *= r; r--; rg++; } else { b++; } } } ans %= 998244353; } for (int i = 1; i <= n; i++) { ans *= i; ans %= 998244353; } cout << ans << '\n'; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #ifdef iq mt19937 rnd(228); #else mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count()); #endif int main() { #ifdef iq freopen("a.in", "r", stdin); #endif ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; string s; cin >> s; int r = 0, g = 0, b = 0, rg = 0, rb = 0, gb = 0; ll ans = 1; for (int i = 0; i < (int)s.size(); i++) { if (s[i] == 'R') { if (gb) { ans *= gb; gb--; } else { if (g) { ans *= g; g--; rg++; } else if (b) { ans *= b; b--; rb++; } else { r++; } } } else if (s[i] == 'G') { if (rb) { ans *= rb; rb--; } else { if (b) { ans *= b; b--; gb++; } else if (r) { ans *= r; r--; rg++; } else { g++; } } } else { if (rg) { ans *= rg; rg--; } else { if (g) { ans *= g; g--; gb++; } else if (r) { ans *= r; r--; rb++; } else { b++; } } } ans %= 998244353; } for (int i = 1; i <= n; i++) { ans *= i; ans %= 998244353; } cout << ans << '\n'; }
[ "identifier.change" ]
741,939
741,940
u814534994
cpp