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
9 values
p03017
#include <iostream> using namespace std; int main() { int n, a, b, c, d; string s; cin >> n >> a >> b >> c >> d >> s; a--; b--; c--; d--; string result = "Yes"; if (c < d) { for (int i = a + 2; i < d; i++) { if (s[i] == '#' && s[i - 1] == '#') { result = "No"; } } } else { bool flag = false; for (int i = a + 2; i < c; i++) { if (s[i] == '#' && s[i - 1] == '#') { result = "No"; } } for (int i = b + 1; i <= d + 2; i++) { if (s[i] == '.' && s[i - 1] == '.' && s[i - 2] == '.') { flag = true; } } if (!flag) { result = "No"; } } cout << result; return 0; }
#include <iostream> using namespace std; int main() { int n, a, b, c, d; string s; cin >> n >> a >> b >> c >> d >> s; a--; b--; c--; d--; string result = "Yes"; if (c < d) { for (int i = a + 2; i < d; i++) { if (s[i] == '#' && s[i - 1] == '#') { result = "No"; } } } else { bool flag = false; for (int i = a + 2; i < c; i++) { if (s[i] == '#' && s[i - 1] == '#') { result = "No"; } } for (int i = b + 1; i <= d + 1; i++) { if (s[i] == '.' && s[i - 1] == '.' && s[i - 2] == '.') { flag = true; } } if (!flag) { result = "No"; } } cout << result; return 0; }
[ "literal.number.change", "control_flow.branch.if.condition.change" ]
830,825
830,826
u085367022
cpp
p03017
#include <iostream> using namespace std; int main() { int n, a, b, c, d; string s; cin >> n >> a >> b >> c >> d >> s; a--; b--; c--; d--; string result = "Yes"; if (c < d) { for (int i = a + 2; i < d; i++) { if (s[i] == '#' && s[i - 1] == '#') { result = "No"; } } } else { bool flag = false; for (int i = a + 2; i < c; i++) { if (s[i] == '#' && s[i - 1] == '#') { result = "No"; } } for (int i = b + 3; i <= d; i++) { if (s[i] == '.' && s[i - 1] == '.' && s[i - 2] == '.') { flag = true; } } if (!flag) { result = "No"; } } cout << result; return 0; }
#include <iostream> using namespace std; int main() { int n, a, b, c, d; string s; cin >> n >> a >> b >> c >> d >> s; a--; b--; c--; d--; string result = "Yes"; if (c < d) { for (int i = a + 2; i < d; i++) { if (s[i] == '#' && s[i - 1] == '#') { result = "No"; } } } else { bool flag = false; for (int i = a + 2; i < c; i++) { if (s[i] == '#' && s[i - 1] == '#') { result = "No"; } } for (int i = b + 1; i <= d + 1; i++) { if (s[i] == '.' && s[i - 1] == '.' && s[i - 2] == '.') { flag = true; } } if (!flag) { result = "No"; } } cout << result; return 0; }
[ "literal.number.change", "control_flow.loop.for.initializer.change", "expression.operation.binary.change", "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "misc.off_by_one" ]
830,828
830,826
u085367022
cpp
p03017
#include <iostream> using namespace std; int main() { int n, a, b, c, d; string s; cin >> n >> a >> b >> c >> d >> s; a--; b--; c--; d--; string result = "Yes"; if (c < d) { for (int i = a + 2; i < d; i++) { if (s[i] == '#' && s[i - 1] == '#') { result = "No"; } } } else { bool flag = false; for (int i = a + 2; i < c; i++) { if (s[i] == '#' && s[i - 1] == '#') { result = "No"; } } for (int i = b + 3; i < d; i++) { if (s[i] == '.' && s[i - 1] == '.' && s[i - 2] == '.') { flag = true; } } if (!flag) { result = "No"; } } cout << result; return 0; }
#include <iostream> using namespace std; int main() { int n, a, b, c, d; string s; cin >> n >> a >> b >> c >> d >> s; a--; b--; c--; d--; string result = "Yes"; if (c < d) { for (int i = a + 2; i < d; i++) { if (s[i] == '#' && s[i - 1] == '#') { result = "No"; } } } else { bool flag = false; for (int i = a + 2; i < c; i++) { if (s[i] == '#' && s[i - 1] == '#') { result = "No"; } } for (int i = b + 1; i <= d + 1; i++) { if (s[i] == '.' && s[i - 1] == '.' && s[i - 2] == '.') { flag = true; } } if (!flag) { result = "No"; } } cout << result; return 0; }
[ "literal.number.change", "control_flow.loop.for.initializer.change", "expression.operation.binary.change", "expression.operator.compare.change", "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "misc.off_by_one" ]
830,829
830,826
u085367022
cpp
p03017
#include <bits/stdc++.h> using namespace std; int main() { int N, A, B, C, D; cin >> N >> A >> B >> C >> D; A--; B--; C--; D--; string S; cin >> S; bool flag = true; if (D > C) { for (int i = B; i < D; i++) { if (S[i] == '#' && S[i + 1] == '#') { flag = false; } } for (int j = A; j < C; j++) { if (S[j] == '#' && S[j + 1] == '#') { flag = false; } } if (flag) { cout << "Yes" << endl; return 0; } } else { // C > D (!=) for (int i = B; i < D; i++) { if (S[i] == '#' && S[i + 1] == '#') { flag = false; } } bool f = false; for (int k = B; k < D - 1; k++) { if (S[k] == '.' && S[k + 1] == '.' && S[k + 2] == '.') { f = true; S[k + 1] = '#'; break; } } if (!f) { flag = false; } for (int j = A; j < C; j++) { if (S[j] == '#' && S[j + 1] == '#') { flag = false; } } if (flag) { cout << "Yes" << endl; return 0; } } cout << "No" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int N, A, B, C, D; cin >> N >> A >> B >> C >> D; A--; B--; C--; D--; string S; cin >> S; bool flag = true; if (D > C) { for (int i = B; i < D; i++) { if (S[i] == '#' && S[i + 1] == '#') { flag = false; } } for (int j = A; j < C; j++) { if (S[j] == '#' && S[j + 1] == '#') { flag = false; } } if (flag) { cout << "Yes" << endl; return 0; } } else { // C > D (!=) for (int i = B; i < D; i++) { if (S[i] == '#' && S[i + 1] == '#') { flag = false; } } bool f = false; for (int k = B - 1; k < D; k++) { if (S[k] == '.' && S[k + 1] == '.' && S[k + 2] == '.') { f = true; S[k + 1] = '#'; break; } } if (!f) { flag = false; } for (int j = A; j < C; j++) { if (S[j] == '#' && S[j + 1] == '#') { flag = false; } } if (flag) { cout << "Yes" << endl; return 0; } } cout << "No" << endl; return 0; }
[ "control_flow.loop.for.initializer.change", "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
830,832
830,833
u904123392
cpp
p03017
#include <bits/stdc++.h> using namespace std; int N, A, B, C, D; string S; void solve() { A--, B--, C--, D--; bool ok = true; for (int i = A + 1; ok && i <= C; ++i) { if (S[i] == '#' && S[i - 1] == '#') ok = false; } for (int i = B + 1; ok && i <= D; ++i) { if (S[i] == '#' && S[i - 1] == '#') ok = false; } if (ok && C > D) { // must contain 3 spaces or both B-1 and B+1 are spaces if (!(S[B - 1] == '.' && S[B + 1] == '.')) { bool f = false; for (int i = B + 2; !f && i <= D; ++i) { if (S[i] == '.' && S[i - 1] == '.' && S[i - 2] == '.') { f = true; } } ok = f; } } if (ok) cout << "Yes\n"; else cout << "No\n"; } int main() { cin >> N >> A >> B >> C >> D; cin >> S; solve(); return 0; }
#include <bits/stdc++.h> using namespace std; int N, A, B, C, D; string S; void solve() { A--, B--, C--, D--; bool ok = true; for (int i = A + 1; ok && i <= C; ++i) { if (S[i] == '#' && S[i - 1] == '#') ok = false; } for (int i = B + 1; ok && i <= D; ++i) { if (S[i] == '#' && S[i - 1] == '#') ok = false; } if (ok && C > D) { // must contain 3 spaces or both B-1 and B+1 are spaces if (!(S[B - 1] == '.' && S[B + 1] == '.')) { bool f = false; for (int i = B; !f && i <= D; ++i) { if (S[i] == '.' && S[i - 1] == '.' && S[i + 1] == '.') { f = true; } } ok = f; } } if (ok) cout << "Yes\n"; else cout << "No\n"; } int main() { cin >> N >> A >> B >> C >> D; cin >> S; solve(); return 0; }
[ "control_flow.loop.for.initializer.change", "expression.operation.binary.remove", "control_flow.loop.for.condition.change" ]
830,834
830,835
u570770016
cpp
p03017
/* гонфлад */ #pragma ARCENIY_KIRILLOV_UVIDEL_KROKODILOV //#pragma comment(linker, "/stack:200000000") //#pragma GCC optimize("Ofast") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //#pragma GCC optimize("no-stack-protector") //#pragma GCC push_options //#pragma GCC optimize ("unroll-loops") //#pragma GCC pop_options #include <bits/stdc++.h> #define fi first #define se second #define pb push_back #define eb emplace_back #define rng(a) a.begin(), a.end() #define fast \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) using namespace std; typedef long long ll; main() { int n, a, b, c, d; cin >> n >> a >> b >> c >> d; string s; cin >> s; for (int i = 0; i < n - 1; i++) { if (s[i] == '#' && s[i + 1] == '#') { if ((a < i + 1 && i + 1 < c) || (b < i + 1 && i + 1 < d)) { cout << "No"; return 0; } } } if (c > d) { for (int i = min(b - 2, 0); i < d - 2; i++) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { cout << "Yes"; return 0; } } cout << "No"; return 0; } cout << "Yes"; return 0; }
/* гонфлад */ #pragma ARCENIY_KIRILLOV_UVIDEL_KROKODILOV //#pragma comment(linker, "/stack:200000000") //#pragma GCC optimize("Ofast") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //#pragma GCC optimize("no-stack-protector") //#pragma GCC push_options //#pragma GCC optimize ("unroll-loops") //#pragma GCC pop_options #include <bits/stdc++.h> #define fi first #define se second #define pb push_back #define eb emplace_back #define rng(a) a.begin(), a.end() #define fast \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) using namespace std; typedef long long ll; main() { int n, a, b, c, d; cin >> n >> a >> b >> c >> d; string s; cin >> s; for (int i = 0; i < n - 1; i++) { if (s[i] == '#' && s[i + 1] == '#') { if ((a < i + 1 && i + 1 < c) || (b < i + 1 && i + 1 < d)) { cout << "No"; return 0; } } } if (c > d) { for (int i = b - 2; i < d - 1; i++) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { cout << "Yes"; return 0; } } cout << "No"; return 0; } cout << "Yes"; return 0; }
[ "control_flow.loop.for.initializer.change", "call.remove", "call.arguments.change", "literal.number.change", "control_flow.branch.if.condition.change" ]
830,843
830,844
u122149278
cpp
p03017
/* гонфлад */ #pragma ARCENIY_KIRILLOV_UVIDEL_KROKODILOV //#pragma comment(linker, "/stack:200000000") //#pragma GCC optimize("Ofast") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //#pragma GCC optimize("no-stack-protector") //#pragma GCC push_options //#pragma GCC optimize ("unroll-loops") //#pragma GCC pop_options #include <bits/stdc++.h> #define fi first #define se second #define pb push_back #define eb emplace_back #define rng(a) a.begin(), a.end() #define fast \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) using namespace std; typedef long long ll; main() { int n, a, b, c, d; cin >> n >> a >> b >> c >> d; string s; cin >> s; for (int i = 0; i < n - 1; i++) { if (s[i] == '#' && s[i + 1] == '#') { if ((a < i + 1 && i + 1 < c) || (b < i + 1 && i + 1 < d)) { cout << "No"; return 0; } } } if (c > d) { for (int i = min(b - 2, 0); i < d - 1; i++) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { cout << "Yes"; return 0; } } cout << "No"; return 0; } cout << "Yes"; return 0; }
/* гонфлад */ #pragma ARCENIY_KIRILLOV_UVIDEL_KROKODILOV //#pragma comment(linker, "/stack:200000000") //#pragma GCC optimize("Ofast") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //#pragma GCC optimize("no-stack-protector") //#pragma GCC push_options //#pragma GCC optimize ("unroll-loops") //#pragma GCC pop_options #include <bits/stdc++.h> #define fi first #define se second #define pb push_back #define eb emplace_back #define rng(a) a.begin(), a.end() #define fast \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) using namespace std; typedef long long ll; main() { int n, a, b, c, d; cin >> n >> a >> b >> c >> d; string s; cin >> s; for (int i = 0; i < n - 1; i++) { if (s[i] == '#' && s[i + 1] == '#') { if ((a < i + 1 && i + 1 < c) || (b < i + 1 && i + 1 < d)) { cout << "No"; return 0; } } } if (c > d) { for (int i = b - 2; i < d - 1; i++) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { cout << "Yes"; return 0; } } cout << "No"; return 0; } cout << "Yes"; return 0; }
[ "control_flow.loop.for.initializer.change", "call.remove", "call.arguments.change" ]
830,845
830,844
u122149278
cpp
p03017
#include <algorithm> #include <bitset> #include <cmath> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <string> #include <vector> #define rep(i, s, n) for (int i = s; i < n; i++) #define repe(i, s, n) for (int i = s; i <= n; i++) #define rep_r(i, s, n) for (int i = n - 1; i >= 0; i--) #define rep_re(i, s, n) for (int i = n; i >= 0; i--) using namespace std; typedef long long ll; static const ll MOD = 1e9 + 7; static const ll INF = 1e25; static const ll MAX_M = 100001; int main() { ll n, a, b, c, d; cin >> n >> a >> b >> c >> d; a--; b--; c--; d--; string s; cin >> s; rep(i, b + 1, d) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } } rep(i, a + 1, c) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } } if (c < d) { cout << "Yes" << endl; return 0; } else { bool three = false; rep(i, b + 1, d) { if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') { three = true; } } cout << (three ? "Yes" : "No") << endl; return 0; } return 0; }
#include <algorithm> #include <bitset> #include <cmath> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <string> #include <vector> #define rep(i, s, n) for (int i = s; i < n; i++) #define repe(i, s, n) for (int i = s; i <= n; i++) #define rep_r(i, s, n) for (int i = n - 1; i >= 0; i--) #define rep_re(i, s, n) for (int i = n; i >= 0; i--) using namespace std; typedef long long ll; static const ll MOD = 1e9 + 7; static const ll INF = 1e25; static const ll MAX_M = 100001; int main() { ll n, a, b, c, d; cin >> n >> a >> b >> c >> d; a--; b--; c--; d--; string s; cin >> s; rep(i, b + 1, d) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } } rep(i, a + 1, c) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } } if (c < d) { cout << "Yes" << endl; return 0; } else { bool three = false; repe(i, b, d) { if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') { three = true; } } cout << (three ? "Yes" : "No") << endl; return 0; } return 0; }
[ "expression.operation.binary.remove" ]
830,848
830,849
u685009987
cpp
p03017
#include "bits/stdc++.h" #define pb push_back #define pob pop_back #define pf push_front #define pof pop_front #define eb emplace_back #define rep(i, a, b) for (long i = (a); i <= (b); ++i) #define per(i, a, b) for (long i = (a); i >= (b); --i) #define mmst(v) memset(v, 0, sizeof(v)) const long kMax2 = 109; const long kMax3 = 1009; const long kMax4 = 10009; const long kMax5 = 100009; const long kMax6 = 1000009; const long kInfI = 0x3F3F3F3F; const float kInfF = 1e15; const long kMAX = 1000000000; using namespace std; using ll = long long; inline int readInt() { char c = getchar(); while (!isdigit(c) && c != '-') c = getchar(); int sigma = 1; if (c == '-') { sigma = -1; c = getchar(); } int x = 0; while (isdigit(c)) { x = x * 10 + c - '0'; c = getchar(); } return x * sigma; } int main() { cin.tie(0); ios::sync_with_stdio(0); int n, a, b, c, d; string s; cin >> n >> a >> b >> c >> d >> s; --a; --b; --c; --d; bool ans = true; rep(i, a, c - 2) { if (s[i] == '#' && s[i + 1] == '#') ans = false; } rep(i, b, d - 2) { if (s[i] == '#' && s[i + 1] == '#') ans = false; } if (c > d) { ans = false; rep(i, b, d) { if (s[i] == '.' && s[i - 1] == '.' && s[i + 1] == '.') { ans = true; break; } } } if (ans) { cout << "YES\n"; } else { cout << "NO\n"; } return 0; }
#include "bits/stdc++.h" #define pb push_back #define pob pop_back #define pf push_front #define pof pop_front #define eb emplace_back #define rep(i, a, b) for (long i = (a); i <= (b); ++i) #define per(i, a, b) for (long i = (a); i >= (b); --i) #define mmst(v) memset(v, 0, sizeof(v)) const long kMax2 = 109; const long kMax3 = 1009; const long kMax4 = 10009; const long kMax5 = 100009; const long kMax6 = 1000009; const long kInfI = 0x3F3F3F3F; const float kInfF = 1e15; const long kMAX = 1000000000; using namespace std; using ll = long long; inline int readInt() { char c = getchar(); while (!isdigit(c) && c != '-') c = getchar(); int sigma = 1; if (c == '-') { sigma = -1; c = getchar(); } int x = 0; while (isdigit(c)) { x = x * 10 + c - '0'; c = getchar(); } return x * sigma; } int main() { cin.tie(0); ios::sync_with_stdio(0); int n, a, b, c, d; string s; cin >> n >> a >> b >> c >> d >> s; --a; --b; --c; --d; bool ans = true; rep(i, a, c - 2) { if (s[i] == '#' && s[i + 1] == '#') ans = false; } rep(i, b, d - 2) { if (s[i] == '#' && s[i + 1] == '#') ans = false; } if (c > d) { ans = false; rep(i, b, d) { if (s[i] == '.' && s[i - 1] == '.' && s[i + 1] == '.') { ans = true; break; } } } if (ans) { cout << "Yes\n"; } else { cout << "No\n"; } return 0; }
[ "literal.string.change", "literal.string.case.change", "io.output.change" ]
830,852
830,853
u449221649
cpp
p03017
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; const int mod = 1000000007; int main() { ios::sync_with_stdio(false); int n, a, b, c, d; string s; cin >> n >> a >> b >> c >> d >> s; s = '#' + s + '#'; if (c < d) { for (int i = a; i < d; i++) if (s[i] == '#' && s[i + 1] == '#') { cout << "No"; return 0; } cout << "Yes"; } else { bool y = 0; for (int i = b; i < d; i++) if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') y = 1; for (int i = a; i < c; i++) if (s[i] == '#' && s[i + 1] == '#') y = 0; if (y) cout << "Yes"; else cout << "No"; } }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; const int mod = 1000000007; int main() { ios::sync_with_stdio(false); int n, a, b, c, d; string s; cin >> n >> a >> b >> c >> d >> s; s = '#' + s + '#'; if (c < d) { for (int i = a; i < d; i++) if (s[i] == '#' && s[i + 1] == '#') { cout << "No"; return 0; } cout << "Yes"; } else { bool y = 0; for (int i = b; i <= d; i++) if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') y = 1; for (int i = a; i < c; i++) if (s[i] == '#' && s[i + 1] == '#') y = 0; if (y) cout << "Yes"; else cout << "No"; } }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
830,861
830,862
u151855078
cpp
p03017
#include "bits/stdc++.h" using namespace std; using ll = long long; using ld = long double; using P = pair<int, int>; constexpr ld EPS = 1e-12; constexpr int INF = numeric_limits<int>::max() / 2; constexpr int MOD = 1e9 + 7; template <typename T> void printv(const vector<T> &v) { int sz = v.size(); for (int i = 0; i < sz; i++) { cout << v[i] << " \n"[i == sz - 1]; } } int main() { cin.tie(0); ios::sync_with_stdio(false); int n, a, b, c, d; // a<b && a<c && b<d cin >> n >> a >> b >> c >> d; string s; cin >> s; a--; b--; c--; d--; bool f = true; for (int i = a + 1; i < c - 1; i++) { if (s[i] == '#' && s[i + 1] == '#') f = false; } for (int i = b + 1; i < d - 1; i++) { if (s[i] == '#' && s[i + 1] == '#') f = false; } if (d < c) { bool check = false; for (int i = max(1, b); i <= d; i++) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') check = true; } if (!check) f = false; } cout << (f ? "Yes" : "No") << endl; }
#include "bits/stdc++.h" using namespace std; using ll = long long; using ld = long double; using P = pair<int, int>; constexpr ld EPS = 1e-12; constexpr int INF = numeric_limits<int>::max() / 2; constexpr int MOD = 1e9 + 7; template <typename T> void printv(const vector<T> &v) { int sz = v.size(); for (int i = 0; i < sz; i++) { cout << v[i] << " \n"[i == sz - 1]; } } int main() { cin.tie(0); ios::sync_with_stdio(false); int n, a, b, c, d; // a<b && a<c && b<d cin >> n >> a >> b >> c >> d; string s; cin >> s; a--; b--; c--; d--; bool f = true; for (int i = a + 1; i < c - 1; i++) { if (s[i] == '#' && s[i + 1] == '#') f = false; } for (int i = b + 1; i < d - 1; i++) { if (s[i] == '#' && s[i + 1] == '#') f = false; } if (d < c) { bool check = false; for (int i = max(1, b); i <= d; i++) { if (s[i] == '.' && s[i + 1] == '.' && s[i - 1] == '.') check = true; } if (!check) f = false; } cout << (f ? "Yes" : "No") << endl; }
[ "control_flow.loop.for.condition.change" ]
830,873
830,874
u968834127
cpp
p03017
#include <iostream> using namespace std; int main() { int N, A, B, C, D; string S; cin >> N >> A >> B >> C >> D >> S; S = "#" + S + "#"; auto can_reach = [&](int start, int end) { for (int i = start; i + 1 <= end; ++i) { if (S[i] == '#' && S[i + 1] == '#') return false; } return true; }; if (!can_reach(A, C) || !can_reach(B, D)) { cout << "No" << endl; return 0; } if (C > D) { bool snuke_can_over = false; for (int i = B; i <= D; ++i) { if (S[i - 1] = '.' && S[i] == '.' && S[i + 1] == '.') { snuke_can_over = true; } } if (!snuke_can_over) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; return 0; }
#include <iostream> using namespace std; int main() { int N, A, B, C, D; string S; cin >> N >> A >> B >> C >> D >> S; S = "#" + S + "#"; auto can_reach = [&](int start, int end) { for (int i = start; i + 1 <= end; i++) { if (S[i] == '#' && S[i + 1] == '#') return false; } return true; }; if (!can_reach(A, C) || !can_reach(B, D)) { cout << "No" << endl; return 0; } if (C > D) { bool snuke_can_over = false; for (int i = B; i <= D; i++) { if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') { snuke_can_over = true; } } if (!snuke_can_over) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; return 0; }
[ "expression.operation.compare.replace.add", "assignment.replace.remove", "misc.typo" ]
830,886
830,887
u625893557
cpp
p03017
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) int main() { int n, a, b, c, d; cin >> n >> a >> b >> c >> d; string s; cin >> s; string ans = "Yes"; bool flag = true; for (int i = a - 1; i < max(c, d) - 1; i++) { if (s[i] == '#' && s[i + 1] == '#') { ans = "No"; break; } if (c > d && i >= b - 2 && i < d - 2 && flag) { ans = "No"; if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { ans = "Yes"; flag = false; } } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) int main() { int n, a, b, c, d; cin >> n >> a >> b >> c >> d; string s; cin >> s; string ans = "Yes"; bool flag = true; for (int i = a - 1; i < max(c, d) - 1; i++) { if (s[i] == '#' && s[i + 1] == '#') { ans = "No"; break; } if (c > d && i >= b - 2 && i < d - 1 && flag) { ans = "No"; if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { ans = "Yes"; flag = false; } } } cout << ans << endl; }
[ "literal.number.change", "control_flow.branch.if.condition.change" ]
830,896
830,897
u190679129
cpp
p03017
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) int main() { int n, a, b, c, d; cin >> n >> a >> b >> c >> d; string s; cin >> s; string ans = "Yes"; bool flag = true; for (int i = a - 1; i < max(c, d) - 1; i++) { if (s[i] == '#' && s[i + 1] == '#') { ans = "No"; break; } if (c > d && i >= b - 1 && i < n - 2 && flag) { ans = "No"; if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { ans = "Yes"; flag = false; } } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) int main() { int n, a, b, c, d; cin >> n >> a >> b >> c >> d; string s; cin >> s; string ans = "Yes"; bool flag = true; for (int i = a - 1; i < max(c, d) - 1; i++) { if (s[i] == '#' && s[i + 1] == '#') { ans = "No"; break; } if (c > d && i >= b - 2 && i < d - 1 && flag) { ans = "No"; if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { ans = "Yes"; flag = false; } } } cout << ans << endl; }
[ "literal.number.change", "control_flow.branch.if.condition.change", "identifier.change" ]
830,898
830,897
u190679129
cpp
p03017
// agc034_a.cpp // Sat Aug 3 16:42:25 2019 #include <algorithm> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <string> #include <unordered_map> #include <vector> #define INTINF 2147483647 #define LLINF 9223372036854775807 using namespace std; using ll = long long; typedef pair<int, int> P; int main() { int n, a, b, c, d; cin >> n >> a >> b >> c >> d; string s; cin >> s; vector<P> three; vector<P> kabe; for (int i = 0; i < s.size() - 2; i++) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { three.push_back(make_pair(i + 1, i + 3)); } else if (s[i] == '#' && s[i + 1] == '#') { kabe.push_back(make_pair(i + 1, i + 2)); } } if (c < d) { for (int i = 0; i < kabe.size(); i++) { if (kabe[i].first > a && kabe[i].first < d) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; } else { for (int i = 0; i < kabe.size(); i++) { if (kabe[i].first > a && kabe[i].first < c) { cout << "No" << endl; return 0; } } int flag = 0; for (int i = 0; i < three.size(); i++) { if (three[i].first >= b - 1 && three[i].first < c) { flag = 1; } } if (flag) { cout << "Yes" << endl; } else { cout << "No" << endl; } } }
// agc034_a.cpp // Sat Aug 3 16:42:25 2019 #include <algorithm> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <string> #include <unordered_map> #include <vector> #define INTINF 2147483647 #define LLINF 9223372036854775807 using namespace std; using ll = long long; typedef pair<int, int> P; int main() { int n, a, b, c, d; cin >> n >> a >> b >> c >> d; string s; cin >> s; vector<P> three; vector<P> kabe; for (int i = 0; i < s.size() - 2; i++) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { three.push_back(make_pair(i + 1, i + 3)); } else if (s[i] == '#' && s[i + 1] == '#') { kabe.push_back(make_pair(i + 1, i + 2)); } } if (c < d) { for (int i = 0; i < kabe.size(); i++) { if (kabe[i].first > a && kabe[i].first < d) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; } else { for (int i = 0; i < kabe.size(); i++) { if (kabe[i].first > a && kabe[i].first < c) { cout << "No" << endl; return 0; } } int flag = 0; for (int i = 0; i < three.size(); i++) { if (three[i].first >= b - 1 && three[i].first < d) { flag = 1; } } if (flag) { cout << "Yes" << endl; } else { cout << "No" << endl; } } }
[ "identifier.change", "control_flow.branch.if.condition.change" ]
830,899
830,900
u628871447
cpp
p03017
#include <algorithm> #include <fstream> #include <iostream> #include <vector> using namespace std; typedef long long ll; int main(int argc, const char *argv[]) { cin.tie(0); ios::sync_with_stdio(false); ll n, a, b, c, d; cin >> n >> a >> b >> c >> d; --a; --b; --c; --d; string s; cin >> s; vector<ll> obstacle; vector<ll> room; for (ll i = 0; i < n; i++) { if (i < n - 1 && s[i] == '#' && s[i + 1] == '#') obstacle.push_back(i); if (i < n - 2 && s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') room.push_back(i); } auto itr1 = lower_bound(obstacle.begin(), obstacle.end(), a); if (c < d) { if (itr1 == obstacle.end() || *itr1 > d) { cout << "Yes" << endl; return 0; } } else { if (itr1 == obstacle.end() || *itr1 > c) { auto itr2 = lower_bound(room.begin(), room.end(), b - 2); if (itr2 != room.end() && *itr2 < d) { cout << "Yes" << endl; return 0; } } } cout << "No" << endl; return 0; }
#include <algorithm> #include <fstream> #include <iostream> #include <vector> using namespace std; typedef long long ll; int main(int argc, const char *argv[]) { cin.tie(0); ios::sync_with_stdio(false); ll n, a, b, c, d; cin >> n >> a >> b >> c >> d; --a; --b; --c; --d; string s; cin >> s; vector<ll> obstacle; vector<ll> room; for (ll i = 0; i < n; i++) { if (i < n - 1 && s[i] == '#' && s[i + 1] == '#') obstacle.push_back(i); if (i < n - 2 && s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') room.push_back(i); } auto itr1 = lower_bound(obstacle.begin(), obstacle.end(), a); if (c < d) { if ((itr1 == obstacle.end() || *itr1 > d)) { cout << "Yes" << endl; return 0; } } else { if (itr1 == obstacle.end() || *itr1 > c) { auto itr3 = lower_bound(room.begin(), room.end(), b - 1); if (itr3 != room.end() && *itr3 < d) { cout << "Yes" << endl; return 0; } } } cout << "No" << endl; return 0; }
[ "control_flow.branch.if.condition.change", "variable_declaration.name.change", "identifier.change", "literal.number.change", "call.arguments.change", "expression.operation.binary.change" ]
830,901
830,902
u906651641
cpp
p03017
#include <algorithm> #include <fstream> #include <iostream> #include <vector> using namespace std; typedef long long ll; int main(int argc, const char *argv[]) { cin.tie(0); ios::sync_with_stdio(false); ll n, a, b, c, d; cin >> n >> a >> b >> c >> d; --a; --b; --c; --d; string s; cin >> s; vector<ll> obstacle; vector<ll> room; for (ll i = 0; i < n; i++) { if (i < n - 1 && s[i] == '#' && s[i + 1] == '#') obstacle.push_back(i); if (i < n - 2 && s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') room.push_back(i); } auto itr1 = lower_bound(obstacle.begin(), obstacle.end(), a); auto itr2 = lower_bound(obstacle.begin(), obstacle.end(), b); if (c < d) { if ((itr1 == obstacle.end() || *itr1 > c) && (itr2 == obstacle.end() || *itr2 > d)) { cout << "Yes" << endl; return 0; } } else { if (itr1 == obstacle.end() || *itr1 > c) { auto itr3 = lower_bound(room.begin(), room.end(), b - 2); if (itr3 != room.end() && *itr3 < d) { cout << "Yes" << endl; return 0; } } } cout << "No" << endl; return 0; }
#include <algorithm> #include <fstream> #include <iostream> #include <vector> using namespace std; typedef long long ll; int main(int argc, const char *argv[]) { cin.tie(0); ios::sync_with_stdio(false); ll n, a, b, c, d; cin >> n >> a >> b >> c >> d; --a; --b; --c; --d; string s; cin >> s; vector<ll> obstacle; vector<ll> room; for (ll i = 0; i < n; i++) { if (i < n - 1 && s[i] == '#' && s[i + 1] == '#') obstacle.push_back(i); if (i < n - 2 && s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') room.push_back(i); } auto itr1 = lower_bound(obstacle.begin(), obstacle.end(), a); auto itr2 = lower_bound(obstacle.begin(), obstacle.end(), b); if (c < d) { if ((itr1 == obstacle.end() || *itr1 > c) && (itr2 == obstacle.end() || *itr2 > d)) { cout << "Yes" << endl; return 0; } } else { if (itr1 == obstacle.end() || *itr1 > c) { auto itr3 = lower_bound(room.begin(), room.end(), b - 1); if (itr3 != room.end() && *itr3 < d) { cout << "Yes" << endl; return 0; } } } cout << "No" << endl; return 0; }
[ "literal.number.change", "call.arguments.change", "expression.operation.binary.change" ]
830,903
830,904
u906651641
cpp
p03017
#include <bits/stdc++.h> using namespace std; #define int long long #define sz(x) (int)(x.size()) signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, a, b, c, d; string s; cin >> n >> a >> b >> c >> d >> s; s = " " + s; bool ans = true; for (int i = b + 1; i < d; i++) { if (s[i] == '#' && s[i - 1] == '#') ans = false; } for (int i = a + 1; i < c; i++) { if (s[i] == '#' && s[i - 1] == '#') ans = false; } if (c > d) { bool flag = false; for (int i = b; i < c; i++) { if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') flag = true; } ans &= flag; } if (ans) cout << "Yes\n"; else cout << "No\n"; }
#include <bits/stdc++.h> using namespace std; #define int long long #define sz(x) (int)(x.size()) signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, a, b, c, d; string s; cin >> n >> a >> b >> c >> d >> s; s = " " + s; bool ans = true; for (int i = b + 1; i < d; i++) { if (s[i] == '#' && s[i - 1] == '#') ans = false; } for (int i = a + 1; i < c; i++) { if (s[i] == '#' && s[i - 1] == '#') ans = false; } if (c > d) { bool flag = false; for (int i = b; i <= d; i++) { if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') flag = true; } ans &= flag; } if (ans) cout << "Yes\n"; else cout << "No\n"; }
[ "control_flow.loop.for.condition.change" ]
830,916
830,917
u590725538
cpp
p03017
#include <bits/stdc++.h> using namespace std; int N, A, B, C, D; string S; int main() { cin >> N >> A >> B >> C >> D; cin >> S; A--; B--; C--; D--; bool flag = false; if (D < C) { for (int i = B; i < D; i++) { if (S[i] == '#' && S[i + 1] == '#') flag = true; } bool flag2 = false; for (int i = B; i < D - 1; i++) { if (S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.') flag2 = true; } if (!flag2) flag = true; for (int i = A; i < C; i++) { if (S[i] == '#' && S[i + 1] == '#') flag = true; } } else { for (int i = B; i < D; i++) { if (S[i] == '#' && S[i + 1] == '#') flag = true; } for (int i = A; i < C; i++) { if (S[i] == '#' && S[i + 1] == '#') flag = true; } } if (flag) cout << "N0" << endl; else cout << "Yes" << endl; }
#include <bits/stdc++.h> using namespace std; int N, A, B, C, D; string S; int main() { cin >> N >> A >> B >> C >> D; cin >> S; A--; B--; C--; D--; bool flag = false; if (D < C) { for (int i = B; i < D; i++) { if (S[i] == '#' && S[i + 1] == '#') flag = true; } bool flag2 = false; for (int i = B - 1; i < D; i++) { if (S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.') flag2 = true; } if (!flag2) flag = true; for (int i = A; i < C; i++) { if (S[i] == '#' && S[i + 1] == '#') flag = true; } } else { for (int i = B; i < D; i++) { if (S[i] == '#' && S[i + 1] == '#') flag = true; } for (int i = A; i < C; i++) { if (S[i] == '#' && S[i + 1] == '#') flag = true; } } if (flag) cout << "No" << endl; else cout << "Yes" << endl; }
[ "control_flow.loop.for.initializer.change", "control_flow.loop.for.condition.change", "expression.operation.binary.remove", "literal.string.change", "io.output.change" ]
830,926
830,925
u205655980
cpp
p03017
#include <algorithm> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <utility> #include <vector> using namespace std; using ll = long long; template <class T> using V = vector<T>; template <class T, class U> using P = pair<T, U>; using vll = V<ll>; using vvll = V<vll>; #define rep(i, k, n) for (ll i = k; i < (ll)n; ++i) #define REP(i, n) rep(i, 0, n) template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } const ll MOD = 1000000007; const ll HIGHINF = (ll)1e18; int main() { ll n, a, b, c, d; cin >> n >> a >> b >> c >> d; string s; cin >> s; for (ll i = a - 1; i < max(c, d) - 2; i++) if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } if (c < d) cout << "Yes" << endl; else { for (ll i = a; i < c - 1; i++) if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') { cout << "Yes" << endl; return 0; } cout << "No" << endl; } return 0; }
#include <algorithm> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <utility> #include <vector> using namespace std; using ll = long long; template <class T> using V = vector<T>; template <class T, class U> using P = pair<T, U>; using vll = V<ll>; using vvll = V<vll>; #define rep(i, k, n) for (ll i = k; i < (ll)n; ++i) #define REP(i, n) rep(i, 0, n) template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } const ll MOD = 1000000007; const ll HIGHINF = (ll)1e18; int main() { ll n, a, b, c, d; cin >> n >> a >> b >> c >> d; string s; cin >> s; for (ll i = a - 1; i < max(c, d) - 2; i++) if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } if (c < d) cout << "Yes" << endl; else { for (ll i = b - 1; i < d; i++) if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') { cout << "Yes" << endl; return 0; } cout << "No" << endl; } return 0; }
[ "control_flow.loop.for.initializer.change", "identifier.change", "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
830,934
830,935
u077337864
cpp
p03017
#include <algorithm> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <utility> #include <vector> using namespace std; using ll = long long; template <class T> using V = vector<T>; template <class T, class U> using P = pair<T, U>; using vll = V<ll>; using vvll = V<vll>; #define rep(i, k, n) for (ll i = k; i < (ll)n; ++i) #define REP(i, n) rep(i, 0, n) template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } const ll MOD = 1000000007; const ll HIGHINF = (ll)1e18; int main() { ll n, a, b, c, d; cin >> n >> a >> b >> c >> d; string s; cin >> s; for (ll i = a - 1; i < max(c, d) - 2; i++) if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } if (c < d) cout << "Yes" << endl; else { for (ll i = a; i < c - 2; i++) if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') { cout << "Yes" << endl; return 0; } cout << "No" << endl; } return 0; }
#include <algorithm> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <utility> #include <vector> using namespace std; using ll = long long; template <class T> using V = vector<T>; template <class T, class U> using P = pair<T, U>; using vll = V<ll>; using vvll = V<vll>; #define rep(i, k, n) for (ll i = k; i < (ll)n; ++i) #define REP(i, n) rep(i, 0, n) template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } const ll MOD = 1000000007; const ll HIGHINF = (ll)1e18; int main() { ll n, a, b, c, d; cin >> n >> a >> b >> c >> d; string s; cin >> s; for (ll i = a - 1; i < max(c, d) - 2; i++) if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } if (c < d) cout << "Yes" << endl; else { for (ll i = b - 1; i < d; i++) if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') { cout << "Yes" << endl; return 0; } cout << "No" << endl; } return 0; }
[ "control_flow.loop.for.initializer.change", "identifier.change", "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
830,936
830,935
u077337864
cpp
p03017
#include <bits/stdc++.h> using namespace std; int main() { int N, A, B, C, D; cin >> N >> A >> B >> C >> D; --A, --B, --C, --D; string S; cin >> S; for (int i{A + 1}; i < max(C, D); ++i) { if (S[i] == '#' && S[i + 1] == '#') { cout << "No" << endl; return 0; } } if (C > D) { S.append("#"); for (int i{A + 1}; i <= D; ++i) { if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') { cout << "Yes" << endl; return 0; } } cout << "No" << endl; return 0; } cout << "Yes" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int N, A, B, C, D; cin >> N >> A >> B >> C >> D; --A, --B, --C, --D; string S; cin >> S; for (int i{A + 1}; i < max(C, D); ++i) { if (S[i] == '#' && S[i + 1] == '#') { cout << "No" << endl; return 0; } } if (C > D) { S.append("#"); for (int i{B}; i <= D; ++i) { if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') { cout << "Yes" << endl; return 0; } } cout << "No" << endl; return 0; } cout << "Yes" << endl; return 0; }
[ "control_flow.loop.for.initializer.change", "expression.operation.binary.change", "expression.operation.binary.remove" ]
830,944
830,945
u154289649
cpp
p03017
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <queue> using namespace std; typedef pair<int, int> P; const int maxn = 1e5 + 10; char s[maxn * 2]; int main() { int n, a, b, c, d; cin >> n; cin >> a >> b >> c >> d; scanf("%s", s + 1); int len = strlen(s + 1); int f = 1; for (int i = min(a, b); i <= max(d, c); i++) { if (s[i] == '#' && s[i + 1] == '#') f = 0; } if (s[c] == '#' || s[d] == '#' || f == 0) puts("No"); else if ((a < b && c < d) || (b < a && d < c)) puts("Yes"); else { int flag = 0; for (int i = max(a, b); i <= max(c, d) + 1; i++) { if (s[i] == s[i - 1] && s[i] == s[i + 1] && s[i] == '.') flag = 1; } if (flag) puts("Yes"); else puts("No"); } return 0; }
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <queue> using namespace std; typedef pair<int, int> P; const int maxn = 1e5 + 10; char s[maxn * 2]; int main() { int n, a, b, c, d; cin >> n; cin >> a >> b >> c >> d; scanf("%s", s + 1); int len = strlen(s + 1); int f = 1; for (int i = min(a, b); i <= max(d, c); i++) { if (s[i] == '#' && s[i + 1] == '#') f = 0; } if (s[c] == '#' || s[d] == '#' || f == 0) puts("No"); else if ((a < b && c < d) || (b < a && d < c)) puts("Yes"); else { int flag = 0; for (int i = max(a, b); i <= min(c, d); i++) { if (s[i] == s[i - 1] && s[i] == s[i + 1] && s[i] == '.') flag = 1; } if (flag) puts("Yes"); else puts("No"); } return 0; }
[ "misc.opposites", "identifier.change", "call.function.change", "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
830,951
830,952
u914135866
cpp
p03017
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <queue> using namespace std; typedef pair<int, int> P; const int maxn = 1e5 + 10; char s[maxn * 2]; int main() { int n, a, b, c, d; cin >> n; cin >> a >> b >> c >> d; scanf("%s", s + 1); int len = strlen(s + 1); int f = 1; for (int i = min(a, b); i <= max(d, c); i++) { if (s[i] == '#' && s[i + 1] == '#') f = 0; } if (s[c] == '#' || s[d] == '#' || f == 0) puts("No"); else if ((a < b && c < d) || (b < a && d < c)) puts("Yes"); else { int flag = 0; for (int i = max(a, b); i <= min(c, d) + 1; i++) { if (s[i] == s[i - 1] && s[i] == s[i + 1] && s[i] == '.') flag = 1; } if (flag) puts("Yes"); else puts("No"); } return 0; }
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <queue> using namespace std; typedef pair<int, int> P; const int maxn = 1e5 + 10; char s[maxn * 2]; int main() { int n, a, b, c, d; cin >> n; cin >> a >> b >> c >> d; scanf("%s", s + 1); int len = strlen(s + 1); int f = 1; for (int i = min(a, b); i <= max(d, c); i++) { if (s[i] == '#' && s[i + 1] == '#') f = 0; } if (s[c] == '#' || s[d] == '#' || f == 0) puts("No"); else if ((a < b && c < d) || (b < a && d < c)) puts("Yes"); else { int flag = 0; for (int i = max(a, b); i <= min(c, d); i++) { if (s[i] == s[i - 1] && s[i] == s[i + 1] && s[i] == '.') flag = 1; } if (flag) puts("Yes"); else puts("No"); } return 0; }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
830,953
830,952
u914135866
cpp
p03017
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <queue> using namespace std; typedef pair<int, int> P; const int maxn = 1e5 + 10; char s[maxn * 2]; int main() { int n, a, b, c, d; cin >> n; cin >> a >> b >> c >> d; scanf("%s", s + 1); int len = strlen(s + 1); int f = 1; for (int i = min(a, b); i <= max(d, c); i++) { if (s[i] == '#' && s[i + 1] == '#') f = 0; } if (s[c] == '#' || s[d] == '#' || f == 0) puts("No"); else if ((a < b && c < d) || (b > a && d < c)) puts("Yes"); else { int flag = 0; for (int i = max(a, b); i <= min(c, d) + 1; i++) { if (s[i] == s[i - 1] && s[i] == s[i + 1] && s[i] == '.') flag = 1; } if (flag) puts("Yes"); else puts("No"); } return 0; }
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <queue> using namespace std; typedef pair<int, int> P; const int maxn = 1e5 + 10; char s[maxn * 2]; int main() { int n, a, b, c, d; cin >> n; cin >> a >> b >> c >> d; scanf("%s", s + 1); int len = strlen(s + 1); int f = 1; for (int i = min(a, b); i <= max(d, c); i++) { if (s[i] == '#' && s[i + 1] == '#') f = 0; } if (s[c] == '#' || s[d] == '#' || f == 0) puts("No"); else if ((a < b && c < d) || (b < a && d < c)) puts("Yes"); else { int flag = 0; for (int i = max(a, b); i <= min(c, d); i++) { if (s[i] == s[i - 1] && s[i] == s[i + 1] && s[i] == '.') flag = 1; } if (flag) puts("Yes"); else puts("No"); } return 0; }
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
830,954
830,952
u914135866
cpp
p03017
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10; char s[maxn]; int vis[maxn]; int n, a, b, c, d; int main() { scanf("%d%d%d%d%d", &n, &a, &b, &c, &d); scanf("%s", s + 1); // int len=strlen(s+1); // cout<<len<<endl; if (s[c] == '#' || s[d] == '#') puts("No"); else { if (a > b) swap(a, b), swap(c, d); int f1 = 0; for (int i = a; i <= max(c, d); i++) { if (s[i] == '#' && s[i - 1] == '#') { f1 = 1; break; } } if (f1) puts("No"); else { int f = 0; /* if(s[b-1]==s[b+1]&&s[b-1]=='.') f=1; for(int i=b+2; i<=d-1; i++) { if(s[i]=='.'&&s[i-1]=='.'&&s[i-2]=='.') f=1; }*/ if (c < d) puts("Yes"); /* else if(c>d&&f==1) puts("Yes");*/ else { int f = 0; for (int i = b + 2; i <= d + 1; i++) { if (s[i] == '.' && s[i - 1] == '.' && s[i - 2] == '.') f = 1; } // cout<<f; if (f) puts("Yes"); else puts("No"); } } } return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10; char s[maxn]; int vis[maxn]; int n, a, b, c, d; int main() { scanf("%d%d%d%d%d", &n, &a, &b, &c, &d); scanf("%s", s + 1); // int len=strlen(s+1); // cout<<len<<endl; if (s[c] == '#' || s[d] == '#') puts("No"); else { if (a > b) swap(a, b), swap(c, d); int f1 = 0; for (int i = a; i <= max(c, d); i++) { if (s[i] == '#' && s[i - 1] == '#') { f1 = 1; break; } } if (f1) puts("No"); else { if (c < d) puts("Yes"); else { int f = 0; for (int i = b + 1; i <= d + 1; i++) { if (s[i] == '.' && s[i - 1] == '.' && s[i - 2] == '.') f = 1; } if (f) puts("Yes"); else puts("No"); } } } return 0; }
[ "variable_declaration.remove", "literal.number.change", "control_flow.loop.for.initializer.change", "expression.off_by_one", "expression.operation.binary.change" ]
830,955
830,956
u914135866
cpp
p03017
#include <iostream> using namespace std; int main(void) { int n, a, b, c, d, x = 0, y = 0; bool f = true; string s; cin >> n >> a >> b >> c >> d >> s; for (int i = a; i < c; i++) { if (s[i] == '#' && s[i - 1] == '#') f = false; } for (int i = b; i < d; i++) { if (s[i] == '#' && s[i - 1] == '#') f = false; } if (!f) { cout << "No" << endl; return 0; } else if (c < d) { cout << "Yes" << endl; return 0; } for (int i = b - 1; i < d + 1; i++) { if (s[i] == '.') { y = max(y, ++x); } else { x = 0; } } if (y >= 3) { cout << "Yes" << endl; return 0; } else { cout << "No" << endl; return 0; } }
#include <iostream> using namespace std; int main(void) { int n, a, b, c, d, x = 0, y = 0; bool f = true; string s; cin >> n >> a >> b >> c >> d >> s; for (int i = a; i < c; i++) { if (s[i] == '#' && s[i - 1] == '#') f = false; } for (int i = b; i < d; i++) { if (s[i] == '#' && s[i - 1] == '#') f = false; } if (!f) { cout << "No" << endl; return 0; } else if (c < d) { cout << "Yes" << endl; return 0; } for (int i = b - 2; i < d + 1; i++) { if (s[i] == '.') { y = max(y, ++x); } else { x = 0; } } if (y >= 3) { cout << "Yes" << endl; return 0; } else { cout << "No" << endl; return 0; } }
[ "literal.number.change", "control_flow.loop.for.initializer.change", "expression.off_by_one", "expression.operation.binary.change" ]
830,958
830,959
u024809932
cpp
p03017
#include <algorithm> #include <iostream> #include <math.h> #include <string.h> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) long long int mod = 1e9 + 7; bool debug = false; typedef long long ll; bool check(string s, int a, int b) { bool jump = true; for (int i = a; i <= b; i++) { if (s[i] == '#') { if (jump) { jump = false; } else { return false; } } else { jump = true; } } return true; } bool check2(string s, int a, int b) { int cnt = 0; for (int i = a; i <= b; i++) { if (s[i] == '#') { cnt = 0; } else { cnt++; if (cnt >= 3) return true; } } return false; } int main() { int n, a, b, c, d; cin >> n >> a >> b >> c >> d; a--; b--; c--; d--; string s; cin >> s; if (c < d) { if (check(s, a, c) && check(s, b, d)) { cout << "Yes" << endl; } else { cout << "No" << endl; } } else { if (check(s, a, c) && check(s, b, d) && check2(s, b, d)) { cout << "Yes" << endl; } else { cout << "No" << endl; } } return 0; }
#include <algorithm> #include <iostream> #include <math.h> #include <string.h> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) long long int mod = 1e9 + 7; bool debug = false; typedef long long ll; bool check(string s, int a, int b) { bool jump = true; for (int i = a; i <= b; i++) { if (s[i] == '#') { if (jump) { jump = false; } else { return false; } } else { jump = true; } } return true; } bool check2(string s, int a, int b) { int cnt = 0; for (int i = a; i <= b; i++) { if (s[i] == '#') { cnt = 0; } else { cnt++; if (cnt >= 3) return true; } } return false; } int main() { int n, a, b, c, d; cin >> n >> a >> b >> c >> d; a--; b--; c--; d--; string s; cin >> s; if (c < d) { if (check(s, a, c) && check(s, b, d)) { cout << "Yes" << endl; } else { cout << "No" << endl; } } else { if (check(s, a, c) && check(s, b, d) && check2(s, b - 1, d + 1)) { cout << "Yes" << endl; } else { cout << "No" << endl; } } return 0; }
[ "control_flow.branch.if.condition.change" ]
830,970
830,971
u732502311
cpp
p03017
#include <algorithm> #include <iostream> #include <math.h> #include <string.h> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) long long int mod = 1e9 + 7; bool debug = false; typedef long long ll; bool check(string s, int a, int b) { bool jump = true; for (int i = a; i <= b; i++) { if (s[i] == '#') { if (jump) { jump = false; } else { return false; } } else { jump = true; } } return true; } bool check2(string s, int a, int b) { int cnt = 0; for (int i = a; i <= b; i++) { if (s[i] == '#') { cnt = 0; } else { cnt++; if (cnt >= 3) return true; } } return false; } int main() { int n, a, b, c, d; cin >> n >> a >> b >> c >> d; a--; b--; c--; d--; string s; cin >> s; if (c < d) { if (check(s, a, c) && check(s, b, d)) { cout << "Yes" << endl; } else { cout << "No" << endl; } } else { if (check(s, a, b) && check(s, b, d) && check2(s, b, d)) { cout << "Yes" << endl; } else { cout << "No" << endl; } } return 0; }
#include <algorithm> #include <iostream> #include <math.h> #include <string.h> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) long long int mod = 1e9 + 7; bool debug = false; typedef long long ll; bool check(string s, int a, int b) { bool jump = true; for (int i = a; i <= b; i++) { if (s[i] == '#') { if (jump) { jump = false; } else { return false; } } else { jump = true; } } return true; } bool check2(string s, int a, int b) { int cnt = 0; for (int i = a; i <= b; i++) { if (s[i] == '#') { cnt = 0; } else { cnt++; if (cnt >= 3) return true; } } return false; } int main() { int n, a, b, c, d; cin >> n >> a >> b >> c >> d; a--; b--; c--; d--; string s; cin >> s; if (c < d) { if (check(s, a, c) && check(s, b, d)) { cout << "Yes" << endl; } else { cout << "No" << endl; } } else { if (check(s, a, c) && check(s, b, d) && check2(s, b - 1, d + 1)) { cout << "Yes" << endl; } else { cout << "No" << endl; } } return 0; }
[ "identifier.change", "control_flow.branch.if.condition.change" ]
830,972
830,971
u732502311
cpp
p03017
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define OK 1 #define NG 0 #define MOD (1000000007) using namespace std; typedef long long int Int; int N, A, B, C, D; string S; bool field[2000000 + 10]; int main(void) { cin >> N >> A >> B >> C >> D; cin >> S; S = "#" + S + "#"; bool flag = false; for (int i = A + 1; i <= max(C, D); i++) { if (S[i - 1] == '#' && S[i] == '#') { flag = true; } else { flag = (flag | false); } } if (flag) { cout << "No" << endl; return 0; } if (D < C) { bool ok = false; for (int k = A + 1; k < D; k++) { if (S[k - 1] == '.' && S[k] == '.' && S[k + 1] == '.') { ok = true; break; } } if (ok) { cout << "Yes" << endl; return 0; } else { cout << "No" << endl; return 0; } } cout << "Yes" << endl; return 0; }
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define OK 1 #define NG 0 #define MOD (1000000007) using namespace std; typedef long long int Int; int N, A, B, C, D; string S; bool field[2000000 + 10]; int main(void) { cin >> N >> A >> B >> C >> D; cin >> S; S = "#" + S + "#"; bool flag = false; for (int i = A + 1; i <= max(C, D); i++) { if (S[i - 1] == '#' && S[i] == '#') { flag = true; } else { flag = (flag | false); } } if (flag) { cout << "No" << endl; return 0; } if (D < C) { bool ok = false; for (int k = B; k <= D; k++) { if (S[k - 1] == '.' && S[k] == '.' && S[k + 1] == '.') { ok = true; break; } } if (ok) { cout << "Yes" << endl; return 0; } else { cout << "No" << endl; return 0; } } cout << "Yes" << endl; return 0; }
[ "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.operation.binary.change", "expression.operation.binary.remove", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
830,973
830,974
u498141549
cpp
p03017
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll MOD = 1e9 + 7; int main() { ll n, a, b, c, d; cin >> n >> a >> b >> c >> d; a--; b--; c--; d--; string s; cin >> s; bool ans = true; s[n] = '#'; for (ll i = b; i <= d; i++) { if (s[i] == '#' && s[i + 1] == '#') { ans = false; break; } for (ll i = a; i <= c; i++) { if (s[i] == '#' && s[i + 1] == '#') { ans = false; break; } } } if (c > d) { ans = false; for (ll i = b; i <= d; i++) { if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') { ans = true; } } } if (ans) cout << "Yes" << endl; else cout << "No" << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll MOD = 1e9 + 7; int main() { ll n, a, b, c, d; cin >> n >> a >> b >> c >> d; a--; b--; c--; d--; string s; cin >> s; bool ans = true; s[n] = '#'; for (ll i = b; i <= d; i++) { if (s[i] == '#' && s[i + 1] == '#') { ans = false; break; } } for (ll i = a; i <= c; i++) { if (s[i] == '#' && s[i + 1] == '#') { ans = false; break; } } if (c > d) { ans = false; for (ll i = b; i <= d; i++) { if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') { ans = true; } } } if (ans) cout << "Yes" << endl; else cout << "No" << endl; }
[]
830,981
830,982
u876784108
cpp
p03017
#include <bits/stdc++.h> #define REP(i, x) for (int i = 0; i < (int)(x); i++) #define ALL(x) (x).begin(), (x).end() typedef long long ll; using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int N, A, B, C, D; string S; cin >> N >> A >> B >> C >> D; cin >> S; for (int i = A + 1; i < C; ++i) { if ((S[i - 1] == '#') && (S[i] == '#')) { cout << "No" << endl; return 0; } } for (int i = B + 1; i < D; ++i) { if ((S[i - 1] == '#') && (S[i] == '#')) { cout << "No" << endl; return 0; } } bool swappable = false; if (C > D) { for (int i = B + 1; i < D - 1; ++i) { if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') { swappable = true; } } if (!swappable) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; return 0; }
#include <bits/stdc++.h> #define REP(i, x) for (int i = 0; i < (int)(x); i++) #define ALL(x) (x).begin(), (x).end() typedef long long ll; using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int N, A, B, C, D; string S; cin >> N >> A >> B >> C >> D; cin >> S; for (int i = A + 1; i < C; ++i) { if ((S[i - 1] == '#') && (S[i] == '#')) { cout << "No" << endl; return 0; } } for (int i = B + 1; i < D; ++i) { if ((S[i - 1] == '#') && (S[i] == '#')) { cout << "No" << endl; return 0; } } bool swappable = false; if (C > D) { for (int i = B - 1; i < D; ++i) { if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') { swappable = true; break; } } if (!swappable) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; return 0; }
[ "misc.opposites", "expression.operator.arithmetic.change", "control_flow.loop.for.initializer.change", "expression.operation.binary.change", "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
830,985
830,986
u965529378
cpp
p03017
#include <bits/stdc++.h> #define REP(i, x) for (int i = 0; i < (int)(x); i++) #define ALL(x) (x).begin(), (x).end() typedef long long ll; using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int N, A, B, C, D; string S; cin >> N >> A >> B >> C >> D; cin >> S; for (int i = A + 1; i < C; ++i) { if ((S[i - 1] == '#') && (S[i] == '#')) { cout << "No" << endl; return 0; } } for (int i = B + 1; i < D; ++i) { if ((S[i - 1] == '#') && (S[i] == '#')) { cout << "No" << endl; return 0; } } bool swappable = false; if (C > D) { for (int i = B; i < D - 1; ++i) { if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') { swappable = true; } } if (!swappable) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; return 0; }
#include <bits/stdc++.h> #define REP(i, x) for (int i = 0; i < (int)(x); i++) #define ALL(x) (x).begin(), (x).end() typedef long long ll; using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int N, A, B, C, D; string S; cin >> N >> A >> B >> C >> D; cin >> S; for (int i = A + 1; i < C; ++i) { if ((S[i - 1] == '#') && (S[i] == '#')) { cout << "No" << endl; return 0; } } for (int i = B + 1; i < D; ++i) { if ((S[i - 1] == '#') && (S[i] == '#')) { cout << "No" << endl; return 0; } } bool swappable = false; if (C > D) { for (int i = B - 1; i < D; ++i) { if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') { swappable = true; break; } } if (!swappable) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; return 0; }
[ "control_flow.loop.for.initializer.change", "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
830,987
830,986
u965529378
cpp
p03017
#include <iostream> using namespace std; int main(void) { int N, A, B, C, D; string S; cin >> N >> A >> B >> C >> D; cin >> S; A--; B--; C--; D--; int flag = true; int end = C; if (C < D) { end = D; } for (int i = A; i + 1 <= end; i++) { if (S[i] == '#' && S[i + 1] == '#') { flag = false; break; } } if (flag == false) { cout << "No" << endl; return 0; } if (C > D) { flag = false; for (int i = B; i + 1 <= D; i++) { if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') { flag = true; break; } } } if (flag == false) { cout << "No" << endl; return 0; } cout << "Yes" << endl; return 0; }
#include <iostream> using namespace std; int main(void) { int N, A, B, C, D; string S; cin >> N >> A >> B >> C >> D; cin >> S; A--; B--; C--; D--; int flag = true; int end = C; if (C < D) { end = D; } for (int i = A; i + 1 <= end; i++) { if (S[i] == '#' && S[i + 1] == '#') { flag = false; break; } } if (flag == false) { cout << "No" << endl; return 0; } if (C > D) { flag = false; for (int i = B; i <= D; i++) { if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') { flag = true; break; } } } if (flag == false) { cout << "No" << endl; return 0; } cout << "Yes" << endl; return 0; }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
830,991
830,992
u422831867
cpp
p03017
#include <alloca.h> #include <iostream> using namespace std; int main() { int N, A, B, C, D; string S; cin >> N >> A >> B >> C >> D >> S; bool result = true; A--; B--; C--; D--; if (S[C] == '#' || S[D] == '#') { result = false; } for (int chkIdx = 0; result && chkIdx < 2; chkIdx++) { int i1, i2; if (chkIdx == 0) { i1 = A; i2 = C; } else { i1 = B; i2 = D; } for (int i = i1; i < i2; i++) { if (S[i] == '#' && S[i + 1] == '#') { result = false; break; } } } if (C > D) { int i; for (i = B; i < D; i++) { if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') { break; } } if (i == D) { result = false; } } cout << (result ? "Yes" : "No") << endl; return 0; }
#include <alloca.h> #include <iostream> using namespace std; int main() { int N, A, B, C, D; string S; cin >> N >> A >> B >> C >> D >> S; bool result = true; A--; B--; C--; D--; if (S[C] == '#' || S[D] == '#') { result = false; } for (int chkIdx = 0; result && chkIdx < 2; chkIdx++) { int i1, i2; if (chkIdx == 0) { i1 = A; i2 = C; } else { i1 = B; i2 = D; } for (int i = i1; i < i2; i++) { if (S[i] == '#' && S[i + 1] == '#') { result = false; break; } } } if (result && C > D) { int i; for (i = B; i <= D; i++) { if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') { break; } } if (i > D) { result = false; } } cout << (result ? "Yes" : "No") << endl; return 0; }
[ "control_flow.branch.if.condition.change", "expression.operator.compare.change" ]
831,008
831,009
u298381622
cpp
p03016
#include <bits/stdc++.h> using ll = long long; using namespace std; long long l, a, b, MOD; struct Matrix { vector<vector<long long>> val; Matrix(int n, int m, long long x = 0) : val(n, vector<long long>(m, x)) {} void init(int n, int m, long long x = 0) { val.assign(n, vector<long long>(m, x)); } int size() const { return (int)val.size(); } inline vector<long long> &operator[](int i) { return val[i]; } }; Matrix operator*(Matrix A, Matrix B) { Matrix R((int)A.size(), (int)B[0].size()); for (int i = 0; i < (int)A.size(); ++i) { for (int j = 0; j < (int)B[0].size(); ++j) { for (int k = 0; k < (int)B.size(); ++k) { R[i][j] = (R[i][j] + A[i][k] * B[k][j] % MOD) % MOD; } } } return R; } Matrix pow(Matrix A, long long n) { Matrix R((int)A.size(), (int)A.size()); for (int i = 0; i < (int)A.size(); ++i) R[i][i] = 1; // 正方行列 while (n > 0) { if (n & 1) R = R * A; A = A * A; n >>= 1; } return R; } long long modpow(long long a, long long n) { long long res = 1; while (n > 0) { if (n & 1) res = res * a % MOD; a = a * a % MOD; n >>= 1; } return res; } ll kyu(int n) { ll res = 0; for (int i = 0; i < n; i++) res = res * 10 + 9; return res; } Matrix mat(int n) { Matrix res(3, 3); res[0][0] = modpow(10, n); res[0][1] = 0; res[0][2] = 0; res[1][0] = 1; res[1][1] = 1; res[1][2] = 0; res[2][0] = 0; res[2][1] = b; res[2][2] = 1; return res; } int main() { cin >> l >> a >> b >> MOD; Matrix data(1, 3); data[0][0] = 0; data[0][1] = a; data[0][2] = 1; for (int i = 1; i <= 18; i++) { ll from = kyu(i - 1), to = kyu(i); from = (from - a < 0 ? -1 : (from - a) / b); to = (to - a < 0 ? -1 : (to - a) / b); if (from >= l - 1) break; if (to < 0) continue; if (to >= l - 1) to = l - 1; ll count = to - from; data = data * pow(mat(i), count); } cout << data[0][0] % MOD << endl; return 0; }
#include <bits/stdc++.h> using ll = long long; using namespace std; long long l, a, b, MOD; struct Matrix { vector<vector<long long>> val; Matrix(int n, int m, long long x = 0) : val(n, vector<long long>(m, x)) {} void init(int n, int m, long long x = 0) { val.assign(n, vector<long long>(m, x)); } int size() const { return (int)val.size(); } inline vector<long long> &operator[](int i) { return val[i]; } }; Matrix operator*(Matrix A, Matrix B) { Matrix R((int)A.size(), (int)B[0].size()); for (int i = 0; i < (int)A.size(); ++i) { for (int j = 0; j < (int)B[0].size(); ++j) { for (int k = 0; k < (int)B.size(); ++k) { R[i][j] = (R[i][j] + A[i][k] * B[k][j] % MOD) % MOD; } } } return R; } Matrix pow(Matrix A, long long n) { Matrix R((int)A.size(), (int)A.size()); for (int i = 0; i < (int)A.size(); ++i) R[i][i] = 1; // 正方行列 while (n > 0) { if (n & 1) R = R * A; A = A * A; n >>= 1; } return R; } long long modpow(long long a, long long n) { long long res = 1; while (n > 0) { if (n & 1) res = res * a % MOD; a = a * a % MOD; n >>= 1; } return res; } ll kyu(int n) { ll res = 0; for (int i = 0; i < n; i++) res = res * 10 + 9; return res; } Matrix mat(int n) { Matrix res(3, 3); res[0][0] = modpow(10, n); res[0][1] = 0; res[0][2] = 0; res[1][0] = 1; res[1][1] = 1; res[1][2] = 0; res[2][0] = 0; res[2][1] = b % MOD; res[2][2] = 1; return res; } int main() { cin >> l >> a >> b >> MOD; Matrix data(1, 3); data[0][0] = 0; data[0][1] = a % MOD; data[0][2] = 1; for (int i = 1; i <= 18; i++) { ll from = kyu(i - 1), to = kyu(i); from = (from - a < 0 ? -1 : (from - a) / b); to = (to - a < 0 ? -1 : (to - a) / b); if (from >= l - 1) break; if (to < 0) continue; if (to >= l - 1) to = l - 1; ll count = to - from; data = data * pow(mat(i), count); } cout << data[0][0] % MOD << endl; return 0; }
[ "assignment.change" ]
831,088
831,091
u842028864
cpp
p03016
#include <algorithm> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <vector> using namespace std; // long long mod = 998244353; long long mod = 1000000007; vector<long long> fact(1000001); vector<long long> invFact(1000001); long long gcd(long long a, long long b) { if (b == 0) { return a; } return gcd(b, a % b); } long long binpow(long long x, long long k) { if (k == 0) { return 1LL; } long long temp = binpow(x, k / 2); if (k % 2 == 1) { return (((temp * temp) % mod) * x) % mod; } else { return (temp * temp) % mod; } } long long modular_inverse(long long x) { return binpow(x, mod - 2); } long long binomial(long long n, long long k) { long long rez = 1; for (long long i = n - k + 1; i <= n; i++) { rez *= i; rez %= mod; } long long temp = 1; for (long long i = 1; i <= k; i++) { temp *= i; temp %= mod; } rez *= modular_inverse(temp); rez %= mod; return rez; } int fi(int a, vector<int> &p) { if (p[a] != p[p[a]]) { p[a] = fi(p[a], p); } return p[a]; } void uni(int a, int b, vector<int> &p) { int x = fi(a, p), y = fi(b, p); if (x != y) { p[x] = y; } } long long euclidianDistanceSquared(pair<int, int> a, pair<int, int> b) { return (a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second); } double euclidianDistanceSquared(pair<double, double> a, pair<double, double> b) { return (a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second); } double euclidianDistance(pair<double, double> a, pair<double, double> b) { return sqrt(euclidianDistanceSquared(a, b)); } bool circleIntersections(pair<double, double> pos1, double r1, pair<double, double> pos2, double r2, pair<double, double> &int1, pair<double, double> &int2) { double d = euclidianDistance(pos1, pos2); if (r1 + r2 < d || d < fabs(r1 - r2)) { return false; } double a = (r1 * r1 - r2 * r2 + d * d) / (2 * d); double h = sqrt(r1 * r1 - a * a); pair<double, double> pos3 = {pos1.first + a * (pos2.first - pos1.first) / d, pos1.second + a * (pos2.second - pos1.second) / d}; int1.first = pos3.first + h * (pos2.second - pos1.second) / d; int1.second = pos3.second - h * (pos2.first - pos1.first) / d; int2.first = pos3.first - h * (pos2.second - pos1.second) / d; int2.second = pos3.second + h * (pos2.first - pos1.first) / d; return true; } class SegmentTree { public: class Node { public: vector<int> value; Node *l, *r; int left, right; Node(int x, int y) { value = vector<int>(26, 0); l = nullptr; r = nullptr; left = x; right = y; } void update(int p, char c) { if (left > p || p > right) { return; } if (left == p && p == right) { for (int i = 0; i < 26; i++) { value[i] = 0; } value[c - 'a'] = 1; return; } if (l == nullptr) { int mid = (left + right) / 2; l = new Node(left, mid); r = new Node(mid + 1, right); } l->update(p, c); r->update(p, c); for (int i = 0; i < 26; i++) { value[i] = l->value[i] + r->value[i]; } } int query(int x, int y) { if (left > y || x > right) { return 0; } if (x <= left && right <= y) { int rez = 0; for (int i = 0; i < 26; i++) { if (value[i] != 0) { rez |= (1 << i); } } return rez; } if (l == nullptr) { return 0; } return l->query(x, y) | r->query(x, y); } }; Node *root; SegmentTree(int n) { root = new Node(0, n - 1); } void update(int p, char c) { root->update(p, c); } int query(int x, int y) { return root->query(x, y); } }; void initMatrix(vector<vector<long long>> &m, int d, long long b) { m[1][0] = 1; m[1][1] = 1; m[2][1] = b % mod; m[2][2] = 1; m[0][0] = binpow(10, d); } void matrixMultiply(vector<vector<long long>> &m1, vector<vector<long long>> &m2, vector<vector<long long>> &res) { vector<vector<long long>> m(res.size(), vector<long long>(res[0].size(), 0)); for (int i = 0; i < m1.size(); i++) { for (int j = 0; j < m2[0].size(); j++) { for (int k = 0; k < m1[0].size(); k++) { (m[i][j] += m1[i][k] * m2[k][j]) %= mod; } } } for (int i = 0; i < m1.size(); i++) { for (int j = 0; j < m2[0].size(); j++) { res[i][j] = m[i][j]; } } } void matrixExp(vector<vector<long long>> &m, long long power, vector<vector<long long>> &res) { if (power == 1) { for (int i = 0; i < m.size(); i++) { for (int j = 0; j < m.size(); j++) { res[i][j] = m[i][j]; } } return; } matrixExp(m, power / 2, res); matrixMultiply(res, res, res); if (power % 2 == 1) { matrixMultiply(m, res, res); } } int digitCount(long long x) { if (x == 0) { return 1; } int cnt = 0; while (x != 0) { x /= 10; cnt++; } return cnt; } int main() { ios::sync_with_stdio(false); cout << fixed << setprecision(12); long long l, a, b, m; cin >> l >> a >> b >> mod; vector<long long> firstDigit(19, -1); vector<long long> lastDigit(19, -1); long long lastCount = digitCount(a + b * (l - 1)); for (int i = digitCount(a); i <= lastCount; i++) { long long left = 0, right = l, mid; while (right - left > 1) { mid = (left + right) / 2; if (digitCount(a + b * mid) > i) { right = mid; } else { left = mid; } } if (digitCount(a + b * left) == i) { lastDigit[i] = left; } left = -1, right = l - 1, mid; while (right - left > 1) { mid = (left + right) / 2; if (digitCount(a + b * mid) >= i) { right = mid; } else { left = mid; } } if (digitCount(a + b * right) == i) { firstDigit[i] = right; } } vector<vector<long long>> m1(3, vector<long long>(3, 0)), m2(3, vector<long long>(3, 0)), res(1, vector<long long>(3, 0)); initMatrix(m1, 0, b); res[0][0] = 0; res[0][1] = a; res[0][2] = 1; for (int i = digitCount(a); i <= lastCount; i++) { if (firstDigit[i] == -1) { continue; } m1[0][0] = binpow(10, i); matrixExp(m1, lastDigit[i] - firstDigit[i] + 1, m2); matrixMultiply(res, m2, res); } cout << res[0][0] << '\n'; return 0; }
#include <algorithm> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <vector> using namespace std; // long long mod = 998244353; long long mod = 1000000007; vector<long long> fact(1000001); vector<long long> invFact(1000001); long long gcd(long long a, long long b) { if (b == 0) { return a; } return gcd(b, a % b); } long long binpow(long long x, long long k) { if (k == 0) { return 1LL; } long long temp = binpow(x, k / 2); if (k % 2 == 1) { return (((temp * temp) % mod) * x) % mod; } else { return (temp * temp) % mod; } } long long modular_inverse(long long x) { return binpow(x, mod - 2); } long long binomial(long long n, long long k) { long long rez = 1; for (long long i = n - k + 1; i <= n; i++) { rez *= i; rez %= mod; } long long temp = 1; for (long long i = 1; i <= k; i++) { temp *= i; temp %= mod; } rez *= modular_inverse(temp); rez %= mod; return rez; } int fi(int a, vector<int> &p) { if (p[a] != p[p[a]]) { p[a] = fi(p[a], p); } return p[a]; } void uni(int a, int b, vector<int> &p) { int x = fi(a, p), y = fi(b, p); if (x != y) { p[x] = y; } } long long euclidianDistanceSquared(pair<int, int> a, pair<int, int> b) { return (a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second); } double euclidianDistanceSquared(pair<double, double> a, pair<double, double> b) { return (a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second); } double euclidianDistance(pair<double, double> a, pair<double, double> b) { return sqrt(euclidianDistanceSquared(a, b)); } bool circleIntersections(pair<double, double> pos1, double r1, pair<double, double> pos2, double r2, pair<double, double> &int1, pair<double, double> &int2) { double d = euclidianDistance(pos1, pos2); if (r1 + r2 < d || d < fabs(r1 - r2)) { return false; } double a = (r1 * r1 - r2 * r2 + d * d) / (2 * d); double h = sqrt(r1 * r1 - a * a); pair<double, double> pos3 = {pos1.first + a * (pos2.first - pos1.first) / d, pos1.second + a * (pos2.second - pos1.second) / d}; int1.first = pos3.first + h * (pos2.second - pos1.second) / d; int1.second = pos3.second - h * (pos2.first - pos1.first) / d; int2.first = pos3.first - h * (pos2.second - pos1.second) / d; int2.second = pos3.second + h * (pos2.first - pos1.first) / d; return true; } class SegmentTree { public: class Node { public: vector<int> value; Node *l, *r; int left, right; Node(int x, int y) { value = vector<int>(26, 0); l = nullptr; r = nullptr; left = x; right = y; } void update(int p, char c) { if (left > p || p > right) { return; } if (left == p && p == right) { for (int i = 0; i < 26; i++) { value[i] = 0; } value[c - 'a'] = 1; return; } if (l == nullptr) { int mid = (left + right) / 2; l = new Node(left, mid); r = new Node(mid + 1, right); } l->update(p, c); r->update(p, c); for (int i = 0; i < 26; i++) { value[i] = l->value[i] + r->value[i]; } } int query(int x, int y) { if (left > y || x > right) { return 0; } if (x <= left && right <= y) { int rez = 0; for (int i = 0; i < 26; i++) { if (value[i] != 0) { rez |= (1 << i); } } return rez; } if (l == nullptr) { return 0; } return l->query(x, y) | r->query(x, y); } }; Node *root; SegmentTree(int n) { root = new Node(0, n - 1); } void update(int p, char c) { root->update(p, c); } int query(int x, int y) { return root->query(x, y); } }; void initMatrix(vector<vector<long long>> &m, int d, long long b) { m[1][0] = 1; m[1][1] = 1; m[2][1] = b % mod; m[2][2] = 1; m[0][0] = binpow(10, d); } void matrixMultiply(vector<vector<long long>> &m1, vector<vector<long long>> &m2, vector<vector<long long>> &res) { vector<vector<long long>> m(res.size(), vector<long long>(res[0].size(), 0)); for (int i = 0; i < m1.size(); i++) { for (int j = 0; j < m2[0].size(); j++) { for (int k = 0; k < m1[0].size(); k++) { (m[i][j] += m1[i][k] * m2[k][j]) %= mod; } } } for (int i = 0; i < m1.size(); i++) { for (int j = 0; j < m2[0].size(); j++) { res[i][j] = m[i][j]; } } } void matrixExp(vector<vector<long long>> &m, long long power, vector<vector<long long>> &res) { if (power == 1) { for (int i = 0; i < m.size(); i++) { for (int j = 0; j < m.size(); j++) { res[i][j] = m[i][j]; } } return; } matrixExp(m, power / 2, res); matrixMultiply(res, res, res); if (power % 2 == 1) { matrixMultiply(m, res, res); } } int digitCount(long long x) { if (x == 0) { return 1; } int cnt = 0; while (x != 0) { x /= 10; cnt++; } return cnt; } int main() { ios::sync_with_stdio(false); cout << fixed << setprecision(12); long long l, a, b; cin >> l >> a >> b >> mod; vector<long long> firstDigit(19, -1); vector<long long> lastDigit(19, -1); long long lastCount = digitCount(a + b * (l - 1)); // for (int i = 0; i < l; i++) // { // cout << i << " " << a + b * i << " " << digitCount(a + b * i) << '\n'; // } for (int i = digitCount(a); i <= lastCount; i++) { long long left = 0, right = l, mid; while (right - left > 1) { mid = (left + right) / 2; if (digitCount(a + b * mid) > i) { right = mid; } else { left = mid; } } if (digitCount(a + b * left) == i) { lastDigit[i] = left; } left = -1, right = l - 1, mid; while (right - left > 1) { mid = (left + right) / 2; if (digitCount(a + b * mid) >= i) { right = mid; } else { left = mid; } } if (digitCount(a + b * right) == i) { firstDigit[i] = right; } } vector<vector<long long>> m1(3, vector<long long>(3, 0)), m2(3, vector<long long>(3, 0)), res(1, vector<long long>(3, 0)); initMatrix(m1, 0, b); res[0][0] = 0; res[0][1] = a % mod; res[0][2] = 1; for (int i = digitCount(a); i <= lastCount; i++) { if (firstDigit[i] == -1) { continue; } // cout << i << " " << firstDigit[i] << " " << lastDigit[i] << '\n'; m1[0][0] = binpow(10, i); matrixExp(m1, lastDigit[i] - firstDigit[i] + 1, m2); matrixMultiply(res, m2, res); } cout << res[0][0] << '\n'; return 0; }
[ "variable_declaration.remove", "assignment.change" ]
831,238
831,249
u800277548
cpp
p03016
/*{{{*/ #include <algorithm> #include <assert.h> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <limits.h> #include <map> #include <queue> #include <set> #include <sstream> #include <string> #include <vector> #define SZ(X) ((int)(X).size()) #define ALL(X) (X).begin(), (X).end() #define REP(I, N) for (int I = 0; I < (N); ++I) #define REPP(I, A, B) for (int I = (A); I < (B); ++I) #define FOR(I, A, B) for (int I = (A); I <= (B); ++I) #define FORS(I, S) for (int I = 0; S[I]; ++I) #define RS(X) scanf("%s", (X)) #define SORT_UNIQUE(c) \ (sort(c.begin(), c.end()), \ c.resize(distance(c.begin(), unique(c.begin(), c.end())))) #define GET_POS(c, x) (lower_bound(c.begin(), c.end(), x) - c.begin()) #define CASET \ int ___T; \ scanf("%d", &___T); \ for (int cs = 1; cs <= ___T; cs++) #define MP make_pair #define PB push_back #define MS0(X) memset((X), 0, sizeof((X))) #define MS1(X) memset((X), -1, sizeof((X))) #define LEN(X) strlen(X) #define F first #define S second using namespace std; typedef long long LL; typedef unsigned long long ULL; typedef long double LD; typedef pair<int, int> PII; typedef vector<int> VI; typedef vector<LL> VL; typedef vector<PII> VPII; typedef pair<LL, LL> PLL; typedef vector<PLL> VPLL; template <class T> void _R(T &x) { cin >> x; } void _R(int &x) { scanf("%d", &x); } void _R(LL &x) { scanf("%lld", &x); } void _R(double &x) { scanf("%lf", &x); } void _R(char &x) { scanf(" %c", &x); } void _R(char *x) { scanf("%s", x); } void R() {} template <class T, class... U> void R(T &head, U &...tail) { _R(head); R(tail...); } template <class T> void _W(const T &x) { cout << x; } void _W(const int &x) { printf("%d", x); } void _W(const LL &x) { printf("%lld", x); } void _W(const double &x) { printf("%.16f", x); } void _W(const char &x) { putchar(x); } void _W(const char *x) { printf("%s", x); } template <class T, class U> void _W(const pair<T, U> &x) { _W(x.F); putchar(' '); _W(x.S); } template <class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); } void W() {} template <class T, class... U> void W(const T &head, const U &...tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); } #ifdef HOME #define DEBUG(...) \ { \ printf("# "); \ printf(__VA_ARGS__); \ puts(""); \ } #else #define DEBUG(...) #endif int MOD = 1e9 + 7; void ADD(LL &x, LL v) { x = (x + v) % MOD; if (x < 0) x += MOD; } /*}}}*/ const int SIZE = 1e6 + 10; LL mypow(LL x, LL y) { x %= MOD; LL res = 1 % MOD; while (y) { if (y & 1) res = res * x % MOD; y >>= 1; x = x * x % MOD; } return res; } LL f(LL ll, LL rr, LL dif, LL num, LL pp) { ll %= MOD; rr %= MOD; dif %= MOD; pp %= MOD; if (num == 1) return ll; if (num & 1) { return (f(ll, rr - dif, dif, num - 1, pp) * pp + rr) % MOD; } return f((ll * pp + (ll + dif)) % MOD, (rr + (rr - dif) * pp) % MOD, 2 * dif * (1 + pp) % MOD, num / 2, pp * pp % MOD); } int main() { LL L, A, B; R(L, A, B); R(MOD); LL ten = 10; LL now = 0; while (1) { if (!L) break; if (ten >= A) { LL ll; if (A >= ten / 10) ll = A; else ll = (ten / 10 - 1 - A) / B * (B + 1) + A; LL rr = (ten - 1 - A) / B * B + A; if (rr >= ll) { if ((rr - ll) / B + 1 > L) rr = ll + B * (L - 1); LL num = (rr - ll) / B + 1; L -= num; now = now * mypow(ten, num) % MOD; ADD(now, f(ll, rr, B, num, ten)); } } ten *= 10; } W(now); return 0; } // ll*ten^(num-1)+(ll+B)*ten^(num-2)+...+rr = X // X*9 =
/*{{{*/ #include <algorithm> #include <assert.h> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <limits.h> #include <map> #include <queue> #include <set> #include <sstream> #include <string> #include <vector> #define SZ(X) ((int)(X).size()) #define ALL(X) (X).begin(), (X).end() #define REP(I, N) for (int I = 0; I < (N); ++I) #define REPP(I, A, B) for (int I = (A); I < (B); ++I) #define FOR(I, A, B) for (int I = (A); I <= (B); ++I) #define FORS(I, S) for (int I = 0; S[I]; ++I) #define RS(X) scanf("%s", (X)) #define SORT_UNIQUE(c) \ (sort(c.begin(), c.end()), \ c.resize(distance(c.begin(), unique(c.begin(), c.end())))) #define GET_POS(c, x) (lower_bound(c.begin(), c.end(), x) - c.begin()) #define CASET \ int ___T; \ scanf("%d", &___T); \ for (int cs = 1; cs <= ___T; cs++) #define MP make_pair #define PB push_back #define MS0(X) memset((X), 0, sizeof((X))) #define MS1(X) memset((X), -1, sizeof((X))) #define LEN(X) strlen(X) #define F first #define S second using namespace std; typedef long long LL; typedef unsigned long long ULL; typedef long double LD; typedef pair<int, int> PII; typedef vector<int> VI; typedef vector<LL> VL; typedef vector<PII> VPII; typedef pair<LL, LL> PLL; typedef vector<PLL> VPLL; template <class T> void _R(T &x) { cin >> x; } void _R(int &x) { scanf("%d", &x); } void _R(LL &x) { scanf("%lld", &x); } void _R(double &x) { scanf("%lf", &x); } void _R(char &x) { scanf(" %c", &x); } void _R(char *x) { scanf("%s", x); } void R() {} template <class T, class... U> void R(T &head, U &...tail) { _R(head); R(tail...); } template <class T> void _W(const T &x) { cout << x; } void _W(const int &x) { printf("%d", x); } void _W(const LL &x) { printf("%lld", x); } void _W(const double &x) { printf("%.16f", x); } void _W(const char &x) { putchar(x); } void _W(const char *x) { printf("%s", x); } template <class T, class U> void _W(const pair<T, U> &x) { _W(x.F); putchar(' '); _W(x.S); } template <class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); } void W() {} template <class T, class... U> void W(const T &head, const U &...tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); } #ifdef HOME #define DEBUG(...) \ { \ printf("# "); \ printf(__VA_ARGS__); \ puts(""); \ } #else #define DEBUG(...) #endif int MOD = 1e9 + 7; void ADD(LL &x, LL v) { x = (x + v) % MOD; if (x < 0) x += MOD; } /*}}}*/ const int SIZE = 1e6 + 10; LL mypow(LL x, LL y) { x %= MOD; LL res = 1 % MOD; while (y) { if (y & 1) res = res * x % MOD; y >>= 1; x = x * x % MOD; } return res; } LL f(LL ll, LL rr, LL dif, LL num, LL pp) { ll %= MOD; rr %= MOD; dif %= MOD; pp %= MOD; if (num == 1) return ll; if (num & 1) { return (f(ll, rr - dif, dif, num - 1, pp) * pp + rr) % MOD; } return f((ll * pp + (ll + dif)) % MOD, (rr + (rr - dif) * pp) % MOD, 2 * dif * (1 + pp) % MOD, num / 2, pp * pp % MOD); } int main() { LL L, A, B; R(L, A, B); R(MOD); LL ten = 10; LL now = 0; while (1) { if (!L) break; if (ten - 1 >= A) { LL ll; if (A >= ten / 10) ll = A; else ll = (ten / 10 - 1 - A) / B * B + B + A; LL rr = (ten - 1 - A) / B * B + A; if (rr >= ll) { if ((rr - ll) / B + 1 > L) rr = ll + B * (L - 1); LL num = (rr - ll) / B + 1; L -= num; now = now * mypow(ten, num) % MOD; ADD(now, f(ll, rr, B, num, ten)); } } ten *= 10; } W(now); return 0; } // ll*ten^(num-1)+(ll+B)*ten^(num-2)+...+rr = X // X*9 =
[ "control_flow.branch.if.condition.change", "assignment.value.change", "identifier.replace.add", "literal.replace.remove", "expression.operation.binary.change" ]
831,305
831,299
u284124505
cpp
p03016
/*{{{*/ #include <algorithm> #include <assert.h> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <limits.h> #include <map> #include <queue> #include <set> #include <sstream> #include <string> #include <vector> #define SZ(X) ((int)(X).size()) #define ALL(X) (X).begin(), (X).end() #define REP(I, N) for (int I = 0; I < (N); ++I) #define REPP(I, A, B) for (int I = (A); I < (B); ++I) #define FOR(I, A, B) for (int I = (A); I <= (B); ++I) #define FORS(I, S) for (int I = 0; S[I]; ++I) #define RS(X) scanf("%s", (X)) #define SORT_UNIQUE(c) \ (sort(c.begin(), c.end()), \ c.resize(distance(c.begin(), unique(c.begin(), c.end())))) #define GET_POS(c, x) (lower_bound(c.begin(), c.end(), x) - c.begin()) #define CASET \ int ___T; \ scanf("%d", &___T); \ for (int cs = 1; cs <= ___T; cs++) #define MP make_pair #define PB push_back #define MS0(X) memset((X), 0, sizeof((X))) #define MS1(X) memset((X), -1, sizeof((X))) #define LEN(X) strlen(X) #define F first #define S second using namespace std; typedef long long LL; typedef unsigned long long ULL; typedef long double LD; typedef pair<int, int> PII; typedef vector<int> VI; typedef vector<LL> VL; typedef vector<PII> VPII; typedef pair<LL, LL> PLL; typedef vector<PLL> VPLL; template <class T> void _R(T &x) { cin >> x; } void _R(int &x) { scanf("%d", &x); } void _R(LL &x) { scanf("%lld", &x); } void _R(double &x) { scanf("%lf", &x); } void _R(char &x) { scanf(" %c", &x); } void _R(char *x) { scanf("%s", x); } void R() {} template <class T, class... U> void R(T &head, U &...tail) { _R(head); R(tail...); } template <class T> void _W(const T &x) { cout << x; } void _W(const int &x) { printf("%d", x); } void _W(const LL &x) { printf("%lld", x); } void _W(const double &x) { printf("%.16f", x); } void _W(const char &x) { putchar(x); } void _W(const char *x) { printf("%s", x); } template <class T, class U> void _W(const pair<T, U> &x) { _W(x.F); putchar(' '); _W(x.S); } template <class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); } void W() {} template <class T, class... U> void W(const T &head, const U &...tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); } #ifdef HOME #define DEBUG(...) \ { \ printf("# "); \ printf(__VA_ARGS__); \ puts(""); \ } #else #define DEBUG(...) #endif int MOD = 1e9 + 7; void ADD(LL &x, LL v) { x = (x + v) % MOD; if (x < 0) x += MOD; } /*}}}*/ const int SIZE = 1e6 + 10; LL mypow(LL x, LL y) { x %= MOD; LL res = 1 % MOD; while (y) { if (y & 1) res = res * x % MOD; y >>= 1; x = x * x % MOD; } return res; } LL f(LL ll, LL rr, LL dif, LL num, LL pp) { ll %= MOD; rr %= MOD; dif %= MOD; pp %= MOD; if (num == 1) return ll; if (num & 1) { return (f(ll, rr - dif, dif, num - 1, pp) * pp + rr) % MOD; } return f((ll * pp + (ll + dif)) % MOD, (rr + (rr - dif) * pp) % MOD, 2 * dif * (1 + pp) % MOD, num / 2, pp * pp % MOD); } int main() { LL L, A, B; R(L, A, B); R(MOD); LL ten = 10; LL now = 0; while (1) { if (!L) break; if (ten >= A) { LL ll; if (A >= ten / 10) ll = A; else ll = (ten / 10 - 1 - A) / B * (B + 1); LL rr = (ten - 1 - A) / B * B + A; if (rr >= ll) { if ((rr - ll) / B + 1 > L) rr = ll + B * (L - 1); LL num = (rr - ll) / B + 1; L -= num; now = now * mypow(ten, num) % MOD; ADD(now, f(ll, rr, B, num, ten)); } } ten *= 10; } W(now); return 0; } // ll*ten^(num-1)+(ll+B)*ten^(num-2)+...+rr = X // X*9 =
/*{{{*/ #include <algorithm> #include <assert.h> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <limits.h> #include <map> #include <queue> #include <set> #include <sstream> #include <string> #include <vector> #define SZ(X) ((int)(X).size()) #define ALL(X) (X).begin(), (X).end() #define REP(I, N) for (int I = 0; I < (N); ++I) #define REPP(I, A, B) for (int I = (A); I < (B); ++I) #define FOR(I, A, B) for (int I = (A); I <= (B); ++I) #define FORS(I, S) for (int I = 0; S[I]; ++I) #define RS(X) scanf("%s", (X)) #define SORT_UNIQUE(c) \ (sort(c.begin(), c.end()), \ c.resize(distance(c.begin(), unique(c.begin(), c.end())))) #define GET_POS(c, x) (lower_bound(c.begin(), c.end(), x) - c.begin()) #define CASET \ int ___T; \ scanf("%d", &___T); \ for (int cs = 1; cs <= ___T; cs++) #define MP make_pair #define PB push_back #define MS0(X) memset((X), 0, sizeof((X))) #define MS1(X) memset((X), -1, sizeof((X))) #define LEN(X) strlen(X) #define F first #define S second using namespace std; typedef long long LL; typedef unsigned long long ULL; typedef long double LD; typedef pair<int, int> PII; typedef vector<int> VI; typedef vector<LL> VL; typedef vector<PII> VPII; typedef pair<LL, LL> PLL; typedef vector<PLL> VPLL; template <class T> void _R(T &x) { cin >> x; } void _R(int &x) { scanf("%d", &x); } void _R(LL &x) { scanf("%lld", &x); } void _R(double &x) { scanf("%lf", &x); } void _R(char &x) { scanf(" %c", &x); } void _R(char *x) { scanf("%s", x); } void R() {} template <class T, class... U> void R(T &head, U &...tail) { _R(head); R(tail...); } template <class T> void _W(const T &x) { cout << x; } void _W(const int &x) { printf("%d", x); } void _W(const LL &x) { printf("%lld", x); } void _W(const double &x) { printf("%.16f", x); } void _W(const char &x) { putchar(x); } void _W(const char *x) { printf("%s", x); } template <class T, class U> void _W(const pair<T, U> &x) { _W(x.F); putchar(' '); _W(x.S); } template <class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); } void W() {} template <class T, class... U> void W(const T &head, const U &...tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); } #ifdef HOME #define DEBUG(...) \ { \ printf("# "); \ printf(__VA_ARGS__); \ puts(""); \ } #else #define DEBUG(...) #endif int MOD = 1e9 + 7; void ADD(LL &x, LL v) { x = (x + v) % MOD; if (x < 0) x += MOD; } /*}}}*/ const int SIZE = 1e6 + 10; LL mypow(LL x, LL y) { x %= MOD; LL res = 1 % MOD; while (y) { if (y & 1) res = res * x % MOD; y >>= 1; x = x * x % MOD; } return res; } LL f(LL ll, LL rr, LL dif, LL num, LL pp) { ll %= MOD; rr %= MOD; dif %= MOD; pp %= MOD; if (num == 1) return ll; if (num & 1) { return (f(ll, rr - dif, dif, num - 1, pp) * pp + rr) % MOD; } return f((ll * pp + (ll + dif)) % MOD, (rr + (rr - dif) * pp) % MOD, 2 * dif * (1 + pp) % MOD, num / 2, pp * pp % MOD); } int main() { LL L, A, B; R(L, A, B); R(MOD); LL ten = 10; LL now = 0; while (1) { if (!L) break; if (ten - 1 >= A) { LL ll; if (A >= ten / 10) ll = A; else ll = (ten / 10 - 1 - A) / B * B + B + A; LL rr = (ten - 1 - A) / B * B + A; if (rr >= ll) { if ((rr - ll) / B + 1 > L) rr = ll + B * (L - 1); LL num = (rr - ll) / B + 1; L -= num; now = now * mypow(ten, num) % MOD; ADD(now, f(ll, rr, B, num, ten)); } } ten *= 10; } W(now); return 0; } // ll*ten^(num-1)+(ll+B)*ten^(num-2)+...+rr = X // X*9 =
[ "control_flow.branch.if.condition.change" ]
831,313
831,299
u284124505
cpp
p03016
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (long long i = 0; i < (long long)(n); i++) #define REP(i, k, n) for (long long i = k; i < (long long)(n); i++) #define all(a) a.begin(), a.end() #define eb emplace_back #define pb push_back #define lb(v, k) (lower_bound(all(v), k) - v.begin()) #define ub(v, k) (upper_bound(all(v), k) - v.begin()) #define fi first #define se second typedef long long ll; typedef pair<ll, ll> P; typedef tuple<ll, ll, ll> PP; typedef multiset<ll> S; typedef priority_queue<ll> PQ; typedef priority_queue<PP, vector<PP>, greater<PP>> SPQ; using vi = vector<ll>; using vvi = vector<vector<ll>>; const ll inf = 1001001001001001; const int INF = 1001001001; // const int mod=1000000007; bool chmin(auto &a, auto b) { if (a > b) { a = b; return true; } return false; } bool chmax(auto &a, auto b) { if (a < b) { a = b; return true; } return false; } void outvi(vi v) { rep(i, v.size()) { if (i) cout << ' '; cout << v[i]; } cout << endl; } void outvvi(vvi v) { rep(i, v.size()) { rep(j, v[i].size()) { if (j) cout << ' '; cout << v[i][j]; } cout << endl; } } ll ans = 0, sum = 0, k = 0, u = 0, t = 1, mod, b; ll fac(ll a, ll p) { a %= mod; if (p == 0) return 1; if (p & 1) return (a * fac(a, p - 1)) % mod; return (fac(a, p / 2) * fac(a, p / 2)) % mod; } ll f(ll n) { if (n == 0) return 0; if (n & 1) return (f(n - 1) * (t % mod) + 1) % mod; else return (f(n / 2) + f(n / 2) * fac((t % mod), n / 2)) % mod; } ll g(ll n) { if (n == 0) return 0; if (n & 1) return (g(n - 1) * (t % mod) + b % mod * (n - 1)) % mod; return (g(n / 2) + (g(n / 2) * fac((t % mod), n / 2)) % mod + (b % mod * (n / 2) % mod * f(n / 2)) % mod) % mod; } int main() { ll l, a, b, n; cin >> l >> a >> b >> mod; while (sum < l) { if (sum < 0) break; t = t * 10 % mod; k = (k + 1) * 10 - 1; u++; if (k < a && k >= 0) continue; n = (k - a) / b + 1; if (sum + n > l || n < 0 || sum + n < 0) n = l - sum; sum += n; ans = ((ans * fac(fac(10, n), u)) % mod + ((a % mod) * f(n)) % mod + g(n) % mod) % mod; a = k + b - (k - a) % b; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (long long i = 0; i < (long long)(n); i++) #define REP(i, k, n) for (long long i = k; i < (long long)(n); i++) #define all(a) a.begin(), a.end() #define eb emplace_back #define pb push_back #define lb(v, k) (lower_bound(all(v), k) - v.begin()) #define ub(v, k) (upper_bound(all(v), k) - v.begin()) #define fi first #define se second typedef long long ll; typedef pair<ll, ll> P; typedef tuple<ll, ll, ll> PP; typedef multiset<ll> S; typedef priority_queue<ll> PQ; typedef priority_queue<PP, vector<PP>, greater<PP>> SPQ; using vi = vector<ll>; using vvi = vector<vector<ll>>; const ll inf = 1001001001001001; const int INF = 1001001001; // const int mod=1000000007; bool chmin(auto &a, auto b) { if (a > b) { a = b; return true; } return false; } bool chmax(auto &a, auto b) { if (a < b) { a = b; return true; } return false; } void outvi(vi v) { rep(i, v.size()) { if (i) cout << ' '; cout << v[i]; } cout << endl; } void outvvi(vvi v) { rep(i, v.size()) { rep(j, v[i].size()) { if (j) cout << ' '; cout << v[i][j]; } cout << endl; } } ll ans = 0, sum = 0, k = 0, u = 0, t = 1, mod, b; ll fac(ll a, ll p) { a %= mod; if (p == 0) return 1; if (p & 1) return (a * fac(a, p - 1)) % mod; return (fac(a, p / 2) * fac(a, p / 2)) % mod; } ll f(ll n) { if (n == 0) return 0; if (n & 1) return (f(n - 1) * (t % mod) + 1) % mod; else return (f(n / 2) + f(n / 2) * fac((t % mod), n / 2)) % mod; } ll g(ll n) { if (n == 0) return 0; if (n & 1) return (g(n - 1) * (t % mod) + b % mod * (n - 1)) % mod; return (g(n / 2) + (g(n / 2) * fac((t % mod), n / 2)) % mod + (b % mod * (n / 2) % mod * f(n / 2)) % mod) % mod; } int main() { ll l, a, n; cin >> l >> a >> b >> mod; while (sum < l) { if (sum < 0) break; t = t * 10 % mod; k = (k + 1) * 10 - 1; u++; if (k < a && k >= 0) continue; n = (k - a) / b + 1; if (sum + n > l || n < 0 || sum + n < 0) n = l - sum; sum += n; ans = ((ans * fac(fac(10, n), u)) % mod + ((a % mod) * f(n)) % mod + g(n) % mod) % mod; a = k + b - (k - a) % b; } cout << ans << endl; }
[ "variable_declaration.remove" ]
831,320
831,324
u422633119
cpp
p03016
//#pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; //衝突対策 #define ws wszzzz #define int long long //@formatter:off template <class A, class B, class C> struct T2 { A f; B s; C t; T2() { f = 0, s = 0, t = 0; } T2(A f, B s, C t) : f(f), s(s), t(t) {} bool operator<(const T2 &r) const { return f != r.f ? f < r.f : s != r.s ? s < r.s : t < r.t; /*return f != r.f ? f > r.f : s != r.s ?n s > r.s : t > r.t; 大きい順 */ } bool operator>(const T2 &r) const { return f != r.f ? f > r.f : s != r.s ? s > r.s : t > r.t; /*return f != r.f ? f > r.f : s != r.s ? s > r.s : t > r.t; 小さい順 */ } bool operator==(const T2 &r) const { return f == r.f && s == r.s && t == r.t; } bool operator!=(const T2 &r) const { return f != r.f || s != r.s || t != r.t; } }; template <class A, class B, class C, class D> struct F2 { A a; B b; C c; D d; F2() { a = 0, b = 0, c = 0, d = 0; } F2(A a, B b, C c, D d) : a(a), b(b), c(c), d(d) {} bool operator<(const F2 &r) const { return a != r.a ? a < r.a : b != r.b ? b < r.b : c != r.c ? c < r.c : d < r.d; /* return a != r.a ? a > r.a : b != r.b ? b > r.b : c != r.c ? c > r.c : d > r.d;*/ } bool operator>(const F2 &r) const { return a != r.a ? a > r.a : b != r.b ? b > r.b : c != r.c ? c > r.c : d > r.d; /* return a != r.a ? a < r.a : b != r.b ? b < r.b : c != r.c ? c < r.c : d < r.d;*/ } bool operator==(const F2 &r) const { return a == r.a && b == r.b && c == r.c && d == r.d; } bool operator!=(const F2 &r) const { return a != r.a || b != r.b || c != r.c || d != r.d; } int operator[](int i) { assert(i < 4); return i == 0 ? a : i == 1 ? b : i == 2 ? c : d; } }; typedef T2<int, int, int> T; typedef F2<int, int, int, int> F; T mt(int a, int b, int c) { return T(a, b, c); } //@マクロ省略系 型,構造 #define ll long long #define double long double #define ull unsigned long long using dou = double; using itn = int; using str = string; using bo = bool; #define au auto using P = pair<int, int>; using pd = pair<dou, dou>; #define fi first #define se second #define beg begin #define rbeg rbegin #define con continue #define bre break #define brk break #define is == #define elf else if #define wh while #define maxq 1 #define minq -1 #define ZERO(a) memset(a, 0, sizeof(a)) #define MINUS(a) memset(a, 0xff, sizeof(a)) #define MALLOC(type, len) (type *)malloc((len) * sizeof(type)) #define lam(right) [&](int &p) { return p right; } //マクロ省略系 コンテナ using vi = vector<int>; using vb = vector<bool>; using vs = vector<string>; using vd = vector<double>; using vc = vector<char>; using vp = vector<P>; using vt = vector<T>; #define V vector #define o_vvt(o1, o2, o3, o4, name, ...) name #define vvt0(t) V<V<t>> #define vvt1(t, a) V<V<t>> a #define vvt2(t, a, b) V<V<t>> a(b) #define vvt3(t, a, b, c) V<V<t>> a(b, V<t>(c)) #define vvt4(t, a, b, c, d) V<V<t>> a(b, V<t>(c, d)) #define vvi(...) \ o_vvt(__VA_ARGS__, vvt4, vvt3, vvt2, vvt1, vvt0)(int, __VA_ARGS__) #define vvb(...) \ o_vvt(__VA_ARGS__, vvt4, vvt3, vvt2, vvt1, vvt0)(bool, __VA_ARGS__) #define vvs(...) \ o_vvt(__VA_ARGS__, vvt4, vvt3, vvt2, vvt1, vvt0)(string, __VA_ARGS__) #define vvd(...) \ o_vvt(__VA_ARGS__, vvt4, vvt3, vvt2, vvt1, vvt0)(double, __VA_ARGS__) #define vvc(...) \ o_vvt(__VA_ARGS__, vvt4, vvt3, vvt2, vvt1, vvt0)(char, __VA_ARGS__) #define vvp(...) \ o_vvt(__VA_ARGS__, vvt4, vvt3, vvt2, vvt1, vvt0)(P, __VA_ARGS__) template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); } template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); } #define vni(name, ...) auto name = make_v<int>(__VA_ARGS__) #define vnb(name, ...) auto name = make_v<bool>(__VA_ARGS__) #define vns(name, ...) auto name = make_v<string>(__VA_ARGS__) #define vnd(name, ...) auto name = make_v<double>(__VA_ARGS__) #define vnc(name, ...) auto name = make_v<char>(__VA_ARGS__) #define vnp(name, ...) auto name = make_v<P>(__VA_ARGS__) #define PQ priority_queue<int, vector<int>, greater<int>> #define tos to_string using mapi = map<int, int>; using mapp = map<P, int>; using mapd = map<dou, int>; using mapc = map<char, int>; using maps = map<str, int>; using seti = set<int>; using setd = set<dou>; using setc = set<char>; using sets = set<str>; using qui = queue<int>; #define bset bitset #define uset unordered_set #define mset multiset #define umap unordered_map #define umapi unordered_map<int, int> #define umapp unordered_map<P, int> #define mmap multimap template <class T> struct pq { priority_queue<T, vector<T>, greater<T>> q; /*小さい順*/ T su = 0; void clear() { q = priority_queue<T, vector<T>, greater<T>>(); su = 0; } void operator+=(T v) { su += v; q.push(v); } T sum() { return su; } T top() { return q.top(); } void pop() { su -= q.top(); q.pop(); } T poll() { T ret = q.top(); su -= ret; q.pop(); return ret; } int size() { return q.size(); } }; template <class T> struct pqg { priority_queue<T> q; /*大きい順*/ T su = 0; void clear() { q = priority_queue<T>(); su = 0; } void operator+=(T v) { su += v; q.push(v); } T sum() { return su; } T top() { return q.top(); } void pop() { su -= q.top(); q.pop(); } T poll() { T ret = q.top(); su -= ret; q.pop(); return ret; } int size() { return q.size(); } }; #define pqi pq<int> #define pqgi pqg<int> //マクロ 繰り返し #define o_rep(o1, o2, o3, o4, name, ...) name #define rep1(n) for (int rep1i = 0, rep1lim = n; rep1i < rep1lim; ++rep1i) #define rep2(i, n) for (int i = 0, rep2lim = n; i < rep2lim; ++i) #define rep3(i, m, n) for (int i = m, rep3lim = n; i < rep3lim; ++i) #define rep4(i, m, n, ad) for (int i = m, rep4lim = n; i < rep4lim; i += ad) #define rep(...) o_rep(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__) #define rer2(i, n) for (int i = n; i >= 0; i--) #define rer3(i, m, n) for (int i = m, rer3lim = n; i >= rer3lim; i--) #define rer4(i, m, n, dec) for (int i = m, rer4lim = n; i >= rer4lim; i -= dec) #define rer(...) o_rep(__VA_ARGS__, rer4, rer3, rer2, )(__VA_ARGS__) #define reps2(i, j, n) \ for (int i = 0, reps2lim = n; i < reps2lim; ++i) \ for (int j = 0; j < reps2lim; ++j) #define reps3(i, j, k, n) \ for (int i = 0, reps3lim = n; i < reps3lim; ++i) \ for (int j = 0; j < reps3lim; ++j) \ for (int k = 0; k < reps3lim; ++k) #define reps4(i, j, k, l, n) \ for (int i = 0, reps4lim = n; i < reps4lim; ++i) \ for (int j = 0; j < reps4lim; ++j) \ for (int k = 0; k < reps4lim; ++k) \ for (int l = 0; l < reps4lim; ++l) #define o_reps(o1, o2, o3, o4, o5, name, ...) name #define reps(...) o_reps(__VA_ARGS__, reps4, reps3, reps2, rep2, )(__VA_ARGS__) #define repss(i, j, k, a, b, c) \ for (int i = 0; i < a; ++i) \ for (int j = 0; j < b; ++j) \ for (int k = 0; k < c; ++k) #define fora(a, b) for (auto &&a : b) #define forg(gi, ve) \ for (int gi = 0, forglim = ve.size(), f, t, c; \ gi < forglim && (f = ve[gi].f, t = ve[gi].t, c = ve[gi].c, true); ++gi) #define fort(gi, ve) \ for (int gi = 0, f, t, c; \ gi < ve.size() && (f = ve[gi].f, t = ve[gi].t, c = ve[gi].c, true); \ ++gi) \ if (t != p) #define form(st, l, r) \ for (auto &&it = st.lower_bound(l); it != st.end() && (*it).fi < r; ++it) #define forit(st, l, r) \ for (auto &&it = st.lower_bound(l); it != st.end() && (*it) < r;) //マクロ 定数 #define k3 1010 #define k4 10101 #define k5 101010 #define k6 1010101 #define k7 10101010 const int inf = (int)1e9 + 100; const ll linf = (ll)1e18 + 100; const char infc = '{'; const string infs = "{"; const double eps = 1e-9; const double PI = 3.1415926535897932384626433832795029L; ll ma = numeric_limits<ll>::min(); ll mi = numeric_limits<ll>::max(); const int y4[] = {-1, 1, 0, 0}; const int x4[] = {0, 0, -1, 1}; const int y8[] = {0, 1, 0, -1, -1, 1, 1, -1}; const int x8[] = {1, 0, -1, 0, 1, -1, 1, -1}; //マクロ省略形 関数等 #define arsz(a) (sizeof(a) / sizeof(a[0])) #define sz(a) ((int)(a).size()) #define mp make_pair #define pb pop_back #define pf push_front #define eb emplace_back #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() constexpr bool ev(int a) { return !(a & 1); } constexpr bool od(int a) { return (a & 1); } //@拡張系 こう出来るべきというもの //埋め込み 存在を意識せずに機能を増やされているもの namespace std { template <> class hash<std::pair<signed, signed>> { public: size_t operator()(const std::pair<signed, signed> &x) const { return hash<ll>()(((ll)x.first << 32) + x.second); } }; template <> class hash<std::pair<ll, ll>> { public : /*大きいllが渡されると、<<32でオーバーフローするがとりあえず問題ないと判断*/ size_t operator()(const std::pair<ll, ll> &x) const { return hash<ll>()(((ll)x.first << 32) + x.second); } }; } // namespace std // stream まとめ istream &operator>>(istream &iss, P &a) { iss >> a.first >> a.second; return iss; } template <typename T> istream &operator>>(istream &iss, vector<T> &vec) { for (T &x : vec) iss >> x; return iss; } template <class T, class U> ostream &operator<<(ostream &os, pair<T, U> p) { os << p.fi << " " << p.se << endl; return os; } ostream &operator<<(ostream &os, T p) { os << p.f << " " << p.s << " " << p.t; return os; } ostream &operator<<(ostream &os, F p) { os << p.a << " " << p.b << " " << p.c << " " << p.d; return os; } template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) { for (int i = 0; i < vec.size(); ++i) os << vec[i] << (i + 1 == vec.size() ? "" : " "); return os; } template <typename T> ostream &operator<<(ostream &os, vector<vector<T>> &vec) { for (int i = 0; i < vec.size(); ++i) { for (int j = 0; j < vec[0].size(); ++j) { os << vec[i][j]; } os << endl; } return os; } template <typename T, typename U> ostream &operator<<(ostream &os, map<T, U> &m) { for (auto &&v : m) os << v; return os; } template <typename W, typename H> void resize(vector<W> &vec, const H head) { vec.resize(head); } template <typename W, typename H, typename... T> void resize(vector<W> &vec, const H &head, const T... tail) { vec.resize(head); for (auto &v : vec) resize(v, tail...); } template <typename T, typename F> bool all_of2(T &v, F f) { return f(v); } template <typename T, typename F> bool all_of2(vector<T> &v, F f) { rep(i, sz(v)) { if (!all_of2(v[i], f)) return false; } return true; } template <typename T, typename F> bool any_of2(T &v, F f) { return f(v); } template <typename T, typename F> bool any_of2(vector<T> &v, F f) { rep(i, sz(v)) { if (any_of2(v[i], f)) return true; } return false; } template <typename T, typename F> bool none_of2(T &v, F f) { return f(v); } template <typename T, typename F> bool none_of2(vector<T> &v, F f) { rep(i, sz(v)) { if (none_of2(v[i], f)) return false; } return true; } template <typename T, typename F> bool find_if2(T &v, F f) { return f(v); } template <typename T, typename F> int find_if2(vector<T> &v, F f) { rep(i, sz(v)) { if (find_if2(v[i], f)) return i; } return sz(v); } template <typename T, typename F> bool rfind_if2(T &v, F f) { return f(v); } template <typename T, typename F> int rfind_if2(vector<T> &v, F f) { rer(i, sz(v) - 1) { if (rfind_if2(v[i], f)) return i; } return -1; } template <class T> bool contains(string &s, const T &v) { return s.find(v) != string::npos; } template <typename T> bool contains(vector<T> &v, const T &val) { return std::find(v.begin(), v.end(), val) != v.end(); } template <typename T, typename F> bool contains_if2(vector<T> &v, F f) { return find_if(v.begin(), v.end(), f) != v.end(); } template <typename T, typename F> int count_if2(T &v, F f) { return f(v); } template <typename T, typename F> int count_if2(vector<T> &vec, F f) { int ret = 0; fora(v, vec) ret += count_if2(v, f); return ret; } template <typename T, typename F> void for_each2(T &v, F f) { f(v); } template <typename T, typename F> void for_each2(vector<T> &vec, F f) { fora(v, vec) for_each2(v, f); } template <typename W> int count_od(vector<W> &a) { return count_if2(a, [](int v) { return v & 1; }); } template <typename W> int count_ev(vector<W> &a) { return count_if2(a, [](int v) { return !(v & 1); }); } #define all_of(a, right) all_of2(a, lam(right)) #define any_of(a, right) any_of2(a, lam(right)) #define none_of(a, right) none_of2(a, lam(right)) #define find_if(a, right) find_if2(a, lam(right)) #define rfind_if(a, right) rfind_if2(a, lam(right)) #define contains_if(a, right) contains_if2(a, lam(right)) #define count_if(a, right) count_if2(a, lam(right)) #define for_each(a, right) \ do { \ fora(v, a) { v right; } \ } while (0) template <class T, class U> void replace(vector<T> &a, T key, U v) { replace(a.begin(), a.end(), key, v); } void replace(str &a, char key, str v) { if (v == "") a.erase(remove(all(a), key), a.end()); } void replace(str &a, char key, char v) { replace(all(a), key, v); } // keyと同じかどうか01で置き換える template <class T, class U> void replace(vector<T> &a, U k) { rep(i, sz(a)) a[i] = a[i] == k; } template <class T, class U> void replace(vector<vector<T>> &a, U k) { rep(i, sz(a)) rep(j, sz(a[0])) a[i][j] = a[i][j] == k; } template <class T> void replace(T &a) { replace(a, '#'); } void replace(str &a, str key, str v) { stringstream t; int kn = sz(key); std::string::size_type Pos(a.find(key)); int l = 0; while (Pos != std::string::npos) { t << a.substr(l, Pos - l); t << v; l = Pos + kn; Pos = a.find(key, Pos + kn); } t << a.substr(l, sz(a) - l); a = t.str(); } template <class T> bool includes(vector<T> &a, vector<T> &b) { vi c = a; vi d = b; sort(all(c)); sort(all(d)); return includes(all(c), all(d)); } template <class T> bool is_permutation(vector<T> &a, vector<T> &b) { return is_permutation(all(a), all(b)); } template <class T> bool next_permutation(vector<T> &a) { return next_permutation(all(a)); } void iota(vector<int> &ve, int s, int n) { ve.resize(n); iota(all(ve), s); } vi iota(int s, int len) { vi ve(len); iota(all(ve), s); return ve; } template <class A, class B> auto vtop(vector<A> &a, vector<B> &b) { assert(sz(a) == sz(b)); /*stringを0で初期化できない */ vector<pair<A, B>> res; rep(i, sz(a)) res.eb(a[i], b[i]); return res; } template <class A, class B> void ptov(vector<pair<A, B>> &p, vector<A> &a, vector<B> &b) { a.resize(sz(p)), b.resize(sz(p)); rep(i, sz(p)) a[i] = p[i].fi, b[i] = p[i].se; } template <class A, class B, class C> auto vtot(vector<A> &a, vector<B> &b, vector<C> &c) { assert(sz(a) == sz(b) && sz(b) == sz(c)); vector<T2<A, B, C>> res; rep(i, sz(a)) res.eb(a[i], b[i], c[i]); return res; } template <class A, class B, class C, class D> auto vtof(vector<A> &a, vector<B> &b, vector<C> &c, vector<D> &d) { assert(sz(a) == sz(b) && sz(b) == sz(c) && sz(c) == sz(d)); vector<F2<A, B, C, D>> res; rep(i, sz(a)) res.eb(a[i], b[i], c[i], d[i]); return res; } enum pcomparator { fisi, fisd, fdsi, fdsd, sifi, sifd, sdfi, sdfd }; enum tcomparator { fisiti, fisitd, fisdti, fisdtd, fdsiti, fdsitd, fdsdti, fdsdtd, fitisi, fitisd, fitdsi, fitdsd, fdtisi, fdtisd, fdtdsi, fdtdsd, sifiti, sifitd, sifdti, sifdtd, sdfiti, sdfitd, sdfdti, sdfdtd, sitifi, sitifd, sitdfi, sitdfd, sdtifi, sdtifd, sdtdfi, sdfdfd, tifisi, tifisd, tifdsi, tifdsd, tdfisi, tdfisd, tdfdsi, tdfdsd, tisifi, tisifd, tisdfi, tisdfd, tdsifi, tdsifd, tdsdfi, tdsdfd }; template <class A, class B> void sort(vector<pair<A, B>> &a, pcomparator type) { typedef pair<A, B> U; if (type == fisi) sort(all(a), [&](U l, U r) { return l.fi != r.fi ? l.fi < r.fi : l.se < r.se; }); else if (type == fisd) sort(all(a), [&](U l, U r) { return l.fi != r.fi ? l.fi < r.fi : l.se > r.se; }); else if (type == fdsi) sort(all(a), [&](U l, U r) { return l.fi != r.fi ? l.fi > r.fi : l.se < r.se; }); else if (type == fdsd) sort(all(a), [&](U l, U r) { return l.fi != r.fi ? l.fi > r.fi : l.se > r.se; }); else if (type == sifi) sort(all(a), [&](U l, U r) { return l.se != r.se ? l.se < r.se : l.fi < r.fi; }); else if (type == sifd) sort(all(a), [&](U l, U r) { return l.se != r.se ? l.se < r.se : l.fi > r.fi; }); else if (type == sdfi) sort(all(a), [&](U l, U r) { return l.se != r.se ? l.se > r.se : l.fi < r.fi; }); else if (type == sdfd) sort(all(a), [&](U l, U r) { return l.se != r.se ? l.se > r.se : l.fi > r.fi; }); }; template <class U> void sort(vector<U> &a, pcomparator type) { if (type == fisi) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f < r.f : l.s < r.s; }); else if (type == fisd) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f < r.f : l.s > r.s; }); else if (type == fdsi) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f > r.f : l.s < r.s; }); else if (type == fdsd) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f > r.f : l.s > r.s; }); else if (type == sifi) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s < r.s : l.f < r.f; }); else if (type == sifd) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s < r.s : l.f > r.f; }); else if (type == sdfi) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s > r.s : l.f < r.f; }); else if (type == sdfd) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s > r.s : l.f > r.f; }); }; template <class A, class B, class C, class D> void sort(vector<F2<A, B, C, D>> &a, pcomparator type) { typedef F2<A, B, C, D> U; if (type == fisi) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a < r.a : l.b < r.b; }); else if (type == fisd) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a < r.a : l.b > r.b; }); else if (type == fdsi) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a > r.a : l.b < r.b; }); else if (type == fdsd) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a > r.a : l.b > r.b; }); else if (type == sifi) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b < r.b : l.a < r.a; }); else if (type == sifd) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b < r.b : l.a > r.a; }); else if (type == sdfi) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b > r.b : l.a < r.a; }); else if (type == sdfd) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b > r.b : l.a > r.a; }); }; template <class U> void sort(vector<U> &a, tcomparator type) { if (type == 0) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f < r.f : l.s != r.s ? l.s < r.s : l.t < r.t; }); else if (type == 1) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f < r.f : l.s != r.s ? l.s < r.s : l.t > r.t; }); else if (type == 2) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f < r.f : l.s != r.s ? l.s > r.s : l.t < r.t; }); else if (type == 3) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f < r.f : l.s != r.s ? l.s > r.s : l.t > r.t; }); else if (type == 4) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f > r.f : l.s != r.s ? l.s < r.s : l.t < r.t; }); else if (type == 5) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f > r.f : l.s != r.s ? l.s < r.s : l.t > r.t; }); else if (type == 6) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f > r.f : l.s != r.s ? l.s > r.s : l.t < r.t; }); else if (type == 7) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f > r.f : l.s != r.s ? l.s > r.s : l.t > r.t; }); else if (type == 8) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f < r.f : l.t != r.t ? l.t < r.t : l.s < r.s; }); else if (type == 9) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f < r.f : l.t != r.t ? l.t < r.t : l.s > r.s; }); else if (type == 10) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f < r.f : l.t != r.t ? l.t > r.t : l.s < r.s; }); else if (type == 11) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f < r.f : l.t != r.t ? l.t > r.t : l.s > r.s; }); else if (type == 12) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f > r.f : l.t != r.t ? l.t < r.t : l.s < r.s; }); else if (type == 13) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f > r.f : l.t != r.t ? l.t < r.t : l.s > r.s; }); else if (type == 14) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f > r.f : l.t != r.t ? l.t > r.t : l.s < r.s; }); else if (type == 15) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f > r.f : l.t != r.t ? l.t > r.t : l.s > r.s; }); else if (type == 16) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s < r.s : l.f != r.f ? l.f < r.f : l.t < r.t; }); else if (type == 17) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s < r.s : l.f != r.f ? l.f < r.f : l.t > r.t; }); else if (type == 18) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s < r.s : l.f != r.f ? l.f > r.f : l.t < r.t; }); else if (type == 19) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s < r.s : l.f != r.f ? l.f > r.f : l.t > r.t; }); else if (type == 20) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s > r.s : l.f != r.f ? l.f < r.f : l.t < r.t; }); else if (type == 21) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s > r.s : l.f != r.f ? l.f < r.f : l.t > r.t; }); else if (type == 22) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s > r.s : l.f != r.f ? l.f > r.f : l.t < r.t; }); else if (type == 23) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s > r.s : l.f != r.f ? l.f > r.f : l.t > r.t; }); else if (type == 24) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s < r.s : l.t != r.t ? l.t < r.t : l.f < r.f; }); else if (type == 25) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s < r.s : l.t != r.t ? l.t < r.t : l.f > r.f; }); else if (type == 26) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s < r.s : l.t != r.t ? l.t > r.t : l.f < r.f; }); else if (type == 27) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s < r.s : l.t != r.t ? l.t > r.t : l.f > r.f; }); else if (type == 28) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s > r.s : l.t != r.t ? l.t < r.t : l.f < r.f; }); else if (type == 29) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s > r.s : l.t != r.t ? l.t < r.t : l.f > r.f; }); else if (type == 30) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s > r.s : l.t != r.t ? l.t > r.t : l.f < r.f; }); else if (type == 31) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s > r.s : l.t != r.t ? l.t > r.t : l.f > r.f; }); else if (type == 32) sort(all(a), [&](U l, U r) { return l.t != r.t ? l.t < r.t : l.f != r.f ? l.f < r.f : l.s < r.s; }); else if (type == 33) sort(all(a), [&](U l, U r) { return l.t != r.t ? l.t < r.t : l.f != r.f ? l.f < r.f : l.s > r.s; }); else if (type == 34) sort(all(a), [&](U l, U r) { return l.t != r.t ? l.t < r.t : l.f != r.f ? l.f > r.f : l.s < r.s; }); else if (type == 35) sort(all(a), [&](U l, U r) { return l.t != r.t ? l.t < r.t : l.f != r.f ? l.f > r.f : l.s > r.s; }); else if (type == 36) sort(all(a), [&](U l, U r) { return l.t != r.t ? l.t > r.t : l.f != r.f ? l.f < r.f : l.s < r.s; }); else if (type == 37) sort(all(a), [&](U l, U r) { return l.t != r.t ? l.t > r.t : l.f != r.f ? l.f < r.f : l.s > r.s; }); else if (type == 38) sort(all(a), [&](U l, U r) { return l.t != r.t ? l.t > r.t : l.f != r.f ? l.f > r.f : l.s < r.s; }); else if (type == 39) sort(all(a), [&](U l, U r) { return l.t != r.t ? l.t > r.t : l.f != r.f ? l.f > r.f : l.s > r.s; }); else if (type == 40) sort(all(a), [&](U l, U r) { return l.t != r.t ? l.t < r.t : l.s != r.s ? l.s < r.s : l.f < r.f; }); else if (type == 41) sort(all(a), [&](U l, U r) { return l.t != r.t ? l.t < r.t : l.s != r.s ? l.s < r.s : l.f > r.f; }); else if (type == 42) sort(all(a), [&](U l, U r) { return l.t != r.t ? l.t < r.t : l.s != r.s ? l.s > r.s : l.f < r.f; }); else if (type == 43) sort(all(a), [&](U l, U r) { return l.t != r.t ? l.t < r.t : l.s != r.s ? l.s > r.s : l.f > r.f; }); else if (type == 44) sort(all(a), [&](U l, U r) { return l.t != r.t ? l.t > r.t : l.s != r.s ? l.s < r.s : l.f < r.f; }); else if (type == 45) sort(all(a), [&](U l, U r) { return l.t != r.t ? l.t > r.t : l.s != r.s ? l.s < r.s : l.f > r.f; }); else if (type == 46) sort(all(a), [&](U l, U r) { return l.t != r.t ? l.t > r.t : l.s != r.s ? l.s > r.s : l.f < r.f; }); else if (type == 47) sort(all(a), [&](U l, U r) { return l.t != r.t ? l.t > r.t : l.s != r.s ? l.s > r.s : l.f > r.f; }); } template <class A, class B, class C, class D> void sort(vector<F2<A, B, C, D>> &a, tcomparator type) { typedef F2<A, B, C, D> U; if (type == 0) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a < r.a : l.b != r.b ? l.b < r.b : l.c < r.c; }); else if (type == 1) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a < r.a : l.b != r.b ? l.b < r.b : l.c > r.c; }); else if (type == 2) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a < r.a : l.b != r.b ? l.b > r.b : l.c < r.c; }); else if (type == 3) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a < r.a : l.b != r.b ? l.b > r.b : l.c > r.c; }); else if (type == 4) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a > r.a : l.b != r.b ? l.b < r.b : l.c < r.c; }); else if (type == 5) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a > r.a : l.b != r.b ? l.b < r.b : l.c > r.c; }); else if (type == 6) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a > r.a : l.b != r.b ? l.b > r.b : l.c < r.c; }); else if (type == 7) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a > r.a : l.b != r.b ? l.b > r.b : l.c > r.c; }); else if (type == 8) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a < r.a : l.c != r.c ? l.c < r.c : l.b < r.b; }); else if (type == 9) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a < r.a : l.c != r.c ? l.c < r.c : l.b > r.b; }); else if (type == 10) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a < r.a : l.c != r.c ? l.c > r.c : l.b < r.b; }); else if (type == 11) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a < r.a : l.c != r.c ? l.c > r.c : l.b > r.b; }); else if (type == 12) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a > r.a : l.c != r.c ? l.c < r.c : l.b < r.b; }); else if (type == 13) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a > r.a : l.c != r.c ? l.c < r.c : l.b > r.b; }); else if (type == 14) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a > r.a : l.c != r.c ? l.c > r.c : l.b < r.b; }); else if (type == 15) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a > r.a : l.c != r.c ? l.c > r.c : l.b > r.b; }); else if (type == 16) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b < r.b : l.a != r.a ? l.a < r.a : l.c < r.c; }); else if (type == 17) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b < r.b : l.a != r.a ? l.a < r.a : l.c > r.c; }); else if (type == 18) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b < r.b : l.a != r.a ? l.a > r.a : l.c < r.c; }); else if (type == 19) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b < r.b : l.a != r.a ? l.a > r.a : l.c > r.c; }); else if (type == 20) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b > r.b : l.a != r.a ? l.a < r.a : l.c < r.c; }); else if (type == 21) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b > r.b : l.a != r.a ? l.a < r.a : l.c > r.c; }); else if (type == 22) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b > r.b : l.a != r.a ? l.a > r.a : l.c < r.c; }); else if (type == 23) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b > r.b : l.a != r.a ? l.a > r.a : l.c > r.c; }); else if (type == 24) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b < r.b : l.c != r.c ? l.c < r.c : l.a < r.a; }); else if (type == 25) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b < r.b : l.c != r.c ? l.c < r.c : l.a > r.a; }); else if (type == 26) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b < r.b : l.c != r.c ? l.c > r.c : l.a < r.a; }); else if (type == 27) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b < r.b : l.c != r.c ? l.c > r.c : l.a > r.a; }); else if (type == 28) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b > r.b : l.c != r.c ? l.c < r.c : l.a < r.a; }); else if (type == 29) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b > r.b : l.c != r.c ? l.c < r.c : l.a > r.a; }); else if (type == 30) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b > r.b : l.c != r.c ? l.c > r.c : l.a < r.a; }); else if (type == 31) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b > r.b : l.c != r.c ? l.c > r.c : l.a > r.a; }); else if (type == 32) sort(all(a), [&](U l, U r) { return l.c != r.c ? l.c < r.c : l.a != r.a ? l.a < r.a : l.b < r.b; }); else if (type == 33) sort(all(a), [&](U l, U r) { return l.c != r.c ? l.c < r.c : l.a != r.a ? l.a < r.a : l.b > r.b; }); else if (type == 34) sort(all(a), [&](U l, U r) { return l.c != r.c ? l.c < r.c : l.a != r.a ? l.a > r.a : l.b < r.b; }); else if (type == 35) sort(all(a), [&](U l, U r) { return l.c != r.c ? l.c < r.c : l.a != r.a ? l.a > r.a : l.b > r.b; }); else if (type == 36) sort(all(a), [&](U l, U r) { return l.c != r.c ? l.c > r.c : l.a != r.a ? l.a < r.a : l.b < r.b; }); else if (type == 37) sort(all(a), [&](U l, U r) { return l.c != r.c ? l.c > r.c : l.a != r.a ? l.a < r.a : l.b > r.b; }); else if (type == 38) sort(all(a), [&](U l, U r) { return l.c != r.c ? l.c > r.c : l.a != r.a ? l.a > r.a : l.b < r.b; }); else if (type == 39) sort(all(a), [&](U l, U r) { return l.c != r.c ? l.c > r.c : l.a != r.a ? l.a > r.a : l.b > r.b; }); else if (type == 40) sort(all(a), [&](U l, U r) { return l.c != r.c ? l.c < r.c : l.b != r.b ? l.b < r.b : l.a < r.a; }); else if (type == 41) sort(all(a), [&](U l, U r) { return l.c != r.c ? l.c < r.c : l.b != r.b ? l.b < r.b : l.a > r.a; }); else if (type == 42) sort(all(a), [&](U l, U r) { return l.c != r.c ? l.c < r.c : l.b != r.b ? l.b > r.b : l.a < r.a; }); else if (type == 43) sort(all(a), [&](U l, U r) { return l.c != r.c ? l.c < r.c : l.b != r.b ? l.b > r.b : l.a > r.a; }); else if (type == 44) sort(all(a), [&](U l, U r) { return l.c != r.c ? l.c > r.c : l.b != r.b ? l.b < r.b : l.a < r.a; }); else if (type == 45) sort(all(a), [&](U l, U r) { return l.c != r.c ? l.c > r.c : l.b != r.b ? l.b < r.b : l.a > r.a; }); else if (type == 46) sort(all(a), [&](U l, U r) { return l.c != r.c ? l.c > r.c : l.b != r.b ? l.b > r.b : l.a < r.a; }); else if (type == 47) sort(all(a), [&](U l, U r) { return l.c != r.c ? l.c > r.c : l.b != r.b ? l.b > r.b : l.a > r.a; }); } void sort(string &a) { sort(all(a)); } template <class T> void sort(vector<T> &a) { sort(all(a)); } // P l, P rで f(P) の形で渡す template <class U, class F> void sort(vector<U> &a, F f) { sort(all(a), [&](U l, U r) { return f(l) < f(r); }); }; template <class T> void rsort(vector<T> &a) { sort(all(a), greater<T>()); }; template <class U, class F> void rsort(vector<U> &a, F f) { sort(all(a), [&](U l, U r) { return f(l) > f(r); }); }; // F = T<T> //例えばreturn p.fi + p.se; template <class A, class B> void sortp(vector<A> &a, vector<B> &b) { auto c = vtop(a, b); sort(c); rep(i, sz(a)) a[i] = c[i].fi, b[i] = c[i].se; } template <class A, class B, class F> void sortp(vector<A> &a, vector<B> &b, F f) { auto c = vtop(a, b); sort(c, f); rep(i, sz(a)) a[i] = c[i].fi, b[i] = c[i].se; } template <class A, class B> void rsortp(vector<A> &a, vector<B> &b) { auto c = vtop(a, b); rsort(c); rep(i, sz(a)) a[i] = c[i].first, b[i] = c[i].second; } template <class A, class B, class F> void rsortp(vector<A> &a, vector<B> &b, F f) { auto c = vtop(a, b); rsort(c, f); rep(i, sz(a)) a[i] = c[i].first, b[i] = c[i].second; } template <class A, class B, class C> void sortt(vector<A> &a, vector<B> &b, vector<C> &c) { auto d = vtot(a, b, c); sort(d); rep(i, sz(a)) a[i] = d[i].f, b[i] = d[i].s, c[i] = d[i].t; } template <class A, class B, class C, class F> void sortt(vector<A> &a, vector<B> &b, vector<C> &c, F f) { auto d = vtot(a, b, c); sort(d, f); rep(i, sz(a)) a[i] = d[i].f, b[i] = d[i].s, c[i] = d[i].t; } template <class A, class B, class C> void rsortt(vector<A> &a, vector<B> &b, vector<C> &c) { auto d = vtot(a, b, c); rsort(d); rep(i, sz(a)) a[i] = d[i].f, b[i] = d[i].s, c[i] = d[i].t; } template <class A, class B, class C, class F> void rsortt(vector<A> &a, vector<B> &b, vector<C> &c, F f) { auto d = vtot(a, b, c); rsort(d, f); rep(i, sz(a)) a[i] = d[i].f, b[i] = d[i].s, c[i] = d[i].t; } // sortindex 元のvectorはソートしない template <class T> vi sorti(vector<T> &a) { auto b = a; vi ind = iota(0, sz(a)); sortp(b, ind); return ind; } /*indexの分で型が変わるためpcomparatorが必要*/ template <class T> vi sorti(vector<T> &a, pcomparator f) { auto b = a; vi ind = iota(0, sz(a)); sortp(b, ind, f); return ind; } template <class T, class F> vi sorti(vector<T> &a, F f) { vi ind = iota(0, sz(a)); sort(all(ind), [&](int x, int y) { return f(a[x]) < f(a[y]); }); return ind; } template <class T> vi rsorti(vector<T> &a) { auto b = a; vi ind = iota(0, sz(a)); rsortp(b, ind); return ind; } template <class T, class F> vi rsorti(vector<T> &a, F f) { vi ind = iota(0, sz(a)); sort(all(ind), [&](int x, int y) { return f(a[x]) > f(a[y]); }); return ind; } template <class A, class B, class F> vi sortpi(vector<A> &a, vector<B> &b, F f) { auto c = vtop(a, b); vi ind = iota(0, sz(a)); sort(all(ind), [&](int x, int y) { return f(c[x]) < f(c[y]); }); return ind; } template <class A, class B> vi sortpi(vector<A> &a, vector<B> &b, pcomparator f) { vi ind = iota(0, sz(a)); auto c = a; auto d = b; sortt(c, d, ind, f); return ind; } template <class A, class B> vi sortpi(vector<A> &a, vector<B> &b) { return sortpi(a, b, fisi); }; template <class A, class B, class F> vi rsortpi(vector<A> &a, vector<B> &b, F f) { auto c = vtop(a, b); vi ind = iota(0, sz(a)); sort(all(ind), [&](int x, int y) { return f(c[x]) > f(c[y]); }); return ind; } template <class A, class B> vi rsortpi(vector<A> &a, vector<B> &b) { return sortpi(a, b, fdsd); }; template <class A, class B, class C, class F> vi sortti(vector<A> &a, vector<B> &b, vector<C> &c, F f) { auto d = vtot(a, b, c); vi ind = iota(0, sz(a)); sort(all(ind), [&](int x, int y) { return f(d[x]) < f(d[y]); }); return ind; } template <class A, class B, class C> vi sortti(vector<A> &a, vector<B> &b, vector<C> &c, pcomparator f) { vi ind = iota(0, sz(a)); auto d = vtof(a, b, c, ind); sort(d, f); rep(i, sz(a)) ind[i] = d[i].d; return ind; } template <class A, class B, class C> vi sortti(vector<A> &a, vector<B> &b, vector<C> &c) { vi ind = iota(0, sz(a)); sort(all(ind), [&](int x, int y) { if (a[x] == a[y]) { if (b[x] == b[y]) return c[x] < c[y]; else return b[x] < b[y]; } else { return a[x] < a[y]; } }); return ind; } template <class A, class B, class C, class F> vi rsortti(vector<A> &a, vector<B> &b, vector<C> &c, F f) { auto d = vtot(a, b, c); vi ind = iota(0, sz(a)); sort(all(ind), [&](int x, int y) { return f(d[x]) > f(d[y]); }); return ind; } template <class A, class B, class C> vi rsortti(vector<A> &a, vector<B> &b, vector<C> &c) { vi ind = iota(0, sz(a)); sort(all(ind), [&](int x, int y) { if (a[x] == a[y]) { if (b[x] == b[y]) return c[x] > c[y]; else return b[x] > b[y]; } else { return a[x] > a[y]; } }); return ind; } template <class T> void sort2(vector<vector<T>> &a) { for (int i = 0, n = a.size(); i < n; ++i) sort(a[i]); } template <class T> void rsort2(vector<vector<T>> &a) { for (int i = 0, n = a.size(); i < n; ++i) rsort(a[i]); } template <typename A, size_t N, typename T> void fill(A (&a)[N], const T &v) { rep(i, N) a[i] = v; } template <typename A, size_t N, size_t O, typename T> void fill(A (&a)[N][O], const T &v) { rep(i, N) rep(j, O) a[i][j] = v; } template <typename A, size_t N, size_t O, size_t P, typename T> void fill(A (&a)[N][O][P], const T &v) { rep(i, N) rep(j, O) rep(k, P) a[i][j][k] = v; } template <typename A, size_t N, size_t O, size_t P, size_t Q, typename T> void fill(A (&a)[N][O][P][Q], const T &v) { rep(i, N) rep(j, O) rep(k, P) rep(l, Q) a[i][j][k][l] = v; } template <typename A, size_t N, size_t O, size_t P, size_t Q, size_t R, typename T> void fill(A (&a)[N][O][P][Q][R], const T &v) { rep(i, N) rep(j, O) rep(k, P) rep(l, Q) rep(m, R) a[i][j][k][l][m] = v; } template <typename A, size_t N, size_t O, size_t P, size_t Q, size_t R, size_t S, typename T> void fill(A (&a)[N][O][P][Q][R][S], const T &v) { rep(i, N) rep(j, O) rep(k, P) rep(l, Q) rep(m, R) rep(n, S) a[i][j][k][l][m][n] = v; } template <typename W, typename T> void fill(W &xx, const T vall) { xx = vall; } template <typename W, typename T> void fill(vector<W> &vecc, const T vall) { for (auto &&vx : vecc) fill(vx, vall); } template <class T, class U> void fill(vector<T> &a, U val, vi &ind) { fora(v, ind) a[v] = val; } template <typename A, size_t N> A sum(A (&a)[N]) { A res = 0; rep(i, N) res += a[i]; return res; } template <typename A, size_t N, size_t O> A sum(A (&a)[N][O]) { A res = 0; rep(i, N) rep(j, O) res += a[i][j]; return res; } template <typename A, size_t N, size_t O, size_t P> A sum(A (&a)[N][O][P]) { A res = 0; rep(i, N) rep(j, O) rep(k, P) res += a[i][j][k]; return res; } template <typename A, size_t N, size_t O, size_t P, size_t Q> A sum(A (&a)[N][O][P][Q]) { A res = 0; rep(i, N) rep(j, O) rep(k, P) rep(l, Q) res += a[i][j][k][l]; return res; } template <typename A, size_t N, size_t O, size_t P, size_t Q, size_t R> A sum(A (&a)[N][O][P][Q][R]) { A res = 0; rep(i, N) rep(j, O) rep(k, P) rep(l, Q) rep(m, R) res += a[i][j][k][l][m]; return res; } template <typename A, size_t N, size_t O, size_t P, size_t Q, size_t R, size_t S> A sum(A (&a)[N][O][P][Q][R][S]) { A res = 0; rep(i, N) rep(j, O) rep(k, P) rep(l, Q) rep(m, R) rep(n, S) res += a[i][j][k][l][m][n]; return res; } //@汎用便利関数 入力 int in() { int ret; cin >> ret; return ret; } string sin() { string ret; cin >> ret; return ret; } template <class T> void in(T &head) { cin >> head; } template <class T, class... U> void in(T &head, U &...tail) { cin >> head; in(tail...); } #define o_din(o1, o2, o3, o4, name, ...) name #define din1(a) \ int a; \ cin >> a #define din2(a, b) \ int a, b; \ cin >> a >> b #define din3(a, b, c) \ int a, b, c; \ cin >> a >> b >> c #define din4(a, b, c, d) \ int a, b, c, d; \ cin >> a >> b >> c >> d #define din(...) o_din(__VA_ARGS__, din4, din3, din2, din1)(__VA_ARGS__) #define o_dind(o1, o2, o3, o4, name, ...) name #define din1d(a) \ din1(a); \ a-- #define din2d(a, b) \ din2(a, b); \ a--, b-- #define din3d(a, b, c) \ din3(a, b, c); \ a--, b--, c-- #define din4d(a, b, c, d) \ din4(a, b, c, d); \ a--, b--, c--, d-- #define dind(...) o_dind(__VA_ARGS__, din4d, din3d, din2d, din1d)(__VA_ARGS__) #define o_out(o1, o2, o3, o4, name, ...) name #define out1(a) cout << a << endl #define out2(a, b) cout << a << " " << b << endl #define out3(a, b, c) cout << a << " " << b << " " << c << endl #define out4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl #define out(...) o_out((__VA_ARGS__), out4, out3, out2, out1)((__VA_ARGS__)) template <class T> void outl(vector<T> &a) { fora(v, a) cout << v << endl; } template <class T> void na(vector<T> &a, int n) { a.resize(n); rep(i, n) cin >> a[i]; } #define dna(a, n) \ vi a(n); \ rep(dnai, n) cin >> a[dnai]; template <class T> void nao(vector<T> &a, int n) { a.resize(n + 1); a[0] = 0; rep(i, n) cin >> a[i + 1]; } template <class T> void naod(vector<T> &a, int n) { a.resize(n + 1); a[0] = 0; rep(i, n) cin >> a[i + 1], a[i + 1]--; } template <class T> void nad(vector<T> &a, int n) { a.resize(n); rep(i, n) cin >> a[i], a[i]--; } template <class T, class U> void na2(vector<T> &a, vector<U> &b, int n) { a.resize(n); b.resize(n); rep(i, n) cin >> a[i] >> b[i]; } #define dna2(a, b, n) \ vi a(n), b(n); \ rep(dna2i, n) cin >> a[dna2i] >> b[dna2i]; template <class T, class U> void nao2(vector<T> &a, vector<U> &b, int n) { a.resize(n + 1); b.resize(n + 1); a[0] = b[0] = 0; rep(i, n) cin >> a[i + 1] >> b[i + 1]; } #define dna2d(a, b, n) \ vi a(n), b(n); \ rep(dna2di, n) { \ cin >> a[dna2di] >> b[dna2di]; \ a[dna2di]--, b[dna2di]--; \ } template <class T, class U> void na2d(vector<T> &a, vector<U> &b, int n) { a.resize(n); b.resize(n); rep(i, n) cin >> a[i] >> b[i], a[i]--, b[i]--; } template <class T, class U, class W> void na3(vector<T> &a, vector<U> &b, vector<W> &c, int n) { a.resize(n); b.resize(n); c.resize(n); rep(i, n) cin >> a[i] >> b[i] >> c[i]; } #define dna3(a, b, c, n) \ vi a(n), b(n), c(n); \ rep(dna3i, n) cin >> a[dna3i] >> b[dna3i] >> c[dna3i]; template <class T, class U, class W> void na3d(vector<T> &a, vector<U> &b, vector<W> &c, int n) { a.resize(n); b.resize(n); c.resize(n); rep(i, n) cin >> a[i] >> b[i] >> c[i], a[i]--, b[i]--, c[i]--; } #define dna3d(a, b, c, n) \ vi a(n), b(n), c(n); \ rep(dna3di, n) { \ cin >> a[dna3di] >> b[dna3di] >> c[dna3di]; \ a[dna3di]--, b[dna3di]--, c[dna3di]--; \ } #define nt(a, h, w) \ resize(a, h, w); \ rep(nthi, h) rep(ntwi, w) cin >> a[nthi][ntwi]; #define ntd(a, h, w) \ resize(a, h, w); \ rep(ntdhi, h) rep(ntdwi, w) cin >> a[ntdhi][ntdwi], a[ntdhi][ntdwi]--; #define ntp(a, h, w) \ resize(a, h + 2, w + 2); \ fill(a, '#'); \ rep(ntphi, 1, h + 1) rep(ntpwi, 1, w + 1) cin >> a[ntphi][ntpwi]; //デバッグ #define sp << " " << #define debugName(VariableName) #VariableName #define deb1(x) debugName(x) << " = " << x #define deb2(x, ...) deb1(x) << ", " << deb1(__VA_ARGS__) #define deb3(x, ...) deb1(x) << ", " << deb2(__VA_ARGS__) #define deb4(x, ...) deb1(x) << ", " << deb3(__VA_ARGS__) #define deb5(x, ...) deb1(x) << ", " << deb4(__VA_ARGS__) #define deb6(x, ...) deb1(x) << ", " << deb5(__VA_ARGS__) #define deb7(x, ...) deb1(x) << ", " << deb6(__VA_ARGS__) #define deb8(x, ...) deb1(x) << ", " << deb7(__VA_ARGS__) #define deb9(x, ...) deb1(x) << ", " << deb8(__VA_ARGS__) #define deb10(x, ...) deb1(x) << ", " << deb9(__VA_ARGS__) #define o_ebug(o1, o2, o3, o4, o5, o6, o7, o8, o9, o10, name, ...) name #ifdef _DEBUG #define deb(...) \ cerr << o_ebug(__VA_ARGS__, deb10, deb9, deb8, deb7, deb6, deb5, deb4, deb3, \ deb2, deb1)(__VA_ARGS__) \ << endl #else #define deb(...) ; #endif #define debugline(x) \ cerr << x << " " \ << "(L:" << __LINE__ << ")" << '\n' //よく使うクラス、構造体 class UnionFind { public: vi par, rank, sizes; int n, trees; UnionFind(int n) : n(n), trees(n) { par.resize(n), rank.resize(n), sizes.resize(n); rep(i, n) par[i] = i, sizes[i] = 1; } int root(int x) { if (par[x] == x) return x; else return par[x] = root(par[x]); } int find(int x) { return root(x); } void unite(int x, int y) { x = root(x); y = root(y); if (x == y) return; if (rank[x] < rank[y]) swap(x, y); trees--; par[y] = x; sizes[x] += sizes[y]; if (rank[x] == rank[y]) ++rank[x]; } bool same(int x, int y) { return root(x) == root(y); } int size(int x) { return sizes[root(x)]; } //順不同 umapなので V<vi> sets() { vvi(res, trees); umap<int, vi> map; rep(i, n) map[root(i)].push_back(i); int i = 0; for (auto &&p : map) { int r = p.fi; res[i].push_back(r); for (auto &&v : p.se) { if (r == v) continue; res[i].push_back(v); } ++i; } return res; } }; using bint = __int128; using u32 = unsigned; using u64 = unsigned long long; using u128 = __uint128_t; std::ostream &operator<<(std::ostream &dest, __int128_t value) { std::ostream::sentry s(dest); if (s) { __uint128_t tmp = value < 0 ? -value : value; char buffer[128]; char *d = std::end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = std::end(buffer) - d; if (dest.rdbuf()->sputn(d, len) != len) { dest.setstate(std::ios_base::badbit); } } return dest; } //__int128 toi128(string &s) { __int128 ret = 0; for (int i = 0; i < //s.length(); ++i) if ('0' <= s[i] && s[i] <= '9') ret = 10 * //ret + s[i] - '0'; return ret;} //エラー void ole() { #ifdef _DEBUG debugline("ole"); exit(0); #endif string a = "a"; rep(i, 30) a += a; rep(i, 1 << 17) cout << a << endl; cout << "OLE 出力長制限超過" << endl; exit(0); } void re() { assert(0 == 1); exit(0); } void tle() { while (inf) cout << inf << endl; } //便利関数 //テスト用 char ranc() { return (char)('a' + rand() % 26); } int rand(int min, int max) { assert(min <= max); if (min >= 0 && max >= 0) { return rand() % (max + 1 - min) + min; } else if (max < 0) { return -rand(-max, -min); } else { if (rand() % 2) { return rand(0, max); } else { return -rand(0, -min); } } } vi ranv(int n, int min, int max) { vi v(n); rep(i, n) v[i] = rand(min, max); return v; } str ransu(int n) { str s; rep(i, n) s += (char)rand('A', 'Z'); return s; } str ransl(int n) { str s; rep(i, n) s += (char)rand('a', 'z'); return s; } //単調増加 vi ranvinc(int n, int min, int max) { vi v(n); bool bad = 1; while (bad) { bad = 0; v.resize(n); rep(i, n) { if (i && min > max - v[i - 1]) { bad = 1; break; } if (i) v[i] = v[i - 1] + rand(min, max - v[i - 1]); else v[i] = rand(min, max); } } return v; } //便利 汎用 void ranvlr(int n, int min, int max, vi &l, vi &r) { l.resize(n); r.resize(n); rep(i, n) { l[i] = rand(min, max); r[i] = l[i] + rand(0, max - l[i]); } } vp run_length(vi &a) { vp ret; ret.eb(a[0], 1); rep(i, 1, sz(a)) { if (ret.back().fi == a[i]) { ret.back().se++; } else { ret.eb(a[i], 1); } } return ret; } vector<pair<char, int>> run_length(string &a) { vector<pair<char, int>> ret; ret.eb(a[0], 1); rep(i, 1, sz(a)) { if (ret.back().fi == a[i]) { ret.back().se++; } else { ret.eb(a[i], 1); } } return ret; } template <class F> int mgr(int ok, int ng, F f) { if (ok < ng) while (ng - ok > 1) { int mid = (ok + ng) / 2; if (f(mid)) ok = mid; else ng = mid; } else while (ok - ng > 1) { int mid = (ok + ng) / 2; if (f(mid)) ok = mid; else ng = mid; } return ok; } // strを整数として比較 string smax(str &a, str b) { if (sz(a) < sz(b)) { return b; } else if (sz(a) > sz(b)) { return a; } else { rep(i, sz(a)) { if (a[i] < b[i]) { return b; } else if (a[i] > b[i]) return a; } } return a; } // strを整数として比較 string smin(str &a, str b) { if (sz(a) < sz(b)) { return a; } else if (sz(a) > sz(b)) { return b; } else { rep(i, sz(a)) { if (a[i] < b[i]) { return a; } else if (a[i] > b[i]) return b; } } return a; } template <typename W, typename T> int find(vector<W> &a, const T key) { rep(i, sz(a)) if (a[i] == key) return i; return -1; } template <typename W, typename T> P find(vector<vector<W>> &a, const T key) { rep(i, sz(a)) rep(j, sz(a[0])) if (a[i][j] == key) return mp(i, j); return mp(-1, -1); } template <typename W, typename U> T find(vector<vector<vector<W>>> &a, const U key) { rep(i, sz(a)) rep(j, sz(a[0])) rep(k, sz(a[0][0])) if (a[i][j][k] == key) return mt(i, j, k); return mt(-1, -1, -1); } template <typename W, typename T> int count2(W &a, const T k) { return a == k; } template <typename W, typename T> int count2(vector<W> &a, const T k) { int ret = 0; fora(v, a) ret += count(v, k); return ret; } template <typename W, typename T> int count(vector<W> &a, const T k) { int ret = 0; fora(v, a) ret += count2(v, k); return ret; } int count(str &a, str k) { int ret = 0, len = k.length(); auto pos = a.find(k); while (pos != string::npos) pos = a.find(k, pos + len), ++ret; return ret; } vi count(str &a) { vi cou(26); char c = 'a'; if ('A' <= a[0] && a[0] <= 'Z') c = 'A'; rep(i, sz(a))++ cou[a[i] - c]; return cou; } #define couif count_if // algorythm inline ll rev(ll a) { ll res = 0; while (a) { res *= 10; res += a % 10; a /= 10; } return res; } template <class T> void rev(vector<T> &a) { reverse(all(a)); } template <class U> void rev(vector<vector<U>> &a) { vector<vector<U>> b(sz(a[0]), vector<U>(sz(a))); rep(h, sz(a)) rep(w, sz(a[0])) b[w][h] = a[h][w]; a = b; } void inline rev(string &a) { reverse(all(a)); } constexpr int p10[] = {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10000000000ll, 100000000000ll, 1000000000000ll, 10000000000000ll, 100000000000000ll, 1000000000000000ll, 10000000000000000ll, 100000000000000000ll, 1000000000000000000ll}; int get(int a, int keta) { return (a / (int)pow(10, keta)) % 10; } int keta(ll v) { if (v < p10[9]) { if (v < p10[4]) { if (v < p10[2]) { if (v < p10[1]) return 1; else return 2; } else { if (v < p10[3]) return 3; else return 4; } } else { if (v < p10[7]) { if (v < p10[5]) return 5; else if (v < p10[6]) return 6; else return 7; } else { if (v < p10[8]) return 8; else return 9; } } } else { if (v < p10[13]) { if (v < p10[11]) { if (v < p10[10]) return 10; else return 11; } else { if (v < p10[12]) return 12; else return 13; } } else { if (v < p10[15]) { if (v < p10[14]) return 14; else if (v < p10[15]) return 15; else return 16; } else { if (v < p10[17]) return 17; else return 18; } } } } int dsum(int v) { int ret = 0; for (; v; v /= 10) ret += v % 10; return ret; } struct sint { int v; sint(int v) : v(v) {} operator int() { return v; } //下からi番目 int operator[](int i) { return (v / p10[i]) % 10; } int back(int i) { return operator[](i); } //上からi番目 int top(int i) { int len = keta(v); return operator[](len - 1 - i); } //先頭からi番目にセット int settop(int i, int k) { int len = keta(v); return set(len - 1 - i, k); } int set(int i, int k) { if (i < 0) return settop(abs(i) - 1, k); return v += p10[i] * (k - (v / p10[i]) % 10); } int add(int i, int k = 1) { return v += p10[i] * k; } int addtop(int i, int k = 1) { return v += p10[keta(v) - i - 1] * k; } int dec(int i, int k = 1) { return v -= p10[i] * k; } int dectop(int i, int k = 1) { return v -= p10[keta(v) - i - 1] * k; } #define op(t, o) \ template <class T> inline t operator o(T r) { return v o r; } op(int, +=); op(int, -=); op(int, *=); op(int, /=); op(int, %=); op(int, +); op(int, -); op(int, *); op(int, /); op(int, %); op(bool, ==); op(bool, !=); op(bool, <); op(bool, <=); op(bool, >); op(bool, >=); #undef op template <class T> inline int operator<<=(T r) { return v *= p10[r]; } template <class T> inline int operator<<(T r) { return v * p10[r]; } template <class T> inline int operator>>=(T r) { return v /= p10[r]; } template <class T> inline int operator>>(T r) { return v / p10[r]; } }; int mask10(int v) { return p10[v] - 1; } //変換系 template <class T> auto keys(T a) { vector<decltype((a.begin())->fi)> res; for (auto &&k : a) res.push_back(k.fi); return res; } template <class T> auto values(T a) { vector<decltype((a.begin())->se)> res; for (auto &&k : a) res.push_back(k.se); return res; } template <class T, class U> inline bool chma(T &a, const U &b) { if (a < b) { a = b; return true; } return false; } template <class U> inline bool chma(const U &b) { return chma(ma, b); } template <class T, class U> inline bool chmi(T &a, const U &b) { if (b < a) { a = b; return true; } return false; } template <class U> inline bool chmi(const U &b) { return chmi(mi, b); } template <class T> inline T min(T a, signed b) { return a < b ? a : b; } template <class T> inline T max(T a, signed b) { return a < b ? b : a; } template <class T> inline T min(T a, T b, T c) { return a >= b ? b >= c ? c : b : a >= c ? c : a; } template <class T> inline T max(T a, T b, T c) { return a <= b ? b <= c ? c : b : a <= c ? c : a; } template <class T> inline T min(vector<T> a) { return *min_element(all(a)); } template <class T> inline T mini(vector<T> a) { return min_element(all(a)) - a.begin(); } template <class T> inline T min(vector<T> a, int n) { return *min_element(a.begin(), a.begin() + min(n, sz(a))); } template <class T> inline T min(vector<T> a, int s, int n) { return *min_element(a.begin() + s, a.begin() + min(n, sz(a))); } template <class T> inline T max(vector<T> a) { return *max_element(all(a)); } template <class T> inline T maxi(vector<T> a) { return max_element(all(a)) - a.begin(); } template <class T> inline T max(vector<T> a, int n) { return *max_element(a.begin(), a.begin() + min(n, sz(a))); } template <class T> inline T max(vector<T> a, int s, int n) { return *max_element(a.begin() + s, a.begin() + min(n, sz(a))); } template <typename A, size_t N> inline A max(A (&a)[N]) { A res = a[0]; rep(i, N) res = max(res, a[i]); return res; } template <typename A, size_t N, size_t O> inline A max(A (&a)[N][O]) { A res = max(a[0]); rep(i, N) res = max(res, max(a[i])); return res; } template <typename A, size_t N, size_t O, size_t P> inline A max(A (&a)[N][O][P]) { A res = max(a[0]); rep(i, N) res = max(res, max(a[i])); return res; } template <typename A, size_t N, size_t O, size_t P, size_t Q> inline A max(A (&a)[N][O][P][Q], const T &v) { A res = max(a[0]); rep(i, N) res = max(res, max(a[i])); return res; } template <typename A, size_t N, size_t O, size_t P, size_t Q, size_t R> inline A max(A (&a)[N][O][P][Q][R]) { A res = max(a[0]); rep(i, N) res = max(res, max(a[i])); return res; } template <typename A, size_t N, size_t O, size_t P, size_t Q, size_t R, size_t S> inline A max(A (&a)[N][O][P][Q][R][S]) { A res = max(a[0]); rep(i, N) res = max(res, max(a[i])); return res; } template <typename A, size_t N> inline A min(A (&a)[N]) { A res = a[0]; rep(i, N) res = min(res, a[i]); return res; } template <typename A, size_t N, size_t O> inline A min(A (&a)[N][O]) { A res = min(a[0]); rep(i, N) res = min(res, max(a[i])); return res; } template <typename A, size_t N, size_t O, size_t P> inline A min(A (&a)[N][O][P]) { A res = min(a[0]); rep(i, N) res = min(res, min(a[i])); return res; } template <typename A, size_t N, size_t O, size_t P, size_t Q> inline A min(A (&a)[N][O][P][Q], const T &v) { A res = min(a[0]); rep(i, N) res = min(res, min(a[i])); return res; } template <typename A, size_t N, size_t O, size_t P, size_t Q, size_t R> inline A min(A (&a)[N][O][P][Q][R]) { A res = min(a[0]); rep(i, N) res = min(res, min(a[i])); return res; } template <typename A, size_t N, size_t O, size_t P, size_t Q, size_t R, size_t S> inline A min(A (&a)[N][O][P][Q][R][S]) { A res = min(a[0]); rep(i, N) res = min(res, min(a[i])); return res; } //@formatter:on template <class T> T sum(vector<T> &v, int s = 0, int t = inf) { T ret = 0; rep(i, s, min(sz(v), t)) ret += v[i]; return ret; } //@formatter:off template <class T> T sum(vector<vector<T>> &v) { T ret = 0; rep(i, sz(v)) ret += sum(v[i]); return ret; } template <class T> T sum(vector<vector<vector<T>>> &v) { T ret = 0; rep(i, sz(v)) ret += sum(v[i]); return ret; } template <class T> T sum(vector<vector<vector<vector<T>>>> &v) { T ret = 0; rep(i, sz(v)) ret += sum(v[i]); return ret; } template <class T> T sum(vector<vector<vector<vector<vector<T>>>>> &v) { T ret = 0; rep(i, sz(v)) ret += sum(v[i]); return ret; } template <class T> auto sum(priority_queue<T, vector<T>, greater<T>> &r) { auto q = r; T ret = 0; while (sz(q)) { ret += q.top(); q.pop(); } return ret; } template <class T> auto sum(priority_queue<T> &r) { auto q = r; T ret = 0; while (sz(q)) { ret += q.top(); q.pop(); } return ret; } // template<class T, class U, class... W> inline auto sumn(vector<T> &v, U head, // W... tail) { auto ret = sum(v[0], tail...); rep(i, 1, min(sz(v), // head))ret += sum(v[i], tail...); return ret;} void clear(PQ &q) { q = PQ(); } template <class T> void clear(queue<T> &q) { while (q.size()) q.pop(); } template <class T> T *negarr(int size) { T *body = (T *)malloc((size * 2 + 1) * sizeof(T)); return body + size; } template <class T> T *negarr2(int h, int w) { double **dummy1 = new double *[2 * h + 1]; double *dummy2 = new double[(2 * h + 1) * (2 * w + 1)]; dummy1[0] = dummy2 + w; for (int i = 1; i <= 2 * h + 1; ++i) { dummy1[i] = dummy1[i - 1] + 2 * w + 1; } double **a = dummy1 + h; return a; } // imoは0-indexed // ruiは1-indexed template <class T> vector<T> imo(vector<T> &v) { vector<T> ret = v; rep(i, sz(ret) - 1) ret[i + 1] += ret[i]; return ret; } // kと同じものの数 template <class T, class U> vi imocou(vector<T> &a, U k) { vector<T> ret = a; rep(i, sz(ret) - 1) ret[i + 1] = ret[i] + (a[i] == k); return ret; } template <class T> vector<T> imox(vector<T> &v) { vector<T> ret = v; rep(i, sz(ret) - 1) ret[i + 1] ^= ret[i]; return ret; } //漸化的に最小を持つ template <class T> vector<T> imi(vector<T> &v) { vector<T> ret = v; rep(i, sz(ret) - 1) chmi(ret[i + 1], ret[i]); return ret; } template <class T> struct ruiC { const vector<T> rui; ruiC(vector<T> &ru) : rui(ru) {} T operator()(int l, int r) { assert(l <= r); return rui[r] - rui[l]; } T operator[](int i) { return rui[i]; } T back() { return rui.back(); } int size() { return rui.size(); } }; template <class T> struct rruic { const T *rrui; rruic(T *ru) : rrui(ru) {} inline T operator()(int l, int r) { assert(l >= r); return rrui[r] - rrui[l]; } inline T operator[](int i) { return rrui[i]; } }; template <class T> vector<T> ruiv(vector<T> &a) { vector<T> ret(a.size() + 1); rep(i, a.size()) ret[i + 1] = ret[i] + a[i]; return ret; } template <class T> ruiC<T> ruic(vector<T> &a) { vector<T> ret = ruiv(a); return ruiC<T>(ret); } vector<int> ruiv(string &a) { if (sz(a) == 0) return vi(1); int dec = ('0' <= a[0] && a[0] <= '9') ? '0' : 0; vector<int> ret(a.size() + 1); rep(i, a.size()) ret[i + 1] = ret[i] + a[i] - dec; return ret; } ruiC<int> ruic(string &a) { vector<int> ret = ruiv(a); return ruiC<int>(ret); } // kと同じものの数 template <class T, class U> vi ruiv(T &a, U k) { vi ret(a.size() + 1); rep(i, a.size()) ret[i + 1] = ret[i] + (a[i] == k); return ret; } template <class T, class U> ruiC<int> ruic(T &a, U k) { vi ret = ruiv(a, k); return ruiC<int>(ret); } // xor template <class T> vector<T> ruix(vector<T> &a) { vector<T> ret(a.size() + 1); rep(i, a.size()) ret[i + 1] = ret[i] ^ a[i]; return ret; } template <class T> vector<T> ruim(vector<T> &a) { vector<T> res(a.size() + 1, 1); rep(i, a.size()) res[i + 1] = res[i] * a[i]; return res; } //漸化的に最小を1indexで持つ template <class T> vector<T> ruimi(vector<T> &a) { int n = sz(a); vector<T> ret(n + 1); rep(i, 1, n) { ret[i] = a[i - 1]; chmi(ret[i + 1], ret[i]); } return ret; } // template<class T> T *rrui(vector<T> &a) { //右から左にかけての半開区間 (-1 n-1] template <class T> rruic<T> rrui(vector<T> &a) { int len = a.size(); T *body = (T *)malloc((len + 1) * sizeof(T)); T *res = body + 1; rer(i, len - 1) res[i - 1] = res[i] + a[i]; return rruic<T>(res); } //掛け算 template <class T> T *rruim(vector<T> &a) { int len = a.size(); T *body = (T *)malloc((len + 1) * sizeof(T)); T *res = body + 1; res[len - 1] = 1; rer(i, len - 1) res[i - 1] = res[i] * a[i]; return res; } template <class T, class U> void inc(T &a, U v = 1) { a += v; } template <class T, class U> void inc(vector<T> &a, U v = 1) { for (auto &u : a) inc(u, v); } template <class T, class U> void dec(T &a, U v = 1) { a -= v; } template <class T, class U> void dec(vector<T> &a, U v = 1) { for (auto &u : a) dec(u, v); } template <class U> void dec(string &a, U v = 1) { for (auto &u : a) dec(u, v); } template <class T> void dec(vector<T> &a) { for (auto &u : a) dec(u, 1); } bool ins(int h, int w, int H, int W) { return h >= 0 && w >= 0 && h < H && w < W; } bool ins(int l, int v, int r) { return l <= v && v < r; } template <class T> bool ins(vector<T> &a, int i, int j = 0) { return ins(0, i, sz(a)) && ins(0, j, sz(a)); } ll u(ll a) { return a < 0 ? 0 : a; } template <class T> vector<T> u(const vector<T> &a) { vector<T> ret = a; fora(v, ret) v = u(v); return ret; } #define MIN(a) numeric_limits<a>::min() #define MAX(a) numeric_limits<a>::max() ll goldd(ll left, ll right, function<ll(ll)> calc) { double GRATIO = 1.6180339887498948482045868343656; ll lm = left + (ll)((right - left) / (GRATIO + 1.0)); ll rm = lm + (ll)((right - lm) / (GRATIO + 1.0)); ll fl = calc(lm); ll fr = calc(rm); while (right - left > 10) { if (fl < fr) { right = rm; rm = lm; fr = fl; lm = left + (ll)((right - left) / (GRATIO + 1.0)); fl = calc(lm); } else { left = lm; lm = rm; fl = fr; rm = lm + (ll)((right - lm) / (GRATIO + 1.0)); fr = calc(rm); } } ll minScore = MAX(ll); ll resIndex = left; for (ll i = left; i < right + 1; ++i) { ll score = calc(i); if (minScore > score) { minScore = score; resIndex = i; } } return resIndex; } ll goldt(ll left, ll right, function<ll(ll)> calc) { double GRATIO = 1.6180339887498948482045868343656; ll lm = left + (ll)((right - left) / (GRATIO + 1.0)); ll rm = lm + (ll)((right - lm) / (GRATIO + 1.0)); ll fl = calc(lm); ll fr = calc(rm); while (right - left > 10) { if (fl > fr) { right = rm; rm = lm; fr = fl; lm = left + (ll)((right - left) / (GRATIO + 1.0)); fl = calc(lm); } else { left = lm; lm = rm; fl = fr; rm = lm + (ll)((right - lm) / (GRATIO + 1.0)); fr = calc(rm); } } if (left > right) { ll l = left; left = right; right = l; } ll maxScore = MIN(ll); ll resIndex = left; for (ll i = left; i < right + 1; ++i) { ll score = calc(i); if (maxScore < score) { maxScore = score; resIndex = i; } } return resIndex; } template <class T> T min(vector<vector<T>> &a) { T res = MAX(T); rep(i, a.size()) chmi(res, *min_element(all(a[i]))); return res; } template <class T> T max(vector<vector<T>> &a) { T res = MIN(T); rep(i, a.size()) chma(res, *max_element(all(a[i]))); return res; } constexpr bool bget(ll m, int keta) { return (m >> keta) & 1; } int bget(ll m, int keta, int sinsuu) { m /= (ll)pow(sinsuu, keta); return m % sinsuu; } ll bit(int n) { return (1LL << (n)); } ll bit(int n, int sinsuu) { return (ll)pow(sinsuu, n); } int mask(int n) { return (1ll << n) - 1; } #define bcou __builtin_popcountll //最下位ビット int lbit(int n) { return n & -n; } //最上位ビット int hbit(int n) { n |= (n >> 1); n |= (n >> 2); n |= (n >> 4); n |= (n >> 8); n |= (n >> 16); n |= (n >> 32); return n - (n >> 1); } int hbitk(int n) { int k = 0; rer(i, 5) { int a = k + (1ll << i); int b = 1ll << a; if (b <= n) k += 1ll << i; } return k; } //初期化は0を渡す ll nextComb(ll &mask, int n, int r) { if (!mask) return mask = (1LL << r) - 1; ll x = mask & -mask; /*最下位の1*/ ll y = mask + x; /*連続した下の1を繰り上がらせる*/ ll res = ((mask & ~y) / x >> 1) | y; if (bget(res, n)) return mask = 0; else return mask = res; } // n桁以下でビットがr個立っているもののvectorを返す vi bitCombList(int n, int r) { vi res; int m = 0; while (nextComb(m, n, r)) { res.push_back(m); } return res; } char itoal(int i) { return 'a' + i; } char itoaL(int i) { return 'A' + i; } int altoi(char c) { if ('A' <= c && c <= 'Z') return c - 'A'; return c - 'a'; } int ctoi(char c) { return c - '0'; } char itoc(int i) { return i + '0'; } int vtoi(vi &v) { int res = 0; if (sz(v) > 18) { debugline("vtoi"); deb(sz(v)); ole(); } rep(i, sz(v)) { res *= 10; res += v[i]; } return res; } vi itov(int i) { vi res; while (i) { res.push_back(i % 10); i /= 10; } rev(res); return res; } vi stov(string &a) { int n = sz(a); vi ret(n); rep(i, n) { ret[i] = a[i] - '0'; } return ret; } //基準を満たさないものは0になる vi stov(string &a, char one) { int n = sz(a); vi ret(n); rep(i, n) ret[i] = a[i] == one; return ret; } vector<vector<int>> ctoi(vector<vector<char>> s, char c) { int n = sz(s), m = sz(s[0]); vector<vector<int>> res(n, vector<int>(m)); rep(i, n) rep(j, m) res[i][j] = s[i][j] == c; return res; } #define unique(v) v.erase(unique(v.begin(), v.end()), v.end()); //[i] := i番として圧縮されたものを返す vi compress(vi &a) { vi b; int len = a.size(); for (int i = 0; i < len; ++i) { b.push_back(a[i]); } sort(b); unique(b); for (int i = 0; i < len; ++i) { a[i] = lower_bound(all(b), a[i]) - b.begin(); } int blen = sz(b); vi ret(blen); rep(i, blen) { ret[i] = b[i]; } return ret; } vi compress(vi &a, umap<int, int> &map) { vi b; int len = a.size(); for (int i = 0; i < len; ++i) { b.push_back(a[i]); } sort(b); unique(b); for (int i = 0; i < len; ++i) { int v = a[i]; a[i] = lower_bound(all(b), a[i]) - b.begin(); map[v] = a[i]; } int blen = sz(b); vi ret(blen); rep(i, blen) { ret[i] = b[i]; } return ret; } vi compress(vi &a, vi &r) { vi b; int len = a.size(); fora(v, a) b.push_back(v); fora(v, r) b.push_back(v); sort(b); unique(b); for (int i = 0; i < len; ++i) a[i] = lower_bound(all(b), a[i]) - b.begin(); for (int i = 0; i < sz(r); ++i) r[i] = lower_bound(all(b), r[i]) - b.begin(); int blen = sz(b); vi ret(blen); rep(i, blen) { ret[i] = b[i]; } return ret; } vi compress(vi &a, vi &r, vi &s) { vi b; int len = a.size(); fora(v, a) b.push_back(v); fora(v, r) b.push_back(v); fora(v, s) b.push_back(v); sort(b); unique(b); for (int i = 0; i < len; ++i) a[i] = lower_bound(all(b), a[i]) - b.begin(); for (int i = 0; i < sz(r); ++i) r[i] = lower_bound(all(b), r[i]) - b.begin(); for (int i = 0; i < sz(s); ++i) r[i] = lower_bound(all(b), s[i]) - b.begin(); int blen = sz(b); vi ret(blen); rep(i, blen) { ret[i] = b[i]; } return ret; } vi compress(V<vi> &a) { vi b; fora(vv, a) fora(v, vv) b.push_back(v); sort(b); unique(b); fora(vv, a) fora(v, vv) v = lower_bound(all(b), v) - b.begin(); int blen = sz(b); vi ret(blen); rep(i, blen) { ret[i] = b[i]; } return ret; } vi compress(vector<vector<vi>> &a) { vi b; fora(vvv, a) fora(vv, vvv) fora(v, vv) b.push_back(v); sort(b); unique(b); fora(vvv, a) fora(vv, vvv) fora(v, vv) v = lower_bound(all(b), v) - b.begin(); int blen = sz(b); vi ret(blen); rep(i, blen) { ret[i] = b[i]; } return ret; } void compress(int a[], int len) { vi b; for (int i = 0; i < len; ++i) { b.push_back(a[i]); } sort(b); unique(b); for (int i = 0; i < len; ++i) { a[i] = lower_bound(all(b), a[i]) - b.begin(); } } //要素が見つからなかったときに困る #define binarySearch(a, v) (binary_search(all(a), v)) #define lowerIndex(a, v) (lower_bound(all(a), v) - a.begin()) #define lowerBound(a, v) (*lower_bound(all(a), v)) #define upperIndex(a, v) (upper_bound(all(a), v) - a.begin()) #define upperBound(a, v) (*upper_bound(all(a), v)) template <class T> void fin(T s) { cout << s << endl, exit(0); } //便利 数学 math int mod(int a, int m) { return (a % m + m) % m; } int pow(int a) { return a * a; }; ll fact(int v) { return v <= 1 ? 1 : v * fact(v - 1); } ll comi(int n, int r) { assert(n < 100); static vvi(pas, 100, 100); if (pas[0][0]) return pas[n][r]; pas[0][0] = 1; rep(i, 1, 100) { pas[i][0] = 1; rep(j, 1, i + 1) pas[i][j] = pas[i - 1][j - 1] + pas[i - 1][j]; } return pas[n][r]; } double comd(int n, int r) { static vd fac; if (sz(fac) < n + 1) { if (sz(fac) == 0) fac.push_back(1); rep(i, sz(fac) - 1, n) { fac.push_back(fac.back() * (i + 1)); } } if (n < r || n <= 0) return 0; return fac[n] / fac[n - r] / fac[r]; } int gcd(int a, int b) { while (b) a %= b, swap(a, b); return abs(a); } int gcd(vi b) { ll res = b[0]; rep(i, 1, sz(b)) res = gcd(b[i], res); return res; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } ll lcm(vi a) { int res = a[0]; rep(i, 1, sz(a)) res = lcm(a[i], res); return res; } ll ceil(ll a, ll b) { if (b == 0) { debugline("ceil"); deb(a, b); ole(); return -1; } else if (a < 0) { return 0; } else { return (a + b - 1) / b; } } // v * v >= aとなる最小のvを返す ll sqrt(ll a) { if (a < 0) { debugline("sqrt"); deb(a); ole(); } ll res = (ll)std::sqrt(a); while (res * res < a) ++res; return res; } double log(double e, double x) { return log(x) / log(e); } ll sig(ll t) { return (1 + t) * t / 2; } ll sig(ll s, ll t) { return (s + t) * (t - s + 1) / 2; } //幾何 Pをcomplexとして扱う template <class T, class U> bool eq(T a, U b) { return fabs(a - b) < eps; } dou atan2(pd a) { return atan2(a.se, a.fi); } dou angle(pd f, pd t) { return atan2(t.se - f.se, t.fi - f.fi); } dou distance(pd a, pd b) { return hypot(a.fi - b.fi, a.se - b.se); } // bを中心とするabcのtheta aからcにかけて時計回り dou angle(pd a, pd b, pd c) { dou ax = a.fi - b.fi; dou ay = a.se - b.se; dou cx = c.fi - b.fi; dou cy = c.se - b.se; double ret = atan2(cy, cx) - atan2(ay, ax); if (ret < 0) ret += 2 * PI; return ret; } dou dot(pd a, pd b) { return a.fi * b.fi + a.se + b.se; } dou cro(pd a, pd b) { return a.fi * b.se - a.se + b.fi; } //機能拡張 template <class T, class U> void operator+=(queue<T> &a, U v) { a.push(v); } template <class T, class U> void operator+=(deque<T> &a, U v) { a.push_back(v); } template <class T, class U> priority_queue<T, vector<T>, greater<T>> & operator+=(priority_queue<T, vector<T>, greater<T>> &a, vector<U> &v) { fora(d, v) a.push(d); return a; } template <class T, class U> priority_queue<T, vector<T>, greater<T>> & operator+=(priority_queue<T, vector<T>, greater<T>> &a, U v) { a.push(v); return a; } template <class T, class U> priority_queue<T> &operator+=(priority_queue<T> &a, U v) { a.push(v); return a; } template <class T> set<T> &operator+=(set<T> &a, vector<T> v) { fora(d, v) a.insert(d); return a; } template <class T, class U> set<T> &operator+=(set<T> &a, U v) { a.insert(v); return a; } template <class T, class U> set<T, greater<T>> &operator+=(set<T, greater<T>> &a, U v) { a.insert(v); return a; } template <class T, class U> vector<T> &operator+=(vector<T> &a, U v) { a.push_back(v); return a; } template <class T, class U> vector<T> operator+(const vector<T> &a, U v) { vector<T> ret = a; ret += v; return ret; } template <class T, class U> vector<T> operator+(U v, const vector<T> &a) { vector<T> ret = a; ret.insert(ret.begin(), v); return ret; } template <class T> vector<T> operator+(vector<T> a, vector<T> b) { vector<T> ret; ret = a; fora(v, b) ret += v; return ret; } template <class T> vector<T> &operator+=(vector<T> &a, vector<T> &b) { fora(v, b) a += v; return a; } template <class T> vector<T> &operator-=(vector<T> &a, vector<T> &b) { if (sz(a) != sz(b)) { debugline("vector<T> operator-="); deb(a); deb(b); exit(0); } rep(i, sz(a)) a[i] -= b[i]; return a; } template <class T> vector<T> operator-(vector<T> &a, vector<T> &b) { if (sz(a) != sz(b)) { debugline("vector<T> operator-"); deb(a); deb(b); ole(); } vector<T> res(sz(a)); rep(i, sz(a)) res[i] = a[i] - b[i]; return res; } template <class T, class U> vector<T> operator*(vector<T> &a, U b) { vector<T> ret; fora(v, a) ret += v * b; return ret; } template <class T, class U> vector<T> operator/(vector<T> &a, U b) { vector<T> ret; fora(v, a) ret += v / b; return ret; } template <class T, class U> vector<T> operator*=(vector<T> &a, U b) { fora(v, a) v *= b; return a; } template <class T, class U> vector<T> operator/=(vector<T> &a, U b) { fora(v, a) v /= b; return a; } template <typename T> void erase(vector<T> &v, unsigned int i) { v.erase(v.begin() + i); } template <typename T> void erase(vector<T> &v, unsigned int s, unsigned int e) { v.erase(v.begin() + s, v.begin() + e); } template <class T, class U> void erase(map<T, U> &m, int okl, int ngr) { m.erase(m.lower_bound(okl), m.lower_bound(ngr)); } template <class T> void erase(set<T> &m, int okl, int ngr) { m.erase(m.lower_bound(okl), m.lower_bound(ngr)); } template <typename T> void erasen(vector<T> &v, unsigned int s, unsigned int n) { v.erase(v.begin() + s, v.begin() + s + n); } template <typename T, typename U> void insert(vector<T> &v, unsigned int i, U t) { v.insert(v.begin() + i, t); } template <typename T, typename U> void push_front(vector<T> &v, U t) { v.insert(v.begin(), t); } template <typename T, typename U> void insert(vector<T> &v, unsigned int i, vector<T> list) { for (auto &&va : list) v.insert(v.begin() + i++, va); } template <typename T> void insert(set<T> &v, vector<T> list) { for (auto &&va : list) v.insert(va); } vector<string> split(const string a, const char deli) { string b = a + deli; int l = 0, r = 0, n = b.size(); vector<string> res; rep(i, n) { if (b[i] == deli) { r = i; if (l < r) res.push_back(b.substr(l, r - l)); l = i + 1; } } return res; } vector<string> split(const string a, const string deli) { vector<string> res; int kn = sz(deli); std::string::size_type Pos(a.find(deli)); int l = 0; while (Pos != std::string::npos) { if (Pos - l) res.push_back(a.substr(l, Pos - l)); l = Pos + kn; Pos = a.find(deli, Pos + kn); } if (sz(a) - l) res.push_back(a.substr(l, sz(a) - l)); return res; } void yn(bool a) { if (a) cout << "yes" << endl; else cout << "no" << endl; } void Yn(bool a) { if (a) cout << "Yes" << endl; else cout << "No" << endl; } void YN(bool a) { if (a) cout << "YES" << endl; else cout << "NO" << endl; } void fyn(bool a) { if (a) cout << "yes" << endl; else cout << "no" << endl; exit(0); } void fYn(bool a) { if (a) cout << "Yes" << endl; else cout << "No" << endl; exit(0); } void fYN(bool a) { if (a) cout << "YES" << endl; else cout << "NO" << endl; exit(0); } void Possible(bool a) { if (a) cout << "Possible" << endl; else cout << "Impossible" << endl; exit(0); } void POSSIBLE(bool a) { if (a) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; exit(0); } //@起動時 struct initon { initon() { cin.tie(0); ios::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(16); srand((unsigned)clock() + (unsigned)time(NULL)); }; } initonv; //@formatter:on // gra mint pr int n, m, k, d, H, W, x, y, z, q; int cou; vi t, a, b, c; // vvi (s, 0, 0); vvc(ba, 0, 0); vp p; str s; //@formatter:off // type N M template <class T, int N> using A = array<T, N>; template <class T, int N, int M> struct mat : A<A<T, N>, M> { using A<A<T, N>, M>::A; using A<A<T, N>, M>::size; template <class U> mat(vector<vector<U>> &a) { rep(i, sz(a)) rep(j, sz(a[0]))(*this)[i][j] = a[i][j]; } void unit(int v = 1) { int lim = min(h(), w()); rep(i, h()) rep(j, w())(*this)[i][j] = (i == j) ? v : 0; } void zero() { rep(i, h()) rep(j, w())(*this)[i][j] = 0; } mat(int v = 0) { if (v > 0) unit(v); } int h() const { return size(); } int w() const { return (*this)[0].size(); } template <class U> void fill(U v) { rep(i, h()) rep(j, w())(*this)[i][j] = v; } T sum() { T res = 0; rep(i, h()) rep(j, w()) res += (*this)[i][j]; return res; } mat operator+(mat &r) { assert(h() == r.h() && w() == r.w()); mat res = mat(); res.zero(); rep(i, H) rep(j, W) res[i][j] = (this)[i][j] + r[i][j]; return res; } mat operator-(mat &r) { assert(h() == r.h() && w() == r.w()); mat res = mat(); res.zero(); rep(i, H) rep(j, W) res[i][j] = (this)[i][j] - r[i][j]; return res; } mat operator*(mat &r) { assert(w() == r.h()); mat res = mat(); res.zero(); for (int i = 0; i < h(); i++) { for (int j = 0; j < r.w(); j++) { for (int k = 0; k < w(); k++) { res[i][j] += (*this)[i][k] * r[k][j]; } } } return res; } mat &operator+=(mat &r) { return *this = *this + r; } mat &operator-=(mat &r) { return *this = *this - r; } mat &operator*=(mat &r) { return *this = *this * r; } mat pow(ll n) { assert(h() == w()); mat x = *this; mat r(1); while (n) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; } }; template <typename T, int H, int W> ostream &operator<<(ostream &os, mat<T, H, W> vec) { for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { os << vec[i][j]; } os << endl; } return os; } //@formatter:on //@formatter:off int MOD = 1000000007; struct mint { int x; mint() : x(0) {} mint(int a) { x = a % MOD; if (x < 0) x += MOD; } mint &operator+=(mint that) { x = (x + that.x) % MOD; return *this; } mint &operator-=(mint that) { x = (x + MOD - that.x) % MOD; return *this; } mint &operator*=(mint that) { x = (int)x * that.x % MOD; return *this; } mint &operator/=(mint that) { return *this *= that.inverse(); } mint operator-() { return mint(-this->x); } friend ostream &operator<<(ostream &out, mint m) { return out << m.x; } mint inverse() { int a = x, b = MOD, u = 1, v = 0; while (b) { int t = a / b; a -= t * b; u -= t * v; swap(a, b); swap(u, v); } return mint(u); } mint operator+(mint that) { return mint(*this) += that; } mint operator-(mint that) { return mint(*this) -= that; } mint operator*(mint that) { return mint(*this) *= that; } mint operator/(mint that) { return mint(*this) /= that; } bool operator==(mint that) const { return x == that.x; } bool operator!=(mint that) const { return x != that.x; } bool operator<(mint that) const { return x < that.x; } bool operator<=(mint that) const { return x <= that.x; } bool operator>(mint that) const { return x > that.x; } bool operator>=(mint that) const { return x >= that.x; } }; istream &operator>>(istream &i, mint &a) { i >> a.x; return i; } typedef vector<mint> vm; vector<mint> fac, finv; int mint_len = 1400000; void setmod(int mod = 1e9 + 7) { MOD = mod; fac = vector<mint>(mint_len + 1); finv = vector<mint>(mint_len + 1); fac[0] = 1; rep(i, 1, mint_len + 1) fac[i] = fac[i - 1] * i; finv[mint_len] = (mint)1 / fac[mint_len]; rer(i, mint_len, 1) finv[i - 1] = finv[i] * i; } mint com(int a, int b) { if (a < 0) return 0; if (b < 0 || b > a) return 0; return fac[a] * finv[a - b] * finv[b]; } mint hom(int a, int b) { return com(a + b - 1, b); } template <typename T, typename U> mint mpow(const T a, const U b) { assert(b >= 0); int x = a, res = 1; U p = b; while (p > 0) { if (p & 1) (res *= x) %= MOD; (x *= x) %= MOD; p >>= 1; } return res; } template <typename T> inline mint mpow(const T a, const mint b) { int x = a, res = 1; int p = b.x; while (p > 0) { if (p & 1) (res *= x) %= MOD; (x *= x) %= MOD; p >>= 1; } return res; } using PM = pair<mint, mint>; using vm = vector<mint>; #define vvm(...) \ o_vvt(__VA_ARGS__, vvt4, vvt3, vvt2, vvt1, vvt0)(mint, __VA_ARGS__) #define smod setmod // setmodを呼ぶ @formatter:on int lower_rem_i(int kei, int rem, int x) { if (rem >= x) return 0; return (x - rem + kei - 1) / kei; } int lower_rem_v(int kei, int rem, int x) { if (rem >= x) return rem; return (x - rem + kei - 1) / kei * kei + rem; } int upper_rem_i(int kei, int rem, int x) { if (rem > x) return 0; return (x - rem + kei) / kei; } int upper_rem_v(int kei, int rem, int x) { if (rem > x) return rem; return (x - rem + kei) / kei * kei + rem; } void solve() { din(n, a, b, mod); smod(mod); // smod(inf); using M = mat<mint, 3, 3>; int l = 0; M res; res[0][0] = 0; res[0][1] = a; res[0][2] = 1; rep(i, 1, 19) { if (l == n) break; int cou = 0; int r = lower_rem_i(a, b, p10[i]); chmi(r, n); if (l == r) con; cou = r - l; M mt(1); mt[0][0] = mpow(10, i); mt[1][0] = 1; mt[2][1] = b; mt = mt.pow(cou); res *= mt; l = r; } cout << res[0][0] << endl; } int my(int n, vi &a) { return 0; } int sister(int n, vi &a) { int ret = 0; return ret; } signed main() { solve(); #define arg n, a #ifdef _DEBUG bool bad = 0; for (int i = 0, ok = 1; i < k5 && ok; ++i) { int n = rand(1, 8); vi a = ranv(n, 1, 10); int myres = my(arg); int res = sister(arg); ok = myres == res; if (!ok) { out(arg); cerr << "正解 : " << res << endl; cerr << "自分 : " << myres << endl; bad = 1; break; } } if (!bad) { // cout << "完璧 : solveを書き直そう" << endl; // cout << " : そして、solve()を呼び出すのだ" << endl; // cout << " : cin>>n; na(a,n);も忘れるな" << endl; } #endif return 0; };
//#pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; //衝突対策 #define ws wszzzz #define int long long //@formatter:off template <class A, class B, class C> struct T2 { A f; B s; C t; T2() { f = 0, s = 0, t = 0; } T2(A f, B s, C t) : f(f), s(s), t(t) {} bool operator<(const T2 &r) const { return f != r.f ? f < r.f : s != r.s ? s < r.s : t < r.t; /*return f != r.f ? f > r.f : s != r.s ?n s > r.s : t > r.t; 大きい順 */ } bool operator>(const T2 &r) const { return f != r.f ? f > r.f : s != r.s ? s > r.s : t > r.t; /*return f != r.f ? f > r.f : s != r.s ? s > r.s : t > r.t; 小さい順 */ } bool operator==(const T2 &r) const { return f == r.f && s == r.s && t == r.t; } bool operator!=(const T2 &r) const { return f != r.f || s != r.s || t != r.t; } }; template <class A, class B, class C, class D> struct F2 { A a; B b; C c; D d; F2() { a = 0, b = 0, c = 0, d = 0; } F2(A a, B b, C c, D d) : a(a), b(b), c(c), d(d) {} bool operator<(const F2 &r) const { return a != r.a ? a < r.a : b != r.b ? b < r.b : c != r.c ? c < r.c : d < r.d; /* return a != r.a ? a > r.a : b != r.b ? b > r.b : c != r.c ? c > r.c : d > r.d;*/ } bool operator>(const F2 &r) const { return a != r.a ? a > r.a : b != r.b ? b > r.b : c != r.c ? c > r.c : d > r.d; /* return a != r.a ? a < r.a : b != r.b ? b < r.b : c != r.c ? c < r.c : d < r.d;*/ } bool operator==(const F2 &r) const { return a == r.a && b == r.b && c == r.c && d == r.d; } bool operator!=(const F2 &r) const { return a != r.a || b != r.b || c != r.c || d != r.d; } int operator[](int i) { assert(i < 4); return i == 0 ? a : i == 1 ? b : i == 2 ? c : d; } }; typedef T2<int, int, int> T; typedef F2<int, int, int, int> F; T mt(int a, int b, int c) { return T(a, b, c); } //@マクロ省略系 型,構造 #define ll long long #define double long double #define ull unsigned long long using dou = double; using itn = int; using str = string; using bo = bool; #define au auto using P = pair<int, int>; using pd = pair<dou, dou>; #define fi first #define se second #define beg begin #define rbeg rbegin #define con continue #define bre break #define brk break #define is == #define elf else if #define wh while #define maxq 1 #define minq -1 #define ZERO(a) memset(a, 0, sizeof(a)) #define MINUS(a) memset(a, 0xff, sizeof(a)) #define MALLOC(type, len) (type *)malloc((len) * sizeof(type)) #define lam(right) [&](int &p) { return p right; } //マクロ省略系 コンテナ using vi = vector<int>; using vb = vector<bool>; using vs = vector<string>; using vd = vector<double>; using vc = vector<char>; using vp = vector<P>; using vt = vector<T>; #define V vector #define o_vvt(o1, o2, o3, o4, name, ...) name #define vvt0(t) V<V<t>> #define vvt1(t, a) V<V<t>> a #define vvt2(t, a, b) V<V<t>> a(b) #define vvt3(t, a, b, c) V<V<t>> a(b, V<t>(c)) #define vvt4(t, a, b, c, d) V<V<t>> a(b, V<t>(c, d)) #define vvi(...) \ o_vvt(__VA_ARGS__, vvt4, vvt3, vvt2, vvt1, vvt0)(int, __VA_ARGS__) #define vvb(...) \ o_vvt(__VA_ARGS__, vvt4, vvt3, vvt2, vvt1, vvt0)(bool, __VA_ARGS__) #define vvs(...) \ o_vvt(__VA_ARGS__, vvt4, vvt3, vvt2, vvt1, vvt0)(string, __VA_ARGS__) #define vvd(...) \ o_vvt(__VA_ARGS__, vvt4, vvt3, vvt2, vvt1, vvt0)(double, __VA_ARGS__) #define vvc(...) \ o_vvt(__VA_ARGS__, vvt4, vvt3, vvt2, vvt1, vvt0)(char, __VA_ARGS__) #define vvp(...) \ o_vvt(__VA_ARGS__, vvt4, vvt3, vvt2, vvt1, vvt0)(P, __VA_ARGS__) template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); } template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); } #define vni(name, ...) auto name = make_v<int>(__VA_ARGS__) #define vnb(name, ...) auto name = make_v<bool>(__VA_ARGS__) #define vns(name, ...) auto name = make_v<string>(__VA_ARGS__) #define vnd(name, ...) auto name = make_v<double>(__VA_ARGS__) #define vnc(name, ...) auto name = make_v<char>(__VA_ARGS__) #define vnp(name, ...) auto name = make_v<P>(__VA_ARGS__) #define PQ priority_queue<int, vector<int>, greater<int>> #define tos to_string using mapi = map<int, int>; using mapp = map<P, int>; using mapd = map<dou, int>; using mapc = map<char, int>; using maps = map<str, int>; using seti = set<int>; using setd = set<dou>; using setc = set<char>; using sets = set<str>; using qui = queue<int>; #define bset bitset #define uset unordered_set #define mset multiset #define umap unordered_map #define umapi unordered_map<int, int> #define umapp unordered_map<P, int> #define mmap multimap template <class T> struct pq { priority_queue<T, vector<T>, greater<T>> q; /*小さい順*/ T su = 0; void clear() { q = priority_queue<T, vector<T>, greater<T>>(); su = 0; } void operator+=(T v) { su += v; q.push(v); } T sum() { return su; } T top() { return q.top(); } void pop() { su -= q.top(); q.pop(); } T poll() { T ret = q.top(); su -= ret; q.pop(); return ret; } int size() { return q.size(); } }; template <class T> struct pqg { priority_queue<T> q; /*大きい順*/ T su = 0; void clear() { q = priority_queue<T>(); su = 0; } void operator+=(T v) { su += v; q.push(v); } T sum() { return su; } T top() { return q.top(); } void pop() { su -= q.top(); q.pop(); } T poll() { T ret = q.top(); su -= ret; q.pop(); return ret; } int size() { return q.size(); } }; #define pqi pq<int> #define pqgi pqg<int> //マクロ 繰り返し #define o_rep(o1, o2, o3, o4, name, ...) name #define rep1(n) for (int rep1i = 0, rep1lim = n; rep1i < rep1lim; ++rep1i) #define rep2(i, n) for (int i = 0, rep2lim = n; i < rep2lim; ++i) #define rep3(i, m, n) for (int i = m, rep3lim = n; i < rep3lim; ++i) #define rep4(i, m, n, ad) for (int i = m, rep4lim = n; i < rep4lim; i += ad) #define rep(...) o_rep(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__) #define rer2(i, n) for (int i = n; i >= 0; i--) #define rer3(i, m, n) for (int i = m, rer3lim = n; i >= rer3lim; i--) #define rer4(i, m, n, dec) for (int i = m, rer4lim = n; i >= rer4lim; i -= dec) #define rer(...) o_rep(__VA_ARGS__, rer4, rer3, rer2, )(__VA_ARGS__) #define reps2(i, j, n) \ for (int i = 0, reps2lim = n; i < reps2lim; ++i) \ for (int j = 0; j < reps2lim; ++j) #define reps3(i, j, k, n) \ for (int i = 0, reps3lim = n; i < reps3lim; ++i) \ for (int j = 0; j < reps3lim; ++j) \ for (int k = 0; k < reps3lim; ++k) #define reps4(i, j, k, l, n) \ for (int i = 0, reps4lim = n; i < reps4lim; ++i) \ for (int j = 0; j < reps4lim; ++j) \ for (int k = 0; k < reps4lim; ++k) \ for (int l = 0; l < reps4lim; ++l) #define o_reps(o1, o2, o3, o4, o5, name, ...) name #define reps(...) o_reps(__VA_ARGS__, reps4, reps3, reps2, rep2, )(__VA_ARGS__) #define repss(i, j, k, a, b, c) \ for (int i = 0; i < a; ++i) \ for (int j = 0; j < b; ++j) \ for (int k = 0; k < c; ++k) #define fora(a, b) for (auto &&a : b) #define forg(gi, ve) \ for (int gi = 0, forglim = ve.size(), f, t, c; \ gi < forglim && (f = ve[gi].f, t = ve[gi].t, c = ve[gi].c, true); ++gi) #define fort(gi, ve) \ for (int gi = 0, f, t, c; \ gi < ve.size() && (f = ve[gi].f, t = ve[gi].t, c = ve[gi].c, true); \ ++gi) \ if (t != p) #define form(st, l, r) \ for (auto &&it = st.lower_bound(l); it != st.end() && (*it).fi < r; ++it) #define forit(st, l, r) \ for (auto &&it = st.lower_bound(l); it != st.end() && (*it) < r;) //マクロ 定数 #define k3 1010 #define k4 10101 #define k5 101010 #define k6 1010101 #define k7 10101010 const int inf = (int)1e9 + 100; const ll linf = (ll)1e18 + 100; const char infc = '{'; const string infs = "{"; const double eps = 1e-9; const double PI = 3.1415926535897932384626433832795029L; ll ma = numeric_limits<ll>::min(); ll mi = numeric_limits<ll>::max(); const int y4[] = {-1, 1, 0, 0}; const int x4[] = {0, 0, -1, 1}; const int y8[] = {0, 1, 0, -1, -1, 1, 1, -1}; const int x8[] = {1, 0, -1, 0, 1, -1, 1, -1}; //マクロ省略形 関数等 #define arsz(a) (sizeof(a) / sizeof(a[0])) #define sz(a) ((int)(a).size()) #define mp make_pair #define pb pop_back #define pf push_front #define eb emplace_back #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() constexpr bool ev(int a) { return !(a & 1); } constexpr bool od(int a) { return (a & 1); } //@拡張系 こう出来るべきというもの //埋め込み 存在を意識せずに機能を増やされているもの namespace std { template <> class hash<std::pair<signed, signed>> { public: size_t operator()(const std::pair<signed, signed> &x) const { return hash<ll>()(((ll)x.first << 32) + x.second); } }; template <> class hash<std::pair<ll, ll>> { public : /*大きいllが渡されると、<<32でオーバーフローするがとりあえず問題ないと判断*/ size_t operator()(const std::pair<ll, ll> &x) const { return hash<ll>()(((ll)x.first << 32) + x.second); } }; } // namespace std // stream まとめ istream &operator>>(istream &iss, P &a) { iss >> a.first >> a.second; return iss; } template <typename T> istream &operator>>(istream &iss, vector<T> &vec) { for (T &x : vec) iss >> x; return iss; } template <class T, class U> ostream &operator<<(ostream &os, pair<T, U> p) { os << p.fi << " " << p.se << endl; return os; } ostream &operator<<(ostream &os, T p) { os << p.f << " " << p.s << " " << p.t; return os; } ostream &operator<<(ostream &os, F p) { os << p.a << " " << p.b << " " << p.c << " " << p.d; return os; } template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) { for (int i = 0; i < vec.size(); ++i) os << vec[i] << (i + 1 == vec.size() ? "" : " "); return os; } template <typename T> ostream &operator<<(ostream &os, vector<vector<T>> &vec) { for (int i = 0; i < vec.size(); ++i) { for (int j = 0; j < vec[0].size(); ++j) { os << vec[i][j]; } os << endl; } return os; } template <typename T, typename U> ostream &operator<<(ostream &os, map<T, U> &m) { for (auto &&v : m) os << v; return os; } template <typename W, typename H> void resize(vector<W> &vec, const H head) { vec.resize(head); } template <typename W, typename H, typename... T> void resize(vector<W> &vec, const H &head, const T... tail) { vec.resize(head); for (auto &v : vec) resize(v, tail...); } template <typename T, typename F> bool all_of2(T &v, F f) { return f(v); } template <typename T, typename F> bool all_of2(vector<T> &v, F f) { rep(i, sz(v)) { if (!all_of2(v[i], f)) return false; } return true; } template <typename T, typename F> bool any_of2(T &v, F f) { return f(v); } template <typename T, typename F> bool any_of2(vector<T> &v, F f) { rep(i, sz(v)) { if (any_of2(v[i], f)) return true; } return false; } template <typename T, typename F> bool none_of2(T &v, F f) { return f(v); } template <typename T, typename F> bool none_of2(vector<T> &v, F f) { rep(i, sz(v)) { if (none_of2(v[i], f)) return false; } return true; } template <typename T, typename F> bool find_if2(T &v, F f) { return f(v); } template <typename T, typename F> int find_if2(vector<T> &v, F f) { rep(i, sz(v)) { if (find_if2(v[i], f)) return i; } return sz(v); } template <typename T, typename F> bool rfind_if2(T &v, F f) { return f(v); } template <typename T, typename F> int rfind_if2(vector<T> &v, F f) { rer(i, sz(v) - 1) { if (rfind_if2(v[i], f)) return i; } return -1; } template <class T> bool contains(string &s, const T &v) { return s.find(v) != string::npos; } template <typename T> bool contains(vector<T> &v, const T &val) { return std::find(v.begin(), v.end(), val) != v.end(); } template <typename T, typename F> bool contains_if2(vector<T> &v, F f) { return find_if(v.begin(), v.end(), f) != v.end(); } template <typename T, typename F> int count_if2(T &v, F f) { return f(v); } template <typename T, typename F> int count_if2(vector<T> &vec, F f) { int ret = 0; fora(v, vec) ret += count_if2(v, f); return ret; } template <typename T, typename F> void for_each2(T &v, F f) { f(v); } template <typename T, typename F> void for_each2(vector<T> &vec, F f) { fora(v, vec) for_each2(v, f); } template <typename W> int count_od(vector<W> &a) { return count_if2(a, [](int v) { return v & 1; }); } template <typename W> int count_ev(vector<W> &a) { return count_if2(a, [](int v) { return !(v & 1); }); } #define all_of(a, right) all_of2(a, lam(right)) #define any_of(a, right) any_of2(a, lam(right)) #define none_of(a, right) none_of2(a, lam(right)) #define find_if(a, right) find_if2(a, lam(right)) #define rfind_if(a, right) rfind_if2(a, lam(right)) #define contains_if(a, right) contains_if2(a, lam(right)) #define count_if(a, right) count_if2(a, lam(right)) #define for_each(a, right) \ do { \ fora(v, a) { v right; } \ } while (0) template <class T, class U> void replace(vector<T> &a, T key, U v) { replace(a.begin(), a.end(), key, v); } void replace(str &a, char key, str v) { if (v == "") a.erase(remove(all(a), key), a.end()); } void replace(str &a, char key, char v) { replace(all(a), key, v); } // keyと同じかどうか01で置き換える template <class T, class U> void replace(vector<T> &a, U k) { rep(i, sz(a)) a[i] = a[i] == k; } template <class T, class U> void replace(vector<vector<T>> &a, U k) { rep(i, sz(a)) rep(j, sz(a[0])) a[i][j] = a[i][j] == k; } template <class T> void replace(T &a) { replace(a, '#'); } void replace(str &a, str key, str v) { stringstream t; int kn = sz(key); std::string::size_type Pos(a.find(key)); int l = 0; while (Pos != std::string::npos) { t << a.substr(l, Pos - l); t << v; l = Pos + kn; Pos = a.find(key, Pos + kn); } t << a.substr(l, sz(a) - l); a = t.str(); } template <class T> bool includes(vector<T> &a, vector<T> &b) { vi c = a; vi d = b; sort(all(c)); sort(all(d)); return includes(all(c), all(d)); } template <class T> bool is_permutation(vector<T> &a, vector<T> &b) { return is_permutation(all(a), all(b)); } template <class T> bool next_permutation(vector<T> &a) { return next_permutation(all(a)); } void iota(vector<int> &ve, int s, int n) { ve.resize(n); iota(all(ve), s); } vi iota(int s, int len) { vi ve(len); iota(all(ve), s); return ve; } template <class A, class B> auto vtop(vector<A> &a, vector<B> &b) { assert(sz(a) == sz(b)); /*stringを0で初期化できない */ vector<pair<A, B>> res; rep(i, sz(a)) res.eb(a[i], b[i]); return res; } template <class A, class B> void ptov(vector<pair<A, B>> &p, vector<A> &a, vector<B> &b) { a.resize(sz(p)), b.resize(sz(p)); rep(i, sz(p)) a[i] = p[i].fi, b[i] = p[i].se; } template <class A, class B, class C> auto vtot(vector<A> &a, vector<B> &b, vector<C> &c) { assert(sz(a) == sz(b) && sz(b) == sz(c)); vector<T2<A, B, C>> res; rep(i, sz(a)) res.eb(a[i], b[i], c[i]); return res; } template <class A, class B, class C, class D> auto vtof(vector<A> &a, vector<B> &b, vector<C> &c, vector<D> &d) { assert(sz(a) == sz(b) && sz(b) == sz(c) && sz(c) == sz(d)); vector<F2<A, B, C, D>> res; rep(i, sz(a)) res.eb(a[i], b[i], c[i], d[i]); return res; } enum pcomparator { fisi, fisd, fdsi, fdsd, sifi, sifd, sdfi, sdfd }; enum tcomparator { fisiti, fisitd, fisdti, fisdtd, fdsiti, fdsitd, fdsdti, fdsdtd, fitisi, fitisd, fitdsi, fitdsd, fdtisi, fdtisd, fdtdsi, fdtdsd, sifiti, sifitd, sifdti, sifdtd, sdfiti, sdfitd, sdfdti, sdfdtd, sitifi, sitifd, sitdfi, sitdfd, sdtifi, sdtifd, sdtdfi, sdfdfd, tifisi, tifisd, tifdsi, tifdsd, tdfisi, tdfisd, tdfdsi, tdfdsd, tisifi, tisifd, tisdfi, tisdfd, tdsifi, tdsifd, tdsdfi, tdsdfd }; template <class A, class B> void sort(vector<pair<A, B>> &a, pcomparator type) { typedef pair<A, B> U; if (type == fisi) sort(all(a), [&](U l, U r) { return l.fi != r.fi ? l.fi < r.fi : l.se < r.se; }); else if (type == fisd) sort(all(a), [&](U l, U r) { return l.fi != r.fi ? l.fi < r.fi : l.se > r.se; }); else if (type == fdsi) sort(all(a), [&](U l, U r) { return l.fi != r.fi ? l.fi > r.fi : l.se < r.se; }); else if (type == fdsd) sort(all(a), [&](U l, U r) { return l.fi != r.fi ? l.fi > r.fi : l.se > r.se; }); else if (type == sifi) sort(all(a), [&](U l, U r) { return l.se != r.se ? l.se < r.se : l.fi < r.fi; }); else if (type == sifd) sort(all(a), [&](U l, U r) { return l.se != r.se ? l.se < r.se : l.fi > r.fi; }); else if (type == sdfi) sort(all(a), [&](U l, U r) { return l.se != r.se ? l.se > r.se : l.fi < r.fi; }); else if (type == sdfd) sort(all(a), [&](U l, U r) { return l.se != r.se ? l.se > r.se : l.fi > r.fi; }); }; template <class U> void sort(vector<U> &a, pcomparator type) { if (type == fisi) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f < r.f : l.s < r.s; }); else if (type == fisd) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f < r.f : l.s > r.s; }); else if (type == fdsi) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f > r.f : l.s < r.s; }); else if (type == fdsd) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f > r.f : l.s > r.s; }); else if (type == sifi) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s < r.s : l.f < r.f; }); else if (type == sifd) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s < r.s : l.f > r.f; }); else if (type == sdfi) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s > r.s : l.f < r.f; }); else if (type == sdfd) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s > r.s : l.f > r.f; }); }; template <class A, class B, class C, class D> void sort(vector<F2<A, B, C, D>> &a, pcomparator type) { typedef F2<A, B, C, D> U; if (type == fisi) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a < r.a : l.b < r.b; }); else if (type == fisd) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a < r.a : l.b > r.b; }); else if (type == fdsi) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a > r.a : l.b < r.b; }); else if (type == fdsd) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a > r.a : l.b > r.b; }); else if (type == sifi) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b < r.b : l.a < r.a; }); else if (type == sifd) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b < r.b : l.a > r.a; }); else if (type == sdfi) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b > r.b : l.a < r.a; }); else if (type == sdfd) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b > r.b : l.a > r.a; }); }; template <class U> void sort(vector<U> &a, tcomparator type) { if (type == 0) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f < r.f : l.s != r.s ? l.s < r.s : l.t < r.t; }); else if (type == 1) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f < r.f : l.s != r.s ? l.s < r.s : l.t > r.t; }); else if (type == 2) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f < r.f : l.s != r.s ? l.s > r.s : l.t < r.t; }); else if (type == 3) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f < r.f : l.s != r.s ? l.s > r.s : l.t > r.t; }); else if (type == 4) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f > r.f : l.s != r.s ? l.s < r.s : l.t < r.t; }); else if (type == 5) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f > r.f : l.s != r.s ? l.s < r.s : l.t > r.t; }); else if (type == 6) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f > r.f : l.s != r.s ? l.s > r.s : l.t < r.t; }); else if (type == 7) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f > r.f : l.s != r.s ? l.s > r.s : l.t > r.t; }); else if (type == 8) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f < r.f : l.t != r.t ? l.t < r.t : l.s < r.s; }); else if (type == 9) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f < r.f : l.t != r.t ? l.t < r.t : l.s > r.s; }); else if (type == 10) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f < r.f : l.t != r.t ? l.t > r.t : l.s < r.s; }); else if (type == 11) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f < r.f : l.t != r.t ? l.t > r.t : l.s > r.s; }); else if (type == 12) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f > r.f : l.t != r.t ? l.t < r.t : l.s < r.s; }); else if (type == 13) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f > r.f : l.t != r.t ? l.t < r.t : l.s > r.s; }); else if (type == 14) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f > r.f : l.t != r.t ? l.t > r.t : l.s < r.s; }); else if (type == 15) sort(all(a), [&](U l, U r) { return l.f != r.f ? l.f > r.f : l.t != r.t ? l.t > r.t : l.s > r.s; }); else if (type == 16) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s < r.s : l.f != r.f ? l.f < r.f : l.t < r.t; }); else if (type == 17) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s < r.s : l.f != r.f ? l.f < r.f : l.t > r.t; }); else if (type == 18) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s < r.s : l.f != r.f ? l.f > r.f : l.t < r.t; }); else if (type == 19) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s < r.s : l.f != r.f ? l.f > r.f : l.t > r.t; }); else if (type == 20) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s > r.s : l.f != r.f ? l.f < r.f : l.t < r.t; }); else if (type == 21) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s > r.s : l.f != r.f ? l.f < r.f : l.t > r.t; }); else if (type == 22) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s > r.s : l.f != r.f ? l.f > r.f : l.t < r.t; }); else if (type == 23) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s > r.s : l.f != r.f ? l.f > r.f : l.t > r.t; }); else if (type == 24) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s < r.s : l.t != r.t ? l.t < r.t : l.f < r.f; }); else if (type == 25) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s < r.s : l.t != r.t ? l.t < r.t : l.f > r.f; }); else if (type == 26) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s < r.s : l.t != r.t ? l.t > r.t : l.f < r.f; }); else if (type == 27) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s < r.s : l.t != r.t ? l.t > r.t : l.f > r.f; }); else if (type == 28) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s > r.s : l.t != r.t ? l.t < r.t : l.f < r.f; }); else if (type == 29) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s > r.s : l.t != r.t ? l.t < r.t : l.f > r.f; }); else if (type == 30) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s > r.s : l.t != r.t ? l.t > r.t : l.f < r.f; }); else if (type == 31) sort(all(a), [&](U l, U r) { return l.s != r.s ? l.s > r.s : l.t != r.t ? l.t > r.t : l.f > r.f; }); else if (type == 32) sort(all(a), [&](U l, U r) { return l.t != r.t ? l.t < r.t : l.f != r.f ? l.f < r.f : l.s < r.s; }); else if (type == 33) sort(all(a), [&](U l, U r) { return l.t != r.t ? l.t < r.t : l.f != r.f ? l.f < r.f : l.s > r.s; }); else if (type == 34) sort(all(a), [&](U l, U r) { return l.t != r.t ? l.t < r.t : l.f != r.f ? l.f > r.f : l.s < r.s; }); else if (type == 35) sort(all(a), [&](U l, U r) { return l.t != r.t ? l.t < r.t : l.f != r.f ? l.f > r.f : l.s > r.s; }); else if (type == 36) sort(all(a), [&](U l, U r) { return l.t != r.t ? l.t > r.t : l.f != r.f ? l.f < r.f : l.s < r.s; }); else if (type == 37) sort(all(a), [&](U l, U r) { return l.t != r.t ? l.t > r.t : l.f != r.f ? l.f < r.f : l.s > r.s; }); else if (type == 38) sort(all(a), [&](U l, U r) { return l.t != r.t ? l.t > r.t : l.f != r.f ? l.f > r.f : l.s < r.s; }); else if (type == 39) sort(all(a), [&](U l, U r) { return l.t != r.t ? l.t > r.t : l.f != r.f ? l.f > r.f : l.s > r.s; }); else if (type == 40) sort(all(a), [&](U l, U r) { return l.t != r.t ? l.t < r.t : l.s != r.s ? l.s < r.s : l.f < r.f; }); else if (type == 41) sort(all(a), [&](U l, U r) { return l.t != r.t ? l.t < r.t : l.s != r.s ? l.s < r.s : l.f > r.f; }); else if (type == 42) sort(all(a), [&](U l, U r) { return l.t != r.t ? l.t < r.t : l.s != r.s ? l.s > r.s : l.f < r.f; }); else if (type == 43) sort(all(a), [&](U l, U r) { return l.t != r.t ? l.t < r.t : l.s != r.s ? l.s > r.s : l.f > r.f; }); else if (type == 44) sort(all(a), [&](U l, U r) { return l.t != r.t ? l.t > r.t : l.s != r.s ? l.s < r.s : l.f < r.f; }); else if (type == 45) sort(all(a), [&](U l, U r) { return l.t != r.t ? l.t > r.t : l.s != r.s ? l.s < r.s : l.f > r.f; }); else if (type == 46) sort(all(a), [&](U l, U r) { return l.t != r.t ? l.t > r.t : l.s != r.s ? l.s > r.s : l.f < r.f; }); else if (type == 47) sort(all(a), [&](U l, U r) { return l.t != r.t ? l.t > r.t : l.s != r.s ? l.s > r.s : l.f > r.f; }); } template <class A, class B, class C, class D> void sort(vector<F2<A, B, C, D>> &a, tcomparator type) { typedef F2<A, B, C, D> U; if (type == 0) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a < r.a : l.b != r.b ? l.b < r.b : l.c < r.c; }); else if (type == 1) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a < r.a : l.b != r.b ? l.b < r.b : l.c > r.c; }); else if (type == 2) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a < r.a : l.b != r.b ? l.b > r.b : l.c < r.c; }); else if (type == 3) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a < r.a : l.b != r.b ? l.b > r.b : l.c > r.c; }); else if (type == 4) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a > r.a : l.b != r.b ? l.b < r.b : l.c < r.c; }); else if (type == 5) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a > r.a : l.b != r.b ? l.b < r.b : l.c > r.c; }); else if (type == 6) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a > r.a : l.b != r.b ? l.b > r.b : l.c < r.c; }); else if (type == 7) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a > r.a : l.b != r.b ? l.b > r.b : l.c > r.c; }); else if (type == 8) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a < r.a : l.c != r.c ? l.c < r.c : l.b < r.b; }); else if (type == 9) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a < r.a : l.c != r.c ? l.c < r.c : l.b > r.b; }); else if (type == 10) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a < r.a : l.c != r.c ? l.c > r.c : l.b < r.b; }); else if (type == 11) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a < r.a : l.c != r.c ? l.c > r.c : l.b > r.b; }); else if (type == 12) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a > r.a : l.c != r.c ? l.c < r.c : l.b < r.b; }); else if (type == 13) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a > r.a : l.c != r.c ? l.c < r.c : l.b > r.b; }); else if (type == 14) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a > r.a : l.c != r.c ? l.c > r.c : l.b < r.b; }); else if (type == 15) sort(all(a), [&](U l, U r) { return l.a != r.a ? l.a > r.a : l.c != r.c ? l.c > r.c : l.b > r.b; }); else if (type == 16) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b < r.b : l.a != r.a ? l.a < r.a : l.c < r.c; }); else if (type == 17) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b < r.b : l.a != r.a ? l.a < r.a : l.c > r.c; }); else if (type == 18) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b < r.b : l.a != r.a ? l.a > r.a : l.c < r.c; }); else if (type == 19) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b < r.b : l.a != r.a ? l.a > r.a : l.c > r.c; }); else if (type == 20) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b > r.b : l.a != r.a ? l.a < r.a : l.c < r.c; }); else if (type == 21) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b > r.b : l.a != r.a ? l.a < r.a : l.c > r.c; }); else if (type == 22) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b > r.b : l.a != r.a ? l.a > r.a : l.c < r.c; }); else if (type == 23) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b > r.b : l.a != r.a ? l.a > r.a : l.c > r.c; }); else if (type == 24) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b < r.b : l.c != r.c ? l.c < r.c : l.a < r.a; }); else if (type == 25) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b < r.b : l.c != r.c ? l.c < r.c : l.a > r.a; }); else if (type == 26) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b < r.b : l.c != r.c ? l.c > r.c : l.a < r.a; }); else if (type == 27) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b < r.b : l.c != r.c ? l.c > r.c : l.a > r.a; }); else if (type == 28) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b > r.b : l.c != r.c ? l.c < r.c : l.a < r.a; }); else if (type == 29) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b > r.b : l.c != r.c ? l.c < r.c : l.a > r.a; }); else if (type == 30) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b > r.b : l.c != r.c ? l.c > r.c : l.a < r.a; }); else if (type == 31) sort(all(a), [&](U l, U r) { return l.b != r.b ? l.b > r.b : l.c != r.c ? l.c > r.c : l.a > r.a; }); else if (type == 32) sort(all(a), [&](U l, U r) { return l.c != r.c ? l.c < r.c : l.a != r.a ? l.a < r.a : l.b < r.b; }); else if (type == 33) sort(all(a), [&](U l, U r) { return l.c != r.c ? l.c < r.c : l.a != r.a ? l.a < r.a : l.b > r.b; }); else if (type == 34) sort(all(a), [&](U l, U r) { return l.c != r.c ? l.c < r.c : l.a != r.a ? l.a > r.a : l.b < r.b; }); else if (type == 35) sort(all(a), [&](U l, U r) { return l.c != r.c ? l.c < r.c : l.a != r.a ? l.a > r.a : l.b > r.b; }); else if (type == 36) sort(all(a), [&](U l, U r) { return l.c != r.c ? l.c > r.c : l.a != r.a ? l.a < r.a : l.b < r.b; }); else if (type == 37) sort(all(a), [&](U l, U r) { return l.c != r.c ? l.c > r.c : l.a != r.a ? l.a < r.a : l.b > r.b; }); else if (type == 38) sort(all(a), [&](U l, U r) { return l.c != r.c ? l.c > r.c : l.a != r.a ? l.a > r.a : l.b < r.b; }); else if (type == 39) sort(all(a), [&](U l, U r) { return l.c != r.c ? l.c > r.c : l.a != r.a ? l.a > r.a : l.b > r.b; }); else if (type == 40) sort(all(a), [&](U l, U r) { return l.c != r.c ? l.c < r.c : l.b != r.b ? l.b < r.b : l.a < r.a; }); else if (type == 41) sort(all(a), [&](U l, U r) { return l.c != r.c ? l.c < r.c : l.b != r.b ? l.b < r.b : l.a > r.a; }); else if (type == 42) sort(all(a), [&](U l, U r) { return l.c != r.c ? l.c < r.c : l.b != r.b ? l.b > r.b : l.a < r.a; }); else if (type == 43) sort(all(a), [&](U l, U r) { return l.c != r.c ? l.c < r.c : l.b != r.b ? l.b > r.b : l.a > r.a; }); else if (type == 44) sort(all(a), [&](U l, U r) { return l.c != r.c ? l.c > r.c : l.b != r.b ? l.b < r.b : l.a < r.a; }); else if (type == 45) sort(all(a), [&](U l, U r) { return l.c != r.c ? l.c > r.c : l.b != r.b ? l.b < r.b : l.a > r.a; }); else if (type == 46) sort(all(a), [&](U l, U r) { return l.c != r.c ? l.c > r.c : l.b != r.b ? l.b > r.b : l.a < r.a; }); else if (type == 47) sort(all(a), [&](U l, U r) { return l.c != r.c ? l.c > r.c : l.b != r.b ? l.b > r.b : l.a > r.a; }); } void sort(string &a) { sort(all(a)); } template <class T> void sort(vector<T> &a) { sort(all(a)); } // P l, P rで f(P) の形で渡す template <class U, class F> void sort(vector<U> &a, F f) { sort(all(a), [&](U l, U r) { return f(l) < f(r); }); }; template <class T> void rsort(vector<T> &a) { sort(all(a), greater<T>()); }; template <class U, class F> void rsort(vector<U> &a, F f) { sort(all(a), [&](U l, U r) { return f(l) > f(r); }); }; // F = T<T> //例えばreturn p.fi + p.se; template <class A, class B> void sortp(vector<A> &a, vector<B> &b) { auto c = vtop(a, b); sort(c); rep(i, sz(a)) a[i] = c[i].fi, b[i] = c[i].se; } template <class A, class B, class F> void sortp(vector<A> &a, vector<B> &b, F f) { auto c = vtop(a, b); sort(c, f); rep(i, sz(a)) a[i] = c[i].fi, b[i] = c[i].se; } template <class A, class B> void rsortp(vector<A> &a, vector<B> &b) { auto c = vtop(a, b); rsort(c); rep(i, sz(a)) a[i] = c[i].first, b[i] = c[i].second; } template <class A, class B, class F> void rsortp(vector<A> &a, vector<B> &b, F f) { auto c = vtop(a, b); rsort(c, f); rep(i, sz(a)) a[i] = c[i].first, b[i] = c[i].second; } template <class A, class B, class C> void sortt(vector<A> &a, vector<B> &b, vector<C> &c) { auto d = vtot(a, b, c); sort(d); rep(i, sz(a)) a[i] = d[i].f, b[i] = d[i].s, c[i] = d[i].t; } template <class A, class B, class C, class F> void sortt(vector<A> &a, vector<B> &b, vector<C> &c, F f) { auto d = vtot(a, b, c); sort(d, f); rep(i, sz(a)) a[i] = d[i].f, b[i] = d[i].s, c[i] = d[i].t; } template <class A, class B, class C> void rsortt(vector<A> &a, vector<B> &b, vector<C> &c) { auto d = vtot(a, b, c); rsort(d); rep(i, sz(a)) a[i] = d[i].f, b[i] = d[i].s, c[i] = d[i].t; } template <class A, class B, class C, class F> void rsortt(vector<A> &a, vector<B> &b, vector<C> &c, F f) { auto d = vtot(a, b, c); rsort(d, f); rep(i, sz(a)) a[i] = d[i].f, b[i] = d[i].s, c[i] = d[i].t; } // sortindex 元のvectorはソートしない template <class T> vi sorti(vector<T> &a) { auto b = a; vi ind = iota(0, sz(a)); sortp(b, ind); return ind; } /*indexの分で型が変わるためpcomparatorが必要*/ template <class T> vi sorti(vector<T> &a, pcomparator f) { auto b = a; vi ind = iota(0, sz(a)); sortp(b, ind, f); return ind; } template <class T, class F> vi sorti(vector<T> &a, F f) { vi ind = iota(0, sz(a)); sort(all(ind), [&](int x, int y) { return f(a[x]) < f(a[y]); }); return ind; } template <class T> vi rsorti(vector<T> &a) { auto b = a; vi ind = iota(0, sz(a)); rsortp(b, ind); return ind; } template <class T, class F> vi rsorti(vector<T> &a, F f) { vi ind = iota(0, sz(a)); sort(all(ind), [&](int x, int y) { return f(a[x]) > f(a[y]); }); return ind; } template <class A, class B, class F> vi sortpi(vector<A> &a, vector<B> &b, F f) { auto c = vtop(a, b); vi ind = iota(0, sz(a)); sort(all(ind), [&](int x, int y) { return f(c[x]) < f(c[y]); }); return ind; } template <class A, class B> vi sortpi(vector<A> &a, vector<B> &b, pcomparator f) { vi ind = iota(0, sz(a)); auto c = a; auto d = b; sortt(c, d, ind, f); return ind; } template <class A, class B> vi sortpi(vector<A> &a, vector<B> &b) { return sortpi(a, b, fisi); }; template <class A, class B, class F> vi rsortpi(vector<A> &a, vector<B> &b, F f) { auto c = vtop(a, b); vi ind = iota(0, sz(a)); sort(all(ind), [&](int x, int y) { return f(c[x]) > f(c[y]); }); return ind; } template <class A, class B> vi rsortpi(vector<A> &a, vector<B> &b) { return sortpi(a, b, fdsd); }; template <class A, class B, class C, class F> vi sortti(vector<A> &a, vector<B> &b, vector<C> &c, F f) { auto d = vtot(a, b, c); vi ind = iota(0, sz(a)); sort(all(ind), [&](int x, int y) { return f(d[x]) < f(d[y]); }); return ind; } template <class A, class B, class C> vi sortti(vector<A> &a, vector<B> &b, vector<C> &c, pcomparator f) { vi ind = iota(0, sz(a)); auto d = vtof(a, b, c, ind); sort(d, f); rep(i, sz(a)) ind[i] = d[i].d; return ind; } template <class A, class B, class C> vi sortti(vector<A> &a, vector<B> &b, vector<C> &c) { vi ind = iota(0, sz(a)); sort(all(ind), [&](int x, int y) { if (a[x] == a[y]) { if (b[x] == b[y]) return c[x] < c[y]; else return b[x] < b[y]; } else { return a[x] < a[y]; } }); return ind; } template <class A, class B, class C, class F> vi rsortti(vector<A> &a, vector<B> &b, vector<C> &c, F f) { auto d = vtot(a, b, c); vi ind = iota(0, sz(a)); sort(all(ind), [&](int x, int y) { return f(d[x]) > f(d[y]); }); return ind; } template <class A, class B, class C> vi rsortti(vector<A> &a, vector<B> &b, vector<C> &c) { vi ind = iota(0, sz(a)); sort(all(ind), [&](int x, int y) { if (a[x] == a[y]) { if (b[x] == b[y]) return c[x] > c[y]; else return b[x] > b[y]; } else { return a[x] > a[y]; } }); return ind; } template <class T> void sort2(vector<vector<T>> &a) { for (int i = 0, n = a.size(); i < n; ++i) sort(a[i]); } template <class T> void rsort2(vector<vector<T>> &a) { for (int i = 0, n = a.size(); i < n; ++i) rsort(a[i]); } template <typename A, size_t N, typename T> void fill(A (&a)[N], const T &v) { rep(i, N) a[i] = v; } template <typename A, size_t N, size_t O, typename T> void fill(A (&a)[N][O], const T &v) { rep(i, N) rep(j, O) a[i][j] = v; } template <typename A, size_t N, size_t O, size_t P, typename T> void fill(A (&a)[N][O][P], const T &v) { rep(i, N) rep(j, O) rep(k, P) a[i][j][k] = v; } template <typename A, size_t N, size_t O, size_t P, size_t Q, typename T> void fill(A (&a)[N][O][P][Q], const T &v) { rep(i, N) rep(j, O) rep(k, P) rep(l, Q) a[i][j][k][l] = v; } template <typename A, size_t N, size_t O, size_t P, size_t Q, size_t R, typename T> void fill(A (&a)[N][O][P][Q][R], const T &v) { rep(i, N) rep(j, O) rep(k, P) rep(l, Q) rep(m, R) a[i][j][k][l][m] = v; } template <typename A, size_t N, size_t O, size_t P, size_t Q, size_t R, size_t S, typename T> void fill(A (&a)[N][O][P][Q][R][S], const T &v) { rep(i, N) rep(j, O) rep(k, P) rep(l, Q) rep(m, R) rep(n, S) a[i][j][k][l][m][n] = v; } template <typename W, typename T> void fill(W &xx, const T vall) { xx = vall; } template <typename W, typename T> void fill(vector<W> &vecc, const T vall) { for (auto &&vx : vecc) fill(vx, vall); } template <class T, class U> void fill(vector<T> &a, U val, vi &ind) { fora(v, ind) a[v] = val; } template <typename A, size_t N> A sum(A (&a)[N]) { A res = 0; rep(i, N) res += a[i]; return res; } template <typename A, size_t N, size_t O> A sum(A (&a)[N][O]) { A res = 0; rep(i, N) rep(j, O) res += a[i][j]; return res; } template <typename A, size_t N, size_t O, size_t P> A sum(A (&a)[N][O][P]) { A res = 0; rep(i, N) rep(j, O) rep(k, P) res += a[i][j][k]; return res; } template <typename A, size_t N, size_t O, size_t P, size_t Q> A sum(A (&a)[N][O][P][Q]) { A res = 0; rep(i, N) rep(j, O) rep(k, P) rep(l, Q) res += a[i][j][k][l]; return res; } template <typename A, size_t N, size_t O, size_t P, size_t Q, size_t R> A sum(A (&a)[N][O][P][Q][R]) { A res = 0; rep(i, N) rep(j, O) rep(k, P) rep(l, Q) rep(m, R) res += a[i][j][k][l][m]; return res; } template <typename A, size_t N, size_t O, size_t P, size_t Q, size_t R, size_t S> A sum(A (&a)[N][O][P][Q][R][S]) { A res = 0; rep(i, N) rep(j, O) rep(k, P) rep(l, Q) rep(m, R) rep(n, S) res += a[i][j][k][l][m][n]; return res; } //@汎用便利関数 入力 int in() { int ret; cin >> ret; return ret; } string sin() { string ret; cin >> ret; return ret; } template <class T> void in(T &head) { cin >> head; } template <class T, class... U> void in(T &head, U &...tail) { cin >> head; in(tail...); } #define o_din(o1, o2, o3, o4, name, ...) name #define din1(a) \ int a; \ cin >> a #define din2(a, b) \ int a, b; \ cin >> a >> b #define din3(a, b, c) \ int a, b, c; \ cin >> a >> b >> c #define din4(a, b, c, d) \ int a, b, c, d; \ cin >> a >> b >> c >> d #define din(...) o_din(__VA_ARGS__, din4, din3, din2, din1)(__VA_ARGS__) #define o_dind(o1, o2, o3, o4, name, ...) name #define din1d(a) \ din1(a); \ a-- #define din2d(a, b) \ din2(a, b); \ a--, b-- #define din3d(a, b, c) \ din3(a, b, c); \ a--, b--, c-- #define din4d(a, b, c, d) \ din4(a, b, c, d); \ a--, b--, c--, d-- #define dind(...) o_dind(__VA_ARGS__, din4d, din3d, din2d, din1d)(__VA_ARGS__) #define o_out(o1, o2, o3, o4, name, ...) name #define out1(a) cout << a << endl #define out2(a, b) cout << a << " " << b << endl #define out3(a, b, c) cout << a << " " << b << " " << c << endl #define out4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl #define out(...) o_out((__VA_ARGS__), out4, out3, out2, out1)((__VA_ARGS__)) template <class T> void outl(vector<T> &a) { fora(v, a) cout << v << endl; } template <class T> void na(vector<T> &a, int n) { a.resize(n); rep(i, n) cin >> a[i]; } #define dna(a, n) \ vi a(n); \ rep(dnai, n) cin >> a[dnai]; template <class T> void nao(vector<T> &a, int n) { a.resize(n + 1); a[0] = 0; rep(i, n) cin >> a[i + 1]; } template <class T> void naod(vector<T> &a, int n) { a.resize(n + 1); a[0] = 0; rep(i, n) cin >> a[i + 1], a[i + 1]--; } template <class T> void nad(vector<T> &a, int n) { a.resize(n); rep(i, n) cin >> a[i], a[i]--; } template <class T, class U> void na2(vector<T> &a, vector<U> &b, int n) { a.resize(n); b.resize(n); rep(i, n) cin >> a[i] >> b[i]; } #define dna2(a, b, n) \ vi a(n), b(n); \ rep(dna2i, n) cin >> a[dna2i] >> b[dna2i]; template <class T, class U> void nao2(vector<T> &a, vector<U> &b, int n) { a.resize(n + 1); b.resize(n + 1); a[0] = b[0] = 0; rep(i, n) cin >> a[i + 1] >> b[i + 1]; } #define dna2d(a, b, n) \ vi a(n), b(n); \ rep(dna2di, n) { \ cin >> a[dna2di] >> b[dna2di]; \ a[dna2di]--, b[dna2di]--; \ } template <class T, class U> void na2d(vector<T> &a, vector<U> &b, int n) { a.resize(n); b.resize(n); rep(i, n) cin >> a[i] >> b[i], a[i]--, b[i]--; } template <class T, class U, class W> void na3(vector<T> &a, vector<U> &b, vector<W> &c, int n) { a.resize(n); b.resize(n); c.resize(n); rep(i, n) cin >> a[i] >> b[i] >> c[i]; } #define dna3(a, b, c, n) \ vi a(n), b(n), c(n); \ rep(dna3i, n) cin >> a[dna3i] >> b[dna3i] >> c[dna3i]; template <class T, class U, class W> void na3d(vector<T> &a, vector<U> &b, vector<W> &c, int n) { a.resize(n); b.resize(n); c.resize(n); rep(i, n) cin >> a[i] >> b[i] >> c[i], a[i]--, b[i]--, c[i]--; } #define dna3d(a, b, c, n) \ vi a(n), b(n), c(n); \ rep(dna3di, n) { \ cin >> a[dna3di] >> b[dna3di] >> c[dna3di]; \ a[dna3di]--, b[dna3di]--, c[dna3di]--; \ } #define nt(a, h, w) \ resize(a, h, w); \ rep(nthi, h) rep(ntwi, w) cin >> a[nthi][ntwi]; #define ntd(a, h, w) \ resize(a, h, w); \ rep(ntdhi, h) rep(ntdwi, w) cin >> a[ntdhi][ntdwi], a[ntdhi][ntdwi]--; #define ntp(a, h, w) \ resize(a, h + 2, w + 2); \ fill(a, '#'); \ rep(ntphi, 1, h + 1) rep(ntpwi, 1, w + 1) cin >> a[ntphi][ntpwi]; //デバッグ #define sp << " " << #define debugName(VariableName) #VariableName #define deb1(x) debugName(x) << " = " << x #define deb2(x, ...) deb1(x) << ", " << deb1(__VA_ARGS__) #define deb3(x, ...) deb1(x) << ", " << deb2(__VA_ARGS__) #define deb4(x, ...) deb1(x) << ", " << deb3(__VA_ARGS__) #define deb5(x, ...) deb1(x) << ", " << deb4(__VA_ARGS__) #define deb6(x, ...) deb1(x) << ", " << deb5(__VA_ARGS__) #define deb7(x, ...) deb1(x) << ", " << deb6(__VA_ARGS__) #define deb8(x, ...) deb1(x) << ", " << deb7(__VA_ARGS__) #define deb9(x, ...) deb1(x) << ", " << deb8(__VA_ARGS__) #define deb10(x, ...) deb1(x) << ", " << deb9(__VA_ARGS__) #define o_ebug(o1, o2, o3, o4, o5, o6, o7, o8, o9, o10, name, ...) name #ifdef _DEBUG #define deb(...) \ cerr << o_ebug(__VA_ARGS__, deb10, deb9, deb8, deb7, deb6, deb5, deb4, deb3, \ deb2, deb1)(__VA_ARGS__) \ << endl #else #define deb(...) ; #endif #define debugline(x) \ cerr << x << " " \ << "(L:" << __LINE__ << ")" << '\n' //よく使うクラス、構造体 class UnionFind { public: vi par, rank, sizes; int n, trees; UnionFind(int n) : n(n), trees(n) { par.resize(n), rank.resize(n), sizes.resize(n); rep(i, n) par[i] = i, sizes[i] = 1; } int root(int x) { if (par[x] == x) return x; else return par[x] = root(par[x]); } int find(int x) { return root(x); } void unite(int x, int y) { x = root(x); y = root(y); if (x == y) return; if (rank[x] < rank[y]) swap(x, y); trees--; par[y] = x; sizes[x] += sizes[y]; if (rank[x] == rank[y]) ++rank[x]; } bool same(int x, int y) { return root(x) == root(y); } int size(int x) { return sizes[root(x)]; } //順不同 umapなので V<vi> sets() { vvi(res, trees); umap<int, vi> map; rep(i, n) map[root(i)].push_back(i); int i = 0; for (auto &&p : map) { int r = p.fi; res[i].push_back(r); for (auto &&v : p.se) { if (r == v) continue; res[i].push_back(v); } ++i; } return res; } }; using bint = __int128; using u32 = unsigned; using u64 = unsigned long long; using u128 = __uint128_t; std::ostream &operator<<(std::ostream &dest, __int128_t value) { std::ostream::sentry s(dest); if (s) { __uint128_t tmp = value < 0 ? -value : value; char buffer[128]; char *d = std::end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = std::end(buffer) - d; if (dest.rdbuf()->sputn(d, len) != len) { dest.setstate(std::ios_base::badbit); } } return dest; } //__int128 toi128(string &s) { __int128 ret = 0; for (int i = 0; i < //s.length(); ++i) if ('0' <= s[i] && s[i] <= '9') ret = 10 * //ret + s[i] - '0'; return ret;} //エラー void ole() { #ifdef _DEBUG debugline("ole"); exit(0); #endif string a = "a"; rep(i, 30) a += a; rep(i, 1 << 17) cout << a << endl; cout << "OLE 出力長制限超過" << endl; exit(0); } void re() { assert(0 == 1); exit(0); } void tle() { while (inf) cout << inf << endl; } //便利関数 //テスト用 char ranc() { return (char)('a' + rand() % 26); } int rand(int min, int max) { assert(min <= max); if (min >= 0 && max >= 0) { return rand() % (max + 1 - min) + min; } else if (max < 0) { return -rand(-max, -min); } else { if (rand() % 2) { return rand(0, max); } else { return -rand(0, -min); } } } vi ranv(int n, int min, int max) { vi v(n); rep(i, n) v[i] = rand(min, max); return v; } str ransu(int n) { str s; rep(i, n) s += (char)rand('A', 'Z'); return s; } str ransl(int n) { str s; rep(i, n) s += (char)rand('a', 'z'); return s; } //単調増加 vi ranvinc(int n, int min, int max) { vi v(n); bool bad = 1; while (bad) { bad = 0; v.resize(n); rep(i, n) { if (i && min > max - v[i - 1]) { bad = 1; break; } if (i) v[i] = v[i - 1] + rand(min, max - v[i - 1]); else v[i] = rand(min, max); } } return v; } //便利 汎用 void ranvlr(int n, int min, int max, vi &l, vi &r) { l.resize(n); r.resize(n); rep(i, n) { l[i] = rand(min, max); r[i] = l[i] + rand(0, max - l[i]); } } vp run_length(vi &a) { vp ret; ret.eb(a[0], 1); rep(i, 1, sz(a)) { if (ret.back().fi == a[i]) { ret.back().se++; } else { ret.eb(a[i], 1); } } return ret; } vector<pair<char, int>> run_length(string &a) { vector<pair<char, int>> ret; ret.eb(a[0], 1); rep(i, 1, sz(a)) { if (ret.back().fi == a[i]) { ret.back().se++; } else { ret.eb(a[i], 1); } } return ret; } template <class F> int mgr(int ok, int ng, F f) { if (ok < ng) while (ng - ok > 1) { int mid = (ok + ng) / 2; if (f(mid)) ok = mid; else ng = mid; } else while (ok - ng > 1) { int mid = (ok + ng) / 2; if (f(mid)) ok = mid; else ng = mid; } return ok; } // strを整数として比較 string smax(str &a, str b) { if (sz(a) < sz(b)) { return b; } else if (sz(a) > sz(b)) { return a; } else { rep(i, sz(a)) { if (a[i] < b[i]) { return b; } else if (a[i] > b[i]) return a; } } return a; } // strを整数として比較 string smin(str &a, str b) { if (sz(a) < sz(b)) { return a; } else if (sz(a) > sz(b)) { return b; } else { rep(i, sz(a)) { if (a[i] < b[i]) { return a; } else if (a[i] > b[i]) return b; } } return a; } template <typename W, typename T> int find(vector<W> &a, const T key) { rep(i, sz(a)) if (a[i] == key) return i; return -1; } template <typename W, typename T> P find(vector<vector<W>> &a, const T key) { rep(i, sz(a)) rep(j, sz(a[0])) if (a[i][j] == key) return mp(i, j); return mp(-1, -1); } template <typename W, typename U> T find(vector<vector<vector<W>>> &a, const U key) { rep(i, sz(a)) rep(j, sz(a[0])) rep(k, sz(a[0][0])) if (a[i][j][k] == key) return mt(i, j, k); return mt(-1, -1, -1); } template <typename W, typename T> int count2(W &a, const T k) { return a == k; } template <typename W, typename T> int count2(vector<W> &a, const T k) { int ret = 0; fora(v, a) ret += count(v, k); return ret; } template <typename W, typename T> int count(vector<W> &a, const T k) { int ret = 0; fora(v, a) ret += count2(v, k); return ret; } int count(str &a, str k) { int ret = 0, len = k.length(); auto pos = a.find(k); while (pos != string::npos) pos = a.find(k, pos + len), ++ret; return ret; } vi count(str &a) { vi cou(26); char c = 'a'; if ('A' <= a[0] && a[0] <= 'Z') c = 'A'; rep(i, sz(a))++ cou[a[i] - c]; return cou; } #define couif count_if // algorythm inline ll rev(ll a) { ll res = 0; while (a) { res *= 10; res += a % 10; a /= 10; } return res; } template <class T> void rev(vector<T> &a) { reverse(all(a)); } template <class U> void rev(vector<vector<U>> &a) { vector<vector<U>> b(sz(a[0]), vector<U>(sz(a))); rep(h, sz(a)) rep(w, sz(a[0])) b[w][h] = a[h][w]; a = b; } void inline rev(string &a) { reverse(all(a)); } constexpr int p10[] = {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10000000000ll, 100000000000ll, 1000000000000ll, 10000000000000ll, 100000000000000ll, 1000000000000000ll, 10000000000000000ll, 100000000000000000ll, 1000000000000000000ll}; int get(int a, int keta) { return (a / (int)pow(10, keta)) % 10; } int keta(ll v) { if (v < p10[9]) { if (v < p10[4]) { if (v < p10[2]) { if (v < p10[1]) return 1; else return 2; } else { if (v < p10[3]) return 3; else return 4; } } else { if (v < p10[7]) { if (v < p10[5]) return 5; else if (v < p10[6]) return 6; else return 7; } else { if (v < p10[8]) return 8; else return 9; } } } else { if (v < p10[13]) { if (v < p10[11]) { if (v < p10[10]) return 10; else return 11; } else { if (v < p10[12]) return 12; else return 13; } } else { if (v < p10[15]) { if (v < p10[14]) return 14; else if (v < p10[15]) return 15; else return 16; } else { if (v < p10[17]) return 17; else return 18; } } } } int dsum(int v) { int ret = 0; for (; v; v /= 10) ret += v % 10; return ret; } struct sint { int v; sint(int v) : v(v) {} operator int() { return v; } //下からi番目 int operator[](int i) { return (v / p10[i]) % 10; } int back(int i) { return operator[](i); } //上からi番目 int top(int i) { int len = keta(v); return operator[](len - 1 - i); } //先頭からi番目にセット int settop(int i, int k) { int len = keta(v); return set(len - 1 - i, k); } int set(int i, int k) { if (i < 0) return settop(abs(i) - 1, k); return v += p10[i] * (k - (v / p10[i]) % 10); } int add(int i, int k = 1) { return v += p10[i] * k; } int addtop(int i, int k = 1) { return v += p10[keta(v) - i - 1] * k; } int dec(int i, int k = 1) { return v -= p10[i] * k; } int dectop(int i, int k = 1) { return v -= p10[keta(v) - i - 1] * k; } #define op(t, o) \ template <class T> inline t operator o(T r) { return v o r; } op(int, +=); op(int, -=); op(int, *=); op(int, /=); op(int, %=); op(int, +); op(int, -); op(int, *); op(int, /); op(int, %); op(bool, ==); op(bool, !=); op(bool, <); op(bool, <=); op(bool, >); op(bool, >=); #undef op template <class T> inline int operator<<=(T r) { return v *= p10[r]; } template <class T> inline int operator<<(T r) { return v * p10[r]; } template <class T> inline int operator>>=(T r) { return v /= p10[r]; } template <class T> inline int operator>>(T r) { return v / p10[r]; } }; int mask10(int v) { return p10[v] - 1; } //変換系 template <class T> auto keys(T a) { vector<decltype((a.begin())->fi)> res; for (auto &&k : a) res.push_back(k.fi); return res; } template <class T> auto values(T a) { vector<decltype((a.begin())->se)> res; for (auto &&k : a) res.push_back(k.se); return res; } template <class T, class U> inline bool chma(T &a, const U &b) { if (a < b) { a = b; return true; } return false; } template <class U> inline bool chma(const U &b) { return chma(ma, b); } template <class T, class U> inline bool chmi(T &a, const U &b) { if (b < a) { a = b; return true; } return false; } template <class U> inline bool chmi(const U &b) { return chmi(mi, b); } template <class T> inline T min(T a, signed b) { return a < b ? a : b; } template <class T> inline T max(T a, signed b) { return a < b ? b : a; } template <class T> inline T min(T a, T b, T c) { return a >= b ? b >= c ? c : b : a >= c ? c : a; } template <class T> inline T max(T a, T b, T c) { return a <= b ? b <= c ? c : b : a <= c ? c : a; } template <class T> inline T min(vector<T> a) { return *min_element(all(a)); } template <class T> inline T mini(vector<T> a) { return min_element(all(a)) - a.begin(); } template <class T> inline T min(vector<T> a, int n) { return *min_element(a.begin(), a.begin() + min(n, sz(a))); } template <class T> inline T min(vector<T> a, int s, int n) { return *min_element(a.begin() + s, a.begin() + min(n, sz(a))); } template <class T> inline T max(vector<T> a) { return *max_element(all(a)); } template <class T> inline T maxi(vector<T> a) { return max_element(all(a)) - a.begin(); } template <class T> inline T max(vector<T> a, int n) { return *max_element(a.begin(), a.begin() + min(n, sz(a))); } template <class T> inline T max(vector<T> a, int s, int n) { return *max_element(a.begin() + s, a.begin() + min(n, sz(a))); } template <typename A, size_t N> inline A max(A (&a)[N]) { A res = a[0]; rep(i, N) res = max(res, a[i]); return res; } template <typename A, size_t N, size_t O> inline A max(A (&a)[N][O]) { A res = max(a[0]); rep(i, N) res = max(res, max(a[i])); return res; } template <typename A, size_t N, size_t O, size_t P> inline A max(A (&a)[N][O][P]) { A res = max(a[0]); rep(i, N) res = max(res, max(a[i])); return res; } template <typename A, size_t N, size_t O, size_t P, size_t Q> inline A max(A (&a)[N][O][P][Q], const T &v) { A res = max(a[0]); rep(i, N) res = max(res, max(a[i])); return res; } template <typename A, size_t N, size_t O, size_t P, size_t Q, size_t R> inline A max(A (&a)[N][O][P][Q][R]) { A res = max(a[0]); rep(i, N) res = max(res, max(a[i])); return res; } template <typename A, size_t N, size_t O, size_t P, size_t Q, size_t R, size_t S> inline A max(A (&a)[N][O][P][Q][R][S]) { A res = max(a[0]); rep(i, N) res = max(res, max(a[i])); return res; } template <typename A, size_t N> inline A min(A (&a)[N]) { A res = a[0]; rep(i, N) res = min(res, a[i]); return res; } template <typename A, size_t N, size_t O> inline A min(A (&a)[N][O]) { A res = min(a[0]); rep(i, N) res = min(res, max(a[i])); return res; } template <typename A, size_t N, size_t O, size_t P> inline A min(A (&a)[N][O][P]) { A res = min(a[0]); rep(i, N) res = min(res, min(a[i])); return res; } template <typename A, size_t N, size_t O, size_t P, size_t Q> inline A min(A (&a)[N][O][P][Q], const T &v) { A res = min(a[0]); rep(i, N) res = min(res, min(a[i])); return res; } template <typename A, size_t N, size_t O, size_t P, size_t Q, size_t R> inline A min(A (&a)[N][O][P][Q][R]) { A res = min(a[0]); rep(i, N) res = min(res, min(a[i])); return res; } template <typename A, size_t N, size_t O, size_t P, size_t Q, size_t R, size_t S> inline A min(A (&a)[N][O][P][Q][R][S]) { A res = min(a[0]); rep(i, N) res = min(res, min(a[i])); return res; } //@formatter:on template <class T> T sum(vector<T> &v, int s = 0, int t = inf) { T ret = 0; rep(i, s, min(sz(v), t)) ret += v[i]; return ret; } //@formatter:off template <class T> T sum(vector<vector<T>> &v) { T ret = 0; rep(i, sz(v)) ret += sum(v[i]); return ret; } template <class T> T sum(vector<vector<vector<T>>> &v) { T ret = 0; rep(i, sz(v)) ret += sum(v[i]); return ret; } template <class T> T sum(vector<vector<vector<vector<T>>>> &v) { T ret = 0; rep(i, sz(v)) ret += sum(v[i]); return ret; } template <class T> T sum(vector<vector<vector<vector<vector<T>>>>> &v) { T ret = 0; rep(i, sz(v)) ret += sum(v[i]); return ret; } template <class T> auto sum(priority_queue<T, vector<T>, greater<T>> &r) { auto q = r; T ret = 0; while (sz(q)) { ret += q.top(); q.pop(); } return ret; } template <class T> auto sum(priority_queue<T> &r) { auto q = r; T ret = 0; while (sz(q)) { ret += q.top(); q.pop(); } return ret; } // template<class T, class U, class... W> inline auto sumn(vector<T> &v, U head, // W... tail) { auto ret = sum(v[0], tail...); rep(i, 1, min(sz(v), // head))ret += sum(v[i], tail...); return ret;} void clear(PQ &q) { q = PQ(); } template <class T> void clear(queue<T> &q) { while (q.size()) q.pop(); } template <class T> T *negarr(int size) { T *body = (T *)malloc((size * 2 + 1) * sizeof(T)); return body + size; } template <class T> T *negarr2(int h, int w) { double **dummy1 = new double *[2 * h + 1]; double *dummy2 = new double[(2 * h + 1) * (2 * w + 1)]; dummy1[0] = dummy2 + w; for (int i = 1; i <= 2 * h + 1; ++i) { dummy1[i] = dummy1[i - 1] + 2 * w + 1; } double **a = dummy1 + h; return a; } // imoは0-indexed // ruiは1-indexed template <class T> vector<T> imo(vector<T> &v) { vector<T> ret = v; rep(i, sz(ret) - 1) ret[i + 1] += ret[i]; return ret; } // kと同じものの数 template <class T, class U> vi imocou(vector<T> &a, U k) { vector<T> ret = a; rep(i, sz(ret) - 1) ret[i + 1] = ret[i] + (a[i] == k); return ret; } template <class T> vector<T> imox(vector<T> &v) { vector<T> ret = v; rep(i, sz(ret) - 1) ret[i + 1] ^= ret[i]; return ret; } //漸化的に最小を持つ template <class T> vector<T> imi(vector<T> &v) { vector<T> ret = v; rep(i, sz(ret) - 1) chmi(ret[i + 1], ret[i]); return ret; } template <class T> struct ruiC { const vector<T> rui; ruiC(vector<T> &ru) : rui(ru) {} T operator()(int l, int r) { assert(l <= r); return rui[r] - rui[l]; } T operator[](int i) { return rui[i]; } T back() { return rui.back(); } int size() { return rui.size(); } }; template <class T> struct rruic { const T *rrui; rruic(T *ru) : rrui(ru) {} inline T operator()(int l, int r) { assert(l >= r); return rrui[r] - rrui[l]; } inline T operator[](int i) { return rrui[i]; } }; template <class T> vector<T> ruiv(vector<T> &a) { vector<T> ret(a.size() + 1); rep(i, a.size()) ret[i + 1] = ret[i] + a[i]; return ret; } template <class T> ruiC<T> ruic(vector<T> &a) { vector<T> ret = ruiv(a); return ruiC<T>(ret); } vector<int> ruiv(string &a) { if (sz(a) == 0) return vi(1); int dec = ('0' <= a[0] && a[0] <= '9') ? '0' : 0; vector<int> ret(a.size() + 1); rep(i, a.size()) ret[i + 1] = ret[i] + a[i] - dec; return ret; } ruiC<int> ruic(string &a) { vector<int> ret = ruiv(a); return ruiC<int>(ret); } // kと同じものの数 template <class T, class U> vi ruiv(T &a, U k) { vi ret(a.size() + 1); rep(i, a.size()) ret[i + 1] = ret[i] + (a[i] == k); return ret; } template <class T, class U> ruiC<int> ruic(T &a, U k) { vi ret = ruiv(a, k); return ruiC<int>(ret); } // xor template <class T> vector<T> ruix(vector<T> &a) { vector<T> ret(a.size() + 1); rep(i, a.size()) ret[i + 1] = ret[i] ^ a[i]; return ret; } template <class T> vector<T> ruim(vector<T> &a) { vector<T> res(a.size() + 1, 1); rep(i, a.size()) res[i + 1] = res[i] * a[i]; return res; } //漸化的に最小を1indexで持つ template <class T> vector<T> ruimi(vector<T> &a) { int n = sz(a); vector<T> ret(n + 1); rep(i, 1, n) { ret[i] = a[i - 1]; chmi(ret[i + 1], ret[i]); } return ret; } // template<class T> T *rrui(vector<T> &a) { //右から左にかけての半開区間 (-1 n-1] template <class T> rruic<T> rrui(vector<T> &a) { int len = a.size(); T *body = (T *)malloc((len + 1) * sizeof(T)); T *res = body + 1; rer(i, len - 1) res[i - 1] = res[i] + a[i]; return rruic<T>(res); } //掛け算 template <class T> T *rruim(vector<T> &a) { int len = a.size(); T *body = (T *)malloc((len + 1) * sizeof(T)); T *res = body + 1; res[len - 1] = 1; rer(i, len - 1) res[i - 1] = res[i] * a[i]; return res; } template <class T, class U> void inc(T &a, U v = 1) { a += v; } template <class T, class U> void inc(vector<T> &a, U v = 1) { for (auto &u : a) inc(u, v); } template <class T, class U> void dec(T &a, U v = 1) { a -= v; } template <class T, class U> void dec(vector<T> &a, U v = 1) { for (auto &u : a) dec(u, v); } template <class U> void dec(string &a, U v = 1) { for (auto &u : a) dec(u, v); } template <class T> void dec(vector<T> &a) { for (auto &u : a) dec(u, 1); } bool ins(int h, int w, int H, int W) { return h >= 0 && w >= 0 && h < H && w < W; } bool ins(int l, int v, int r) { return l <= v && v < r; } template <class T> bool ins(vector<T> &a, int i, int j = 0) { return ins(0, i, sz(a)) && ins(0, j, sz(a)); } ll u(ll a) { return a < 0 ? 0 : a; } template <class T> vector<T> u(const vector<T> &a) { vector<T> ret = a; fora(v, ret) v = u(v); return ret; } #define MIN(a) numeric_limits<a>::min() #define MAX(a) numeric_limits<a>::max() ll goldd(ll left, ll right, function<ll(ll)> calc) { double GRATIO = 1.6180339887498948482045868343656; ll lm = left + (ll)((right - left) / (GRATIO + 1.0)); ll rm = lm + (ll)((right - lm) / (GRATIO + 1.0)); ll fl = calc(lm); ll fr = calc(rm); while (right - left > 10) { if (fl < fr) { right = rm; rm = lm; fr = fl; lm = left + (ll)((right - left) / (GRATIO + 1.0)); fl = calc(lm); } else { left = lm; lm = rm; fl = fr; rm = lm + (ll)((right - lm) / (GRATIO + 1.0)); fr = calc(rm); } } ll minScore = MAX(ll); ll resIndex = left; for (ll i = left; i < right + 1; ++i) { ll score = calc(i); if (minScore > score) { minScore = score; resIndex = i; } } return resIndex; } ll goldt(ll left, ll right, function<ll(ll)> calc) { double GRATIO = 1.6180339887498948482045868343656; ll lm = left + (ll)((right - left) / (GRATIO + 1.0)); ll rm = lm + (ll)((right - lm) / (GRATIO + 1.0)); ll fl = calc(lm); ll fr = calc(rm); while (right - left > 10) { if (fl > fr) { right = rm; rm = lm; fr = fl; lm = left + (ll)((right - left) / (GRATIO + 1.0)); fl = calc(lm); } else { left = lm; lm = rm; fl = fr; rm = lm + (ll)((right - lm) / (GRATIO + 1.0)); fr = calc(rm); } } if (left > right) { ll l = left; left = right; right = l; } ll maxScore = MIN(ll); ll resIndex = left; for (ll i = left; i < right + 1; ++i) { ll score = calc(i); if (maxScore < score) { maxScore = score; resIndex = i; } } return resIndex; } template <class T> T min(vector<vector<T>> &a) { T res = MAX(T); rep(i, a.size()) chmi(res, *min_element(all(a[i]))); return res; } template <class T> T max(vector<vector<T>> &a) { T res = MIN(T); rep(i, a.size()) chma(res, *max_element(all(a[i]))); return res; } constexpr bool bget(ll m, int keta) { return (m >> keta) & 1; } int bget(ll m, int keta, int sinsuu) { m /= (ll)pow(sinsuu, keta); return m % sinsuu; } ll bit(int n) { return (1LL << (n)); } ll bit(int n, int sinsuu) { return (ll)pow(sinsuu, n); } int mask(int n) { return (1ll << n) - 1; } #define bcou __builtin_popcountll //最下位ビット int lbit(int n) { return n & -n; } //最上位ビット int hbit(int n) { n |= (n >> 1); n |= (n >> 2); n |= (n >> 4); n |= (n >> 8); n |= (n >> 16); n |= (n >> 32); return n - (n >> 1); } int hbitk(int n) { int k = 0; rer(i, 5) { int a = k + (1ll << i); int b = 1ll << a; if (b <= n) k += 1ll << i; } return k; } //初期化は0を渡す ll nextComb(ll &mask, int n, int r) { if (!mask) return mask = (1LL << r) - 1; ll x = mask & -mask; /*最下位の1*/ ll y = mask + x; /*連続した下の1を繰り上がらせる*/ ll res = ((mask & ~y) / x >> 1) | y; if (bget(res, n)) return mask = 0; else return mask = res; } // n桁以下でビットがr個立っているもののvectorを返す vi bitCombList(int n, int r) { vi res; int m = 0; while (nextComb(m, n, r)) { res.push_back(m); } return res; } char itoal(int i) { return 'a' + i; } char itoaL(int i) { return 'A' + i; } int altoi(char c) { if ('A' <= c && c <= 'Z') return c - 'A'; return c - 'a'; } int ctoi(char c) { return c - '0'; } char itoc(int i) { return i + '0'; } int vtoi(vi &v) { int res = 0; if (sz(v) > 18) { debugline("vtoi"); deb(sz(v)); ole(); } rep(i, sz(v)) { res *= 10; res += v[i]; } return res; } vi itov(int i) { vi res; while (i) { res.push_back(i % 10); i /= 10; } rev(res); return res; } vi stov(string &a) { int n = sz(a); vi ret(n); rep(i, n) { ret[i] = a[i] - '0'; } return ret; } //基準を満たさないものは0になる vi stov(string &a, char one) { int n = sz(a); vi ret(n); rep(i, n) ret[i] = a[i] == one; return ret; } vector<vector<int>> ctoi(vector<vector<char>> s, char c) { int n = sz(s), m = sz(s[0]); vector<vector<int>> res(n, vector<int>(m)); rep(i, n) rep(j, m) res[i][j] = s[i][j] == c; return res; } #define unique(v) v.erase(unique(v.begin(), v.end()), v.end()); //[i] := i番として圧縮されたものを返す vi compress(vi &a) { vi b; int len = a.size(); for (int i = 0; i < len; ++i) { b.push_back(a[i]); } sort(b); unique(b); for (int i = 0; i < len; ++i) { a[i] = lower_bound(all(b), a[i]) - b.begin(); } int blen = sz(b); vi ret(blen); rep(i, blen) { ret[i] = b[i]; } return ret; } vi compress(vi &a, umap<int, int> &map) { vi b; int len = a.size(); for (int i = 0; i < len; ++i) { b.push_back(a[i]); } sort(b); unique(b); for (int i = 0; i < len; ++i) { int v = a[i]; a[i] = lower_bound(all(b), a[i]) - b.begin(); map[v] = a[i]; } int blen = sz(b); vi ret(blen); rep(i, blen) { ret[i] = b[i]; } return ret; } vi compress(vi &a, vi &r) { vi b; int len = a.size(); fora(v, a) b.push_back(v); fora(v, r) b.push_back(v); sort(b); unique(b); for (int i = 0; i < len; ++i) a[i] = lower_bound(all(b), a[i]) - b.begin(); for (int i = 0; i < sz(r); ++i) r[i] = lower_bound(all(b), r[i]) - b.begin(); int blen = sz(b); vi ret(blen); rep(i, blen) { ret[i] = b[i]; } return ret; } vi compress(vi &a, vi &r, vi &s) { vi b; int len = a.size(); fora(v, a) b.push_back(v); fora(v, r) b.push_back(v); fora(v, s) b.push_back(v); sort(b); unique(b); for (int i = 0; i < len; ++i) a[i] = lower_bound(all(b), a[i]) - b.begin(); for (int i = 0; i < sz(r); ++i) r[i] = lower_bound(all(b), r[i]) - b.begin(); for (int i = 0; i < sz(s); ++i) r[i] = lower_bound(all(b), s[i]) - b.begin(); int blen = sz(b); vi ret(blen); rep(i, blen) { ret[i] = b[i]; } return ret; } vi compress(V<vi> &a) { vi b; fora(vv, a) fora(v, vv) b.push_back(v); sort(b); unique(b); fora(vv, a) fora(v, vv) v = lower_bound(all(b), v) - b.begin(); int blen = sz(b); vi ret(blen); rep(i, blen) { ret[i] = b[i]; } return ret; } vi compress(vector<vector<vi>> &a) { vi b; fora(vvv, a) fora(vv, vvv) fora(v, vv) b.push_back(v); sort(b); unique(b); fora(vvv, a) fora(vv, vvv) fora(v, vv) v = lower_bound(all(b), v) - b.begin(); int blen = sz(b); vi ret(blen); rep(i, blen) { ret[i] = b[i]; } return ret; } void compress(int a[], int len) { vi b; for (int i = 0; i < len; ++i) { b.push_back(a[i]); } sort(b); unique(b); for (int i = 0; i < len; ++i) { a[i] = lower_bound(all(b), a[i]) - b.begin(); } } //要素が見つからなかったときに困る #define binarySearch(a, v) (binary_search(all(a), v)) #define lowerIndex(a, v) (lower_bound(all(a), v) - a.begin()) #define lowerBound(a, v) (*lower_bound(all(a), v)) #define upperIndex(a, v) (upper_bound(all(a), v) - a.begin()) #define upperBound(a, v) (*upper_bound(all(a), v)) template <class T> void fin(T s) { cout << s << endl, exit(0); } //便利 数学 math int mod(int a, int m) { return (a % m + m) % m; } int pow(int a) { return a * a; }; ll fact(int v) { return v <= 1 ? 1 : v * fact(v - 1); } ll comi(int n, int r) { assert(n < 100); static vvi(pas, 100, 100); if (pas[0][0]) return pas[n][r]; pas[0][0] = 1; rep(i, 1, 100) { pas[i][0] = 1; rep(j, 1, i + 1) pas[i][j] = pas[i - 1][j - 1] + pas[i - 1][j]; } return pas[n][r]; } double comd(int n, int r) { static vd fac; if (sz(fac) < n + 1) { if (sz(fac) == 0) fac.push_back(1); rep(i, sz(fac) - 1, n) { fac.push_back(fac.back() * (i + 1)); } } if (n < r || n <= 0) return 0; return fac[n] / fac[n - r] / fac[r]; } int gcd(int a, int b) { while (b) a %= b, swap(a, b); return abs(a); } int gcd(vi b) { ll res = b[0]; rep(i, 1, sz(b)) res = gcd(b[i], res); return res; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } ll lcm(vi a) { int res = a[0]; rep(i, 1, sz(a)) res = lcm(a[i], res); return res; } ll ceil(ll a, ll b) { if (b == 0) { debugline("ceil"); deb(a, b); ole(); return -1; } else if (a < 0) { return 0; } else { return (a + b - 1) / b; } } // v * v >= aとなる最小のvを返す ll sqrt(ll a) { if (a < 0) { debugline("sqrt"); deb(a); ole(); } ll res = (ll)std::sqrt(a); while (res * res < a) ++res; return res; } double log(double e, double x) { return log(x) / log(e); } ll sig(ll t) { return (1 + t) * t / 2; } ll sig(ll s, ll t) { return (s + t) * (t - s + 1) / 2; } //幾何 Pをcomplexとして扱う template <class T, class U> bool eq(T a, U b) { return fabs(a - b) < eps; } dou atan2(pd a) { return atan2(a.se, a.fi); } dou angle(pd f, pd t) { return atan2(t.se - f.se, t.fi - f.fi); } dou distance(pd a, pd b) { return hypot(a.fi - b.fi, a.se - b.se); } // bを中心とするabcのtheta aからcにかけて時計回り dou angle(pd a, pd b, pd c) { dou ax = a.fi - b.fi; dou ay = a.se - b.se; dou cx = c.fi - b.fi; dou cy = c.se - b.se; double ret = atan2(cy, cx) - atan2(ay, ax); if (ret < 0) ret += 2 * PI; return ret; } dou dot(pd a, pd b) { return a.fi * b.fi + a.se + b.se; } dou cro(pd a, pd b) { return a.fi * b.se - a.se + b.fi; } //機能拡張 template <class T, class U> void operator+=(queue<T> &a, U v) { a.push(v); } template <class T, class U> void operator+=(deque<T> &a, U v) { a.push_back(v); } template <class T, class U> priority_queue<T, vector<T>, greater<T>> & operator+=(priority_queue<T, vector<T>, greater<T>> &a, vector<U> &v) { fora(d, v) a.push(d); return a; } template <class T, class U> priority_queue<T, vector<T>, greater<T>> & operator+=(priority_queue<T, vector<T>, greater<T>> &a, U v) { a.push(v); return a; } template <class T, class U> priority_queue<T> &operator+=(priority_queue<T> &a, U v) { a.push(v); return a; } template <class T> set<T> &operator+=(set<T> &a, vector<T> v) { fora(d, v) a.insert(d); return a; } template <class T, class U> set<T> &operator+=(set<T> &a, U v) { a.insert(v); return a; } template <class T, class U> set<T, greater<T>> &operator+=(set<T, greater<T>> &a, U v) { a.insert(v); return a; } template <class T, class U> vector<T> &operator+=(vector<T> &a, U v) { a.push_back(v); return a; } template <class T, class U> vector<T> operator+(const vector<T> &a, U v) { vector<T> ret = a; ret += v; return ret; } template <class T, class U> vector<T> operator+(U v, const vector<T> &a) { vector<T> ret = a; ret.insert(ret.begin(), v); return ret; } template <class T> vector<T> operator+(vector<T> a, vector<T> b) { vector<T> ret; ret = a; fora(v, b) ret += v; return ret; } template <class T> vector<T> &operator+=(vector<T> &a, vector<T> &b) { fora(v, b) a += v; return a; } template <class T> vector<T> &operator-=(vector<T> &a, vector<T> &b) { if (sz(a) != sz(b)) { debugline("vector<T> operator-="); deb(a); deb(b); exit(0); } rep(i, sz(a)) a[i] -= b[i]; return a; } template <class T> vector<T> operator-(vector<T> &a, vector<T> &b) { if (sz(a) != sz(b)) { debugline("vector<T> operator-"); deb(a); deb(b); ole(); } vector<T> res(sz(a)); rep(i, sz(a)) res[i] = a[i] - b[i]; return res; } template <class T, class U> vector<T> operator*(vector<T> &a, U b) { vector<T> ret; fora(v, a) ret += v * b; return ret; } template <class T, class U> vector<T> operator/(vector<T> &a, U b) { vector<T> ret; fora(v, a) ret += v / b; return ret; } template <class T, class U> vector<T> operator*=(vector<T> &a, U b) { fora(v, a) v *= b; return a; } template <class T, class U> vector<T> operator/=(vector<T> &a, U b) { fora(v, a) v /= b; return a; } template <typename T> void erase(vector<T> &v, unsigned int i) { v.erase(v.begin() + i); } template <typename T> void erase(vector<T> &v, unsigned int s, unsigned int e) { v.erase(v.begin() + s, v.begin() + e); } template <class T, class U> void erase(map<T, U> &m, int okl, int ngr) { m.erase(m.lower_bound(okl), m.lower_bound(ngr)); } template <class T> void erase(set<T> &m, int okl, int ngr) { m.erase(m.lower_bound(okl), m.lower_bound(ngr)); } template <typename T> void erasen(vector<T> &v, unsigned int s, unsigned int n) { v.erase(v.begin() + s, v.begin() + s + n); } template <typename T, typename U> void insert(vector<T> &v, unsigned int i, U t) { v.insert(v.begin() + i, t); } template <typename T, typename U> void push_front(vector<T> &v, U t) { v.insert(v.begin(), t); } template <typename T, typename U> void insert(vector<T> &v, unsigned int i, vector<T> list) { for (auto &&va : list) v.insert(v.begin() + i++, va); } template <typename T> void insert(set<T> &v, vector<T> list) { for (auto &&va : list) v.insert(va); } vector<string> split(const string a, const char deli) { string b = a + deli; int l = 0, r = 0, n = b.size(); vector<string> res; rep(i, n) { if (b[i] == deli) { r = i; if (l < r) res.push_back(b.substr(l, r - l)); l = i + 1; } } return res; } vector<string> split(const string a, const string deli) { vector<string> res; int kn = sz(deli); std::string::size_type Pos(a.find(deli)); int l = 0; while (Pos != std::string::npos) { if (Pos - l) res.push_back(a.substr(l, Pos - l)); l = Pos + kn; Pos = a.find(deli, Pos + kn); } if (sz(a) - l) res.push_back(a.substr(l, sz(a) - l)); return res; } void yn(bool a) { if (a) cout << "yes" << endl; else cout << "no" << endl; } void Yn(bool a) { if (a) cout << "Yes" << endl; else cout << "No" << endl; } void YN(bool a) { if (a) cout << "YES" << endl; else cout << "NO" << endl; } void fyn(bool a) { if (a) cout << "yes" << endl; else cout << "no" << endl; exit(0); } void fYn(bool a) { if (a) cout << "Yes" << endl; else cout << "No" << endl; exit(0); } void fYN(bool a) { if (a) cout << "YES" << endl; else cout << "NO" << endl; exit(0); } void Possible(bool a) { if (a) cout << "Possible" << endl; else cout << "Impossible" << endl; exit(0); } void POSSIBLE(bool a) { if (a) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; exit(0); } //@起動時 struct initon { initon() { cin.tie(0); ios::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(16); srand((unsigned)clock() + (unsigned)time(NULL)); }; } initonv; //@formatter:on // gra mint pr int n, m, k, d, H, W, x, y, z, q; int cou; vi t, a, b, c; // vvi (s, 0, 0); vvc(ba, 0, 0); vp p; str s; //@formatter:off // type N M template <class T, int N> using A = array<T, N>; template <class T, int N, int M> struct mat : A<A<T, N>, M> { using A<A<T, N>, M>::A; using A<A<T, N>, M>::size; template <class U> mat(vector<vector<U>> &a) { rep(i, sz(a)) rep(j, sz(a[0]))(*this)[i][j] = a[i][j]; } void unit(int v = 1) { int lim = min(h(), w()); rep(i, h()) rep(j, w())(*this)[i][j] = (i == j) ? v : 0; } void zero() { rep(i, h()) rep(j, w())(*this)[i][j] = 0; } mat(int v = 0) { if (v > 0) unit(v); } int h() const { return size(); } int w() const { return (*this)[0].size(); } template <class U> void fill(U v) { rep(i, h()) rep(j, w())(*this)[i][j] = v; } T sum() { T res = 0; rep(i, h()) rep(j, w()) res += (*this)[i][j]; return res; } mat operator+(mat &r) { assert(h() == r.h() && w() == r.w()); mat res = mat(); res.zero(); rep(i, H) rep(j, W) res[i][j] = (this)[i][j] + r[i][j]; return res; } mat operator-(mat &r) { assert(h() == r.h() && w() == r.w()); mat res = mat(); res.zero(); rep(i, H) rep(j, W) res[i][j] = (this)[i][j] - r[i][j]; return res; } mat operator*(mat &r) { assert(w() == r.h()); mat res = mat(); res.zero(); for (int i = 0; i < h(); i++) { for (int j = 0; j < r.w(); j++) { for (int k = 0; k < w(); k++) { res[i][j] += (*this)[i][k] * r[k][j]; } } } return res; } mat &operator+=(mat &r) { return *this = *this + r; } mat &operator-=(mat &r) { return *this = *this - r; } mat &operator*=(mat &r) { return *this = *this * r; } mat pow(ll n) { assert(h() == w()); mat x = *this; mat r(1); while (n) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; } }; template <typename T, int H, int W> ostream &operator<<(ostream &os, mat<T, H, W> vec) { for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { os << vec[i][j]; } os << endl; } return os; } //@formatter:on //@formatter:off int MOD = 1000000007; struct mint { int x; mint() : x(0) {} mint(int a) { x = a % MOD; if (x < 0) x += MOD; } mint &operator+=(mint that) { x = (x + that.x) % MOD; return *this; } mint &operator-=(mint that) { x = (x + MOD - that.x) % MOD; return *this; } mint &operator*=(mint that) { x = (int)x * that.x % MOD; return *this; } mint &operator/=(mint that) { return *this *= that.inverse(); } mint operator-() { return mint(-this->x); } friend ostream &operator<<(ostream &out, mint m) { return out << m.x; } mint inverse() { int a = x, b = MOD, u = 1, v = 0; while (b) { int t = a / b; a -= t * b; u -= t * v; swap(a, b); swap(u, v); } return mint(u); } mint operator+(mint that) { return mint(*this) += that; } mint operator-(mint that) { return mint(*this) -= that; } mint operator*(mint that) { return mint(*this) *= that; } mint operator/(mint that) { return mint(*this) /= that; } bool operator==(mint that) const { return x == that.x; } bool operator!=(mint that) const { return x != that.x; } bool operator<(mint that) const { return x < that.x; } bool operator<=(mint that) const { return x <= that.x; } bool operator>(mint that) const { return x > that.x; } bool operator>=(mint that) const { return x >= that.x; } }; istream &operator>>(istream &i, mint &a) { i >> a.x; return i; } typedef vector<mint> vm; vector<mint> fac, finv; int mint_len = 1400000; void setmod(int mod = 1e9 + 7) { MOD = mod; fac = vector<mint>(mint_len + 1); finv = vector<mint>(mint_len + 1); fac[0] = 1; rep(i, 1, mint_len + 1) fac[i] = fac[i - 1] * i; finv[mint_len] = (mint)1 / fac[mint_len]; rer(i, mint_len, 1) finv[i - 1] = finv[i] * i; } mint com(int a, int b) { if (a < 0) return 0; if (b < 0 || b > a) return 0; return fac[a] * finv[a - b] * finv[b]; } mint hom(int a, int b) { return com(a + b - 1, b); } template <typename T, typename U> mint mpow(const T a, const U b) { assert(b >= 0); int x = a, res = 1; U p = b; while (p > 0) { if (p & 1) (res *= x) %= MOD; (x *= x) %= MOD; p >>= 1; } return res; } template <typename T> inline mint mpow(const T a, const mint b) { int x = a, res = 1; int p = b.x; while (p > 0) { if (p & 1) (res *= x) %= MOD; (x *= x) %= MOD; p >>= 1; } return res; } using PM = pair<mint, mint>; using vm = vector<mint>; #define vvm(...) \ o_vvt(__VA_ARGS__, vvt4, vvt3, vvt2, vvt1, vvt0)(mint, __VA_ARGS__) #define smod setmod // setmodを呼ぶ @formatter:on int lower_rem_i(int kei, int rem, int x) { if (rem >= x) return 0; return (x - rem + kei - 1) / kei; } int lower_rem_v(int kei, int rem, int x) { if (rem >= x) return rem; return (x - rem + kei - 1) / kei * kei + rem; } int upper_rem_i(int kei, int rem, int x) { if (rem > x) return 0; return (x - rem + kei) / kei; } int upper_rem_v(int kei, int rem, int x) { if (rem > x) return rem; return (x - rem + kei) / kei * kei + rem; } void solve() { din(n, a, b, mod); smod(mod); // smod(inf); using M = mat<mint, 3, 3>; int l = 0; M res; res[0][0] = 0; res[0][1] = a; res[0][2] = 1; rep(i, 1, 19) { if (l == n) break; int cou = 0; int r = lower_rem_i(b, a, p10[i]); chmi(r, n); if (l == r) con; cou = r - l; M mt(1); mt[0][0] = mpow(10, i); mt[1][0] = 1; mt[2][1] = b; mt = mt.pow(cou); res *= mt; l = r; } cout << res[0][0] << endl; } int my(int n, vi &a) { return 0; } int sister(int n, vi &a) { int ret = 0; return ret; } signed main() { solve(); #define arg n, a #ifdef _DEBUG bool bad = 0; for (int i = 0, ok = 1; i < k5 && ok; ++i) { int n = rand(1, 8); vi a = ranv(n, 1, 10); int myres = my(arg); int res = sister(arg); ok = myres == res; if (!ok) { out(arg); cerr << "正解 : " << res << endl; cerr << "自分 : " << myres << endl; bad = 1; break; } } if (!bad) { // cout << "完璧 : solveを書き直そう" << endl; // cout << " : そして、solve()を呼び出すのだ" << endl; // cout << " : cin>>n; na(a,n);も忘れるな" << endl; } #endif return 0; };
[ "call.arguments.change", "call.arguments.add" ]
831,328
831,382
u986437843
cpp
p03016
#include <bits/stdc++.h> using namespace std; #define REP(i, a, n) for (int i = (a); i < (int)(n); i++) #define rep(i, n) REP(i, 0, n) #define FOR(it, c) \ for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; typedef unsigned long long ull; typedef vector<ll> vec; typedef vector<vec> mat; mat mul(mat &A, mat &B, ll MOD) { // A*B mat C(A.size(), vec(B[0].size())); rep(i, A.size()) rep(k, B.size()) { rep(j, B[0].size()) { __uint128_t a = A[i][k]; __uint128_t b = B[k][j]; __uint128_t ab = a * b; ab %= MOD; C[i][j] = (C[i][j] + (ll)ab) % MOD; } } return C; } mat pow(mat A, ll n, ll MOD) { // A^n mat B(A.size(), vec(A.size())); rep(i, A.size()) B[i][i] = 1; while (n > 0) { if (n & 1) B = mul(B, A, MOD); A = mul(A, A, MOD); n >>= 1; } return B; } ll mod_pow(ll x, ll n, ll mod) { if (n == 0) return 1; ll res = mod_pow(x * x % mod, n / 2, mod); if (n & 1) res = res * x % mod; return res; } int get_keta(ll x) { int keta = 0; while (x > 0) { keta++; x /= 10; } return keta; } int main() { ll L, A, B, M; cin >> L >> A >> B >> M; ll ret = 0; ll base = 0; vec mvec{0, A, 1}; for (ll k = 1; k < 19; k++) { ll st = -1, ed = -1; { ll lb = -1, ub = L; while (ub - lb > 1) { ll mid = (lb + ub) / 2; ll s = A + B * mid; if (get_keta(s) < k) lb = mid; else ub = mid; } if (0 <= ub && ub < L) { if (get_keta(A + B * ub) == k) st = ub; } } { ll lb = -1, ub = L; while (ub - lb > 1) { ll mid = (lb + ub) / 2; ll s = A + B * mid; if (get_keta(s) <= k) lb = mid; else ub = mid; } if (0 <= lb && lb < L) { if (get_keta(A + B * lb) == k) ed = lb; } } if (st != -1 && ed != -1) { ll n = ed - st + 1; ll kk = 1; rep(i, k) kk *= 10; mat smat{{kk, 0, 0}, {1, 1, 0}, {0, B, 1}}; mat dmat = pow(smat, n, M); // cout << " " << dmat[0][0] << " " << dmat[0][1] << " " << dmat[0][2] << // endl; cout << " " << dmat[1][0] << " " << dmat[1][1] << " " << // dmat[1][2] << endl; cout << " " << dmat[2][0] << " " << dmat[2][1] << " // " << dmat[2][2] << endl; vec nvec{0, 0, 0}; nvec[0] += (dmat[0][0] * mvec[0]) % M; nvec[0] %= M; nvec[0] += (dmat[1][0] * mvec[1]) % M; nvec[0] %= M; nvec[0] += (dmat[2][0] * mvec[2]) % M; nvec[0] %= M; nvec[1] += (dmat[0][1] * mvec[0]) % M; nvec[1] %= M; nvec[1] += (dmat[1][1] * mvec[1]) % M; nvec[1] %= M; nvec[1] += (dmat[2][1] * mvec[2]) % M; nvec[1] %= M; nvec[2] += (dmat[0][2] * mvec[0]) % M; nvec[2] %= M; nvec[2] += (dmat[1][2] * mvec[1]) % M; nvec[2] %= M; nvec[2] += (dmat[2][2] * mvec[2]) % M; nvec[2] %= M; mvec = nvec; // cout << mvec[0] << endl; } } cout << mvec[0] << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define REP(i, a, n) for (int i = (a); i < (int)(n); i++) #define rep(i, n) REP(i, 0, n) #define FOR(it, c) \ for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; typedef unsigned long long ull; typedef vector<ll> vec; typedef vector<vec> mat; mat mul(mat &A, mat &B, ll MOD) { // A*B mat C(A.size(), vec(B[0].size())); rep(i, A.size()) rep(k, B.size()) { rep(j, B[0].size()) { __uint128_t a = A[i][k]; __uint128_t b = B[k][j]; __uint128_t ab = a * b; ab %= MOD; C[i][j] = (C[i][j] + (ll)ab) % MOD; } } return C; } mat pow(mat A, ll n, ll MOD) { // A^n mat B(A.size(), vec(A.size())); rep(i, A.size()) B[i][i] = 1; while (n > 0) { if (n & 1) B = mul(B, A, MOD); A = mul(A, A, MOD); n >>= 1; } return B; } ll mod_pow(ll x, ll n, ll mod) { if (n == 0) return 1; ll res = mod_pow(x * x % mod, n / 2, mod); if (n & 1) res = res * x % mod; return res; } int get_keta(ll x) { int keta = 0; while (x > 0) { keta++; x /= 10; } return keta; } int main() { ll L, A, B, M; cin >> L >> A >> B >> M; ll ret = 0; ll base = 0; vec mvec{0, A % M, 1}; for (ll k = 1; k < 19; k++) { ll st = -1, ed = -1; { ll lb = -1, ub = L; while (ub - lb > 1) { ll mid = (lb + ub) / 2; ll s = A + B * mid; if (get_keta(s) < k) lb = mid; else ub = mid; } if (0 <= ub && ub < L) { if (get_keta(A + B * ub) == k) st = ub; } } { ll lb = -1, ub = L; while (ub - lb > 1) { ll mid = (lb + ub) / 2; ll s = A + B * mid; if (get_keta(s) <= k) lb = mid; else ub = mid; } if (0 <= lb && lb < L) { if (get_keta(A + B * lb) == k) ed = lb; } } if (st != -1 && ed != -1) { ll n = ed - st + 1; ll kk = 1; rep(i, k) kk *= 10; mat smat{{kk % M, 0, 0}, {1, 1, 0}, {0, B % M, 1}}; mat dmat = pow(smat, n, M); // cout << " " << dmat[0][0] << " " << dmat[0][1] << " " << dmat[0][2] << // endl; cout << " " << dmat[1][0] << " " << dmat[1][1] << " " << // dmat[1][2] << endl; cout << " " << dmat[2][0] << " " << dmat[2][1] << " // " << dmat[2][2] << endl; vec nvec{0, 0, 0}; nvec[0] += (dmat[0][0] * mvec[0]) % M; nvec[0] %= M; nvec[0] += (dmat[1][0] * mvec[1]) % M; nvec[0] %= M; nvec[0] += (dmat[2][0] * mvec[2]) % M; nvec[0] %= M; nvec[1] += (dmat[0][1] * mvec[0]) % M; nvec[1] %= M; nvec[1] += (dmat[1][1] * mvec[1]) % M; nvec[1] %= M; nvec[1] += (dmat[2][1] * mvec[2]) % M; nvec[1] %= M; nvec[2] += (dmat[0][2] * mvec[0]) % M; nvec[2] %= M; nvec[2] += (dmat[1][2] * mvec[1]) % M; nvec[2] %= M; nvec[2] += (dmat[2][2] * mvec[2]) % M; nvec[2] %= M; mvec = nvec; // cout << mvec[0] << endl; } } cout << mvec[0] << endl; return 0; }
[ "assignment.change" ]
831,444
831,450
u624678037
cpp
p03016
#include <algorithm> #include <bitset> #include <cassert> #include <ciso646> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <deque> #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 int inf = 1e9 + 7; const ll INF = 1LL << 60; const ll mod = 1e9 + 7; #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; #define fr first #define sc second #define all(c) c.begin(), c.end() #define pb push_back #define debug(x) cout << #x << " = " << (x) << endl; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } //#define int long long typedef vector<ll> vec; typedef vector<vec> mat; ll m; mat mul(mat &A, mat &B) { mat C(A.size(), vec(B[0].size(), 0)); for (int i = 0; i < A.size(); ++i) { for (int j = 0; j < B[0].size(); ++j) { for (int k = 0; k < B.size(); ++k) { C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % m; } } } return C; } mat pow(mat A, ll n) { mat B(A.size(), vec(A.size(), 0)); for (int i = 0; i < A.size(); ++i) { B[i][i] = 1LL; } while (n > 0) { if (n & 1) B = mul(B, A); A = mul(A, A); n >>= 1; } return B; } void solve() { ll l, a, b; cin >> l >> a >> b >> m; ll x0 = 0, s0 = a % m, k0 = 1; for (int d = 1; d <= 18; ++d) { mat A(3, vec(3)); A[0][0] = (ll)pow(10, d) % m; A[0][1] = 1; A[0][2] = 0; A[1][0] = 0; A[1][1] = 1; A[1][2] = b % m; A[2][0] = 0; A[2][1] = 0; A[2][2] = 1; if (a > (ll)pow(10, d)) continue; ll cnt = ((ll)pow(10, d) - 1 - a) / b - ((ll)pow(10, d - 1) - 1 - a) / b; if (a < (ll)pow(10, d)) cnt = 1 + ((ll)pow(10, d) - 1 - a) / b; if (l >= cnt) { l -= cnt; } else { cnt = l; l = 0; } // debug(cnt); // debug(l); A = pow(A, cnt); ll x = (A[0][0] * x0 % m + A[0][1] * s0 % m + A[0][2] * k0 % m) % m; ll s = (A[1][0] * x0 % m + A[1][1] * s0 % m + A[1][2] * k0 % m) % m; ll k = (A[2][0] * x0 % m + A[2][1] * s0 % m + A[2][2] * k0 % m) % m; x0 = x; s0 = s; k0 = k; } cout << x0 << 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 <deque> #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 int inf = 1e9 + 7; const ll INF = 1LL << 60; const ll mod = 1e9 + 7; #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; #define fr first #define sc second #define all(c) c.begin(), c.end() #define pb push_back #define debug(x) cout << #x << " = " << (x) << endl; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } //#define int long long typedef vector<ll> vec; typedef vector<vec> mat; ll m; mat mul(mat &A, mat &B) { mat C(A.size(), vec(B[0].size(), 0)); for (int i = 0; i < A.size(); ++i) { for (int j = 0; j < B[0].size(); ++j) { for (int k = 0; k < B.size(); ++k) { C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % m; } } } return C; } mat pow(mat A, ll n) { mat B(A.size(), vec(A.size(), 0)); for (int i = 0; i < A.size(); ++i) { B[i][i] = 1LL; } while (n > 0) { if (n & 1) B = mul(B, A); A = mul(A, A); n >>= 1; } return B; } void solve() { ll l, a, b; cin >> l >> a >> b >> m; ll x0 = 0, s0 = a % m, k0 = 1; for (int d = 1; d <= 18; ++d) { mat A(3, vec(3)); A[0][0] = (ll)pow(10, d) % m; A[0][1] = 1; A[0][2] = 0; A[1][0] = 0; A[1][1] = 1; A[1][2] = b % m; A[2][0] = 0; A[2][1] = 0; A[2][2] = 1; if (a > (ll)pow(10, d)) continue; ll cnt = ((ll)pow(10, d) - 1 - a) / b - ((ll)pow(10, d - 1) - 1 - a) / b; if (a > (ll)pow(10, d - 1)) cnt = 1 + ((ll)pow(10, d) - 1 - a) / b; if (l >= cnt) { l -= cnt; } else { cnt = l; l = 0; } // debug(cnt); // debug(l); A = pow(A, cnt); ll x = (A[0][0] * x0 % m + A[0][1] * s0 % m + A[0][2] * k0 % m) % m; ll s = (A[1][0] * x0 % m + A[1][1] * s0 % m + A[1][2] * k0 % m) % m; ll k = (A[2][0] * x0 % m + A[2][1] * s0 % m + A[2][2] * k0 % m) % m; x0 = x; s0 = s; k0 = k; } cout << x0 << endl; } signed main() { ios::sync_with_stdio(false); cin.tie(0); // cout << fixed << setprecision(10); // init(); solve(); // cout << "finish" << endl; return 0; }
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "misc.off_by_one" ]
831,464
831,468
u508571192
cpp
p03016
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define rep(i, a, b) for (int i = int(a); i < int(b); ++i) #define All(x) (x).begin(), (x).end() using namespace std; typedef long long ll; ll mod; class mint { private: ll _num, _mod; mint set(ll num) { _num = num; if (_num >= 0) _num %= _mod; else _num += (1 - (_num + 1) / _mod) * _mod; return *this; } ll _mpow(ll x, ll n) { // x^n(mod) ←普通にpow(x,n)では溢れてしまうため,随時mod計算 // 2分累乗法だから早い ll ans = 1; while (n != 0) { if (n & 1) ans = ans * x % _mod; x = x * x % _mod; n = n >> 1; } return ans; } ll imod(ll n) { return _mpow(n, _mod - 2); } public: mint() { _num = 0; _mod = mod; } mint(ll num) { _mod = mod; _num = (num + (1LL << 25) * mod) % mod; } mint(ll num, ll M) { _mod = M; _num = (num + (1LL << 25) * mod) % _mod; } mint(const mint &cp) { _num = cp._num; _mod = cp._mod; } mint operator=(const ll x) { return set(x); } mint operator+(const ll x) { return mint(_num + (x % _mod), _mod); } mint operator-(const ll x) { return mint(_num - (x % _mod), _mod); } mint operator*(const ll x) { return mint(_num * (x % _mod), _mod); } mint operator/(ll x) { return mint(_num * imod(x), _mod); } mint operator+=(const ll x) { return set(_num + (x % _mod)); } mint operator-=(const ll x) { return set(_num - (x % _mod)); } mint operator*=(const ll x) { return set(_num * (x % _mod)); } mint operator/=(ll x) { return set(_num * imod(x)); } mint operator+(const mint &x) { return mint(_num + x._num, _mod); } mint operator-(const mint &x) { return mint(_num - x._num, _mod); } mint operator*(const mint &x) { return mint(_num * x._num, _mod); } mint operator/(mint x) { return mint(_num * imod(x._num), _mod); } mint operator+=(const mint &x) { return set(_num + x._num); } mint operator-=(const mint &x) { return set(_num - x._num); } mint operator*=(const mint &x) { return set(_num * x._num); } mint operator/=(mint x) { return set(_num * imod(x._num)); } bool operator<(const mint &x) const { return _num < x._num; } bool operator==(const mint &x) const { return _num == x._num; } bool operator>(const mint &x) const { return _num > x._num; } friend mint operator+(ll x, const mint &m) { return mint(m._num + (x % m._mod), m._mod); } friend mint operator-(ll x, const mint &m) { return mint((x % m._mod) - m._num, m._mod); } friend mint operator*(ll x, const mint &m) { return mint(m._num * (x % m._mod), m._mod); } friend mint operator/(ll x, mint m) { return mint(m.imod(m._num) * x, m._mod); } explicit operator ll() { return _num; } explicit operator int() { return (int)_num; } friend ostream &operator<<(ostream &os, const mint &x) { os << x._num; return os; } friend istream &operator>>(istream &is, mint &x) { ll val; is >> val; x.set(val); return is; } }; template <typename T> class MAT { private: int row, col; vector<vector<T>> _A; MAT set(vector<vector<T>> A) { _A = A; return *this; } public: MAT() {} MAT(int n, int m) { if (n < 1 || m < 0) { cout << "err Matrix::Matrix" << endl; exit(1); } row = n; col = m ? m : n; // m=0のとき単位行列を作る REP(i, row) { vector<T> a(col, 0.0); _A.push_back(a); } // 値の初期化 if (m == 0) REP(i, n) _A[i][i] = 1.0; } MAT(const MAT &cp) { _A = cp._A; row = cp.row; col = cp.col; } T *operator[](int i) { return _A[i].data(); } MAT operator=(vector<vector<T>> x) { return set(x); } MAT operator+(MAT x) { if (row != x.row || col != x.col) { cout << "err Matrix::operator+" << endl; cout << " not equal matrix size" << endl; exit(0); } MAT r(row, col); REP(i, row) REP(j, col) r[i][j] = _A[i][j] + x[i][j]; return r; } MAT operator-(MAT x) { if (row != x.row || col != x.col) { cout << "err Matrix::operator-" << endl; cout << " not equal matrix size" << endl; exit(0); } MAT r(row, col); REP(i, row) REP(j, col) r[i][j] = _A[i][j] - x[i][j]; return r; } MAT operator*(MAT x) { if (col != x.row) { cout << "err Matrix::operator*" << endl; cout << " not equal matrix size" << endl; exit(0); } MAT r(row, x.col); REP(i, row) REP(j, x.col) REP(k, col) r[i][j] += _A[i][k] * x[k][j]; return r; } MAT operator/(T a) { MAT r(row, col); REP(i, row) REP(j, col) r[i][j] = _A[i][j] / a; return r; } MAT operator^(ll n) { if (row != col) { cout << "err Matrix::operator^" << endl; cout << " not equal matrix size" << endl; exit(0); } MAT r(row, 0), A = *this; while (n) { if (n & 1) r *= A; A *= A; n >>= 1; } return r; } MAT operator+=(MAT x) { if (row != x.row || col != x.col) { cout << "err Matrix::operator+=" << endl; cout << " not equal matrix size" << endl; exit(0); } MAT r(row, col); REP(i, row) REP(j, col) r[i][j] = _A[i][j] + x[i][j]; return set(r._A); } MAT operator-=(MAT x) { if (row != x.row || col != x.col) { cout << "err Matrix::operator-=" << endl; cout << " not equal matrix size" << endl; exit(0); } MAT r(row, col); REP(i, row) REP(j, col) r[i][j] = _A[i][j] - x[i][j]; return set(r._A); } MAT operator*=(MAT x) { if (col != x.row) { cout << "err Matrix::operator*" << endl; cout << " not equal matrix size" << endl; exit(0); } MAT r(row, x.col); REP(i, row) REP(j, x.col) REP(k, col) r[i][j] += _A[i][k] * x[k][j]; return set(r._A); } MAT operator/=(T a) { MAT r(row, col); REP(i, row) REP(j, col) r[i][j] = _A[i][j] / a; return r; } friend MAT operator*(T n, MAT x) { MAT r(x.row, x.col); REP(i, x.row) REP(j, x.col) r[i][j] = n * x[i][j]; return r; } friend MAT operator*(MAT x, T n) { MAT r(x.row, x.col); REP(i, x.row) REP(j, x.col) r[i][j] = n * x[i][j]; return r; } explicit operator vector<vector<T>>() { return _A; } friend ostream &operator<<(ostream &os, const MAT &x) { REP(i, x.row) REP(j, x.col) os << x._A[i][j] << " \n"[j == x.col - 1]; return os; } friend istream &operator>>(istream &is, MAT &x) { REP(i, x.row) REP(j, x.col) is >> x._A[i][j]; return is; } int size_row() { return row; } int size_col() { return col; } MAT transpose() { MAT r(col, row); REP(i, col) REP(j, row) r[i][j] = _A[j][i]; return r; } MAT inverse() { T buf; MAT<T> inv_a(row, 0); vector<vector<T>> a = _A; //掃き出し法 REP(i, row) { buf = 1 / a[i][i]; REP(j, row) { a[i][j] *= buf; inv_a[i][j] *= buf; } REP(j, row) { if (i != j) { buf = a[j][i]; REP(k, row) { a[j][k] -= a[i][k] * buf; inv_a[j][k] -= inv_a[i][k] * buf; } } } } return inv_a; } }; int main() { ll L, A, B; cin >> L >> A >> B >> mod; MAT<mint> C(3, 0); ll a = 1; rep(d, 1, 19) { ll r = min((a * 10 - 1 - A) / B, L - 1) + 1; ll l = min((a - 1 - A) / B, L - 1) + 1; if (a - 1 - A < 0) l--; if (a * 10 - a - A < 0) r--; l = max(0LL, l); r = max(0LL, r); ll Cd = r - l; MAT<mint> A(3, 3); A[0][0] = a * 10; A[1][0] = A[1][1] = A[2][2] = 1; A[2][1] = B; C *= A ^ Cd; // cout<<Cd<<endl; a *= 10; } MAT<mint> ans(1, 3); ans[0][1] = A; ans[0][2] = 1; ans = ans * C; cout << ans[0][0] << endl; }
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define rep(i, a, b) for (int i = int(a); i < int(b); ++i) #define All(x) (x).begin(), (x).end() using namespace std; typedef long long ll; ll mod; class mint { private: ll _num, _mod; mint set(ll num) { _num = num; if (_num >= 0) _num %= _mod; else _num += (1 - (_num + 1) / _mod) * _mod; return *this; } ll _mpow(ll x, ll n) { // x^n(mod) ←普通にpow(x,n)では溢れてしまうため,随時mod計算 // 2分累乗法だから早い ll ans = 1; while (n != 0) { if (n & 1) ans = ans * x % _mod; x = x * x % _mod; n = n >> 1; } return ans; } ll imod(ll n) { return _mpow(n, _mod - 2); } public: mint() { _num = 0; _mod = mod; } mint(ll num) { _mod = mod; _num = (num + (1LL << 25) * mod) % mod; } mint(ll num, ll M) { _mod = M; _num = (num + (1LL << 25) * mod) % _mod; } mint(const mint &cp) { _num = cp._num; _mod = cp._mod; } mint operator=(const ll x) { return set(x); } mint operator+(const ll x) { return mint(_num + (x % _mod), _mod); } mint operator-(const ll x) { return mint(_num - (x % _mod), _mod); } mint operator*(const ll x) { return mint(_num * (x % _mod), _mod); } mint operator/(ll x) { return mint(_num * imod(x), _mod); } mint operator+=(const ll x) { return set(_num + (x % _mod)); } mint operator-=(const ll x) { return set(_num - (x % _mod)); } mint operator*=(const ll x) { return set(_num * (x % _mod)); } mint operator/=(ll x) { return set(_num * imod(x)); } mint operator+(const mint &x) { return mint(_num + x._num, _mod); } mint operator-(const mint &x) { return mint(_num - x._num, _mod); } mint operator*(const mint &x) { return mint(_num * x._num, _mod); } mint operator/(mint x) { return mint(_num * imod(x._num), _mod); } mint operator+=(const mint &x) { return set(_num + x._num); } mint operator-=(const mint &x) { return set(_num - x._num); } mint operator*=(const mint &x) { return set(_num * x._num); } mint operator/=(mint x) { return set(_num * imod(x._num)); } bool operator<(const mint &x) const { return _num < x._num; } bool operator==(const mint &x) const { return _num == x._num; } bool operator>(const mint &x) const { return _num > x._num; } friend mint operator+(ll x, const mint &m) { return mint(m._num + (x % m._mod), m._mod); } friend mint operator-(ll x, const mint &m) { return mint((x % m._mod) - m._num, m._mod); } friend mint operator*(ll x, const mint &m) { return mint(m._num * (x % m._mod), m._mod); } friend mint operator/(ll x, mint m) { return mint(m.imod(m._num) * x, m._mod); } explicit operator ll() { return _num; } explicit operator int() { return (int)_num; } friend ostream &operator<<(ostream &os, const mint &x) { os << x._num; return os; } friend istream &operator>>(istream &is, mint &x) { ll val; is >> val; x.set(val); return is; } }; template <typename T> class MAT { private: int row, col; vector<vector<T>> _A; MAT set(vector<vector<T>> A) { _A = A; return *this; } public: MAT() {} MAT(int n, int m) { if (n < 1 || m < 0) { cout << "err Matrix::Matrix" << endl; exit(1); } row = n; col = m ? m : n; // m=0のとき単位行列を作る REP(i, row) { vector<T> a(col, 0.0); _A.push_back(a); } // 値の初期化 if (m == 0) REP(i, n) _A[i][i] = 1.0; } MAT(const MAT &cp) { _A = cp._A; row = cp.row; col = cp.col; } T *operator[](int i) { return _A[i].data(); } MAT operator=(vector<vector<T>> x) { return set(x); } MAT operator+(MAT x) { if (row != x.row || col != x.col) { cout << "err Matrix::operator+" << endl; cout << " not equal matrix size" << endl; exit(0); } MAT r(row, col); REP(i, row) REP(j, col) r[i][j] = _A[i][j] + x[i][j]; return r; } MAT operator-(MAT x) { if (row != x.row || col != x.col) { cout << "err Matrix::operator-" << endl; cout << " not equal matrix size" << endl; exit(0); } MAT r(row, col); REP(i, row) REP(j, col) r[i][j] = _A[i][j] - x[i][j]; return r; } MAT operator*(MAT x) { if (col != x.row) { cout << "err Matrix::operator*" << endl; cout << " not equal matrix size" << endl; exit(0); } MAT r(row, x.col); REP(i, row) REP(j, x.col) REP(k, col) r[i][j] += _A[i][k] * x[k][j]; return r; } MAT operator/(T a) { MAT r(row, col); REP(i, row) REP(j, col) r[i][j] = _A[i][j] / a; return r; } MAT operator^(ll n) { if (row != col) { cout << "err Matrix::operator^" << endl; cout << " not equal matrix size" << endl; exit(0); } MAT r(row, 0), A = *this; while (n) { if (n & 1) r *= A; A *= A; n >>= 1; } return r; } MAT operator+=(MAT x) { if (row != x.row || col != x.col) { cout << "err Matrix::operator+=" << endl; cout << " not equal matrix size" << endl; exit(0); } MAT r(row, col); REP(i, row) REP(j, col) r[i][j] = _A[i][j] + x[i][j]; return set(r._A); } MAT operator-=(MAT x) { if (row != x.row || col != x.col) { cout << "err Matrix::operator-=" << endl; cout << " not equal matrix size" << endl; exit(0); } MAT r(row, col); REP(i, row) REP(j, col) r[i][j] = _A[i][j] - x[i][j]; return set(r._A); } MAT operator*=(MAT x) { if (col != x.row) { cout << "err Matrix::operator*" << endl; cout << " not equal matrix size" << endl; exit(0); } MAT r(row, x.col); REP(i, row) REP(j, x.col) REP(k, col) r[i][j] += _A[i][k] * x[k][j]; return set(r._A); } MAT operator/=(T a) { MAT r(row, col); REP(i, row) REP(j, col) r[i][j] = _A[i][j] / a; return r; } friend MAT operator*(T n, MAT x) { MAT r(x.row, x.col); REP(i, x.row) REP(j, x.col) r[i][j] = n * x[i][j]; return r; } friend MAT operator*(MAT x, T n) { MAT r(x.row, x.col); REP(i, x.row) REP(j, x.col) r[i][j] = n * x[i][j]; return r; } explicit operator vector<vector<T>>() { return _A; } friend ostream &operator<<(ostream &os, const MAT &x) { REP(i, x.row) REP(j, x.col) os << x._A[i][j] << " \n"[j == x.col - 1]; return os; } friend istream &operator>>(istream &is, MAT &x) { REP(i, x.row) REP(j, x.col) is >> x._A[i][j]; return is; } int size_row() { return row; } int size_col() { return col; } MAT transpose() { MAT r(col, row); REP(i, col) REP(j, row) r[i][j] = _A[j][i]; return r; } MAT inverse() { T buf; MAT<T> inv_a(row, 0); vector<vector<T>> a = _A; //掃き出し法 REP(i, row) { buf = 1 / a[i][i]; REP(j, row) { a[i][j] *= buf; inv_a[i][j] *= buf; } REP(j, row) { if (i != j) { buf = a[j][i]; REP(k, row) { a[j][k] -= a[i][k] * buf; inv_a[j][k] -= inv_a[i][k] * buf; } } } } return inv_a; } }; int main() { ll L, A, B; cin >> L >> A >> B >> mod; MAT<mint> C(3, 0); ll a = 1; rep(d, 1, 19) { ll r = min((a * 10 - 1 - A) / B, L - 1) + 1; ll l = min((a - 1 - A) / B, L - 1) + 1; if (a - 1 - A < 0) l--; if (a * 10 - 1 - A < 0) r--; l = max(0LL, l); r = max(0LL, r); ll Cd = r - l; MAT<mint> A(3, 3); A[0][0] = a * 10; A[1][0] = A[1][1] = A[2][2] = 1; A[2][1] = B; C *= A ^ Cd; // cout<<Cd<<endl; a *= 10; } MAT<mint> ans(1, 3); ans[0][1] = A; ans[0][2] = 1; ans = ans * C; cout << ans[0][0] << endl; }
[ "identifier.replace.remove", "literal.replace.add", "control_flow.branch.if.condition.change" ]
831,552
831,562
u203033720
cpp
p03016
#include <algorithm> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdlib.h> #include <string.h> #include <string> #include <utility> #include <vector> using namespace std; #define ll long long #define ld long double #define EPS 1e-9 #define INF 1e9 #define LINF (ll) INF *INF #define MOD 1000000007 #define rep(i, n) for (int i = 0; i < (n); i++) #define loop(i, a, n) for (int i = a; i < (n); i++) #define all(in) in.begin(), in.end() #define shosu(x) fixed << setprecision(x) #define int unsigned ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! typedef vector<int> vi; typedef vector<string> vs; typedef pair<int, int> pii; typedef pair<pii, int> ppi; typedef pair<int, pii> pip; typedef vector<pii> vp; typedef vector<vi> vvi; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int lcm(int a, int b) { return a / gcd(a, b) * b; } void printMatrix(vvi a) { rep(i, a.size()) { rep(j, a[0].size()) cout << a[i][j] << " "; cout << endl; } } vvi product(vvi a, vvi b, int mod) { // ret = a * b % mod vvi ret(a.size(), vi(b[0].size(), 0)); rep(i, a.size()) rep(j, b[0].size()) { rep(k, a[0].size())(ret[i][j] += a[i][k] * b[k][j]) %= mod; } return ret; } vvi powMatrix(vvi a, int t, int mod) { // A^t % mod int n = a.size(); vvi ret(n, vi(n, 0)); rep(i, n) ret[i][i] = 1; // 単位行列 while (t > 0) { //繰り返し自乗法 if (t & 1) ret = product(ret, a, mod); a = product(a, a, mod); t = t >> 1; } return ret; } signed main(void) { int l, a, b, m; cin >> l >> a >> b >> m; int now = 0; //項数 vvi x(3, vi(3, 0)); x[0][1] = x[1][1] = x[2][2] = 1; x[1][2] = b; x[0][0] = 10; vvi y(3, vi(1, 0)); y[1][0] = a; y[2][0] = 1; loop(keta, 1, 19) if (now < l) { if (to_string(a + b * now).size() > keta) { x[0][0] *= 10; continue; } x[0][0] %= m; int ok = 0, ng = l + 1; //桁がketa以下となるような最大の項を探す while (ng - ok > 1) { int mid = (ok + ng) / 2; string s = to_string(a + b * mid); if (s.size() <= keta) ok = mid; else ng = mid; } // cout << "桁" << keta << " ok=" << ok << ",ng=" << ng << endl; if (ok < now) break; if (l <= ok) ok = l - 1; //[now, ok]について計算する y = product(powMatrix(x, ok - now + 1, m), y, m); now = ok + 1; x[0][0] *= 10; // cout << "桁" << keta << " 次の項" << now << " 今の答え" << y[0][0] << // endl; printMatrix(x); printMatrix(y); cout << endl; } cout << y[0][0] << endl; }
#include <algorithm> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdlib.h> #include <string.h> #include <string> #include <utility> #include <vector> using namespace std; #define ll long long #define ld long double #define EPS 1e-9 #define INF 1e9 #define LINF (ll) INF *INF #define MOD 1000000007 #define rep(i, n) for (int i = 0; i < (n); i++) #define loop(i, a, n) for (int i = a; i < (n); i++) #define all(in) in.begin(), in.end() #define shosu(x) fixed << setprecision(x) #define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! typedef vector<int> vi; typedef vector<string> vs; typedef pair<int, int> pii; typedef pair<pii, int> ppi; typedef pair<int, pii> pip; typedef vector<pii> vp; typedef vector<vi> vvi; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int lcm(int a, int b) { return a / gcd(a, b) * b; } void printMatrix(vvi a) { rep(i, a.size()) { rep(j, a[0].size()) cout << a[i][j] << " "; cout << endl; } } vvi product(vvi a, vvi b, int mod) { // ret = a * b % mod vvi ret(a.size(), vi(b[0].size(), 0)); rep(i, a.size()) rep(j, b[0].size()) { rep(k, a[0].size())(ret[i][j] += a[i][k] * b[k][j]) %= mod; } return ret; } vvi powMatrix(vvi a, int t, int mod) { // A^t % mod int n = a.size(); vvi ret(n, vi(n, 0)); rep(i, n) ret[i][i] = 1; // 単位行列 while (t > 0) { //繰り返し自乗法 if (t & 1) ret = product(ret, a, mod); a = product(a, a, mod); t = t >> 1; } return ret; } signed main(void) { int l, a, b, m; cin >> l >> a >> b >> m; int now = 0; //項数 vvi x(3, vi(3, 0)); x[0][1] = x[1][1] = x[2][2] = 1; x[1][2] = b % m; x[0][0] = 10; vvi y(3, vi(1, 0)); y[1][0] = a % m; y[2][0] = 1; loop(keta, 1, 19) if (now < l) { if (to_string(a + b * now).size() > keta) { x[0][0] *= 10; continue; } x[0][0] %= m; int ok = 0, ng = l + 1; //桁がketa以下となるような最大の項を探す while (ng - ok > 1) { int mid = (ok + ng) / 2; string s = to_string(a + b * mid); if (s.size() <= keta) ok = mid; else ng = mid; } // cout << "桁" << keta << " ok=" << ok << ",ng=" << ng << endl; if (ok < now) break; if (l <= ok) ok = l - 1; //[now, ok]について計算する y = product(powMatrix(x, ok - now + 1, m), y, m); now = ok + 1; x[0][0] *= 10; // cout << "桁" << keta << " 次の項" << now << " 今の答え" << y[0][0] << // endl; printMatrix(x); printMatrix(y); cout << endl; } cout << y[0][0] << endl; }
[ "assignment.change" ]
831,569
831,571
u471289663
cpp
p03016
#include <algorithm> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdlib.h> #include <string.h> #include <string> #include <utility> #include <vector> using namespace std; #define ll long long #define ld long double #define EPS 1e-9 #define INF 1e9 #define LINF (ll) INF *INF #define MOD 1000000007 #define rep(i, n) for (int i = 0; i < (n); i++) #define loop(i, a, n) for (int i = a; i < (n); i++) #define all(in) in.begin(), in.end() #define shosu(x) fixed << setprecision(x) #define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! typedef vector<int> vi; typedef vector<string> vs; typedef pair<int, int> pii; typedef pair<pii, int> ppi; typedef pair<int, pii> pip; typedef vector<pii> vp; typedef vector<vi> vvi; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int lcm(int a, int b) { return a / gcd(a, b) * b; } void printMatrix(vvi a) { rep(i, a.size()) { rep(j, a[0].size()) cout << a[i][j] << " "; cout << endl; } } vvi product(vvi a, vvi b, int mod) { // ret = a * b % mod vvi ret(a.size(), vi(b[0].size(), 0)); rep(i, a.size()) rep(j, b[0].size()) { rep(k, a[0].size())(ret[i][j] += a[i][k] * b[k][j]) %= mod; } return ret; } vvi powMatrix(vvi a, int t, int mod) { // A^t % mod int n = a.size(); vvi ret(n, vi(n, 0)); rep(i, n) ret[i][i] = 1; // 単位行列 while (t > 0) { //繰り返し自乗法 if (t & 1) ret = product(ret, a, mod); a = product(a, a, mod); t = t >> 1; } return ret; } signed main(void) { int l, a, b, m; cin >> l >> a >> b >> m; int now = 0; //項数 vvi x(3, vi(3, 0)); x[0][1] = x[1][1] = x[2][2] = 1; x[1][2] = b; x[0][0] = 10; vvi y(3, vi(1, 0)); y[1][0] = a; y[2][0] = 1; loop(keta, 1, 19) if (now < l) { if (to_string(a + b * now).size() > keta) { x[0][0] *= 10; continue; } x[0][0] %= m; int ok = 0, ng = l + 1; //桁がketa以下となるような最大の項を探す while (ng - ok > 1) { int mid = (ok + ng) / 2; string s = to_string(a + b * mid); if (s.size() <= keta) ok = mid; else ng = mid; } // cout << "桁" << keta << " ok=" << ok << ",ng=" << ng << endl; if (ok < now) break; if (l <= ok) ok = l - 1; //[now, ok]について計算する y = product(powMatrix(x, ok - now + 1, m), y, m); now = ok + 1; x[0][0] *= 10; // cout << "桁" << keta << " 次の項" << now << " 今の答え" << y[0][0] << // endl; printMatrix(x); printMatrix(y); cout << endl; } cout << y[0][0] << endl; }
#include <algorithm> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdlib.h> #include <string.h> #include <string> #include <utility> #include <vector> using namespace std; #define ll long long #define ld long double #define EPS 1e-9 #define INF 1e9 #define LINF (ll) INF *INF #define MOD 1000000007 #define rep(i, n) for (int i = 0; i < (n); i++) #define loop(i, a, n) for (int i = a; i < (n); i++) #define all(in) in.begin(), in.end() #define shosu(x) fixed << setprecision(x) #define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! typedef vector<int> vi; typedef vector<string> vs; typedef pair<int, int> pii; typedef pair<pii, int> ppi; typedef pair<int, pii> pip; typedef vector<pii> vp; typedef vector<vi> vvi; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int lcm(int a, int b) { return a / gcd(a, b) * b; } void printMatrix(vvi a) { rep(i, a.size()) { rep(j, a[0].size()) cout << a[i][j] << " "; cout << endl; } } vvi product(vvi a, vvi b, int mod) { // ret = a * b % mod vvi ret(a.size(), vi(b[0].size(), 0)); rep(i, a.size()) rep(j, b[0].size()) { rep(k, a[0].size())(ret[i][j] += a[i][k] * b[k][j]) %= mod; } return ret; } vvi powMatrix(vvi a, int t, int mod) { // A^t % mod int n = a.size(); vvi ret(n, vi(n, 0)); rep(i, n) ret[i][i] = 1; // 単位行列 while (t > 0) { //繰り返し自乗法 if (t & 1) ret = product(ret, a, mod); a = product(a, a, mod); t = t >> 1; } return ret; } signed main(void) { int l, a, b, m; cin >> l >> a >> b >> m; int now = 0; //項数 vvi x(3, vi(3, 0)); x[0][1] = x[1][1] = x[2][2] = 1; x[1][2] = b % m; x[0][0] = 10; vvi y(3, vi(1, 0)); y[1][0] = a % m; y[2][0] = 1; loop(keta, 1, 19) if (now < l) { if (to_string(a + b * now).size() > keta) { x[0][0] *= 10; continue; } x[0][0] %= m; int ok = 0, ng = l + 1; //桁がketa以下となるような最大の項を探す while (ng - ok > 1) { int mid = (ok + ng) / 2; string s = to_string(a + b * mid); if (s.size() <= keta) ok = mid; else ng = mid; } // cout << "桁" << keta << " ok=" << ok << ",ng=" << ng << endl; if (ok < now) break; if (l <= ok) ok = l - 1; //[now, ok]について計算する y = product(powMatrix(x, ok - now + 1, m), y, m); now = ok + 1; x[0][0] *= 10; // cout << "桁" << keta << " 次の項" << now << " 今の答え" << y[0][0] << // endl; printMatrix(x); printMatrix(y); cout << endl; } cout << y[0][0] << endl; }
[ "assignment.change" ]
831,572
831,571
u471289663
cpp
p03017
#include <bits/stdc++.h> // using namespace std; #define DUMP(x) std::cout << (#x) << " = " << (x) << "\n" void Main() { int n, a, b, c, d; std::cin >> n >> a >> b >> c >> d; std::string s; s.reserve(n); std::cin >> s; for (int i = b; i < d - 1; ++i) { if (s[i] == '#' && s[i + 1] == '#') { std::cout << "No\n"; return; } } for (int i = a; i < c - 1; ++i) { if (s[i] == '#' && s[i + 1] == '#') { std::cout << "No\n"; return; } } if (c > d) { for (int i = b - 2; i < d - 2; ++i) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { std::cout << "Yes\n"; return; } } } else { std::cout << "Yes\n"; return; } std::cout << "No\n"; return; } int main() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(15); Main(); return 0; }
#include <bits/stdc++.h> // using namespace std; #define DUMP(x) std::cout << (#x) << " = " << (x) << "\n" void Main() { int n, a, b, c, d; std::cin >> n >> a >> b >> c >> d; std::string s; s.reserve(n); std::cin >> s; for (int i = b; i < d - 1; ++i) { if (s[i] == '#' && s[i + 1] == '#') { std::cout << "No\n"; return; } } for (int i = a; i < c - 1; ++i) { if (s[i] == '#' && s[i + 1] == '#') { std::cout << "No\n"; return; } } if (c > d) { for (int i = b - 2; i < d - 1; ++i) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { std::cout << "Yes\n"; return; } } } else { std::cout << "Yes\n"; return; } std::cout << "No\n"; return; } int main() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(15); Main(); return 0; }
[ "literal.number.change", "control_flow.branch.if.condition.change" ]
831,011
831,013
u664394831
cpp
p03017
#include <iostream> #include <string> using namespace std; bool reachable(string s, int start, int end) { bool res = true; for (int i = start - 1; i < end - 1; i++) { if (s[i] == '#' & s[i + 1] == '#') { res = false; break; } } return res; } int main() { int n, a, b, c, d; string s; cin >> n >> a >> b >> c >> d; cin >> s; bool TF = true; if (reachable(s, a, c) & reachable(s, b, d)) TF = true; else TF = false; if (c > d) { bool sunuke_can_go_over_hunuke = false; for (int i = b - 2; i < d; i++) { if (((s[i] == '.') & (s[i + 1] == '.')) & (s[i + 2] == '.')) { sunuke_can_go_over_hunuke = true; } } TF = (TF & sunuke_can_go_over_hunuke); } if (TF) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
#include <iostream> #include <string> using namespace std; bool reachable(string s, int start, int end) { bool res = true; for (int i = start - 1; i < end - 1; i++) { if (s[i] == '#' & s[i + 1] == '#') { res = false; break; } } return res; } int main() { int n, a, b, c, d; string s; cin >> n >> a >> b >> c >> d; cin >> s; bool TF = true; if (reachable(s, a, c) & reachable(s, b, d)) TF = true; else TF = false; if (c > d) { bool sunuke_can_go_over_hunuke = false; for (int i = b - 2; i < d - 1; i++) { if (((s[i] == '.') & (s[i + 1] == '.')) & (s[i + 2] == '.')) { sunuke_can_go_over_hunuke = true; } } TF = (TF & sunuke_can_go_over_hunuke); } if (TF) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "misc.off_by_one" ]
831,014
831,016
u717463970
cpp
p03017
#include <algorithm> #include <cmath> #include <cstdlib> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <string> #include <vector> using namespace std; typedef long long ll; typedef std::pair<int, int> ipair; bool lessPair(const ipair &l, const ipair &r) { return l.second < r.second; } bool morePair(const ipair &l, const ipair &r) { return l.second > r.second; } 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; } const ll MOD = 1e9 + 7; // const long long INF = 1LL<<60; void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; } void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; } void mul(long long &a, long long b) { a *= b; a %= MOD; } ll llmin(ll a, ll b) { if (a < b) return a; else return b; } ll llmax(ll a, ll b) { if (a < b) return b; else return a; } ll llabs(ll a) { if (a >= 0) return a; else return -a; } ll llmodpow(ll a, ll n) { if (n == 0) return 1; ll tmp = llmodpow(a, n / 2); mul(tmp, tmp); if (n & 1) mul(tmp, a); return tmp; } int main() { int N, A, B, C, D; cin >> N >> A >> B >> C >> D; string S; cin >> S; A--; B--; C--; D--; for (int i = 0; i < N; i++) { if (A > i || i > max(C, D)) continue; if (S[i] == '#') { if (i + 1 <= max(C, D) && S[i + 1] == '#') { cout << "No" << endl; return 0; } } } if (C < D) { cout << "Yes" << endl; return 0; } for (int i = 0; i < N; i++) { if (A > i || i > D) continue; if (S[i] == '.' && B <= i && i + 2 <= D + 1 && S[i + 1] == '.' && S[i + 2] == '.') { cout << "Yes" << endl; return 0; } } cout << "No" << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstdlib> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <string> #include <vector> using namespace std; typedef long long ll; typedef std::pair<int, int> ipair; bool lessPair(const ipair &l, const ipair &r) { return l.second < r.second; } bool morePair(const ipair &l, const ipair &r) { return l.second > r.second; } 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; } const ll MOD = 1e9 + 7; // const long long INF = 1LL<<60; void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; } void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; } void mul(long long &a, long long b) { a *= b; a %= MOD; } ll llmin(ll a, ll b) { if (a < b) return a; else return b; } ll llmax(ll a, ll b) { if (a < b) return b; else return a; } ll llabs(ll a) { if (a >= 0) return a; else return -a; } ll llmodpow(ll a, ll n) { if (n == 0) return 1; ll tmp = llmodpow(a, n / 2); mul(tmp, tmp); if (n & 1) mul(tmp, a); return tmp; } int main() { int N, A, B, C, D; cin >> N >> A >> B >> C >> D; string S; cin >> S; A--; B--; C--; D--; for (int i = 0; i < N; i++) { if (A > i || i > max(C, D)) continue; if (S[i] == '#') { if (i + 1 <= max(C, D) && S[i + 1] == '#') { cout << "No" << endl; return 0; } } } if (C < D) { cout << "Yes" << endl; return 0; } for (int i = 0; i < N; i++) { if (A > i || i > D) continue; if (S[i] == '.' && B - 1 <= i && i + 2 <= D + 1 && S[i + 1] == '.' && S[i + 2] == '.') { cout << "Yes" << endl; return 0; } } cout << "No" << endl; return 0; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "misc.off_by_one" ]
831,066
831,068
u775224245
cpp
p03017
#include <algorithm> #include <cmath> #include <cstdlib> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <string> #include <vector> using namespace std; typedef long long ll; typedef std::pair<int, int> ipair; bool lessPair(const ipair &l, const ipair &r) { return l.second < r.second; } bool morePair(const ipair &l, const ipair &r) { return l.second > r.second; } 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; } const ll MOD = 1e9 + 7; // const long long INF = 1LL<<60; void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; } void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; } void mul(long long &a, long long b) { a *= b; a %= MOD; } ll llmin(ll a, ll b) { if (a < b) return a; else return b; } ll llmax(ll a, ll b) { if (a < b) return b; else return a; } ll llabs(ll a) { if (a >= 0) return a; else return -a; } ll llmodpow(ll a, ll n) { if (n == 0) return 1; ll tmp = llmodpow(a, n / 2); mul(tmp, tmp); if (n & 1) mul(tmp, a); return tmp; } int main() { int N, A, B, C, D; cin >> N >> A >> B >> C >> D; string S; cin >> S; A--; B--; C--; D--; for (int i = 0; i < N; i++) { if (A > i || i > max(C, D)) continue; if (S[i] == '#') { if (i + 1 <= max(C, D) && S[i + 1] == '#') { cout << "No" << endl; return 0; } } } if (C < D) { cout << "Yes" << endl; return 0; } for (int i = 0; i < N; i++) { if (A > i || i > D) continue; if (S[i] == '.' && B <= i && i + 2 <= D && S[i + 1] == '.' && S[i + 2] == '.') { cout << "Yes" << endl; return 0; } } cout << "No" << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstdlib> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <string> #include <vector> using namespace std; typedef long long ll; typedef std::pair<int, int> ipair; bool lessPair(const ipair &l, const ipair &r) { return l.second < r.second; } bool morePair(const ipair &l, const ipair &r) { return l.second > r.second; } 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; } const ll MOD = 1e9 + 7; // const long long INF = 1LL<<60; void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; } void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; } void mul(long long &a, long long b) { a *= b; a %= MOD; } ll llmin(ll a, ll b) { if (a < b) return a; else return b; } ll llmax(ll a, ll b) { if (a < b) return b; else return a; } ll llabs(ll a) { if (a >= 0) return a; else return -a; } ll llmodpow(ll a, ll n) { if (n == 0) return 1; ll tmp = llmodpow(a, n / 2); mul(tmp, tmp); if (n & 1) mul(tmp, a); return tmp; } int main() { int N, A, B, C, D; cin >> N >> A >> B >> C >> D; string S; cin >> S; A--; B--; C--; D--; for (int i = 0; i < N; i++) { if (A > i || i > max(C, D)) continue; if (S[i] == '#') { if (i + 1 <= max(C, D) && S[i + 1] == '#') { cout << "No" << endl; return 0; } } } if (C < D) { cout << "Yes" << endl; return 0; } for (int i = 0; i < N; i++) { if (A > i || i > D) continue; if (S[i] == '.' && B - 1 <= i && i + 2 <= D + 1 && S[i + 1] == '.' && S[i + 2] == '.') { cout << "Yes" << endl; return 0; } } cout << "No" << endl; return 0; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "misc.off_by_one" ]
831,070
831,068
u775224245
cpp
p03017
#include <algorithm> #include <cmath> #include <cstdlib> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <string> #include <vector> using namespace std; typedef long long ll; typedef std::pair<int, int> ipair; bool lessPair(const ipair &l, const ipair &r) { return l.second < r.second; } bool morePair(const ipair &l, const ipair &r) { return l.second > r.second; } 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; } const ll MOD = 1e9 + 7; // const long long INF = 1LL<<60; void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; } void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; } void mul(long long &a, long long b) { a *= b; a %= MOD; } ll llmin(ll a, ll b) { if (a < b) return a; else return b; } ll llmax(ll a, ll b) { if (a < b) return b; else return a; } ll llabs(ll a) { if (a >= 0) return a; else return -a; } ll llmodpow(ll a, ll n) { if (n == 0) return 1; ll tmp = llmodpow(a, n / 2); mul(tmp, tmp); if (n & 1) mul(tmp, a); return tmp; } int main() { int N, A, B, C, D; cin >> N >> A >> B >> C >> D; string S; cin >> S; A--; B--; C--; D--; for (int i = 0; i < N; i++) { if (A > i || i > max(C, D)) continue; if (S[i] == '#') { if (i + 1 <= max(C, D) && S[i + 1] == '#') { cout << "No" << endl; return 0; } } } if (C < D) { cout << "Yes" << endl; return 0; } for (int i = 0; i < N; i++) { if (A > i || i > C) continue; if (S[i] == '.' && B <= i && i + 2 <= D && S[i + 1] == '.' && S[i + 2] == '.') { cout << "Yes" << endl; return 0; } } cout << "No" << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstdlib> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <string> #include <vector> using namespace std; typedef long long ll; typedef std::pair<int, int> ipair; bool lessPair(const ipair &l, const ipair &r) { return l.second < r.second; } bool morePair(const ipair &l, const ipair &r) { return l.second > r.second; } 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; } const ll MOD = 1e9 + 7; // const long long INF = 1LL<<60; void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; } void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; } void mul(long long &a, long long b) { a *= b; a %= MOD; } ll llmin(ll a, ll b) { if (a < b) return a; else return b; } ll llmax(ll a, ll b) { if (a < b) return b; else return a; } ll llabs(ll a) { if (a >= 0) return a; else return -a; } ll llmodpow(ll a, ll n) { if (n == 0) return 1; ll tmp = llmodpow(a, n / 2); mul(tmp, tmp); if (n & 1) mul(tmp, a); return tmp; } int main() { int N, A, B, C, D; cin >> N >> A >> B >> C >> D; string S; cin >> S; A--; B--; C--; D--; for (int i = 0; i < N; i++) { if (A > i || i > max(C, D)) continue; if (S[i] == '#') { if (i + 1 <= max(C, D) && S[i + 1] == '#') { cout << "No" << endl; return 0; } } } if (C < D) { cout << "Yes" << endl; return 0; } for (int i = 0; i < N; i++) { if (A > i || i > D) continue; if (S[i] == '.' && B - 1 <= i && i + 2 <= D + 1 && S[i + 1] == '.' && S[i + 2] == '.') { cout << "Yes" << endl; return 0; } } cout << "No" << endl; return 0; }
[ "identifier.change", "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "misc.off_by_one" ]
831,072
831,068
u775224245
cpp
p03017
#include "bits/stdc++.h" using namespace std; // typedef //------------------------------------------ typedef long long LL; typedef unsigned long long ULL; typedef vector<LL> VLL; typedef vector<VLL> VVLL; typedef vector<string> VS; typedef pair<LL, LL> PLL; // container util //------------------------------------------ #define ALL(a) (a).begin(), (a).end() #define PB push_back #define MP make_pair #define SORT(c) sort((c).begin(), (c).end()) #define COUT(x) cout << x << endl // repetition //------------------------------------------ #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) // constant //-------------------------------------------- const double PI = acos(-1.0); const LL MOD = 1e9 + 7; const ULL INF = 1e20; // function //-------------------------------------------- LL gcd(LL, LL); bool isEven(LL); void coutY(); void coutN(); int main() { LL n; cin >> n; LL a, b, c, d; cin >> a >> b >> c >> d; string s; cin >> s; FOR(i, a - 1, max(c, d)) { if (s[i - 1] == '#' && s[i] == '#') { coutN(); return 0; } } if (c > d) { FOR(i, b - 1, d - 1) { string tmp = s.substr(i - 1, 3); if (tmp == "...") { coutY(); return 0; } } coutN(); return 0; } coutY(); return 0; } LL gcd(LL a, LL b) { if (a == 0 || b == 0) return 0; if (a < b) swap(a, b); if (a % b == 0) return b; else gcd(b, a % b); } bool isEven(LL a) { return !((bool)(a % 2)); } void coutY() { cout << "Yes" << endl; return; } void coutN() { cout << "No" << endl; return; }
#include "bits/stdc++.h" using namespace std; // typedef //------------------------------------------ typedef long long LL; typedef unsigned long long ULL; typedef vector<LL> VLL; typedef vector<VLL> VVLL; typedef vector<string> VS; typedef pair<LL, LL> PLL; // container util //------------------------------------------ #define ALL(a) (a).begin(), (a).end() #define PB push_back #define MP make_pair #define SORT(c) sort((c).begin(), (c).end()) #define COUT(x) cout << x << endl // repetition //------------------------------------------ #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) // constant //-------------------------------------------- const double PI = acos(-1.0); const LL MOD = 1e9 + 7; const ULL INF = 1e20; // function //-------------------------------------------- LL gcd(LL, LL); bool isEven(LL); void coutY(); void coutN(); int main() { LL n; cin >> n; LL a, b, c, d; cin >> a >> b >> c >> d; string s; cin >> s; FOR(i, a, max(c, d)) { if (s[i - 1] == '#' && s[i] == '#') { coutN(); return 0; } } if (c > d) { FOR(i, b - 1, d) { string tmp = s.substr(i - 1, 3); if (tmp == "...") { coutY(); return 0; } } coutN(); return 0; } coutY(); return 0; } LL gcd(LL a, LL b) { if (a == 0 || b == 0) return 0; if (a < b) swap(a, b); if (a % b == 0) return b; else gcd(b, a % b); } bool isEven(LL a) { return !((bool)(a % 2)); } void coutY() { cout << "Yes" << endl; return; } void coutN() { cout << "No" << endl; return; }
[ "expression.operation.binary.remove" ]
831,110
831,111
u196798307
cpp
p03017
#include "bits/stdc++.h" using namespace std; // typedef //------------------------------------------ typedef long long LL; typedef unsigned long long ULL; typedef vector<LL> VLL; typedef vector<VLL> VVLL; typedef vector<string> VS; typedef pair<LL, LL> PLL; // container util //------------------------------------------ #define ALL(a) (a).begin(), (a).end() #define PB push_back #define MP make_pair #define SORT(c) sort((c).begin(), (c).end()) #define COUT(x) cout << x << endl // repetition //------------------------------------------ #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) // constant //-------------------------------------------- const double PI = acos(-1.0); const LL MOD = 1e9 + 7; const ULL INF = 1e20; // function //-------------------------------------------- LL gcd(LL, LL); bool isEven(LL); void coutY(); void coutN(); int main() { LL n; cin >> n; LL a, b, c, d; cin >> a >> b >> c >> d; string s; cin >> s; FOR(i, a, max(c, d)) { if (s[i - 1] == '#' && s[i] == '#') { coutN(); return 0; } } if (c > d) { // cout<<1<<endl; FOR(i, b - 1, d) { string tmp = s.substr(i, 3); // COUT(tmp); if (tmp == "...") { coutY(); return 0; } } coutN(); return 0; } coutY(); return 0; } LL gcd(LL a, LL b) { if (a == 0 || b == 0) return 0; if (a < b) swap(a, b); if (a % b == 0) return b; else gcd(b, a % b); } bool isEven(LL a) { return !((bool)(a % 2)); } void coutY() { cout << "Yes" << endl; return; } void coutN() { cout << "No" << endl; return; }
#include "bits/stdc++.h" using namespace std; // typedef //------------------------------------------ typedef long long LL; typedef unsigned long long ULL; typedef vector<LL> VLL; typedef vector<VLL> VVLL; typedef vector<string> VS; typedef pair<LL, LL> PLL; // container util //------------------------------------------ #define ALL(a) (a).begin(), (a).end() #define PB push_back #define MP make_pair #define SORT(c) sort((c).begin(), (c).end()) #define COUT(x) cout << x << endl // repetition //------------------------------------------ #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) // constant //-------------------------------------------- const double PI = acos(-1.0); const LL MOD = 1e9 + 7; const ULL INF = 1e20; // function //-------------------------------------------- LL gcd(LL, LL); bool isEven(LL); void coutY(); void coutN(); int main() { LL n; cin >> n; LL a, b, c, d; cin >> a >> b >> c >> d; string s; cin >> s; FOR(i, a, max(c, d)) { if (s[i - 1] == '#' && s[i] == '#') { coutN(); return 0; } } if (c > d) { FOR(i, b - 1, d) { string tmp = s.substr(i - 1, 3); if (tmp == "...") { coutY(); return 0; } } coutN(); return 0; } coutY(); return 0; } LL gcd(LL a, LL b) { if (a == 0 || b == 0) return 0; if (a < b) swap(a, b); if (a % b == 0) return b; else gcd(b, a % b); } bool isEven(LL a) { return !((bool)(a % 2)); } void coutY() { cout << "Yes" << endl; return; } void coutN() { cout << "No" << endl; return; }
[ "assignment.change" ]
831,112
831,111
u196798307
cpp
p03017
#include "bits/stdc++.h" using namespace std; // typedef //------------------------------------------ typedef long long LL; typedef unsigned long long ULL; typedef vector<LL> VLL; typedef vector<VLL> VVLL; typedef vector<string> VS; typedef pair<LL, LL> PLL; // container util //------------------------------------------ #define ALL(a) (a).begin(), (a).end() #define PB push_back #define MP make_pair #define SORT(c) sort((c).begin(), (c).end()) #define COUT(x) cout << x << endl // repetition //------------------------------------------ #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) // constant //-------------------------------------------- const double PI = acos(-1.0); const LL MOD = 1e9 + 7; const ULL INF = 1e20; // function //-------------------------------------------- LL gcd(LL, LL); bool isEven(LL); void coutY(); void coutN(); int main() { LL n; cin >> n; LL a, b, c, d; cin >> a >> b >> c >> d; string s; cin >> s; FOR(i, a - 1, max(c, d)) { if (s[i - 1] == '#' && s[i] == '#') { coutN(); return 0; } } if (c > d) { FOR(i, b - 1, d - 1) { string tmp = s.substr(i, 3); if (tmp == "...") { coutY(); return 0; } } coutN(); return 0; } coutY(); return 0; } LL gcd(LL a, LL b) { if (a == 0 || b == 0) return 0; if (a < b) swap(a, b); if (a % b == 0) return b; else gcd(b, a % b); } bool isEven(LL a) { return !((bool)(a % 2)); } void coutY() { cout << "Yes" << endl; return; } void coutN() { cout << "No" << endl; return; }
#include "bits/stdc++.h" using namespace std; // typedef //------------------------------------------ typedef long long LL; typedef unsigned long long ULL; typedef vector<LL> VLL; typedef vector<VLL> VVLL; typedef vector<string> VS; typedef pair<LL, LL> PLL; // container util //------------------------------------------ #define ALL(a) (a).begin(), (a).end() #define PB push_back #define MP make_pair #define SORT(c) sort((c).begin(), (c).end()) #define COUT(x) cout << x << endl // repetition //------------------------------------------ #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) // constant //-------------------------------------------- const double PI = acos(-1.0); const LL MOD = 1e9 + 7; const ULL INF = 1e20; // function //-------------------------------------------- LL gcd(LL, LL); bool isEven(LL); void coutY(); void coutN(); int main() { LL n; cin >> n; LL a, b, c, d; cin >> a >> b >> c >> d; string s; cin >> s; FOR(i, a, max(c, d)) { if (s[i - 1] == '#' && s[i] == '#') { coutN(); return 0; } } if (c > d) { FOR(i, b - 1, d) { string tmp = s.substr(i - 1, 3); if (tmp == "...") { coutY(); return 0; } } coutN(); return 0; } coutY(); return 0; } LL gcd(LL a, LL b) { if (a == 0 || b == 0) return 0; if (a < b) swap(a, b); if (a % b == 0) return b; else gcd(b, a % b); } bool isEven(LL a) { return !((bool)(a % 2)); } void coutY() { cout << "Yes" << endl; return; } void coutN() { cout << "No" << endl; return; }
[ "expression.operation.binary.remove" ]
831,113
831,111
u196798307
cpp
p03017
#include "bits/stdc++.h" using namespace std; // typedef //------------------------------------------ typedef long long LL; typedef unsigned long long ULL; typedef vector<LL> VLL; typedef vector<VLL> VVLL; typedef vector<string> VS; typedef pair<LL, LL> PLL; // container util //------------------------------------------ #define ALL(a) (a).begin(), (a).end() #define PB push_back #define MP make_pair #define SORT(c) sort((c).begin(), (c).end()) #define COUT(x) cout << x << endl // repetition //------------------------------------------ #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) // constant //-------------------------------------------- const double PI = acos(-1.0); const LL MOD = 1e9 + 7; const ULL INF = 1e20; // function //-------------------------------------------- LL gcd(LL, LL); bool isEven(LL); void coutY(); void coutN(); int main() { LL n; cin >> n; LL a, b, c, d; cin >> a >> b >> c >> d; string s; cin >> s; FOR(i, a - 1, max(c, d)) { if (s[i - 1] == '#' && s[i] == '#') { coutN(); return 0; } } if (c > d) { FOR(i, b - 1, d - 2) { string tmp = s.substr(i, 3); if (tmp == "...") { coutY(); return 0; } } coutN(); return 0; } coutY(); return 0; } LL gcd(LL a, LL b) { if (a == 0 || b == 0) return 0; if (a < b) swap(a, b); if (a % b == 0) return b; else gcd(b, a % b); } bool isEven(LL a) { return !((bool)(a % 2)); } void coutY() { cout << "Yes" << endl; return; } void coutN() { cout << "No" << endl; return; }
#include "bits/stdc++.h" using namespace std; // typedef //------------------------------------------ typedef long long LL; typedef unsigned long long ULL; typedef vector<LL> VLL; typedef vector<VLL> VVLL; typedef vector<string> VS; typedef pair<LL, LL> PLL; // container util //------------------------------------------ #define ALL(a) (a).begin(), (a).end() #define PB push_back #define MP make_pair #define SORT(c) sort((c).begin(), (c).end()) #define COUT(x) cout << x << endl // repetition //------------------------------------------ #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) // constant //-------------------------------------------- const double PI = acos(-1.0); const LL MOD = 1e9 + 7; const ULL INF = 1e20; // function //-------------------------------------------- LL gcd(LL, LL); bool isEven(LL); void coutY(); void coutN(); int main() { LL n; cin >> n; LL a, b, c, d; cin >> a >> b >> c >> d; string s; cin >> s; FOR(i, a, max(c, d)) { if (s[i - 1] == '#' && s[i] == '#') { coutN(); return 0; } } if (c > d) { FOR(i, b - 1, d) { string tmp = s.substr(i - 1, 3); if (tmp == "...") { coutY(); return 0; } } coutN(); return 0; } coutY(); return 0; } LL gcd(LL a, LL b) { if (a == 0 || b == 0) return 0; if (a < b) swap(a, b); if (a % b == 0) return b; else gcd(b, a % b); } bool isEven(LL a) { return !((bool)(a % 2)); } void coutY() { cout << "Yes" << endl; return; } void coutN() { cout << "No" << endl; return; }
[ "expression.operation.binary.remove" ]
831,114
831,111
u196798307
cpp
p03017
#include "bits/stdc++.h" using namespace std; // typedef //------------------------------------------ typedef long long LL; typedef unsigned long long ULL; typedef vector<LL> VLL; typedef vector<VLL> VVLL; typedef vector<string> VS; typedef pair<LL, LL> PLL; // container util //------------------------------------------ #define ALL(a) (a).begin(), (a).end() #define PB push_back #define MP make_pair #define SORT(c) sort((c).begin(), (c).end()) #define COUT(x) cout << x << endl // repetition //------------------------------------------ #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) // constant //-------------------------------------------- const double PI = acos(-1.0); const LL MOD = 1e9 + 7; const ULL INF = 1e20; // function //-------------------------------------------- LL gcd(LL, LL); bool isEven(LL); void coutY(); void coutN(); int main() { LL n; cin >> n; LL a, b, c, d; cin >> a >> b >> c >> d; string s; cin >> s; FOR(i, a, max(c, d)) { if (s[i - 1] == '#' && s[i] == '#') { coutN(); return 0; } } if (c > d) { FOR(i, b - 1, d - 2) { string tmp = s.substr(i, 3); if (tmp == "...") { coutY(); return 0; } } coutN(); return 0; } coutY(); return 0; } LL gcd(LL a, LL b) { if (a == 0 || b == 0) return 0; if (a < b) swap(a, b); if (a % b == 0) return b; else gcd(b, a % b); } bool isEven(LL a) { return !((bool)(a % 2)); } void coutY() { cout << "Yes" << endl; return; } void coutN() { cout << "No" << endl; return; }
#include "bits/stdc++.h" using namespace std; // typedef //------------------------------------------ typedef long long LL; typedef unsigned long long ULL; typedef vector<LL> VLL; typedef vector<VLL> VVLL; typedef vector<string> VS; typedef pair<LL, LL> PLL; // container util //------------------------------------------ #define ALL(a) (a).begin(), (a).end() #define PB push_back #define MP make_pair #define SORT(c) sort((c).begin(), (c).end()) #define COUT(x) cout << x << endl // repetition //------------------------------------------ #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) // constant //-------------------------------------------- const double PI = acos(-1.0); const LL MOD = 1e9 + 7; const ULL INF = 1e20; // function //-------------------------------------------- LL gcd(LL, LL); bool isEven(LL); void coutY(); void coutN(); int main() { LL n; cin >> n; LL a, b, c, d; cin >> a >> b >> c >> d; string s; cin >> s; FOR(i, a, max(c, d)) { if (s[i - 1] == '#' && s[i] == '#') { coutN(); return 0; } } if (c > d) { FOR(i, b - 1, d) { string tmp = s.substr(i - 1, 3); if (tmp == "...") { coutY(); return 0; } } coutN(); return 0; } coutY(); return 0; } LL gcd(LL a, LL b) { if (a == 0 || b == 0) return 0; if (a < b) swap(a, b); if (a % b == 0) return b; else gcd(b, a % b); } bool isEven(LL a) { return !((bool)(a % 2)); } void coutY() { cout << "Yes" << endl; return; } void coutN() { cout << "No" << endl; return; }
[ "expression.operation.binary.remove" ]
831,115
831,111
u196798307
cpp
p03017
#include "bits/stdc++.h" using namespace std; // typedef //------------------------------------------ typedef long long LL; typedef unsigned long long ULL; typedef vector<LL> VLL; typedef vector<VLL> VVLL; typedef vector<string> VS; typedef pair<LL, LL> PLL; // container util //------------------------------------------ #define ALL(a) (a).begin(), (a).end() #define PB push_back #define MP make_pair #define SORT(c) sort((c).begin(), (c).end()) #define COUT(x) cout << x << endl // repetition //------------------------------------------ #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) // constant //-------------------------------------------- const double PI = acos(-1.0); const LL MOD = 1e9 + 7; const ULL INF = 1e20; // function //-------------------------------------------- LL gcd(LL, LL); bool isEven(LL); void coutY(); void coutN(); int main() { LL n; cin >> n; LL a, b, c, d; cin >> a >> b >> c >> d; string s; cin >> s; FOR(i, a, max(c, d)) { if (s[i - 1] == '#' && s[i] == '#') { coutN(); return 0; } } if (c > d) { FOR(i, b, d - 2) { string tmp = s.substr(i, 3); if (tmp == "...") { coutY(); return 0; } } coutN(); return 0; } coutY(); return 0; } LL gcd(LL a, LL b) { if (a == 0 || b == 0) return 0; if (a < b) swap(a, b); if (a % b == 0) return b; else gcd(b, a % b); } bool isEven(LL a) { return !((bool)(a % 2)); } void coutY() { cout << "Yes" << endl; return; } void coutN() { cout << "No" << endl; return; }
#include "bits/stdc++.h" using namespace std; // typedef //------------------------------------------ typedef long long LL; typedef unsigned long long ULL; typedef vector<LL> VLL; typedef vector<VLL> VVLL; typedef vector<string> VS; typedef pair<LL, LL> PLL; // container util //------------------------------------------ #define ALL(a) (a).begin(), (a).end() #define PB push_back #define MP make_pair #define SORT(c) sort((c).begin(), (c).end()) #define COUT(x) cout << x << endl // repetition //------------------------------------------ #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) // constant //-------------------------------------------- const double PI = acos(-1.0); const LL MOD = 1e9 + 7; const ULL INF = 1e20; // function //-------------------------------------------- LL gcd(LL, LL); bool isEven(LL); void coutY(); void coutN(); int main() { LL n; cin >> n; LL a, b, c, d; cin >> a >> b >> c >> d; string s; cin >> s; FOR(i, a, max(c, d)) { if (s[i - 1] == '#' && s[i] == '#') { coutN(); return 0; } } if (c > d) { FOR(i, b - 1, d) { string tmp = s.substr(i - 1, 3); if (tmp == "...") { coutY(); return 0; } } coutN(); return 0; } coutY(); return 0; } LL gcd(LL a, LL b) { if (a == 0 || b == 0) return 0; if (a < b) swap(a, b); if (a % b == 0) return b; else gcd(b, a % b); } bool isEven(LL a) { return !((bool)(a % 2)); } void coutY() { cout << "Yes" << endl; return; } void coutN() { cout << "No" << endl; return; }
[ "expression.operation.binary.remove" ]
831,116
831,111
u196798307
cpp
p03017
#include <bits/stdc++.h> #define ll long long #define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++) using namespace std; int main() { ll n, a, b, c, d; cin >> n >> a >> b >> c >> d; a--; b--; c--; d--; string str; cin >> str; for (ll i = a - 1; i < max(c, d); i++) { if (str[i] == '#' && str[i - 1] == '#') { cout << "No" << endl; return 0; } } if (c > d) { for (ll i = b + 1; i < d; i++) { if (str[i] == '.' && str[i - 1] == '.' && str[i - 2] == '.') { cout << "Yes" << endl; return 0; } } cout << "No" << endl; return 0; } cout << "Yes" << endl; }
#include <bits/stdc++.h> #define ll long long #define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++) using namespace std; int main() { ll n, a, b, c, d; cin >> n >> a >> b >> c >> d; a--; b--; c--; d--; string str; cin >> str; for (ll i = a; i < max(c, d); i++) { if (str[i] == '#' && str[i - 1] == '#') { cout << "No" << endl; return 0; } } if (c > d) { for (ll i = b + 1; i <= d + 1; i++) { if (str[i] == '.' && str[i - 1] == '.' && str[i - 2] == '.') { cout << "Yes" << endl; return 0; } } cout << "No" << endl; return 0; } cout << "Yes" << endl; }
[ "control_flow.loop.for.initializer.change", "expression.operation.binary.remove", "expression.operator.compare.change", "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "misc.off_by_one" ]
831,125
831,127
u201316840
cpp
p03017
#include <bits/stdc++.h> using namespace std; bool equals(const string &a, int start, const string &b) { for (int i = 0; i < b.size(); ++i) { if (start + i >= a.size() || a[start + i] != b[i]) { return false; } } return true; } bool can_goal(const string &s, int beg, int end) { for (int i = beg; i < end; ++i) { if (equals(s, i, "##")) { return false; } } return true; } bool can_over(const string &s, int beg, int end) { for (int i = beg; i < end; ++i) { if (equals(s, i, "...")) { return true; } } return false; } int main() { int N, A, B, C, D; string S; cin >> N >> A >> B >> C >> D >> S; bool goal = can_goal(S, A - 1, C - 1) && can_goal(S, B - 1, D - 1); bool result = goal && (C < D || can_over(S, B - 1, D - 1)); cout << (result ? "Yes" : "No") << endl; }
#include <bits/stdc++.h> using namespace std; bool equals(const string &a, int start, const string &b) { for (int i = 0; i < b.size(); ++i) { if (start + i >= a.size() || a[start + i] != b[i]) { return false; } } return true; } bool can_goal(const string &s, int beg, int end) { for (int i = beg; i < end; ++i) { if (equals(s, i, "##")) { return false; } } return true; } bool can_over(const string &s, int beg, int end) { for (int i = beg; i < end; ++i) { if (equals(s, i, "...")) { return true; } } return false; } int main() { int N, A, B, C, D; string S; cin >> N >> A >> B >> C >> D >> S; bool goal = can_goal(S, A - 1, C - 1) && can_goal(S, B - 1, D - 1); bool result = goal && (C < D || can_over(S, B - 2, D - 1)); cout << (result ? "Yes" : "No") << endl; }
[ "literal.number.change", "call.arguments.change", "expression.operation.binary.change" ]
831,133
831,134
u842596864
cpp
p03017
#include <bits/stdc++.h> #define fi first #define se second #define pb push_back #define endl "\n" #define int long long using namespace std; const int N = 300111; int n, m, a, b, c, d; string s; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // freopen("input.txt","r",stdin); cin >> n >> a >> b >> c >> d; a--, b--, c--, d--; cin >> s; for (int i = 1; i < s.size(); i++) { if (s[i - 1] == '#' && s[i] == '#') { if (a < i && c > i) { cout << "No" << endl; return 0; } if (b < i && d > i) { cout << "No" << endl; return 0; } } } if (c > d) { for (int i = b; i < d; i++) { if (s[i - 1] != '#' && s[i + 1] != '#' && s[i] != '#') { cout << "Yes" << endl; return 0; } } cout << "No" << endl; return 0; } cout << "Yes" << endl; return 0; }
#include <bits/stdc++.h> #define fi first #define se second #define pb push_back #define endl "\n" #define int long long using namespace std; const int N = 300111; int n, m, a, b, c, d; string s; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // freopen("input.txt","r",stdin); cin >> n >> a >> b >> c >> d; a--, b--, c--, d--; cin >> s; for (int i = 1; i < s.size(); i++) { if (s[i - 1] == '#' && s[i] == '#') { if (a < i && c > i) { cout << "No" << endl; return 0; } if (b < i && d > i) { cout << "No" << endl; return 0; } } } if (c > d) { for (int i = b; i <= d; i++) { if (s[i - 1] != '#' && s[i + 1] != '#' && s[i] != '#') { cout << "Yes" << endl; return 0; } } cout << "No" << endl; return 0; } cout << "Yes" << endl; return 0; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
831,151
831,152
u067866475
cpp
p03017
#define _CRT_SECURE_NO_WARNINGS #include <bits/stdc++.h> #define fi first #define se second #define pb push_back #define E "\n"; using namespace std; const long long MOD = (long long)1e9 + 7; int n, a, b, c, d; string s; bool fun1(int x, int y) { for (int i = x + 2; i < y; i++) { if (s[i - 1] == '#' && s[i] == '#') return false; } return true; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> a >> b >> c >> d >> s; s = "*" + s; if (!fun1(a, c) || !fun1(b, d)) { cout << "NO" << E; return 0; } if (c < d) { cout << "YES" << E; return 0; } for (int i = b; i <= d; i++) { if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') { cout << "YES" << E; return 0; } } cout << "NO" << E; // system("pause"); return 0; }
#define _CRT_SECURE_NO_WARNINGS #include <bits/stdc++.h> #define fi first #define se second #define pb push_back #define E "\n"; using namespace std; const long long MOD = (long long)1e9 + 7; int n, a, b, c, d; string s; bool fun1(int x, int y) { for (int i = x + 2; i < y; i++) { if (s[i - 1] == '#' && s[i] == '#') return false; } return true; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> a >> b >> c >> d >> s; s = "*" + s; if (!fun1(a, c) || !fun1(b, d)) { cout << "No" << E; return 0; } if (c < d) { cout << "Yes" << E; return 0; } for (int i = b; i <= d; i++) { if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') { cout << "Yes" << E; return 0; } } cout << "No" << E; // system("pause"); return 0; }
[ "literal.string.change", "literal.string.case.change", "io.output.change" ]
831,162
831,164
u398025421
cpp
p03017
#include <algorithm> #include <cmath> #include <cstdlib> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <tuple> #include <vector> using namespace std; typedef long long ll; const ll mod = 1e9 + 7; const ll INF = 1LL << 60; int main() { ll n, a, b, c, d; string s; cin >> n >> a >> b >> c >> d >> s; a--; b--; c--; d--; for (ll i = a; i < max(c, d); i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } } if (c < d) cout << "Yes" << endl; else { for (ll i = b; i < d; i++) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { cout << "Yes" << endl; return 0; } } cout << "No" << endl; } }
#include <algorithm> #include <cmath> #include <cstdlib> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <tuple> #include <vector> using namespace std; typedef long long ll; const ll mod = 1e9 + 7; const ll INF = 1LL << 60; int main() { ll n, a, b, c, d; string s; cin >> n >> a >> b >> c >> d >> s; a--; b--; c--; d--; for (ll i = a; i < max(c, d); i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } } if (c < d) cout << "Yes" << endl; else { for (ll i = b - 1; i < d; i++) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { cout << "Yes" << endl; return 0; } } cout << "No" << endl; } }
[ "control_flow.loop.for.initializer.change" ]
831,171
831,173
u553605501
cpp
p03017
#include <algorithm> #include <cmath> #include <cstdlib> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <tuple> #include <vector> using namespace std; typedef long long ll; const ll mod = 1e9 + 7; const ll INF = 1LL << 60; int main() { ll n, a, b, c, d; string s; cin >> n >> a >> b >> c >> d >> s; a--; b--; c--; d--; for (ll i = a; i < max(c, d); i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } } if (c < d) cout << "Yes" << endl; else { for (ll i = a; i < d; i++) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { cout << "Yes" << endl; return 0; } } cout << "No" << endl; } }
#include <algorithm> #include <cmath> #include <cstdlib> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <tuple> #include <vector> using namespace std; typedef long long ll; const ll mod = 1e9 + 7; const ll INF = 1LL << 60; int main() { ll n, a, b, c, d; string s; cin >> n >> a >> b >> c >> d >> s; a--; b--; c--; d--; for (ll i = a; i < max(c, d); i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } } if (c < d) cout << "Yes" << endl; else { for (ll i = b - 1; i < d; i++) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { cout << "Yes" << endl; return 0; } } cout << "No" << endl; } }
[ "control_flow.loop.for.initializer.change" ]
831,174
831,173
u553605501
cpp
p03017
#include <algorithm> #include <cmath> #include <cstdlib> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <tuple> #include <vector> using namespace std; typedef long long ll; const ll mod = 1e9 + 7; const ll INF = 1LL << 60; int main() { ll n, a, b, c, d; string s; cin >> n >> a >> b >> c >> d >> s; a--; b--; c--; d--; for (ll i = a; i < max(c, d); i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } } if (c < d) cout << "Yes" << endl; else { for (ll i = a; i <= d; i++) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { cout << "Yes" << endl; return 0; } } cout << "No" << endl; } }
#include <algorithm> #include <cmath> #include <cstdlib> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <tuple> #include <vector> using namespace std; typedef long long ll; const ll mod = 1e9 + 7; const ll INF = 1LL << 60; int main() { ll n, a, b, c, d; string s; cin >> n >> a >> b >> c >> d >> s; a--; b--; c--; d--; for (ll i = a; i < max(c, d); i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } } if (c < d) cout << "Yes" << endl; else { for (ll i = b - 1; i < d; i++) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { cout << "Yes" << endl; return 0; } } cout << "No" << endl; } }
[ "control_flow.loop.for.initializer.change", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
831,175
831,173
u553605501
cpp
p03017
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <list> #include <numeric> #include <queue> #include <set> #include <stack> #include <tuple> #include <vector> using namespace std; int main() { int n, a, b, c, d; cin >> n >> a >> b >> c >> d; string str = "0", strtemp; cin >> strtemp; str += strtemp; bool overtake = false; if (d < c) { overtake = true; } bool triplePlane = false; for (int i = b; i <= c; i++) { if (str[i - 1] == '.' && str[i] == '.' && str[i + 1] == '.') { triplePlane = true; break; } } bool doubleRock = false; for (int i = a + 1; i < c - 1; i++) { if (str[i] == '#' && str[i + 1] == '#') { doubleRock = true; break; } } for (int i = b + 1; i < d - 1; i++) { if (str[i] == '#' && str[i + 1] == '#') { doubleRock = true; break; } } if (overtake == false && doubleRock == false) { cout << "Yes"; } else if (overtake == true && doubleRock == false && triplePlane == true) { cout << "Yes"; } else { cout << "No"; } return 0; }
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <list> #include <numeric> #include <queue> #include <set> #include <stack> #include <tuple> #include <vector> using namespace std; int main() { int n, a, b, c, d; cin >> n >> a >> b >> c >> d; string str = "0", strtemp; cin >> strtemp; str += strtemp; bool overtake = false; if (d < c) { overtake = true; } bool triplePlane = false; for (int i = b; i <= d; i++) { if (str[i - 1] == '.' && str[i] == '.' && str[i + 1] == '.') { triplePlane = true; break; } } bool doubleRock = false; for (int i = a + 1; i < c - 1; i++) { if (str[i] == '#' && str[i + 1] == '#') { doubleRock = true; break; } } for (int i = b + 1; i < d - 1; i++) { if (str[i] == '#' && str[i + 1] == '#') { doubleRock = true; break; } } if (overtake == false && doubleRock == false) { cout << "Yes"; } else if (overtake == true && doubleRock == false && triplePlane == true) { cout << "Yes"; } else { cout << "No"; } return 0; }
[ "identifier.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
831,176
831,177
u947304300
cpp
p03017
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define REP(i, N) for (int i = 0; i < N; i++) #define REP1(i, N) for (int i = 1; i < N; i++) #define RREP(i, N) for (int i = N - 1; i >= 0; --i) #define ANS(a) cout << a << endl; #define SORT(V) sort(V.begin(), V.end()) #define RSORT(V) sort(V.rbegin(), V.rend()) #define DBG(V) \ for (auto v : V) \ cout << v << " "; \ cout << endl int N, A, B, C, D; string S; int main() { cin >> N >> A >> B >> C >> D; cin >> S; --A; --B; --C; --D; bool flg = true; bool flg3 = false; if (C < D) { flg3 = true; } else { if (S[D - 1] == '.' && S[D + 1] == '.') { flg3 = true; } else { flg3 = false; } } for (int i = A + 1; flg && (i <= C || i <= D); ++i) { if (S[i - 1] == '#' && S[i] == '#') { flg = false; } if (!flg3 && (B <= i && (i < C - 1 && i < D - 1))) { if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') flg3 = true; } } if (flg && flg3) { ANS("Yes"); } else { ANS("No"); } return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define REP(i, N) for (int i = 0; i < N; i++) #define REP1(i, N) for (int i = 1; i < N; i++) #define RREP(i, N) for (int i = N - 1; i >= 0; --i) #define ANS(a) cout << a << endl; #define SORT(V) sort(V.begin(), V.end()) #define RSORT(V) sort(V.rbegin(), V.rend()) #define DBG(V) \ for (auto v : V) \ cout << v << " "; \ cout << endl int N, A, B, C, D; string S; int main() { cin >> N >> A >> B >> C >> D; cin >> S; --A; --B; --C; --D; bool flg = true; bool flg3 = false; if (C < D) { flg3 = true; } else { if (S[D - 1] == '.' && S[D + 1] == '.') { flg3 = true; } else { flg3 = false; } } for (int i = A + 1; flg && (i <= C || i <= D); ++i) { if (S[i - 1] == '#' && S[i] == '#') { flg = false; } if (!flg3 && (B <= i && (i <= C && i <= D))) { if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') flg3 = true; } } if (flg && flg3) { ANS("Yes"); } else { ANS("No"); } return 0; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
831,182
831,183
u013373291
cpp
p03017
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <vector> #define ll long long #define pii pair<int, int> #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 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 INF (1 << 30) - 1 #define LLINF (1LL << 61) - 1 // #define int ll using namespace std; const int MOD = 1000000007; const int MAX = 510000; int main() { cin.tie(0); ios::sync_with_stdio(false); ll n, a, b, c, d; string s; cin >> n >> a >> b >> c >> d >> s; bool f1 = false, f2 = false; rep2(i, a - 1, max(c, d)) { if (s[i] == '#' && s[i + 1] == '#') f1 = true; } rep2(i, b - 1, min(c, d)) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') f2 = true; } if (c < d) { if (f1) cout << "No" << endl; else cout << "Yes" << endl; } else { if (!f1 && f2) cout << "Yes" << endl; else cout << "No" << endl; } return 0; }
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <vector> #define ll long long #define pii pair<int, int> #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 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 INF (1 << 30) - 1 #define LLINF (1LL << 61) - 1 // #define int ll using namespace std; const int MOD = 1000000007; const int MAX = 510000; int main() { cin.tie(0); ios::sync_with_stdio(false); ll n, a, b, c, d; string s; cin >> n >> a >> b >> c >> d >> s; bool f1 = false, f2 = false; rep2(i, a - 1, max(c, d)) { if (s[i] == '#' && s[i + 1] == '#') f1 = true; } rep2(i, b - 1, min(c, d)) { if (s[i] == '.' && s[i + 1] == '.' && s[i - 1] == '.') f2 = true; } if (c < d) { if (f1) cout << "No" << endl; else cout << "Yes" << endl; } else { if (!f1 && f2) cout << "Yes" << endl; else cout << "No" << endl; } return 0; }
[]
831,199
831,200
u241367243
cpp
p03017
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <vector> #define ll long long #define pii pair<int, int> #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 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 INF (1 << 30) - 1 #define LLINF (1LL << 61) - 1 // #define int ll using namespace std; const int MOD = 1000000007; const int MAX = 510000; int main() { cin.tie(0); ios::sync_with_stdio(false); ll n, a, b, c, d; string s; cin >> n >> a >> b >> c >> d >> s; bool f1 = false, f2 = false; rep2(i, a - 1, max(c, d)) { if (s[i] == '#' && s[i + 1] == '#') f1 = true; } rep2(i, a - 1, min(c, d)) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') f2 = true; } if (c < d) { if (f1) cout << "No" << endl; else cout << "Yes" << endl; } else { if (!f1 && f2) cout << "Yes" << endl; else cout << "No" << endl; } return 0; }
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <vector> #define ll long long #define pii pair<int, int> #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 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 INF (1 << 30) - 1 #define LLINF (1LL << 61) - 1 // #define int ll using namespace std; const int MOD = 1000000007; const int MAX = 510000; int main() { cin.tie(0); ios::sync_with_stdio(false); ll n, a, b, c, d; string s; cin >> n >> a >> b >> c >> d >> s; bool f1 = false, f2 = false; rep2(i, a - 1, max(c, d)) { if (s[i] == '#' && s[i + 1] == '#') f1 = true; } rep2(i, b - 1, min(c, d)) { if (s[i] == '.' && s[i + 1] == '.' && s[i - 1] == '.') f2 = true; } if (c < d) { if (f1) cout << "No" << endl; else cout << "Yes" << endl; } else { if (!f1 && f2) cout << "Yes" << endl; else cout << "No" << endl; } return 0; }
[ "identifier.change", "call.arguments.change", "expression.operation.binary.change" ]
831,202
831,200
u241367243
cpp
p03017
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define pb push_back #define mp make_pair #define all(a) begin(a), end(a) #define FOR(x, val, to) for (int x = (val); x < int((to)); ++x) #define FORE(x, val, to) for (auto x = (val); x <= (to); ++x) #define FORR(x, arr) for (auto &x : arr) #define FORS(x, plus, arr) \ for (auto x = begin(arr) + (plus); x != end(arr); ++x) #define FORREV(x, plus, arr) \ for (auto x = (arr).rbegin() + (plus); x != (arr).rend(); ++x) #define REE(s_) \ { \ cout << s_ << '\n'; \ exit(0); \ } #define GET(arr) \ for (auto &i : (arr)) \ sc(i) #define whatis(x) cerr << #x << " is " << (x) << endl; #define e1 first #define e2 second #define INF 0x7f7f7f7f typedef std::pair<int, int> pi; typedef std::vector<int> vi; typedef std::vector<std::string> vs; typedef int64_t ll; typedef uint64_t ull; #define umap unordered_map #define uset unordered_set using namespace std; using namespace __gnu_pbds; #ifdef _WIN32 #define getchar_unlocked() _getchar_nolock() #define _CRT_DISABLE_PERFCRIT_LOCKS #endif template <class L, class R> ostream &operator<<(ostream &os, map<L, R> P) { for (auto const &vv : P) os << "(" << vv.first << "," << vv.second << ")"; return os; } template <class T> ostream &operator<<(ostream &os, set<T> V) { os << "["; for (auto const &vv : V) os << vv << ","; os << "]"; return os; } template <class T> ostream &operator<<(ostream &os, vector<T> V) { os << "["; for (auto const &vv : V) os << vv << ","; os << "]"; return os; } template <class L, class R> ostream &operator<<(ostream &os, pair<L, R> P) { os << "(" << P.first << "," << P.second << ")"; return os; } inline int fstoi(const string &str) { auto it = str.begin(); bool neg = 0; int num = 0; if (*it == '-') neg = 1; else num = *it - '0'; ++it; while (it < str.end()) num = num * 10 + (*it++ - '0'); if (neg) num *= -1; return num; } inline void getch(char &x) { while (x = getchar_unlocked(), x < 33) { ; } } inline void getstr(string &str) { str.clear(); char cur; while (cur = getchar_unlocked(), cur < 33) { ; } while (cur > 32) { str += cur; cur = getchar_unlocked(); } } template <typename T> inline bool sc(T &num) { bool neg = 0; int c; num = 0; while (c = getchar_unlocked(), c < 33) { if (c == EOF) return false; } if (c == '-') { neg = 1; c = getchar_unlocked(); } for (; c > 47; c = getchar_unlocked()) num = num * 10 + c - 48; if (neg) num *= -1; return true; } template <typename T, typename... Args> inline void sc(T &num, Args &...args) { bool neg = 0; int c; num = 0; while (c = getchar_unlocked(), c < 33) { ; } if (c == '-') { neg = 1; c = getchar_unlocked(); } for (; c > 47; c = getchar_unlocked()) num = num * 10 + c - 48; if (neg) num *= -1; sc(args...); } template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; // s.find_by_order(), // s.order_of_key() <- works like // lower_bound template <typename T> using ordered_map = tree<T, int, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define N 1000001 int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, a, b, c, d; sc(n, a, b, c, d); string s; getstr(s); --a, --b, --c, --d; bool k = 1; FORR(i, s) i = i == '#'; // isrock FOR(i, a, c - 1) { if (s[i] && s[i + 1]) { k = 0; break; } } FOR(i, b, d - 1) { if (s[i] && s[i + 1]) { k = 0; break; } } if (d < c) { bool hm = 0; for (int i = b - 1; i < c - 1; ++i) { // od pola przed pozycja b if ((s[i] || s[i + 1] || s[i + 2]) == 0) { hm = 1; } } if (!hm) k = 0; } cout << (k ? "Yes" : "No"); }
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define pb push_back #define mp make_pair #define all(a) begin(a), end(a) #define FOR(x, val, to) for (int x = (val); x < int((to)); ++x) #define FORE(x, val, to) for (auto x = (val); x <= (to); ++x) #define FORR(x, arr) for (auto &x : arr) #define FORS(x, plus, arr) \ for (auto x = begin(arr) + (plus); x != end(arr); ++x) #define FORREV(x, plus, arr) \ for (auto x = (arr).rbegin() + (plus); x != (arr).rend(); ++x) #define REE(s_) \ { \ cout << s_ << '\n'; \ exit(0); \ } #define GET(arr) \ for (auto &i : (arr)) \ sc(i) #define whatis(x) cerr << #x << " is " << (x) << endl; #define e1 first #define e2 second #define INF 0x7f7f7f7f typedef std::pair<int, int> pi; typedef std::vector<int> vi; typedef std::vector<std::string> vs; typedef int64_t ll; typedef uint64_t ull; #define umap unordered_map #define uset unordered_set using namespace std; using namespace __gnu_pbds; #ifdef _WIN32 #define getchar_unlocked() _getchar_nolock() #define _CRT_DISABLE_PERFCRIT_LOCKS #endif template <class L, class R> ostream &operator<<(ostream &os, map<L, R> P) { for (auto const &vv : P) os << "(" << vv.first << "," << vv.second << ")"; return os; } template <class T> ostream &operator<<(ostream &os, set<T> V) { os << "["; for (auto const &vv : V) os << vv << ","; os << "]"; return os; } template <class T> ostream &operator<<(ostream &os, vector<T> V) { os << "["; for (auto const &vv : V) os << vv << ","; os << "]"; return os; } template <class L, class R> ostream &operator<<(ostream &os, pair<L, R> P) { os << "(" << P.first << "," << P.second << ")"; return os; } inline int fstoi(const string &str) { auto it = str.begin(); bool neg = 0; int num = 0; if (*it == '-') neg = 1; else num = *it - '0'; ++it; while (it < str.end()) num = num * 10 + (*it++ - '0'); if (neg) num *= -1; return num; } inline void getch(char &x) { while (x = getchar_unlocked(), x < 33) { ; } } inline void getstr(string &str) { str.clear(); char cur; while (cur = getchar_unlocked(), cur < 33) { ; } while (cur > 32) { str += cur; cur = getchar_unlocked(); } } template <typename T> inline bool sc(T &num) { bool neg = 0; int c; num = 0; while (c = getchar_unlocked(), c < 33) { if (c == EOF) return false; } if (c == '-') { neg = 1; c = getchar_unlocked(); } for (; c > 47; c = getchar_unlocked()) num = num * 10 + c - 48; if (neg) num *= -1; return true; } template <typename T, typename... Args> inline void sc(T &num, Args &...args) { bool neg = 0; int c; num = 0; while (c = getchar_unlocked(), c < 33) { ; } if (c == '-') { neg = 1; c = getchar_unlocked(); } for (; c > 47; c = getchar_unlocked()) num = num * 10 + c - 48; if (neg) num *= -1; sc(args...); } template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; // s.find_by_order(), // s.order_of_key() <- works like // lower_bound template <typename T> using ordered_map = tree<T, int, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define N 1000001 int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, a, b, c, d; sc(n, a, b, c, d); string s; getstr(s); --a, --b, --c, --d; bool k = 1; FORR(i, s) i = i == '#'; // isrock FOR(i, a, c - 1) { if (s[i] && s[i + 1]) { k = 0; break; } } FOR(i, b, d - 1) { if (s[i] && s[i + 1]) { k = 0; break; } } if (d < c) { bool hm = 0; for (int i = b - 1; i < d; ++i) { // od pola przed pozycja b if ((s[i] || s[i + 1] || s[i + 2]) == 0) { hm = 1; } } if (!hm) k = 0; } cout << (k ? "Yes" : "No"); }
[ "identifier.change", "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
831,212
831,213
u761407600
cpp
p03017
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define pb push_back #define mp make_pair #define all(a) begin(a), end(a) #define FOR(x, val, to) for (int x = (val); x < int((to)); ++x) #define FORE(x, val, to) for (auto x = (val); x <= (to); ++x) #define FORR(x, arr) for (auto &x : arr) #define FORS(x, plus, arr) \ for (auto x = begin(arr) + (plus); x != end(arr); ++x) #define FORREV(x, plus, arr) \ for (auto x = (arr).rbegin() + (plus); x != (arr).rend(); ++x) #define REE(s_) \ { \ cout << s_ << '\n'; \ exit(0); \ } #define GET(arr) \ for (auto &i : (arr)) \ sc(i) #define whatis(x) cerr << #x << " is " << (x) << endl; #define e1 first #define e2 second #define INF 0x7f7f7f7f typedef std::pair<int, int> pi; typedef std::vector<int> vi; typedef std::vector<std::string> vs; typedef int64_t ll; typedef uint64_t ull; #define umap unordered_map #define uset unordered_set using namespace std; using namespace __gnu_pbds; #ifdef _WIN32 #define getchar_unlocked() _getchar_nolock() #define _CRT_DISABLE_PERFCRIT_LOCKS #endif template <class L, class R> ostream &operator<<(ostream &os, map<L, R> P) { for (auto const &vv : P) os << "(" << vv.first << "," << vv.second << ")"; return os; } template <class T> ostream &operator<<(ostream &os, set<T> V) { os << "["; for (auto const &vv : V) os << vv << ","; os << "]"; return os; } template <class T> ostream &operator<<(ostream &os, vector<T> V) { os << "["; for (auto const &vv : V) os << vv << ","; os << "]"; return os; } template <class L, class R> ostream &operator<<(ostream &os, pair<L, R> P) { os << "(" << P.first << "," << P.second << ")"; return os; } inline int fstoi(const string &str) { auto it = str.begin(); bool neg = 0; int num = 0; if (*it == '-') neg = 1; else num = *it - '0'; ++it; while (it < str.end()) num = num * 10 + (*it++ - '0'); if (neg) num *= -1; return num; } inline void getch(char &x) { while (x = getchar_unlocked(), x < 33) { ; } } inline void getstr(string &str) { str.clear(); char cur; while (cur = getchar_unlocked(), cur < 33) { ; } while (cur > 32) { str += cur; cur = getchar_unlocked(); } } template <typename T> inline bool sc(T &num) { bool neg = 0; int c; num = 0; while (c = getchar_unlocked(), c < 33) { if (c == EOF) return false; } if (c == '-') { neg = 1; c = getchar_unlocked(); } for (; c > 47; c = getchar_unlocked()) num = num * 10 + c - 48; if (neg) num *= -1; return true; } template <typename T, typename... Args> inline void sc(T &num, Args &...args) { bool neg = 0; int c; num = 0; while (c = getchar_unlocked(), c < 33) { ; } if (c == '-') { neg = 1; c = getchar_unlocked(); } for (; c > 47; c = getchar_unlocked()) num = num * 10 + c - 48; if (neg) num *= -1; sc(args...); } template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; // s.find_by_order(), // s.order_of_key() <- works like // lower_bound template <typename T> using ordered_map = tree<T, int, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define N 1000001 int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, a, b, c, d; sc(n, a, b, c, d); string s; getstr(s); --a, --b, --c, --d; bool k = 1; FORR(i, s) i = i == '#'; // isrock FOR(i, a, c - 1) { if (s[i] && s[i + 1]) { k = 0; break; } } FOR(i, b, d - 1) { if (s[i] && s[i + 1]) { k = 0; break; } } if (d < c) { bool hm = 0; for (int i = b - 1; i < c - 1; ++i) { // od pola przed pozycja b if ((s[i] || s[i + 1] || s[i + 2]) == 0) { hm = 1; } } if (!hm) k = 0; } cout << (k ? "YES" : "NO"); }
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define pb push_back #define mp make_pair #define all(a) begin(a), end(a) #define FOR(x, val, to) for (int x = (val); x < int((to)); ++x) #define FORE(x, val, to) for (auto x = (val); x <= (to); ++x) #define FORR(x, arr) for (auto &x : arr) #define FORS(x, plus, arr) \ for (auto x = begin(arr) + (plus); x != end(arr); ++x) #define FORREV(x, plus, arr) \ for (auto x = (arr).rbegin() + (plus); x != (arr).rend(); ++x) #define REE(s_) \ { \ cout << s_ << '\n'; \ exit(0); \ } #define GET(arr) \ for (auto &i : (arr)) \ sc(i) #define whatis(x) cerr << #x << " is " << (x) << endl; #define e1 first #define e2 second #define INF 0x7f7f7f7f typedef std::pair<int, int> pi; typedef std::vector<int> vi; typedef std::vector<std::string> vs; typedef int64_t ll; typedef uint64_t ull; #define umap unordered_map #define uset unordered_set using namespace std; using namespace __gnu_pbds; #ifdef _WIN32 #define getchar_unlocked() _getchar_nolock() #define _CRT_DISABLE_PERFCRIT_LOCKS #endif template <class L, class R> ostream &operator<<(ostream &os, map<L, R> P) { for (auto const &vv : P) os << "(" << vv.first << "," << vv.second << ")"; return os; } template <class T> ostream &operator<<(ostream &os, set<T> V) { os << "["; for (auto const &vv : V) os << vv << ","; os << "]"; return os; } template <class T> ostream &operator<<(ostream &os, vector<T> V) { os << "["; for (auto const &vv : V) os << vv << ","; os << "]"; return os; } template <class L, class R> ostream &operator<<(ostream &os, pair<L, R> P) { os << "(" << P.first << "," << P.second << ")"; return os; } inline int fstoi(const string &str) { auto it = str.begin(); bool neg = 0; int num = 0; if (*it == '-') neg = 1; else num = *it - '0'; ++it; while (it < str.end()) num = num * 10 + (*it++ - '0'); if (neg) num *= -1; return num; } inline void getch(char &x) { while (x = getchar_unlocked(), x < 33) { ; } } inline void getstr(string &str) { str.clear(); char cur; while (cur = getchar_unlocked(), cur < 33) { ; } while (cur > 32) { str += cur; cur = getchar_unlocked(); } } template <typename T> inline bool sc(T &num) { bool neg = 0; int c; num = 0; while (c = getchar_unlocked(), c < 33) { if (c == EOF) return false; } if (c == '-') { neg = 1; c = getchar_unlocked(); } for (; c > 47; c = getchar_unlocked()) num = num * 10 + c - 48; if (neg) num *= -1; return true; } template <typename T, typename... Args> inline void sc(T &num, Args &...args) { bool neg = 0; int c; num = 0; while (c = getchar_unlocked(), c < 33) { ; } if (c == '-') { neg = 1; c = getchar_unlocked(); } for (; c > 47; c = getchar_unlocked()) num = num * 10 + c - 48; if (neg) num *= -1; sc(args...); } template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; // s.find_by_order(), // s.order_of_key() <- works like // lower_bound template <typename T> using ordered_map = tree<T, int, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define N 1000001 int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, a, b, c, d; sc(n, a, b, c, d); string s; getstr(s); --a, --b, --c, --d; bool k = 1; FORR(i, s) i = i == '#'; // isrock FOR(i, a, c - 1) { if (s[i] && s[i + 1]) { k = 0; break; } } FOR(i, b, d - 1) { if (s[i] && s[i + 1]) { k = 0; break; } } if (d < c) { bool hm = 0; for (int i = b - 1; i < d; ++i) { // od pola przed pozycja b if ((s[i] || s[i + 1] || s[i + 2]) == 0) { hm = 1; } } if (!hm) k = 0; } cout << (k ? "Yes" : "No"); }
[ "identifier.change", "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "expression.operation.binary.remove", "literal.string.change", "literal.string.case.change", "io.output.change" ]
831,215
831,213
u761407600
cpp
p03017
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b, c, d; string s; bool match = true; cin >> n >> a >> b >> c >> d >> s; a--; b--; c--; d--; for (int i = a; i < max(c, d); i++) { if (s[i] == '#' && s[i + 1] == '#') match = false; } if (c > d) { for (int i = b - 1; i < d + 2; i++) { if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') { match = true; break; } match = false; } } if (match) cout << "Yes"; else cout << "No"; }
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b, c, d; string s; bool match = true; cin >> n >> a >> b >> c >> d >> s; a--; b--; c--; d--; for (int i = a; i < max(c, d); i++) { if (s[i] == '#' && s[i + 1] == '#') match = false; } if (c > d) { for (int i = b; i <= d; i++) { if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') { match = true; break; } match = false; } } if (match) cout << "Yes"; else cout << "No"; }
[ "control_flow.loop.for.initializer.change", "expression.operation.binary.remove", "expression.operator.compare.change", "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change" ]
831,216
831,217
u710135612
cpp
p03017
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b, c, d; string s; bool match = true; cin >> n >> a >> b >> c >> d >> s; a--; b--; c--; d--; for (int i = a; i < max(c, d); i++) { if (s[i] == '#' && s[i + 1] == '#') match = false; } if (c > d) { for (int i = b; i < d; i++) { if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') { match = true; break; } match = false; } } if (match) cout << "Yes"; else cout << "No"; }
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b, c, d; string s; bool match = true; cin >> n >> a >> b >> c >> d >> s; a--; b--; c--; d--; for (int i = a; i < max(c, d); i++) { if (s[i] == '#' && s[i + 1] == '#') match = false; } if (c > d) { for (int i = b; i <= d; i++) { if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') { match = true; break; } match = false; } } if (match) cout << "Yes"; else cout << "No"; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
831,219
831,217
u710135612
cpp
p03017
#include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <cstdlib> #include <cstring> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string> #include <vector> using namespace std; typedef unsigned long long ull; typedef long long ll; string s; bool check1(int l, int r) { for (int i = l; i + 1 < r; i++) { if (s[i] == '#' && s[i + 1] == '#') { return false; } } return true; } bool check2(int l, int r) { for (int i = l; i + 2 < r; i++) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { return true; } } return false; } int main() { int n, a, b, c, d; cin >> n >> a >> b >> c >> d >> s; a--; b--; c--; d--; bool bl; if (d < c) { bl = check1(a, c) & check2(b, d); } else { bl = check1(a, c) & check1(b, d); } if (bl) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
#include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <cstdlib> #include <cstring> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string> #include <vector> using namespace std; typedef unsigned long long ull; typedef long long ll; string s; bool check1(int l, int r) { for (int i = l; i + 1 < r; i++) { if (s[i] == '#' && s[i + 1] == '#') { return false; } } return true; } bool check2(int l, int r) { for (int i = l - 1; i + 1 <= r; i++) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { return true; } } return false; } int main() { int n, a, b, c, d; cin >> n >> a >> b >> c >> d >> s; a--; b--; c--; d--; bool bl; if (d < c) { bl = check1(a, c) & check2(b, d); } else { bl = check1(a, c) & check1(b, d); } if (bl) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
[ "control_flow.loop.for.initializer.change", "control_flow.loop.for.condition.change" ]
831,225
831,227
u348670055
cpp
p03017
#include <bits/stdc++.h> using namespace std; #define watch(x) cerr << (#x) << ": " << (x) << endl bool bad(int a, int c, string s) { int cnt = 0; for (int i = a; i < c; ++i) { if (s[i] == '#') cnt++; else cnt = 0; if (cnt == 2) return true; } return false; } bool criss(int a, int c, string s) { int cnt = 0; a -= 2; for (int i = a; i < c; ++i) { if (s[i] == '.') cnt++; else cnt = 0; if (cnt == 3) return false; } return true; } bool solve(int n, string s, int a, int b, int c, int d) { if (bad(a, c, s) || bad(b, d, s)) return false; if (d > c && b < a) { if (criss(a, c, s)) return false; } if (c > d && a < b) { if (criss(b, d, s)) return false; } return true; } int32_t main() { int n, a, b, c, d; cin >> n >> a >> b >> c >> d; string s; cin >> s; bool ans = solve(n, s, a, b, c, d); if (ans) cout << "Yes\n"; else cout << "No\n"; return 0; }
#include <bits/stdc++.h> using namespace std; #define watch(x) cerr << (#x) << ": " << (x) << endl bool bad(int a, int c, string s) { int cnt = 0; for (int i = a; i < c; ++i) { if (s[i] == '#') cnt++; else cnt = 0; if (cnt == 2) return true; } return false; } bool criss(int a, int c, string s) { int cnt = 0; a -= 2; c++; for (int i = a; i < c; ++i) { if (s[i] == '.') cnt++; else cnt = 0; if (cnt == 3) return false; } return true; } bool solve(int n, string s, int a, int b, int c, int d) { if (bad(a, c, s) || bad(b, d, s)) return false; if (d > c && b < a) { if (criss(a, c, s)) return false; } if (c > d && a < b) { if (criss(b, d, s)) return false; } return true; } int32_t main() { int n, a, b, c, d; cin >> n >> a >> b >> c >> d; string s; cin >> s; bool ans = solve(n, s, a, b, c, d); if (ans) cout << "Yes\n"; else cout << "No\n"; return 0; }
[ "expression.unary.arithmetic.add" ]
831,228
831,229
u455309216
cpp
p03017
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define T_ template #define Tn typename T_<Tn T> inline bool cmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; } T_<Tn T> inline bool cmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; } T_<Tn L, Tn R> ostream &operator<<(ostream &out, pair<L, R> t) { return out << "(" << t.first << "," << t.second << ")"; } T_<Tn T> ostream &operator<<(ostream &out, vector<T> t) { for (unsigned i = 0; i < t.size(); i++) out << (" ("[!i]) << t[i] << (",)"[i == t.size() - 1]); return out; } T_<Tn T> inline void read(T &x) { x = 0; char ch; while (!isdigit(ch = getchar())) ; while (isdigit(ch)) { x = x * 10 + ch - '0'; ch = getchar(); } } const int MaxN = 200010; int n, a, b, c, d; char s[MaxN]; int main() { read(n); read(a); read(b); read(c); read(d); scanf("%s", s + 1); for (int p = a; p < c; p++) if (s[p] == '#' && s[p + 1] == '#') { puts("No"); return 0; } for (int p = b; p < d; p++) if (s[p] == '#' && s[p + 1] == '#') { puts("No"); return 0; } if (c < d) return puts("Yes"), 0; if (c > d) { for (int p = b; p < d; p++) if (s[p] == '.' && s[p - 1] == '.' && s[p + 1] == '.') { puts("Yes"); return 0; } puts("No"); } return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define T_ template #define Tn typename T_<Tn T> inline bool cmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; } T_<Tn T> inline bool cmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; } T_<Tn L, Tn R> ostream &operator<<(ostream &out, pair<L, R> t) { return out << "(" << t.first << "," << t.second << ")"; } T_<Tn T> ostream &operator<<(ostream &out, vector<T> t) { for (unsigned i = 0; i < t.size(); i++) out << (" ("[!i]) << t[i] << (",)"[i == t.size() - 1]); return out; } T_<Tn T> inline void read(T &x) { x = 0; char ch; while (!isdigit(ch = getchar())) ; while (isdigit(ch)) { x = x * 10 + ch - '0'; ch = getchar(); } } const int MaxN = 200010; int n, a, b, c, d; char s[MaxN]; int main() { read(n); read(a); read(b); read(c); read(d); scanf("%s", s + 1); for (int p = a; p < c; p++) if (s[p] == '#' && s[p + 1] == '#') { puts("No"); return 0; } for (int p = b; p < d; p++) if (s[p] == '#' && s[p + 1] == '#') { puts("No"); return 0; } if (c < d) return puts("Yes"), 0; if (c > d) { for (int p = b; p <= d; p++) if (s[p] == '.' && s[p - 1] == '.' && s[p + 1] == '.') { puts("Yes"); return 0; } puts("No"); } return 0; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
831,240
831,241
u890171625
cpp
p03017
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define T_ template #define Tn typename T_<Tn T> inline bool cmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; } T_<Tn T> inline bool cmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; } T_<Tn L, Tn R> ostream &operator<<(ostream &out, pair<L, R> t) { return out << "(" << t.first << "," << t.second << ")"; } T_<Tn T> ostream &operator<<(ostream &out, vector<T> t) { for (unsigned i = 0; i < t.size(); i++) out << (" ("[!i]) << t[i] << (",)"[i == t.size() - 1]); return out; } T_<Tn T> inline void read(T &x) { x = 0; char ch; while (!isdigit(ch = getchar())) ; while (isdigit(ch)) { x = x * 10 + ch - '0'; ch = getchar(); } } const int MaxN = 200010; int n, a, b, c, d; char s[MaxN]; int main() { read(n); read(a); read(b); read(c); read(d); scanf("%s", s + 1); for (int p = a; p < c; p++) if (s[p] == '#' && s[p + 1] == '#') { puts("No"); return 0; } for (int p = b; p < d; p++) if (s[p] == '#' && s[p + 1] == '#') { puts("No"); return 0; } if (c < d) return puts("Yes"), 0; if (c > d) { for (int p = b; p < c; p++) if (s[p] == '.' && s[p - 1] == '.' && s[p + 1] == '.') { puts("Yes"); return 0; } puts("No"); } return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define T_ template #define Tn typename T_<Tn T> inline bool cmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; } T_<Tn T> inline bool cmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; } T_<Tn L, Tn R> ostream &operator<<(ostream &out, pair<L, R> t) { return out << "(" << t.first << "," << t.second << ")"; } T_<Tn T> ostream &operator<<(ostream &out, vector<T> t) { for (unsigned i = 0; i < t.size(); i++) out << (" ("[!i]) << t[i] << (",)"[i == t.size() - 1]); return out; } T_<Tn T> inline void read(T &x) { x = 0; char ch; while (!isdigit(ch = getchar())) ; while (isdigit(ch)) { x = x * 10 + ch - '0'; ch = getchar(); } } const int MaxN = 200010; int n, a, b, c, d; char s[MaxN]; int main() { read(n); read(a); read(b); read(c); read(d); scanf("%s", s + 1); for (int p = a; p < c; p++) if (s[p] == '#' && s[p + 1] == '#') { puts("No"); return 0; } for (int p = b; p < d; p++) if (s[p] == '#' && s[p + 1] == '#') { puts("No"); return 0; } if (c < d) return puts("Yes"), 0; if (c > d) { for (int p = b; p <= d; p++) if (s[p] == '.' && s[p - 1] == '.' && s[p + 1] == '.') { puts("Yes"); return 0; } puts("No"); } return 0; }
[ "control_flow.loop.for.condition.change" ]
831,242
831,241
u890171625
cpp
p03017
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define T_ template #define Tn typename T_<Tn T> inline bool cmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; } T_<Tn T> inline bool cmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; } T_<Tn L, Tn R> ostream &operator<<(ostream &out, pair<L, R> t) { return out << "(" << t.first << "," << t.second << ")"; } T_<Tn T> ostream &operator<<(ostream &out, vector<T> t) { for (unsigned i = 0; i < t.size(); i++) out << (" ("[!i]) << t[i] << (",)"[i == t.size() - 1]); return out; } T_<Tn T> inline void read(T &x) { x = 0; char ch; while (!isdigit(ch = getchar())) ; while (isdigit(ch)) { x = x * 10 + ch - '0'; ch = getchar(); } } const int MaxN = 200010; int n, a, b, c, d; char s[MaxN]; int main() { read(n); read(a); read(b); read(c); read(d); scanf("%s", s + 1); for (int p = a; p < c; p++) if (s[p] == '#' && s[p + 1] == '#') { puts("No"); return 0; } for (int p = b; p < d; p++) if (s[p] == '#' && s[p + 1] == '#') { puts("No"); return 0; } if (c < d) return puts("Yes"), 0; if (c > d) { for (int p = b; p <= c; p++) if (s[p] == '.' && s[p - 1] == '.' && s[p + 1] == '.') { puts("Yes"); return 0; } puts("No"); } return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define T_ template #define Tn typename T_<Tn T> inline bool cmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; } T_<Tn T> inline bool cmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; } T_<Tn L, Tn R> ostream &operator<<(ostream &out, pair<L, R> t) { return out << "(" << t.first << "," << t.second << ")"; } T_<Tn T> ostream &operator<<(ostream &out, vector<T> t) { for (unsigned i = 0; i < t.size(); i++) out << (" ("[!i]) << t[i] << (",)"[i == t.size() - 1]); return out; } T_<Tn T> inline void read(T &x) { x = 0; char ch; while (!isdigit(ch = getchar())) ; while (isdigit(ch)) { x = x * 10 + ch - '0'; ch = getchar(); } } const int MaxN = 200010; int n, a, b, c, d; char s[MaxN]; int main() { read(n); read(a); read(b); read(c); read(d); scanf("%s", s + 1); for (int p = a; p < c; p++) if (s[p] == '#' && s[p + 1] == '#') { puts("No"); return 0; } for (int p = b; p < d; p++) if (s[p] == '#' && s[p + 1] == '#') { puts("No"); return 0; } if (c < d) return puts("Yes"), 0; if (c > d) { for (int p = b; p <= d; p++) if (s[p] == '.' && s[p - 1] == '.' && s[p + 1] == '.') { puts("Yes"); return 0; } puts("No"); } return 0; }
[ "identifier.change", "control_flow.branch.if.condition.change" ]
831,243
831,241
u890171625
cpp
p03017
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define T_ template #define Tn typename T_<Tn T> inline bool cmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; } T_<Tn T> inline bool cmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; } T_<Tn L, Tn R> ostream &operator<<(ostream &out, pair<L, R> t) { return out << "(" << t.first << "," << t.second << ")"; } T_<Tn T> ostream &operator<<(ostream &out, vector<T> t) { for (unsigned i = 0; i < t.size(); i++) out << (" ("[!i]) << t[i] << (",)"[i == t.size() - 1]); return out; } T_<Tn T> inline void read(T &x) { x = 0; char ch; while (!isdigit(ch = getchar())) ; while (isdigit(ch)) { x = x * 10 + ch - '0'; ch = getchar(); } } const int MaxN = 200010; int n, a, b, c, d; char s[MaxN]; int main() { read(n); read(a); read(b); read(c); read(d); scanf("%s", s + 1); for (int p = a; p < c; p++) if (s[p] == '#' && s[p + 1] == '#') { puts("No"); return 0; } for (int p = b; p < d; p++) if (s[p] == '#' && s[p + 1] == '#') { puts("No"); return 0; } if (c < d) return puts("Yes"), 0; if (c > d) { for (int p = b + 1; p < c; p++) if (s[p] == '.' && s[p - 1] == '.' && s[p + 1] == '.') { puts("Yes"); return 0; } puts("No"); } return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define T_ template #define Tn typename T_<Tn T> inline bool cmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; } T_<Tn T> inline bool cmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; } T_<Tn L, Tn R> ostream &operator<<(ostream &out, pair<L, R> t) { return out << "(" << t.first << "," << t.second << ")"; } T_<Tn T> ostream &operator<<(ostream &out, vector<T> t) { for (unsigned i = 0; i < t.size(); i++) out << (" ("[!i]) << t[i] << (",)"[i == t.size() - 1]); return out; } T_<Tn T> inline void read(T &x) { x = 0; char ch; while (!isdigit(ch = getchar())) ; while (isdigit(ch)) { x = x * 10 + ch - '0'; ch = getchar(); } } const int MaxN = 200010; int n, a, b, c, d; char s[MaxN]; int main() { read(n); read(a); read(b); read(c); read(d); scanf("%s", s + 1); for (int p = a; p < c; p++) if (s[p] == '#' && s[p + 1] == '#') { puts("No"); return 0; } for (int p = b; p < d; p++) if (s[p] == '#' && s[p + 1] == '#') { puts("No"); return 0; } if (c < d) return puts("Yes"), 0; if (c > d) { for (int p = b; p <= d; p++) if (s[p] == '.' && s[p - 1] == '.' && s[p + 1] == '.') { puts("Yes"); return 0; } puts("No"); } return 0; }
[ "control_flow.loop.for.initializer.change", "expression.operation.binary.remove", "control_flow.loop.for.condition.change" ]
831,244
831,241
u890171625
cpp
p03017
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define T_ template #define Tn typename T_<Tn T> inline bool cmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; } T_<Tn T> inline bool cmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; } T_<Tn L, Tn R> ostream &operator<<(ostream &out, pair<L, R> t) { return out << "(" << t.first << "," << t.second << ")"; } T_<Tn T> ostream &operator<<(ostream &out, vector<T> t) { for (unsigned i = 0; i < t.size(); i++) out << (" ("[!i]) << t[i] << (",)"[i == t.size() - 1]); return out; } T_<Tn T> inline void read(T &x) { x = 0; char ch; while (!isdigit(ch = getchar())) ; while (isdigit(ch)) { x = x * 10 + ch - '0'; ch = getchar(); } } const int MaxN = 200010; int n, a, b, c, d; char s[MaxN]; int main() { read(n); read(a); read(b); read(c); read(d); scanf("%s", s + 1); for (int p = a; p < b; p++) if (s[p] == '#' && s[p + 1] == '#') { puts("No"); return 0; } for (int p = c; p < d; p++) if (s[p] == '#' && s[p + 1] == '#') { puts("No"); return 0; } if (c < d) return puts("Yes"), 0; if (c > d) { for (int p = b + 1; p < c; p++) if (s[p] == '.' && s[p - 1] == '.' && s[p + 1] == '.') { puts("Yes"); return 0; } puts("No"); } return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define T_ template #define Tn typename T_<Tn T> inline bool cmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; } T_<Tn T> inline bool cmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; } T_<Tn L, Tn R> ostream &operator<<(ostream &out, pair<L, R> t) { return out << "(" << t.first << "," << t.second << ")"; } T_<Tn T> ostream &operator<<(ostream &out, vector<T> t) { for (unsigned i = 0; i < t.size(); i++) out << (" ("[!i]) << t[i] << (",)"[i == t.size() - 1]); return out; } T_<Tn T> inline void read(T &x) { x = 0; char ch; while (!isdigit(ch = getchar())) ; while (isdigit(ch)) { x = x * 10 + ch - '0'; ch = getchar(); } } const int MaxN = 200010; int n, a, b, c, d; char s[MaxN]; int main() { read(n); read(a); read(b); read(c); read(d); scanf("%s", s + 1); for (int p = a; p < c; p++) if (s[p] == '#' && s[p + 1] == '#') { puts("No"); return 0; } for (int p = b; p < d; p++) if (s[p] == '#' && s[p + 1] == '#') { puts("No"); return 0; } if (c < d) return puts("Yes"), 0; if (c > d) { for (int p = b; p <= d; p++) if (s[p] == '.' && s[p - 1] == '.' && s[p + 1] == '.') { puts("Yes"); return 0; } puts("No"); } return 0; }
[ "identifier.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.operation.binary.remove" ]
831,245
831,241
u890171625
cpp
p03017
#include <cstdio> #include <iostream> using namespace std; int n, a, b, c, d; string s; int main() { cin >> n >> a >> b >> c >> d >> s; s = '-' + s; for (int i = a; i < c - 1; i++) { if (s[i] == '#' && s[i + 1] == '#') { puts("No"); return 0; } } for (int i = b; i < d - 1; i++) { if (s[i] == '#' && s[i + 1] == '#') { puts("No"); return 0; } } if (c < d) { puts("Yes"); return 0; } else { for (int i = b; i < d - 1; i++) { if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') { { puts("Yes"); return 0; } } } puts("No"); return 0; } }
#include <cstdio> #include <iostream> using namespace std; int n, a, b, c, d; string s; int main() { cin >> n >> a >> b >> c >> d >> s; s = '-' + s; for (int i = a; i < c - 1; i++) { if (s[i] == '#' && s[i + 1] == '#') { puts("No"); return 0; } } for (int i = b; i < d - 1; i++) { if (s[i] == '#' && s[i + 1] == '#') { puts("No"); return 0; } } if (c < d) { puts("Yes"); return 0; } else { for (int i = b; i <= d; i++) { if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') { { puts("Yes"); return 0; } } } puts("No"); return 0; } }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
831,256
831,258
u093170535
cpp
p03017
// Copyright: lzt #include <algorithm> #include <cmath> #include <cstdlib> #include <cstring> #include <ctime> #include <iostream> #include <map> #include <queue> #include <set> #include <stdio.h> #include <string> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef long double ld; typedef unsigned long long ull; typedef pair<long long, long long> pll; #define fi first #define se second #define pb push_back #define mp make_pair #define rep(i, j, k) for (register int i = (int)(j); i <= (int)(k); i++) #define rrep(i, j, k) for (register int i = (int)(j); i >= (int)(k); i--) #define Debug(...) fprintf(stderr, __VA_ARGS__) ll read() { ll 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 * 10 + c - '0'; c = getchar(); } return x * f; } const int maxn = 200200; int n, a, b, c, d; char s[maxn]; void work() { n = read(), a = read(), b = read(), c = read(), d = read(); scanf("%s", s + 1); rep(i, a, c - 1) if (s[i] == '#' && s[i + 1] == '#') { puts("No"); return; } rep(i, b, d - 1) if (s[i] == '#' && s[i + 1] == '#') { puts("No"); return; } if (c > d) { rep(i, b, d - 2) if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { puts("Yes"); return; } puts("No"); return; } puts("Yes"); } int main() { #ifdef LZT freopen("in", "r", stdin); #endif work(); #ifdef LZT Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC); #endif }
// Copyright: lzt #include <algorithm> #include <cmath> #include <cstdlib> #include <cstring> #include <ctime> #include <iostream> #include <map> #include <queue> #include <set> #include <stdio.h> #include <string> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef long double ld; typedef unsigned long long ull; typedef pair<long long, long long> pll; #define fi first #define se second #define pb push_back #define mp make_pair #define rep(i, j, k) for (register int i = (int)(j); i <= (int)(k); i++) #define rrep(i, j, k) for (register int i = (int)(j); i >= (int)(k); i--) #define Debug(...) fprintf(stderr, __VA_ARGS__) ll read() { ll 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 * 10 + c - '0'; c = getchar(); } return x * f; } const int maxn = 200200; int n, a, b, c, d; char s[maxn]; void work() { n = read(), a = read(), b = read(), c = read(), d = read(); scanf("%s", s + 1); rep(i, a, c - 1) if (s[i] == '#' && s[i + 1] == '#') { puts("No"); return; } rep(i, b, d - 1) if (s[i] == '#' && s[i + 1] == '#') { puts("No"); return; } if (c > d) { rep(i, b - 1, d - 1) if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { puts("Yes"); return; } puts("No"); return; } puts("Yes"); } int main() { #ifdef LZT freopen("in", "r", stdin); #endif work(); #ifdef LZT Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC); #endif }
[ "literal.number.change", "call.arguments.change", "expression.operation.binary.change" ]
831,261
831,262
u357800105
cpp
p03017
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <utility> #include <vector> using lli = long long int; int inf = 1000000007; using namespace std; int N, A, B, C, D; string S; int main() { cin >> N >> A >> B >> C >> D; cin >> S; for (int i = A - 1; i < C; i++) if (S[i] == '#' && S[i] == S[i + 1]) { cout << "No" << endl; return 0; } for (int i = B - 1; i < D; i++) if (S[i] == '#' && S[i] == S[i + 1]) { cout << "No" << endl; return 0; } //交差するか if (C < D) { //しない cout << "Yes" << endl; return 0; } // A- B-D - C みたいなとき // A-Dの間で[...]があれば入れ替え可能 for (int i = B - 1; i <= D - 2; i++) if (S[i] == '.' && S[i] == S[i + 1] && S[i] == S[i + 2]) { cout << "Yes" << endl; return 0; } // cout << la << " " << ra << endl; cout << "No" << endl; }
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <utility> #include <vector> using lli = long long int; int inf = 1000000007; using namespace std; int N, A, B, C, D; string S; int main() { cin >> N >> A >> B >> C >> D; cin >> S; for (int i = A - 1; i < C; i++) if (S[i] == '#' && S[i] == S[i + 1]) { cout << "No" << endl; return 0; } for (int i = B - 1; i < D; i++) if (S[i] == '#' && S[i] == S[i + 1]) { cout << "No" << endl; return 0; } //交差するか if (C < D) { //しない cout << "Yes" << endl; return 0; } // A- B-D - C みたいなとき // A-Dの間で[...]があれば入れ替え可能 for (int i = B - 2; i <= D - 2; i++) if (S[i] == '.' && S[i] == S[i + 1] && S[i] == S[i + 2]) { cout << "Yes" << endl; return 0; } // cout << la << " " << ra << endl; cout << "No" << endl; }
[ "literal.number.change", "control_flow.loop.for.initializer.change", "expression.off_by_one", "expression.operation.binary.change" ]
831,268
831,269
u134381136
cpp
p03017
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <utility> #include <vector> using lli = long long int; int inf = 1000000007; using namespace std; int N, A, B, C, D; string S; int main() { cin >> N >> A >> B >> C >> D; cin >> S; for (int i = A - 1; i < C; i++) if (S[i] == '#' && S[i] == S[i + 1]) { cout << "No" << endl; return 0; } for (int i = B - 1; i < D; i++) if (S[i] == '#' && S[i] == S[i + 1]) { cout << "No" << endl; return 0; } //交差するか if (C < D) { //しない cout << "Yes" << endl; return 0; } // A- B-D - C みたいなとき // A-Dの間で[...]があれば入れ替え可能 for (int i = A - 1; i <= D - 2; i++) if (S[i] == '.' && S[i] == S[i + 1] && S[i] == S[i + 2]) { cout << "Yes" << endl; return 0; } // cout << la << " " << ra << endl; cout << "No" << endl; }
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <utility> #include <vector> using lli = long long int; int inf = 1000000007; using namespace std; int N, A, B, C, D; string S; int main() { cin >> N >> A >> B >> C >> D; cin >> S; for (int i = A - 1; i < C; i++) if (S[i] == '#' && S[i] == S[i + 1]) { cout << "No" << endl; return 0; } for (int i = B - 1; i < D; i++) if (S[i] == '#' && S[i] == S[i + 1]) { cout << "No" << endl; return 0; } //交差するか if (C < D) { //しない cout << "Yes" << endl; return 0; } // A- B-D - C みたいなとき // A-Dの間で[...]があれば入れ替え可能 for (int i = B - 2; i <= D - 2; i++) if (S[i] == '.' && S[i] == S[i + 1] && S[i] == S[i + 2]) { cout << "Yes" << endl; return 0; } // cout << la << " " << ra << endl; cout << "No" << endl; }
[ "identifier.change", "control_flow.loop.for.initializer.change", "expression.operation.binary.change", "literal.number.change", "expression.off_by_one" ]
831,270
831,269
u134381136
cpp
p03017
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <utility> #include <vector> using lli = long long int; int inf = 1000000007; using namespace std; int N, A, B, C, D; string S; int main() { cin >> N >> A >> B >> C >> D; cin >> S; for (int i = A - 1; i < C; i++) if (S[i] == '#' && S[i] == S[i + 1]) { cout << "No" << endl; return 0; } for (int i = B - 1; i < D; i++) if (S[i] == '#' && S[i] == S[i + 1]) { cout << "No" << endl; return 0; } //交差するか if (C < D) { //しない cout << "Yes" << endl; return 0; } // A- B-D - C みたいなとき // A-Dの間で[...]があれば入れ替え可能 for (int i = A - 1; i < D - 2; i++) if (S[i] == '.' && S[i] == S[i + 1] && S[i] == S[i + 2]) { cout << "Yes" << endl; return 0; } // cout << la << " " << ra << endl; cout << "No" << endl; }
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <utility> #include <vector> using lli = long long int; int inf = 1000000007; using namespace std; int N, A, B, C, D; string S; int main() { cin >> N >> A >> B >> C >> D; cin >> S; for (int i = A - 1; i < C; i++) if (S[i] == '#' && S[i] == S[i + 1]) { cout << "No" << endl; return 0; } for (int i = B - 1; i < D; i++) if (S[i] == '#' && S[i] == S[i + 1]) { cout << "No" << endl; return 0; } //交差するか if (C < D) { //しない cout << "Yes" << endl; return 0; } // A- B-D - C みたいなとき // A-Dの間で[...]があれば入れ替え可能 for (int i = B - 2; i <= D - 2; i++) if (S[i] == '.' && S[i] == S[i + 1] && S[i] == S[i + 2]) { cout << "Yes" << endl; return 0; } // cout << la << " " << ra << endl; cout << "No" << endl; }
[ "identifier.change", "control_flow.loop.for.initializer.change", "expression.operation.binary.change", "literal.number.change", "expression.off_by_one", "expression.operator.compare.change", "control_flow.loop.for.condition.change" ]
831,271
831,269
u134381136
cpp
p03017
#include <bits/stdc++.h> using namespace std; using i64 = long long; int main() { int n, a, b, c, d; string s; bool ans = true; cin >> n >> a >> b >> c >> d >> s; for (int i = a - 1; i < max(c, d) - 1; i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } } if (c > d) { ans = false; for (int i = b - 2; i < min(c, d) - 2; i++) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') ans = true; } } if (ans) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using i64 = long long; int main() { int n, a, b, c, d; string s; bool ans = true; cin >> n >> a >> b >> c >> d >> s; for (int i = a - 1; i < max(c, d) - 1; i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } } if (c > d) { ans = false; for (int i = b - 2; i < min(c, d) - 1; i++) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') ans = true; } } if (ans) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
[ "literal.number.change", "control_flow.branch.if.condition.change" ]
831,280
831,281
u366245083
cpp
p03017
#include <bits/stdc++.h> using namespace std; using i64 = long long; int main() { int n, a, b, c, d; string s; bool ans = true; cin >> n >> a >> b >> c >> d >> s; for (int i = a - 1; i < max(c, d) - 1; i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } } if (c > d) { ans = false; for (int i = b - 1; i < max(c, d) - 2; i++) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') ans = true; } } if (ans) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using i64 = long long; int main() { int n, a, b, c, d; string s; bool ans = true; cin >> n >> a >> b >> c >> d >> s; for (int i = a - 1; i < max(c, d) - 1; i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } } if (c > d) { ans = false; for (int i = b - 2; i < min(c, d) - 1; i++) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') ans = true; } } if (ans) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
[ "literal.number.change", "control_flow.loop.for.initializer.change", "expression.off_by_one", "expression.operation.binary.change", "misc.opposites", "identifier.change", "call.function.change", "control_flow.branch.if.condition.change" ]
831,283
831,281
u366245083
cpp
p03017
#include <bits/stdc++.h> using namespace std; using i64 = long long; int main() { int n, a, b, c, d; string s; bool ans = true; cin >> n >> a >> b >> c >> d >> s; for (int i = a - 1; i < max(c, d) - 1; i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } } if (c > d) { ans = false; for (int i = a - 1; i < max(c, d) - 2; i++) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') ans = true; } } if (ans) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using i64 = long long; int main() { int n, a, b, c, d; string s; bool ans = true; cin >> n >> a >> b >> c >> d >> s; for (int i = a - 1; i < max(c, d) - 1; i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } } if (c > d) { ans = false; for (int i = b - 2; i < min(c, d) - 1; i++) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') ans = true; } } if (ans) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
[ "identifier.change", "control_flow.loop.for.initializer.change", "expression.operation.binary.change", "literal.number.change", "expression.off_by_one", "misc.opposites", "call.function.change", "control_flow.branch.if.condition.change" ]
831,284
831,281
u366245083
cpp
p03017
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007LL; long long GCD(long long a, long long b) { return b == 0 ? a : GCD(b, a % b); } int main() { cin.sync_with_stdio(0); cin.tie(0); cout.tie(0); // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); int n, a, b, c, d; string e; cin >> n >> a >> b >> c >> d >> e; --a; --b; --c; --d; for (int i = a; i <= c; ++i) { if (e[i] == e[i - 1] && e[i] == '#') { cout << "No"; return 0; } } for (int i = b; i <= d; ++i) { if (e[i] == e[i - 1] && e[i] == '#') { cout << "No"; return 0; } } if ((a < b && c > d) || (b < a && c < d)) { for (int i = max(a, b) - 1; i < min(c, d) + 1; ++i) { if (e[i] == '.' && e[i + 1] == '.' && e[i + 2] == '.') { cout << "Yes"; return 0; } } cout << "No"; return 0; } cout << "Yes"; return 0; }
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007LL; long long GCD(long long a, long long b) { return b == 0 ? a : GCD(b, a % b); } int main() { cin.sync_with_stdio(0); cin.tie(0); cout.tie(0); // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); int n, a, b, c, d; string e; cin >> n >> a >> b >> c >> d >> e; --a; --b; --c; --d; for (int i = a; i <= c; ++i) { if (e[i] == e[i - 1] && e[i] == '#') { cout << "No"; return 0; } } for (int i = b; i <= d; ++i) { if (e[i] == e[i - 1] && e[i] == '#') { cout << "No"; return 0; } } if ((a < b && c > d) || (b < a && c < d)) { for (int i = max(a, b) - 1; i < min(c, d); ++i) { if (e[i] == '.' && e[i + 1] == '.' && e[i + 2] == '.') { cout << "Yes"; return 0; } } cout << "No"; return 0; } cout << "Yes"; return 0; }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
831,285
831,286
u276568758
cpp
p03017
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007LL; long long GCD(long long a, long long b) { return b == 0 ? a : GCD(b, a % b); } int main() { cin.sync_with_stdio(0); cin.tie(0); cout.tie(0); // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); int n, a, b, c, d; string e; cin >> n >> a >> b >> c >> d >> e; --a; --b; --c; --d; for (int i = a; i <= c; ++i) { if (e[i] == e[i - 1] && e[i] == '#') { cout << "No"; return 0; } } for (int i = b; i <= d; ++i) { if (e[i] == e[i - 1] && e[i] == '#') { cout << "No"; return 0; } } if ((a < b && c > d) || (b < a && c < d)) { for (int i = max(a, b) - 1; i < min(c, d) - 1; ++i) { if (e[i] == '.' && e[i + 1] == '.' && e[i + 2] == '.') { cout << "Yes"; return 0; } } cout << "No"; return 0; } cout << "Yes"; return 0; }
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007LL; long long GCD(long long a, long long b) { return b == 0 ? a : GCD(b, a % b); } int main() { cin.sync_with_stdio(0); cin.tie(0); cout.tie(0); // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); int n, a, b, c, d; string e; cin >> n >> a >> b >> c >> d >> e; --a; --b; --c; --d; for (int i = a; i <= c; ++i) { if (e[i] == e[i - 1] && e[i] == '#') { cout << "No"; return 0; } } for (int i = b; i <= d; ++i) { if (e[i] == e[i - 1] && e[i] == '#') { cout << "No"; return 0; } } if ((a < b && c > d) || (b < a && c < d)) { for (int i = max(a, b) - 1; i < min(c, d); ++i) { if (e[i] == '.' && e[i + 1] == '.' && e[i + 2] == '.') { cout << "Yes"; return 0; } } cout << "No"; return 0; } cout << "Yes"; return 0; }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
831,287
831,286
u276568758
cpp
p03017
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007LL; long long GCD(long long a, long long b) { return b == 0 ? a : GCD(b, a % b); } int main() { cin.sync_with_stdio(0); cin.tie(0); cout.tie(0); // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); int n, a, b, c, d; string e; cin >> n >> a >> b >> c >> d >> e; --a; --b; --c; --d; for (int i = a; i <= c; ++i) { if (e[i] == e[i - 1] && e[i] == '#') { cout << "No"; return 0; } } for (int i = b; i <= d; ++i) { if (e[i] == e[i - 1] && e[i] == '#') { cout << "No"; return 0; } } if ((a < b && c > d) || (b < a && c < d)) { for (int i = min(a, b) - 1; i < min(c, d) - 1; ++i) { if (e[i] == '.' && e[i + 1] == '.' && e[i + 2] == '.') { cout << "Yes"; return 0; } } cout << "No"; return 0; } cout << "Yes"; return 0; }
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007LL; long long GCD(long long a, long long b) { return b == 0 ? a : GCD(b, a % b); } int main() { cin.sync_with_stdio(0); cin.tie(0); cout.tie(0); // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); int n, a, b, c, d; string e; cin >> n >> a >> b >> c >> d >> e; --a; --b; --c; --d; for (int i = a; i <= c; ++i) { if (e[i] == e[i - 1] && e[i] == '#') { cout << "No"; return 0; } } for (int i = b; i <= d; ++i) { if (e[i] == e[i - 1] && e[i] == '#') { cout << "No"; return 0; } } if ((a < b && c > d) || (b < a && c < d)) { for (int i = max(a, b) - 1; i < min(c, d); ++i) { if (e[i] == '.' && e[i + 1] == '.' && e[i + 2] == '.') { cout << "Yes"; return 0; } } cout << "No"; return 0; } cout << "Yes"; return 0; }
[ "misc.opposites", "identifier.change", "call.function.change", "control_flow.loop.for.initializer.change", "expression.operation.binary.change", "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
831,288
831,286
u276568758
cpp
p03017
#include <bits/stdc++.h> #define syosu(x) fixed << setprecision(x) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> P; typedef pair<double, double> pdd; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<double> vd; typedef vector<vd> vvd; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<string> vs; typedef vector<P> vp; typedef vector<vp> vvp; typedef vector<pll> vpll; typedef pair<int, P> pip; typedef vector<pip> vip; const int inf = 1 << 30; const ll INF = 1ll << 60; const double pi = acos(-1); const double eps = 1e-8; const ll mod = 1e9 + 7; const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, -1, 0, 1}; int n, a, b, c, d; string s; int main() { cin >> n >> a >> b >> c >> d >> s; bool B = 1; for (int i = a - 1; i < c - 1; i++) if (s[i] == '#' && s[i + 1] == '#') B = 0; for (int i = b - 1; i < d - 1; i++) if (s[i] == '#' && s[i + 1] == '#') B = 0; if (c > d) { bool B_ = 0; for (int i = c - 1; i < d; i++) if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') B_ = 1; B &= B_; } cout << (B ? "Yes" : "No") << endl; }
#include <bits/stdc++.h> #define syosu(x) fixed << setprecision(x) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> P; typedef pair<double, double> pdd; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<double> vd; typedef vector<vd> vvd; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<string> vs; typedef vector<P> vp; typedef vector<vp> vvp; typedef vector<pll> vpll; typedef pair<int, P> pip; typedef vector<pip> vip; const int inf = 1 << 30; const ll INF = 1ll << 60; const double pi = acos(-1); const double eps = 1e-8; const ll mod = 1e9 + 7; const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, -1, 0, 1}; int n, a, b, c, d; string s; int main() { cin >> n >> a >> b >> c >> d >> s; bool B = 1; for (int i = a - 1; i < c - 1; i++) if (s[i] == '#' && s[i + 1] == '#') B = 0; for (int i = b - 1; i < d - 1; i++) if (s[i] == '#' && s[i + 1] == '#') B = 0; if (c > d) { bool B_ = 0; for (int i = b - 1; i < d; i++) if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') B_ = 1; B &= B_; } cout << (B ? "Yes" : "No") << endl; }
[ "identifier.change", "control_flow.loop.for.initializer.change", "expression.operation.binary.change" ]
831,296
831,297
u434747175
cpp
p03017
#include <algorithm> #include <cmath> #include <cstdio> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vl; #define rep(var, n) for (int var = 0; var < (n); ++var) #define ALL(c) (c).begin(), (c).end() int main() { // int n, a, b, c, d; cin >> n >> a >> b >> c >> d; a--; b--; c--; d--; string s; cin >> s; for (int i = a; i < c; i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } } for (int i = b; i < d; i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } } if (d < c) { bool three = false; for (int i = b - 1; i <= c - 1; i++) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { three = true; break; } } if (!three) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vl; #define rep(var, n) for (int var = 0; var < (n); ++var) #define ALL(c) (c).begin(), (c).end() int main() { // int n, a, b, c, d; cin >> n >> a >> b >> c >> d; a--; b--; c--; d--; string s; cin >> s; for (int i = a; i < c; i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } } for (int i = b; i < d; i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } } if (d < c) { bool three = false; for (int i = b - 1; i <= d - 1; i++) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { three = true; break; } } if (!three) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; return 0; }
[ "identifier.change", "control_flow.branch.if.condition.change" ]
831,298
831,300
u194385557
cpp
p03017
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b, c, d; string s; scanf("%d %d %d %d %d", &n, &a, &b, &c, &d); cin >> s; a--; b--; c--; d--; int x = 0, y = 0; int m = max(c, d); for (int i = a; i < m; i++) { if (s[i] == '#' && s[i + 1] == '#') { printf("No"); return 0; } } m = min(c, d); if (d < c) { int y = 0; for (int i = b; i < d; i++) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') y++; } if (y) printf("Yes"); else printf("No"); } else printf("Yes"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b, c, d; string s; scanf("%d %d %d %d %d", &n, &a, &b, &c, &d); cin >> s; a--; b--; c--; d--; int x = 0, y = 0; int m = max(c, d); for (int i = a; i < m; i++) { if (s[i] == '#' && s[i + 1] == '#') { printf("No"); return 0; } } m = min(c, d); if (d < c) { int y = 0; for (int i = b - 1; i < d; i++) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') y++; } if (y) printf("Yes"); else printf("No"); } else printf("Yes"); return 0; }
[ "control_flow.loop.for.initializer.change" ]
831,301
831,302
u717536011
cpp
p03017
#include "bits/stdc++.h" using namespace std; #define LL long long #define PB push_back #define MP make_pair int N, A, B, C, D; string S; int main() { cin >> N >> A >> B >> C >> D >> S; A--; B--; C--; D--; if (A > B) { swap(A, B); swap(C, D); } if (C < D) { for (int i = A; i < C; i++) { if (S[i] == '#' && S[i + 1] == '#') { cout << "No" << endl; return 0; } } for (int i = B; i < D; i++) { if (S[i] == '#' && S[i + 1] == '#') { cout << "No" << endl; return 0; } } cout << "Yes" << endl; } else { for (int i = A; i < C && i + 1 < N; i++) { if (S[i] == '#' && S[i + 1] == '#') { cout << "No" << endl; return 0; } } for (int i = D; i <= B && i + 1 < N; i++) { if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') { cout << "Yes" << endl; return 0; } } cout << "No" << endl; } }
#include "bits/stdc++.h" using namespace std; #define LL long long #define PB push_back #define MP make_pair int N, A, B, C, D; string S; int main() { cin >> N >> A >> B >> C >> D >> S; A--; B--; C--; D--; if (A > B) { swap(A, B); swap(C, D); } if (C < D) { for (int i = A; i < C; i++) { if (S[i] == '#' && S[i + 1] == '#') { cout << "No" << endl; return 0; } } for (int i = B; i < D; i++) { if (S[i] == '#' && S[i + 1] == '#') { cout << "No" << endl; return 0; } } cout << "Yes" << endl; } else { for (int i = A; i < C && i + 1 < N; i++) { if (S[i] == '#' && S[i + 1] == '#') { cout << "No" << endl; return 0; } } for (int i = B; i <= D && i + 1 < N; i++) { if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') { cout << "Yes" << endl; return 0; } } cout << "No" << endl; } }
[ "variable_declaration.value.change", "identifier.change", "control_flow.loop.for.initializer.change", "control_flow.branch.if.condition.change" ]
831,303
831,304
u422592877
cpp
p03017
#include <bits/stdc++.h> using namespace std; signed main() { string s; int n, sa, sb, ea, eb, end; cin >> n >> sa >> sb >> ea >> eb; cin >> s; s = s + "aaaa"; eb--; ea--; sa--; sb--; bool check = false; for (int i = sa; i < max(ea, eb); i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No"; return 0; } } if (eb > ea) cout << "Yes"; else if (eb < ea) { bool check = false; for (int i = sb; i <= eb; i++) { if (s[i] == s[i + 1] && s[i + 2] == s[i + 1] && s[i + 1] == '.') check = true; } if (check == true) cout << "Yes"; else cout << "No"; } }
#include <bits/stdc++.h> using namespace std; signed main() { string s; int n, sa, sb, ea, eb, end; cin >> n >> sa >> sb >> ea >> eb; cin >> s; s = s + "aaaa"; eb--; ea--; sa--; sb--; bool check = false; for (int i = sa; i < max(ea, eb); i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No"; return 0; } } if (eb > ea) cout << "Yes"; else if (eb < ea) { bool check = false; for (int i = sb - 1; i <= eb - 1; i++) { if (s[i] == s[i + 1] && s[i + 2] == s[i + 1] && s[i + 1] == '.') check = true; } if (check == true) cout << "Yes"; else cout << "No"; } }
[ "control_flow.loop.for.initializer.change", "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "misc.off_by_one" ]
831,306
831,307
u998997473
cpp
p03017
#include <bits/stdc++.h> using namespace std; signed main() { string s; int n, sa, sb, ea, eb, end; cin >> n >> sa >> sb >> ea >> eb; cin >> s; s = s + "aaaa"; eb--; ea--; sa--; sb--; bool check = false; for (int i = sa; i < max(ea, eb); i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No"; return 0; } } if (eb > ea) cout << "Yes"; else if (eb < ea) { bool check = false; for (int i = sb - 1; i <= eb; i++) { if (s[i] == s[i + 1] && s[i + 2] == s[i + 1] && s[i + 1] == '.') check = true; } if (check == true) cout << "Yes"; else cout << "No"; } }
#include <bits/stdc++.h> using namespace std; signed main() { string s; int n, sa, sb, ea, eb, end; cin >> n >> sa >> sb >> ea >> eb; cin >> s; s = s + "aaaa"; eb--; ea--; sa--; sb--; bool check = false; for (int i = sa; i < max(ea, eb); i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No"; return 0; } } if (eb > ea) cout << "Yes"; else if (eb < ea) { bool check = false; for (int i = sb - 1; i <= eb - 1; i++) { if (s[i] == s[i + 1] && s[i + 2] == s[i + 1] && s[i + 1] == '.') check = true; } if (check == true) cout << "Yes"; else cout << "No"; } }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "misc.off_by_one" ]
831,308
831,307
u998997473
cpp
p03017
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 50; int n; int a, b, c, d; string s; int cnt; int main() { cin >> n; cin >> a >> b >> c >> d; cin >> s; s = ' ' + s; if (c < d) { cnt = 0; for (int i = a; i <= d + 1; i++) { if (s[i] == s[i + 1] && s[i] == '#') { cnt++; break; } } if (cnt > 0) cout << "No"; else cout << "Yes"; } else { cnt = 0; for (int i = a; i <= c + 1; i++) { if (s[i] == s[i + 1] && s[i] == '#') { cnt++; break; } } if (cnt) { cout << "No"; } else { cnt = 0; for (int i = b - 1; i <= d; i++) { if (s[i] == s[i + 1] && s[i + 1] == s[i + 2] && s[i] == '.') { cnt++; break; } } if (cnt) cout << "Yes"; else cout << "No"; } } }
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 50; int n; int a, b, c, d; string s; int cnt; int main() { cin >> n; cin >> a >> b >> c >> d; cin >> s; s = ' ' + s; if (c < d) { cnt = 0; for (int i = a; i <= d; i++) { if (s[i] == s[i + 1] && s[i] == '#') { cnt++; break; } } if (cnt > 0) cout << "No"; else cout << "Yes"; } else { cnt = 0; for (int i = a; i <= c; i++) { if (s[i] == s[i + 1] && s[i] == '#') { cnt++; break; } } if (cnt) { cout << "No"; } else { cnt = 0; for (int i = b - 1; i <= d - 1; i++) { if (s[i] == s[i + 1] && s[i + 1] == s[i + 2] && s[i] == '.') { cnt++; break; } } if (cnt) cout << "Yes"; else cout << "No"; } } }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove", "control_flow.branch.if.condition.change", "misc.off_by_one" ]
831,315
831,316
u979516092
cpp
p03017
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 50; int n; int a, b, c, d; string s; int cnt; int main() { cin >> n; cin >> a >> b >> c >> d; cin >> s; s = ' ' + s; if (c < d) { cnt = 0; for (int i = a; i <= d; i++) { if (s[i] == s[i + 1] && s[i] == '#') { cnt++; break; } } if (cnt > 0) cout << "No"; else cout << "Yes"; } else { cnt = 0; for (int i = a; i <= c; i++) { if (s[i] == s[i + 1] && s[i] == '#') { cnt++; break; } } if (cnt) { cout << "No"; } else { cnt = 0; for (int i = b - 1; i <= d; i++) { if (s[i] == s[i + 1] && s[i + 1] == s[i + 2] && s[i] == '.') { cnt++; break; } } if (cnt) cout << "Yes"; else cout << "No"; } } }
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 50; int n; int a, b, c, d; string s; int cnt; int main() { cin >> n; cin >> a >> b >> c >> d; cin >> s; s = ' ' + s; if (c < d) { cnt = 0; for (int i = a; i <= d; i++) { if (s[i] == s[i + 1] && s[i] == '#') { cnt++; break; } } if (cnt > 0) cout << "No"; else cout << "Yes"; } else { cnt = 0; for (int i = a; i <= c; i++) { if (s[i] == s[i + 1] && s[i] == '#') { cnt++; break; } } if (cnt) { cout << "No"; } else { cnt = 0; for (int i = b - 1; i <= d - 1; i++) { if (s[i] == s[i + 1] && s[i + 1] == s[i + 2] && s[i] == '.') { cnt++; break; } } if (cnt) cout << "Yes"; else cout << "No"; } } }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "misc.off_by_one" ]
831,317
831,316
u979516092
cpp
p03017
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 50; int n; int a, b, c, d; string s; int cnt; int main() { cin >> n; cin >> a >> b >> c >> d; cin >> s; s = ' ' + s; if (c < d) { cnt = 0; for (int i = a; i <= d; i++) { if (s[i] == s[i + 1] && s[i] == '#') { cnt++; break; } } if (cnt > 0) cout << "No"; else cout << "Yes"; } else { cnt = 0; for (int i = a; i <= c; i++) { if (s[i] == s[i + 1] && s[i] == '#') { cnt++; break; } } if (cnt) { cout << "No"; } else { cnt = 0; for (int i = b; i <= d; i++) { if (s[i] == s[i + 1] && s[i + 1] == s[i + 2] && s[i] == '.') { cnt++; break; } } if (cnt) cout << "Yes"; else cout << "No"; } } }
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 50; int n; int a, b, c, d; string s; int cnt; int main() { cin >> n; cin >> a >> b >> c >> d; cin >> s; s = ' ' + s; if (c < d) { cnt = 0; for (int i = a; i <= d; i++) { if (s[i] == s[i + 1] && s[i] == '#') { cnt++; break; } } if (cnt > 0) cout << "No"; else cout << "Yes"; } else { cnt = 0; for (int i = a; i <= c; i++) { if (s[i] == s[i + 1] && s[i] == '#') { cnt++; break; } } if (cnt) { cout << "No"; } else { cnt = 0; for (int i = b - 1; i <= d - 1; i++) { if (s[i] == s[i + 1] && s[i + 1] == s[i + 2] && s[i] == '.') { cnt++; break; } } if (cnt) cout << "Yes"; else cout << "No"; } } }
[ "control_flow.loop.for.initializer.change", "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "misc.off_by_one" ]
831,318
831,316
u979516092
cpp
p03017
#include <bits/stdc++.h> using namespace std; int n, a, b, c, d; string s; int dem; int main() { cin >> n >> a >> b >> c >> d; cin >> s; s = " " + s; if (c < d) { for (int i = a; i <= d - 1; i++) { if (s[i] == s[i + 1] && s[i] == '#') { cout << "No"; return 0; } } cout << "Yes"; } else { for (int i = a; i < c; i++) { if (s[i] == s[i + 1] && s[i] == '#') { cout << "No"; return 0; } } for (int i = b; i <= min(d - 1, n - 2); i++) { if (s[i] == s[i + 1] && s[i + 2] == s[i] && s[i] == '.') { dem++; } } if (dem > 0) { cout << "Yes"; return 0; } cout << "No"; } }
#include <bits/stdc++.h> using namespace std; int n, a, b, c, d; string s; int dem; int main() { cin >> n >> a >> b >> c >> d; cin >> s; s = " " + s; if (c < d) { for (int i = a; i <= d - 1; i++) { if (s[i] == s[i + 1] && s[i] == '#') { cout << "No"; return 0; } } cout << "Yes"; } else { for (int i = a; i < c; i++) { if (s[i] == s[i + 1] && s[i] == '#') { cout << "No"; return 0; } } for (int i = b - 1; i <= min(d - 1, n - 2); i++) { if (s[i] == s[i + 1] && s[i + 2] == s[i] && s[i] == '.') { dem++; } } if (dem > 0) { cout << "Yes"; return 0; } cout << "No"; } }
[ "control_flow.loop.for.initializer.change" ]
831,323
831,325
u185917548
cpp