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 <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll, ll>; int main() { int N, A, B, C, D; cin >> N >> A >> B >> C >> D; string S; cin >> S; int fstoneA = 0, fstoneB = 0; for (int i = A - 1; i < C - 1; i++) { if (S[i] == '#' && S[i + 1] == '#') fstoneA = 1; } for (int i = B - 1; i < D - 1; i++) { if (S[i] == '#' && S[i + 1] == '#') fstoneB = 1; } if (fstoneA || fstoneB) { cout << "No"; return 0; } if (C <= B || C <= D) { cout << "Yes"; return 0; } int flag = 0; for (int i = B - 1; i < C - 1; i++) { if (S.substr(i - 1, 3) == "...") flag = 1; } if (flag == 1) cout << "Yes"; else cout << "No"; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll, ll>; int main() { int N, A, B, C, D; cin >> N >> A >> B >> C >> D; string S; cin >> S; int fstoneA = 0, fstoneB = 0; for (int i = A - 1; i < C - 1; i++) { if (S[i] == '#' && S[i + 1] == '#') fstoneA = 1; } for (int i = B - 1; i < D - 1; i++) { if (S[i] == '#' && S[i + 1] == '#') fstoneB = 1; } if (fstoneA || fstoneB) { cout << "No"; return 0; } if (C <= B || C <= D) { cout << "Yes"; return 0; } int flag = 0; for (int i = B - 1; i <= D - 1; i++) { if (S.substr(i - 1, 3) == "...") flag = 1; } if (flag == 1) cout << "Yes"; else cout << "No"; return 0; }
[ "control_flow.loop.for.condition.change" ]
832,756
832,755
u129667379
cpp
p03017
#if 1 #include <bits/stdc++.h> using namespace std; int n, s1, s2, e1, e2; char a[200005]; int b[2]; int main() { scanf("%d %d %d %d %d", &n, &s1, &s2, &e1, &e2); // if(s1 > e1) swap(s1,e1); // if(s2 > e2) swap(s2,e2); if (s1 > e1 || s2 > e2) { printf("No"); return 0; } scanf("%s", a + 1); int c = 0; for (int i = s1; i < e1; i++) { if (a[i] == '#' && a[i + 1] == '#') { printf("No"); return 0; } } for (int i = s2; i < e2; i++) { if (a[i] == '#' && a[i + 1] == '#') { printf("No"); return 0; } } for (int i = s2; i <= e2; i++) { if (a[i] == '.' && a[i + 1] == '.' && a[i + 2] == '.') { c = 1; } } // cout << c; if ((s1 < s2 && e1 > e2) && !c) { printf("No"); return 0; } printf("Yes"); return 0; } #endif // 1++
#if 1 #include <bits/stdc++.h> using namespace std; int n, s1, s2, e1, e2; char a[200005]; int b[2]; int main() { scanf("%d %d %d %d %d", &n, &s1, &s2, &e1, &e2); // if(s1 > e1) swap(s1,e1); // if(s2 > e2) swap(s2,e2); if (s1 > e1 || s2 > e2) { printf("No"); return 0; } scanf("%s", a + 1); int c = 0; for (int i = s1; i < e1; i++) { if (a[i] == '#' && a[i + 1] == '#') { printf("No"); return 0; } } for (int i = s2; i < e2; i++) { if (a[i] == '#' && a[i + 1] == '#') { printf("No"); return 0; } } for (int i = s2 - 1; i < e2; i++) { if (a[i] == '.' && a[i + 1] == '.' && a[i + 2] == '.') { c = 1; } } // cout << c; if ((s1 < s2 && e1 > e2) && !c) { printf("No"); return 0; } printf("Yes"); return 0; } #endif // 1++
[ "control_flow.loop.for.initializer.change", "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
832,761
832,762
u998677610
cpp
p03017
#if 1 #include <bits/stdc++.h> using namespace std; int n, s1, s2, e1, e2; char a[200005]; int b[2]; int main() { scanf("%d %d %d %d %d", &n, &s1, &s2, &e1, &e2); // if(s1 > e1) swap(s1,e1); // if(s2 > e2) swap(s2,e2); if (s1 > e1 || s2 > e2) { printf("No"); return 0; } scanf("%s", a + 1); int c = 0; for (int i = s1; i < e1; i++) { if (a[i] == '#' && a[i + 1] == '#') { printf("No"); return 0; } } for (int i = s2; i < e2; i++) { if (a[i] == '#' && a[i + 1] == '#') { printf("No"); return 0; } } for (int i = s2; i < e2; i++) { if (a[i] == '.' && a[i + 1] == '.' && a[i + 2] == '.') { c = 1; } } // cout << c; if ((s1 < s2 && e1 > e2) && !c) { printf("No"); return 0; } printf("Yes"); return 0; } #endif // 1++
#if 1 #include <bits/stdc++.h> using namespace std; int n, s1, s2, e1, e2; char a[200005]; int b[2]; int main() { scanf("%d %d %d %d %d", &n, &s1, &s2, &e1, &e2); // if(s1 > e1) swap(s1,e1); // if(s2 > e2) swap(s2,e2); if (s1 > e1 || s2 > e2) { printf("No"); return 0; } scanf("%s", a + 1); int c = 0; for (int i = s1; i < e1; i++) { if (a[i] == '#' && a[i + 1] == '#') { printf("No"); return 0; } } for (int i = s2; i < e2; i++) { if (a[i] == '#' && a[i + 1] == '#') { printf("No"); return 0; } } for (int i = s2 - 1; i < e2; i++) { if (a[i] == '.' && a[i + 1] == '.' && a[i + 2] == '.') { c = 1; } } // cout << c; if ((s1 < s2 && e1 > e2) && !c) { printf("No"); return 0; } printf("Yes"); return 0; } #endif // 1++
[ "control_flow.loop.for.initializer.change" ]
832,763
832,762
u998677610
cpp
p03017
#pragma region include #include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <vector> #define ALL(obj) (obj).begin(), (obj).end() #define RALL(obj) (obj).rbegin(), (obj).rend() #define REP(i, n) for (int i = 0; i < n; i++) #define REPR(i, n) for (int i = n; i >= 0; i--) #define FOR(i, m, n) for (int i = m; i < n; i++) #define MOD 1000000007 #define INF 1000000000 #define LLINF 4000000000000000000 using namespace std; typedef long long ll; typedef pair<int, int> PII; typedef vector<int> VI; typedef vector<VI> VVI; #pragma endregion int main() { cin.tie(0); ios::sync_with_stdio(false); int N, A, B, C, D; cin >> N >> A >> B >> C >> D; A--; B--; C--; D--; string s; cin >> s; REP(i, s.size() - 1) { if (s[i] == '#' && s[i + 1] == '#') { if ((A < i && i < C) || (B < i && i < D)) { puts("No"); return 0; } } } if (C > D) { for (int i = B; i < D && i + 2 < s.size(); i++) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { puts("Yes"); return 0; } } puts("No"); } else { puts("Yes"); } getchar(); getchar(); }
#pragma region include #include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <vector> #define ALL(obj) (obj).begin(), (obj).end() #define RALL(obj) (obj).rbegin(), (obj).rend() #define REP(i, n) for (int i = 0; i < n; i++) #define REPR(i, n) for (int i = n; i >= 0; i--) #define FOR(i, m, n) for (int i = m; i < n; i++) #define MOD 1000000007 #define INF 1000000000 #define LLINF 4000000000000000000 using namespace std; typedef long long ll; typedef pair<int, int> PII; typedef vector<int> VI; typedef vector<VI> VVI; #pragma endregion int main() { cin.tie(0); ios::sync_with_stdio(false); int N, A, B, C, D; cin >> N >> A >> B >> C >> D; A--; B--; C--; D--; string s; cin >> s; REP(i, s.size() - 1) { if (s[i] == '#' && s[i + 1] == '#') { if ((A < i && i < C) || (B < i && i < D)) { puts("No"); return 0; } } } if (C > D) { for (int i = B - 1; i < D && i + 2 < s.size(); i++) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { puts("Yes"); return 0; } } puts("No"); } else { puts("Yes"); } getchar(); getchar(); }
[ "control_flow.loop.for.initializer.change" ]
832,772
832,773
u435935167
cpp
p03017
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define rept(i, a, b) for (int i = a; i < b; i++) #define ll long long #define MOD 1000000007 #define IMIN INT_MIN; #define IMAX INT_MAX; int main() { int N, A, B, C, D; cin >> N >> A >> B >> C >> D; A--; B--; C--; D--; string S; cin >> S; bool ok1 = true; bool ok2 = true; bool ok3 = false; bool spflag = false; // without position switch ABCD if (C < D) { rept(i, A, D - 1) { if (S[i] == '#' && S[i + 1] == '#') { ok1 = false; break; } } if (ok1) ok3 = true; } // with position switch ABDC else { ok1 = ok2 = true; // do BD first rept(i, B + 1, D - 1) { if ((S[i] == '#') && (S[i + 1] == '#')) { ok1 = false; break; } } // check if there is a hole rept(i, B, D) { if (S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.') { spflag = true; } } if (ok1 && spflag) { // do AC rept(i, A + 1, C - 1) { if ((S[i] == '#') && (S[i + 1] == '#')) { ok2 = false; break; } } if (ok2) ok3 = true; } } if (ok3) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define rept(i, a, b) for (int i = a; i < b; i++) #define ll long long #define MOD 1000000007 #define IMIN INT_MIN; #define IMAX INT_MAX; int main() { int N, A, B, C, D; cin >> N >> A >> B >> C >> D; A--; B--; C--; D--; string S; cin >> S; bool ok1 = true; bool ok2 = true; bool ok3 = false; bool spflag = false; // without position switch ABCD if (C < D) { rept(i, A, D - 1) { if (S[i] == '#' && S[i + 1] == '#') { ok1 = false; break; } } if (ok1) ok3 = true; } // with position switch ABDC else { ok1 = ok2 = true; // do BD first rept(i, B + 1, D - 1) { if ((S[i] == '#') && (S[i + 1] == '#')) { ok1 = false; break; } } // check if there is a hole rept(i, B - 1, D) { if (S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.') { spflag = true; } } if (ok1 && spflag) { // do AC rept(i, A + 1, C - 1) { if ((S[i] == '#') && (S[i + 1] == '#')) { ok2 = false; break; } } if (ok2) ok3 = true; } } if (ok3) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
[ "expression.operation.binary.add" ]
832,774
832,775
u569041543
cpp
p03017
#include <algorithm> #include <cmath> #include <cstdlib> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <string> #include <utility> #include <vector> #define ll long long #define REP(i, x) for (int(i) = 0; (i) < (x); (i)++) #define pi 3.1415926535 const int MOD = 1000000007; using namespace std; int main() { ll n, a, b, c, d; string s; cin >> n >> a >> b >> c >> d >> s; bool flag; if (c == d) { flag = false; } else if (c > d) { flag = false; for (ll i = b - 1; i <= d - 2; i++) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { flag = true; } } for (ll i = a - 1; i <= c - 2; i++) { if (s[i] == '#' && s[i + 1] == '#') { flag = false; } } } else { flag = true; for (ll i = a - 1; i <= d - 2; i++) { if (s[i] == '#' && s[i + 1] == '#') { flag = false; } } } if (flag) { cout << "Yes" << endl; } else { cout << "No" << endl; } return 0; }
#include <algorithm> #include <cmath> #include <cstdlib> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <string> #include <utility> #include <vector> #define ll long long #define REP(i, x) for (int(i) = 0; (i) < (x); (i)++) #define pi 3.1415926535 const int MOD = 1000000007; using namespace std; int main() { ll n, a, b, c, d; string s; cin >> n >> a >> b >> c >> d >> s; bool flag; if (c == d) { flag = false; } else if (c > d) { flag = false; for (ll i = b - 2; i <= d - 2; i++) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { flag = true; } } for (ll i = a - 1; i <= c - 2; i++) { if (s[i] == '#' && s[i + 1] == '#') { flag = false; } } } else { flag = true; for (ll i = a - 1; i <= d - 2; i++) { if (s[i] == '#' && s[i + 1] == '#') { flag = false; } } } if (flag) { 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" ]
832,776
832,777
u342129174
cpp
p03017
#include <algorithm> #include <cmath> #include <cstdlib> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <string> #include <utility> #include <vector> #define ll long long #define REP(i, x) for (int(i) = 0; (i) < (x); (i)++) #define pi 3.1415926535 const int MOD = 1000000007; using namespace std; int main() { ll n, a, b, c, d; string s; cin >> n >> a >> b >> c >> d >> s; bool flag; if (c == d) { flag = false; } else if (c > d) { flag = false; for (ll i = a - 1; i <= c - 3; i++) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { flag = true; } } for (ll i = a - 1; i <= c - 2; i++) { if (s[i] == '#' && s[i + 1] == '#') { flag = false; } } } else { flag = true; for (ll i = a - 1; i <= d - 2; i++) { if (s[i] == '#' && s[i + 1] == '#') { flag = false; } } } if (flag) { cout << "Yes" << endl; } else { cout << "No" << endl; } return 0; }
#include <algorithm> #include <cmath> #include <cstdlib> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <string> #include <utility> #include <vector> #define ll long long #define REP(i, x) for (int(i) = 0; (i) < (x); (i)++) #define pi 3.1415926535 const int MOD = 1000000007; using namespace std; int main() { ll n, a, b, c, d; string s; cin >> n >> a >> b >> c >> d >> s; bool flag; if (c == d) { flag = false; } else if (c > d) { flag = false; for (ll i = b - 2; i <= d - 2; i++) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { flag = true; } } for (ll i = a - 1; i <= c - 2; i++) { if (s[i] == '#' && s[i + 1] == '#') { flag = false; } } } else { flag = true; for (ll i = a - 1; i <= d - 2; i++) { if (s[i] == '#' && s[i + 1] == '#') { flag = false; } } } if (flag) { 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", "control_flow.branch.if.condition.change" ]
832,778
832,777
u342129174
cpp
p03017
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll N; cin >> N; ll A; cin >> A; ll B; cin >> B; ll C; cin >> C; ll D; cin >> D; string S; cin >> S; bool jumpable = false; ll cnt = 0; for (ll j = B - 2; j < min(C, D); ++j) { if (S[j] == '.') { cnt += 1; if (cnt >= 3) { jumpable = true; break; } } else { cnt = 0; } } bool sunuke = false, funuke = false; ll j; for (j = A - 1; j < C - 1; ++j) { if (S[j + 1] == '#' && S[j + 2] == '#') { break; } } if (j == C - 1) sunuke = true; if (C > D && !jumpable) sunuke = false; for (j = B - 1; j < D - 1; ++j) { if (S[j + 1] == '#' && S[j + 2] == '#') { break; } } if (j == D - 1) funuke = true; cout << (sunuke && funuke ? "Yes" : "No") << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll N; cin >> N; ll A; cin >> A; ll B; cin >> B; ll C; cin >> C; ll D; cin >> D; string S; cin >> S; bool jumpable = false; ll cnt = 0; for (ll j = B - 2; j < D + 1; ++j) { if (S[j] == '.') { cnt += 1; if (cnt >= 3) { jumpable = true; break; } } else { cnt = 0; } } bool sunuke = false, funuke = false; ll j; for (j = A - 1; j < C - 1; ++j) { if (S[j + 1] == '#' && S[j + 2] == '#') { break; } } if (j == C - 1) sunuke = true; if (C > D && !jumpable) sunuke = false; for (j = B - 1; j < D - 1; ++j) { if (S[j + 1] == '#' && S[j + 2] == '#') { break; } } if (j == D - 1) funuke = true; cout << (sunuke && funuke ? "Yes" : "No") << endl; return 0; }
[ "control_flow.loop.for.condition.change", "call.remove", "call.arguments.change", "expression.operation.binary.change" ]
832,781
832,782
u275710783
cpp
p03017
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll N; cin >> N; ll A; cin >> A; ll B; cin >> B; ll C; cin >> C; ll D; cin >> D; string S; cin >> S; bool jumpable = false; ll cnt = 0; for (ll j = B - 2; j < C; ++j) { if (S[j] == '.') { cnt += 1; if (cnt >= 3) { jumpable = true; break; } } else { cnt = 0; } } bool sunuke = false, funuke = false; ll j; for (j = A - 1; j < C - 1; ++j) { if (S[j + 1] == '#' && S[j + 2] == '#') { break; } } if (j == C - 1) sunuke = true; if (C > D && !jumpable) sunuke = false; for (j = B - 1; j < D - 1; ++j) { if (S[j + 1] == '#' && S[j + 2] == '#') { break; } } if (j == D - 1) funuke = true; cout << (sunuke && funuke ? "Yes" : "No") << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll N; cin >> N; ll A; cin >> A; ll B; cin >> B; ll C; cin >> C; ll D; cin >> D; string S; cin >> S; bool jumpable = false; ll cnt = 0; for (ll j = B - 2; j < D + 1; ++j) { if (S[j] == '.') { cnt += 1; if (cnt >= 3) { jumpable = true; break; } } else { cnt = 0; } } bool sunuke = false, funuke = false; ll j; for (j = A - 1; j < C - 1; ++j) { if (S[j + 1] == '#' && S[j + 2] == '#') { break; } } if (j == C - 1) sunuke = true; if (C > D && !jumpable) sunuke = false; for (j = B - 1; j < D - 1; ++j) { if (S[j + 1] == '#' && S[j + 2] == '#') { break; } } if (j == D - 1) funuke = true; cout << (sunuke && funuke ? "Yes" : "No") << endl; return 0; }
[ "identifier.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change", "misc.off_by_one" ]
832,783
832,782
u275710783
cpp
p03017
#include <bits/stdc++.h> using namespace std; int main() { int N, A, B, C, D; char S[200005]; cin >> N >> A >> B >> C >> D; cin >> S; if (B < C) { // A < B < C < D の配置 (Bは Aの移動の邪魔にならない) if (C < D) { int frag_ad = 1; for (int i = A - 1; i < D - 2; i++) { if (S[i] == '#' && S[i + 1] == '#') { frag_ad = 0; break; } } if (frag_ad == 1) { cout << "Yes" << endl; } else { cout << "No" << endl; } } // A < B < D < C (Bが Aの移動の邪魔になる) else { int frag_ac = 1; int frag_bd = 0; for (int i = A - 1; i < C - 2; i++) { if (S[i] == '#' && S[i + 1] == '#') { frag_ac = 0; break; } } for (int i = B - 1; i < D - 1; i++) { if (S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.') { frag_bd = 1; } } if (frag_ac == 1 && frag_bd == 1) { cout << "Yes" << endl; } else { cout << "No" << endl; } } } // A < C < B < D の配置(A, Bの追い越し考慮不要) else { int frag_ac = 1; int frag_bd = 1; for (int i = A - 1; i < C - 2; i++) { if (S[i] == '#' && S[i + 1] == '#') { frag_ac = 0; break; } } for (int i = B - 1; i < D - 2; i++) { if (S[i] == '#' && S[i + 1] == '#') { frag_bd = 0; break; } } if (frag_ac == 1 && frag_bd == 1) { cout << "Yes" << endl; } else { cout << "No" << endl; } } }
#include <bits/stdc++.h> using namespace std; int main() { int N, A, B, C, D; char S[200005]; cin >> N >> A >> B >> C >> D; cin >> S; if (B < C) { // A < B < C < D の配置 (Bは Aの移動の邪魔にならない) if (C < D) { int frag_ad = 1; for (int i = A - 1; i < D - 2; i++) { if (S[i] == '#' && S[i + 1] == '#') { frag_ad = 0; break; } } if (frag_ad == 1) { cout << "Yes" << endl; } else { cout << "No" << endl; } } // A < B < D < C (Bが Aの移動の邪魔になる) else { int frag_ac = 1; int frag_bd = 0; for (int i = A - 1; i < C - 2; i++) { if (S[i] == '#' && S[i + 1] == '#') { frag_ac = 0; break; } } for (int i = B - 2; i < D - 1; i++) { if (S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.') { frag_bd = 1; } } if (frag_ac == 1 && frag_bd == 1) { cout << "Yes" << endl; } else { cout << "No" << endl; } } } // A < C < B < D の配置(A, Bの追い越し考慮不要) else { int frag_ac = 1; int frag_bd = 1; for (int i = A - 1; i < C - 2; i++) { if (S[i] == '#' && S[i + 1] == '#') { frag_ac = 0; break; } } for (int i = B - 1; i < D - 2; i++) { if (S[i] == '#' && S[i + 1] == '#') { frag_bd = 0; break; } } if (frag_ac == 1 && frag_bd == 1) { cout << "Yes" << endl; } else { cout << "No" << endl; } } }
[ "literal.number.change", "control_flow.loop.for.initializer.change", "expression.off_by_one", "expression.operation.binary.change" ]
832,790
832,791
u399232305
cpp
p03017
#include <bits/stdc++.h> using namespace std; int main() { int N, A, B, C, D; char S[200005]; cin >> N >> A >> B >> C >> D; cin >> S; if (B < C) { // A < B < C < D の配置 (BはAの移動の邪魔にならない) if (C < D) { int frag_ad = 1; for (int i = A - 1; i < D - 2; i++) { if (S[i] == '#' && S[i + 1] == '#') { frag_ad = 0; break; } } if (frag_ad == 1) { cout << "Yes" << endl; } else { cout << "No" << endl; } } // A < B < D < C (移動後のBが Aの移動の邪魔になる) else { int frag_ac = 1; int frag_bd = 0; for (int i = A - 1; i < C - 2; i++) { if (S[i] == '#' && S[i + 1] == '#') { frag_ac = 0; break; } } for (int i = B - 1; i < D - 2; i++) { if (S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.') { frag_bd = 1; } } if (frag_ac == 1 && frag_bd == 1) { cout << "Yes" << endl; } else { cout << "No" << endl; } } } // A < C < B < D の配置(A, Bの追い越し考慮不要) else { int frag_ac = 1; int frag_bd = 1; for (int i = A - 1; i < C - 2; i++) { if (S[i] == '#' && S[i + 1] == '#') { frag_ac = 0; break; } } for (int i = B - 1; i < D - 2; i++) { if (S[i] == '#' && S[i + 1] == '#') { frag_bd = 0; break; } } if (frag_ac == 1 && frag_bd == 1) { cout << "Yes" << endl; } else { cout << "No" << endl; } } }
#include <bits/stdc++.h> using namespace std; int main() { int N, A, B, C, D; char S[200005]; cin >> N >> A >> B >> C >> D; cin >> S; if (B < C) { // A < B < C < D の配置 (Bは Aの移動の邪魔にならない) if (C < D) { int frag_ad = 1; for (int i = A - 1; i < D - 2; i++) { if (S[i] == '#' && S[i + 1] == '#') { frag_ad = 0; break; } } if (frag_ad == 1) { cout << "Yes" << endl; } else { cout << "No" << endl; } } // A < B < D < C (Bが Aの移動の邪魔になる) else { int frag_ac = 1; int frag_bd = 0; for (int i = A - 1; i < C - 2; i++) { if (S[i] == '#' && S[i + 1] == '#') { frag_ac = 0; break; } } for (int i = B - 2; i < D - 1; i++) { if (S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.') { frag_bd = 1; } } if (frag_ac == 1 && frag_bd == 1) { cout << "Yes" << endl; } else { cout << "No" << endl; } } } // A < C < B < D の配置(A, Bの追い越し考慮不要) else { int frag_ac = 1; int frag_bd = 1; for (int i = A - 1; i < C - 2; i++) { if (S[i] == '#' && S[i + 1] == '#') { frag_ac = 0; break; } } for (int i = B - 1; i < D - 2; i++) { if (S[i] == '#' && S[i + 1] == '#') { frag_bd = 0; break; } } if (frag_ac == 1 && frag_bd == 1) { cout << "Yes" << endl; } else { cout << "No" << endl; } } }
[ "literal.number.change", "control_flow.loop.for.initializer.change", "expression.off_by_one", "expression.operation.binary.change", "control_flow.branch.if.condition.change" ]
832,792
832,791
u399232305
cpp
p03017
#include <bits/stdc++.h> using namespace std; // #include<boost/multiprecision/cpp_int.hpp> // using namespace boost::multiprecision; #define BEGIN \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL) #define END return EXIT_SUCCESS #define rep(I, N) for (auto I = 0; I < (N); ++I) #define up(I, A, B) for (auto I = (A); I <= (B); ++I) #define dw(I, A, B) for (auto I = (A); I >= (B); --I) #define all(C) (C).begin(), (C).end() #define rall(C) (C).rbegin(), (C).rend() #define ft first #define sd second #define mp make_pair #define mt make_tuple #define pf push_front #define pb push_back #define pt pop_front #define pk pop_back #define eb emplace_back #define lb lower_bound #define ub upper_bound #define rs resize 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; } template <class T> inline void in(T &p) { cin >> p; } template <class T1, class T2> inline void in(T1 &p1, T2 &p2) { cin >> p1 >> p2; } template <class T1, class T2, class T3> inline void in(T1 &p1, T2 &p2, T3 &p3) { cin >> p1 >> p2 >> p3; } template <class T1, class T2, class T3, class T4> inline void in(T1 &p1, T2 &p2, T3 &p3, T4 &p4) { cin >> p1 >> p2 >> p3 >> p4; } template <class T1, class T2, class T3, class T4, class T5> inline void in(T1 &p1, T2 &p2, T3 &p3, T4 &p4, T5 &p5) { cin >> p1 >> p2 >> p3 >> p4 >> p5; } template <class T> inline void out(T p) { cout << p << endl; } template <class T1, class T2> inline void out(T1 p1, T2 p2) { cout << p1 << " " << p2 << endl; } template <class T1, class T2, class T3> inline void out(T1 p1, T2 p2, T3 p3) { cout << p1 << " " << p2 << " " << p3 << endl; } template <class T1, class T2, class T3, class T4> inline void out(T1 p1, T2 p2, T3 p3, T4 p4) { cout << p1 << " " << p2 << " " << p3 << " " << p4 << endl; } inline void solve(void) { long N, A, B, C, D; in(N); in(A, B, C, D); A--; B--; C--; D--; string S; in(S); long cnt = 0; up(i, A + 1, C - 1) { if (S[i] == '#') cnt++; else cnt = 0; if (cnt == 2) { out("No"); return; } } cnt = 0; int cnt2 = 0; bool f = false; up(i, B + 1, D - 1) { if (S[i] == '#') cnt++; else cnt = 0; if (cnt == 2) { out("No"); return; } if (S[i] == '.') cnt2++; else cnt2 = 0; if (cnt2 == 3) { f = true; } } if (C < D) { out("Yes"); return; } if (f || (S[D - 1] == '.' && S[D + 1] == '.') || (S[B - 1] == '.' && S[B + 1] == '.')) { out("Yes"); } else { out("No"); } } int main(int argc, char **argv) { BEGIN; solve(); END; }
#include <bits/stdc++.h> using namespace std; // #include<boost/multiprecision/cpp_int.hpp> // using namespace boost::multiprecision; #define BEGIN \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL) #define END return EXIT_SUCCESS #define rep(I, N) for (auto I = 0; I < (N); ++I) #define up(I, A, B) for (auto I = (A); I <= (B); ++I) #define dw(I, A, B) for (auto I = (A); I >= (B); --I) #define all(C) (C).begin(), (C).end() #define rall(C) (C).rbegin(), (C).rend() #define ft first #define sd second #define mp make_pair #define mt make_tuple #define pf push_front #define pb push_back #define pt pop_front #define pk pop_back #define eb emplace_back #define lb lower_bound #define ub upper_bound #define rs resize 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; } template <class T> inline void in(T &p) { cin >> p; } template <class T1, class T2> inline void in(T1 &p1, T2 &p2) { cin >> p1 >> p2; } template <class T1, class T2, class T3> inline void in(T1 &p1, T2 &p2, T3 &p3) { cin >> p1 >> p2 >> p3; } template <class T1, class T2, class T3, class T4> inline void in(T1 &p1, T2 &p2, T3 &p3, T4 &p4) { cin >> p1 >> p2 >> p3 >> p4; } template <class T1, class T2, class T3, class T4, class T5> inline void in(T1 &p1, T2 &p2, T3 &p3, T4 &p4, T5 &p5) { cin >> p1 >> p2 >> p3 >> p4 >> p5; } template <class T> inline void out(T p) { cout << p << endl; } template <class T1, class T2> inline void out(T1 p1, T2 p2) { cout << p1 << " " << p2 << endl; } template <class T1, class T2, class T3> inline void out(T1 p1, T2 p2, T3 p3) { cout << p1 << " " << p2 << " " << p3 << endl; } template <class T1, class T2, class T3, class T4> inline void out(T1 p1, T2 p2, T3 p3, T4 p4) { cout << p1 << " " << p2 << " " << p3 << " " << p4 << endl; } inline void solve(void) { long N, A, B, C, D; in(N); in(A, B, C, D); A--; B--; C--; D--; string S; in(S); long cnt = 0; up(i, A + 1, C - 1) { if (S[i] == '#') cnt++; else cnt = 0; if (cnt == 2) { out("No"); return; } } cnt = 0; int cnt2 = 0; bool f = false; up(i, B, D) { if (S[i] == '#') cnt++; else cnt = 0; if (cnt == 2) { out("No"); return; } if (S[i] == '.') cnt2++; else cnt2 = 0; if (cnt2 == 3) { f = true; } } if (C < D) { out("Yes"); return; } if (f || (S[D - 1] == '.' && S[D + 1] == '.') || (S[B - 1] == '.' && S[B + 1] == '.')) { out("Yes"); } else { out("No"); } } int main(int argc, char **argv) { BEGIN; solve(); END; }
[ "expression.operation.binary.remove" ]
832,810
832,811
u743561048
cpp
p03017
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using pii = pair<int, int>; #define INF LONG_MAX #define MOD 1000000007 #define rng(a) a.begin(), a.end() #define rrng(a) a.end(), a.begin() int main() { ios::sync_with_stdio(false); cin.tie(0); int N, A, B, C, D; string S; cin >> N >> A >> B >> C >> D >> S; A--; B--; C--; D--; bool okb = true; for (int i = B; i < D; i++) { if (S[i] == '#' && S[i + 1] == '#') okb = false; } bool oka = true; for (int i = A; i < C; i++) { if (S[i] == '#' && S[i + 1] == '#') oka = false; } bool one = (oka && okb); okb = true; for (int i = B; i < D; i++) { if (S[i] == '#' && S[i + 1] == '#') okb = false; } S[D] = '#'; oka = true; for (int i = A; i < C; i++) { if (S[i] == '#' && S[i + 1] == '#') oka = false; } bool two = (oka && okb); S[D] = '.'; bool three = false; for (int i = B - 1; i < D - 1; i++) { if (S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.') three = true; } if (C < D && one) cout << "Yes" << endl; else if (D < C && three && one) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using pii = pair<int, int>; #define INF LONG_MAX #define MOD 1000000007 #define rng(a) a.begin(), a.end() #define rrng(a) a.end(), a.begin() int main() { ios::sync_with_stdio(false); cin.tie(0); int N, A, B, C, D; string S; cin >> N >> A >> B >> C >> D >> S; A--; B--; C--; D--; bool okb = true; for (int i = B; i < D; i++) { if (S[i] == '#' && S[i + 1] == '#') okb = false; } bool oka = true; for (int i = A; i < C; i++) { if (S[i] == '#' && S[i + 1] == '#') oka = false; } bool one = (oka && okb); okb = true; for (int i = B; i < D; i++) { if (S[i] == '#' && S[i + 1] == '#') okb = false; } S[D] = '#'; oka = true; for (int i = A; i < C; i++) { if (S[i] == '#' && S[i + 1] == '#') oka = false; } bool two = (oka && okb); S[D] = '.'; bool three = false; for (int i = B - 1; i < D; i++) { if (S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.') three = true; } if (C < D && one) cout << "Yes" << endl; else if (D < C && three && one) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
832,812
832,813
u864171425
cpp
p03017
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using pii = pair<int, int>; #define INF LONG_MAX #define MOD 1000000007 #define rng(a) a.begin(), a.end() #define rrng(a) a.end(), a.begin() int main() { ios::sync_with_stdio(false); cin.tie(0); int N, A, B, C, D; string S; cin >> N >> A >> B >> C >> D >> S; A--; B--; C--; D--; bool okb = true; for (int i = B; i < D; i++) { if (S[i] == '#' && S[i + 1] == '#') okb = false; } bool oka = true; for (int i = A; i < C; i++) { if (S[i] == '#' && S[i + 1] == '#') oka = false; } bool one = (oka && okb); okb = true; for (int i = B; i < D; i++) { if (S[i] == '#' && S[i + 1] == '#') okb = false; } S[D] = '#'; oka = true; for (int i = A; i < C; i++) { if (S[i] == '#' && S[i + 1] == '#') oka = false; } bool two = (oka && okb); S[D] = '.'; bool three = false; for (int i = B - 1; i < D - 2; i++) { if (S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.') three = true; } if (C < D && one) cout << "Yes" << endl; else if (D < C && three) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using pii = pair<int, int>; #define INF LONG_MAX #define MOD 1000000007 #define rng(a) a.begin(), a.end() #define rrng(a) a.end(), a.begin() int main() { ios::sync_with_stdio(false); cin.tie(0); int N, A, B, C, D; string S; cin >> N >> A >> B >> C >> D >> S; A--; B--; C--; D--; bool okb = true; for (int i = B; i < D; i++) { if (S[i] == '#' && S[i + 1] == '#') okb = false; } bool oka = true; for (int i = A; i < C; i++) { if (S[i] == '#' && S[i + 1] == '#') oka = false; } bool one = (oka && okb); okb = true; for (int i = B; i < D; i++) { if (S[i] == '#' && S[i + 1] == '#') okb = false; } S[D] = '#'; oka = true; for (int i = A; i < C; i++) { if (S[i] == '#' && S[i + 1] == '#') oka = false; } bool two = (oka && okb); S[D] = '.'; bool three = false; for (int i = B - 1; i < D; i++) { if (S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.') three = true; } if (C < D && one) cout << "Yes" << endl; else if (D < C && three && one) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove", "control_flow.branch.if.condition.change" ]
832,814
832,813
u864171425
cpp
p03017
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using pii = pair<int, int>; #define INF LONG_MAX #define MOD 1000000007 #define rng(a) a.begin(), a.end() #define rrng(a) a.end(), a.begin() int main() { ios::sync_with_stdio(false); cin.tie(0); int N, A, B, C, D; string S; cin >> N >> A >> B >> C >> D >> S; A--; B--; C--; D--; bool okb = true; for (int i = B; i < D; i++) { if (S[i] == '#' && S[i + 1] == '#') okb = false; } bool oka = true; for (int i = A; i < C; i++) { if (S[i] == '#' && S[i + 1] == '#') oka = false; } bool one = (oka && okb); okb = true; for (int i = B; i < D; i++) { if (S[i] == '#' && S[i + 1] == '#') okb = false; } S[D] = '#'; oka = true; for (int i = A; i < C; i++) { if (S[i] == '#' && S[i + 1] == '#') oka = false; } bool two = (oka && okb); S[D] = '.'; bool three = false; for (int i = B - 1; i < D - 2; i++) { if (S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.') three = true; } if (C < D && one) cout << "Yes" << endl; else if (D < C && (three || two)) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using pii = pair<int, int>; #define INF LONG_MAX #define MOD 1000000007 #define rng(a) a.begin(), a.end() #define rrng(a) a.end(), a.begin() int main() { ios::sync_with_stdio(false); cin.tie(0); int N, A, B, C, D; string S; cin >> N >> A >> B >> C >> D >> S; A--; B--; C--; D--; bool okb = true; for (int i = B; i < D; i++) { if (S[i] == '#' && S[i + 1] == '#') okb = false; } bool oka = true; for (int i = A; i < C; i++) { if (S[i] == '#' && S[i + 1] == '#') oka = false; } bool one = (oka && okb); okb = true; for (int i = B; i < D; i++) { if (S[i] == '#' && S[i + 1] == '#') okb = false; } S[D] = '#'; oka = true; for (int i = A; i < C; i++) { if (S[i] == '#' && S[i + 1] == '#') oka = false; } bool two = (oka && okb); S[D] = '.'; bool three = false; for (int i = B - 1; i < D; i++) { if (S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.') three = true; } if (C < D && one) cout << "Yes" << endl; else if (D < C && three && one) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove", "control_flow.branch.if.condition.change" ]
832,815
832,813
u864171425
cpp
p03017
#include <bits/stdc++.h> using namespace std; #define int long long #define fi first #define se second #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define rep1(i, n) for (int i = 1; i <= (int)(n); ++i) #define rep11(i, n) for (int i = 1; i < (int)(n); ++i) #define repo(i, o, n) for (int i = o; i < (int)(n); ++i) #define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i) #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define sperase(v, n) (v).erase(remove(all(v), n), (v).end()) #define vdelete(v) (v).erase(unique(all(v)), (v).end()) #define pb(n) push_back(n) #define mp make_pair #define MOD 1000000007 #define INF 9223372036854775807 int n, a, b, c, d, memo[200000], ma, mi, bb, cc, aa, aaa; bool f, ff; string s; signed main() { cin >> n >> a >> b >> c >> d >> s; a--, b--, c--, d--; ma = max(max(a, b), max(c, d)); mi = min(min(a, b), min(c, d)); repo(i, mi, ma) { if (s[i] == '#') bb++, cc = 0; else cc++, bb = 0; if (cc >= 3) { if (!f && max(a, b) < i) { f = true; aa = i; } } if (bb >= 2) { if ((a < i && i < c) || b < i && i < d) { cout << "No" << endl; return 0; } } } if (c > d) { if (f && aa <= min(c, d)) cout << "Yes" << endl; else cout << "No" << endl; } else cout << "Yes" << endl; }
#include <bits/stdc++.h> using namespace std; #define int long long #define fi first #define se second #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define rep1(i, n) for (int i = 1; i <= (int)(n); ++i) #define rep11(i, n) for (int i = 1; i < (int)(n); ++i) #define repo(i, o, n) for (int i = o; i < (int)(n); ++i) #define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i) #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define sperase(v, n) (v).erase(remove(all(v), n), (v).end()) #define vdelete(v) (v).erase(unique(all(v)), (v).end()) #define pb(n) push_back(n) #define mp make_pair #define MOD 1000000007 #define INF 9223372036854775807 int n, a, b, c, d, memo[200000], ma, mi, bb, cc, aa, aaa; bool f, ff; string s; signed main() { cin >> n >> a >> b >> c >> d >> s; a--, b--, c--, d--; ma = max(max(a, b), max(c, d)); mi = min(min(a, b), min(c, d)); repo(i, mi, ma) { if (s[i] == '#') bb++, cc = 0; else cc++, bb = 0; if (cc == 3) { if (!f && max(a, b) < i) { f = true; aa = i - 1; } } if (bb >= 2) { if ((a < i && i < c) || b < i && i < d) { cout << "No" << endl; return 0; } } } if (c > d) { if (f && aa <= min(c, d)) cout << "Yes" << endl; else cout << "No" << endl; } else cout << "Yes" << endl; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change", "assignment.change" ]
832,816
832,817
u721367699
cpp
p03017
#include <algorithm> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <memory> #include <numeric> #include <queue> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> constexpr long long MOD = 1000000007; int main() { int N, A, B, C, D; std::cin >> N >> A >> B >> C >> D; --A; --B; --C; --D; std::string str; std::cin >> str; bool AtoC = true; for (int i = A + 1; i < C; ++i) { if (str[i] == '#' && str[i + 1] == '#') { AtoC = false; break; } } bool BtoD = true; for (int i = B + 1; i < D; ++i) { if (str[i] == '#' && str[i + 1] == '#') { BtoD = false; break; } } if (C < B || C < D) { std::cout << (AtoC && BtoD ? "Yes" : "No") << std::endl; } else { bool canOver = false; for (int i = B - 1; i < D - 1; ++i) { if (i + 2 < str.size() && str[i] == '.' && str[i + 1] == '.' && str[i + 2] == '.') { canOver = true; break; } } std::cout << (AtoC && BtoD && canOver ? "Yes" : "No") << std::endl; } return 0; }
#include <algorithm> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <memory> #include <numeric> #include <queue> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> constexpr long long MOD = 1000000007; int main() { int N, A, B, C, D; std::cin >> N >> A >> B >> C >> D; --A; --B; --C; --D; std::string str; std::cin >> str; bool AtoC = true; for (int i = A + 1; i < C; ++i) { if (str[i] == '#' && str[i + 1] == '#') { AtoC = false; break; } } bool BtoD = true; for (int i = B + 1; i < D; ++i) { if (str[i] == '#' && str[i + 1] == '#') { BtoD = false; break; } } if (C < B || C < D) { std::cout << (AtoC && BtoD ? "Yes" : "No") << std::endl; } else { bool canOver = false; for (int i = B - 1; i < D; ++i) { if (i + 2 < str.size() && str[i] == '.' && str[i + 1] == '.' && str[i + 2] == '.') { canOver = true; break; } } std::cout << (AtoC && BtoD && canOver ? "Yes" : "No") << std::endl; } return 0; }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
832,818
832,819
u866733412
cpp
p03017
#include <algorithm> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <memory> #include <numeric> #include <queue> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> constexpr long long MOD = 1000000007; int main() { int N, A, B, C, D; std::cin >> N >> A >> B >> C >> D; --A; --B; --C; --D; std::string str; std::cin >> str; bool AtoC = true; for (int i = A + 1; i < C; ++i) { if (str[i] == '#' && str[i + 1] == '#') { AtoC = false; break; } } bool BtoD = true; for (int i = B + 1; i < D; ++i) { if (str[i] == '#' && str[i + 1] == '#') { AtoC = false; break; } } if (C < B || C < D) { std::cout << (AtoC && BtoD ? "Yes" : "No") << std::endl; } else { bool canOver = false; for (int i = B - 1; i < D - 1; ++i) { if (i + 2 < str.size() && str[i] == '.' && str[i + 1] == '.' && str[i + 2] == '.') { canOver = true; break; } } std::cout << (AtoC && BtoD && canOver ? "Yes" : "No") << std::endl; } return 0; }
#include <algorithm> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <memory> #include <numeric> #include <queue> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> constexpr long long MOD = 1000000007; int main() { int N, A, B, C, D; std::cin >> N >> A >> B >> C >> D; --A; --B; --C; --D; std::string str; std::cin >> str; bool AtoC = true; for (int i = A + 1; i < C; ++i) { if (str[i] == '#' && str[i + 1] == '#') { AtoC = false; break; } } bool BtoD = true; for (int i = B + 1; i < D; ++i) { if (str[i] == '#' && str[i + 1] == '#') { BtoD = false; break; } } if (C < B || C < D) { std::cout << (AtoC && BtoD ? "Yes" : "No") << std::endl; } else { bool canOver = false; for (int i = B - 1; i < D; ++i) { if (i + 2 < str.size() && str[i] == '.' && str[i + 1] == '.' && str[i + 2] == '.') { canOver = true; break; } } std::cout << (AtoC && BtoD && canOver ? "Yes" : "No") << std::endl; } return 0; }
[ "assignment.variable.change", "identifier.change", "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
832,820
832,819
u866733412
cpp
p03017
#include <algorithm> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <memory> #include <numeric> #include <queue> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> constexpr long long MOD = 1000000007; int main() { int N, A, B, C, D; std::cin >> N >> A >> B >> C >> D; --A; --B; --C; --D; std::string str; std::cin >> str; bool AtoC = true; for (int i = A + 1; i < D; ++i) { if (str[i] == '#' && str[i + 1] == '#') { AtoC = false; break; } } bool BtoD = true; for (int i = B + 1; i < D; ++i) { if (str[i] == '#' && str[i + 1] == '#') { AtoC = false; break; } } if (C < B || C < D) { std::cout << (AtoC && BtoD ? "Yes" : "No") << std::endl; } else { bool canOver = false; for (int i = B - 1; i < D - 1; ++i) { if (i + 2 < str.size() && str[i] == '.' && str[i + 1] == '.' && str[i + 2] == '.') { canOver = true; break; } } std::cout << (AtoC && BtoD && canOver ? "Yes" : "No") << std::endl; } return 0; }
#include <algorithm> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <memory> #include <numeric> #include <queue> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> constexpr long long MOD = 1000000007; int main() { int N, A, B, C, D; std::cin >> N >> A >> B >> C >> D; --A; --B; --C; --D; std::string str; std::cin >> str; bool AtoC = true; for (int i = A + 1; i < C; ++i) { if (str[i] == '#' && str[i + 1] == '#') { AtoC = false; break; } } bool BtoD = true; for (int i = B + 1; i < D; ++i) { if (str[i] == '#' && str[i + 1] == '#') { BtoD = false; break; } } if (C < B || C < D) { std::cout << (AtoC && BtoD ? "Yes" : "No") << std::endl; } else { bool canOver = false; for (int i = B - 1; i < D; ++i) { if (i + 2 < str.size() && str[i] == '.' && str[i + 1] == '.' && str[i + 2] == '.') { canOver = true; break; } } std::cout << (AtoC && BtoD && canOver ? "Yes" : "No") << std::endl; } return 0; }
[ "identifier.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change", "assignment.variable.change", "expression.operation.binary.remove" ]
832,821
832,819
u866733412
cpp
p03017
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <string> #include <vector> typedef long long ll; using namespace std; int main(void) { string s; int i, j, n, a, b, c, d; bool r1 = 0, b1 = 0, b2 = 0, b3 = 0; cin >> n >> a >> b >> c >> d; cin >> s; if (c < d) { r1 = 0; for (i = b - 1; i < d - 1; i++) { if (s[i] == '#') { if (r1) { cout << "No" << endl; return 0; } r1 = 1; } else { r1 = 0; } } r1 = 0; for (i = a - 1; i < c - 1; i++) { if (s[i] == '#') { if (r1) { cout << "No" << endl; return 0; } r1 = 1; } else { r1 = 0; } } cout << "Yes" << endl; return 0; } else { for (i = b - 2; i < d - 1; i++) { if (s[i] == '#') { b1 = b2 = 0; } else { if (b1) { if (b2) { b3 = 1; break; } else { b2 = 1; } } b1 = 1; } } r1 = 0; for (i = a - 1; i < c - 1; i++) { if (s[i] == '#') { if (r1) { cout << "No" << endl; return 0; } r1 = 1; } else { r1 = 0; } } if (b3) { cout << "Yes" << endl; } else { cout << "No" << endl; } } return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <string> #include <vector> typedef long long ll; using namespace std; int main(void) { string s; int i, n, a, b, c, d; bool r1 = 0, b1 = 0, b2 = 0, b3 = 0; cin >> n >> a >> b >> c >> d; cin >> s; if (c < d) { r1 = 0; for (i = b - 1; i < d - 1; i++) { if (s[i] == '#') { if (r1) { cout << "No" << endl; return 0; } r1 = 1; } else { r1 = 0; } } r1 = 0; for (i = a - 1; i < c - 1; i++) { if (s[i] == '#') { if (r1) { cout << "No" << endl; return 0; } r1 = 1; } else { r1 = 0; } } cout << "Yes" << endl; return 0; } else { for (i = b - 2; i < d + 1; i++) { if (s[i] == '#') { b1 = b2 = 0; } else { if (b1) { if (b2) { b3 = 1; break; } else { b2 = 1; } } b1 = 1; } } r1 = 0; for (i = a - 1; i < c - 1; i++) { if (s[i] == '#') { if (r1) { cout << "No" << endl; return 0; } r1 = 1; } else { r1 = 0; } } if (b3) { cout << "Yes" << endl; } else { cout << "No" << endl; } } return 0; }
[ "variable_declaration.remove", "misc.opposites", "expression.operator.arithmetic.change", "control_flow.branch.if.condition.change" ]
832,829
832,830
u516922881
cpp
p03017
#include <bits/stdc++.h> using namespace std; #define ll long long #define ini(arr, val) memset(arr, (val), sizeof(arr)) #define loop(i, n) for (ll i = 0; i < n; i++) #define all(a) (a).begin(), (a).end() #define exist(s, e) (s.find(e) != s.end()) #define dbg(x) cerr << #x << " is " << x << endl; #define pt(x) cout << x << "\n"; #define mp make_pair #define pb push_back #define f first #define s second #define inf (int)1e9 #define eps 1e-9 #define PI 3.1415926535897932384626433832795 #define mod 1000000007 #define fast \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define test \ int t; \ cin >> t; \ while (t--) typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<string> vs; typedef vector<pii> vpii; typedef vector<vi> vvi; typedef map<int, int> mii; typedef set<int> si; typedef pair<ll, ll> pll; typedef vector<ll> vl; typedef vector<string> vs; typedef vector<pll> vpll; typedef vector<vl> vvl; typedef map<ll, ll> mll; typedef set<ll> sl; ////////////////////////////////////////////////////////////////////////////////////////// // main starts ////////////////////////////////////////////////////////////////////////////////////////// int const lmt = 1e5 + 5; ll n, a, b, c, d; string s; bool check(ll a, ll e) { for (int i = a; i < e; i++) { if (s[i] == '#' && s[i] == s[i + 1]) return false; } return true; } int main() { fast cin >> n >> a >> b >> c >> d; cin >> s; a--; b--; c--; d--; if (c == d) { cout << "No\n"; return 0; } if (c <= b || c < d) { if (check(b, d)) { s[d] = '#'; if (check(a, c)) cout << "Yes\n"; else { cout << "No\n"; } } else { cout << "No\n"; } } else if (d < c) { if (check(b, d) && check(a, c)) { for (int i = b; i < d - 1; i++) { if (s[i] == '.' && s[i] == s[i + 1] && s[i] == s[i + 2]) { cout << "Yes\n"; return 0; } } } cout << "No\n"; } else { cout << "No\n"; } } /* */
#include <bits/stdc++.h> using namespace std; #define ll long long #define ini(arr, val) memset(arr, (val), sizeof(arr)) #define loop(i, n) for (ll i = 0; i < n; i++) #define all(a) (a).begin(), (a).end() #define exist(s, e) (s.find(e) != s.end()) #define dbg(x) cerr << #x << " is " << x << endl; #define pt(x) cout << x << "\n"; #define mp make_pair #define pb push_back #define f first #define s second #define inf (int)1e9 #define eps 1e-9 #define PI 3.1415926535897932384626433832795 #define mod 1000000007 #define fast \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define test \ int t; \ cin >> t; \ while (t--) typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<string> vs; typedef vector<pii> vpii; typedef vector<vi> vvi; typedef map<int, int> mii; typedef set<int> si; typedef pair<ll, ll> pll; typedef vector<ll> vl; typedef vector<string> vs; typedef vector<pll> vpll; typedef vector<vl> vvl; typedef map<ll, ll> mll; typedef set<ll> sl; ////////////////////////////////////////////////////////////////////////////////////////// // main starts ////////////////////////////////////////////////////////////////////////////////////////// int const lmt = 1e5 + 5; ll n, a, b, c, d; string s; bool check(ll a, ll e) { for (int i = a; i < e; i++) { if (s[i] == '#' && s[i] == s[i + 1]) return false; } return true; } int main() { fast cin >> n >> a >> b >> c >> d; cin >> s; a--; b--; c--; d--; if (c == d) { cout << "No\n"; return 0; } if (c <= b || c < d) { if (check(b, d)) { s[d] = '#'; if (check(a, c)) cout << "Yes\n"; else { cout << "No\n"; } } else { cout << "No\n"; } } else if (d < c) { if (check(b, d) && check(a, c)) { for (int i = b - 1; i < d; i++) { if (s[i] == '.' && s[i] == s[i + 1] && s[i] == s[i + 2]) { cout << "Yes\n"; return 0; } } } cout << "No\n"; } else { cout << "No\n"; } } /* */
[ "control_flow.loop.for.initializer.change", "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
832,834
832,835
u105645742
cpp
p03017
#include <algorithm> #include <deque> #include <iostream> #include <math.h> #include <queue> #include <string> #include <vector> using namespace std; typedef pair<int, int> P; typedef pair<int, pair<int, int>> PP; typedef long long ll; int main() { int n, a, b, c, d; cin >> n >> a >> b >> c >> d; string s; cin >> s; bool flag = false; for (int i = min(a - 1, b - 1) + 1; i <= max(c - 1, d - 1); i++) { if (s[i - 1] == '#' && s[i] == '#') { cout << "No" << endl; return 0; } } for (int i = max(a - 1, b - 1); i <= min(c - 1, d - 1) - 2 + 1; i++) { if (s[i] == '.' && (s[i + 1] == '.' && s[i + 2] == '.')) { flag = true; break; } } if (a > b && c > d) { cout << "Yes" << endl; } else if (a < b && c < d) { cout << "Yes" << endl; } else { if (flag == true) { cout << "Yes" << endl; } else { cout << "No" << endl; } } return 0; }
#include <algorithm> #include <deque> #include <iostream> #include <math.h> #include <queue> #include <string> #include <vector> using namespace std; typedef pair<int, int> P; typedef pair<int, pair<int, int>> PP; typedef long long ll; int main() { int n, a, b, c, d; cin >> n >> a >> b >> c >> d; string s; cin >> s; bool flag = false; for (int i = min(a - 1, b - 1) + 1; i <= max(c - 1, d - 1); i++) { if (s[i - 1] == '#' && s[i] == '#') { cout << "No" << endl; return 0; } } for (int i = max(a - 1, b - 1) - 1; i <= min(c - 1, d - 1) - 2 + 1; i++) { if (s[i] == '.' && (s[i + 1] == '.' && s[i + 2] == '.')) { flag = true; break; } } if (a > b && c > d) { cout << "Yes" << endl; } else if (a < b && c < d) { cout << "Yes" << endl; } else { if (flag == true) { cout << "Yes" << endl; } else { cout << "No" << endl; } } return 0; }
[ "control_flow.loop.for.initializer.change" ]
832,842
832,843
u678503521
cpp
p03017
#include <algorithm> #include <deque> #include <iostream> #include <math.h> #include <queue> #include <string> #include <vector> using namespace std; typedef pair<int, int> P; typedef pair<int, pair<int, int>> PP; typedef long long ll; int main() { int n, a, b, c, d; cin >> n >> a >> b >> c >> d; string s; cin >> s; bool flag = false; for (int i = min(a - 1, b - 1) + 1; i <= max(c - 1, d - 1); i++) { if (s[i - 1] == '#' && s[i] == '#') { cout << "No" << endl; return 0; } } for (int i = max(a - 1, b - 1); i <= min(c - 1, d - 1) - 2; i++) { if (s[i] == '.' && (s[i + 1] == '.' && s[i + 2] == '.')) { flag = true; break; } } if (a > b && c > d) { cout << "Yes" << endl; } else if (a < b && c < d) { cout << "Yes" << endl; } else { if (flag == true) { cout << "Yes" << endl; } else { cout << "No" << endl; } } return 0; }
#include <algorithm> #include <deque> #include <iostream> #include <math.h> #include <queue> #include <string> #include <vector> using namespace std; typedef pair<int, int> P; typedef pair<int, pair<int, int>> PP; typedef long long ll; int main() { int n, a, b, c, d; cin >> n >> a >> b >> c >> d; string s; cin >> s; bool flag = false; for (int i = min(a - 1, b - 1) + 1; i <= max(c - 1, d - 1); i++) { if (s[i - 1] == '#' && s[i] == '#') { cout << "No" << endl; return 0; } } for (int i = max(a - 1, b - 1) - 1; i <= min(c - 1, d - 1) - 2 + 1; i++) { if (s[i] == '.' && (s[i + 1] == '.' && s[i + 2] == '.')) { flag = true; break; } } if (a > b && c > d) { cout << "Yes" << endl; } else if (a < b && c < d) { cout << "Yes" << endl; } else { if (flag == true) { cout << "Yes" << endl; } else { cout << "No" << endl; } } return 0; }
[ "control_flow.loop.for.initializer.change", "control_flow.loop.for.condition.change", "misc.off_by_one" ]
832,844
832,843
u678503521
cpp
p03017
// template version 1.11 using namespace std; #include <bits/stdc++.h> #include <iostream> // varibable settings {{{ #define infile "../test/sample-1.in" #define int long long const int INF = 1e18; const int MOD = 1e9 + 7; // }}} // define basic macro {{{ #define _overload3(_1, _2, _3, name, ...) name #define _rep(i, n) repi(i, 0, n) #define repi(i, a, b) for (int i = (int)(a); i < (int)(b); ++i) #define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__) #define _rrep(i, n) rrepi(i, 0, n) #define rrepi(i, a, b) for (int i = (int)((b)-1); i >= (int)(a); --i) #define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__) #define each(i, a) for (auto &&i : a) #define all(x) (x).begin(), (x).end() #define sz(x) ((int)(x).size()) #define pb(a) push_back(a) #define mp(a, b) make_pair(a, b) #define uni(x) \ sort(all(x)); \ x.erase(unique(all(x)), x.end()) #define ub upper_bound #define lb lower_bound template <class T> inline void chmax(T &a, const T &b) { if ((a) < (b)) (a) = (b); } template <class T> inline void chmin(T &a, const T &b) { if ((a) > (b)) (a) = (b); } typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef long double ld; typedef pair<int, int> pii; typedef tuple<int, int, int> iii; template <typename T> using PQ = priority_queue<T, vector<T>, greater<T>>; struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast; #if defined(PCM) || defined(LOCAL) #include "lib/dump.hpp" #else #define dump(...) 42 #define dump_1d(...) 42 #define dump_2d(...) 42 #endif //}}} int solve() { int n, a, b, c, d; cin >> n >> a >> b >> c >> d; a--; b--; c--; d--; string s; cin >> s; if (c < b) { rep(i, a + 1, c - 1) { if (s[i] == '#' and s[i + 1] == '#') { cout << "No" << endl; return 0; } } rep(i, b + 1, d - 1) { if (s[i] == '#' and s[i + 1] == '#') { cout << "No" << endl; return 0; } } cout << "Yes" << endl; return 0; } else if (c < d) { rep(i, a + 1, d - 1) { if (s[i] == '#' and s[i + 1] == '#') { cout << "No" << endl; return 0; } } cout << "Yes" << endl; return 0; } else if (d < c) { rep(i, a + 1, c - 1) { if (s[i] == '#' and s[i + 1] == '#') { cout << "No" << endl; return 0; } } rep(i, b - 1, d - 1) { if (s[i] == '.' and s[i + 1] == '.' and s[i + 2] == '.') { cout << "Yes" << endl; return 0; } } cout << "No" << endl; return 0; } else { assert(false); } return 0; } signed main() { //{{{ #ifdef INPUT_FROM_FILE std::ifstream in(infile); std::cin.rdbuf(in.rdbuf()); #endif solve(); return 0; } //}}}
// template version 1.11 using namespace std; #include <bits/stdc++.h> #include <iostream> // varibable settings {{{ #define infile "../test/sample-1.in" #define int long long const int INF = 1e18; const int MOD = 1e9 + 7; // }}} // define basic macro {{{ #define _overload3(_1, _2, _3, name, ...) name #define _rep(i, n) repi(i, 0, n) #define repi(i, a, b) for (int i = (int)(a); i < (int)(b); ++i) #define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__) #define _rrep(i, n) rrepi(i, 0, n) #define rrepi(i, a, b) for (int i = (int)((b)-1); i >= (int)(a); --i) #define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__) #define each(i, a) for (auto &&i : a) #define all(x) (x).begin(), (x).end() #define sz(x) ((int)(x).size()) #define pb(a) push_back(a) #define mp(a, b) make_pair(a, b) #define uni(x) \ sort(all(x)); \ x.erase(unique(all(x)), x.end()) #define ub upper_bound #define lb lower_bound template <class T> inline void chmax(T &a, const T &b) { if ((a) < (b)) (a) = (b); } template <class T> inline void chmin(T &a, const T &b) { if ((a) > (b)) (a) = (b); } typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef long double ld; typedef pair<int, int> pii; typedef tuple<int, int, int> iii; template <typename T> using PQ = priority_queue<T, vector<T>, greater<T>>; struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast; #if defined(PCM) || defined(LOCAL) #include "lib/dump.hpp" #else #define dump(...) 42 #define dump_1d(...) 42 #define dump_2d(...) 42 #endif //}}} int solve() { int n, a, b, c, d; cin >> n >> a >> b >> c >> d; a--; b--; c--; d--; string s; cin >> s; if (c < b) { rep(i, a + 1, c - 1) { if (s[i] == '#' and s[i + 1] == '#') { cout << "No" << endl; return 0; } } rep(i, b + 1, d - 1) { if (s[i] == '#' and s[i + 1] == '#') { cout << "No" << endl; return 0; } } cout << "Yes" << endl; return 0; } else if (c < d) { rep(i, a + 1, d - 1) { if (s[i] == '#' and s[i + 1] == '#') { cout << "No" << endl; return 0; } } cout << "Yes" << endl; return 0; } else if (d < c) { rep(i, a + 1, c - 1) { if (s[i] == '#' and s[i + 1] == '#') { cout << "No" << endl; return 0; } } rep(i, b - 1, d) { if (s[i] == '.' and s[i + 1] == '.' and s[i + 2] == '.') { cout << "Yes" << endl; return 0; } } cout << "No" << endl; return 0; } else { assert(false); } return 0; } signed main() { //{{{ #ifdef INPUT_FROM_FILE std::ifstream in(infile); std::cin.rdbuf(in.rdbuf()); #endif solve(); return 0; } //}}}
[ "expression.operation.binary.remove" ]
832,866
832,867
u314057689
cpp
p03017
#include <bits/stdc++.h> using namespace std; int n, m, i, j, t, k, s, a, b, c, d; char st[200005]; int main() { scanf("%d%d%d%d%d", &n, &a, &b, &c, &d); scanf("%s", st + 1); for (i = a; i < max(c, d); ++i) if (st[i] == '#' && st[i + 1] == '#') { printf("No\n"); return 0; } if (c < d) { printf("Yes\n"); return 0; } for (i = b - 1; i <= min(d - 2, n - 2); ++i) if (st[i] == '.' && st[i + 1] == '.' && st[i + 2] == '.') { printf("Yes\n"); return 0; } /*for (i=c+2;i<=n-2&&(st[i]!='#'||st[i+1]!='#');++i) if (st[i]=='.'&&st[i+1]=='.'&&st[i+2]=='.') { printf("Yes\n"); return 0; } for (i=a-2;i>0&&(st[i]!='#'||st[i+1]!='#');--i) if (st[i]=='.'&&st[i+1]=='.'&&st[i+2]=='.') { printf("Yes\n"); return 0; }*/ printf("No\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int n, m, i, j, t, k, s, a, b, c, d; char st[200005]; int main() { scanf("%d%d%d%d%d", &n, &a, &b, &c, &d); scanf("%s", st + 1); for (i = a; i < max(c, d); ++i) if (st[i] == '#' && st[i + 1] == '#') { printf("No\n"); return 0; } if (c < d) { printf("Yes\n"); return 0; } for (i = b - 1; i <= min(d - 1, n - 2); ++i) if (st[i] == '.' && st[i + 1] == '.' && st[i + 2] == '.') { printf("Yes\n"); return 0; } /*for (i=c+2;i<=n-2&&(st[i]!='#'||st[i+1]!='#');++i) if (st[i]=='.'&&st[i+1]=='.'&&st[i+2]=='.') { printf("Yes\n"); return 0; } for (i=a-2;i>0&&(st[i]!='#'||st[i+1]!='#');--i) if (st[i]=='.'&&st[i+1]=='.'&&st[i+2]=='.') { printf("Yes\n"); return 0; }*/ printf("No\n"); return 0; }
[ "literal.number.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "call.arguments.change", "expression.operation.binary.change" ]
832,871
832,872
u886728471
cpp
p03017
#include <bits/stdc++.h> using namespace std; int n, m, i, j, t, k, s, a, b, c, d; char st[200005]; int main() { scanf("%d%d%d%d%d", &n, &a, &b, &c, &d); scanf("%s", st + 1); for (i = a; i < max(c, d); ++i) if (st[i] == '#' && st[i + 1] == '#') { printf("No\n"); return 0; } if (c < d) { printf("Yes\n"); return 0; } for (i = a - 2; i <= min(d - 2, n - 2); ++i) if (st[i] == '.' && st[i + 1] == '.' && st[i + 2] == '.') { printf("Yes\n"); return 0; } /*for (i=c+2;i<=n-2&&(st[i]!='#'||st[i+1]!='#');++i) if (st[i]=='.'&&st[i+1]=='.'&&st[i+2]=='.') { printf("Yes\n"); return 0; } for (i=a-2;i>0&&(st[i]!='#'||st[i+1]!='#');--i) if (st[i]=='.'&&st[i+1]=='.'&&st[i+2]=='.') { printf("Yes\n"); return 0; }*/ printf("No\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int n, m, i, j, t, k, s, a, b, c, d; char st[200005]; int main() { scanf("%d%d%d%d%d", &n, &a, &b, &c, &d); scanf("%s", st + 1); for (i = a; i < max(c, d); ++i) if (st[i] == '#' && st[i + 1] == '#') { printf("No\n"); return 0; } if (c < d) { printf("Yes\n"); return 0; } for (i = b - 1; i <= min(d - 1, n - 2); ++i) if (st[i] == '.' && st[i + 1] == '.' && st[i + 2] == '.') { printf("Yes\n"); return 0; } /*for (i=c+2;i<=n-2&&(st[i]!='#'||st[i+1]!='#');++i) if (st[i]=='.'&&st[i+1]=='.'&&st[i+2]=='.') { printf("Yes\n"); return 0; } for (i=a-2;i>0&&(st[i]!='#'||st[i+1]!='#');--i) if (st[i]=='.'&&st[i+1]=='.'&&st[i+2]=='.') { printf("Yes\n"); return 0; }*/ printf("No\n"); return 0; }
[ "assignment.value.change", "identifier.change", "control_flow.loop.for.initializer.change", "expression.operation.binary.change", "literal.number.change", "expression.off_by_one", "control_flow.loop.for.condition.change", "call.arguments.change" ]
832,873
832,872
u886728471
cpp
p03017
#include <bits/stdc++.h> using namespace std; int n, m, i, j, t, k, s, a, b, c, d; char st[200005]; int main() { scanf("%d%d%d%d%d", &n, &a, &b, &c, &d); scanf("%s", st + 1); for (i = a; i < max(c, d); ++i) if (st[i] == '#' && st[i + 1] == '#') { printf("No\n"); return 0; } if (c < d) { printf("Yes\n"); return 0; } for (i = a - 2; i <= min(c, n - 2); ++i) if (st[i] == '.' && st[i + 1] == '.' && st[i + 2] == '.') { printf("Yes\n"); return 0; } /*for (i=c+2;i<=n-2&&(st[i]!='#'||st[i+1]!='#');++i) if (st[i]=='.'&&st[i+1]=='.'&&st[i+2]=='.') { printf("Yes\n"); return 0; } for (i=a-2;i>0&&(st[i]!='#'||st[i+1]!='#');--i) if (st[i]=='.'&&st[i+1]=='.'&&st[i+2]=='.') { printf("Yes\n"); return 0; }*/ printf("No\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int n, m, i, j, t, k, s, a, b, c, d; char st[200005]; int main() { scanf("%d%d%d%d%d", &n, &a, &b, &c, &d); scanf("%s", st + 1); for (i = a; i < max(c, d); ++i) if (st[i] == '#' && st[i + 1] == '#') { printf("No\n"); return 0; } if (c < d) { printf("Yes\n"); return 0; } for (i = b - 1; i <= min(d - 1, n - 2); ++i) if (st[i] == '.' && st[i + 1] == '.' && st[i + 2] == '.') { printf("Yes\n"); return 0; } /*for (i=c+2;i<=n-2&&(st[i]!='#'||st[i+1]!='#');++i) if (st[i]=='.'&&st[i+1]=='.'&&st[i+2]=='.') { printf("Yes\n"); return 0; } for (i=a-2;i>0&&(st[i]!='#'||st[i+1]!='#');--i) if (st[i]=='.'&&st[i+1]=='.'&&st[i+2]=='.') { printf("Yes\n"); return 0; }*/ printf("No\n"); return 0; }
[ "assignment.value.change", "identifier.change", "control_flow.loop.for.initializer.change", "expression.operation.binary.change", "literal.number.change", "expression.off_by_one", "control_flow.loop.for.condition.change", "call.arguments.change", "misc.off_by_one" ]
832,874
832,872
u886728471
cpp
p03017
#include <bits/stdc++.h> #define REP(i, N) for (int i = 0; i < (N); ++i) #define ALL(x) (x).begin(), (x).end() #define MOD 1000000007 #define PB push_back #define MP make_pair using namespace std; typedef long long ll; ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; } ll div_ceil(ll, ll); int dx[4] = {0, 0, -1, 1}; int dy[4] = {-1, 1, 0, 0}; int main() { ll N, a, b, c, d; std::cin >> N >> a >> b >> c >> d; string S; std::cin >> S; bool ans = true; if (c < d) { for (int i = a - 1; i < d - 1; i++) { if (S[i] == '#' && S[i + 1] == '#') { ans = false; } } } else { ans = false; for (int i = b - 2; i < d - 2; i++) { if (S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.') { ans = true; } } for (int i = a - 1; i < c - 1; i++) { if (S[i] == '#' && S[i + 1] == '#') { ans = false; } } } if (ans) { std::cout << "Yes" << '\n'; } else { std::cout << "No" << '\n'; } } ll div_ceil(ll a, ll b) { ll quotient = a / b; ll remainder = a % b; if (remainder == 0) { return quotient; } else { return quotient + 1; } }
#include <bits/stdc++.h> #define REP(i, N) for (int i = 0; i < (N); ++i) #define ALL(x) (x).begin(), (x).end() #define MOD 1000000007 #define PB push_back #define MP make_pair using namespace std; typedef long long ll; ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; } ll div_ceil(ll, ll); int dx[4] = {0, 0, -1, 1}; int dy[4] = {-1, 1, 0, 0}; int main() { ll N, a, b, c, d; std::cin >> N >> a >> b >> c >> d; string S; std::cin >> S; bool ans = true; if (c < d) { for (int i = a - 1; i < d - 1; i++) { if (S[i] == '#' && S[i + 1] == '#') { ans = false; } } } else { ans = false; for (int i = b - 2; i < d - 1; i++) { if (S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.') { ans = true; } } for (int i = a - 1; i < c - 1; i++) { if (S[i] == '#' && S[i + 1] == '#') { ans = false; } } } if (ans) { std::cout << "Yes" << '\n'; } else { std::cout << "No" << '\n'; } } ll div_ceil(ll a, ll b) { ll quotient = a / b; ll remainder = a % b; if (remainder == 0) { return quotient; } else { return quotient + 1; } }
[ "literal.number.change", "control_flow.branch.if.condition.change" ]
832,878
832,879
u408053343
cpp
p03017
#include <bits/stdc++.h> #define REP(i, N) for (int i = 0; i < (N); ++i) #define ALL(x) (x).begin(), (x).end() #define MOD 1000000007 #define PB push_back #define MP make_pair using namespace std; typedef long long ll; ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; } ll div_ceil(ll, ll); int dx[4] = {0, 0, -1, 1}; int dy[4] = {-1, 1, 0, 0}; int main() { ll N, a, b, c, d; std::cin >> N >> a >> b >> c >> d; string S; std::cin >> S; bool ans = true; if (c < d) { for (int i = a - 1; i < d - 1; i++) { if (S[i] == '#' && S[i + 1] == '#') { ans = false; } } } else { ans = false; for (int i = b - 1; i < d - 2; i++) { if (S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.') { ans = true; } } for (int i = a - 1; i < c - 1; i++) { if (S[i] == '#' && S[i + 1] == '#') { ans = false; } } } if (ans) { std::cout << "Yes" << '\n'; } else { std::cout << "No" << '\n'; } } ll div_ceil(ll a, ll b) { ll quotient = a / b; ll remainder = a % b; if (remainder == 0) { return quotient; } else { return quotient + 1; } }
#include <bits/stdc++.h> #define REP(i, N) for (int i = 0; i < (N); ++i) #define ALL(x) (x).begin(), (x).end() #define MOD 1000000007 #define PB push_back #define MP make_pair using namespace std; typedef long long ll; ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; } ll div_ceil(ll, ll); int dx[4] = {0, 0, -1, 1}; int dy[4] = {-1, 1, 0, 0}; int main() { ll N, a, b, c, d; std::cin >> N >> a >> b >> c >> d; string S; std::cin >> S; bool ans = true; if (c < d) { for (int i = a - 1; i < d - 1; i++) { if (S[i] == '#' && S[i + 1] == '#') { ans = false; } } } else { ans = false; for (int i = b - 2; i < d - 1; i++) { if (S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.') { ans = true; } } for (int i = a - 1; i < c - 1; i++) { if (S[i] == '#' && S[i + 1] == '#') { ans = false; } } } if (ans) { std::cout << "Yes" << '\n'; } else { std::cout << "No" << '\n'; } } ll div_ceil(ll a, ll b) { ll quotient = a / b; ll remainder = a % b; if (remainder == 0) { return quotient; } else { return quotient + 1; } }
[ "literal.number.change", "control_flow.loop.for.initializer.change", "expression.off_by_one", "expression.operation.binary.change", "control_flow.branch.if.condition.change" ]
832,880
832,879
u408053343
cpp
p03017
#include <bits/stdc++.h> #define REP(i, N) for (int i = 0; i < (N); ++i) #define ALL(x) (x).begin(), (x).end() #define MOD 1000000007 #define PB push_back #define MP make_pair using namespace std; typedef long long ll; ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; } ll div_ceil(ll, ll); int dx[4] = {0, 0, -1, 1}; int dy[4] = {-1, 1, 0, 0}; int main() { ll N, a, b, c, d; std::cin >> N >> a >> b >> c >> d; string S; std::cin >> S; bool ans = true; if (c < d) { for (int i = a - 1; i < d - 1; i++) { if (S[i] == '#' && S[i - 1] == '#') { ans = false; } } } else { ans = false; for (int i = b - 1; i < d - 2; i++) { if (S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.') { ans = true; } } for (int i = a - 1; i < c - 1; i++) { if (S[i] == '#' && S[i - 1] == '#') { ans = false; } } } if (ans) { std::cout << "Yes" << '\n'; } else { std::cout << "No" << '\n'; } } ll div_ceil(ll a, ll b) { ll quotient = a / b; ll remainder = a % b; if (remainder == 0) { return quotient; } else { return quotient + 1; } }
#include <bits/stdc++.h> #define REP(i, N) for (int i = 0; i < (N); ++i) #define ALL(x) (x).begin(), (x).end() #define MOD 1000000007 #define PB push_back #define MP make_pair using namespace std; typedef long long ll; ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; } ll div_ceil(ll, ll); int dx[4] = {0, 0, -1, 1}; int dy[4] = {-1, 1, 0, 0}; int main() { ll N, a, b, c, d; std::cin >> N >> a >> b >> c >> d; string S; std::cin >> S; bool ans = true; if (c < d) { for (int i = a - 1; i < d - 1; i++) { if (S[i] == '#' && S[i + 1] == '#') { ans = false; } } } else { ans = false; for (int i = b - 2; i < d - 1; i++) { if (S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.') { ans = true; } } for (int i = a - 1; i < c - 1; i++) { if (S[i] == '#' && S[i + 1] == '#') { ans = false; } } } if (ans) { std::cout << "Yes" << '\n'; } else { std::cout << "No" << '\n'; } } ll div_ceil(ll a, ll b) { ll quotient = a / b; ll remainder = a % b; if (remainder == 0) { return quotient; } else { return quotient + 1; } }
[ "misc.opposites", "expression.operator.arithmetic.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change", "literal.number.change", "control_flow.loop.for.initializer.change", "expression.off_by_one", "expression.operation.binary.change" ]
832,881
832,879
u408053343
cpp
p03017
#include <bits/stdc++.h> using namespace std; bool f(int x, int y, string s) { for (int i = x; i < y - 2; i++) { if (s[i] == '#' && s[i + 1] == '#') { return false; } } return true; } bool g(int x, int y, string s) { //すぬけ君がふぬけ君を抜けるか判定 for (int i = x - 1; i < y; i++) { if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') { return true; } } return false; } int main() { int n, a, b, c, d; string s; cin >> n >> a >> b >> c >> d; cin >> s; if (c < d) { if (f(b, d, s) && f(a, c, s)) { cout << "Yes" << endl; } else { cout << "No" << endl; } } else { if (g(b, c, s)) { if (f(b, d, s) && f(a, c, s)) { cout << "Yes" << endl; } else { cout << "No" << endl; } } else { cout << "No" << endl; } } return 0; }
#include <bits/stdc++.h> using namespace std; bool f(int x, int y, string s) { for (int i = x; i < y - 2; i++) { if (s[i] == '#' && s[i + 1] == '#') { return false; } } return true; } bool g(int x, int y, string s) { //すぬけ君がふぬけ君を抜けるか判定 for (int i = x - 1; i < y; i++) { if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') { return true; } } return false; } int main() { int n, a, b, c, d; string s; cin >> n >> a >> b >> c >> d; cin >> s; if (c < d) { if (f(b, d, s) && f(a, c, s)) { cout << "Yes" << endl; } else { cout << "No" << endl; } } else { if (g(b, d, s)) { if (f(b, d, s) && f(a, c, s)) { cout << "Yes" << endl; } else { cout << "No" << endl; } } else { cout << "No" << endl; } } return 0; }
[ "identifier.change", "control_flow.branch.if.condition.change" ]
832,891
832,892
u528388170
cpp
p03017
#include <bits/stdc++.h> using namespace std; using pint = pair<int, int>; using ll = long long; using pll = pair<ll, ll>; #define FOR(i, begin, end) \ for (int i = (begin), i##_end_ = (end); i < i##_end_; i++) #define IFOR(i, begin, end) \ for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--) #define REP(i, n) FOR(i, 0, n) #define IREP(i, n) IFOR(i, 0, n) #define FI first #define SE second #define endl "\n" #define ciosup \ cin.tie(0); \ ios::sync_with_stdio(false); #define eb emplace_back constexpr ll INF = 1e9 + 7; constexpr ll MOD = 1e9 + 7; int main() { int n, a, b, c, d; cin >> n >> a >> b >> c >> d; a--; b--; c--; d--; string s; cin >> s; // int l=a, r=n-1; // FOR(i, b+1, n) //{ // if (s[i-1] == '#' && s[i] == '#') // { // r = i - 2; // break; // } //} bool judge = true; if (c < d) { //先にBが動く(ABCD) FOR(i, b + 1, d) { if (s[i - 1] == '#' && s[i] == '#') { judge = false; } } FOR(i, a + 1, c) { if (s[i - 1] == '#' && s[i] == '#') { judge = false; } } } else { //先にAが動く(ABDC) judge = false; FOR(i, b + 2, d + 2) { if (s[i - 2] == '.' && s[i - 1] == '.' && s[i] == '.') { judge = true; break; } } FOR(i, b + 1, d) { if (s[i - 1] == '#' && s[i] == '#') { judge = false; } } FOR(i, a + 1, c) { if (s[i - 1] == '#' && s[i] == '#') { judge = false; } } } if (judge) { cout << "Yes" << endl; } else { cout << "No" << endl; } }
#include <bits/stdc++.h> using namespace std; using pint = pair<int, int>; using ll = long long; using pll = pair<ll, ll>; #define FOR(i, begin, end) \ for (int i = (begin), i##_end_ = (end); i < i##_end_; i++) #define IFOR(i, begin, end) \ for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--) #define REP(i, n) FOR(i, 0, n) #define IREP(i, n) IFOR(i, 0, n) #define FI first #define SE second #define endl "\n" #define ciosup \ cin.tie(0); \ ios::sync_with_stdio(false); #define eb emplace_back constexpr ll INF = 1e9 + 7; constexpr ll MOD = 1e9 + 7; int main() { int n, a, b, c, d; cin >> n >> a >> b >> c >> d; a--; b--; c--; d--; string s; cin >> s; bool judge = true; if (c < d) { //先にBが動く(ABCD) FOR(i, b + 1, d) { if (s[i - 1] == '#' && s[i] == '#') { judge = false; } } FOR(i, a + 1, c) { if (s[i - 1] == '#' && s[i] == '#') { judge = false; } } } else { //先にAが動く(ABDC) judge = false; FOR(i, b + 1, d + 2) { if (s[i - 2] == '.' && s[i - 1] == '.' && s[i] == '.') { judge = true; break; } } FOR(i, b + 1, d) { if (s[i - 1] == '#' && s[i] == '#') { judge = false; } } FOR(i, a + 1, c) { if (s[i - 1] == '#' && s[i] == '#') { judge = false; } } } if (judge) { cout << "Yes" << endl; } else { cout << "No" << endl; } }
[ "literal.number.change", "call.arguments.change", "expression.operation.binary.change" ]
832,893
832,894
u337054478
cpp
p03017
#include <algorithm> #include <iostream> #include <math.h> #include <sstream> #include <stdio.h> #include <string> #include <vector> using namespace std; int main() { int N, A, B, C, D; string S; cin >> N >> A >> B >> C >> D >> S; A = A - 1; B = B - 1; C = C - 1; D = D - 1; S[A] = 'A'; S[B] = 'B'; if (C < D) { while (1) { if (B == D) { break; } if (S[B + 2] != '#' && B + 2 <= D) { S[B + 2] = 'B'; S[B] = '.'; B = B + 2; } else if (S[B + 1] != '#' && B + 1 <= D) { S[B + 1] = 'B'; S[B] = '.'; B = B + 1; } else { cout << "No" << endl; return 0; } } while (1) { if (A == C) { break; } if (S[A + 2] != '#' && A + 2 <= C) { S[A + 2] = 'A'; S[A] = '.'; A = A + 2; } else if (S[A + 1] != '#' && A + 1 <= D) { S[A + 1] = 'A'; S[A] = '.'; A = A + 1; } else { cout << "No" << endl; return 0; } } } else { while (1) { if (S[A + 2] != '#' && A + 2 <= C && S[A + 2] != 'B') { S[A + 2] = 'A'; S[A] = '.'; A = A + 2; } else if (S[A + 1] != '#' && A + 1 <= D && S[A + 1] != 'B') { S[A + 1] = 'A'; S[A] = '.'; A = A + 1; } else if (S[B + 1] != '#' && B + 1 <= D) { S[B + 1] = 'B'; S[B] = '.'; B = B + 1; } else if (S[B + 2] != '#' && B + 2 <= D) { S[B + 2] = 'B'; S[B] = '.'; B = B + 2; } else { cout << "No" << endl; return 0; } if (A > B) { break; } } while (1) { if (A == C) { break; } if (S[A + 2] != '#' && A + 2 <= C) { S[A + 2] = 'A'; S[A] = '.'; A = A + 2; } else if (S[A + 1] != '#' && A + 1 <= D) { S[A + 1] = 'A'; S[A] = '.'; A = A + 1; } else { cout << "No" << endl; return 0; } } while (1) { if (B == D) { break; } if (S[B + 2] != '#' && B + 2 <= D) { S[B + 2] = 'B'; S[B] = '.'; B = B + 2; } else if (S[B + 1] != '#' && B + 1 <= D) { S[B + 1] = 'B'; S[B] = '.'; B = B + 1; } else { cout << "No" << endl; return 0; } } } cout << "Yes" << endl; return 0; }
#include <algorithm> #include <iostream> #include <math.h> #include <sstream> #include <stdio.h> #include <string> #include <vector> using namespace std; int main() { int N, A, B, C, D; string S; cin >> N >> A >> B >> C >> D >> S; A = A - 1; B = B - 1; C = C - 1; D = D - 1; S[A] = 'A'; S[B] = 'B'; if (C < D) { while (1) { if (B == D) { break; } if (S[B + 2] != '#' && B + 2 <= D) { S[B + 2] = 'B'; S[B] = '.'; B = B + 2; } else if (S[B + 1] != '#' && B + 1 <= D) { S[B + 1] = 'B'; S[B] = '.'; B = B + 1; } else { cout << "No" << endl; return 0; } } while (1) { if (A == C) { break; } if (S[A + 2] != '#' && A + 2 <= C) { S[A + 2] = 'A'; S[A] = '.'; A = A + 2; } else if (S[A + 1] != '#' && A + 1 <= C) { S[A + 1] = 'A'; S[A] = '.'; A = A + 1; } else { cout << "No" << endl; return 0; } } } else { while (1) { if (S[A + 2] != '#' && A + 2 <= C && S[A + 2] != 'B') { S[A + 2] = 'A'; S[A] = '.'; A = A + 2; } else if (S[A + 1] != '#' && A + 1 <= C && S[A + 1] != 'B') { S[A + 1] = 'A'; S[A] = '.'; A = A + 1; } else if (S[B + 1] != '#' && B + 1 <= D) { S[B + 1] = 'B'; S[B] = '.'; B = B + 1; } else if (S[B + 2] != '#' && B + 2 <= D) { S[B + 2] = 'B'; S[B] = '.'; B = B + 2; } else { cout << "No" << endl; return 0; } if (A > B) { break; } } while (1) { if (A == C) { break; } if (S[A + 2] != '#' && A + 2 <= C) { S[A + 2] = 'A'; S[A] = '.'; A = A + 2; } else if (S[A + 1] != '#' && A + 1 <= C) { S[A + 1] = 'A'; S[A] = '.'; A = A + 1; } else { cout << "No" << endl; return 0; } } while (1) { if (B == D) { break; } if (S[B + 2] != '#' && B + 2 <= D) { S[B + 2] = 'B'; S[B] = '.'; B = B + 2; } else if (S[B + 1] != '#' && B + 1 <= D) { S[B + 1] = 'B'; S[B] = '.'; B = B + 1; } else { cout << "No" << endl; return 0; } } } cout << "Yes" << endl; return 0; }
[ "identifier.change", "control_flow.branch.if.condition.change" ]
832,899
832,900
u490552503
cpp
p03017
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define repr(i, n) for (int i = (n); i >= 0; i--) #define ALL(x) (x).begin(), (x).end() int GCD(int a, int b) { return b ? GCD(b, a % b) : a; } int LCM(int a, int b) { return a * b / GCD(a, b); } typedef long long ll; typedef unsigned long long ull; const int INF = 1e9; const int MOD = 1e9 + 7; int main() { int n; cin >> n; int a, b, c, d; cin >> a >> b >> c >> d; string s; cin >> s; if (c < b) { for (int i = a - 1; i < d - 2; i++) { if (i >= c - 1 && i < b) continue; if (s[i] == '#' && s[i + 1] == '#') { cout << "No"; return 0; } } cout << "Yes"; return 0; } else if (c < d) { for (int i = a - 1; i < d - 2; i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No"; return 0; } } cout << "Yes"; return 0; } else if (d < c) { for (int i = a - 1; i < c - 2; i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No"; return 0; } } for (int i = b - 2; i <= d; i++) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { cout << "Yes"; return 0; } } cout << "No"; } return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define repr(i, n) for (int i = (n); i >= 0; i--) #define ALL(x) (x).begin(), (x).end() int GCD(int a, int b) { return b ? GCD(b, a % b) : a; } int LCM(int a, int b) { return a * b / GCD(a, b); } typedef long long ll; typedef unsigned long long ull; const int INF = 1e9; const int MOD = 1e9 + 7; int main() { int n; cin >> n; int a, b, c, d; cin >> a >> b >> c >> d; string s; cin >> s; if (c < b) { for (int i = a - 1; i < d - 2; i++) { if (i >= c - 1 && i <= b - 1) continue; if (s[i] == '#' && s[i + 1] == '#') { cout << "No"; return 0; } } cout << "Yes"; return 0; } else if (c < d) { for (int i = a - 1; i < d - 2; i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No"; return 0; } } cout << "Yes"; return 0; } else if (d < c) { for (int i = a - 1; i < c - 2; i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No"; return 0; } } for (int i = b - 2; i <= d - 2; i++) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { cout << "Yes"; return 0; } } cout << "No"; } return 0; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "misc.off_by_one" ]
832,910
832,911
u875541682
cpp
p03017
#include <algorithm> #include <bits/stdc++.h> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <fstream> #include <iostream> #include <iterator> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string.h> #include <vector> using namespace std; #define all(x) (x).begin(), (x).end() //#define mp make_pair #define pb push_back #define ff first #define ss second #define ll long long typedef vector<ll> vi; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll n, m, i, j, k, a, b, d, x, c = 0, u = 0, ans = 0; string s; cin >> n >> a >> b >> c >> d; cin >> s; a--; b--; c--; d--; for (i = a + 1; i < c - 1; i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No"; return 0; } } for (i = b + 1; i < d - 1; i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No"; return 0; } } if (c < d) { cout << "Yes"; return 0; } else { for (i = b - 1; i < d - 1; i++) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { cout << "Yes"; return 0; } } } cout << "No"; return 0; }
#include <algorithm> #include <bits/stdc++.h> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <fstream> #include <iostream> #include <iterator> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string.h> #include <vector> using namespace std; #define all(x) (x).begin(), (x).end() //#define mp make_pair #define pb push_back #define ff first #define ss second #define ll long long typedef vector<ll> vi; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll n, m, i, j, k, a, b, d, x, c = 0, u = 0, ans = 0; string s; cin >> n >> a >> b >> c >> d; cin >> s; a--; b--; c--; d--; for (i = a + 1; i < c - 1; i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No"; return 0; } } for (i = b + 1; i < d - 1; i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No"; return 0; } } if (c < d) { cout << "Yes"; return 0; } else { for (i = b - 1; i < d; i++) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { cout << "Yes"; return 0; } } } cout << "No"; return 0; }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
832,915
832,916
u415518175
cpp
p03017
#include <iostream> #include <string> using namespace std; int main() { int n, a, b, c, d; string s; bool ans_sub = false; cin >> n >> a >> b >> c >> d; cin >> s; if (d < c) { //交差する必要あり //三連'.'検索 for (int i = b - 1; i < d - 1; i++) { if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') { ans_sub = true; } } if (ans_sub == false) { cout << "No" << endl; return 0; } } //二連で岩が置かれていないかチェック for (int i = b - 1; i < d - 2; i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } } for (int i = a - 1; i < c - 2; i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } } cout << "Yes" << endl; }
#include <iostream> #include <string> using namespace std; int main() { int n, a, b, c, d; string s; bool ans_sub = false; cin >> n >> a >> b >> c >> d; cin >> s; if (d < c) { //交差する必要あり //三連'.'検索 for (int i = b - 1; i < d; i++) { if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') { ans_sub = true; } } if (ans_sub == false) { cout << "No" << endl; return 0; } } //二連で岩が置かれていないかチェック for (int i = b - 1; i < d - 1; i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } } for (int i = a - 1; i < c - 1; i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } } cout << "Yes" << endl; }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove", "literal.number.change", "expression.off_by_one", "expression.operation.binary.change" ]
832,920
832,921
u048128931
cpp
p03017
#include <iostream> #include <string> using namespace std; int main() { int n, a, b, c, d; string s; bool ans_sub = false; cin >> n >> a >> b >> c >> d; cin >> s; if (d < c) { //交差する必要あり //三連'.'検索 for (int i = b - 1; i < d - 1; i++) { if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') { ans_sub = true; } } if (ans_sub == false) { cout << "No" << endl; return 0; } } //二連で岩が置かれていないかチェック for (int i = b - 1; i < d - 1; i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } } for (int i = a - 1; i < c - 1; i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } } cout << "Yes" << endl; }
#include <iostream> #include <string> using namespace std; int main() { int n, a, b, c, d; string s; bool ans_sub = false; cin >> n >> a >> b >> c >> d; cin >> s; if (d < c) { //交差する必要あり //三連'.'検索 for (int i = b - 1; i < d; i++) { if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') { ans_sub = true; } } if (ans_sub == false) { cout << "No" << endl; return 0; } } //二連で岩が置かれていないかチェック for (int i = b - 1; i < d - 1; i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } } for (int i = a - 1; i < c - 1; i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } } cout << "Yes" << endl; }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove" ]
832,922
832,921
u048128931
cpp
p03017
#include <iostream> #include <string> using namespace std; int main() { int n, a, b, c, d; string s; bool ans_sub = false; cin >> n >> a >> b >> c >> d; cin >> s; if (d < c) { //交差する必要あり //三連'.'検索 for (int i = b - 1; i < d - 1; i++) { if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') { ans_sub = true; } } if (ans_sub == false) { cout << "No" << endl; return 0; } } //二連で岩が置かれていないかチェック for (int i = b; i < d - 1; i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } } for (int i = a; i < c - 1; i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } } cout << "Yes" << endl; }
#include <iostream> #include <string> using namespace std; int main() { int n, a, b, c, d; string s; bool ans_sub = false; cin >> n >> a >> b >> c >> d; cin >> s; if (d < c) { //交差する必要あり //三連'.'検索 for (int i = b - 1; i < d; i++) { if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') { ans_sub = true; } } if (ans_sub == false) { cout << "No" << endl; return 0; } } //二連で岩が置かれていないかチェック for (int i = b - 1; i < d - 1; i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } } for (int i = a - 1; i < c - 1; i++) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } } cout << "Yes" << endl; }
[ "control_flow.loop.for.condition.change", "expression.operation.binary.remove", "control_flow.loop.for.initializer.change" ]
832,923
832,921
u048128931
cpp
p03017
#include <algorithm> #include <bits/stdc++.h> using namespace std; template <class T> using V = vector<T>; template <class S, class T> using P = pair<S, T>; template <class... T> using TP = tuple<T...>; using ll = long long; using db = double; using ldb = long db; using str = string; using vll = V<ll>; using vvll = V<V<ll>>; using pll = P<ll, ll>; using tpll = TP<ll, ll, ll>; using vpll = V<pll>; using vst = V<str>; using vch = V<char>; #define FOR(i, a, b) for (ll i = (a); i < (ll)(b); i++) #define rFOR(i, a, b) for (ll i = (b); i > (ll)(a); i--) #define oFOR(i, a, b) for (ll i = (a); i < (ll)(b); i += 2) #define bgn begin() #define en end() #define SORT(a) sort((a).bgn, (a).en) #define REV(a) reverse((a).bgn, (a).en) #define fi first #define se second #define sz size() #define gcd(a, b) __gcd(a, b) #define lcm(a, b) __lcm(a, b) #define co(a) cout << a << endl #define ci(a) cin >> a #define pb(a) push_back(a) #define pob pop_back() #define mp make_pair #define mt make_tuple #define pbmp(a, b) push_back(mp(a, b)) #define subs(a, b) substr(a, b) #define INF 1e16 #define mod 1e9 + 7 int main() { ll n, a, b, c, d; cin >> n >> a >> b >> c >> d; str s; cin >> s; bool D = true; FOR(i, a, c - 1) { if (s[i] == '#') { if (s[i + 1] == '#') { D = false; break; } } } FOR(i, b, d - 1) { if (s[i] == '#') { if (s[i + 1] == '#') { D = false; break; } } } int count = 0, cou = 0; if (c > d) { if (s[b - 2] == '.') { if (s[b - 1] == '.') { if (s[b] == '.') { cou++; } } } if (s[d - 2] == '.') { if (s[d - 1] == '.') { if (s[d] == '.') { cou++; } } } FOR(i, b - 1, d - 1) { if (s[i] == '.') { count++; if (count > 2) { cou++; } } if (s[i] == '#') { count = 0; } // co(count); // co(cou); } } if (c > d) { if (D && cou > 0) { co("Yes"); } else { co("No"); } } else { if (D) { co("Yes"); } else { co("No"); } } }
#include <algorithm> #include <bits/stdc++.h> using namespace std; template <class T> using V = vector<T>; template <class S, class T> using P = pair<S, T>; template <class... T> using TP = tuple<T...>; using ll = long long; using db = double; using ldb = long db; using str = string; using vll = V<ll>; using vvll = V<V<ll>>; using pll = P<ll, ll>; using tpll = TP<ll, ll, ll>; using vpll = V<pll>; using vst = V<str>; using vch = V<char>; #define FOR(i, a, b) for (ll i = (a); i < (ll)(b); i++) #define rFOR(i, a, b) for (ll i = (b); i > (ll)(a); i--) #define oFOR(i, a, b) for (ll i = (a); i < (ll)(b); i += 2) #define bgn begin() #define en end() #define SORT(a) sort((a).bgn, (a).en) #define REV(a) reverse((a).bgn, (a).en) #define fi first #define se second #define sz size() #define gcd(a, b) __gcd(a, b) #define lcm(a, b) __lcm(a, b) #define co(a) cout << a << endl #define ci(a) cin >> a #define pb(a) push_back(a) #define pob pop_back() #define mp make_pair #define mt make_tuple #define pbmp(a, b) push_back(mp(a, b)) #define subs(a, b) substr(a, b) #define INF 1e16 #define mod 1e9 + 7 int main() { ll n, a, b, c, d; cin >> n >> a >> b >> c >> d; str s; cin >> s; bool D = true; FOR(i, a - 1, c - 1) { if (s[i] == '#') { if (s[i + 1] == '#') { D = false; break; } } } FOR(i, b - 1, d - 1) { if (s[i] == '#') { if (s[i + 1] == '#') { D = false; break; } } } int count = 0, cou = 0; if (c > d) { if (s[b - 2] == '.') { if (s[b - 1] == '.') { if (s[b] == '.') { cou++; } } } if (s[d - 2] == '.') { if (s[d - 1] == '.') { if (s[d] == '.') { cou++; } } } FOR(i, b - 1, d) { if (s[i] == '.') { count++; if (count > 2) { cou++; } } if (s[i] == '#') { count = 0; } // co(count); // co(cou); } } if (c > d) { if (D && cou > 0) { co("Yes"); } else { co("No"); } } else { if (D) { co("Yes"); } else { co("No"); } } }
[ "expression.operation.binary.remove" ]
832,954
832,955
u177143886
cpp
p03017
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define repp(i, a, b) for (int i = (int)a; i < (int)b; ++i) #define repm(i, a, b) for (int i = (int)a; i > (int)b; --i) using ll = long long; static const ll mod = 1e9 + 7; static const ll INF = 1LL << 50; using namespace std; int main() { int n, a, b, c, d; cin >> n >> a >> b >> c >> d; string s; cin >> s; a--; b--; c--; d--; bool judge = true; for (int i = b + 1; i < max(c, d); ++i) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } } if (c < d) { cout << "Yes" << endl; return 0; } for (int i = a + 1; i < d; ++i) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { cout << "Yes" << endl; return 0; } } cout << "No" << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define repp(i, a, b) for (int i = (int)a; i < (int)b; ++i) #define repm(i, a, b) for (int i = (int)a; i > (int)b; --i) using ll = long long; static const ll mod = 1e9 + 7; static const ll INF = 1LL << 50; using namespace std; int main() { int n, a, b, c, d; cin >> n >> a >> b >> c >> d; string s; cin >> s; a--; b--; c--; d--; bool judge = true; for (int i = a + 1; i < max(c, d); ++i) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } } if (c < d) { cout << "Yes" << endl; return 0; } for (int i = b - 1; i < d; ++i) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { cout << "Yes" << endl; return 0; } } cout << "No" << endl; return 0; }
[ "identifier.change", "control_flow.loop.for.initializer.change", "expression.operation.binary.change" ]
832,958
832,959
u698883164
cpp
p03017
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define repp(i, a, b) for (int i = (int)a; i < (int)b; ++i) #define repm(i, a, b) for (int i = (int)a; i > (int)b; --i) using ll = long long; static const ll mod = 1e9 + 7; static const ll INF = 1LL << 50; using namespace std; int main() { int n, a, b, c, d; cin >> n >> a >> b >> c >> d; string s; cin >> s; a--; b--; c--; d--; bool judge = true; for (int i = 0; i < max(c, d); ++i) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } } if (c < d) { cout << "Yes" << endl; return 0; } for (int i = b; i < d; ++i) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { cout << "Yes" << endl; return 0; } } cout << "No" << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define repp(i, a, b) for (int i = (int)a; i < (int)b; ++i) #define repm(i, a, b) for (int i = (int)a; i > (int)b; --i) using ll = long long; static const ll mod = 1e9 + 7; static const ll INF = 1LL << 50; using namespace std; int main() { int n, a, b, c, d; cin >> n >> a >> b >> c >> d; string s; cin >> s; a--; b--; c--; d--; bool judge = true; for (int i = a + 1; i < max(c, d); ++i) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } } if (c < d) { cout << "Yes" << endl; return 0; } for (int i = b - 1; i < d; ++i) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { cout << "Yes" << endl; return 0; } } cout << "No" << endl; return 0; }
[ "identifier.replace.add", "literal.replace.remove", "control_flow.loop.for.initializer.change" ]
832,962
832,959
u698883164
cpp
p03017
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define repp(i, a, b) for (int i = (int)a; i < (int)b; ++i) #define repm(i, a, b) for (int i = (int)a; i > (int)b; --i) using ll = long long; static const ll mod = 1e9 + 7; static const ll INF = 1LL << 50; using namespace std; int main() { int n, a, b, c, d; cin >> n >> a >> b >> c >> d; string s; cin >> s; a--; b--; c--; d--; bool judge = true; for (int i = 0; i < max(c, d); ++i) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } } if (c < d) { cout << "Yes" << endl; return 0; } for (int i = 0; i < d; ++i) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { cout << "Yes" << endl; return 0; } } cout << "No" << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define repp(i, a, b) for (int i = (int)a; i < (int)b; ++i) #define repm(i, a, b) for (int i = (int)a; i > (int)b; --i) using ll = long long; static const ll mod = 1e9 + 7; static const ll INF = 1LL << 50; using namespace std; int main() { int n, a, b, c, d; cin >> n >> a >> b >> c >> d; string s; cin >> s; a--; b--; c--; d--; bool judge = true; for (int i = a + 1; i < max(c, d); ++i) { if (s[i] == '#' && s[i + 1] == '#') { cout << "No" << endl; return 0; } } if (c < d) { cout << "Yes" << endl; return 0; } for (int i = b - 1; i < d; ++i) { if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') { cout << "Yes" << endl; return 0; } } cout << "No" << endl; return 0; }
[ "identifier.replace.add", "literal.replace.remove", "control_flow.loop.for.initializer.change" ]
832,963
832,959
u698883164
cpp
p03003
#include "bits/stdc++.h" #define REP(i, n) for (ll i = 0; i < ll(n); ++i) #define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i) #define FOR(i, m, n) for (ll i = m; i < ll(n); ++i) #define RFOR(i, m, n) for (ll i = ll(n) - 1; i >= ll(m); --i) #define ALL(v) (v).begin(), (v).end() #define UNIQUE(v) v.erase(unique(ALL(v)), v.end()); #define INF 1000000001ll #define MOD 1000000007ll #define EPS 1e-9 constexpr int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1}; constexpr int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1}; using namespace std; using ll = long long; using vi = vector<int>; using vl = vector<ll>; using vvi = vector<vi>; using vvl = vector<vl>; using pii = pair<int, int>; using pll = pair<ll, ll>; template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; } template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } int main() { cin.tie(0); ios::sync_with_stdio(false); int n, m; cin >> n >> m; vl a(n), b(m); REP(i, n) cin >> a[i]; REP(i, m) cin >> b[i]; vvi dp(n + 1, vi(m + 1, 0)); REP(i, n) REP(j, m) { dp[i + 1][j + 1] = ((dp[i][j + 1] + dp[i + 1][j] - dp[i][j]) % MOD + MOD) % MOD; dp[i + 1][j + 1] %= MOD; if (a[i] == b[j]) { dp[i + 1][j + 1] += 1 + dp[i][j]; dp[i + 1][j + 1] %= MOD; } } cout << dp[n][m] << endl; }
#include "bits/stdc++.h" #define REP(i, n) for (ll i = 0; i < ll(n); ++i) #define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i) #define FOR(i, m, n) for (ll i = m; i < ll(n); ++i) #define RFOR(i, m, n) for (ll i = ll(n) - 1; i >= ll(m); --i) #define ALL(v) (v).begin(), (v).end() #define UNIQUE(v) v.erase(unique(ALL(v)), v.end()); #define INF 1000000001ll #define MOD 1000000007ll #define EPS 1e-9 constexpr int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1}; constexpr int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1}; using namespace std; using ll = long long; using vi = vector<int>; using vl = vector<ll>; using vvi = vector<vi>; using vvl = vector<vl>; using pii = pair<int, int>; using pll = pair<ll, ll>; template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; } template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } int main() { cin.tie(0); ios::sync_with_stdio(false); int n, m; cin >> n >> m; vl a(n), b(m); REP(i, n) cin >> a[i]; REP(i, m) cin >> b[i]; vvi dp(n + 1, vi(m + 1, 0)); REP(i, n) REP(j, m) { dp[i + 1][j + 1] = ((dp[i][j + 1] + dp[i + 1][j] - dp[i][j]) % MOD + MOD) % MOD; dp[i + 1][j + 1] %= MOD; if (a[i] == b[j]) { dp[i + 1][j + 1] += 1 + dp[i][j]; dp[i + 1][j + 1] %= MOD; } } cout << (dp[n][m] + 1) % MOD << endl; }
[ "expression.operation.binary.add" ]
832,970
832,971
u918357423
cpp
p03004
#include <algorithm> #include <array> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctype.h> #include <deque> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string.h> #include <unordered_map> #include <utility> #include <vector> #define _USE_MATH_DEFINES #include <iostream> #include <math.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<ll, double> pld; typedef pair<double, double> pdd; typedef pair<double, ll> pdl; typedef pair<int, char> pic; typedef vector<ll> vl; typedef vector<int> vi; typedef priority_queue<ll, vector<ll>, greater<ll>> llgreaterq; typedef priority_queue<pll, vector<pll>, greater<pll>> pllgreaterq; typedef priority_queue<pair<ll, pll>, vector<pair<ll, pll>>, greater<pair<ll, pll>>> plpllgreaterq; typedef priority_queue<vi, vector<vi>, greater<vi>> vigreaterq; typedef priority_queue<vl, vector<vl>, greater<vl>> vlgreaterq; template <class o, class p, class q> using tuple3q = priority_queue<tuple<o, p, q>, vector<tuple<o, p, q>>, greater<tuple<o, p, q>>>; template <class o, class p, class q, class r> using tuple4q = priority_queue<tuple<o, p, q, r>, vector<tuple<o, p, q, r>>, greater<tuple<o, p, q, r>>>; template <class o, class p, class q, class r, class s> using tuple5q = priority_queue<tuple<o, p, q, r, s>, vector<tuple<o, p, q, r, s>>, greater<tuple<o, p, q, r, s>>>; int dx[] = {-1, 0, 1, 0}; int dy[] = {0, -1, 0, 1}; #define bit(x, v) ((ll)x << v) #define rep(x, n) for (ll x = 0; x < n; x++) #define rep2(x, f, v) for (ll x = f; x < v; x++) #define repe(v, x) for (auto v : x) // 許容する誤差ε #define EPS (1e-10) // 2つのスカラーが等しいかどうか #define EQ(a, b) (std::abs(a - b) < EPS) // 2つのベクトルが等しいかどうか #define EQV(a, b) (EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag())) #define all(a) a.begin(), a.end() #define all0(a) memset(a, 0, sizeof(a)) #define allm1(a) memset(a, -1, sizeof(a)) #define put_float(v) \ cout << fixed << setprecision(10); \ cout << v << endl #define put(v) cout << v << endl #define vinsert(v, p, x) v.insert(v.begin() + p, x) #define vsort(v) sort(all(v)); #define dup(v) v.erase(unique(all(v)), v.end()) #define ion(i, j) ((i & (1LL << j)) > 0) #define next(i) \ i++; \ i %= 2 #define Len size() #define ull unsignd long long #define psp(a, b) push_back(make_pair(a, b)) #define psp2(a, b) push(make_pair(a, b)) #define cini(a) \ a; \ cin >> a #define infa(a, b) (a + b) % INF #define infm(a, b) (a * b) % INF #define infd(a, b) (a * modinv(b)) % INF #define infs(a, b) (a + INF - b) % INF #define inf(a) (a) %= INF #define inff(a) ((a) % INF) #define No cout << "No" << endl #define Yes cout << "Yes" << endl #define NO cout << "NO" << endl #define YES cout << "YES" << endl #define smal -INF *INF #define big INF *INF const ll INF = 1000000007; const int MAX = 2000010; const int MOD = 1000000007; long long fac[MAX], finv[MAX], inv[MAX]; void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 long long COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } ll getpow(ll b, ll x, ll md) { ll t = b; ll res = 1; while (x > 0) { if (x & 1) { res *= t; res %= md; } x >>= 1; t *= t; t %= md; } return res; } ll getpow(ll b, ll x) { return getpow(b, x, INF); } ll modinv(ll x) { return getpow(x, INF - 2); } ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } class mint { int md = 1000000007; public: long long x; mint(ll x, ll md) { this->md = md; this->x = (x % md + md) % md; } mint(long long x = 0) : x((x % md + md) % md) {} mint operator-() const { return mint(-x); } mint &operator+=(const mint &a) { if ((x += a.x) >= md) x -= md; return *this; } mint &operator-=(const mint &a) { if ((x += md - a.x) >= md) x -= md; return *this; } mint &operator*=(const mint &a) { (x *= a.x) %= md; return *this; } mint operator+(const mint &a) const { mint res(*this); return res += a; } mint operator-(const mint &a) const { mint res(*this); return res -= a; } mint operator*(const mint &a) const { mint res(*this); return res *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(md - 2); } mint &operator/=(const mint &a) { return (*this) *= a.inv(); } mint operator/(const mint &a) const { mint res(*this); return res /= a; } friend ostream &operator<<(ostream &os, const mint &m) { os << m.x; return os; } }; int pr[100010]; int lank[100010]; void uini(int n) { for (size_t i = 0; i <= n; i++) { pr[i] = i; lank[i] = 1; } } int parent(int x) { if (x == pr[x]) return x; return pr[x] = parent(pr[x]); } int same(int x, int y) { return parent(x) == parent(y); } bool unit(int x, int y) { int px = parent(x); int py = parent(y); if (px == py) return false; if (lank[py] < lank[px]) { pr[py] = px; lank[px] += lank[py]; } else { pr[px] = py; lank[py] += lank[px]; } return true; } ll n; int ci = 0; struct Node { int key; int priority; Node *parent, *left, *right; Node(int key, int priority); Node() {} }; Node NIL; Node::Node(int key, int priority) : key(key), priority(priority) { left = &NIL; right = &NIL; } Node *root = new Node(); void cenrec(Node *k) { if (k->key == NIL.key) return; cenrec(k->left); cout << " " << k->key; cenrec(k->right); } void fastrec(Node *k) { if (k->key == NIL.key) return; cout << " " << k->key; fastrec(k->left); fastrec(k->right); } void insert(Node *v) { Node *y = &NIL; Node *x = root; while (x->key != NIL.key) { y = x; if (v->key < x->key) { x = x->left; } else { x = x->right; } } v->parent = y; if (y->key == NIL.key) { root = v; } else if (v->key < y->key) { y->left = v; } else { y->right = v; } } Node *find(Node *k, ll v) { if (k->key == NIL.key) return &NIL; if (k->key == v) return k; if (v < k->key) return find(k->left, v); return find(k->right, v); } void delp12(Node *x) { if (x->key == NIL.key) return; Node *l = x->left; Node *r = x->right; Node *pr = x->parent; if (l->key == NIL.key && r->key == NIL.key) { if (pr->left == x) { pr->left = &NIL; } else pr->right = &NIL; } else if (l->key != NIL.key) { if (pr->left == x) { pr->left = l; } else pr->right = l; l->parent = pr; } else if (r->key != NIL.key) { if (pr->left == x) { pr->left = r; } else pr->right = r; r->parent = pr; } } Node *get_next(Node *k) { if (k->key == NIL.key) return &NIL; Node *res = get_next(k->left); if (res->key != NIL.key) return res; return k; } void del(Node *x) { if (x->key == NIL.key) return; Node *l = x->left; Node *r = x->right; Node *pr = x->parent; if (l->key != NIL.key && r->key != NIL.key) { Node *nex = get_next(r); x->key = nex->key; delp12(nex); } else { delp12(x); } } Node *rightRotate(Node *t) { Node *s = t->left; t->left = s->right; s->right = t; return s; } Node *leftRotate(Node *t) { Node *s = t->right; t->right = s->left; s->left = t; return s; } Node *_insert(Node *t, int key, int priority) { if (t->key == NIL.key) { return new Node(key, priority); } if (key == t->key) { return t; } if (key < t->key) { t->left = _insert(t->left, key, priority); if (t->priority < t->left->priority) { t = rightRotate(t); } } else { t->right = _insert(t->right, key, priority); if (t->priority < t->right->priority) { t = leftRotate(t); } } return t; } Node *delete1(Node *t, int key); Node *_delete(Node *t, int key) { if (t->left->key == NIL.key && t->right->key == NIL.key) { return &NIL; } else if (t->left->key == NIL.key) { t = leftRotate(t); } else if (t->right->key == NIL.key) { t = rightRotate(t); } else { if (t->left->priority > t->right->priority) { t = rightRotate(t); } else t = leftRotate(t); } return delete1(t, key); } Node *delete1(Node *t, int key) { if (t->key == NIL.key) { return &NIL; } if (key < t->key) { t->left = delete1(t->left, key); } else if (key > t->key) { t->right = delete1(t->right, key); } else return _delete(t, key); return t; } int H; int left(int i) { return i * 2 + 1; } int right(int i) { return i * 2 + 2; } class edge { public: int from, to, i; ll val; edge() {} edge(ll to) : to(to) {} edge(ll to, ll i) : to(to), i(i) {} edge(ll from, ll to, ll val) : from(from), to(to), val(val) {} }; class LCA { private: vector<vector<edge>> v; vector<vector<int>> parent; vector<int> depth; void dfs(int n, int m, int d) { parent[0][n] = m; depth[n] = d; for (auto x : v[n]) { if (x.to != m) dfs(x.to, n, d + 1); } } public: LCA(ll N, ll root, vector<vector<edge>> &tree) { v = tree; parent = vector<vector<int>>(21, vector<int>(N + 1, 0)); depth = vector<int>(N + 1, 0); dfs(root, -1, 0); for (int j = 0; j + 1 < 20; j++) { for (int i = 1; i <= N; i++) { if (parent[j][i] < 0) parent[j + 1][i] = -1; else parent[j + 1][i] = parent[j][parent[j][i]]; } } } int lca(int n, int m) { if (depth[n] > depth[m]) swap(n, m); for (int j = 0; j < 20; j++) { if ((depth[m] - depth[n]) >> j & 1) m = parent[j][m]; } if (n == m) return n; for (int j = 19; j >= 0; j--) { if (parent[j][n] != parent[j][m]) { n = parent[j][n]; m = parent[j][m]; } } return parent[0][n]; } int dep(int n) { return depth[n]; } }; ll k; int _rank[1010]; int temp[1010]; bool compare_sa(int i, int j) { if (_rank[i] != _rank[j]) return _rank[i] < _rank[j]; else { int ri = i + k <= n ? _rank[i + k] : -1; int rj = j + k <= n ? _rank[j + k] : -1; return ri < rj; } } void construct_sa(string S, int *sa) { n = S.length(); for (size_t i = 0; i <= n; i++) { sa[i] = i; _rank[i] = i < n ? S[i] : -1; } for (k = 1; k <= n; k *= 2) { sort(sa, sa + n + 1, compare_sa); // saはソート後の接尾辞の並びになっている、rankは元の位置のindexを保持したまま、更新されている。 // ピンとこなかった部分 temp[sa[0]] = 0; for (size_t i = 1; i <= n; i++) { temp[sa[i]] = temp[sa[i - 1]] + (compare_sa(sa[i - 1], sa[i]) ? 1 : 0); } for (size_t i = 0; i <= n; i++) { _rank[i] = temp[i]; } } } bool contain(string S, int *sa, string T) { int a = 0, b = S.length(); // sa は 接尾辞が辞書順に並んでいる、入っているのはその位置のインデックス while (b - a > 1) { int c = (a + b) / 2; if (S.compare(sa[c], T.length(), T) < 0) a = c; else b = c; } return S.compare(sa[b], T.length(), T) == 0; } #define bit(x, v) ((ll)x << v) class BIT { static const int MAX_N = 500010; public: BIT() { memset(bit, 0, sizeof(bit)); } ll bit[MAX_N + 1], n; ll sum(int i) { ll s = 0; while (i > 0) { s += bit[i]; i -= i & -i; } return s; } void add(int i, int x) { while (i <= n) { bit[i] += x; i += i & -i; } } }; struct UnionFind { vector<int> A; UnionFind(int n) : A(n, -1) {} int find(int x) { if (A[x] < 0) return x; return A[x] = find(A[x]); } void unite(int x, int y) { x = find(x), y = find(y); if (x == y) return; if (A[x] > A[y]) swap(x, y); A[x] += A[y]; A[y] = x; } int ngroups() { int ans = 0; for (auto a : A) if (a < 0) ans++; return ans; } }; vector<ll> getp(ll n) { vector<ll> res; ll a = 2; if (n % 2 == 0) { res.push_back(2); while (n % 2 == 0) n /= 2; } for (ll i = 3; i * i <= n; i += 2) { if (n % i == 0) { res.push_back(i); while (n % i == 0) n /= i; } } if (n != 1) res.push_back(n); return res; } vector<ll> getp2(ll n) { vector<ll> res; ll a = 2; if (n % 2 == 0) { while (n % 2 == 0) { n /= 2; res.push_back(2); } } for (ll i = 3; i * i <= n; i += 2) { if (n % i == 0) { while (n % i == 0) { n /= i; res.push_back(i); } } } if (n != 1) res.push_back(n); return res; } vector<pll> getp3(ll n) { vector<pll> res; ll a = 2; int si = 0; if (n % 2 == 0) { res.push_back(make_pair(2, 0)); while (n % 2 == 0) { n /= 2; res[si].second++; } si++; } for (ll i = 3; i * i <= n; i += 2) { if (n % i == 0) { res.push_back(make_pair(i, 0)); while (n % i == 0) { n /= i; res[si].second++; } si++; } } if (n != 1) { res.push_back(make_pair(n, 1)); } return res; } vector<ll> getDivisors(ll n) { vector<ll> res; ll a = 2; res.push_back(1); for (ll i = 2; i * i <= n; i++) { if (n % i == 0) { res.push_back(i); if (n / i != i) res.push_back(n / i); } } return res; } struct ve { public: vector<ve> child; int _t = INF; ve(int t) : _t(t) {} ve(ve _left, ve _right) { _t = _left._t + _right._t; child.push_back(_left); child.push_back(_right); } bool operator<(const ve &t) const { return _t > t._t; } }; vector<bool> elas(ll n) { vector<bool> r(n); fill(r.begin(), r.end(), 1); r[0] = 0; r[1] = 0; for (ll i = 2; i * i < n; i++) { if (!r[i]) continue; ll ti = i * 2; while (ti < n) { r[ti] = false; ti += i; } } return r; } bool isPrime(ll v) { for (ll i = 2; i * i <= v; i++) { if (v % i == 0) return false; } return true; } class SegTree { public: const static int MAX_N = 100010; const static int DAT_SIZE = (1 << 18) - 1; int N, Q; int A[MAX_N]; ll data[DAT_SIZE], datb[DAT_SIZE]; void init(int _n) { N = 1; while (N < _n) N <<= 1; memset(data, 0, sizeof(data)); memset(datb, 0, sizeof(datb)); } void init(int _n, ll iv) { N = 1; while (N < _n) N <<= 1; rep(i, DAT_SIZE) { data[i] = iv; datb[i] = iv; } } void add(int a, int b, int x) { add(a, b + 1, x, 0, 0, N); } void add(int a, int b, int x, int k, int l, int r) { if (a <= l && r <= b) { data[k] += x; } else if (l < b && a < r) { datb[k] += (min(b, r) - max(a, l)) * x; add(a, b, x, k * 2 + 1, l, (l + r) / 2); add(a, b, x, k * 2 + 2, (l + r) / 2, r); } } void change(int a, int b, int x) { change(a, b + 1, x, 0, 0, N); } void change(int a, int b, int x, int k, int l, int r) { if (a <= l && r <= b) { data[k] = x; } else if (l < b && a < r) { datb[k] = x; change(a, b, x, k * 2 + 1, l, (l + r) / 2); change(a, b, x, k * 2 + 2, (l + r) / 2, r); } } ll sum(int a, int b) { return sum(a, b + 1, 0, 0, N); } ll sum(int a, int b, int k, int l, int r) { if (b <= l || r <= a) { return 0; } if (a <= l && r <= b) { return data[k] * (r - l) + datb[k]; } ll res = (min(b, r) - max(a, l)) * data[k]; res += sum(a, b, k * 2 + 1, l, (l + r) / 2); res += sum(a, b, k * 2 + 2, (l + r) / 2, r); return res; } }; class Segment; class Circle; class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x, y - p.y); } Point operator*(double a) { return Point(a * x, a * y); } Point operator/(double a) { return Point(x / a, y / a); } double abs() { return sqrt(norm()); } double norm() { return x * x + y * y; } bool operator<(const Point &p) const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const Point &p) const { return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS; } static double dot(Point a, Point b) { return a.x * b.x + a.y * b.y; } static double cross(Point a, Point b) { return a.x * b.y - a.y * b.x; } static bool isOrthogonal(Point a, Point b) { return EQ(dot(a, b), 0.0); } static bool isOrthogonal(Point a1, Point a2, Point b1, Point b2) { return isOrthogonal(a1 - a2, b1 - b2); } static bool isOrthogonal(Segment s1, Segment s2); static bool isPalallel(Point a, Point b) { return EQ(cross(a, b), 0.0); } static bool isPalallel(Point a1, Point a2, Point b1, Point b2) { return isPalallel(a1 - a2, b1 - b2); } static bool isPalallel(Segment s1, Segment s2); static const int COUNTER_CLOCKWISE = 1; static const int CLOCKWISE = -1; static const int ONLINE_BACK = 2; static const int ONLINE_FRONT = -2; static const int ON_SEGMENT = 0; static int ccw(Point p0, Point p1, Point p2) { // 線分はp0とp1でp2がどこにあるかを探る Point a = p1 - p0; Point b = p2 - p0; if (cross(a, b) > EPS) return COUNTER_CLOCKWISE; if (cross(a, b) < -EPS) return CLOCKWISE; if (dot(a, b) < -EPS) return ONLINE_BACK; if (a.norm() < b.norm()) return ONLINE_FRONT; return ON_SEGMENT; } static bool intersect(Point p1, Point p2, Point p3, Point p4) { return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 && ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0); } static bool intersect(Segment s1, Segment s2); static Point project(Segment s, Point p); static Point reflect(Segment s, Point p); static Point getDistance(Point a, Point b) { return (a - b).abs(); } static double getDistanceLP(Segment s, Point p); static double getDistanceSP(Segment s, Point p); static double getDistance(Segment s1, Segment s2); static Point getIntersection(Segment s1, Segment s2); static pair<Point, Point> crossPoints(Circle c, Segment s); static int contains(vector<Point> g, Point p) { int n = g.size(); bool x = false; rep(i, n) { Point a = g[i] - p, b = g[(i + 1) % n] - p; // 線の上に載っているか if (std::abs(cross(a, b)) < EPS && dot(a, b) < EPS) return 1; // pを基準として上下にあるか // または外積が正か?(→にあるか) if (a.y > b.y) swap(a, b); if (a.y < EPS && EPS < b.y && cross(a, b) > EPS) x = !x; } return x ? 2 : 0; } static vector<Point> andrewScan(vector<Point> s) { vector<Point> u, l; if (s.size() < 3) return s; sort(all(s)); u.push_back(s[0]); u.push_back(s[1]); l.push_back(s[s.size() - 1]); l.push_back(s[s.size() - 2]); for (int i = 2; i < s.size(); i++) { for (int _n = u.size(); _n >= 2 && ccw(u[_n - 2], u[_n - 1], s[i]) > CLOCKWISE; _n--) { u.pop_back(); } u.push_back(s[i]); } for (int i = s.size() - 3; i >= 0; i--) { for (int _n = l.size(); _n >= 2 && ccw(l[_n - 2], l[_n - 1], s[i]) > CLOCKWISE; _n--) { l.pop_back(); } l.push_back(s[i]); } reverse(all(l)); for (int i = u.size() - 2; i >= 1; i--) { l.push_back(u[i]); } return l; } void get_cin() { cin >> x >> y; } }; class Segment { public: Point p1, p2; Segment() {} Segment(Point p1, Point p2) : p1(p1), p2(p2) {} void get_cin() { cin >> p1.x >> p1.y >> p2.x >> p2.y; } Point p1tp2() { return p2 - p1; } Point p2tp1() { return p1 - p2; } double abs() { return std::abs(norm()); } double norm() { return (p2 - p1).norm(); } }; bool Point::isOrthogonal(Segment s1, Segment s2) { return EQ(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0); } bool Point::isPalallel(Segment s1, Segment s2) { return EQ(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0); } bool Point::intersect(Segment s1, Segment s2) { return intersect(s1.p1, s1.p2, s2.p1, s2.p2); } Point Point::project(Segment s, Point p) { Point base = s.p2 - s.p1; double r = Point::dot(p - s.p1, base) / base.norm(); return s.p1 + base * r; } Point Point::reflect(Segment s, Point p) { return (project(s, p) * 2) - p; } double Point::getDistanceLP(Segment s, Point p) { return std::abs(cross(s.p2 - s.p1, p - s.p1) / (s.p2 - s.p1).abs()); } double Point::getDistanceSP(Segment s, Point p) { if (dot(s.p2 - s.p1, p - s.p1) < 0.0) return (p - s.p1).abs(); if (dot(s.p1 - s.p2, p - s.p2) < 0.0) return (p - s.p2).abs(); return getDistanceLP(s, p); } double Point::getDistance(Segment s1, Segment s2) { if (intersect(s1, s2)) return 0.0; return min({getDistanceSP(s1, s2.p1), getDistanceSP(s1, s2.p2), getDistanceSP(s2, s1.p1), getDistanceSP(s2, s1.p2)}); } Point Point::getIntersection(Segment s1, Segment s2) { // (s1.p1 - s2.p1).norm() auto bs = s1.p2 - s1.p1; auto n1 = s2.p1 - s1.p1; auto n2 = s2.p2 - s1.p1; auto c1 = std::abs(cross(n1, bs)) / bs.norm(); auto c2 = std::abs(cross(n2, bs)) / bs.norm(); return s2.p1 + (s2.p2 - s2.p1) * (c1 / (c1 + c2)); // c1:c2=t:1-t // c2t=(1-t)c1 // t/(1-t)=c1/(c1+c2) // } double arg(Point p) { return atan2(p.y, p.x); } Point polar(double a, double r) { return Point(cos(r) * a, sin(r) * a); } class Circle { public: Point c; double r; Circle(Point c = Point(), double r = 0.0) : c(c), r(r) {} void get_cin() { cin >> c.x >> c.y >> r; } static pair<Point, Point> getCrossPoints(Circle c1, Circle c2) { double d = (c1.c - c2.c).abs(); // 中心点どうしの距離 double a = acos((c1.r * c1.r + d * d - c2.r * c2.r) / (2 * c1.r * d)); double t = arg(c2.c - c1.c); return make_pair(c1.c + polar(c1.r, t + a), c1.c + polar(c1.r, t - a)); } }; pair<Point, Point> Point::crossPoints(Circle c, Segment s) { auto pp = project(s, c.c); auto f = (pp - c.c).norm(); auto mu = sqrt(c.r * c.r - f); auto e = s.p1tp2() / s.p1tp2().abs(); return make_pair(pp + e * mu, pp - e * mu); } ll divRm(string s, ll x) { ll r = 0; for (ll i = 0; i < s.size(); i++) { r *= 10; r += s[i] - '0'; r %= x; } return r; } ll cmbi(ll x, ll b) { ll res = 1; for (size_t i = 0; i < b; i++) { res *= x - i; res %= INF; res *= inv[b - i]; res %= INF; } return res; } double digsum(ll x) { ll res = 0; while (x > 0) { res += x % 10; x /= 10; } return res; } bool check_parindrome(string s) { int n = s.size(); rep(i, n / 2) { if (s[i] != s[n - i - 1]) { return false; } } return true; } // ここまでライブラリ // ここからコード struct mm { double h = -big, l = big; }; double x[100010], y[100010]; char d[100010]; mm m[4]; mm fm[2]; void sech(mm &v, double a) { v.h = max(v.h, a); v.l = min(v.l, a); } void setu(vector<double> &v, int p, char c) { ll f = p / 2; if (f == 1) { swap(x, y); } rep(i, n) { if (d[i] != c) continue; if (m[p].l < big) { v.push_back(abs(x[i] - m[p].l)); v.push_back(abs(x[i] - m[p].l) / 2); v.push_back(abs(x[i] - m[p].h)); v.push_back(abs(x[i] - m[p].h) / 2); } if (fm[f].l < big) { v.push_back(abs(x[i] - fm[f].l)); v.push_back(abs(x[i] - fm[f].l) / 2); v.push_back(abs(x[i] - fm[f].h)); v.push_back(abs(x[i] - fm[f].h) / 2); } } if (f == 1) { swap(x, y); } } double clx(double x) { return max({m[0].h + x, m[1].h - x, fm[0].h}) - min({m[0].l + x, m[1].l - x, fm[0].l}); } double cly(double x) { return max({m[2].h + x, m[3].h - x, fm[1].h}) - min({m[2].l + x, m[3].l - x, fm[1].l}); } double clc(double x) { return clx(x) * cly(x); } void solv() { cin >> n; rep(i, n) { cin >> x[i] >> y[i] >> d[i]; switch (d[i]) { case 'R': sech(m[0], x[i]); sech(fm[1], y[i]); break; case 'L': sech(m[1], x[i]); sech(fm[1], y[i]); break; case 'U': sech(m[2], y[i]); sech(fm[0], x[i]); break; case 'D': sech(m[3], y[i]); sech(fm[0], x[i]); break; } } vector<double> v; setu(v, 0, 'L'); setu(v, 1, 'R'); setu(v, 2, 'U'); setu(v, 3, 'D'); double res = clc(0); rep(i, v.size()) { res = min(res, clc(v[i])); } put_float(res); } int main() { COMinit(); solv(); return 0; }
#include <algorithm> #include <array> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctype.h> #include <deque> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string.h> #include <unordered_map> #include <utility> #include <vector> #define _USE_MATH_DEFINES #include <iostream> #include <math.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<ll, double> pld; typedef pair<double, double> pdd; typedef pair<double, ll> pdl; typedef pair<int, char> pic; typedef vector<ll> vl; typedef vector<int> vi; typedef priority_queue<ll, vector<ll>, greater<ll>> llgreaterq; typedef priority_queue<pll, vector<pll>, greater<pll>> pllgreaterq; typedef priority_queue<pair<ll, pll>, vector<pair<ll, pll>>, greater<pair<ll, pll>>> plpllgreaterq; typedef priority_queue<vi, vector<vi>, greater<vi>> vigreaterq; typedef priority_queue<vl, vector<vl>, greater<vl>> vlgreaterq; template <class o, class p, class q> using tuple3q = priority_queue<tuple<o, p, q>, vector<tuple<o, p, q>>, greater<tuple<o, p, q>>>; template <class o, class p, class q, class r> using tuple4q = priority_queue<tuple<o, p, q, r>, vector<tuple<o, p, q, r>>, greater<tuple<o, p, q, r>>>; template <class o, class p, class q, class r, class s> using tuple5q = priority_queue<tuple<o, p, q, r, s>, vector<tuple<o, p, q, r, s>>, greater<tuple<o, p, q, r, s>>>; int dx[] = {-1, 0, 1, 0}; int dy[] = {0, -1, 0, 1}; #define bit(x, v) ((ll)x << v) #define rep(x, n) for (ll x = 0; x < n; x++) #define rep2(x, f, v) for (ll x = f; x < v; x++) #define repe(v, x) for (auto v : x) // 許容する誤差ε #define EPS (1e-10) // 2つのスカラーが等しいかどうか #define EQ(a, b) (std::abs(a - b) < EPS) // 2つのベクトルが等しいかどうか #define EQV(a, b) (EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag())) #define all(a) a.begin(), a.end() #define all0(a) memset(a, 0, sizeof(a)) #define allm1(a) memset(a, -1, sizeof(a)) #define put_float(v) \ cout << fixed << setprecision(10); \ cout << v << endl #define put(v) cout << v << endl #define vinsert(v, p, x) v.insert(v.begin() + p, x) #define vsort(v) sort(all(v)); #define dup(v) v.erase(unique(all(v)), v.end()) #define ion(i, j) ((i & (1LL << j)) > 0) #define next(i) \ i++; \ i %= 2 #define Len size() #define ull unsignd long long #define psp(a, b) push_back(make_pair(a, b)) #define psp2(a, b) push(make_pair(a, b)) #define cini(a) \ a; \ cin >> a #define infa(a, b) (a + b) % INF #define infm(a, b) (a * b) % INF #define infd(a, b) (a * modinv(b)) % INF #define infs(a, b) (a + INF - b) % INF #define inf(a) (a) %= INF #define inff(a) ((a) % INF) #define No cout << "No" << endl #define Yes cout << "Yes" << endl #define NO cout << "NO" << endl #define YES cout << "YES" << endl #define smal -INF *INF #define big INF *INF const ll INF = 1000000007; const int MAX = 2000010; const int MOD = 1000000007; long long fac[MAX], finv[MAX], inv[MAX]; void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 long long COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } ll getpow(ll b, ll x, ll md) { ll t = b; ll res = 1; while (x > 0) { if (x & 1) { res *= t; res %= md; } x >>= 1; t *= t; t %= md; } return res; } ll getpow(ll b, ll x) { return getpow(b, x, INF); } ll modinv(ll x) { return getpow(x, INF - 2); } ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } class mint { int md = 1000000007; public: long long x; mint(ll x, ll md) { this->md = md; this->x = (x % md + md) % md; } mint(long long x = 0) : x((x % md + md) % md) {} mint operator-() const { return mint(-x); } mint &operator+=(const mint &a) { if ((x += a.x) >= md) x -= md; return *this; } mint &operator-=(const mint &a) { if ((x += md - a.x) >= md) x -= md; return *this; } mint &operator*=(const mint &a) { (x *= a.x) %= md; return *this; } mint operator+(const mint &a) const { mint res(*this); return res += a; } mint operator-(const mint &a) const { mint res(*this); return res -= a; } mint operator*(const mint &a) const { mint res(*this); return res *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(md - 2); } mint &operator/=(const mint &a) { return (*this) *= a.inv(); } mint operator/(const mint &a) const { mint res(*this); return res /= a; } friend ostream &operator<<(ostream &os, const mint &m) { os << m.x; return os; } }; int pr[100010]; int lank[100010]; void uini(int n) { for (size_t i = 0; i <= n; i++) { pr[i] = i; lank[i] = 1; } } int parent(int x) { if (x == pr[x]) return x; return pr[x] = parent(pr[x]); } int same(int x, int y) { return parent(x) == parent(y); } bool unit(int x, int y) { int px = parent(x); int py = parent(y); if (px == py) return false; if (lank[py] < lank[px]) { pr[py] = px; lank[px] += lank[py]; } else { pr[px] = py; lank[py] += lank[px]; } return true; } ll n; int ci = 0; struct Node { int key; int priority; Node *parent, *left, *right; Node(int key, int priority); Node() {} }; Node NIL; Node::Node(int key, int priority) : key(key), priority(priority) { left = &NIL; right = &NIL; } Node *root = new Node(); void cenrec(Node *k) { if (k->key == NIL.key) return; cenrec(k->left); cout << " " << k->key; cenrec(k->right); } void fastrec(Node *k) { if (k->key == NIL.key) return; cout << " " << k->key; fastrec(k->left); fastrec(k->right); } void insert(Node *v) { Node *y = &NIL; Node *x = root; while (x->key != NIL.key) { y = x; if (v->key < x->key) { x = x->left; } else { x = x->right; } } v->parent = y; if (y->key == NIL.key) { root = v; } else if (v->key < y->key) { y->left = v; } else { y->right = v; } } Node *find(Node *k, ll v) { if (k->key == NIL.key) return &NIL; if (k->key == v) return k; if (v < k->key) return find(k->left, v); return find(k->right, v); } void delp12(Node *x) { if (x->key == NIL.key) return; Node *l = x->left; Node *r = x->right; Node *pr = x->parent; if (l->key == NIL.key && r->key == NIL.key) { if (pr->left == x) { pr->left = &NIL; } else pr->right = &NIL; } else if (l->key != NIL.key) { if (pr->left == x) { pr->left = l; } else pr->right = l; l->parent = pr; } else if (r->key != NIL.key) { if (pr->left == x) { pr->left = r; } else pr->right = r; r->parent = pr; } } Node *get_next(Node *k) { if (k->key == NIL.key) return &NIL; Node *res = get_next(k->left); if (res->key != NIL.key) return res; return k; } void del(Node *x) { if (x->key == NIL.key) return; Node *l = x->left; Node *r = x->right; Node *pr = x->parent; if (l->key != NIL.key && r->key != NIL.key) { Node *nex = get_next(r); x->key = nex->key; delp12(nex); } else { delp12(x); } } Node *rightRotate(Node *t) { Node *s = t->left; t->left = s->right; s->right = t; return s; } Node *leftRotate(Node *t) { Node *s = t->right; t->right = s->left; s->left = t; return s; } Node *_insert(Node *t, int key, int priority) { if (t->key == NIL.key) { return new Node(key, priority); } if (key == t->key) { return t; } if (key < t->key) { t->left = _insert(t->left, key, priority); if (t->priority < t->left->priority) { t = rightRotate(t); } } else { t->right = _insert(t->right, key, priority); if (t->priority < t->right->priority) { t = leftRotate(t); } } return t; } Node *delete1(Node *t, int key); Node *_delete(Node *t, int key) { if (t->left->key == NIL.key && t->right->key == NIL.key) { return &NIL; } else if (t->left->key == NIL.key) { t = leftRotate(t); } else if (t->right->key == NIL.key) { t = rightRotate(t); } else { if (t->left->priority > t->right->priority) { t = rightRotate(t); } else t = leftRotate(t); } return delete1(t, key); } Node *delete1(Node *t, int key) { if (t->key == NIL.key) { return &NIL; } if (key < t->key) { t->left = delete1(t->left, key); } else if (key > t->key) { t->right = delete1(t->right, key); } else return _delete(t, key); return t; } int H; int left(int i) { return i * 2 + 1; } int right(int i) { return i * 2 + 2; } class edge { public: int from, to, i; ll val; edge() {} edge(ll to) : to(to) {} edge(ll to, ll i) : to(to), i(i) {} edge(ll from, ll to, ll val) : from(from), to(to), val(val) {} }; class LCA { private: vector<vector<edge>> v; vector<vector<int>> parent; vector<int> depth; void dfs(int n, int m, int d) { parent[0][n] = m; depth[n] = d; for (auto x : v[n]) { if (x.to != m) dfs(x.to, n, d + 1); } } public: LCA(ll N, ll root, vector<vector<edge>> &tree) { v = tree; parent = vector<vector<int>>(21, vector<int>(N + 1, 0)); depth = vector<int>(N + 1, 0); dfs(root, -1, 0); for (int j = 0; j + 1 < 20; j++) { for (int i = 1; i <= N; i++) { if (parent[j][i] < 0) parent[j + 1][i] = -1; else parent[j + 1][i] = parent[j][parent[j][i]]; } } } int lca(int n, int m) { if (depth[n] > depth[m]) swap(n, m); for (int j = 0; j < 20; j++) { if ((depth[m] - depth[n]) >> j & 1) m = parent[j][m]; } if (n == m) return n; for (int j = 19; j >= 0; j--) { if (parent[j][n] != parent[j][m]) { n = parent[j][n]; m = parent[j][m]; } } return parent[0][n]; } int dep(int n) { return depth[n]; } }; ll k; int _rank[1010]; int temp[1010]; bool compare_sa(int i, int j) { if (_rank[i] != _rank[j]) return _rank[i] < _rank[j]; else { int ri = i + k <= n ? _rank[i + k] : -1; int rj = j + k <= n ? _rank[j + k] : -1; return ri < rj; } } void construct_sa(string S, int *sa) { n = S.length(); for (size_t i = 0; i <= n; i++) { sa[i] = i; _rank[i] = i < n ? S[i] : -1; } for (k = 1; k <= n; k *= 2) { sort(sa, sa + n + 1, compare_sa); // saはソート後の接尾辞の並びになっている、rankは元の位置のindexを保持したまま、更新されている。 // ピンとこなかった部分 temp[sa[0]] = 0; for (size_t i = 1; i <= n; i++) { temp[sa[i]] = temp[sa[i - 1]] + (compare_sa(sa[i - 1], sa[i]) ? 1 : 0); } for (size_t i = 0; i <= n; i++) { _rank[i] = temp[i]; } } } bool contain(string S, int *sa, string T) { int a = 0, b = S.length(); // sa は 接尾辞が辞書順に並んでいる、入っているのはその位置のインデックス while (b - a > 1) { int c = (a + b) / 2; if (S.compare(sa[c], T.length(), T) < 0) a = c; else b = c; } return S.compare(sa[b], T.length(), T) == 0; } #define bit(x, v) ((ll)x << v) class BIT { static const int MAX_N = 500010; public: BIT() { memset(bit, 0, sizeof(bit)); } ll bit[MAX_N + 1], n; ll sum(int i) { ll s = 0; while (i > 0) { s += bit[i]; i -= i & -i; } return s; } void add(int i, int x) { while (i <= n) { bit[i] += x; i += i & -i; } } }; struct UnionFind { vector<int> A; UnionFind(int n) : A(n, -1) {} int find(int x) { if (A[x] < 0) return x; return A[x] = find(A[x]); } void unite(int x, int y) { x = find(x), y = find(y); if (x == y) return; if (A[x] > A[y]) swap(x, y); A[x] += A[y]; A[y] = x; } int ngroups() { int ans = 0; for (auto a : A) if (a < 0) ans++; return ans; } }; vector<ll> getp(ll n) { vector<ll> res; ll a = 2; if (n % 2 == 0) { res.push_back(2); while (n % 2 == 0) n /= 2; } for (ll i = 3; i * i <= n; i += 2) { if (n % i == 0) { res.push_back(i); while (n % i == 0) n /= i; } } if (n != 1) res.push_back(n); return res; } vector<ll> getp2(ll n) { vector<ll> res; ll a = 2; if (n % 2 == 0) { while (n % 2 == 0) { n /= 2; res.push_back(2); } } for (ll i = 3; i * i <= n; i += 2) { if (n % i == 0) { while (n % i == 0) { n /= i; res.push_back(i); } } } if (n != 1) res.push_back(n); return res; } vector<pll> getp3(ll n) { vector<pll> res; ll a = 2; int si = 0; if (n % 2 == 0) { res.push_back(make_pair(2, 0)); while (n % 2 == 0) { n /= 2; res[si].second++; } si++; } for (ll i = 3; i * i <= n; i += 2) { if (n % i == 0) { res.push_back(make_pair(i, 0)); while (n % i == 0) { n /= i; res[si].second++; } si++; } } if (n != 1) { res.push_back(make_pair(n, 1)); } return res; } vector<ll> getDivisors(ll n) { vector<ll> res; ll a = 2; res.push_back(1); for (ll i = 2; i * i <= n; i++) { if (n % i == 0) { res.push_back(i); if (n / i != i) res.push_back(n / i); } } return res; } struct ve { public: vector<ve> child; int _t = INF; ve(int t) : _t(t) {} ve(ve _left, ve _right) { _t = _left._t + _right._t; child.push_back(_left); child.push_back(_right); } bool operator<(const ve &t) const { return _t > t._t; } }; vector<bool> elas(ll n) { vector<bool> r(n); fill(r.begin(), r.end(), 1); r[0] = 0; r[1] = 0; for (ll i = 2; i * i < n; i++) { if (!r[i]) continue; ll ti = i * 2; while (ti < n) { r[ti] = false; ti += i; } } return r; } bool isPrime(ll v) { for (ll i = 2; i * i <= v; i++) { if (v % i == 0) return false; } return true; } class SegTree { public: const static int MAX_N = 100010; const static int DAT_SIZE = (1 << 18) - 1; int N, Q; int A[MAX_N]; ll data[DAT_SIZE], datb[DAT_SIZE]; void init(int _n) { N = 1; while (N < _n) N <<= 1; memset(data, 0, sizeof(data)); memset(datb, 0, sizeof(datb)); } void init(int _n, ll iv) { N = 1; while (N < _n) N <<= 1; rep(i, DAT_SIZE) { data[i] = iv; datb[i] = iv; } } void add(int a, int b, int x) { add(a, b + 1, x, 0, 0, N); } void add(int a, int b, int x, int k, int l, int r) { if (a <= l && r <= b) { data[k] += x; } else if (l < b && a < r) { datb[k] += (min(b, r) - max(a, l)) * x; add(a, b, x, k * 2 + 1, l, (l + r) / 2); add(a, b, x, k * 2 + 2, (l + r) / 2, r); } } void change(int a, int b, int x) { change(a, b + 1, x, 0, 0, N); } void change(int a, int b, int x, int k, int l, int r) { if (a <= l && r <= b) { data[k] = x; } else if (l < b && a < r) { datb[k] = x; change(a, b, x, k * 2 + 1, l, (l + r) / 2); change(a, b, x, k * 2 + 2, (l + r) / 2, r); } } ll sum(int a, int b) { return sum(a, b + 1, 0, 0, N); } ll sum(int a, int b, int k, int l, int r) { if (b <= l || r <= a) { return 0; } if (a <= l && r <= b) { return data[k] * (r - l) + datb[k]; } ll res = (min(b, r) - max(a, l)) * data[k]; res += sum(a, b, k * 2 + 1, l, (l + r) / 2); res += sum(a, b, k * 2 + 2, (l + r) / 2, r); return res; } }; class Segment; class Circle; class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x, y - p.y); } Point operator*(double a) { return Point(a * x, a * y); } Point operator/(double a) { return Point(x / a, y / a); } double abs() { return sqrt(norm()); } double norm() { return x * x + y * y; } bool operator<(const Point &p) const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const Point &p) const { return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS; } static double dot(Point a, Point b) { return a.x * b.x + a.y * b.y; } static double cross(Point a, Point b) { return a.x * b.y - a.y * b.x; } static bool isOrthogonal(Point a, Point b) { return EQ(dot(a, b), 0.0); } static bool isOrthogonal(Point a1, Point a2, Point b1, Point b2) { return isOrthogonal(a1 - a2, b1 - b2); } static bool isOrthogonal(Segment s1, Segment s2); static bool isPalallel(Point a, Point b) { return EQ(cross(a, b), 0.0); } static bool isPalallel(Point a1, Point a2, Point b1, Point b2) { return isPalallel(a1 - a2, b1 - b2); } static bool isPalallel(Segment s1, Segment s2); static const int COUNTER_CLOCKWISE = 1; static const int CLOCKWISE = -1; static const int ONLINE_BACK = 2; static const int ONLINE_FRONT = -2; static const int ON_SEGMENT = 0; static int ccw(Point p0, Point p1, Point p2) { // 線分はp0とp1でp2がどこにあるかを探る Point a = p1 - p0; Point b = p2 - p0; if (cross(a, b) > EPS) return COUNTER_CLOCKWISE; if (cross(a, b) < -EPS) return CLOCKWISE; if (dot(a, b) < -EPS) return ONLINE_BACK; if (a.norm() < b.norm()) return ONLINE_FRONT; return ON_SEGMENT; } static bool intersect(Point p1, Point p2, Point p3, Point p4) { return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 && ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0); } static bool intersect(Segment s1, Segment s2); static Point project(Segment s, Point p); static Point reflect(Segment s, Point p); static Point getDistance(Point a, Point b) { return (a - b).abs(); } static double getDistanceLP(Segment s, Point p); static double getDistanceSP(Segment s, Point p); static double getDistance(Segment s1, Segment s2); static Point getIntersection(Segment s1, Segment s2); static pair<Point, Point> crossPoints(Circle c, Segment s); static int contains(vector<Point> g, Point p) { int n = g.size(); bool x = false; rep(i, n) { Point a = g[i] - p, b = g[(i + 1) % n] - p; // 線の上に載っているか if (std::abs(cross(a, b)) < EPS && dot(a, b) < EPS) return 1; // pを基準として上下にあるか // または外積が正か?(→にあるか) if (a.y > b.y) swap(a, b); if (a.y < EPS && EPS < b.y && cross(a, b) > EPS) x = !x; } return x ? 2 : 0; } static vector<Point> andrewScan(vector<Point> s) { vector<Point> u, l; if (s.size() < 3) return s; sort(all(s)); u.push_back(s[0]); u.push_back(s[1]); l.push_back(s[s.size() - 1]); l.push_back(s[s.size() - 2]); for (int i = 2; i < s.size(); i++) { for (int _n = u.size(); _n >= 2 && ccw(u[_n - 2], u[_n - 1], s[i]) > CLOCKWISE; _n--) { u.pop_back(); } u.push_back(s[i]); } for (int i = s.size() - 3; i >= 0; i--) { for (int _n = l.size(); _n >= 2 && ccw(l[_n - 2], l[_n - 1], s[i]) > CLOCKWISE; _n--) { l.pop_back(); } l.push_back(s[i]); } reverse(all(l)); for (int i = u.size() - 2; i >= 1; i--) { l.push_back(u[i]); } return l; } void get_cin() { cin >> x >> y; } }; class Segment { public: Point p1, p2; Segment() {} Segment(Point p1, Point p2) : p1(p1), p2(p2) {} void get_cin() { cin >> p1.x >> p1.y >> p2.x >> p2.y; } Point p1tp2() { return p2 - p1; } Point p2tp1() { return p1 - p2; } double abs() { return std::abs(norm()); } double norm() { return (p2 - p1).norm(); } }; bool Point::isOrthogonal(Segment s1, Segment s2) { return EQ(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0); } bool Point::isPalallel(Segment s1, Segment s2) { return EQ(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0); } bool Point::intersect(Segment s1, Segment s2) { return intersect(s1.p1, s1.p2, s2.p1, s2.p2); } Point Point::project(Segment s, Point p) { Point base = s.p2 - s.p1; double r = Point::dot(p - s.p1, base) / base.norm(); return s.p1 + base * r; } Point Point::reflect(Segment s, Point p) { return (project(s, p) * 2) - p; } double Point::getDistanceLP(Segment s, Point p) { return std::abs(cross(s.p2 - s.p1, p - s.p1) / (s.p2 - s.p1).abs()); } double Point::getDistanceSP(Segment s, Point p) { if (dot(s.p2 - s.p1, p - s.p1) < 0.0) return (p - s.p1).abs(); if (dot(s.p1 - s.p2, p - s.p2) < 0.0) return (p - s.p2).abs(); return getDistanceLP(s, p); } double Point::getDistance(Segment s1, Segment s2) { if (intersect(s1, s2)) return 0.0; return min({getDistanceSP(s1, s2.p1), getDistanceSP(s1, s2.p2), getDistanceSP(s2, s1.p1), getDistanceSP(s2, s1.p2)}); } Point Point::getIntersection(Segment s1, Segment s2) { // (s1.p1 - s2.p1).norm() auto bs = s1.p2 - s1.p1; auto n1 = s2.p1 - s1.p1; auto n2 = s2.p2 - s1.p1; auto c1 = std::abs(cross(n1, bs)) / bs.norm(); auto c2 = std::abs(cross(n2, bs)) / bs.norm(); return s2.p1 + (s2.p2 - s2.p1) * (c1 / (c1 + c2)); // c1:c2=t:1-t // c2t=(1-t)c1 // t/(1-t)=c1/(c1+c2) // } double arg(Point p) { return atan2(p.y, p.x); } Point polar(double a, double r) { return Point(cos(r) * a, sin(r) * a); } class Circle { public: Point c; double r; Circle(Point c = Point(), double r = 0.0) : c(c), r(r) {} void get_cin() { cin >> c.x >> c.y >> r; } static pair<Point, Point> getCrossPoints(Circle c1, Circle c2) { double d = (c1.c - c2.c).abs(); // 中心点どうしの距離 double a = acos((c1.r * c1.r + d * d - c2.r * c2.r) / (2 * c1.r * d)); double t = arg(c2.c - c1.c); return make_pair(c1.c + polar(c1.r, t + a), c1.c + polar(c1.r, t - a)); } }; pair<Point, Point> Point::crossPoints(Circle c, Segment s) { auto pp = project(s, c.c); auto f = (pp - c.c).norm(); auto mu = sqrt(c.r * c.r - f); auto e = s.p1tp2() / s.p1tp2().abs(); return make_pair(pp + e * mu, pp - e * mu); } ll divRm(string s, ll x) { ll r = 0; for (ll i = 0; i < s.size(); i++) { r *= 10; r += s[i] - '0'; r %= x; } return r; } ll cmbi(ll x, ll b) { ll res = 1; for (size_t i = 0; i < b; i++) { res *= x - i; res %= INF; res *= inv[b - i]; res %= INF; } return res; } double digsum(ll x) { ll res = 0; while (x > 0) { res += x % 10; x /= 10; } return res; } bool check_parindrome(string s) { int n = s.size(); rep(i, n / 2) { if (s[i] != s[n - i - 1]) { return false; } } return true; } // ここまでライブラリ // ここからコード struct mm { double h = -big, l = big; }; double x[100010], y[100010]; char d[100010]; mm m[4]; mm fm[2]; void sech(mm &v, double a) { v.h = max(v.h, a); v.l = min(v.l, a); } void setu(vector<double> &v, int p, char c) { ll f = p / 2; if (f == 1) { swap(x, y); } rep(i, n) { if (d[i] != c) continue; if (m[p].l < big) { v.push_back(abs(x[i] - m[p].l)); v.push_back(abs(x[i] - m[p].l) / 2); v.push_back(abs(x[i] - m[p].h)); v.push_back(abs(x[i] - m[p].h) / 2); } if (fm[f].l < big) { v.push_back(abs(x[i] - fm[f].l)); v.push_back(abs(x[i] - fm[f].l) / 2); v.push_back(abs(x[i] - fm[f].h)); v.push_back(abs(x[i] - fm[f].h) / 2); } } if (f == 1) { swap(x, y); } } double clx(double x) { return max({m[0].h + x, m[1].h - x, fm[0].h}) - min({m[0].l + x, m[1].l - x, fm[0].l}); } double cly(double x) { return max({m[2].h + x, m[3].h - x, fm[1].h}) - min({m[2].l + x, m[3].l - x, fm[1].l}); } double clc(double x) { return clx(x) * cly(x); } void solv() { cin >> n; rep(i, n) { cin >> x[i] >> y[i] >> d[i]; switch (d[i]) { case 'R': sech(m[0], x[i]); sech(fm[1], y[i]); break; case 'L': sech(m[1], x[i]); sech(fm[1], y[i]); break; case 'U': sech(m[2], y[i]); sech(fm[0], x[i]); break; case 'D': sech(m[3], y[i]); sech(fm[0], x[i]); break; } } vector<double> v; setu(v, 0, 'L'); setu(v, 1, 'R'); setu(v, 2, 'D'); setu(v, 3, 'U'); double res = clc(0); rep(i, v.size()) { res = min(res, clc(v[i])); } put_float(res); } int main() { COMinit(); solv(); return 0; }
[ "literal.string.change", "call.arguments.change" ]
832,980
832,981
u224756887
cpp
p03004
#include <algorithm> #include <array> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctype.h> #include <deque> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string.h> #include <unordered_map> #include <utility> #include <vector> #define _USE_MATH_DEFINES #include <iostream> #include <math.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<ll, double> pld; typedef pair<double, double> pdd; typedef pair<double, ll> pdl; typedef pair<int, char> pic; typedef vector<ll> vl; typedef vector<int> vi; typedef priority_queue<ll, vector<ll>, greater<ll>> llgreaterq; typedef priority_queue<pll, vector<pll>, greater<pll>> pllgreaterq; typedef priority_queue<pair<ll, pll>, vector<pair<ll, pll>>, greater<pair<ll, pll>>> plpllgreaterq; typedef priority_queue<vi, vector<vi>, greater<vi>> vigreaterq; typedef priority_queue<vl, vector<vl>, greater<vl>> vlgreaterq; template <class o, class p, class q> using tuple3q = priority_queue<tuple<o, p, q>, vector<tuple<o, p, q>>, greater<tuple<o, p, q>>>; template <class o, class p, class q, class r> using tuple4q = priority_queue<tuple<o, p, q, r>, vector<tuple<o, p, q, r>>, greater<tuple<o, p, q, r>>>; template <class o, class p, class q, class r, class s> using tuple5q = priority_queue<tuple<o, p, q, r, s>, vector<tuple<o, p, q, r, s>>, greater<tuple<o, p, q, r, s>>>; int dx[] = {-1, 0, 1, 0}; int dy[] = {0, -1, 0, 1}; #define bit(x, v) ((ll)x << v) #define rep(x, n) for (ll x = 0; x < n; x++) #define rep2(x, f, v) for (ll x = f; x < v; x++) #define repe(v, x) for (auto v : x) // 許容する誤差ε #define EPS (1e-10) // 2つのスカラーが等しいかどうか #define EQ(a, b) (std::abs(a - b) < EPS) // 2つのベクトルが等しいかどうか #define EQV(a, b) (EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag())) #define all(a) a.begin(), a.end() #define all0(a) memset(a, 0, sizeof(a)) #define allm1(a) memset(a, -1, sizeof(a)) #define put_float(v) \ cout << fixed << setprecision(10); \ cout << v << endl #define put(v) cout << v << endl #define vinsert(v, p, x) v.insert(v.begin() + p, x) #define vsort(v) sort(all(v)); #define dup(v) v.erase(unique(all(v)), v.end()) #define ion(i, j) ((i & (1LL << j)) > 0) #define next(i) \ i++; \ i %= 2 #define Len size() #define ull unsignd long long #define psp(a, b) push_back(make_pair(a, b)) #define psp2(a, b) push(make_pair(a, b)) #define cini(a) \ a; \ cin >> a #define infa(a, b) (a + b) % INF #define infm(a, b) (a * b) % INF #define infd(a, b) (a * modinv(b)) % INF #define infs(a, b) (a + INF - b) % INF #define inf(a) (a) %= INF #define inff(a) ((a) % INF) #define No cout << "No" << endl #define Yes cout << "Yes" << endl #define NO cout << "NO" << endl #define YES cout << "YES" << endl #define smal -INF *INF #define big INF *INF const ll INF = 1000000007; const int MAX = 2000010; const int MOD = 1000000007; long long fac[MAX], finv[MAX], inv[MAX]; void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 long long COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } ll getpow(ll b, ll x, ll md) { ll t = b; ll res = 1; while (x > 0) { if (x & 1) { res *= t; res %= md; } x >>= 1; t *= t; t %= md; } return res; } ll getpow(ll b, ll x) { return getpow(b, x, INF); } ll modinv(ll x) { return getpow(x, INF - 2); } ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } class mint { int md = 1000000007; public: long long x; mint(ll x, ll md) { this->md = md; this->x = (x % md + md) % md; } mint(long long x = 0) : x((x % md + md) % md) {} mint operator-() const { return mint(-x); } mint &operator+=(const mint &a) { if ((x += a.x) >= md) x -= md; return *this; } mint &operator-=(const mint &a) { if ((x += md - a.x) >= md) x -= md; return *this; } mint &operator*=(const mint &a) { (x *= a.x) %= md; return *this; } mint operator+(const mint &a) const { mint res(*this); return res += a; } mint operator-(const mint &a) const { mint res(*this); return res -= a; } mint operator*(const mint &a) const { mint res(*this); return res *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(md - 2); } mint &operator/=(const mint &a) { return (*this) *= a.inv(); } mint operator/(const mint &a) const { mint res(*this); return res /= a; } friend ostream &operator<<(ostream &os, const mint &m) { os << m.x; return os; } }; int pr[100010]; int lank[100010]; void uini(int n) { for (size_t i = 0; i <= n; i++) { pr[i] = i; lank[i] = 1; } } int parent(int x) { if (x == pr[x]) return x; return pr[x] = parent(pr[x]); } int same(int x, int y) { return parent(x) == parent(y); } bool unit(int x, int y) { int px = parent(x); int py = parent(y); if (px == py) return false; if (lank[py] < lank[px]) { pr[py] = px; lank[px] += lank[py]; } else { pr[px] = py; lank[py] += lank[px]; } return true; } ll n; int ci = 0; struct Node { int key; int priority; Node *parent, *left, *right; Node(int key, int priority); Node() {} }; Node NIL; Node::Node(int key, int priority) : key(key), priority(priority) { left = &NIL; right = &NIL; } Node *root = new Node(); void cenrec(Node *k) { if (k->key == NIL.key) return; cenrec(k->left); cout << " " << k->key; cenrec(k->right); } void fastrec(Node *k) { if (k->key == NIL.key) return; cout << " " << k->key; fastrec(k->left); fastrec(k->right); } void insert(Node *v) { Node *y = &NIL; Node *x = root; while (x->key != NIL.key) { y = x; if (v->key < x->key) { x = x->left; } else { x = x->right; } } v->parent = y; if (y->key == NIL.key) { root = v; } else if (v->key < y->key) { y->left = v; } else { y->right = v; } } Node *find(Node *k, ll v) { if (k->key == NIL.key) return &NIL; if (k->key == v) return k; if (v < k->key) return find(k->left, v); return find(k->right, v); } void delp12(Node *x) { if (x->key == NIL.key) return; Node *l = x->left; Node *r = x->right; Node *pr = x->parent; if (l->key == NIL.key && r->key == NIL.key) { if (pr->left == x) { pr->left = &NIL; } else pr->right = &NIL; } else if (l->key != NIL.key) { if (pr->left == x) { pr->left = l; } else pr->right = l; l->parent = pr; } else if (r->key != NIL.key) { if (pr->left == x) { pr->left = r; } else pr->right = r; r->parent = pr; } } Node *get_next(Node *k) { if (k->key == NIL.key) return &NIL; Node *res = get_next(k->left); if (res->key != NIL.key) return res; return k; } void del(Node *x) { if (x->key == NIL.key) return; Node *l = x->left; Node *r = x->right; Node *pr = x->parent; if (l->key != NIL.key && r->key != NIL.key) { Node *nex = get_next(r); x->key = nex->key; delp12(nex); } else { delp12(x); } } Node *rightRotate(Node *t) { Node *s = t->left; t->left = s->right; s->right = t; return s; } Node *leftRotate(Node *t) { Node *s = t->right; t->right = s->left; s->left = t; return s; } Node *_insert(Node *t, int key, int priority) { if (t->key == NIL.key) { return new Node(key, priority); } if (key == t->key) { return t; } if (key < t->key) { t->left = _insert(t->left, key, priority); if (t->priority < t->left->priority) { t = rightRotate(t); } } else { t->right = _insert(t->right, key, priority); if (t->priority < t->right->priority) { t = leftRotate(t); } } return t; } Node *delete1(Node *t, int key); Node *_delete(Node *t, int key) { if (t->left->key == NIL.key && t->right->key == NIL.key) { return &NIL; } else if (t->left->key == NIL.key) { t = leftRotate(t); } else if (t->right->key == NIL.key) { t = rightRotate(t); } else { if (t->left->priority > t->right->priority) { t = rightRotate(t); } else t = leftRotate(t); } return delete1(t, key); } Node *delete1(Node *t, int key) { if (t->key == NIL.key) { return &NIL; } if (key < t->key) { t->left = delete1(t->left, key); } else if (key > t->key) { t->right = delete1(t->right, key); } else return _delete(t, key); return t; } int H; int left(int i) { return i * 2 + 1; } int right(int i) { return i * 2 + 2; } class edge { public: int from, to, i; ll val; edge() {} edge(ll to) : to(to) {} edge(ll to, ll i) : to(to), i(i) {} edge(ll from, ll to, ll val) : from(from), to(to), val(val) {} }; class LCA { private: vector<vector<edge>> v; vector<vector<int>> parent; vector<int> depth; void dfs(int n, int m, int d) { parent[0][n] = m; depth[n] = d; for (auto x : v[n]) { if (x.to != m) dfs(x.to, n, d + 1); } } public: LCA(ll N, ll root, vector<vector<edge>> &tree) { v = tree; parent = vector<vector<int>>(21, vector<int>(N + 1, 0)); depth = vector<int>(N + 1, 0); dfs(root, -1, 0); for (int j = 0; j + 1 < 20; j++) { for (int i = 1; i <= N; i++) { if (parent[j][i] < 0) parent[j + 1][i] = -1; else parent[j + 1][i] = parent[j][parent[j][i]]; } } } int lca(int n, int m) { if (depth[n] > depth[m]) swap(n, m); for (int j = 0; j < 20; j++) { if ((depth[m] - depth[n]) >> j & 1) m = parent[j][m]; } if (n == m) return n; for (int j = 19; j >= 0; j--) { if (parent[j][n] != parent[j][m]) { n = parent[j][n]; m = parent[j][m]; } } return parent[0][n]; } int dep(int n) { return depth[n]; } }; ll k; int _rank[1010]; int temp[1010]; bool compare_sa(int i, int j) { if (_rank[i] != _rank[j]) return _rank[i] < _rank[j]; else { int ri = i + k <= n ? _rank[i + k] : -1; int rj = j + k <= n ? _rank[j + k] : -1; return ri < rj; } } void construct_sa(string S, int *sa) { n = S.length(); for (size_t i = 0; i <= n; i++) { sa[i] = i; _rank[i] = i < n ? S[i] : -1; } for (k = 1; k <= n; k *= 2) { sort(sa, sa + n + 1, compare_sa); // saはソート後の接尾辞の並びになっている、rankは元の位置のindexを保持したまま、更新されている。 // ピンとこなかった部分 temp[sa[0]] = 0; for (size_t i = 1; i <= n; i++) { temp[sa[i]] = temp[sa[i - 1]] + (compare_sa(sa[i - 1], sa[i]) ? 1 : 0); } for (size_t i = 0; i <= n; i++) { _rank[i] = temp[i]; } } } bool contain(string S, int *sa, string T) { int a = 0, b = S.length(); // sa は 接尾辞が辞書順に並んでいる、入っているのはその位置のインデックス while (b - a > 1) { int c = (a + b) / 2; if (S.compare(sa[c], T.length(), T) < 0) a = c; else b = c; } return S.compare(sa[b], T.length(), T) == 0; } #define bit(x, v) ((ll)x << v) class BIT { static const int MAX_N = 500010; public: BIT() { memset(bit, 0, sizeof(bit)); } ll bit[MAX_N + 1], n; ll sum(int i) { ll s = 0; while (i > 0) { s += bit[i]; i -= i & -i; } return s; } void add(int i, int x) { while (i <= n) { bit[i] += x; i += i & -i; } } }; struct UnionFind { vector<int> A; UnionFind(int n) : A(n, -1) {} int find(int x) { if (A[x] < 0) return x; return A[x] = find(A[x]); } void unite(int x, int y) { x = find(x), y = find(y); if (x == y) return; if (A[x] > A[y]) swap(x, y); A[x] += A[y]; A[y] = x; } int ngroups() { int ans = 0; for (auto a : A) if (a < 0) ans++; return ans; } }; vector<ll> getp(ll n) { vector<ll> res; ll a = 2; if (n % 2 == 0) { res.push_back(2); while (n % 2 == 0) n /= 2; } for (ll i = 3; i * i <= n; i += 2) { if (n % i == 0) { res.push_back(i); while (n % i == 0) n /= i; } } if (n != 1) res.push_back(n); return res; } vector<ll> getp2(ll n) { vector<ll> res; ll a = 2; if (n % 2 == 0) { while (n % 2 == 0) { n /= 2; res.push_back(2); } } for (ll i = 3; i * i <= n; i += 2) { if (n % i == 0) { while (n % i == 0) { n /= i; res.push_back(i); } } } if (n != 1) res.push_back(n); return res; } vector<pll> getp3(ll n) { vector<pll> res; ll a = 2; int si = 0; if (n % 2 == 0) { res.push_back(make_pair(2, 0)); while (n % 2 == 0) { n /= 2; res[si].second++; } si++; } for (ll i = 3; i * i <= n; i += 2) { if (n % i == 0) { res.push_back(make_pair(i, 0)); while (n % i == 0) { n /= i; res[si].second++; } si++; } } if (n != 1) { res.push_back(make_pair(n, 1)); } return res; } vector<ll> getDivisors(ll n) { vector<ll> res; ll a = 2; res.push_back(1); for (ll i = 2; i * i <= n; i++) { if (n % i == 0) { res.push_back(i); if (n / i != i) res.push_back(n / i); } } return res; } struct ve { public: vector<ve> child; int _t = INF; ve(int t) : _t(t) {} ve(ve _left, ve _right) { _t = _left._t + _right._t; child.push_back(_left); child.push_back(_right); } bool operator<(const ve &t) const { return _t > t._t; } }; vector<bool> elas(ll n) { vector<bool> r(n); fill(r.begin(), r.end(), 1); r[0] = 0; r[1] = 0; for (ll i = 2; i * i < n; i++) { if (!r[i]) continue; ll ti = i * 2; while (ti < n) { r[ti] = false; ti += i; } } return r; } bool isPrime(ll v) { for (ll i = 2; i * i <= v; i++) { if (v % i == 0) return false; } return true; } class SegTree { public: const static int MAX_N = 100010; const static int DAT_SIZE = (1 << 18) - 1; int N, Q; int A[MAX_N]; ll data[DAT_SIZE], datb[DAT_SIZE]; void init(int _n) { N = 1; while (N < _n) N <<= 1; memset(data, 0, sizeof(data)); memset(datb, 0, sizeof(datb)); } void init(int _n, ll iv) { N = 1; while (N < _n) N <<= 1; rep(i, DAT_SIZE) { data[i] = iv; datb[i] = iv; } } void add(int a, int b, int x) { add(a, b + 1, x, 0, 0, N); } void add(int a, int b, int x, int k, int l, int r) { if (a <= l && r <= b) { data[k] += x; } else if (l < b && a < r) { datb[k] += (min(b, r) - max(a, l)) * x; add(a, b, x, k * 2 + 1, l, (l + r) / 2); add(a, b, x, k * 2 + 2, (l + r) / 2, r); } } void change(int a, int b, int x) { change(a, b + 1, x, 0, 0, N); } void change(int a, int b, int x, int k, int l, int r) { if (a <= l && r <= b) { data[k] = x; } else if (l < b && a < r) { datb[k] = x; change(a, b, x, k * 2 + 1, l, (l + r) / 2); change(a, b, x, k * 2 + 2, (l + r) / 2, r); } } ll sum(int a, int b) { return sum(a, b + 1, 0, 0, N); } ll sum(int a, int b, int k, int l, int r) { if (b <= l || r <= a) { return 0; } if (a <= l && r <= b) { return data[k] * (r - l) + datb[k]; } ll res = (min(b, r) - max(a, l)) * data[k]; res += sum(a, b, k * 2 + 1, l, (l + r) / 2); res += sum(a, b, k * 2 + 2, (l + r) / 2, r); return res; } }; class Segment; class Circle; class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x, y - p.y); } Point operator*(double a) { return Point(a * x, a * y); } Point operator/(double a) { return Point(x / a, y / a); } double abs() { return sqrt(norm()); } double norm() { return x * x + y * y; } bool operator<(const Point &p) const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const Point &p) const { return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS; } static double dot(Point a, Point b) { return a.x * b.x + a.y * b.y; } static double cross(Point a, Point b) { return a.x * b.y - a.y * b.x; } static bool isOrthogonal(Point a, Point b) { return EQ(dot(a, b), 0.0); } static bool isOrthogonal(Point a1, Point a2, Point b1, Point b2) { return isOrthogonal(a1 - a2, b1 - b2); } static bool isOrthogonal(Segment s1, Segment s2); static bool isPalallel(Point a, Point b) { return EQ(cross(a, b), 0.0); } static bool isPalallel(Point a1, Point a2, Point b1, Point b2) { return isPalallel(a1 - a2, b1 - b2); } static bool isPalallel(Segment s1, Segment s2); static const int COUNTER_CLOCKWISE = 1; static const int CLOCKWISE = -1; static const int ONLINE_BACK = 2; static const int ONLINE_FRONT = -2; static const int ON_SEGMENT = 0; static int ccw(Point p0, Point p1, Point p2) { // 線分はp0とp1でp2がどこにあるかを探る Point a = p1 - p0; Point b = p2 - p0; if (cross(a, b) > EPS) return COUNTER_CLOCKWISE; if (cross(a, b) < -EPS) return CLOCKWISE; if (dot(a, b) < -EPS) return ONLINE_BACK; if (a.norm() < b.norm()) return ONLINE_FRONT; return ON_SEGMENT; } static bool intersect(Point p1, Point p2, Point p3, Point p4) { return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 && ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0); } static bool intersect(Segment s1, Segment s2); static Point project(Segment s, Point p); static Point reflect(Segment s, Point p); static Point getDistance(Point a, Point b) { return (a - b).abs(); } static double getDistanceLP(Segment s, Point p); static double getDistanceSP(Segment s, Point p); static double getDistance(Segment s1, Segment s2); static Point getIntersection(Segment s1, Segment s2); static pair<Point, Point> crossPoints(Circle c, Segment s); static int contains(vector<Point> g, Point p) { int n = g.size(); bool x = false; rep(i, n) { Point a = g[i] - p, b = g[(i + 1) % n] - p; // 線の上に載っているか if (std::abs(cross(a, b)) < EPS && dot(a, b) < EPS) return 1; // pを基準として上下にあるか // または外積が正か?(→にあるか) if (a.y > b.y) swap(a, b); if (a.y < EPS && EPS < b.y && cross(a, b) > EPS) x = !x; } return x ? 2 : 0; } static vector<Point> andrewScan(vector<Point> s) { vector<Point> u, l; if (s.size() < 3) return s; sort(all(s)); u.push_back(s[0]); u.push_back(s[1]); l.push_back(s[s.size() - 1]); l.push_back(s[s.size() - 2]); for (int i = 2; i < s.size(); i++) { for (int _n = u.size(); _n >= 2 && ccw(u[_n - 2], u[_n - 1], s[i]) > CLOCKWISE; _n--) { u.pop_back(); } u.push_back(s[i]); } for (int i = s.size() - 3; i >= 0; i--) { for (int _n = l.size(); _n >= 2 && ccw(l[_n - 2], l[_n - 1], s[i]) > CLOCKWISE; _n--) { l.pop_back(); } l.push_back(s[i]); } reverse(all(l)); for (int i = u.size() - 2; i >= 1; i--) { l.push_back(u[i]); } return l; } void get_cin() { cin >> x >> y; } }; class Segment { public: Point p1, p2; Segment() {} Segment(Point p1, Point p2) : p1(p1), p2(p2) {} void get_cin() { cin >> p1.x >> p1.y >> p2.x >> p2.y; } Point p1tp2() { return p2 - p1; } Point p2tp1() { return p1 - p2; } double abs() { return std::abs(norm()); } double norm() { return (p2 - p1).norm(); } }; bool Point::isOrthogonal(Segment s1, Segment s2) { return EQ(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0); } bool Point::isPalallel(Segment s1, Segment s2) { return EQ(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0); } bool Point::intersect(Segment s1, Segment s2) { return intersect(s1.p1, s1.p2, s2.p1, s2.p2); } Point Point::project(Segment s, Point p) { Point base = s.p2 - s.p1; double r = Point::dot(p - s.p1, base) / base.norm(); return s.p1 + base * r; } Point Point::reflect(Segment s, Point p) { return (project(s, p) * 2) - p; } double Point::getDistanceLP(Segment s, Point p) { return std::abs(cross(s.p2 - s.p1, p - s.p1) / (s.p2 - s.p1).abs()); } double Point::getDistanceSP(Segment s, Point p) { if (dot(s.p2 - s.p1, p - s.p1) < 0.0) return (p - s.p1).abs(); if (dot(s.p1 - s.p2, p - s.p2) < 0.0) return (p - s.p2).abs(); return getDistanceLP(s, p); } double Point::getDistance(Segment s1, Segment s2) { if (intersect(s1, s2)) return 0.0; return min({getDistanceSP(s1, s2.p1), getDistanceSP(s1, s2.p2), getDistanceSP(s2, s1.p1), getDistanceSP(s2, s1.p2)}); } Point Point::getIntersection(Segment s1, Segment s2) { // (s1.p1 - s2.p1).norm() auto bs = s1.p2 - s1.p1; auto n1 = s2.p1 - s1.p1; auto n2 = s2.p2 - s1.p1; auto c1 = std::abs(cross(n1, bs)) / bs.norm(); auto c2 = std::abs(cross(n2, bs)) / bs.norm(); return s2.p1 + (s2.p2 - s2.p1) * (c1 / (c1 + c2)); // c1:c2=t:1-t // c2t=(1-t)c1 // t/(1-t)=c1/(c1+c2) // } double arg(Point p) { return atan2(p.y, p.x); } Point polar(double a, double r) { return Point(cos(r) * a, sin(r) * a); } class Circle { public: Point c; double r; Circle(Point c = Point(), double r = 0.0) : c(c), r(r) {} void get_cin() { cin >> c.x >> c.y >> r; } static pair<Point, Point> getCrossPoints(Circle c1, Circle c2) { double d = (c1.c - c2.c).abs(); // 中心点どうしの距離 double a = acos((c1.r * c1.r + d * d - c2.r * c2.r) / (2 * c1.r * d)); double t = arg(c2.c - c1.c); return make_pair(c1.c + polar(c1.r, t + a), c1.c + polar(c1.r, t - a)); } }; pair<Point, Point> Point::crossPoints(Circle c, Segment s) { auto pp = project(s, c.c); auto f = (pp - c.c).norm(); auto mu = sqrt(c.r * c.r - f); auto e = s.p1tp2() / s.p1tp2().abs(); return make_pair(pp + e * mu, pp - e * mu); } ll divRm(string s, ll x) { ll r = 0; for (ll i = 0; i < s.size(); i++) { r *= 10; r += s[i] - '0'; r %= x; } return r; } ll cmbi(ll x, ll b) { ll res = 1; for (size_t i = 0; i < b; i++) { res *= x - i; res %= INF; res *= inv[b - i]; res %= INF; } return res; } double digsum(ll x) { ll res = 0; while (x > 0) { res += x % 10; x /= 10; } return res; } bool check_parindrome(string s) { int n = s.size(); rep(i, n / 2) { if (s[i] != s[n - i - 1]) { return false; } } return true; } // ここまでライブラリ // ここからコード struct mm { double h = -big, l = big; }; double x[100010], y[100010]; char d[100010]; mm m[4]; mm fm[2]; void sech(mm &v, double a) { v.h = max(v.h, a); v.l = min(v.l, a); } void setu(vector<double> &v, int p, char c) { ll f = p / 2; if (f == 0) { swap(x, y); } rep(i, n) { if (d[i] != c) continue; if (m[p].l < big) { v.push_back(abs(x[i] - m[p].l)); v.push_back(abs(x[i] - m[p].l) / 2); v.push_back(abs(x[i] - m[p].h)); v.push_back(abs(x[i] - m[p].h) / 2); } if (fm[f].l < big) { v.push_back(abs(x[i] - fm[f].l)); v.push_back(abs(x[i] - fm[f].l) / 2); v.push_back(abs(x[i] - fm[f].h)); v.push_back(abs(x[i] - fm[f].h) / 2); } } if (f == 0) { swap(x, y); } } double clx(double x) { return max({m[0].h + x, m[1].h - x, fm[0].h}) - min({m[0].l + x, m[1].l - x, fm[0].l}); } double cly(double x) { return max({m[2].h + x, m[3].h - x, fm[1].h}) - min({m[2].l + x, m[3].l - x, fm[1].l}); } double clc(double x) { return clx(x) * cly(x); } void solv() { cin >> n; rep(i, n) { cin >> x[i] >> y[i] >> d[i]; switch (d[i]) { case 'R': sech(m[0], x[i]); sech(fm[1], y[i]); break; case 'L': sech(m[1], x[i]); sech(fm[1], y[i]); break; case 'U': sech(m[2], y[i]); sech(fm[0], x[i]); break; case 'D': sech(m[3], y[i]); sech(fm[0], x[i]); break; } } vector<double> v; setu(v, 0, 'L'); setu(v, 1, 'R'); setu(v, 2, 'U'); setu(v, 3, 'D'); double res = clc(0); rep(i, v.size()) { res = min(res, clc(v[i])); } put_float(res); } int main() { COMinit(); solv(); return 0; }
#include <algorithm> #include <array> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctype.h> #include <deque> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string.h> #include <unordered_map> #include <utility> #include <vector> #define _USE_MATH_DEFINES #include <iostream> #include <math.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<ll, double> pld; typedef pair<double, double> pdd; typedef pair<double, ll> pdl; typedef pair<int, char> pic; typedef vector<ll> vl; typedef vector<int> vi; typedef priority_queue<ll, vector<ll>, greater<ll>> llgreaterq; typedef priority_queue<pll, vector<pll>, greater<pll>> pllgreaterq; typedef priority_queue<pair<ll, pll>, vector<pair<ll, pll>>, greater<pair<ll, pll>>> plpllgreaterq; typedef priority_queue<vi, vector<vi>, greater<vi>> vigreaterq; typedef priority_queue<vl, vector<vl>, greater<vl>> vlgreaterq; template <class o, class p, class q> using tuple3q = priority_queue<tuple<o, p, q>, vector<tuple<o, p, q>>, greater<tuple<o, p, q>>>; template <class o, class p, class q, class r> using tuple4q = priority_queue<tuple<o, p, q, r>, vector<tuple<o, p, q, r>>, greater<tuple<o, p, q, r>>>; template <class o, class p, class q, class r, class s> using tuple5q = priority_queue<tuple<o, p, q, r, s>, vector<tuple<o, p, q, r, s>>, greater<tuple<o, p, q, r, s>>>; int dx[] = {-1, 0, 1, 0}; int dy[] = {0, -1, 0, 1}; #define bit(x, v) ((ll)x << v) #define rep(x, n) for (ll x = 0; x < n; x++) #define rep2(x, f, v) for (ll x = f; x < v; x++) #define repe(v, x) for (auto v : x) // 許容する誤差ε #define EPS (1e-10) // 2つのスカラーが等しいかどうか #define EQ(a, b) (std::abs(a - b) < EPS) // 2つのベクトルが等しいかどうか #define EQV(a, b) (EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag())) #define all(a) a.begin(), a.end() #define all0(a) memset(a, 0, sizeof(a)) #define allm1(a) memset(a, -1, sizeof(a)) #define put_float(v) \ cout << fixed << setprecision(10); \ cout << v << endl #define put(v) cout << v << endl #define vinsert(v, p, x) v.insert(v.begin() + p, x) #define vsort(v) sort(all(v)); #define dup(v) v.erase(unique(all(v)), v.end()) #define ion(i, j) ((i & (1LL << j)) > 0) #define next(i) \ i++; \ i %= 2 #define Len size() #define ull unsignd long long #define psp(a, b) push_back(make_pair(a, b)) #define psp2(a, b) push(make_pair(a, b)) #define cini(a) \ a; \ cin >> a #define infa(a, b) (a + b) % INF #define infm(a, b) (a * b) % INF #define infd(a, b) (a * modinv(b)) % INF #define infs(a, b) (a + INF - b) % INF #define inf(a) (a) %= INF #define inff(a) ((a) % INF) #define No cout << "No" << endl #define Yes cout << "Yes" << endl #define NO cout << "NO" << endl #define YES cout << "YES" << endl #define smal -INF *INF #define big INF *INF const ll INF = 1000000007; const int MAX = 2000010; const int MOD = 1000000007; long long fac[MAX], finv[MAX], inv[MAX]; void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 long long COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } ll getpow(ll b, ll x, ll md) { ll t = b; ll res = 1; while (x > 0) { if (x & 1) { res *= t; res %= md; } x >>= 1; t *= t; t %= md; } return res; } ll getpow(ll b, ll x) { return getpow(b, x, INF); } ll modinv(ll x) { return getpow(x, INF - 2); } ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } class mint { int md = 1000000007; public: long long x; mint(ll x, ll md) { this->md = md; this->x = (x % md + md) % md; } mint(long long x = 0) : x((x % md + md) % md) {} mint operator-() const { return mint(-x); } mint &operator+=(const mint &a) { if ((x += a.x) >= md) x -= md; return *this; } mint &operator-=(const mint &a) { if ((x += md - a.x) >= md) x -= md; return *this; } mint &operator*=(const mint &a) { (x *= a.x) %= md; return *this; } mint operator+(const mint &a) const { mint res(*this); return res += a; } mint operator-(const mint &a) const { mint res(*this); return res -= a; } mint operator*(const mint &a) const { mint res(*this); return res *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(md - 2); } mint &operator/=(const mint &a) { return (*this) *= a.inv(); } mint operator/(const mint &a) const { mint res(*this); return res /= a; } friend ostream &operator<<(ostream &os, const mint &m) { os << m.x; return os; } }; int pr[100010]; int lank[100010]; void uini(int n) { for (size_t i = 0; i <= n; i++) { pr[i] = i; lank[i] = 1; } } int parent(int x) { if (x == pr[x]) return x; return pr[x] = parent(pr[x]); } int same(int x, int y) { return parent(x) == parent(y); } bool unit(int x, int y) { int px = parent(x); int py = parent(y); if (px == py) return false; if (lank[py] < lank[px]) { pr[py] = px; lank[px] += lank[py]; } else { pr[px] = py; lank[py] += lank[px]; } return true; } ll n; int ci = 0; struct Node { int key; int priority; Node *parent, *left, *right; Node(int key, int priority); Node() {} }; Node NIL; Node::Node(int key, int priority) : key(key), priority(priority) { left = &NIL; right = &NIL; } Node *root = new Node(); void cenrec(Node *k) { if (k->key == NIL.key) return; cenrec(k->left); cout << " " << k->key; cenrec(k->right); } void fastrec(Node *k) { if (k->key == NIL.key) return; cout << " " << k->key; fastrec(k->left); fastrec(k->right); } void insert(Node *v) { Node *y = &NIL; Node *x = root; while (x->key != NIL.key) { y = x; if (v->key < x->key) { x = x->left; } else { x = x->right; } } v->parent = y; if (y->key == NIL.key) { root = v; } else if (v->key < y->key) { y->left = v; } else { y->right = v; } } Node *find(Node *k, ll v) { if (k->key == NIL.key) return &NIL; if (k->key == v) return k; if (v < k->key) return find(k->left, v); return find(k->right, v); } void delp12(Node *x) { if (x->key == NIL.key) return; Node *l = x->left; Node *r = x->right; Node *pr = x->parent; if (l->key == NIL.key && r->key == NIL.key) { if (pr->left == x) { pr->left = &NIL; } else pr->right = &NIL; } else if (l->key != NIL.key) { if (pr->left == x) { pr->left = l; } else pr->right = l; l->parent = pr; } else if (r->key != NIL.key) { if (pr->left == x) { pr->left = r; } else pr->right = r; r->parent = pr; } } Node *get_next(Node *k) { if (k->key == NIL.key) return &NIL; Node *res = get_next(k->left); if (res->key != NIL.key) return res; return k; } void del(Node *x) { if (x->key == NIL.key) return; Node *l = x->left; Node *r = x->right; Node *pr = x->parent; if (l->key != NIL.key && r->key != NIL.key) { Node *nex = get_next(r); x->key = nex->key; delp12(nex); } else { delp12(x); } } Node *rightRotate(Node *t) { Node *s = t->left; t->left = s->right; s->right = t; return s; } Node *leftRotate(Node *t) { Node *s = t->right; t->right = s->left; s->left = t; return s; } Node *_insert(Node *t, int key, int priority) { if (t->key == NIL.key) { return new Node(key, priority); } if (key == t->key) { return t; } if (key < t->key) { t->left = _insert(t->left, key, priority); if (t->priority < t->left->priority) { t = rightRotate(t); } } else { t->right = _insert(t->right, key, priority); if (t->priority < t->right->priority) { t = leftRotate(t); } } return t; } Node *delete1(Node *t, int key); Node *_delete(Node *t, int key) { if (t->left->key == NIL.key && t->right->key == NIL.key) { return &NIL; } else if (t->left->key == NIL.key) { t = leftRotate(t); } else if (t->right->key == NIL.key) { t = rightRotate(t); } else { if (t->left->priority > t->right->priority) { t = rightRotate(t); } else t = leftRotate(t); } return delete1(t, key); } Node *delete1(Node *t, int key) { if (t->key == NIL.key) { return &NIL; } if (key < t->key) { t->left = delete1(t->left, key); } else if (key > t->key) { t->right = delete1(t->right, key); } else return _delete(t, key); return t; } int H; int left(int i) { return i * 2 + 1; } int right(int i) { return i * 2 + 2; } class edge { public: int from, to, i; ll val; edge() {} edge(ll to) : to(to) {} edge(ll to, ll i) : to(to), i(i) {} edge(ll from, ll to, ll val) : from(from), to(to), val(val) {} }; class LCA { private: vector<vector<edge>> v; vector<vector<int>> parent; vector<int> depth; void dfs(int n, int m, int d) { parent[0][n] = m; depth[n] = d; for (auto x : v[n]) { if (x.to != m) dfs(x.to, n, d + 1); } } public: LCA(ll N, ll root, vector<vector<edge>> &tree) { v = tree; parent = vector<vector<int>>(21, vector<int>(N + 1, 0)); depth = vector<int>(N + 1, 0); dfs(root, -1, 0); for (int j = 0; j + 1 < 20; j++) { for (int i = 1; i <= N; i++) { if (parent[j][i] < 0) parent[j + 1][i] = -1; else parent[j + 1][i] = parent[j][parent[j][i]]; } } } int lca(int n, int m) { if (depth[n] > depth[m]) swap(n, m); for (int j = 0; j < 20; j++) { if ((depth[m] - depth[n]) >> j & 1) m = parent[j][m]; } if (n == m) return n; for (int j = 19; j >= 0; j--) { if (parent[j][n] != parent[j][m]) { n = parent[j][n]; m = parent[j][m]; } } return parent[0][n]; } int dep(int n) { return depth[n]; } }; ll k; int _rank[1010]; int temp[1010]; bool compare_sa(int i, int j) { if (_rank[i] != _rank[j]) return _rank[i] < _rank[j]; else { int ri = i + k <= n ? _rank[i + k] : -1; int rj = j + k <= n ? _rank[j + k] : -1; return ri < rj; } } void construct_sa(string S, int *sa) { n = S.length(); for (size_t i = 0; i <= n; i++) { sa[i] = i; _rank[i] = i < n ? S[i] : -1; } for (k = 1; k <= n; k *= 2) { sort(sa, sa + n + 1, compare_sa); // saはソート後の接尾辞の並びになっている、rankは元の位置のindexを保持したまま、更新されている。 // ピンとこなかった部分 temp[sa[0]] = 0; for (size_t i = 1; i <= n; i++) { temp[sa[i]] = temp[sa[i - 1]] + (compare_sa(sa[i - 1], sa[i]) ? 1 : 0); } for (size_t i = 0; i <= n; i++) { _rank[i] = temp[i]; } } } bool contain(string S, int *sa, string T) { int a = 0, b = S.length(); // sa は 接尾辞が辞書順に並んでいる、入っているのはその位置のインデックス while (b - a > 1) { int c = (a + b) / 2; if (S.compare(sa[c], T.length(), T) < 0) a = c; else b = c; } return S.compare(sa[b], T.length(), T) == 0; } #define bit(x, v) ((ll)x << v) class BIT { static const int MAX_N = 500010; public: BIT() { memset(bit, 0, sizeof(bit)); } ll bit[MAX_N + 1], n; ll sum(int i) { ll s = 0; while (i > 0) { s += bit[i]; i -= i & -i; } return s; } void add(int i, int x) { while (i <= n) { bit[i] += x; i += i & -i; } } }; struct UnionFind { vector<int> A; UnionFind(int n) : A(n, -1) {} int find(int x) { if (A[x] < 0) return x; return A[x] = find(A[x]); } void unite(int x, int y) { x = find(x), y = find(y); if (x == y) return; if (A[x] > A[y]) swap(x, y); A[x] += A[y]; A[y] = x; } int ngroups() { int ans = 0; for (auto a : A) if (a < 0) ans++; return ans; } }; vector<ll> getp(ll n) { vector<ll> res; ll a = 2; if (n % 2 == 0) { res.push_back(2); while (n % 2 == 0) n /= 2; } for (ll i = 3; i * i <= n; i += 2) { if (n % i == 0) { res.push_back(i); while (n % i == 0) n /= i; } } if (n != 1) res.push_back(n); return res; } vector<ll> getp2(ll n) { vector<ll> res; ll a = 2; if (n % 2 == 0) { while (n % 2 == 0) { n /= 2; res.push_back(2); } } for (ll i = 3; i * i <= n; i += 2) { if (n % i == 0) { while (n % i == 0) { n /= i; res.push_back(i); } } } if (n != 1) res.push_back(n); return res; } vector<pll> getp3(ll n) { vector<pll> res; ll a = 2; int si = 0; if (n % 2 == 0) { res.push_back(make_pair(2, 0)); while (n % 2 == 0) { n /= 2; res[si].second++; } si++; } for (ll i = 3; i * i <= n; i += 2) { if (n % i == 0) { res.push_back(make_pair(i, 0)); while (n % i == 0) { n /= i; res[si].second++; } si++; } } if (n != 1) { res.push_back(make_pair(n, 1)); } return res; } vector<ll> getDivisors(ll n) { vector<ll> res; ll a = 2; res.push_back(1); for (ll i = 2; i * i <= n; i++) { if (n % i == 0) { res.push_back(i); if (n / i != i) res.push_back(n / i); } } return res; } struct ve { public: vector<ve> child; int _t = INF; ve(int t) : _t(t) {} ve(ve _left, ve _right) { _t = _left._t + _right._t; child.push_back(_left); child.push_back(_right); } bool operator<(const ve &t) const { return _t > t._t; } }; vector<bool> elas(ll n) { vector<bool> r(n); fill(r.begin(), r.end(), 1); r[0] = 0; r[1] = 0; for (ll i = 2; i * i < n; i++) { if (!r[i]) continue; ll ti = i * 2; while (ti < n) { r[ti] = false; ti += i; } } return r; } bool isPrime(ll v) { for (ll i = 2; i * i <= v; i++) { if (v % i == 0) return false; } return true; } class SegTree { public: const static int MAX_N = 100010; const static int DAT_SIZE = (1 << 18) - 1; int N, Q; int A[MAX_N]; ll data[DAT_SIZE], datb[DAT_SIZE]; void init(int _n) { N = 1; while (N < _n) N <<= 1; memset(data, 0, sizeof(data)); memset(datb, 0, sizeof(datb)); } void init(int _n, ll iv) { N = 1; while (N < _n) N <<= 1; rep(i, DAT_SIZE) { data[i] = iv; datb[i] = iv; } } void add(int a, int b, int x) { add(a, b + 1, x, 0, 0, N); } void add(int a, int b, int x, int k, int l, int r) { if (a <= l && r <= b) { data[k] += x; } else if (l < b && a < r) { datb[k] += (min(b, r) - max(a, l)) * x; add(a, b, x, k * 2 + 1, l, (l + r) / 2); add(a, b, x, k * 2 + 2, (l + r) / 2, r); } } void change(int a, int b, int x) { change(a, b + 1, x, 0, 0, N); } void change(int a, int b, int x, int k, int l, int r) { if (a <= l && r <= b) { data[k] = x; } else if (l < b && a < r) { datb[k] = x; change(a, b, x, k * 2 + 1, l, (l + r) / 2); change(a, b, x, k * 2 + 2, (l + r) / 2, r); } } ll sum(int a, int b) { return sum(a, b + 1, 0, 0, N); } ll sum(int a, int b, int k, int l, int r) { if (b <= l || r <= a) { return 0; } if (a <= l && r <= b) { return data[k] * (r - l) + datb[k]; } ll res = (min(b, r) - max(a, l)) * data[k]; res += sum(a, b, k * 2 + 1, l, (l + r) / 2); res += sum(a, b, k * 2 + 2, (l + r) / 2, r); return res; } }; class Segment; class Circle; class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x, y - p.y); } Point operator*(double a) { return Point(a * x, a * y); } Point operator/(double a) { return Point(x / a, y / a); } double abs() { return sqrt(norm()); } double norm() { return x * x + y * y; } bool operator<(const Point &p) const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const Point &p) const { return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS; } static double dot(Point a, Point b) { return a.x * b.x + a.y * b.y; } static double cross(Point a, Point b) { return a.x * b.y - a.y * b.x; } static bool isOrthogonal(Point a, Point b) { return EQ(dot(a, b), 0.0); } static bool isOrthogonal(Point a1, Point a2, Point b1, Point b2) { return isOrthogonal(a1 - a2, b1 - b2); } static bool isOrthogonal(Segment s1, Segment s2); static bool isPalallel(Point a, Point b) { return EQ(cross(a, b), 0.0); } static bool isPalallel(Point a1, Point a2, Point b1, Point b2) { return isPalallel(a1 - a2, b1 - b2); } static bool isPalallel(Segment s1, Segment s2); static const int COUNTER_CLOCKWISE = 1; static const int CLOCKWISE = -1; static const int ONLINE_BACK = 2; static const int ONLINE_FRONT = -2; static const int ON_SEGMENT = 0; static int ccw(Point p0, Point p1, Point p2) { // 線分はp0とp1でp2がどこにあるかを探る Point a = p1 - p0; Point b = p2 - p0; if (cross(a, b) > EPS) return COUNTER_CLOCKWISE; if (cross(a, b) < -EPS) return CLOCKWISE; if (dot(a, b) < -EPS) return ONLINE_BACK; if (a.norm() < b.norm()) return ONLINE_FRONT; return ON_SEGMENT; } static bool intersect(Point p1, Point p2, Point p3, Point p4) { return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 && ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0); } static bool intersect(Segment s1, Segment s2); static Point project(Segment s, Point p); static Point reflect(Segment s, Point p); static Point getDistance(Point a, Point b) { return (a - b).abs(); } static double getDistanceLP(Segment s, Point p); static double getDistanceSP(Segment s, Point p); static double getDistance(Segment s1, Segment s2); static Point getIntersection(Segment s1, Segment s2); static pair<Point, Point> crossPoints(Circle c, Segment s); static int contains(vector<Point> g, Point p) { int n = g.size(); bool x = false; rep(i, n) { Point a = g[i] - p, b = g[(i + 1) % n] - p; // 線の上に載っているか if (std::abs(cross(a, b)) < EPS && dot(a, b) < EPS) return 1; // pを基準として上下にあるか // または外積が正か?(→にあるか) if (a.y > b.y) swap(a, b); if (a.y < EPS && EPS < b.y && cross(a, b) > EPS) x = !x; } return x ? 2 : 0; } static vector<Point> andrewScan(vector<Point> s) { vector<Point> u, l; if (s.size() < 3) return s; sort(all(s)); u.push_back(s[0]); u.push_back(s[1]); l.push_back(s[s.size() - 1]); l.push_back(s[s.size() - 2]); for (int i = 2; i < s.size(); i++) { for (int _n = u.size(); _n >= 2 && ccw(u[_n - 2], u[_n - 1], s[i]) > CLOCKWISE; _n--) { u.pop_back(); } u.push_back(s[i]); } for (int i = s.size() - 3; i >= 0; i--) { for (int _n = l.size(); _n >= 2 && ccw(l[_n - 2], l[_n - 1], s[i]) > CLOCKWISE; _n--) { l.pop_back(); } l.push_back(s[i]); } reverse(all(l)); for (int i = u.size() - 2; i >= 1; i--) { l.push_back(u[i]); } return l; } void get_cin() { cin >> x >> y; } }; class Segment { public: Point p1, p2; Segment() {} Segment(Point p1, Point p2) : p1(p1), p2(p2) {} void get_cin() { cin >> p1.x >> p1.y >> p2.x >> p2.y; } Point p1tp2() { return p2 - p1; } Point p2tp1() { return p1 - p2; } double abs() { return std::abs(norm()); } double norm() { return (p2 - p1).norm(); } }; bool Point::isOrthogonal(Segment s1, Segment s2) { return EQ(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0); } bool Point::isPalallel(Segment s1, Segment s2) { return EQ(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0); } bool Point::intersect(Segment s1, Segment s2) { return intersect(s1.p1, s1.p2, s2.p1, s2.p2); } Point Point::project(Segment s, Point p) { Point base = s.p2 - s.p1; double r = Point::dot(p - s.p1, base) / base.norm(); return s.p1 + base * r; } Point Point::reflect(Segment s, Point p) { return (project(s, p) * 2) - p; } double Point::getDistanceLP(Segment s, Point p) { return std::abs(cross(s.p2 - s.p1, p - s.p1) / (s.p2 - s.p1).abs()); } double Point::getDistanceSP(Segment s, Point p) { if (dot(s.p2 - s.p1, p - s.p1) < 0.0) return (p - s.p1).abs(); if (dot(s.p1 - s.p2, p - s.p2) < 0.0) return (p - s.p2).abs(); return getDistanceLP(s, p); } double Point::getDistance(Segment s1, Segment s2) { if (intersect(s1, s2)) return 0.0; return min({getDistanceSP(s1, s2.p1), getDistanceSP(s1, s2.p2), getDistanceSP(s2, s1.p1), getDistanceSP(s2, s1.p2)}); } Point Point::getIntersection(Segment s1, Segment s2) { // (s1.p1 - s2.p1).norm() auto bs = s1.p2 - s1.p1; auto n1 = s2.p1 - s1.p1; auto n2 = s2.p2 - s1.p1; auto c1 = std::abs(cross(n1, bs)) / bs.norm(); auto c2 = std::abs(cross(n2, bs)) / bs.norm(); return s2.p1 + (s2.p2 - s2.p1) * (c1 / (c1 + c2)); // c1:c2=t:1-t // c2t=(1-t)c1 // t/(1-t)=c1/(c1+c2) // } double arg(Point p) { return atan2(p.y, p.x); } Point polar(double a, double r) { return Point(cos(r) * a, sin(r) * a); } class Circle { public: Point c; double r; Circle(Point c = Point(), double r = 0.0) : c(c), r(r) {} void get_cin() { cin >> c.x >> c.y >> r; } static pair<Point, Point> getCrossPoints(Circle c1, Circle c2) { double d = (c1.c - c2.c).abs(); // 中心点どうしの距離 double a = acos((c1.r * c1.r + d * d - c2.r * c2.r) / (2 * c1.r * d)); double t = arg(c2.c - c1.c); return make_pair(c1.c + polar(c1.r, t + a), c1.c + polar(c1.r, t - a)); } }; pair<Point, Point> Point::crossPoints(Circle c, Segment s) { auto pp = project(s, c.c); auto f = (pp - c.c).norm(); auto mu = sqrt(c.r * c.r - f); auto e = s.p1tp2() / s.p1tp2().abs(); return make_pair(pp + e * mu, pp - e * mu); } ll divRm(string s, ll x) { ll r = 0; for (ll i = 0; i < s.size(); i++) { r *= 10; r += s[i] - '0'; r %= x; } return r; } ll cmbi(ll x, ll b) { ll res = 1; for (size_t i = 0; i < b; i++) { res *= x - i; res %= INF; res *= inv[b - i]; res %= INF; } return res; } double digsum(ll x) { ll res = 0; while (x > 0) { res += x % 10; x /= 10; } return res; } bool check_parindrome(string s) { int n = s.size(); rep(i, n / 2) { if (s[i] != s[n - i - 1]) { return false; } } return true; } // ここまでライブラリ // ここからコード struct mm { double h = -big, l = big; }; double x[100010], y[100010]; char d[100010]; mm m[4]; mm fm[2]; void sech(mm &v, double a) { v.h = max(v.h, a); v.l = min(v.l, a); } void setu(vector<double> &v, int p, char c) { ll f = p / 2; if (f == 1) { swap(x, y); } rep(i, n) { if (d[i] != c) continue; if (m[p].l < big) { v.push_back(abs(x[i] - m[p].l)); v.push_back(abs(x[i] - m[p].l) / 2); v.push_back(abs(x[i] - m[p].h)); v.push_back(abs(x[i] - m[p].h) / 2); } if (fm[f].l < big) { v.push_back(abs(x[i] - fm[f].l)); v.push_back(abs(x[i] - fm[f].l) / 2); v.push_back(abs(x[i] - fm[f].h)); v.push_back(abs(x[i] - fm[f].h) / 2); } } if (f == 1) { swap(x, y); } } double clx(double x) { return max({m[0].h + x, m[1].h - x, fm[0].h}) - min({m[0].l + x, m[1].l - x, fm[0].l}); } double cly(double x) { return max({m[2].h + x, m[3].h - x, fm[1].h}) - min({m[2].l + x, m[3].l - x, fm[1].l}); } double clc(double x) { return clx(x) * cly(x); } void solv() { cin >> n; rep(i, n) { cin >> x[i] >> y[i] >> d[i]; switch (d[i]) { case 'R': sech(m[0], x[i]); sech(fm[1], y[i]); break; case 'L': sech(m[1], x[i]); sech(fm[1], y[i]); break; case 'U': sech(m[2], y[i]); sech(fm[0], x[i]); break; case 'D': sech(m[3], y[i]); sech(fm[0], x[i]); break; } } vector<double> v; setu(v, 0, 'L'); setu(v, 1, 'R'); setu(v, 2, 'D'); setu(v, 3, 'U'); double res = clc(0); rep(i, v.size()) { res = min(res, clc(v[i])); } put_float(res); } int main() { COMinit(); solv(); return 0; }
[ "literal.number.change", "control_flow.branch.if.condition.change", "literal.string.change", "call.arguments.change" ]
832,982
832,981
u224756887
cpp
p03004
#include <algorithm> #include <array> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctype.h> #include <deque> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string.h> #include <unordered_map> #include <utility> #include <vector> #define _USE_MATH_DEFINES #include <iostream> #include <math.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<ll, double> pld; typedef pair<double, double> pdd; typedef pair<double, ll> pdl; typedef pair<int, char> pic; typedef vector<ll> vl; typedef vector<int> vi; typedef priority_queue<ll, vector<ll>, greater<ll>> llgreaterq; typedef priority_queue<pll, vector<pll>, greater<pll>> pllgreaterq; typedef priority_queue<pair<ll, pll>, vector<pair<ll, pll>>, greater<pair<ll, pll>>> plpllgreaterq; typedef priority_queue<vi, vector<vi>, greater<vi>> vigreaterq; typedef priority_queue<vl, vector<vl>, greater<vl>> vlgreaterq; template <class o, class p, class q> using tuple3q = priority_queue<tuple<o, p, q>, vector<tuple<o, p, q>>, greater<tuple<o, p, q>>>; template <class o, class p, class q, class r> using tuple4q = priority_queue<tuple<o, p, q, r>, vector<tuple<o, p, q, r>>, greater<tuple<o, p, q, r>>>; int dx[] = {-1, 0, 1, 0}; int dy[] = {0, -1, 0, 1}; #define bit(x, v) ((ll)x << v) #define rep(x, n) for (ll x = 0; x < n; x++) #define rep2(x, f, v) for (ll x = f; x < v; x++) #define repe(v, x) for (auto v : x) // 許容する誤差ε #define EPS (1e-10) // 2つのスカラーが等しいかどうか #define EQ(a, b) (std::abs(a - b) < EPS) // 2つのベクトルが等しいかどうか #define EQV(a, b) (EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag())) #define all(a) a.begin(), a.end() #define all0(a) memset(a, 0, sizeof(a)) #define allm1(a) memset(a, -1, sizeof(a)) #define put_float(v) \ cout << fixed << setprecision(10); \ cout << v << endl #define put(v) cout << v << endl #define vinsert(v, p, x) v.insert(v.begin() + p, x) #define vsort(v) sort(all(v)); #define dup(v) v.erase(unique(all(v)), v.end()) #define ion(i, j) ((i & (1LL << j)) > 0) #define next(i) \ i++; \ i %= 2 #define Len size() #define ull unsignd long long #define psp(a, b) push_back(make_pair(a, b)) #define psp2(a, b) push(make_pair(a, b)) #define cini(a) \ a; \ cin >> a #define infa(a, b) (a + b) % INF #define infm(a, b) (a * b) % INF #define infd(a, b) (a * modinv(b)) % INF #define infs(a, b) (a + INF - b) % INF #define inf(a) (a) %= INF #define inff(a) ((a) % INF) #define No cout << "No" << endl #define Yes cout << "Yes" << endl #define NO cout << "NO" << endl #define YES cout << "YES" << endl #define smal -INF *INF #define big INF *INF const ll INF = 1000000007; const int MAX = 2000010; const int MOD = 1000000007; long long fac[MAX], finv[MAX], inv[MAX]; void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 long long COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } ll getpow(ll b, ll x, ll md) { ll t = b; ll res = 1; while (x > 0) { if (x & 1) { res *= t; res %= md; } x >>= 1; t *= t; t %= md; } return res; } ll getpow(ll b, ll x) { return getpow(b, x, INF); } ll modinv(ll x) { return getpow(x, INF - 2); } ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } class mint { int md = 1000000007; public: long long x; mint(ll x, ll md) { this->md = md; this->x = (x % md + md) % md; } mint(long long x = 0) : x((x % md + md) % md) {} mint operator-() const { return mint(-x); } mint &operator+=(const mint &a) { if ((x += a.x) >= md) x -= md; return *this; } mint &operator-=(const mint &a) { if ((x += md - a.x) >= md) x -= md; return *this; } mint &operator*=(const mint &a) { (x *= a.x) %= md; return *this; } mint operator+(const mint &a) const { mint res(*this); return res += a; } mint operator-(const mint &a) const { mint res(*this); return res -= a; } mint operator*(const mint &a) const { mint res(*this); return res *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(md - 2); } mint &operator/=(const mint &a) { return (*this) *= a.inv(); } mint operator/(const mint &a) const { mint res(*this); return res /= a; } friend ostream &operator<<(ostream &os, const mint &m) { os << m.x; return os; } }; int pr[100010]; int lank[100010]; void uini(int n) { for (size_t i = 0; i <= n; i++) { pr[i] = i; lank[i] = 1; } } int parent(int x) { if (x == pr[x]) return x; return pr[x] = parent(pr[x]); } int same(int x, int y) { return parent(x) == parent(y); } bool unit(int x, int y) { int px = parent(x); int py = parent(y); if (px == py) return false; if (lank[py] < lank[px]) { pr[py] = px; lank[px] += lank[py]; } else { pr[px] = py; lank[py] += lank[px]; } return true; } ll n; int ci = 0; struct Node { int key; int priority; Node *parent, *left, *right; Node(int key, int priority); Node() {} }; Node NIL; Node::Node(int key, int priority) : key(key), priority(priority) { left = &NIL; right = &NIL; } Node *root = new Node(); void cenrec(Node *k) { if (k->key == NIL.key) return; cenrec(k->left); cout << " " << k->key; cenrec(k->right); } void fastrec(Node *k) { if (k->key == NIL.key) return; cout << " " << k->key; fastrec(k->left); fastrec(k->right); } void insert(Node *v) { Node *y = &NIL; Node *x = root; while (x->key != NIL.key) { y = x; if (v->key < x->key) { x = x->left; } else { x = x->right; } } v->parent = y; if (y->key == NIL.key) { root = v; } else if (v->key < y->key) { y->left = v; } else { y->right = v; } } Node *find(Node *k, ll v) { if (k->key == NIL.key) return &NIL; if (k->key == v) return k; if (v < k->key) return find(k->left, v); return find(k->right, v); } void delp12(Node *x) { if (x->key == NIL.key) return; Node *l = x->left; Node *r = x->right; Node *pr = x->parent; if (l->key == NIL.key && r->key == NIL.key) { if (pr->left == x) { pr->left = &NIL; } else pr->right = &NIL; } else if (l->key != NIL.key) { if (pr->left == x) { pr->left = l; } else pr->right = l; l->parent = pr; } else if (r->key != NIL.key) { if (pr->left == x) { pr->left = r; } else pr->right = r; r->parent = pr; } } Node *get_next(Node *k) { if (k->key == NIL.key) return &NIL; Node *res = get_next(k->left); if (res->key != NIL.key) return res; return k; } void del(Node *x) { if (x->key == NIL.key) return; Node *l = x->left; Node *r = x->right; Node *pr = x->parent; if (l->key != NIL.key && r->key != NIL.key) { Node *nex = get_next(r); x->key = nex->key; delp12(nex); } else { delp12(x); } } Node *rightRotate(Node *t) { Node *s = t->left; t->left = s->right; s->right = t; return s; } Node *leftRotate(Node *t) { Node *s = t->right; t->right = s->left; s->left = t; return s; } Node *_insert(Node *t, int key, int priority) { if (t->key == NIL.key) { return new Node(key, priority); } if (key == t->key) { return t; } if (key < t->key) { t->left = _insert(t->left, key, priority); if (t->priority < t->left->priority) { t = rightRotate(t); } } else { t->right = _insert(t->right, key, priority); if (t->priority < t->right->priority) { t = leftRotate(t); } } return t; } Node *delete1(Node *t, int key); Node *_delete(Node *t, int key) { if (t->left->key == NIL.key && t->right->key == NIL.key) { return &NIL; } else if (t->left->key == NIL.key) { t = leftRotate(t); } else if (t->right->key == NIL.key) { t = rightRotate(t); } else { if (t->left->priority > t->right->priority) { t = rightRotate(t); } else t = leftRotate(t); } return delete1(t, key); } Node *delete1(Node *t, int key) { if (t->key == NIL.key) { return &NIL; } if (key < t->key) { t->left = delete1(t->left, key); } else if (key > t->key) { t->right = delete1(t->right, key); } else return _delete(t, key); return t; } int H; int left(int i) { return i * 2 + 1; } int right(int i) { return i * 2 + 2; } class edge { public: int from, to, i; ll val; edge() {} edge(ll to) : to(to) {} edge(ll to, ll i) : to(to), i(i) {} edge(ll from, ll to, ll val) : from(from), to(to), val(val) {} }; class LCA { private: vector<vector<edge>> v; vector<vector<int>> parent; vector<int> depth; void dfs(int n, int m, int d) { parent[0][n] = m; depth[n] = d; for (auto x : v[n]) { if (x.to != m) dfs(x.to, n, d + 1); } } public: LCA(ll N, ll root, vector<vector<edge>> &tree) { v = tree; parent = vector<vector<int>>(21, vector<int>(N + 1, 0)); depth = vector<int>(N + 1, 0); dfs(root, -1, 0); for (int j = 0; j + 1 < 20; j++) { for (int i = 1; i <= N; i++) { if (parent[j][i] < 0) parent[j + 1][i] = -1; else parent[j + 1][i] = parent[j][parent[j][i]]; } } } int lca(int n, int m) { if (depth[n] > depth[m]) swap(n, m); for (int j = 0; j < 20; j++) { if ((depth[m] - depth[n]) >> j & 1) m = parent[j][m]; } if (n == m) return n; for (int j = 19; j >= 0; j--) { if (parent[j][n] != parent[j][m]) { n = parent[j][n]; m = parent[j][m]; } } return parent[0][n]; } int dep(int n) { return depth[n]; } }; ll k; int _rank[1010]; int temp[1010]; bool compare_sa(int i, int j) { if (_rank[i] != _rank[j]) return _rank[i] < _rank[j]; else { int ri = i + k <= n ? _rank[i + k] : -1; int rj = j + k <= n ? _rank[j + k] : -1; return ri < rj; } } void construct_sa(string S, int *sa) { n = S.length(); for (size_t i = 0; i <= n; i++) { sa[i] = i; _rank[i] = i < n ? S[i] : -1; } for (k = 1; k <= n; k *= 2) { sort(sa, sa + n + 1, compare_sa); // saはソート後の接尾辞の並びになっている、rankは元の位置のindexを保持したまま、更新されている。 // ピンとこなかった部分 temp[sa[0]] = 0; for (size_t i = 1; i <= n; i++) { temp[sa[i]] = temp[sa[i - 1]] + (compare_sa(sa[i - 1], sa[i]) ? 1 : 0); } for (size_t i = 0; i <= n; i++) { _rank[i] = temp[i]; } } } bool contain(string S, int *sa, string T) { int a = 0, b = S.length(); // sa は 接尾辞が辞書順に並んでいる、入っているのはその位置のインデックス while (b - a > 1) { int c = (a + b) / 2; if (S.compare(sa[c], T.length(), T) < 0) a = c; else b = c; } return S.compare(sa[b], T.length(), T) == 0; } #define bit(x, v) ((ll)x << v) class BIT { static const int MAX_N = 500010; public: BIT() { memset(bit, 0, sizeof(bit)); } ll bit[MAX_N + 1], n; ll sum(int i) { ll s = 0; while (i > 0) { s += bit[i]; i -= i & -i; } return s; } void add(int i, int x) { while (i <= n) { bit[i] += x; i += i & -i; } } }; struct UnionFind { vector<int> A; UnionFind(int n) : A(n, -1) {} int find(int x) { if (A[x] < 0) return x; return A[x] = find(A[x]); } void unite(int x, int y) { x = find(x), y = find(y); if (x == y) return; if (A[x] > A[y]) swap(x, y); A[x] += A[y]; A[y] = x; } int ngroups() { int ans = 0; for (auto a : A) if (a < 0) ans++; return ans; } }; vector<ll> getp(ll n) { vector<ll> res; ll a = 2; if (n % 2 == 0) { res.push_back(2); while (n % 2 == 0) n /= 2; } for (ll i = 3; i * i <= n; i += 2) { if (n % i == 0) { res.push_back(i); while (n % i == 0) n /= i; } } if (n != 1) res.push_back(n); return res; } vector<ll> getp2(ll n) { vector<ll> res; ll a = 2; if (n % 2 == 0) { while (n % 2 == 0) { n /= 2; res.push_back(2); } } for (ll i = 3; i * i <= n; i += 2) { if (n % i == 0) { while (n % i == 0) { n /= i; res.push_back(i); } } } if (n != 1) res.push_back(n); return res; } vector<pll> getp3(ll n) { vector<pll> res; ll a = 2; int si = 0; if (n % 2 == 0) { res.push_back(make_pair(2, 0)); while (n % 2 == 0) { n /= 2; res[si].second++; } si++; } for (ll i = 3; i * i <= n; i += 2) { if (n % i == 0) { res.push_back(make_pair(i, 0)); while (n % i == 0) { n /= i; res[si].second++; } si++; } } if (n != 1) { res.push_back(make_pair(n, 1)); } return res; } vector<ll> getDivisors(ll n) { vector<ll> res; ll a = 2; res.push_back(1); for (ll i = 2; i * i <= n; i++) { if (n % i == 0) { res.push_back(i); if (n / i != i) res.push_back(n / i); } } return res; } struct ve { public: vector<ve> child; int _t = INF; ve(int t) : _t(t) {} ve(ve _left, ve _right) { _t = _left._t + _right._t; child.push_back(_left); child.push_back(_right); } bool operator<(const ve &t) const { return _t > t._t; } }; vector<bool> elas(ll n) { vector<bool> r(n); fill(r.begin(), r.end(), 1); r[0] = 0; r[1] = 0; for (ll i = 2; i * i < n; i++) { if (!r[i]) continue; ll ti = i * 2; while (ti < n) { r[ti] = false; ti += i; } } return r; } bool isPrime(ll v) { for (ll i = 2; i * i <= v; i++) { if (v % i == 0) return false; } return true; } class SegTree { public: const static int MAX_N = 100010; const static int DAT_SIZE = (1 << 18) - 1; int N, Q; int A[MAX_N]; ll data[DAT_SIZE], datb[DAT_SIZE]; void init(int _n) { N = 1; while (N < _n) N <<= 1; memset(data, 0, sizeof(data)); memset(datb, 0, sizeof(datb)); } void init(int _n, ll iv) { N = 1; while (N < _n) N <<= 1; rep(i, DAT_SIZE) { data[i] = iv; datb[i] = iv; } } void add(int a, int b, int x) { add(a, b + 1, x, 0, 0, N); } void add(int a, int b, int x, int k, int l, int r) { if (a <= l && r <= b) { data[k] += x; } else if (l < b && a < r) { datb[k] += (min(b, r) - max(a, l)) * x; add(a, b, x, k * 2 + 1, l, (l + r) / 2); add(a, b, x, k * 2 + 2, (l + r) / 2, r); } } void change(int a, int b, int x) { change(a, b + 1, x, 0, 0, N); } void change(int a, int b, int x, int k, int l, int r) { if (a <= l && r <= b) { data[k] = x; } else if (l < b && a < r) { datb[k] = x; change(a, b, x, k * 2 + 1, l, (l + r) / 2); change(a, b, x, k * 2 + 2, (l + r) / 2, r); } } ll sum(int a, int b) { return sum(a, b + 1, 0, 0, N); } ll sum(int a, int b, int k, int l, int r) { if (b <= l || r <= a) { return 0; } if (a <= l && r <= b) { return data[k] * (r - l) + datb[k]; } ll res = (min(b, r) - max(a, l)) * data[k]; res += sum(a, b, k * 2 + 1, l, (l + r) / 2); res += sum(a, b, k * 2 + 2, (l + r) / 2, r); return res; } }; class Segment; class Circle; class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x, y - p.y); } Point operator*(double a) { return Point(a * x, a * y); } Point operator/(double a) { return Point(x / a, y / a); } double abs() { return sqrt(norm()); } double norm() { return x * x + y * y; } bool operator<(const Point &p) const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const Point &p) const { return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS; } static double dot(Point a, Point b) { return a.x * b.x + a.y * b.y; } static double cross(Point a, Point b) { return a.x * b.y - a.y * b.x; } static bool isOrthogonal(Point a, Point b) { return EQ(dot(a, b), 0.0); } static bool isOrthogonal(Point a1, Point a2, Point b1, Point b2) { return isOrthogonal(a1 - a2, b1 - b2); } static bool isOrthogonal(Segment s1, Segment s2); static bool isPalallel(Point a, Point b) { return EQ(cross(a, b), 0.0); } static bool isPalallel(Point a1, Point a2, Point b1, Point b2) { return isPalallel(a1 - a2, b1 - b2); } static bool isPalallel(Segment s1, Segment s2); static const int COUNTER_CLOCKWISE = 1; static const int CLOCKWISE = -1; static const int ONLINE_BACK = 2; static const int ONLINE_FRONT = -2; static const int ON_SEGMENT = 0; static int ccw(Point p0, Point p1, Point p2) { // 線分はp0とp1でp2がどこにあるかを探る Point a = p1 - p0; Point b = p2 - p0; if (cross(a, b) > EPS) return COUNTER_CLOCKWISE; if (cross(a, b) < -EPS) return CLOCKWISE; if (dot(a, b) < -EPS) return ONLINE_BACK; if (a.norm() < b.norm()) return ONLINE_FRONT; return ON_SEGMENT; } static bool intersect(Point p1, Point p2, Point p3, Point p4) { return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 && ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0); } static bool intersect(Segment s1, Segment s2); static Point project(Segment s, Point p); static Point reflect(Segment s, Point p); static Point getDistance(Point a, Point b) { return (a - b).abs(); } static double getDistanceLP(Segment s, Point p); static double getDistanceSP(Segment s, Point p); static double getDistance(Segment s1, Segment s2); static Point getIntersection(Segment s1, Segment s2); static pair<Point, Point> crossPoints(Circle c, Segment s); static int contains(vector<Point> g, Point p) { int n = g.size(); bool x = false; rep(i, n) { Point a = g[i] - p, b = g[(i + 1) % n] - p; // 線の上に載っているか if (std::abs(cross(a, b)) < EPS && dot(a, b) < EPS) return 1; // pを基準として上下にあるか // または外積が正か?(→にあるか) if (a.y > b.y) swap(a, b); if (a.y < EPS && EPS < b.y && cross(a, b) > EPS) x = !x; } return x ? 2 : 0; } static vector<Point> andrewScan(vector<Point> s) { vector<Point> u, l; if (s.size() < 3) return s; sort(all(s)); u.push_back(s[0]); u.push_back(s[1]); l.push_back(s[s.size() - 1]); l.push_back(s[s.size() - 2]); for (int i = 2; i < s.size(); i++) { for (int _n = u.size(); _n >= 2 && ccw(u[_n - 2], u[_n - 1], s[i]) > CLOCKWISE; _n--) { u.pop_back(); } u.push_back(s[i]); } for (int i = s.size() - 3; i >= 0; i--) { for (int _n = l.size(); _n >= 2 && ccw(l[_n - 2], l[_n - 1], s[i]) > CLOCKWISE; _n--) { l.pop_back(); } l.push_back(s[i]); } reverse(all(l)); for (int i = u.size() - 2; i >= 1; i--) { l.push_back(u[i]); } return l; } void get_cin() { cin >> x >> y; } }; class Segment { public: Point p1, p2; Segment() {} Segment(Point p1, Point p2) : p1(p1), p2(p2) {} void get_cin() { cin >> p1.x >> p1.y >> p2.x >> p2.y; } Point p1tp2() { return p2 - p1; } Point p2tp1() { return p1 - p2; } double abs() { return std::abs(norm()); } double norm() { return (p2 - p1).norm(); } }; bool Point::isOrthogonal(Segment s1, Segment s2) { return EQ(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0); } bool Point::isPalallel(Segment s1, Segment s2) { return EQ(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0); } bool Point::intersect(Segment s1, Segment s2) { return intersect(s1.p1, s1.p2, s2.p1, s2.p2); } Point Point::project(Segment s, Point p) { Point base = s.p2 - s.p1; double r = Point::dot(p - s.p1, base) / base.norm(); return s.p1 + base * r; } Point Point::reflect(Segment s, Point p) { return (project(s, p) * 2) - p; } double Point::getDistanceLP(Segment s, Point p) { return std::abs(cross(s.p2 - s.p1, p - s.p1) / (s.p2 - s.p1).abs()); } double Point::getDistanceSP(Segment s, Point p) { if (dot(s.p2 - s.p1, p - s.p1) < 0.0) return (p - s.p1).abs(); if (dot(s.p1 - s.p2, p - s.p2) < 0.0) return (p - s.p2).abs(); return getDistanceLP(s, p); } double Point::getDistance(Segment s1, Segment s2) { if (intersect(s1, s2)) return 0.0; return min({getDistanceSP(s1, s2.p1), getDistanceSP(s1, s2.p2), getDistanceSP(s2, s1.p1), getDistanceSP(s2, s1.p2)}); } Point Point::getIntersection(Segment s1, Segment s2) { // (s1.p1 - s2.p1).norm() auto bs = s1.p2 - s1.p1; auto n1 = s2.p1 - s1.p1; auto n2 = s2.p2 - s1.p1; auto c1 = std::abs(cross(n1, bs)) / bs.norm(); auto c2 = std::abs(cross(n2, bs)) / bs.norm(); return s2.p1 + (s2.p2 - s2.p1) * (c1 / (c1 + c2)); // c1:c2=t:1-t // c2t=(1-t)c1 // t/(1-t)=c1/(c1+c2) // } double arg(Point p) { return atan2(p.y, p.x); } Point polar(double a, double r) { return Point(cos(r) * a, sin(r) * a); } class Circle { public: Point c; double r; Circle(Point c = Point(), double r = 0.0) : c(c), r(r) {} void get_cin() { cin >> c.x >> c.y >> r; } static pair<Point, Point> getCrossPoints(Circle c1, Circle c2) { double d = (c1.c - c2.c).abs(); // 中心点どうしの距離 double a = acos((c1.r * c1.r + d * d - c2.r * c2.r) / (2 * c1.r * d)); double t = arg(c2.c - c1.c); return make_pair(c1.c + polar(c1.r, t + a), c1.c + polar(c1.r, t - a)); } }; pair<Point, Point> Point::crossPoints(Circle c, Segment s) { auto pp = project(s, c.c); auto f = (pp - c.c).norm(); auto mu = sqrt(c.r * c.r - f); auto e = s.p1tp2() / s.p1tp2().abs(); return make_pair(pp + e * mu, pp - e * mu); } ll divRm(string s, ll x) { ll r = 0; for (ll i = 0; i < s.size(); i++) { r *= 10; r += s[i] - '0'; r %= x; } return r; } ll cmbi(ll x, ll b) { ll res = 1; for (size_t i = 0; i < b; i++) { res *= x - i; res %= INF; res *= inv[b - i]; res %= INF; } return res; } double digsum(ll x) { ll res = 0; while (x > 0) { res += x % 10; x /= 10; } return res; } bool check_parindrome(string s) { int n = s.size(); rep(i, n / 2) { if (s[i] != s[n - i - 1]) { return false; } } return true; } // ここまでライブラリ // ここからコード struct ds { double l, h; }; ds xm[4]; ds ym[4]; double x[100010], y[100010]; char d[100010]; void chmax(double &a, double &b) { if (a < b) a = b; } void chmin(double &a, double &b) { if (a > b) a = b; } void setxm(ll p, ll i) { chmax(xm[p].h, x[i]); chmin(xm[p].l, x[i]); chmax(ym[p + 2].h, y[i]); chmin(ym[p + 2].l, y[i]); } void setym(ll p, ll i) { chmax(xm[p].h, x[i]); chmin(xm[p].l, x[i]); chmax(ym[p - 2].h, y[i]); chmin(ym[p - 2].l, y[i]); } double xv(double v) { return max({xm[2].h, xm[3].h, xm[0].h + v, xm[1].h - v}) - min({xm[2].l, xm[3].l, xm[0].l + v, xm[1].l - v}); } double yv(double v) { return max({ym[2].h, ym[3].h, ym[0].h + v, ym[1].h - v}) - min({ym[2].l, ym[3].l, ym[0].l + v, ym[1].l - v}); } void setup(vector<double> &v, ll p, char c) { // pとcをぶつける // その際bとb+1の固定値もぶつける ll b = p - p % 2; // xに寄せて処理をする if (p >= 2) { swap(x, y); swap(xm, ym); } rep(i, n) { if (d[i] != c) { continue; } if (xm[p].l != big) { v.push_back(abs(xm[p].l - x[i])); v.push_back(abs(xm[p].l - x[i]) / 2); v.push_back(abs(xm[p].h - x[i])); v.push_back(abs(xm[p].h - x[i]) / 2); } if (xm[b].l != big) { v.push_back(abs(xm[b].l - x[i])); v.push_back(abs(xm[b].l - x[i]) / 2); v.push_back(abs(xm[b].h - x[i])); v.push_back(abs(xm[b].h - x[i]) / 2); } if (xm[b + 1].l != big) { v.push_back(abs(xm[b + 1].l - x[i])); v.push_back(abs(xm[b + 1].l - x[i]) / 2); v.push_back(abs(xm[b + 1].h - x[i])); v.push_back(abs(xm[b + 1].h - x[i]) / 2); } } if (p >= 2) { swap(x, y); swap(xm, ym); } } void solv() { cin >> n; rep(i, 4) { xm[i].h = -big; xm[i].l = big; ym[i].h = -big; ym[i].l = big; } rep(i, n) { cin >> x[i] >> y[i] >> d[i]; if (d[i] == 'R') { setxm(0, i); } if (d[i] == 'L') { setxm(1, i); } if (d[i] == 'U') { setym(2, i); } if (d[i] == 'D') { setym(3, i); } } vector<double> v; setup(v, 0, 'L'); setup(v, 1, 'R'); setup(v, 2, 'D'); setup(v, 3, 'U'); vsort(v); dup(v); double res = xv(0) * yv(0); rep(i, v.size()) { res = min(res, xv(v[i]) * yv(v[i])); } put_float(res); } int main() { COMinit(); solv(); return 0; }
#include <algorithm> #include <array> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctype.h> #include <deque> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string.h> #include <unordered_map> #include <utility> #include <vector> #define _USE_MATH_DEFINES #include <iostream> #include <math.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<ll, double> pld; typedef pair<double, double> pdd; typedef pair<double, ll> pdl; typedef pair<int, char> pic; typedef vector<ll> vl; typedef vector<int> vi; typedef priority_queue<ll, vector<ll>, greater<ll>> llgreaterq; typedef priority_queue<pll, vector<pll>, greater<pll>> pllgreaterq; typedef priority_queue<pair<ll, pll>, vector<pair<ll, pll>>, greater<pair<ll, pll>>> plpllgreaterq; typedef priority_queue<vi, vector<vi>, greater<vi>> vigreaterq; typedef priority_queue<vl, vector<vl>, greater<vl>> vlgreaterq; template <class o, class p, class q> using tuple3q = priority_queue<tuple<o, p, q>, vector<tuple<o, p, q>>, greater<tuple<o, p, q>>>; template <class o, class p, class q, class r> using tuple4q = priority_queue<tuple<o, p, q, r>, vector<tuple<o, p, q, r>>, greater<tuple<o, p, q, r>>>; int dx[] = {-1, 0, 1, 0}; int dy[] = {0, -1, 0, 1}; #define bit(x, v) ((ll)x << v) #define rep(x, n) for (ll x = 0; x < n; x++) #define rep2(x, f, v) for (ll x = f; x < v; x++) #define repe(v, x) for (auto v : x) // 許容する誤差ε #define EPS (1e-10) // 2つのスカラーが等しいかどうか #define EQ(a, b) (std::abs(a - b) < EPS) // 2つのベクトルが等しいかどうか #define EQV(a, b) (EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag())) #define all(a) a.begin(), a.end() #define all0(a) memset(a, 0, sizeof(a)) #define allm1(a) memset(a, -1, sizeof(a)) #define put_float(v) \ cout << fixed << setprecision(10); \ cout << v << endl #define put(v) cout << v << endl #define vinsert(v, p, x) v.insert(v.begin() + p, x) #define vsort(v) sort(all(v)); #define dup(v) v.erase(unique(all(v)), v.end()) #define ion(i, j) ((i & (1LL << j)) > 0) #define next(i) \ i++; \ i %= 2 #define Len size() #define ull unsignd long long #define psp(a, b) push_back(make_pair(a, b)) #define psp2(a, b) push(make_pair(a, b)) #define cini(a) \ a; \ cin >> a #define infa(a, b) (a + b) % INF #define infm(a, b) (a * b) % INF #define infd(a, b) (a * modinv(b)) % INF #define infs(a, b) (a + INF - b) % INF #define inf(a) (a) %= INF #define inff(a) ((a) % INF) #define No cout << "No" << endl #define Yes cout << "Yes" << endl #define NO cout << "NO" << endl #define YES cout << "YES" << endl #define smal -INF *INF #define big INF *INF const ll INF = 1000000007; const int MAX = 2000010; const int MOD = 1000000007; long long fac[MAX], finv[MAX], inv[MAX]; void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 long long COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } ll getpow(ll b, ll x, ll md) { ll t = b; ll res = 1; while (x > 0) { if (x & 1) { res *= t; res %= md; } x >>= 1; t *= t; t %= md; } return res; } ll getpow(ll b, ll x) { return getpow(b, x, INF); } ll modinv(ll x) { return getpow(x, INF - 2); } ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } class mint { int md = 1000000007; public: long long x; mint(ll x, ll md) { this->md = md; this->x = (x % md + md) % md; } mint(long long x = 0) : x((x % md + md) % md) {} mint operator-() const { return mint(-x); } mint &operator+=(const mint &a) { if ((x += a.x) >= md) x -= md; return *this; } mint &operator-=(const mint &a) { if ((x += md - a.x) >= md) x -= md; return *this; } mint &operator*=(const mint &a) { (x *= a.x) %= md; return *this; } mint operator+(const mint &a) const { mint res(*this); return res += a; } mint operator-(const mint &a) const { mint res(*this); return res -= a; } mint operator*(const mint &a) const { mint res(*this); return res *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(md - 2); } mint &operator/=(const mint &a) { return (*this) *= a.inv(); } mint operator/(const mint &a) const { mint res(*this); return res /= a; } friend ostream &operator<<(ostream &os, const mint &m) { os << m.x; return os; } }; int pr[100010]; int lank[100010]; void uini(int n) { for (size_t i = 0; i <= n; i++) { pr[i] = i; lank[i] = 1; } } int parent(int x) { if (x == pr[x]) return x; return pr[x] = parent(pr[x]); } int same(int x, int y) { return parent(x) == parent(y); } bool unit(int x, int y) { int px = parent(x); int py = parent(y); if (px == py) return false; if (lank[py] < lank[px]) { pr[py] = px; lank[px] += lank[py]; } else { pr[px] = py; lank[py] += lank[px]; } return true; } ll n; int ci = 0; struct Node { int key; int priority; Node *parent, *left, *right; Node(int key, int priority); Node() {} }; Node NIL; Node::Node(int key, int priority) : key(key), priority(priority) { left = &NIL; right = &NIL; } Node *root = new Node(); void cenrec(Node *k) { if (k->key == NIL.key) return; cenrec(k->left); cout << " " << k->key; cenrec(k->right); } void fastrec(Node *k) { if (k->key == NIL.key) return; cout << " " << k->key; fastrec(k->left); fastrec(k->right); } void insert(Node *v) { Node *y = &NIL; Node *x = root; while (x->key != NIL.key) { y = x; if (v->key < x->key) { x = x->left; } else { x = x->right; } } v->parent = y; if (y->key == NIL.key) { root = v; } else if (v->key < y->key) { y->left = v; } else { y->right = v; } } Node *find(Node *k, ll v) { if (k->key == NIL.key) return &NIL; if (k->key == v) return k; if (v < k->key) return find(k->left, v); return find(k->right, v); } void delp12(Node *x) { if (x->key == NIL.key) return; Node *l = x->left; Node *r = x->right; Node *pr = x->parent; if (l->key == NIL.key && r->key == NIL.key) { if (pr->left == x) { pr->left = &NIL; } else pr->right = &NIL; } else if (l->key != NIL.key) { if (pr->left == x) { pr->left = l; } else pr->right = l; l->parent = pr; } else if (r->key != NIL.key) { if (pr->left == x) { pr->left = r; } else pr->right = r; r->parent = pr; } } Node *get_next(Node *k) { if (k->key == NIL.key) return &NIL; Node *res = get_next(k->left); if (res->key != NIL.key) return res; return k; } void del(Node *x) { if (x->key == NIL.key) return; Node *l = x->left; Node *r = x->right; Node *pr = x->parent; if (l->key != NIL.key && r->key != NIL.key) { Node *nex = get_next(r); x->key = nex->key; delp12(nex); } else { delp12(x); } } Node *rightRotate(Node *t) { Node *s = t->left; t->left = s->right; s->right = t; return s; } Node *leftRotate(Node *t) { Node *s = t->right; t->right = s->left; s->left = t; return s; } Node *_insert(Node *t, int key, int priority) { if (t->key == NIL.key) { return new Node(key, priority); } if (key == t->key) { return t; } if (key < t->key) { t->left = _insert(t->left, key, priority); if (t->priority < t->left->priority) { t = rightRotate(t); } } else { t->right = _insert(t->right, key, priority); if (t->priority < t->right->priority) { t = leftRotate(t); } } return t; } Node *delete1(Node *t, int key); Node *_delete(Node *t, int key) { if (t->left->key == NIL.key && t->right->key == NIL.key) { return &NIL; } else if (t->left->key == NIL.key) { t = leftRotate(t); } else if (t->right->key == NIL.key) { t = rightRotate(t); } else { if (t->left->priority > t->right->priority) { t = rightRotate(t); } else t = leftRotate(t); } return delete1(t, key); } Node *delete1(Node *t, int key) { if (t->key == NIL.key) { return &NIL; } if (key < t->key) { t->left = delete1(t->left, key); } else if (key > t->key) { t->right = delete1(t->right, key); } else return _delete(t, key); return t; } int H; int left(int i) { return i * 2 + 1; } int right(int i) { return i * 2 + 2; } class edge { public: int from, to, i; ll val; edge() {} edge(ll to) : to(to) {} edge(ll to, ll i) : to(to), i(i) {} edge(ll from, ll to, ll val) : from(from), to(to), val(val) {} }; class LCA { private: vector<vector<edge>> v; vector<vector<int>> parent; vector<int> depth; void dfs(int n, int m, int d) { parent[0][n] = m; depth[n] = d; for (auto x : v[n]) { if (x.to != m) dfs(x.to, n, d + 1); } } public: LCA(ll N, ll root, vector<vector<edge>> &tree) { v = tree; parent = vector<vector<int>>(21, vector<int>(N + 1, 0)); depth = vector<int>(N + 1, 0); dfs(root, -1, 0); for (int j = 0; j + 1 < 20; j++) { for (int i = 1; i <= N; i++) { if (parent[j][i] < 0) parent[j + 1][i] = -1; else parent[j + 1][i] = parent[j][parent[j][i]]; } } } int lca(int n, int m) { if (depth[n] > depth[m]) swap(n, m); for (int j = 0; j < 20; j++) { if ((depth[m] - depth[n]) >> j & 1) m = parent[j][m]; } if (n == m) return n; for (int j = 19; j >= 0; j--) { if (parent[j][n] != parent[j][m]) { n = parent[j][n]; m = parent[j][m]; } } return parent[0][n]; } int dep(int n) { return depth[n]; } }; ll k; int _rank[1010]; int temp[1010]; bool compare_sa(int i, int j) { if (_rank[i] != _rank[j]) return _rank[i] < _rank[j]; else { int ri = i + k <= n ? _rank[i + k] : -1; int rj = j + k <= n ? _rank[j + k] : -1; return ri < rj; } } void construct_sa(string S, int *sa) { n = S.length(); for (size_t i = 0; i <= n; i++) { sa[i] = i; _rank[i] = i < n ? S[i] : -1; } for (k = 1; k <= n; k *= 2) { sort(sa, sa + n + 1, compare_sa); // saはソート後の接尾辞の並びになっている、rankは元の位置のindexを保持したまま、更新されている。 // ピンとこなかった部分 temp[sa[0]] = 0; for (size_t i = 1; i <= n; i++) { temp[sa[i]] = temp[sa[i - 1]] + (compare_sa(sa[i - 1], sa[i]) ? 1 : 0); } for (size_t i = 0; i <= n; i++) { _rank[i] = temp[i]; } } } bool contain(string S, int *sa, string T) { int a = 0, b = S.length(); // sa は 接尾辞が辞書順に並んでいる、入っているのはその位置のインデックス while (b - a > 1) { int c = (a + b) / 2; if (S.compare(sa[c], T.length(), T) < 0) a = c; else b = c; } return S.compare(sa[b], T.length(), T) == 0; } #define bit(x, v) ((ll)x << v) class BIT { static const int MAX_N = 500010; public: BIT() { memset(bit, 0, sizeof(bit)); } ll bit[MAX_N + 1], n; ll sum(int i) { ll s = 0; while (i > 0) { s += bit[i]; i -= i & -i; } return s; } void add(int i, int x) { while (i <= n) { bit[i] += x; i += i & -i; } } }; struct UnionFind { vector<int> A; UnionFind(int n) : A(n, -1) {} int find(int x) { if (A[x] < 0) return x; return A[x] = find(A[x]); } void unite(int x, int y) { x = find(x), y = find(y); if (x == y) return; if (A[x] > A[y]) swap(x, y); A[x] += A[y]; A[y] = x; } int ngroups() { int ans = 0; for (auto a : A) if (a < 0) ans++; return ans; } }; vector<ll> getp(ll n) { vector<ll> res; ll a = 2; if (n % 2 == 0) { res.push_back(2); while (n % 2 == 0) n /= 2; } for (ll i = 3; i * i <= n; i += 2) { if (n % i == 0) { res.push_back(i); while (n % i == 0) n /= i; } } if (n != 1) res.push_back(n); return res; } vector<ll> getp2(ll n) { vector<ll> res; ll a = 2; if (n % 2 == 0) { while (n % 2 == 0) { n /= 2; res.push_back(2); } } for (ll i = 3; i * i <= n; i += 2) { if (n % i == 0) { while (n % i == 0) { n /= i; res.push_back(i); } } } if (n != 1) res.push_back(n); return res; } vector<pll> getp3(ll n) { vector<pll> res; ll a = 2; int si = 0; if (n % 2 == 0) { res.push_back(make_pair(2, 0)); while (n % 2 == 0) { n /= 2; res[si].second++; } si++; } for (ll i = 3; i * i <= n; i += 2) { if (n % i == 0) { res.push_back(make_pair(i, 0)); while (n % i == 0) { n /= i; res[si].second++; } si++; } } if (n != 1) { res.push_back(make_pair(n, 1)); } return res; } vector<ll> getDivisors(ll n) { vector<ll> res; ll a = 2; res.push_back(1); for (ll i = 2; i * i <= n; i++) { if (n % i == 0) { res.push_back(i); if (n / i != i) res.push_back(n / i); } } return res; } struct ve { public: vector<ve> child; int _t = INF; ve(int t) : _t(t) {} ve(ve _left, ve _right) { _t = _left._t + _right._t; child.push_back(_left); child.push_back(_right); } bool operator<(const ve &t) const { return _t > t._t; } }; vector<bool> elas(ll n) { vector<bool> r(n); fill(r.begin(), r.end(), 1); r[0] = 0; r[1] = 0; for (ll i = 2; i * i < n; i++) { if (!r[i]) continue; ll ti = i * 2; while (ti < n) { r[ti] = false; ti += i; } } return r; } bool isPrime(ll v) { for (ll i = 2; i * i <= v; i++) { if (v % i == 0) return false; } return true; } class SegTree { public: const static int MAX_N = 100010; const static int DAT_SIZE = (1 << 18) - 1; int N, Q; int A[MAX_N]; ll data[DAT_SIZE], datb[DAT_SIZE]; void init(int _n) { N = 1; while (N < _n) N <<= 1; memset(data, 0, sizeof(data)); memset(datb, 0, sizeof(datb)); } void init(int _n, ll iv) { N = 1; while (N < _n) N <<= 1; rep(i, DAT_SIZE) { data[i] = iv; datb[i] = iv; } } void add(int a, int b, int x) { add(a, b + 1, x, 0, 0, N); } void add(int a, int b, int x, int k, int l, int r) { if (a <= l && r <= b) { data[k] += x; } else if (l < b && a < r) { datb[k] += (min(b, r) - max(a, l)) * x; add(a, b, x, k * 2 + 1, l, (l + r) / 2); add(a, b, x, k * 2 + 2, (l + r) / 2, r); } } void change(int a, int b, int x) { change(a, b + 1, x, 0, 0, N); } void change(int a, int b, int x, int k, int l, int r) { if (a <= l && r <= b) { data[k] = x; } else if (l < b && a < r) { datb[k] = x; change(a, b, x, k * 2 + 1, l, (l + r) / 2); change(a, b, x, k * 2 + 2, (l + r) / 2, r); } } ll sum(int a, int b) { return sum(a, b + 1, 0, 0, N); } ll sum(int a, int b, int k, int l, int r) { if (b <= l || r <= a) { return 0; } if (a <= l && r <= b) { return data[k] * (r - l) + datb[k]; } ll res = (min(b, r) - max(a, l)) * data[k]; res += sum(a, b, k * 2 + 1, l, (l + r) / 2); res += sum(a, b, k * 2 + 2, (l + r) / 2, r); return res; } }; class Segment; class Circle; class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x, y - p.y); } Point operator*(double a) { return Point(a * x, a * y); } Point operator/(double a) { return Point(x / a, y / a); } double abs() { return sqrt(norm()); } double norm() { return x * x + y * y; } bool operator<(const Point &p) const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const Point &p) const { return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS; } static double dot(Point a, Point b) { return a.x * b.x + a.y * b.y; } static double cross(Point a, Point b) { return a.x * b.y - a.y * b.x; } static bool isOrthogonal(Point a, Point b) { return EQ(dot(a, b), 0.0); } static bool isOrthogonal(Point a1, Point a2, Point b1, Point b2) { return isOrthogonal(a1 - a2, b1 - b2); } static bool isOrthogonal(Segment s1, Segment s2); static bool isPalallel(Point a, Point b) { return EQ(cross(a, b), 0.0); } static bool isPalallel(Point a1, Point a2, Point b1, Point b2) { return isPalallel(a1 - a2, b1 - b2); } static bool isPalallel(Segment s1, Segment s2); static const int COUNTER_CLOCKWISE = 1; static const int CLOCKWISE = -1; static const int ONLINE_BACK = 2; static const int ONLINE_FRONT = -2; static const int ON_SEGMENT = 0; static int ccw(Point p0, Point p1, Point p2) { // 線分はp0とp1でp2がどこにあるかを探る Point a = p1 - p0; Point b = p2 - p0; if (cross(a, b) > EPS) return COUNTER_CLOCKWISE; if (cross(a, b) < -EPS) return CLOCKWISE; if (dot(a, b) < -EPS) return ONLINE_BACK; if (a.norm() < b.norm()) return ONLINE_FRONT; return ON_SEGMENT; } static bool intersect(Point p1, Point p2, Point p3, Point p4) { return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 && ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0); } static bool intersect(Segment s1, Segment s2); static Point project(Segment s, Point p); static Point reflect(Segment s, Point p); static Point getDistance(Point a, Point b) { return (a - b).abs(); } static double getDistanceLP(Segment s, Point p); static double getDistanceSP(Segment s, Point p); static double getDistance(Segment s1, Segment s2); static Point getIntersection(Segment s1, Segment s2); static pair<Point, Point> crossPoints(Circle c, Segment s); static int contains(vector<Point> g, Point p) { int n = g.size(); bool x = false; rep(i, n) { Point a = g[i] - p, b = g[(i + 1) % n] - p; // 線の上に載っているか if (std::abs(cross(a, b)) < EPS && dot(a, b) < EPS) return 1; // pを基準として上下にあるか // または外積が正か?(→にあるか) if (a.y > b.y) swap(a, b); if (a.y < EPS && EPS < b.y && cross(a, b) > EPS) x = !x; } return x ? 2 : 0; } static vector<Point> andrewScan(vector<Point> s) { vector<Point> u, l; if (s.size() < 3) return s; sort(all(s)); u.push_back(s[0]); u.push_back(s[1]); l.push_back(s[s.size() - 1]); l.push_back(s[s.size() - 2]); for (int i = 2; i < s.size(); i++) { for (int _n = u.size(); _n >= 2 && ccw(u[_n - 2], u[_n - 1], s[i]) > CLOCKWISE; _n--) { u.pop_back(); } u.push_back(s[i]); } for (int i = s.size() - 3; i >= 0; i--) { for (int _n = l.size(); _n >= 2 && ccw(l[_n - 2], l[_n - 1], s[i]) > CLOCKWISE; _n--) { l.pop_back(); } l.push_back(s[i]); } reverse(all(l)); for (int i = u.size() - 2; i >= 1; i--) { l.push_back(u[i]); } return l; } void get_cin() { cin >> x >> y; } }; class Segment { public: Point p1, p2; Segment() {} Segment(Point p1, Point p2) : p1(p1), p2(p2) {} void get_cin() { cin >> p1.x >> p1.y >> p2.x >> p2.y; } Point p1tp2() { return p2 - p1; } Point p2tp1() { return p1 - p2; } double abs() { return std::abs(norm()); } double norm() { return (p2 - p1).norm(); } }; bool Point::isOrthogonal(Segment s1, Segment s2) { return EQ(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0); } bool Point::isPalallel(Segment s1, Segment s2) { return EQ(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0); } bool Point::intersect(Segment s1, Segment s2) { return intersect(s1.p1, s1.p2, s2.p1, s2.p2); } Point Point::project(Segment s, Point p) { Point base = s.p2 - s.p1; double r = Point::dot(p - s.p1, base) / base.norm(); return s.p1 + base * r; } Point Point::reflect(Segment s, Point p) { return (project(s, p) * 2) - p; } double Point::getDistanceLP(Segment s, Point p) { return std::abs(cross(s.p2 - s.p1, p - s.p1) / (s.p2 - s.p1).abs()); } double Point::getDistanceSP(Segment s, Point p) { if (dot(s.p2 - s.p1, p - s.p1) < 0.0) return (p - s.p1).abs(); if (dot(s.p1 - s.p2, p - s.p2) < 0.0) return (p - s.p2).abs(); return getDistanceLP(s, p); } double Point::getDistance(Segment s1, Segment s2) { if (intersect(s1, s2)) return 0.0; return min({getDistanceSP(s1, s2.p1), getDistanceSP(s1, s2.p2), getDistanceSP(s2, s1.p1), getDistanceSP(s2, s1.p2)}); } Point Point::getIntersection(Segment s1, Segment s2) { // (s1.p1 - s2.p1).norm() auto bs = s1.p2 - s1.p1; auto n1 = s2.p1 - s1.p1; auto n2 = s2.p2 - s1.p1; auto c1 = std::abs(cross(n1, bs)) / bs.norm(); auto c2 = std::abs(cross(n2, bs)) / bs.norm(); return s2.p1 + (s2.p2 - s2.p1) * (c1 / (c1 + c2)); // c1:c2=t:1-t // c2t=(1-t)c1 // t/(1-t)=c1/(c1+c2) // } double arg(Point p) { return atan2(p.y, p.x); } Point polar(double a, double r) { return Point(cos(r) * a, sin(r) * a); } class Circle { public: Point c; double r; Circle(Point c = Point(), double r = 0.0) : c(c), r(r) {} void get_cin() { cin >> c.x >> c.y >> r; } static pair<Point, Point> getCrossPoints(Circle c1, Circle c2) { double d = (c1.c - c2.c).abs(); // 中心点どうしの距離 double a = acos((c1.r * c1.r + d * d - c2.r * c2.r) / (2 * c1.r * d)); double t = arg(c2.c - c1.c); return make_pair(c1.c + polar(c1.r, t + a), c1.c + polar(c1.r, t - a)); } }; pair<Point, Point> Point::crossPoints(Circle c, Segment s) { auto pp = project(s, c.c); auto f = (pp - c.c).norm(); auto mu = sqrt(c.r * c.r - f); auto e = s.p1tp2() / s.p1tp2().abs(); return make_pair(pp + e * mu, pp - e * mu); } ll divRm(string s, ll x) { ll r = 0; for (ll i = 0; i < s.size(); i++) { r *= 10; r += s[i] - '0'; r %= x; } return r; } ll cmbi(ll x, ll b) { ll res = 1; for (size_t i = 0; i < b; i++) { res *= x - i; res %= INF; res *= inv[b - i]; res %= INF; } return res; } double digsum(ll x) { ll res = 0; while (x > 0) { res += x % 10; x /= 10; } return res; } bool check_parindrome(string s) { int n = s.size(); rep(i, n / 2) { if (s[i] != s[n - i - 1]) { return false; } } return true; } // ここまでライブラリ // ここからコード struct ds { double l, h; }; ds xm[4]; ds ym[4]; double x[100010], y[100010]; char d[100010]; void chmax(double &a, double &b) { if (a < b) a = b; } void chmin(double &a, double &b) { if (a > b) a = b; } void setxm(ll p, ll i) { chmax(xm[p].h, x[i]); chmin(xm[p].l, x[i]); chmax(ym[p + 2].h, y[i]); chmin(ym[p + 2].l, y[i]); } void setym(ll p, ll i) { chmax(xm[p].h, x[i]); chmin(xm[p].l, x[i]); chmax(ym[p - 2].h, y[i]); chmin(ym[p - 2].l, y[i]); } double xv(double v) { return max({xm[2].h, xm[3].h, xm[0].h + v, xm[1].h - v}) - min({xm[2].l, xm[3].l, xm[0].l + v, xm[1].l - v}); } double yv(double v) { return max({ym[2].h, ym[3].h, ym[0].h + v, ym[1].h - v}) - min({ym[2].l, ym[3].l, ym[0].l + v, ym[1].l - v}); } void setup(vector<double> &v, ll p, char c) { // pとcをぶつける // その際bとb+1の固定値もぶつける ll b = p - p % 2; // xに寄せて処理をする if (p >= 2) { swap(x, y); swap(xm, ym); p -= 2; } rep(i, n) { if (d[i] != c) { continue; } if (xm[p].l != big) { v.push_back(abs(xm[p].l - x[i])); v.push_back(abs(xm[p].l - x[i]) / 2); v.push_back(abs(xm[p].h - x[i])); v.push_back(abs(xm[p].h - x[i]) / 2); } if (xm[b].l != big) { v.push_back(abs(xm[b].l - x[i])); v.push_back(abs(xm[b].l - x[i]) / 2); v.push_back(abs(xm[b].h - x[i])); v.push_back(abs(xm[b].h - x[i]) / 2); } if (xm[b + 1].l != big) { v.push_back(abs(xm[b + 1].l - x[i])); v.push_back(abs(xm[b + 1].l - x[i]) / 2); v.push_back(abs(xm[b + 1].h - x[i])); v.push_back(abs(xm[b + 1].h - x[i]) / 2); } } if (p >= 2) { swap(x, y); swap(xm, ym); } } void solv() { cin >> n; rep(i, 4) { xm[i].h = -big; xm[i].l = big; ym[i].h = -big; ym[i].l = big; } rep(i, n) { cin >> x[i] >> y[i] >> d[i]; if (d[i] == 'R') { setxm(0, i); } if (d[i] == 'L') { setxm(1, i); } if (d[i] == 'U') { setym(2, i); } if (d[i] == 'D') { setym(3, i); } } vector<double> v; setup(v, 0, 'L'); setup(v, 1, 'R'); setup(v, 2, 'D'); setup(v, 3, 'U'); vsort(v); dup(v); double res = xv(0) * yv(0); rep(i, v.size()) { res = min(res, xv(v[i]) * yv(v[i])); } put_float(res); } int main() { COMinit(); solv(); return 0; }
[ "assignment.add" ]
832,983
832,984
u224756887
cpp
p03004
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define sz(x) int(x.size()) #define show(x) \ { \ for (auto i : x) { \ cout << i << " "; \ } \ cout << endl; \ } using namespace std; using ll = long long; using P = pair<int, int>; const int INF = 1e9; double xleft = INF, xright = -INF, up = -INF, down = INF; double rightVecMax = -INF, rightVecMin = INF; double leftVecMax = -INF, leftVecMin = INF; double upVecMax = -INF, upVecMin = INF; double downVecMax = -INF, downVecMin = INF; double calLeft(double time) { double res = min(xleft, rightVecMin + time); res = min(res, leftVecMin - time); return res; } double calRight(double time) { double res = max(xright, leftVecMax - time); res = max(res, rightVecMax + time); return res; } double calUp(double time) { double res = max(up, upVecMax + time); res = max(res, downVecMax - time); return res; } double calDown(double time) { double res = min(down, upVecMin + time); res = min(res, downVecMin - time); return res; } double cal(double time) { double res = (ll)(calRight(time) - calLeft(time)) * (calUp(time) - calDown(time)); return res; } int main() { // 結果を決め打ち(二分探索)、dp?、 // xとy共に、減少、不変、増加を辿る、相加相乗平均によりグラフが重なったところ、 // 交差する点がなければ4つの点の中で最小値 // 上下左右を関数化する int N; cin >> N; vector<double> X(N); vector<double> Y(N); rep(i, N) { double x, y; char d; cin >> x >> y >> d; X.push_back(x); Y.push_back(y); if (d == 'R') { up = max(up, y); down = min(down, y); rightVecMax = max(rightVecMax, x); rightVecMin = min(rightVecMin, x); } if (d == 'L') { up = max(up, y); down = min(down, y); leftVecMax = max(leftVecMax, x); leftVecMin = min(leftVecMin, x); } if (d == 'U') { xright = max(xright, x); xleft = min(xleft, x); upVecMax = max(upVecMax, y); upVecMin = min(upVecMin, y); } if (d == 'D') { xright = max(xright, x); xleft = min(xleft, x); downVecMax = max(downVecMax, y); downVecMin = min(downVecMin, y); } } double ans = cal(0); double l = 0, r = INF; // 時間の山登り法 rep(i, 200) { double l2 = (l * 2 + r) / 3; double r2 = (l + r * 2) / 3; if (cal(l2) < cal(r2)) r = r2; else l = l2; } ans = min(ans, min(cal(l), cal(r))); printf("%.12f\n", ans); return 0; // ll, 0, -, 1i, for s&g, debug }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define sz(x) int(x.size()) #define show(x) \ { \ for (auto i : x) { \ cout << i << " "; \ } \ cout << endl; \ } using namespace std; using ll = long long; using P = pair<int, int>; const int INF = 1e9; double xleft = INF, xright = -INF, up = -INF, down = INF; double rightVecMax = -INF, rightVecMin = INF; double leftVecMax = -INF, leftVecMin = INF; double upVecMax = -INF, upVecMin = INF; double downVecMax = -INF, downVecMin = INF; double calLeft(double time) { double res = min(xleft, rightVecMin + time); res = min(res, leftVecMin - time); return res; } double calRight(double time) { double res = max(xright, leftVecMax - time); res = max(res, rightVecMax + time); return res; } double calUp(double time) { double res = max(up, upVecMax + time); res = max(res, downVecMax - time); return res; } double calDown(double time) { double res = min(down, upVecMin + time); res = min(res, downVecMin - time); return res; } double cal(double time) { double res = (calRight(time) - calLeft(time)) * (calUp(time) - calDown(time)); return res; } int main() { // 結果を決め打ち(二分探索)、dp?、 // xとy共に、減少、不変、増加を辿る、相加相乗平均によりグラフが重なったところ、 // 交差する点がなければ4つの点の中で最小値 // 上下左右を関数化する int N; cin >> N; vector<double> X(N); vector<double> Y(N); rep(i, N) { double x, y; char d; cin >> x >> y >> d; X.push_back(x); Y.push_back(y); if (d == 'R') { up = max(up, y); down = min(down, y); rightVecMax = max(rightVecMax, x); rightVecMin = min(rightVecMin, x); } if (d == 'L') { up = max(up, y); down = min(down, y); leftVecMax = max(leftVecMax, x); leftVecMin = min(leftVecMin, x); } if (d == 'U') { xright = max(xright, x); xleft = min(xleft, x); upVecMax = max(upVecMax, y); upVecMin = min(upVecMin, y); } if (d == 'D') { xright = max(xright, x); xleft = min(xleft, x); downVecMax = max(downVecMax, y); downVecMin = min(downVecMin, y); } } double ans = cal(0); double l = 0, r = INF; // 時間の山登り法 rep(i, 200) { double l2 = (l * 2 + r) / 3; double r2 = (l + r * 2) / 3; if (cal(l2) < cal(r2)) r = r2; else l = l2; } ans = min(ans, min(cal(l), cal(r))); // candをいくつかに絞り込む // vector<double> cand; // cand.push_back(0); // if (rightVecMin < xleft) { // cand.push_back(xleft - rightVecMin); // cand.push_back(xright - rightVecMin); // } // if (rightVecMax < xright) { // cand.push_back(xright - rightVecMax); // } // if (leftVecMax > xright) { // cand.push_back(leftVecMax - xright); // cand.push_back(leftVecMax - xleft); // } // if (leftVecMin > xleft) { // cand.push_back(leftVecMin - xleft); // } // if (upVecMin < down) { // cand.push_back(down - upVecMin); // cand.push_back(up - upVecMin); // } // if (upVecMax < up) { // cand.push_back(up - upVecMax); // } // if (downVecMax > up) { // cand.push_back(downVecMax - up); // cand.push_back(downVecMax - down); // } // if (downVecMin > down) { // cand.push_back(downVecMin - down); // } // cand.push_back(INF); // sort(cand.begin(), cand.end()); // for (int i = 0; i < sz(cand) - 1; i++) { // if (cand[i] < 0 || cand[i+1] < 0) continue; // l = cand[i]; // r = (cand[i] + cand[i+1]) / 2; // ans = min(ans, min(cal(l), cal(r))); // rep(i, 200) { // double l2 = (l * 2 + r) / 3; // double r2 = (l + r * 2) / 3; // if (cal(l2) < cal(r2)) r = r2; // else l = l2; // } // ans = min(ans, min(cal(l), cal(r))); // l = (cand[i] + cand[i+1]) / 2; // r = cand[i+1]; // ans = min(ans, min(cal(l), cal(r))); // rep(i, 200) { // double l2 = (l * 2 + r) / 3; // double r2 = (l + r * 2) / 3; // if (cal(l2) < cal(r2)) r = r2; // else l = l2; // } // ans = min(ans, min(cal(l), cal(r))); // } printf("%.12f\n", ans); return 0; // ll, 0, -, 1i, for s&g, debug }
[]
832,987
832,988
u600402037
cpp
p03004
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define sz(x) int(x.size()) #define show(x) \ { \ for (auto i : x) { \ cout << i << " "; \ } \ cout << endl; \ } using namespace std; using ll = long long; using P = pair<int, int>; const int INF = 1e9; double xleft = INF, xright = -INF, up = -INF, down = INF; double rightVecMax = -INF, rightVecMin = INF; double leftVecMax = -INF, leftVecMin = INF; double upVecMax = -INF, upVecMin = INF; double downVecMax = -INF, downVecMin = INF; double calLeft(double time) { double res = min(xleft, rightVecMin + time); res = min(res, leftVecMin - time); return res; } double calRight(double time) { double res = max(xright, leftVecMax - time); res = max(res, rightVecMax + time); return res; } double calUp(double time) { double res = max(up, upVecMax + time); res = max(res, downVecMax - time); return res; } double calDown(double time) { double res = min(down, upVecMin + time); res = min(res, downVecMin - time); return res; } double cal(double time) { double res = (ll)(calRight(time) - calLeft(time)) * (calUp(time) - calDown(time)); return res; } int main() { // 結果を決め打ち(二分探索)、dp?、 // xとy共に、減少、不変、増加を辿る、相加相乗平均によりグラフが重なったところ、 // 交差する点がなければ4つの点の中で最小値 // 上下左右を関数化する int N; cin >> N; vector<double> X(N); vector<double> Y(N); rep(i, N) { double x, y; char d; cin >> x >> y >> d; X.push_back(x); Y.push_back(y); if (d == 'R') { up = max(up, y); down = min(down, y); rightVecMax = max(rightVecMax, x); rightVecMin = min(rightVecMin, x); } if (d == 'L') { up = max(up, y); down = min(down, y); leftVecMax = max(leftVecMax, x); leftVecMin = min(leftVecMin, x); } if (d == 'U') { xright = max(xright, x); xleft = min(xleft, x); upVecMax = max(upVecMax, y); upVecMin = min(upVecMin, y); } if (d == 'D') { xright = max(xright, x); xleft = min(xleft, x); downVecMax = max(downVecMax, y); downVecMin = min(downVecMin, y); } } double ans = cal(0); double l = 0, r = INF; // 時間の山登り法 rep(i, 200) { double l2 = (l * 2 + r) / 3; double r2 = (l + r * 2) / 3; if (cal(l2) < cal(r2)) r = r2; else l = l2; } ans = min(ans, min(cal(l), cal(r))); // candをいくつかに絞り込む vector<double> cand; cand.push_back(0); if (rightVecMin < xleft) { cand.push_back(xleft - rightVecMin); cand.push_back(xright - rightVecMin); } if (rightVecMax < xright) { cand.push_back(xright - rightVecMax); } if (leftVecMax > xright) { cand.push_back(leftVecMax - xright); cand.push_back(leftVecMax - xleft); } if (leftVecMin > xleft) { cand.push_back(leftVecMin - xleft); } if (upVecMin < down) { cand.push_back(down - upVecMin); cand.push_back(up - upVecMin); } if (upVecMax < up) { cand.push_back(up - upVecMax); } if (downVecMax > up) { cand.push_back(downVecMax - up); cand.push_back(downVecMax - down); } if (downVecMin > down) { cand.push_back(downVecMin - down); } cand.push_back(INF); sort(cand.begin(), cand.end()); for (int i = 0; i < sz(cand) - 1; i++) { if (cand[i] < 0 || cand[i + 1] < 0) continue; l = cand[i]; r = (cand[i] + cand[i + 1]) / 2; ans = min(ans, min(cal(l), cal(r))); rep(i, 200) { double l2 = (l * 2 + r) / 3; double r2 = (l + r * 2) / 3; if (cal(l2) < cal(r2)) r = r2; else l = l2; } ans = min(ans, min(cal(l), cal(r))); l = (cand[i] + cand[i + 1]) / 2; r = cand[i + 1]; ans = min(ans, min(cal(l), cal(r))); rep(i, 200) { double l2 = (l * 2 + r) / 3; double r2 = (l + r * 2) / 3; if (cal(l2) < cal(r2)) r = r2; else l = l2; } ans = min(ans, min(cal(l), cal(r))); } printf("%.12f\n", ans); return 0; // ll, 0, -, 1i, for s&g, debug }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define sz(x) int(x.size()) #define show(x) \ { \ for (auto i : x) { \ cout << i << " "; \ } \ cout << endl; \ } using namespace std; using ll = long long; using P = pair<int, int>; const int INF = 1e9; double xleft = INF, xright = -INF, up = -INF, down = INF; double rightVecMax = -INF, rightVecMin = INF; double leftVecMax = -INF, leftVecMin = INF; double upVecMax = -INF, upVecMin = INF; double downVecMax = -INF, downVecMin = INF; double calLeft(double time) { double res = min(xleft, rightVecMin + time); res = min(res, leftVecMin - time); return res; } double calRight(double time) { double res = max(xright, leftVecMax - time); res = max(res, rightVecMax + time); return res; } double calUp(double time) { double res = max(up, upVecMax + time); res = max(res, downVecMax - time); return res; } double calDown(double time) { double res = min(down, upVecMin + time); res = min(res, downVecMin - time); return res; } double cal(double time) { double res = (calRight(time) - calLeft(time)) * (calUp(time) - calDown(time)); return res; } int main() { // 結果を決め打ち(二分探索)、dp?、 // xとy共に、減少、不変、増加を辿る、相加相乗平均によりグラフが重なったところ、 // 交差する点がなければ4つの点の中で最小値 // 上下左右を関数化する int N; cin >> N; vector<double> X(N); vector<double> Y(N); rep(i, N) { double x, y; char d; cin >> x >> y >> d; X.push_back(x); Y.push_back(y); if (d == 'R') { up = max(up, y); down = min(down, y); rightVecMax = max(rightVecMax, x); rightVecMin = min(rightVecMin, x); } if (d == 'L') { up = max(up, y); down = min(down, y); leftVecMax = max(leftVecMax, x); leftVecMin = min(leftVecMin, x); } if (d == 'U') { xright = max(xright, x); xleft = min(xleft, x); upVecMax = max(upVecMax, y); upVecMin = min(upVecMin, y); } if (d == 'D') { xright = max(xright, x); xleft = min(xleft, x); downVecMax = max(downVecMax, y); downVecMin = min(downVecMin, y); } } double ans = cal(0); double l = 0, r = INF; // 時間の山登り法 rep(i, 200) { double l2 = (l * 2 + r) / 3; double r2 = (l + r * 2) / 3; if (cal(l2) < cal(r2)) r = r2; else l = l2; } ans = min(ans, min(cal(l), cal(r))); // candをいくつかに絞り込む vector<double> cand; cand.push_back(0); if (rightVecMin < xleft) { cand.push_back(xleft - rightVecMin); cand.push_back(xright - rightVecMin); } if (rightVecMax < xright) { cand.push_back(xright - rightVecMax); } if (leftVecMax > xright) { cand.push_back(leftVecMax - xright); cand.push_back(leftVecMax - xleft); } if (leftVecMin > xleft) { cand.push_back(leftVecMin - xleft); } if (upVecMin < down) { cand.push_back(down - upVecMin); cand.push_back(up - upVecMin); } if (upVecMax < up) { cand.push_back(up - upVecMax); } if (downVecMax > up) { cand.push_back(downVecMax - up); cand.push_back(downVecMax - down); } if (downVecMin > down) { cand.push_back(downVecMin - down); } cand.push_back(INF); sort(cand.begin(), cand.end()); for (int i = 0; i < sz(cand) - 1; i++) { if (cand[i] < 0 || cand[i + 1] < 0) continue; l = cand[i]; r = (cand[i] + cand[i + 1]) / 2; ans = min(ans, min(cal(l), cal(r))); rep(i, 200) { double l2 = (l * 2 + r) / 3; double r2 = (l + r * 2) / 3; if (cal(l2) < cal(r2)) r = r2; else l = l2; } ans = min(ans, min(cal(l), cal(r))); l = (cand[i] + cand[i + 1]) / 2; r = cand[i + 1]; ans = min(ans, min(cal(l), cal(r))); rep(i, 200) { double l2 = (l * 2 + r) / 3; double r2 = (l + r * 2) / 3; if (cal(l2) < cal(r2)) r = r2; else l = l2; } ans = min(ans, min(cal(l), cal(r))); } printf("%.12f\n", ans); return 0; // ll, 0, -, 1i, for s&g, debug }
[]
832,989
832,990
u600402037
cpp
p03004
//#pragma GCC optimize("Ofast") //#pragma GCC optimize("unroll-loops") //#pragma GCC target("fma,avx,avx2") #include <bits/stdc++.h> using namespace std; #define int long long #define ld long double #define sz(a) (int)(a).size() #define all(a) (a).begin(), (a).end() #define x first #define y second mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); const ld inf = 6e8; const ld eps = 1e-9; int n; vector<ld> x, y; vector<char> d; ld get_x(int i, ld t) { if (d[i] == 'L') return x[i] - t; if (d[i] == 'R') return x[i] + t; return x[i]; } ld get_y(int i, ld t) { if (d[i] == 'D') return y[i] - t; if (d[i] == 'U') return y[i] + t; return y[i]; } ld solve(ld t) { ld mx_x = -inf * inf, mn_x = inf * inf; ld mx_y = -inf * inf, mn_y = inf * inf; for (int i = 0; i < n; i++) { ld xx = get_x(i, t); ld yy = get_y(i, t); mx_x = max(mx_x, xx); mn_x = min(mn_x, xx); mx_y = max(mx_y, yy); mn_y = min(mn_y, yy); } return (mx_x - mn_x) * (mx_y - mn_y); } signed main() { ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); cin >> n; x.resize(n); y.resize(n); d.resize(n); for (int i = 0; i < n; i++) { cin >> x[i] >> y[i] >> d[i]; } ld l = 0.0, r = inf, m2, m1; ld three = 3.0; for (int i = 0; i < 600; i++) { m1 = l + (r - l) / three; m2 = r - (r - l) / three; if (solve(m1) + eps > solve(m2)) { l = m1; } else { r = m2; } } cout << fixed << setprecision(12) << solve(l) << "\n"; return 0; }
//#pragma GCC optimize("Ofast") //#pragma GCC optimize("unroll-loops") //#pragma GCC target("fma,avx,avx2") #include <bits/stdc++.h> using namespace std; #define int long long #define ld long double #define sz(a) (int)(a).size() #define all(a) (a).begin(), (a).end() #define x first #define y second mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); const ld inf = 6e8; const ld eps = 1e-10; int n; vector<ld> x, y; vector<char> d; ld get_x(int i, ld t) { if (d[i] == 'L') return x[i] - t; if (d[i] == 'R') return x[i] + t; return x[i]; } ld get_y(int i, ld t) { if (d[i] == 'D') return y[i] - t; if (d[i] == 'U') return y[i] + t; return y[i]; } ld solve(ld t) { ld mx_x = -inf * inf, mn_x = inf * inf; ld mx_y = -inf * inf, mn_y = inf * inf; for (int i = 0; i < n; i++) { ld xx = get_x(i, t); ld yy = get_y(i, t); mx_x = max(mx_x, xx); mn_x = min(mn_x, xx); mx_y = max(mx_y, yy); mn_y = min(mn_y, yy); } return (mx_x - mn_x) * (mx_y - mn_y); } signed main() { ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); cin >> n; x.resize(n); y.resize(n); d.resize(n); for (int i = 0; i < n; i++) { cin >> x[i] >> y[i] >> d[i]; } ld l = 0.0, r = inf, m2, m1; ld three = 3.0; for (int i = 0; i < 600; i++) { m1 = l + (r - l) / three; m2 = r - (r - l) / three; if (solve(m1) + eps > solve(m2)) { l = m1; } else { r = m2; } } cout << fixed << setprecision(12) << solve(l) << "\n"; return 0; }
[ "literal.number.change", "variable_declaration.value.change" ]
833,003
833,004
u304537903
cpp
p03004
#include <bits/stdc++.h> using namespace std; using lint = long long int; using P = pair<int, int>; using PL = pair<lint, lint>; #define FOR(i, begin, end) \ for (int i = (begin), i##_end_ = (end); i < i##_end_; i++) #define IFOR(i, begin, end) \ for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--) #define REP(i, n) FOR(i, 0, n) #define IREP(i, n) IFOR(i, 0, n) #define ALL(a) (a).begin(), (a).end() constexpr int MOD = 1000000007; constexpr lint B1 = 1532834020; constexpr lint M1 = 2147482409; constexpr lint B2 = 1388622299; constexpr lint M2 = 2147478017; constexpr int INF = 2147483647; void yes(bool expr) { cout << (expr ? "Yes" : "No") << "\n"; } lint cxmax = -1e9; lint cxmin = 1e9; lint cymax = -1e9; lint cymin = 1e9; lint rxmax = -1e9; lint rxmin = 1e9; lint lxmax = -1e9; lint lxmin = 1e9; lint uymax = -1e9; lint uymin = 1e9; lint dymax = -1e9; lint dymin = 1e9; lint solve(lint t) { if (t < 0) return 1e18; lint xmax = max(cxmax, max(rxmax + t, lxmax - t)); lint xmin = min(cxmin, max(rxmin + t, lxmin - t)); lint ymax = max(cymax, max(uymax + t, dymax - t)); lint ymin = min(cymin, max(uymin + t, dymin - t)); return (xmax - xmin) * (ymax - ymin); } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int N; cin >> N; REP(i, N) { lint x, y; char d; cin >> x >> y >> d; x *= 2; y *= 2; if (d == 'R') { rxmax = max(rxmax, x); rxmin = min(rxmin, x); cymax = max(cymax, y); cymin = min(cymin, y); } else if (d == 'L') { lxmax = max(lxmax, x); lxmin = min(lxmin, x); cymax = max(cymax, y); cymin = min(cymin, y); } else if (d == 'U') { cxmax = max(cxmax, x); cxmin = min(cxmin, x); uymax = max(uymax, y); uymin = min(uymin, y); } else { cxmax = max(cxmax, x); cxmin = min(cxmin, x); dymax = max(dymax, y); dymin = min(dymin, y); } } lint ans = solve(0); ans = min(ans, solve((lxmax - rxmax) / 2)); ans = min(ans, solve((lxmax - cxmax))); ans = min(ans, solve((cxmax - rxmax))); ans = min(ans, solve((lxmin - rxmin) / 2)); ans = min(ans, solve((lxmin - cxmin))); ans = min(ans, solve((cxmin - rxmin))); ans = min(ans, solve((dymax - uymax) / 2)); ans = min(ans, solve((dymax - cymax))); ans = min(ans, solve((cymax - uymax))); ans = min(ans, solve((dymin - uymin) / 2)); ans = min(ans, solve((dymin - cymin))); ans = min(ans, solve((cymin - uymin))); cout << fixed << setprecision(10) << (double)ans / 4.0 << "\n"; }
#include <bits/stdc++.h> using namespace std; using lint = long long int; using P = pair<int, int>; using PL = pair<lint, lint>; #define FOR(i, begin, end) \ for (int i = (begin), i##_end_ = (end); i < i##_end_; i++) #define IFOR(i, begin, end) \ for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--) #define REP(i, n) FOR(i, 0, n) #define IREP(i, n) IFOR(i, 0, n) #define ALL(a) (a).begin(), (a).end() constexpr int MOD = 1000000007; constexpr lint B1 = 1532834020; constexpr lint M1 = 2147482409; constexpr lint B2 = 1388622299; constexpr lint M2 = 2147478017; constexpr int INF = 2147483647; void yes(bool expr) { cout << (expr ? "Yes" : "No") << "\n"; } lint cxmax = -1e9; lint cxmin = 1e9; lint cymax = -1e9; lint cymin = 1e9; lint rxmax = -1e9; lint rxmin = 1e9; lint lxmax = -1e9; lint lxmin = 1e9; lint uymax = -1e9; lint uymin = 1e9; lint dymax = -1e9; lint dymin = 1e9; lint solve(lint t) { if (t < 0) return 1e18; lint xmax = max(cxmax, max(rxmax + t, lxmax - t)); lint xmin = min(cxmin, min(rxmin + t, lxmin - t)); lint ymax = max(cymax, max(uymax + t, dymax - t)); lint ymin = min(cymin, min(uymin + t, dymin - t)); return (xmax - xmin) * (ymax - ymin); } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int N; cin >> N; REP(i, N) { lint x, y; char d; cin >> x >> y >> d; x *= 2; y *= 2; if (d == 'R') { rxmax = max(rxmax, x); rxmin = min(rxmin, x); cymax = max(cymax, y); cymin = min(cymin, y); } else if (d == 'L') { lxmax = max(lxmax, x); lxmin = min(lxmin, x); cymax = max(cymax, y); cymin = min(cymin, y); } else if (d == 'U') { cxmax = max(cxmax, x); cxmin = min(cxmin, x); uymax = max(uymax, y); uymin = min(uymin, y); } else { cxmax = max(cxmax, x); cxmin = min(cxmin, x); dymax = max(dymax, y); dymin = min(dymin, y); } } lint ans = solve(0); ans = min(ans, solve((lxmax - rxmax) / 2)); ans = min(ans, solve((lxmax - cxmax))); ans = min(ans, solve((cxmax - rxmax))); ans = min(ans, solve((lxmin - rxmin) / 2)); ans = min(ans, solve((lxmin - cxmin))); ans = min(ans, solve((cxmin - rxmin))); ans = min(ans, solve((dymax - uymax) / 2)); ans = min(ans, solve((dymax - cymax))); ans = min(ans, solve((cymax - uymax))); ans = min(ans, solve((dymin - uymin) / 2)); ans = min(ans, solve((dymin - cymin))); ans = min(ans, solve((cymin - uymin))); cout << fixed << setprecision(10) << (double)ans / 4.0 << "\n"; }
[ "misc.opposites", "identifier.change", "call.function.change", "call.arguments.change" ]
833,005
833,006
u914173586
cpp
p03004
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> oset; #define sim template <class c #define ris return *this #define dor > debug &operator<< #define eni(x) \ sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<( \ c i) { sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c *x) -> decltype(cerr << *x, 0); sim > char dud(...); struct debug { #ifdef LOCAL ~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair<b, c> d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; } #else sim dor(const c &) { ris; } #endif } ; #define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " using ll = long long; #define mins(x, y) x = min(x, y) #define maxs(x, y) x = max(x, y) const double inf = 1e10; struct D { vector<double> l, r; D() : l(3, inf), r(3, -inf) {} void add(double x, int v) { ++v; mins(l[v], x); maxs(r[v], x); } double get(double t) { double nl = inf, nr = -inf; for (int i = 0; i < 3; i++) { mins(nl, l[i] + i * t); maxs(nr, r[i] + i * t); } return nr - nl; } vector<double> events() { vector<double> ts; for (int i = 0; i < 3; i++) { for (int j = 0; j < i; j++) { { double t = (l[j] - l[i]) / (i - j); if (t < 0) ts.push_back(t); } { double t = (r[j] - r[i]) / (i - j); if (t > 0) ts.push_back(t); } } } return ts; } }; void test_case() { int n; cin >> n; D xd, yd; for (int i = 0; i < n; i++) { int x, y; char d; cin >> x >> y >> d; if (d == 'L') xd.add(x, -1), yd.add(y, 0); if (d == 'R') xd.add(x, 1), yd.add(y, 0); if (d == 'U') xd.add(x, 0), yd.add(y, 1); if (d == 'D') xd.add(x, 0), yd.add(y, -1); } vector<double> ts; ts.push_back(0); ts.push_back(inf); { auto nts = xd.events(); ts.insert(ts.end(), nts.begin(), nts.end()); } { auto nts = yd.events(); ts.insert(ts.end(), nts.begin(), nts.end()); } sort(ts.begin(), ts.end()); double ans = 1e18; for (double t : ts) { double now = xd.get(t) * yd.get(t); mins(ans, now); } cout << ans << "\n"; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout << setprecision(10); int T = 1; //~ cin >> T; while (T--) { test_case(); } return 0; }
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> oset; #define sim template <class c #define ris return *this #define dor > debug &operator<< #define eni(x) \ sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<( \ c i) { sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c *x) -> decltype(cerr << *x, 0); sim > char dud(...); struct debug { #ifdef LOCAL ~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair<b, c> d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; } #else sim dor(const c &) { ris; } #endif } ; #define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " using ll = long long; #define mins(x, y) x = min(x, y) #define maxs(x, y) x = max(x, y) const double inf = 1e10; struct D { vector<double> l, r; D() : l(3, inf), r(3, -inf) {} void add(double x, int v) { ++v; mins(l[v], x); maxs(r[v], x); } double get(double t) { double nl = inf, nr = -inf; for (int i = 0; i < 3; i++) { mins(nl, l[i] + i * t); maxs(nr, r[i] + i * t); } return nr - nl; } vector<double> events() { vector<double> ts; for (int i = 0; i < 3; i++) { for (int j = 0; j < i; j++) { { double t = (l[j] - l[i]) / (i - j); if (t > 0) ts.push_back(t); } { double t = (r[j] - r[i]) / (i - j); if (t > 0) ts.push_back(t); } } } return ts; } }; void test_case() { int n; cin >> n; D xd, yd; for (int i = 0; i < n; i++) { int x, y; char d; cin >> x >> y >> d; if (d == 'L') xd.add(x, -1), yd.add(y, 0); if (d == 'R') xd.add(x, 1), yd.add(y, 0); if (d == 'U') xd.add(x, 0), yd.add(y, 1); if (d == 'D') xd.add(x, 0), yd.add(y, -1); } vector<double> ts; ts.push_back(0); ts.push_back(inf); { auto nts = xd.events(); ts.insert(ts.end(), nts.begin(), nts.end()); } { auto nts = yd.events(); ts.insert(ts.end(), nts.begin(), nts.end()); } sort(ts.begin(), ts.end()); double ans = 1e18; for (double t : ts) { double now = xd.get(t) * yd.get(t); mins(ans, now); } cout << ans << "\n"; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout << setprecision(10); int T = 1; //~ cin >> T; while (T--) { test_case(); } return 0; }
[ "misc.opposites", "expression.operator.compare.change", "assignment.value.change", "call.arguments.change", "expression.operation.binary.change" ]
833,024
833,025
u306697932
cpp
p03004
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> oset; #define sim template <class c #define ris return *this #define dor > debug &operator<< #define eni(x) \ sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<( \ c i) { sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c *x) -> decltype(cerr << *x, 0); sim > char dud(...); struct debug { #ifdef LOCAL ~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair<b, c> d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; } #else sim dor(const c &) { ris; } #endif } ; #define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " using ll = long long; #define mins(x, y) x = min(x, y) #define maxs(x, y) x = max(x, y) const double inf = 1e10; struct D { vector<double> l, r; D() : l(3, inf), r(3, -inf) {} void add(double x, int v) { ++v; mins(l[v], x); maxs(r[v], x); } double get(double t) { double nl = inf, nr = -inf; for (int i = 0; i < 3; i++) { mins(nl, l[i] + i * t); maxs(nr, r[i] + i * t); } return nr - nl; } vector<double> events() { vector<double> ts; for (int i = 0; i < 3; i++) { for (int j = 0; j < i; j++) { { double t = (l[j] - l[i]) / (i - j); if (t < 0) ts.push_back(t); } { double t = (r[j] - r[i]) / (i - j); if (t > 0) ts.push_back(t); } } } return ts; } }; void test_case() { int n; cin >> n; D xd, yd; for (int i = 0; i < n; i++) { int x, y; char d; cin >> x >> y >> d; if (d == 'L') xd.add(x, -1), yd.add(y, 0); if (d == 'R') xd.add(x, 1), yd.add(y, 0); if (d == 'U') xd.add(x, 0), yd.add(y, 1); if (d == 'D') xd.add(x, 0), yd.add(y, -1); } vector<double> ts; ts.push_back(0); ts.push_back(inf); { auto nts = xd.events(); ts.insert(ts.end(), nts.begin(), nts.end()); } { auto nts = yd.events(); ts.insert(ts.end(), nts.begin(), nts.end()); } sort(ts.begin(), ts.end()); double ans = 1e18; for (double t : ts) { double now = xd.get(t) * yd.get(t); mins(ans, now); } cout << ans << "\n"; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout << setprecision(9); int T = 1; //~ cin >> T; while (T--) { test_case(); } return 0; }
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> oset; #define sim template <class c #define ris return *this #define dor > debug &operator<< #define eni(x) \ sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<( \ c i) { sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c *x) -> decltype(cerr << *x, 0); sim > char dud(...); struct debug { #ifdef LOCAL ~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair<b, c> d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; } #else sim dor(const c &) { ris; } #endif } ; #define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " using ll = long long; #define mins(x, y) x = min(x, y) #define maxs(x, y) x = max(x, y) const double inf = 1e10; struct D { vector<double> l, r; D() : l(3, inf), r(3, -inf) {} void add(double x, int v) { ++v; mins(l[v], x); maxs(r[v], x); } double get(double t) { double nl = inf, nr = -inf; for (int i = 0; i < 3; i++) { mins(nl, l[i] + i * t); maxs(nr, r[i] + i * t); } return nr - nl; } vector<double> events() { vector<double> ts; for (int i = 0; i < 3; i++) { for (int j = 0; j < i; j++) { { double t = (l[j] - l[i]) / (i - j); if (t > 0) ts.push_back(t); } { double t = (r[j] - r[i]) / (i - j); if (t > 0) ts.push_back(t); } } } return ts; } }; void test_case() { int n; cin >> n; D xd, yd; for (int i = 0; i < n; i++) { int x, y; char d; cin >> x >> y >> d; if (d == 'L') xd.add(x, -1), yd.add(y, 0); if (d == 'R') xd.add(x, 1), yd.add(y, 0); if (d == 'U') xd.add(x, 0), yd.add(y, 1); if (d == 'D') xd.add(x, 0), yd.add(y, -1); } vector<double> ts; ts.push_back(0); ts.push_back(inf); { auto nts = xd.events(); ts.insert(ts.end(), nts.begin(), nts.end()); } { auto nts = yd.events(); ts.insert(ts.end(), nts.begin(), nts.end()); } sort(ts.begin(), ts.end()); double ans = 1e18; for (double t : ts) { double now = xd.get(t) * yd.get(t); mins(ans, now); } cout << ans << "\n"; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout << setprecision(10); int T = 1; //~ cin >> T; while (T--) { test_case(); } return 0; }
[ "misc.opposites", "expression.operator.compare.change", "assignment.value.change", "call.arguments.change", "expression.operation.binary.change", "literal.number.change" ]
833,026
833,025
u306697932
cpp
p03004
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <string> #include <time.h> #include <utility> #include <vector> #define ll int64_t #define Rep(i, n) for (ll i = 0; i < n; i++) using namespace std; typedef vector<ll> vec; typedef vector<vec> mat; const ll inf = 1LL << 60; template <class T> inline void chmin(T &a, T b) { if (a > b) { a = b; } } template <class T> inline void chmax(T &a, T b) { if (a < b) { a = b; } } void printvec(vec &v) { Rep(i, (ll)v.size()) { cout << v[i] << " \n"[i + 1 == (ll)v.size()]; } } int main() { cin.tie(0); ios::sync_with_stdio(false); ll N; cin >> N; set<ll> xr, xl, xfixed, yr, yl, yfixed; Rep(i, N) { ll x, y; char d; cin >> x >> y >> d; x *= 2; y *= 2; switch (d) { case 'R': xr.insert(x); yfixed.insert(y); break; case 'L': xl.insert(x); yfixed.insert(y); break; case 'U': xfixed.insert(x); yr.insert(y); break; case 'D': xfixed.insert(x); yl.insert(y); break; default: break; } } // cout << "xr\n"; // for (ll e : xr) { // cout << e << "\n"; // } // cout << "xfixed\n"; // for (ll e : xfixed) cout << e << "\n"; // cout << "xl\n"; // for (ll e : xl) cout << e << "\n"; set<ll> candidate; candidate.insert(0); if (xfixed.empty() and xl.empty() or xl.empty() and xr.empty() or xr.empty() and xfixed.empty()) { } else if (xr.empty()) { ll xmax2 = *(--xfixed.end()); ll xmax3 = *(--xl.end()); ll t2 = max<ll>(0, xmax3 - xmax2); candidate.insert(t2); } else if (xfixed.empty()) { ll xmax1 = *(--xr.end()); ll xmax3 = *(--xl.end()); ll t3 = max<ll>(0, (xmax3 - xmax1) / 2); candidate.insert(t3); } else if (xl.empty()) { ll xmax1 = *(--xr.end()); ll xmax2 = *(--xfixed.end()); ll t1 = max<ll>(0, xmax2 - xmax1); candidate.insert(t1); } else { ll xmax1 = *(--xr.end()); ll xmax2 = *(--xfixed.end()); ll xmax3 = *(--xl.end()); ll t1 = max<ll>(0, xmax2 - xmax1); ll t2 = max<ll>(0, xmax3 - xmax2); ll t3 = max<ll>(0, (xmax3 - xmax1) / 2); candidate.insert(t1); candidate.insert(t2); candidate.insert(t3); } if (xfixed.empty() and xl.empty() or xl.empty() and xr.empty() or xr.empty() and xfixed.empty()) { } else if (xr.empty()) { ll xmax2 = *xfixed.begin(); ll xmax3 = *xl.begin(); ll t2 = max<ll>(0, xmax3 - xmax2); candidate.insert(t2); } else if (xfixed.empty()) { ll xmax1 = *xr.begin(); ll xmax3 = *xl.begin(); ll t3 = max<ll>(0, (xmax3 - xmax1) / 2); candidate.insert(t3); } else if (xl.empty()) { ll xmax1 = *xr.begin(); ll xmax2 = *xfixed.begin(); ll t1 = max<ll>(0, xmax2 - xmax1); candidate.insert(t1); } else { ll xmax1 = *xr.begin(); ll xmax2 = *xfixed.begin(); ll xmax3 = *xl.begin(); ll t1 = max<ll>(0, xmax2 - xmax1); ll t2 = max<ll>(0, xmax3 - xmax2); ll t3 = max<ll>(0, (xmax3 - xmax1) / 2); candidate.insert(t1); candidate.insert(t2); candidate.insert(t3); } if (yfixed.empty() and yl.empty() or yl.empty() and yr.empty() or yr.empty() and yfixed.empty()) { } else if (yr.empty()) { ll xmax2 = *(--yfixed.end()); ll xmax3 = *(--yl.end()); ll t2 = max<ll>(0, xmax3 - xmax2); candidate.insert(t2); } else if (yfixed.empty()) { ll xmax1 = *(--yr.end()); ll xmax3 = *(--yl.end()); ll t3 = max<ll>(0, (xmax3 - xmax1) / 2); candidate.insert(t3); } else if (yl.empty()) { ll xmax1 = *(--yr.end()); ll xmax2 = *(--yfixed.end()); ll t1 = max<ll>(0, xmax2 - xmax1); candidate.insert(t1); } else { ll xmax1 = *(--yr.end()); ll xmax2 = *(--yfixed.end()); ll xmax3 = *(--yl.end()); ll t1 = max<ll>(0, xmax2 - xmax1); ll t2 = max<ll>(0, xmax3 - xmax2); ll t3 = max<ll>(0, (xmax3 - xmax1) / 2); candidate.insert(t1); candidate.insert(t2); candidate.insert(t3); } if (yfixed.empty() and yl.empty() or yl.empty() and yr.empty() or yr.empty() and yfixed.empty()) { } else if (yr.empty()) { ll xmax2 = *yfixed.begin(); ll xmax3 = *yl.begin(); ll t2 = max<ll>(0, xmax3 - xmax2); candidate.insert(t2); } else if (yfixed.empty()) { ll xmax1 = *yr.begin(); ll xmax3 = *yl.begin(); ll t3 = max<ll>(0, (xmax3 - xmax1) / 2); candidate.insert(t3); } else if (yl.empty()) { ll xmax1 = *yr.begin(); ll xmax2 = *yfixed.begin(); ll t1 = max<ll>(0, xmax2 - xmax1); candidate.insert(t1); } else { ll xmax1 = *yr.begin(); ll xmax2 = *yfixed.begin(); ll xmax3 = *yl.begin(); ll t1 = max<ll>(0, xmax2 - xmax1); ll t2 = max<ll>(0, xmax3 - xmax2); ll t3 = max<ll>(0, (xmax3 - xmax1) / 2); candidate.insert(t1); candidate.insert(t2); candidate.insert(t3); } ll ans = inf; for (ll t : candidate) { // cout << t << "\n"; ll xmax = -inf; if (xr.size()) chmax(xmax, *(--xr.end()) + t); if (xfixed.size()) chmax(xmax, *(--xfixed.end())); if (xl.size()) chmax(xmax, *(--xl.end()) - t); ll xmin = inf; if (xr.size()) chmin(xmin, *(xr.begin()) + t); if (xfixed.size()) chmin(xmin, *(xfixed.begin())); if (xl.size()) chmin(xmin, *(xl.begin())); ll ymax = -inf; if (yr.size()) chmax(ymax, *(--yr.end()) + t); if (yfixed.size()) chmax(ymax, *(--yfixed.end())); if (yl.size()) chmax(ymax, *(--yl.end()) - t); ll ymin = inf; if (yr.size()) chmin(ymin, *yr.begin() + t); if (yfixed.size()) chmin(ymin, *yfixed.begin()); if (yl.size()) chmin(ymin, *yl.begin()); // cout << xmax << " " << xmin << " " << ymax << " " << ymin << "\n"; // cout << (xmax-xmin) * (ymax-ymin) << "\n"; chmin(ans, (xmax - xmin) * (ymax - ymin)); } cout << fixed << setprecision(10) << ans / (long double)4.0 << endl; }
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <string> #include <time.h> #include <utility> #include <vector> #define ll int64_t #define Rep(i, n) for (ll i = 0; i < n; i++) using namespace std; typedef vector<ll> vec; typedef vector<vec> mat; const ll inf = 1LL << 60; template <class T> inline void chmin(T &a, T b) { if (a > b) { a = b; } } template <class T> inline void chmax(T &a, T b) { if (a < b) { a = b; } } void printvec(vec &v) { Rep(i, (ll)v.size()) { cout << v[i] << " \n"[i + 1 == (ll)v.size()]; } } int main() { cin.tie(0); ios::sync_with_stdio(false); ll N; cin >> N; set<ll> xr, xl, xfixed, yr, yl, yfixed; Rep(i, N) { ll x, y; char d; cin >> x >> y >> d; x *= 2; y *= 2; switch (d) { case 'R': xr.insert(x); yfixed.insert(y); break; case 'L': xl.insert(x); yfixed.insert(y); break; case 'U': xfixed.insert(x); yr.insert(y); break; case 'D': xfixed.insert(x); yl.insert(y); break; default: break; } } // cout << "xr\n"; // for (ll e : xr) { // cout << e << "\n"; // } // cout << "xfixed\n"; // for (ll e : xfixed) cout << e << "\n"; // cout << "xl\n"; // for (ll e : xl) cout << e << "\n"; // cout << "yr\n"; // for (ll e : yr) cout << e << "\n"; // cout << "yfixed\n"; // for (ll e : yfixed) cout << e << "\n"; // cout << "yl\n"; // for (ll e : yl) cout << e << "\n"; set<ll> candidate; candidate.insert(0); if (xfixed.empty() and xl.empty() or xl.empty() and xr.empty() or xr.empty() and xfixed.empty()) { } else if (xr.empty()) { ll xmax2 = *(--xfixed.end()); ll xmax3 = *(--xl.end()); ll t2 = max<ll>(0, xmax3 - xmax2); candidate.insert(t2); } else if (xfixed.empty()) { ll xmax1 = *(--xr.end()); ll xmax3 = *(--xl.end()); ll t3 = max<ll>(0, (xmax3 - xmax1) / 2); candidate.insert(t3); } else if (xl.empty()) { ll xmax1 = *(--xr.end()); ll xmax2 = *(--xfixed.end()); ll t1 = max<ll>(0, xmax2 - xmax1); candidate.insert(t1); } else { ll xmax1 = *(--xr.end()); ll xmax2 = *(--xfixed.end()); ll xmax3 = *(--xl.end()); ll t1 = max<ll>(0, xmax2 - xmax1); ll t2 = max<ll>(0, xmax3 - xmax2); ll t3 = max<ll>(0, (xmax3 - xmax1) / 2); candidate.insert(t1); candidate.insert(t2); candidate.insert(t3); } if (xfixed.empty() and xl.empty() or xl.empty() and xr.empty() or xr.empty() and xfixed.empty()) { } else if (xr.empty()) { ll xmax2 = *xfixed.begin(); ll xmax3 = *xl.begin(); ll t2 = max<ll>(0, xmax3 - xmax2); candidate.insert(t2); } else if (xfixed.empty()) { ll xmax1 = *xr.begin(); ll xmax3 = *xl.begin(); ll t3 = max<ll>(0, (xmax3 - xmax1) / 2); candidate.insert(t3); } else if (xl.empty()) { ll xmax1 = *xr.begin(); ll xmax2 = *xfixed.begin(); ll t1 = max<ll>(0, xmax2 - xmax1); candidate.insert(t1); } else { ll xmax1 = *xr.begin(); ll xmax2 = *xfixed.begin(); ll xmax3 = *xl.begin(); ll t1 = max<ll>(0, xmax2 - xmax1); ll t2 = max<ll>(0, xmax3 - xmax2); ll t3 = max<ll>(0, (xmax3 - xmax1) / 2); candidate.insert(t1); candidate.insert(t2); candidate.insert(t3); } if (yfixed.empty() and yl.empty() or yl.empty() and yr.empty() or yr.empty() and yfixed.empty()) { } else if (yr.empty()) { ll xmax2 = *(--yfixed.end()); ll xmax3 = *(--yl.end()); ll t2 = max<ll>(0, xmax3 - xmax2); candidate.insert(t2); } else if (yfixed.empty()) { ll xmax1 = *(--yr.end()); ll xmax3 = *(--yl.end()); ll t3 = max<ll>(0, (xmax3 - xmax1) / 2); candidate.insert(t3); } else if (yl.empty()) { ll xmax1 = *(--yr.end()); ll xmax2 = *(--yfixed.end()); ll t1 = max<ll>(0, xmax2 - xmax1); candidate.insert(t1); } else { ll xmax1 = *(--yr.end()); ll xmax2 = *(--yfixed.end()); ll xmax3 = *(--yl.end()); ll t1 = max<ll>(0, xmax2 - xmax1); ll t2 = max<ll>(0, xmax3 - xmax2); ll t3 = max<ll>(0, (xmax3 - xmax1) / 2); candidate.insert(t1); candidate.insert(t2); candidate.insert(t3); } if (yfixed.empty() and yl.empty() or yl.empty() and yr.empty() or yr.empty() and yfixed.empty()) { } else if (yr.empty()) { ll xmax2 = *yfixed.begin(); ll xmax3 = *yl.begin(); ll t2 = max<ll>(0, xmax3 - xmax2); candidate.insert(t2); } else if (yfixed.empty()) { ll xmax1 = *yr.begin(); ll xmax3 = *yl.begin(); ll t3 = max<ll>(0, (xmax3 - xmax1) / 2); candidate.insert(t3); } else if (yl.empty()) { ll xmax1 = *yr.begin(); ll xmax2 = *yfixed.begin(); ll t1 = max<ll>(0, xmax2 - xmax1); candidate.insert(t1); } else { ll xmax1 = *yr.begin(); ll xmax2 = *yfixed.begin(); ll xmax3 = *yl.begin(); ll t1 = max<ll>(0, xmax2 - xmax1); ll t2 = max<ll>(0, xmax3 - xmax2); ll t3 = max<ll>(0, (xmax3 - xmax1) / 2); candidate.insert(t1); candidate.insert(t2); candidate.insert(t3); } ll ans = inf; for (ll t : candidate) { // cout << t << "\n"; ll xmax = -inf; if (xr.size()) chmax(xmax, *(--xr.end()) + t); if (xfixed.size()) chmax(xmax, *(--xfixed.end())); if (xl.size()) chmax(xmax, *(--xl.end()) - t); ll xmin = inf; if (xr.size()) chmin(xmin, *(xr.begin()) + t); if (xfixed.size()) chmin(xmin, *(xfixed.begin())); if (xl.size()) chmin(xmin, *(xl.begin()) - t); ll ymax = -inf; if (yr.size()) chmax(ymax, *(--yr.end()) + t); if (yfixed.size()) chmax(ymax, *(--yfixed.end())); if (yl.size()) chmax(ymax, *(--yl.end()) - t); ll ymin = inf; if (yr.size()) chmin(ymin, *yr.begin() + t); if (yfixed.size()) chmin(ymin, *yfixed.begin()); if (yl.size()) chmin(ymin, *yl.begin() - t); // cout << xmax << " " << xmin << " " << ymax << " " << ymin << "\n"; // cout << (xmax-xmin) * (ymax-ymin) << "\n"; chmin(ans, (xmax - xmin) * (ymax - ymin)); } cout << fixed << setprecision(10) << ans / (long double)4.0 << endl; }
[ "expression.operation.binary.add" ]
833,041
833,042
u017271745
cpp
p03004
#include <bits/stdc++.h> using namespace std; inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } typedef long long ll; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<long long> VL; typedef vector<vector<long long>> VVL; typedef vector<string> VS; typedef pair<int, int> P; typedef tuple<int, int, int> tpl; #define ALL(a) (a).begin(), (a).end() #define SORT(c) sort((c).begin(), (c).end()) #define REVERSE(c) reverse((c).begin(), (c).end()) #define LB(a, x) lower_bound((a).begin(), (a).end(), x) - (a).begin() #define UB(a, x) upper_bound((a).begin(), (a).end(), x) - (a).begin() #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) #define RFOR(i, a, b) for (int i = (a)-1; i >= (b); --i) #define RREP(i, n) RFOR(i, n, 0) #define en "\n" constexpr double EPS = 1e-9; constexpr double PI = 3.1415926535897932; constexpr int INF = 2147483647; constexpr long long LINF = 1LL << 60; constexpr long long MOD = 1000000007; // 998244353; #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl; 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; } void Main() { int N; cin >> N; vector<long double> x(N), y(N); vector<char> dir(N); VI l, r, u, d, lr, ud; REP(i, N) { cin >> x[i] >> y[i] >> dir[i]; if (dir[i] == 'U') { u.push_back(i); ud.push_back(i); } else if (dir[i] == 'D') { d.push_back(i); ud.push_back(i); } else if (dir[i] == 'L') { l.push_back(i); lr.push_back(i); } else { r.push_back(i); lr.push_back(i); } } auto compx = [&](int i, int j) { return x[i] < x[j]; }; auto compy = [&](int i, int j) { return y[i] < y[j]; }; sort(ALL(l), compx); sort(ALL(r), compx); sort(ALL(ud), compx); sort(ALL(u), compy); sort(ALL(d), compy); sort(ALL(lr), compy); VI xmin, xmax, ymin, ymax; vector<long double> cand_t{0}; if (l.size()) { xmin.push_back(l[0]); xmax.push_back(l.back()); } if (r.size()) { REP(i, xmin.size()) { long double t = (x[xmin[i]] - x[r[0]]) / 2; if (t >= 0) cand_t.push_back(t); t = (x[xmax[i]] - x[r.back()]) / 2; if (t >= 0) cand_t.push_back(t); } xmin.push_back(r[0]); xmax.push_back(r.back()); } if (ud.size()) { REP(i, xmin.size()) { if (dir[xmin[i]] == 'L' && x[ud[0]] <= x[xmin[i]]) cand_t.push_back(x[xmin[i]] - x[ud[0]]); else if (dir[xmin[i]] == 'R' && x[xmin[i]] <= x[ud[0]]) cand_t.push_back(x[ud[0]] - x[xmin[i]]); if (dir[xmax[i]] == 'L' && x[ud.back()] <= x[xmax[i]]) cand_t.push_back(x[xmax[i]] - x[ud.back()]); else if (dir[xmax[i]] == 'R' && x[xmax[i]] <= x[ud.back()]) cand_t.push_back(x[ud.back()] - x[xmax[i]]); } xmin.push_back(ud[0]); xmax.push_back(ud.back()); } if (d.size()) { ymin.push_back(d[0]); ymax.push_back(d.back()); } if (u.size()) { REP(i, ymin.size()) { long double t = (y[ymin[i]] - y[u[0]]) / 2; if (t >= 0) cand_t.push_back(t); t = (y[ymax[i]] - y[u.back()]) / 2; if (t >= 0) cand_t.push_back(t); } ymin.push_back(u[0]); ymax.push_back(u.back()); } if (lr.size()) { REP(i, ymin.size()) { if (dir[ymin[i]] == 'U' && y[lr[0]] <= y[ymin[i]]) cand_t.push_back(y[ymin[i]] - y[lr[0]]); else if (dir[ymin[i]] == 'D' && y[ymin[i]] <= y[lr[0]]) cand_t.push_back(y[lr[0]] - y[ymin[i]]); if (dir[ymax[i]] == 'U' && y[lr.back()] <= y[ymax[i]]) cand_t.push_back(y[ymax[i]] - y[lr.back()]); else if (dir[ymax[i]] == 'D' && y[ymax[i]] <= y[lr.back()]) cand_t.push_back(y[lr.back()] - y[ymax[i]]); } ymin.push_back(lr[0]); ymax.push_back(lr.back()); } long double ans = 1e18; int K = cand_t.size(); REP(i, K) { long double t = cand_t[i]; long double xmn = 1e15, xmx = -1e15, ymn = 1e15, ymx = -1e15; for (int j : xmin) { if (dir[j] == 'L') chmin(xmn, -t + x[j]); else if (dir[j] == 'R') chmin(xmn, t + x[j]); else chmin(xmn, x[j]); } for (int j : xmax) { if (dir[j] == 'L') chmax(xmx, -t + x[j]); else if (dir[j] == 'R') chmax(xmx, t + x[j]); else chmax(xmx, x[j]); } for (int j : ymin) { if (dir[j] == 'D') chmin(ymn, -t + y[j]); else if (dir[j] == 'U') chmin(ymn, t + y[j]); else chmin(ymn, y[j]); } for (int j : ymax) { if (dir[j] == 'D') chmax(ymx, -t + y[j]); else if (dir[j] == 'U') chmax(ymx, t + y[j]); else chmax(ymx, y[j]); } chmin(ans, (xmx - xmn) * (ymx - ymn)); } cout << ans << en; return; } int main(void) { cin.tie(0); ios_base::sync_with_stdio(0); cout << fixed << setprecision(15); int t = 1; // cin>>t; REP(_, t) { Main(); } return 0; }
#include <bits/stdc++.h> using namespace std; inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } typedef long long ll; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<long long> VL; typedef vector<vector<long long>> VVL; typedef vector<string> VS; typedef pair<int, int> P; typedef tuple<int, int, int> tpl; #define ALL(a) (a).begin(), (a).end() #define SORT(c) sort((c).begin(), (c).end()) #define REVERSE(c) reverse((c).begin(), (c).end()) #define LB(a, x) lower_bound((a).begin(), (a).end(), x) - (a).begin() #define UB(a, x) upper_bound((a).begin(), (a).end(), x) - (a).begin() #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) #define RFOR(i, a, b) for (int i = (a)-1; i >= (b); --i) #define RREP(i, n) RFOR(i, n, 0) #define en "\n" constexpr double EPS = 1e-9; constexpr double PI = 3.1415926535897932; constexpr int INF = 2147483647; constexpr long long LINF = 1LL << 60; constexpr long long MOD = 1000000007; // 998244353; #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl; 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; } void Main() { int N; cin >> N; vector<long double> x(N), y(N); vector<char> dir(N); VI l, r, u, d, lr, ud; REP(i, N) { cin >> x[i] >> y[i] >> dir[i]; if (dir[i] == 'U') { u.push_back(i); ud.push_back(i); } else if (dir[i] == 'D') { d.push_back(i); ud.push_back(i); } else if (dir[i] == 'L') { l.push_back(i); lr.push_back(i); } else { r.push_back(i); lr.push_back(i); } } auto compx = [&](int i, int j) { return x[i] < x[j]; }; auto compy = [&](int i, int j) { return y[i] < y[j]; }; sort(ALL(l), compx); sort(ALL(r), compx); sort(ALL(ud), compx); sort(ALL(u), compy); sort(ALL(d), compy); sort(ALL(lr), compy); VI xmin, xmax, ymin, ymax; vector<long double> cand_t{0}; if (l.size()) { xmin.push_back(l[0]); xmax.push_back(l.back()); } if (r.size()) { REP(i, xmin.size()) { long double t = (x[xmin[i]] - x[r[0]]) / 2; if (t >= 0) cand_t.push_back(t); t = (x[xmax[i]] - x[r.back()]) / 2; if (t >= 0) cand_t.push_back(t); } xmin.push_back(r[0]); xmax.push_back(r.back()); } if (ud.size()) { REP(i, xmin.size()) { if (dir[xmin[i]] == 'L' && x[ud[0]] <= x[xmin[i]]) cand_t.push_back(x[xmin[i]] - x[ud[0]]); else if (dir[xmin[i]] == 'R' && x[xmin[i]] <= x[ud[0]]) cand_t.push_back(x[ud[0]] - x[xmin[i]]); if (dir[xmax[i]] == 'L' && x[ud.back()] <= x[xmax[i]]) cand_t.push_back(x[xmax[i]] - x[ud.back()]); else if (dir[xmax[i]] == 'R' && x[xmax[i]] <= x[ud.back()]) cand_t.push_back(x[ud.back()] - x[xmax[i]]); } xmin.push_back(ud[0]); xmax.push_back(ud.back()); } if (d.size()) { ymin.push_back(d[0]); ymax.push_back(d.back()); } if (u.size()) { REP(i, ymin.size()) { long double t = (y[ymin[i]] - y[u[0]]) / 2; if (t >= 0) cand_t.push_back(t); t = (y[ymax[i]] - y[u.back()]) / 2; if (t >= 0) cand_t.push_back(t); } ymin.push_back(u[0]); ymax.push_back(u.back()); } if (lr.size()) { REP(i, ymin.size()) { if (dir[ymin[i]] == 'D' && y[lr[0]] <= y[ymin[i]]) cand_t.push_back(y[ymin[i]] - y[lr[0]]); else if (dir[ymin[i]] == 'U' && y[ymin[i]] <= y[lr[0]]) cand_t.push_back(y[lr[0]] - y[ymin[i]]); if (dir[ymax[i]] == 'D' && y[lr.back()] <= y[ymax[i]]) cand_t.push_back(y[ymax[i]] - y[lr.back()]); else if (dir[ymax[i]] == 'U' && y[ymax[i]] <= y[lr.back()]) cand_t.push_back(y[lr.back()] - y[ymax[i]]); } ymin.push_back(lr[0]); ymax.push_back(lr.back()); } long double ans = 1e18; int K = cand_t.size(); REP(i, K) { long double t = cand_t[i]; long double xmn = 1e15, xmx = -1e15, ymn = 1e15, ymx = -1e15; for (int j : xmin) { if (dir[j] == 'L') chmin(xmn, -t + x[j]); else if (dir[j] == 'R') chmin(xmn, t + x[j]); else chmin(xmn, x[j]); } for (int j : xmax) { if (dir[j] == 'L') chmax(xmx, -t + x[j]); else if (dir[j] == 'R') chmax(xmx, t + x[j]); else chmax(xmx, x[j]); } for (int j : ymin) { if (dir[j] == 'D') chmin(ymn, -t + y[j]); else if (dir[j] == 'U') chmin(ymn, t + y[j]); else chmin(ymn, y[j]); } for (int j : ymax) { if (dir[j] == 'D') chmax(ymx, -t + y[j]); else if (dir[j] == 'U') chmax(ymx, t + y[j]); else chmax(ymx, y[j]); } chmin(ans, (xmx - xmn) * (ymx - ymn)); } cout << ans << en; return; } int main(void) { cin.tie(0); ios_base::sync_with_stdio(0); cout << fixed << setprecision(15); int t = 1; // cin>>t; REP(_, t) { Main(); } return 0; }
[ "literal.string.change", "control_flow.branch.if.condition.change" ]
833,047
833,048
u934272719
cpp
p03004
#include <algorithm> #include <array> #include <cmath> #include <complex> #include <cstdio> #include <deque> #include <float.h> #include <functional> #include <iomanip> #include <iostream> #include <limits.h> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <vector> using namespace std; #define i64 long long #define int long long #define I32_MAX 2147483647 #define I64_MAX 9223372036854775807LL #define I64_MAX2 1223372036854775807LL #define INF I64_MAX2 #define MOD 1000000007 #define MEM_SIZE 10000 #define DEBUG_OUT true #define ALL(x) (x).begin(), (x).end() // int DP[MEM_SIZE][MEM_SIZE] = {0}; // int GMEM[MEM_SIZE][MEM_SIZE] = {0}; template <typename T> void DEBUG(T e) { if (DEBUG_OUT == false) return; std::cout << e << std::endl; } template <typename T> void DEBUG(const std::vector<T> &v) { if (DEBUG_OUT == false) return; for (const auto &e : v) { std::cout << e << " "; } std::cout << std::endl; } template <typename T> void DEBUG(const std::vector<std::vector<T>> &vv) { if (DEBUG_OUT == false) return; for (const auto &v : vv) { DEBUG(v); } } template <class T, class X> void DEBUG(X d, T e) { if (DEBUG_OUT == false) return; std::cout << d << " "; DEBUG(e); }; template <class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } } template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); } template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); } // CODE int dx[]{1, -1, 0, 0}, dy[]{0, 0, 1, -1}; double fn(double t, int mode, vector<vector<int>> &data) { double MIN = -1, MAX = -1; for (int i = 0; i < data.size(); i++) { double X; if (mode == 0) X = data[i][0] + dx[data[i][2]] * t; else X = data[i][1] + dy[data[i][2]] * t; if (i == 0) { MIN = MAX = X; } else { MIN = min(MIN, X); MAX = max(MAX, X); } } return MAX - MIN; } void solve(void) { int N; cin >> N; vector<vector<int>> data(N, vector<int>(3)); for (int i = 0; i < N; i++) { int X, Y; char D; cin >> X >> Y >> D; data[i][0] = X; data[i][1] = Y; if (D == 'R') data[i][2] = 0; else if (D == 'L') data[i][2] = 1; else if (D == 'U') data[i][2] = 2; else if (D == 'D') data[i][2] = 3; } double l = 0, r = 1e15; for (int i = 0; i < 200; i++) { double l1 = (l + l + r) / 3; double l2 = (l + r + r) / 3; if (fn(l1, 0, data) + fn(l1, 1, data) < fn(l2, 0, data) * fn(l2, 1, data)) r = l2; else l = l1; } cout << fn(l, 0, data) * fn(l, 1, data) << endl; return; } int32_t main(int32_t argc, const char *argv[]) { std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout << std::fixed; std::cout << std::setprecision(9); solve(); return 0; }
#include <algorithm> #include <array> #include <cmath> #include <complex> #include <cstdio> #include <deque> #include <float.h> #include <functional> #include <iomanip> #include <iostream> #include <limits.h> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <vector> using namespace std; #define i64 long long #define int long long #define I32_MAX 2147483647 #define I64_MAX 9223372036854775807LL #define I64_MAX2 1223372036854775807LL #define INF I64_MAX2 #define MOD 1000000007 #define MEM_SIZE 10000 #define DEBUG_OUT true #define ALL(x) (x).begin(), (x).end() // int DP[MEM_SIZE][MEM_SIZE] = {0}; // int GMEM[MEM_SIZE][MEM_SIZE] = {0}; template <typename T> void DEBUG(T e) { if (DEBUG_OUT == false) return; std::cout << e << std::endl; } template <typename T> void DEBUG(const std::vector<T> &v) { if (DEBUG_OUT == false) return; for (const auto &e : v) { std::cout << e << " "; } std::cout << std::endl; } template <typename T> void DEBUG(const std::vector<std::vector<T>> &vv) { if (DEBUG_OUT == false) return; for (const auto &v : vv) { DEBUG(v); } } template <class T, class X> void DEBUG(X d, T e) { if (DEBUG_OUT == false) return; std::cout << d << " "; DEBUG(e); }; template <class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } } template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); } template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); } // CODE double dx[]{1, -1, 0, 0}, dy[]{0, 0, 1, -1}; double fn(double t, int mode, vector<vector<int>> &data) { double MIN = INF, MAX = -1; for (int i = 0; i < data.size(); i++) { double X; if (mode == 0) X = data[i][0] + dx[data[i][2]] * t; else X = data[i][1] + dy[data[i][2]] * t; if (i == 0) { MIN = MAX = X; } else { MIN = min(MIN, X); MAX = max(MAX, X); } } return MAX - MIN; } void solve(void) { int N; cin >> N; vector<vector<int>> data(N, vector<int>(3)); for (int i = 0; i < N; i++) { int X, Y; char D; cin >> X >> Y >> D; data[i][0] = X; data[i][1] = Y; if (D == 'R') data[i][2] = 0; else if (D == 'L') data[i][2] = 1; else if (D == 'U') data[i][2] = 2; else if (D == 'D') data[i][2] = 3; } double l = 0, r = 1e15; for (int i = 0; i <= 200; i++) { double l1 = (l + l + r) / 3; double l2 = (l + r + r) / 3; if (fn(l1, 0, data) * fn(l1, 1, data) < fn(l2, 0, data) * fn(l2, 1, data)) r = l2; else l = l1; // DEBUG(l); } cout << fn(l, 0, data) * fn(l, 1, data) << endl; return; } int32_t main(int32_t argc, const char *argv[]) { std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout << std::fixed; std::cout << std::setprecision(9); solve(); return 0; }
[ "variable_declaration.type.primitive.change", "variable_declaration.value.change", "identifier.replace.add", "literal.replace.remove", "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change", "expression.operator.a...
833,072
833,073
u221285045
cpp
p03004
#pragma GCC optimize("O3") #include <bits/stdc++.h> #define ll long long #define rep2(i, a, b) for (ll i = a; i <= b; ++i) #define rep(i, n) for (ll i = 0; i < n; i++) #define rep3(i, a, b) for (ll i = a; i >= b; i--) #define pii pair<int, int> #define pll pair<ll, ll> #define pq priority_queue #define pb push_back #define eb emplace_back #define vec vector<int> #define vecll vector<ll> #define vecpii vector<pii> #define vec2(a, b) vector<vec>(a, vec(b)) #define vec2ll(a, b) vector<vecll>(a, vecll(b)) #define vec3(a, b, c) vector<vector<vec>>(a, vec2(b, c)) #define vec3ll(a, b, c) vector<vector<vecll>>(a, vec2ll(b, c)) #define fi first #define se second #define endl "\n" #define all(c) begin(c), end(c) #define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); #define lb(c, x) distance(c.begin(), lower_bound(all(c), x)) #define ub(c, x) distance(c.begin(), upper_bound(all(c), x)) #define MM " " using namespace std; int in() { int x; cin >> x; return x; } ll lin() { ll x; cin >> x; return x; } 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; } template <class T> inline void print(pair<T, T> p) { cout << "(" << p.first << "," << p.second << ") "; } template <class T> inline void print(vector<pair<T, T>> v) { for (auto e : v) print(e); cout << endl; } template <class T> inline void print(T v) { for (auto e : v) cout << e << " "; cout << endl; } void go(); main() { ios int Testcases = 1; while (Testcases--) { go(); } return 0; } #define double long double vector<pii> x, y; int n; double solve(double t) { double lx = 1e15, rx = -1e15; double ly = 1e15, ry = -1e15; rep(i, n) { chmin(lx, (double)(x[i].first + t * x[i].second)); chmax(rx, (double)(x[i].first + t * x[i].second)); chmin(ly, (double)(y[i].first + t * y[i].second)); chmax(ry, (double)(y[i].first + t * y[i].second)); } return (rx - lx) * (ry - ly); } void go() { n = in(); rep(i, n) { int a = in(), b = in(); char c; cin >> c; switch (c) { case 'R': x.eb(a, 1); y.eb(b, 0); break; case 'L': x.eb(a, -1); y.eb(b, 0); break; case 'U': x.eb(a, 0); y.eb(b, 1); break; case 'D': x.eb(a, 0); y.eb(b, -1); break; } } double l = 0, r = 1e9; int iter = 100; cout << fixed << setprecision(15); while (iter--) { double t1 = (l * 2 + r) / 3.0, t2 = (l + r * 2) / 3.0; double s1 = solve(t1), s2 = solve(t2); // cout<<t1<<" "<<t2<<endl; // cout<<s1<<" "<<s2<<endl; if (s1 < s2) { r = t2; } else l = t1; } cout << solve(l) << endl; }
#pragma GCC optimize("O3") #include <bits/stdc++.h> #define ll long long #define rep2(i, a, b) for (ll i = a; i <= b; ++i) #define rep(i, n) for (ll i = 0; i < n; i++) #define rep3(i, a, b) for (ll i = a; i >= b; i--) #define pii pair<int, int> #define pll pair<ll, ll> #define pq priority_queue #define pb push_back #define eb emplace_back #define vec vector<int> #define vecll vector<ll> #define vecpii vector<pii> #define vec2(a, b) vector<vec>(a, vec(b)) #define vec2ll(a, b) vector<vecll>(a, vecll(b)) #define vec3(a, b, c) vector<vector<vec>>(a, vec2(b, c)) #define vec3ll(a, b, c) vector<vector<vecll>>(a, vec2ll(b, c)) #define fi first #define se second #define endl "\n" #define all(c) begin(c), end(c) #define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); #define lb(c, x) distance(c.begin(), lower_bound(all(c), x)) #define ub(c, x) distance(c.begin(), upper_bound(all(c), x)) #define MM " " using namespace std; int in() { int x; cin >> x; return x; } ll lin() { ll x; cin >> x; return x; } 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; } template <class T> inline void print(pair<T, T> p) { cout << "(" << p.first << "," << p.second << ") "; } template <class T> inline void print(vector<pair<T, T>> v) { for (auto e : v) print(e); cout << endl; } template <class T> inline void print(T v) { for (auto e : v) cout << e << " "; cout << endl; } void go(); main() { ios int Testcases = 1; while (Testcases--) { go(); } return 0; } #define double long double vector<pii> x, y; int n; double solve(double t) { double lx = 1e15, rx = -1e15; double ly = 1e15, ry = -1e15; rep(i, n) { chmin(lx, (double)(x[i].first + t * x[i].second)); chmax(rx, (double)(x[i].first + t * x[i].second)); chmin(ly, (double)(y[i].first + t * y[i].second)); chmax(ry, (double)(y[i].first + t * y[i].second)); } return (rx - lx) * (ry - ly); } void go() { n = in(); rep(i, n) { int a = in(), b = in(); char c; cin >> c; switch (c) { case 'R': x.eb(a, 1); y.eb(b, 0); break; case 'L': x.eb(a, -1); y.eb(b, 0); break; case 'U': x.eb(a, 0); y.eb(b, 1); break; case 'D': x.eb(a, 0); y.eb(b, -1); break; } } double l = 0, r = 1e9; int iter = 1000; cout << fixed << setprecision(15); while (iter--) { double t1 = (l * 2 + r) / 3.0, t2 = (l + r * 2) / 3.0; double s1 = solve(t1), s2 = solve(t2); // cout<<t1<<" "<<t2<<endl; // cout<<s1<<" "<<s2<<endl; if (s1 < s2) { r = t2; } else l = t1; } cout << solve(l) << endl; }
[ "literal.number.change", "variable_declaration.value.change" ]
833,082
833,083
u495699318
cpp
p03004
#include <bits/stdc++.h> using namespace std; #define all(V) V.begin(), V.end() #define ll long long #define MOD 998244353 const double SMALL = pow(10, -12); vector<pair<double, double>> P[4]; double M[4][4], L[4][4]; void chmin(double &x, double y) { x = min(x, y); } void chmax(double &x, double y) { x = max(x, y); } double val(double T) { double xmax = LLONG_MIN, xmin = LLONG_MAX, ymax = LLONG_MIN, ymin = LLONG_MAX; chmax(xmax, max({M[0][0] - T, M[0][1] - T, M[1][0] + T, M[1][1] + T, M[2][0], M[2][1], M[3][0], M[3][1]})); chmin(xmin, min({L[0][0] - T, L[0][1] - T, L[1][0] + T, L[1][1] + T, L[2][0], L[2][1], L[3][0], L[3][1]})); chmax(ymax, max({M[2][2] + T, M[2][3] + T, M[3][2] - T, M[3][3] - T, M[0][2], M[0][3], M[1][2], M[1][3]})); chmin(ymin, min({L[2][2] + T, L[2][3] + T, L[3][2] - T, L[3][3] - T, L[0][2], L[0][3], L[1][2], L[1][3]})); // cout << T << " " << xmax << " " << xmin << " " << ymax << " " << ymin << // endl; return (xmax - xmin) * (ymax - ymin); } double tri(double x, double y, int t) { if (t > 40) return val(x); double T31 = (x * 2 + y) / 3; double T32 = (x + y * 2) / 3; double t31 = val(T31); double t32 = val(T32); if (t31 < t32) { return tri(x, T32, t + 1); } else { return tri(T31, y, t + 1); } } int main() { int N, x, y; char d; cin >> N; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { M[i][j] = LLONG_MIN; L[i][j] = LLONG_MAX; } } for (int i = 0; i < N; i++) { cin >> x >> y >> d; if (d == 'L') P[0].push_back({x, y}); else if (d == 'R') P[1].push_back({x, y}); else if (d == 'U') P[2].push_back({x, y}); else P[3].push_back({x, y}); } for (int i = 0; i < 4; i++) { for (auto j : P[i]) { chmin(L[i][0], j.first); chmax(M[i][1], j.first); chmax(M[i][2], j.second); chmin(L[i][3], j.second); } } //上下に動くものの中でx最大、x最小 vector<double> CT; double udxx = LLONG_MIN, udxn = LLONG_MAX; for (auto &i : P[3]) { chmax(udxx, i.first); chmin(udxn, i.first); } for (auto &i : P[2]) { chmax(udxx, i.first); chmin(udxn, i.first); } //左に動くものの中でx最大、最小 sort(all(P[0])); int ps1 = P[0].size(); if (ps1 != 0) { CT.push_back(udxx - P[0][ps1 - 1].first); CT.push_back(udxn - P[0][ps1 - 1].first); CT.push_back(udxx - P[0][0].first); CT.push_back(udxn - P[0][0].first); } sort(all(P[1])); int ps2 = P[1].size(); if (ps2 != 0) { CT.push_back(udxx - P[1][ps2 - 1].first); CT.push_back(udxn - P[1][ps2 - 1].first); CT.push_back(udxx - P[1][0].first); CT.push_back(udxn - P[1][0].first); } if (ps1 > 0 && ps2 > 0) { CT.push_back((P[0][ps1 - 1].first - P[1][ps2 - 1].first) / 2); CT.push_back((P[0][ps1 - 1].first - P[1][0].first) / 2); CT.push_back((P[0][0].first - P[1][ps2 - 1].first) / 2); CT.push_back((P[0][0].first - P[1][0].first) / 2); } double lryx = LLONG_MIN, lryn = LLONG_MAX; for (auto &i : P[0]) { chmax(lryx, i.second); chmax(lryn, i.second); } for (auto &i : P[1]) { chmax(lryx, i.second); chmax(lryn, i.second); } sort(all(P[2])); int ps_2 = P[2].size(); sort(all(P[3])); int ps_3 = P[3].size(); if (ps_2 > 0) { CT.push_back(lryx - P[2][ps_2 - 1].second); CT.push_back(lryx - P[2][0].second); CT.push_back(lryn - P[2][ps_2 - 1].second); CT.push_back(lryn - P[2][0].second); } if (ps_3 > 0) { CT.push_back(lryx - P[3][ps_3 - 1].second); CT.push_back(lryx - P[3][0].second); CT.push_back(lryn - P[3][ps_3 - 1].second); CT.push_back(lryn - P[3][0].second); } if (ps_2 > 0 && ps_3 > 0) { CT.push_back((P[2][ps_2 - 1].second - P[3][ps_3 - 1].second)); CT.push_back((P[2][0].second - P[3][ps_3 - 1].second)); CT.push_back((P[2][ps_2 - 1].second - P[3][0].second)); CT.push_back((P[2][0].second - P[3][0].second)); } CT.push_back(0.0); CT.push_back(0.0); for (auto &i : CT) { i = abs(i); if (i > LLONG_MAX / 3) i = 0; } sort(all(CT)); //ここまで来れば、3分探索やるだけ int cts = CT.size(); double ans = LLONG_MAX; for (int i = 1; i < cts; i++) { // cout << CT[i - 1] << " " << CT[i] << endl; chmin(ans, tri(CT[i - 1], CT[i], 1)); } printf("%.11f\n", ans); }
#include <bits/stdc++.h> using namespace std; #define all(V) V.begin(), V.end() #define ll long long #define MOD 998244353 const double SMALL = pow(10, -12); vector<pair<double, double>> P[4]; double M[4][4], L[4][4]; void chmin(double &x, double y) { x = min(x, y); } void chmax(double &x, double y) { x = max(x, y); } double val(double T) { double xmax = LLONG_MIN, xmin = LLONG_MAX, ymax = LLONG_MIN, ymin = LLONG_MAX; chmax(xmax, max({M[0][0] - T, M[0][1] - T, M[1][0] + T, M[1][1] + T, M[2][0], M[2][1], M[3][0], M[3][1]})); chmin(xmin, min({L[0][0] - T, L[0][1] - T, L[1][0] + T, L[1][1] + T, L[2][0], L[2][1], L[3][0], L[3][1]})); chmax(ymax, max({M[2][2] + T, M[2][3] + T, M[3][2] - T, M[3][3] - T, M[0][2], M[0][3], M[1][2], M[1][3]})); chmin(ymin, min({L[2][2] + T, L[2][3] + T, L[3][2] - T, L[3][3] - T, L[0][2], L[0][3], L[1][2], L[1][3]})); // cout << T << " " << xmax << " " << xmin << " " << ymax << " " << ymin << // endl; return (xmax - xmin) * (ymax - ymin); } double tri(double x, double y, int t) { if (t > 120) return val(x); double T31 = (x * 2 + y) / 3; double T32 = (x + y * 2) / 3; double t31 = val(T31); double t32 = val(T32); if (t31 < t32) { return tri(x, T32, t + 1); } else { return tri(T31, y, t + 1); } } int main() { int N, x, y; char d; cin >> N; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { M[i][j] = LLONG_MIN; L[i][j] = LLONG_MAX; } } for (int i = 0; i < N; i++) { cin >> x >> y >> d; if (d == 'L') P[0].push_back({x, y}); else if (d == 'R') P[1].push_back({x, y}); else if (d == 'U') P[2].push_back({x, y}); else P[3].push_back({x, y}); } for (int i = 0; i < 4; i++) { for (auto j : P[i]) { chmin(L[i][0], j.first); chmax(M[i][1], j.first); chmax(M[i][2], j.second); chmin(L[i][3], j.second); } } //上下に動くものの中でx最大、x最小 vector<double> CT; double udxx = LLONG_MIN, udxn = LLONG_MAX; for (auto &i : P[3]) { chmax(udxx, i.first); chmin(udxn, i.first); } for (auto &i : P[2]) { chmax(udxx, i.first); chmin(udxn, i.first); } //左に動くものの中でx最大、最小 sort(all(P[0])); int ps1 = P[0].size(); if (ps1 != 0) { CT.push_back(udxx - P[0][ps1 - 1].first); CT.push_back(udxn - P[0][ps1 - 1].first); CT.push_back(udxx - P[0][0].first); CT.push_back(udxn - P[0][0].first); } sort(all(P[1])); int ps2 = P[1].size(); if (ps2 != 0) { CT.push_back(udxx - P[1][ps2 - 1].first); CT.push_back(udxn - P[1][ps2 - 1].first); CT.push_back(udxx - P[1][0].first); CT.push_back(udxn - P[1][0].first); } if (ps1 > 0 && ps2 > 0) { CT.push_back((P[0][ps1 - 1].first - P[1][ps2 - 1].first) / 2); CT.push_back((P[0][ps1 - 1].first - P[1][0].first) / 2); CT.push_back((P[0][0].first - P[1][ps2 - 1].first) / 2); CT.push_back((P[0][0].first - P[1][0].first) / 2); } double lryx = LLONG_MIN, lryn = LLONG_MAX; for (auto &i : P[0]) { chmax(lryx, i.second); chmax(lryn, i.second); } for (auto &i : P[1]) { chmax(lryx, i.second); chmax(lryn, i.second); } sort(all(P[2])); int ps_2 = P[2].size(); sort(all(P[3])); int ps_3 = P[3].size(); if (ps_2 > 0) { CT.push_back(lryx - P[2][ps_2 - 1].second); CT.push_back(lryx - P[2][0].second); CT.push_back(lryn - P[2][ps_2 - 1].second); CT.push_back(lryn - P[2][0].second); } if (ps_3 > 0) { CT.push_back(lryx - P[3][ps_3 - 1].second); CT.push_back(lryx - P[3][0].second); CT.push_back(lryn - P[3][ps_3 - 1].second); CT.push_back(lryn - P[3][0].second); } if (ps_2 > 0 && ps_3 > 0) { CT.push_back((P[2][ps_2 - 1].second - P[3][ps_3 - 1].second)); CT.push_back((P[2][0].second - P[3][ps_3 - 1].second)); CT.push_back((P[2][ps_2 - 1].second - P[3][0].second)); CT.push_back((P[2][0].second - P[3][0].second)); } CT.push_back(0.0); CT.push_back(0.0); for (auto &i : CT) { i = abs(i); if (i > LLONG_MAX / 3) i = 0; } sort(all(CT)); //ここまで来れば、3分探索やるだけ int cts = CT.size(); double ans = LLONG_MAX; for (int i = 1; i < cts; i++) { // cout << CT[i - 1] << " " << CT[i] << endl; chmin(ans, tri(CT[i - 1], CT[i], 1)); } printf("%.11f\n", ans); }
[ "literal.number.change", "control_flow.branch.if.condition.change" ]
833,098
833,099
u045811375
cpp
p03004
#include <bits/stdc++.h> using namespace std; #define int long long #define rep(i, n) for (int i = 0; i < (n); i++) #define reps(i, a, b) for (int i = (a); i < (b); i++) #define pb push_back #define eb emplace_back #define all(v) (v).begin(), (v).end() #define fi first #define se second using vint = vector<int>; using pint = pair<int, int>; using vpint = vector<pint>; template <typename A, typename B> inline void chmin(A &a, B b) { if (a > b) a = b; } template <typename A, typename B> inline void chmax(A &a, B b) { if (a < b) a = b; } template <class A, class B> ostream &operator<<(ostream &ost, const pair<A, B> &p) { ost << "{" << p.first << "," << p.second << "}"; return ost; } template <class T> ostream &operator<<(ostream &ost, const vector<T> &v) { ost << "{"; for (int i = 0; i < v.size(); i++) { if (i) ost << ","; ost << v[i]; } ost << "}"; return ost; } const int INF = 1001001001001001001; string DIR = "URDL"; int N; int X[111111], Y[111111]; int D[111111]; int mx[3], mn[3]; signed main() { cin >> N; rep(i, N) { char d; cin >> X[i] >> Y[i] >> d; X[i] *= 2; Y[i] *= 2; D[i] = find(all(DIR), d) - DIR.begin(); } vint ts{0}; fill_n(mx, 3, -INF); fill_n(mn, 3, INF); rep(i, N) { int k; if (D[i] == 0) k = 0; else if (D[i] == 2) k = 1; else k = 2; chmax(mx[k], Y[i]); chmin(mn[k], Y[i]); } ts.pb((mx[1] - mx[0]) / 2); ts.pb(mx[2] - mx[0]); ts.pb(mx[1] - mx[2]); ts.pb((mn[1] - mn[0]) / 2); ts.pb(mn[2] - mn[0]); ts.pb(mn[1] - mn[2]); fill_n(mx, 3, -INF); fill_n(mn, 3, INF); rep(i, N) { int k; if (D[i] == 1) k = 0; else if (D[i] == 3) k = 1; else k = 2; chmax(mx[k], X[i]); chmin(mn[k], X[i]); } ts.pb((mx[1] - mx[0]) / 2); ts.pb(mx[2] - mx[0]); ts.pb(mx[1] - mx[2]); ts.pb((mn[1] - mn[0]) / 2); ts.pb(mn[2] - mn[0]); ts.pb(mn[1] - mn[2]); vint ts_; for (auto t : ts) { if (t < 0 || t > INF / 10) continue; ts_.pb(t); } ts = ts_; int ans = INF; for (auto t : ts) { int mxx = -INF, mnx = INF, mxy = -INF, mny = INF; rep(i, N) { int x = X[i], y = Y[i]; if (D[i] == 0) { y += t; } else if (D[i] == 1) { x += t; } else if (D[i] == 2) { y -= t; } else { y += t; } chmax(mxx, x); chmin(mnx, x); chmax(mxy, y); chmin(mny, y); } chmin(ans, (mxx - mnx) * (mxy - mny)); } printf("%.20f\n", 0.25 * ans); return 0; }
#include <bits/stdc++.h> using namespace std; #define int long long #define rep(i, n) for (int i = 0; i < (n); i++) #define reps(i, a, b) for (int i = (a); i < (b); i++) #define pb push_back #define eb emplace_back #define all(v) (v).begin(), (v).end() #define fi first #define se second using vint = vector<int>; using pint = pair<int, int>; using vpint = vector<pint>; template <typename A, typename B> inline void chmin(A &a, B b) { if (a > b) a = b; } template <typename A, typename B> inline void chmax(A &a, B b) { if (a < b) a = b; } template <class A, class B> ostream &operator<<(ostream &ost, const pair<A, B> &p) { ost << "{" << p.first << "," << p.second << "}"; return ost; } template <class T> ostream &operator<<(ostream &ost, const vector<T> &v) { ost << "{"; for (int i = 0; i < v.size(); i++) { if (i) ost << ","; ost << v[i]; } ost << "}"; return ost; } const int INF = 1001001001001001001; string DIR = "URDL"; int N; int X[111111], Y[111111]; int D[111111]; int mx[3], mn[3]; signed main() { cin >> N; rep(i, N) { char d; cin >> X[i] >> Y[i] >> d; X[i] *= 2; Y[i] *= 2; D[i] = find(all(DIR), d) - DIR.begin(); } vint ts{0}; fill_n(mx, 3, -INF); fill_n(mn, 3, INF); rep(i, N) { int k; if (D[i] == 0) k = 0; else if (D[i] == 2) k = 1; else k = 2; chmax(mx[k], Y[i]); chmin(mn[k], Y[i]); } ts.pb((mx[1] - mx[0]) / 2); ts.pb(mx[2] - mx[0]); ts.pb(mx[1] - mx[2]); ts.pb((mn[1] - mn[0]) / 2); ts.pb(mn[2] - mn[0]); ts.pb(mn[1] - mn[2]); fill_n(mx, 3, -INF); fill_n(mn, 3, INF); rep(i, N) { int k; if (D[i] == 1) k = 0; else if (D[i] == 3) k = 1; else k = 2; chmax(mx[k], X[i]); chmin(mn[k], X[i]); } ts.pb((mx[1] - mx[0]) / 2); ts.pb(mx[2] - mx[0]); ts.pb(mx[1] - mx[2]); ts.pb((mn[1] - mn[0]) / 2); ts.pb(mn[2] - mn[0]); ts.pb(mn[1] - mn[2]); vint ts_; for (auto t : ts) { if (t < 0 || t > INF / 10) continue; ts_.pb(t); } ts = ts_; int ans = INF; for (auto t : ts) { int mxx = -INF, mnx = INF, mxy = -INF, mny = INF; rep(i, N) { int x = X[i], y = Y[i]; if (D[i] == 0) { y += t; } else if (D[i] == 1) { x += t; } else if (D[i] == 2) { y -= t; } else { x -= t; } chmax(mxx, x); chmin(mnx, x); chmax(mxy, y); chmin(mny, y); } chmin(ans, (mxx - mnx) * (mxy - mny)); } printf("%.20f\n", 0.25 * ans); return 0; }
[ "assignment.change" ]
833,113
833,112
u685892567
cpp
p03004
/*{{{*/ #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; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; string cc = "RULD"; int x[SIZE], y[SIZE]; string d[SIZE]; const int INF = 1e9; template <class T> void maa(T &x, T y) { if (x < y) x = y; } template <class T> void mii(T &x, T y) { if (x > y) x = y; } vector<double> AA{0.}; void f1(int x, int y) { if (x < y) AA.PB((y - x) * 0.5); } void f2(int x, int y) { if (x < y) AA.PB(y - x); } void f3(int x, int y) { if (x > y) AA.PB(x - y); } void test(int N, char c1, char c2, int v1[]) { char c[2] = {c1, c2}; int mi[3], ma[3]; REP(i, 3) mi[i] = INF, ma[i] = -INF; REP(i, N) { if (d[i][0] == c[0]) { maa(ma[0], v1[i]); mii(mi[0], v1[i]); } else if (d[i][0] == c[1]) { maa(ma[1], v1[i]); mii(mi[1], v1[i]); } else { maa(ma[2], v1[i]); mii(mi[2], v1[i]); } } f1(ma[0], ma[1]); f1(mi[0], ma[1]); f1(ma[0], mi[1]); f1(mi[0], mi[1]); f2(ma[0], ma[2]); f2(mi[0], ma[2]); f2(ma[0], mi[2]); f2(mi[0], mi[2]); f3(ma[1], ma[2]); f3(mi[1], ma[2]); f3(ma[1], mi[2]); f3(mi[1], mi[2]); } int main() { int N; R(N); FOR(i, 1, N) { R(x[i], y[i], d[i]); } test(N, 'R', 'L', x); test(N, 'U', 'D', y); double an = 1e18; for (auto v : AA) { double mi[2] = {1e18, 1e18}, ma[2] = {-1e18, -1e18}; REP(i, N) { REP(j, 4) { if (d[i][0] == cc[j]) { maa(ma[0], x[i] + dx[j] * v); maa(ma[1], y[i] + dy[j] * v); mii(mi[0], x[i] + dx[j] * v); mii(mi[1], y[i] + dy[j] * v); } } } // W(v,mi[0],mi[1],ma[0],ma[1]); an = min(an, (ma[0] - mi[0]) * (ma[1] - mi[1])); } W(an); return 0; }
/*{{{*/ #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; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; string cc = "RULD"; int x[SIZE], y[SIZE]; string d[SIZE]; const int INF = 1e9; template <class T> void maa(T &x, T y) { if (x < y) x = y; } template <class T> void mii(T &x, T y) { if (x > y) x = y; } vector<double> AA{0.}; void f1(int x, int y) { if (x < y) AA.PB((y - x) * 0.5); } void f2(int x, int y) { if (x < y) AA.PB(y - x); } void f3(int x, int y) { if (x > y) AA.PB(x - y); } void test(int N, char c1, char c2, int v1[]) { char c[2] = {c1, c2}; int mi[3], ma[3]; REP(i, 3) mi[i] = INF, ma[i] = -INF; REP(i, N) { if (d[i][0] == c[0]) { maa(ma[0], v1[i]); mii(mi[0], v1[i]); } else if (d[i][0] == c[1]) { maa(ma[1], v1[i]); mii(mi[1], v1[i]); } else { maa(ma[2], v1[i]); mii(mi[2], v1[i]); } } f1(ma[0], ma[1]); f1(mi[0], ma[1]); f1(ma[0], mi[1]); f1(mi[0], mi[1]); f2(ma[0], ma[2]); f2(mi[0], ma[2]); f2(ma[0], mi[2]); f2(mi[0], mi[2]); f3(ma[1], ma[2]); f3(mi[1], ma[2]); f3(ma[1], mi[2]); f3(mi[1], mi[2]); } int main() { int N; R(N); REP(i, N) { R(x[i], y[i], d[i]); } test(N, 'R', 'L', x); test(N, 'U', 'D', y); double an = 1e18; for (auto v : AA) { double mi[2] = {1e18, 1e18}, ma[2] = {-1e18, -1e18}; REP(i, N) { REP(j, 4) { if (d[i][0] == cc[j]) { maa(ma[0], x[i] + dx[j] * v); maa(ma[1], y[i] + dy[j] * v); mii(mi[0], x[i] + dx[j] * v); mii(mi[1], y[i] + dy[j] * v); } } } // W(v,mi[0],mi[1],ma[0],ma[1]); an = min(an, (ma[0] - mi[0]) * (ma[1] - mi[1])); } W(an); return 0; }
[ "call.arguments.change" ]
833,120
833,121
u284124505
cpp
p03004
#include <algorithm> #include <iostream> #include <limits.h> #include <vector> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < n; i++) const ll INF = LLONG_MAX / 2; int n; vector<ll> x, y; vector<int> dx, dy; ll solve(ll t) { ll xmin = INF; ll ymin = INF; ll xmax = -INF; ll ymax = -INF; rep(i, n) { ll x2 = x[i] + dx[i] * t; ll y2 = y[i] + dy[i] * t; xmin = min(xmin, x2); xmax = max(xmax, x2); ymin = min(ymin, y2); ymax = max(ymax, y2); } return (xmax - xmin) * (ymax - ymin); } main() { cin >> n; x.assign(n, 0); y.assign(n, 0); dx.assign(n, 0); dy.assign(n, 0); rep(i, n) { char d; cin >> x[i] >> y[i] >> d; x[i] *= 2; y[i] *= 2; if (d == 'R') dx[i]++; else if (d == 'L') dx[i]--; else if (d == 'U') dy[i]++; else if (d == 'D') dy[i]--; } ll left = 0; ll right = 4e9; while (right - left > 3) { ll mid1 = (left * 2 + right) / 3; ll mid2 = (left + right * 2) / 3; if (solve(mid1) < solve(mid2)) right = mid2; else left = mid1; } ll ans = INF; for (ll i = left; i <= right; i++) ans = min(ans, solve(i)); printf("%.10f\n", ans / 4.0); }
#include <algorithm> #include <iostream> #include <limits.h> #include <vector> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < n; i++) const ll INF = LLONG_MAX / 2; int n; vector<ll> x, y; vector<int> dx, dy; ll solve(ll t) { ll xmin = INF; ll ymin = INF; ll xmax = -INF; ll ymax = -INF; rep(i, n) { ll x2 = x[i] + dx[i] * t; ll y2 = y[i] + dy[i] * t; xmin = min(xmin, x2); xmax = max(xmax, x2); ymin = min(ymin, y2); ymax = max(ymax, y2); } return (xmax - xmin) * (ymax - ymin); } main() { cin >> n; x.assign(n, 0); y.assign(n, 0); dx.assign(n, 0); dy.assign(n, 0); rep(i, n) { char d; cin >> x[i] >> y[i] >> d; x[i] *= 2; y[i] *= 2; if (d == 'R') dx[i]++; else if (d == 'L') dx[i]--; else if (d == 'U') dy[i]++; else if (d == 'D') dy[i]--; } ll left = 0; ll right = 400000000; while (right - left > 3) { ll mid1 = (left * 2 + right) / 3; ll mid2 = (left + right * 2) / 3; if (solve(mid1) < solve(mid2)) right = mid2; else left = mid1; } ll ans = INF; for (ll i = left; i <= right; i++) ans = min(ans, solve(i)); printf("%.10f\n", ans / 4.0); }
[ "literal.number.change", "variable_declaration.value.change" ]
833,139
833,140
u468811760
cpp
p03004
#include <bits/stdc++.h> using namespace std; int main() { cout.precision(17); cout.setf(ios_base::fixed, ios_base::floatfield); int N; cin >> N; vector<pair<int64_t, int64_t>> info[4]; map<char, int> idx; idx['R'] = 0; idx['L'] = 1; idx['U'] = 2; idx['D'] = 3; int64_t x, y; char d; vector<double> cand; int64_t xmax[4], xmin[4], ymax[4], ymin[4]; for (int i = 0; i < 4; i++) { xmax[i] = ymax[i] = -1e15; xmin[i] = ymin[i] = 1e15; } for (int i = 0; i < N; i++) { cin >> x >> y >> d; info[idx[d]].emplace_back(x, y); xmax[idx[d]] = max(xmax[idx[d]], x); xmin[idx[d]] = min(xmin[idx[d]], x); ymax[idx[d]] = max(ymax[idx[d]], y); ymin[idx[d]] = max(ymin[idx[d]], y); } cand.push_back(0.0); cand.push_back(0.5 * (xmax[idx['L']] - xmax[idx['R']])); cand.push_back(xmax[idx['L']] - xmax[idx['U']]); cand.push_back(xmax[idx['L']] - xmax[idx['D']]); cand.push_back(-xmax[idx['R']] + xmax[idx['U']]); cand.push_back(-xmax[idx['R']] + xmax[idx['D']]); cand.push_back(0.5 * (xmin[idx['L']] - xmin[idx['R']])); cand.push_back(xmin[idx['L']] - xmin[idx['U']]); cand.push_back(xmin[idx['L']] - xmin[idx['D']]); cand.push_back(-xmin[idx['R']] + xmin[idx['U']]); cand.push_back(-xmin[idx['R']] + xmin[idx['D']]); cand.push_back(0.5 * (ymax[idx['D']] - ymax[idx['U']])); cand.push_back(ymax[idx['D']] - ymax[idx['L']]); cand.push_back(ymax[idx['D']] - ymax[idx['R']]); cand.push_back(-ymax[idx['U']] + ymax[idx['L']]); cand.push_back(-ymax[idx['U']] + ymax[idx['R']]); cand.push_back(0.5 * (ymin[idx['D']] - ymin[idx['U']])); cand.push_back(ymin[idx['D']] - ymin[idx['L']]); cand.push_back(ymin[idx['D']] - ymin[idx['R']]); cand.push_back(-ymin[idx['U']] + ymin[idx['L']]); cand.push_back(-ymin[idx['U']] + ymin[idx['R']]); double ans = 1e18; for (auto t : cand) { if (t > 5e9) continue; if (t < 0) t *= -1; double l = 1e15, r = -1e15, u = -1e15, d = 1e15; for (auto pos : info[idx['L']]) { l = min(l, pos.first - t); r = max(r, pos.first - t); u = max(u, pos.second + 0.0); d = min(d, pos.second + 0.0); } for (auto pos : info[idx['R']]) { l = min(l, pos.first + t); r = max(r, pos.first + t); u = max(u, pos.second + 0.0); d = min(d, pos.second + 0.0); } for (auto pos : info[idx['U']]) { l = min(l, pos.first + 0.0); r = max(r, pos.first + 0.0); u = max(u, pos.second + t); d = min(d, pos.second + t); } for (auto pos : info[idx['D']]) { l = min(l, pos.first + 0.0); r = max(r, pos.first + 0.0); u = max(u, pos.second - t); d = min(d, pos.second - t); } ans = min(ans, (r - l) * (u - d)); } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { cout.precision(17); cout.setf(ios_base::fixed, ios_base::floatfield); int N; cin >> N; vector<pair<int64_t, int64_t>> info[4]; map<char, int> idx; idx['R'] = 0; idx['L'] = 1; idx['U'] = 2; idx['D'] = 3; int64_t x, y; char d; vector<double> cand; int64_t xmax[4], xmin[4], ymax[4], ymin[4]; for (int i = 0; i < 4; i++) { xmax[i] = ymax[i] = -1e15; xmin[i] = ymin[i] = 1e15; } for (int i = 0; i < N; i++) { cin >> x >> y >> d; info[idx[d]].emplace_back(x, y); xmax[idx[d]] = max(xmax[idx[d]], x); xmin[idx[d]] = min(xmin[idx[d]], x); ymax[idx[d]] = max(ymax[idx[d]], y); ymin[idx[d]] = min(ymin[idx[d]], y); } cand.push_back(0.0); cand.push_back(0.5 * (xmax[idx['L']] - xmax[idx['R']])); cand.push_back(xmax[idx['L']] - xmax[idx['U']]); cand.push_back(xmax[idx['L']] - xmax[idx['D']]); cand.push_back(-xmax[idx['R']] + xmax[idx['U']]); cand.push_back(-xmax[idx['R']] + xmax[idx['D']]); cand.push_back(0.5 * (xmin[idx['L']] - xmin[idx['R']])); cand.push_back(xmin[idx['L']] - xmin[idx['U']]); cand.push_back(xmin[idx['L']] - xmin[idx['D']]); cand.push_back(-xmin[idx['R']] + xmin[idx['U']]); cand.push_back(-xmin[idx['R']] + xmin[idx['D']]); cand.push_back(0.5 * (ymax[idx['D']] - ymax[idx['U']])); cand.push_back(ymax[idx['D']] - ymax[idx['L']]); cand.push_back(ymax[idx['D']] - ymax[idx['R']]); cand.push_back(-ymax[idx['U']] + ymax[idx['L']]); cand.push_back(-ymax[idx['U']] + ymax[idx['R']]); cand.push_back(0.5 * (ymin[idx['D']] - ymin[idx['U']])); cand.push_back(ymin[idx['D']] - ymin[idx['L']]); cand.push_back(ymin[idx['D']] - ymin[idx['R']]); cand.push_back(-ymin[idx['U']] + ymin[idx['L']]); cand.push_back(-ymin[idx['U']] + ymin[idx['R']]); double ans = 1e18; for (auto t : cand) { if (t > 1e14) continue; if (t < 0) t *= -1; double l = 1e15, r = -1e15, u = -1e15, d = 1e15; for (auto pos : info[idx['L']]) { l = min(l, pos.first - t); r = max(r, pos.first - t); u = max(u, pos.second + 0.0); d = min(d, pos.second + 0.0); } for (auto pos : info[idx['R']]) { l = min(l, pos.first + t); r = max(r, pos.first + t); u = max(u, pos.second + 0.0); d = min(d, pos.second + 0.0); } for (auto pos : info[idx['U']]) { l = min(l, pos.first + 0.0); r = max(r, pos.first + 0.0); u = max(u, pos.second + t); d = min(d, pos.second + t); } for (auto pos : info[idx['D']]) { l = min(l, pos.first + 0.0); r = max(r, pos.first + 0.0); u = max(u, pos.second - t); d = min(d, pos.second - t); } ans = min(ans, (r - l) * (u - d)); } cout << ans << endl; return 0; }
[ "misc.opposites", "assignment.value.change", "identifier.change", "call.function.change", "literal.number.change", "control_flow.branch.if.condition.change" ]
833,175
833,176
u726604439
cpp
p03004
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cmath> #include <cstdint> #include <cstdio> #include <cstring> #include <deque> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <tuple> #include <utility> #include <vector> using namespace std; using i64 = int64_t; using i32 = int32_t; template <class T, class U> void init_n(vector<T> &v, size_t n, U x) { v = vector<T>(n, x); } template <class T> void init_n(vector<T> &v, size_t n) { init_n(v, n, T()); } template <class T> void read_n(vector<T> &v, size_t n, size_t o = 0) { v = vector<T>(n + o); for (size_t i = o; i < n + o; ++i) cin >> v[i]; } template <class T> void read_n(T a[], size_t n, size_t o = 0) { for (size_t i = o; i < n + o; ++i) cin >> a[i]; } template <class T> T gabs(const T &x) { return max(x, -x); } #define abs gabs const char *dir_s = "RLUD"; int dir(char c) { return strchr(dir_s, c) - dir_s; } int vxs[] = {1, -1, 0, 0}, vys[] = {0, 0, 1, -1}; struct Point { i64 x, y, vx, vy; }; bool cmp_xmin(Point p, Point q) { return p.x < q.x; } bool cmp_xmax(Point p, Point q) { return p.x > q.x; } bool cmp_ymin(Point p, Point q) { return p.y < q.y; } bool cmp_ymax(Point p, Point q) { return p.y > q.y; } const i64 inf = 1ll << 62; i64 n; vector<Point> p_all[4], ps; int main() { cin >> n; for (i64 i = 0; i < n; ++i) { i64 x, y; char d; cin >> x >> y >> d; i64 di = dir(d); p_all[di].push_back({2 * x, 2 * y, vxs[di], vys[di]}); } decltype(cmp_xmin) *cmps[] = { cmp_xmin, cmp_xmax, cmp_ymin, cmp_ymax, }; for (i64 d = 0; d < 4; ++d) { if (p_all[d].empty()) continue; for (i64 k = 0; k < 4; ++k) { Point p = p_all[d][0]; for (size_t i = 1; i < p_all[d].size(); ++i) { if (cmps[k](p, p_all[d][i])) p = p_all[d][i]; } ps.push_back(p); } } vector<i64> ts(1, 0); for (size_t i = 0; i < ps.size(); ++i) { for (size_t j = i + 1; j < ps.size(); ++j) { auto p = ps[i], q = ps[j]; i64 t = 0; if (p.vx != q.vx) { t = (q.x - p.x) / (p.vx - q.vx); if (t >= 0) ts.push_back(t); } if (p.vy != q.vy) { t = (q.y - p.y) / (p.vy - q.vy); if (t >= 0) ts.push_back(t); } } } i64 ans2 = inf; for (i64 t : ts) { i64 xmin = inf, xmax = -inf, ymin = inf, ymax = -inf; for (auto p : ps) { i64 tx = p.x + p.vx * t, ty = p.y + p.vy * t; xmin = min(xmin, tx); xmax = max(xmax, tx); ymin = min(ymin, ty); ymax = max(ymax, ty); } ans2 = min(ans2, (xmax - xmin) * (ymax - ymin)); } printf("%.1lf\n", (double)ans2 / 4); return 0; }
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cmath> #include <cstdint> #include <cstdio> #include <cstring> #include <deque> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <tuple> #include <utility> #include <vector> using namespace std; using i64 = int64_t; using i32 = int32_t; template <class T, class U> void init_n(vector<T> &v, size_t n, U x) { v = vector<T>(n, x); } template <class T> void init_n(vector<T> &v, size_t n) { init_n(v, n, T()); } template <class T> void read_n(vector<T> &v, size_t n, size_t o = 0) { v = vector<T>(n + o); for (size_t i = o; i < n + o; ++i) cin >> v[i]; } template <class T> void read_n(T a[], size_t n, size_t o = 0) { for (size_t i = o; i < n + o; ++i) cin >> a[i]; } template <class T> T gabs(const T &x) { return max(x, -x); } #define abs gabs const char *dir_s = "RLUD"; int dir(char c) { return strchr(dir_s, c) - dir_s; } int vxs[] = {1, -1, 0, 0}, vys[] = {0, 0, 1, -1}; struct Point { i64 x, y, vx, vy; }; bool cmp_xmin(Point p, Point q) { return p.x < q.x; } bool cmp_xmax(Point p, Point q) { return p.x > q.x; } bool cmp_ymin(Point p, Point q) { return p.y < q.y; } bool cmp_ymax(Point p, Point q) { return p.y > q.y; } const i64 inf = 1ll << 62; i64 n; vector<Point> p_all[4], ps; int main() { cin >> n; for (i64 i = 0; i < n; ++i) { i64 x, y; char d; cin >> x >> y >> d; i64 di = dir(d); p_all[di].push_back({2 * x, 2 * y, vxs[di], vys[di]}); } decltype(cmp_xmin) *cmps[] = { cmp_xmin, cmp_xmax, cmp_ymin, cmp_ymax, }; for (i64 d = 0; d < 4; ++d) { if (p_all[d].empty()) continue; for (i64 k = 0; k < 4; ++k) { Point p = p_all[d][0]; for (size_t i = 1; i < p_all[d].size(); ++i) { if (cmps[k](p, p_all[d][i])) p = p_all[d][i]; } ps.push_back(p); } } vector<i64> ts(1, 0); for (size_t i = 0; i < ps.size(); ++i) { for (size_t j = i + 1; j < ps.size(); ++j) { auto p = ps[i], q = ps[j]; i64 t = 0; if (p.vx != q.vx) { t = (q.x - p.x) / (p.vx - q.vx); if (t >= 0) ts.push_back(t); } if (p.vy != q.vy) { t = (q.y - p.y) / (p.vy - q.vy); if (t >= 0) ts.push_back(t); } } } i64 ans2 = inf; for (i64 t : ts) { i64 xmin = inf, xmax = -inf, ymin = inf, ymax = -inf; for (auto p : ps) { i64 tx = p.x + p.vx * t, ty = p.y + p.vy * t; xmin = min(xmin, tx); xmax = max(xmax, tx); ymin = min(ymin, ty); ymax = max(ymax, ty); } ans2 = min(ans2, (xmax - xmin) * (ymax - ymin)); } printf("%.2lf\n", (double)ans2 / 4); return 0; }
[ "literal.string.change", "call.arguments.change", "io.output.change" ]
833,191
833,192
u090994275
cpp
p03004
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define mins(x, y) x = min(x, y) #define maxs(x, y) x = max(x, y) using namespace std; const double inf = 1e10; struct D { vector<double> l, r; D() : l(3, inf), r(3, -inf) {} void add(double x, int v) { ++v; mins(l[v], x); maxs(r[v], x); } double get(double t) { double nl = inf, nr = -inf; rep(i, 3) { mins(nl, l[i] + i * t); maxs(nr, r[i] + i * t); } return nr - nl; } vector<double> events() { vector<double> ts; rep(i, 3) rep(j, i) { { double t = (l[j] - l[i]) / i - j; if (t > 0) ts.push_back(t); } { double t = (r[j] - r[i]) / i - j; if (t > 0) ts.push_back(t); } } return ts; } }; int main() { int n; cin >> n; D xd, yd; rep(i, n) { int x, y; char d; cin >> x >> y >> d; if (d == 'L') xd.add(x, -1), yd.add(y, 0); if (d == 'R') xd.add(x, 1), yd.add(y, 0); if (d == 'U') xd.add(x, 0), yd.add(y, 1); if (d == 'D') xd.add(x, 0), yd.add(y, -1); } vector<double> ts; ts.push_back(0); ts.push_back(inf); { auto nts = xd.events(); ts.insert(ts.end(), nts.begin(), nts.end()); } { auto nts = yd.events(); ts.insert(ts.end(), nts.begin(), nts.end()); } sort(ts.begin(), ts.end()); double ans = 1e18; for (double t : ts) { double now = xd.get(t) * yd.get(t); mins(ans, now); } printf("%.10f\n", ans); return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define mins(x, y) x = min(x, y) #define maxs(x, y) x = max(x, y) using namespace std; const double inf = 1e10; struct D { vector<double> l, r; D() : l(3, inf), r(3, -inf) {} void add(double x, int v) { ++v; mins(l[v], x); maxs(r[v], x); } double get(double t) { double nl = inf, nr = -inf; rep(i, 3) { mins(nl, l[i] + i * t); maxs(nr, r[i] + i * t); } return nr - nl; } vector<double> events() { vector<double> ts; rep(i, 3) rep(j, i) { { double t = (l[j] - l[i]) / (i - j); if (t > 0) ts.push_back(t); } { double t = (r[j] - r[i]) / (i - j); if (t > 0) ts.push_back(t); } } return ts; } }; int main() { int n; cin >> n; D xd, yd; rep(i, n) { int x, y; char d; cin >> x >> y >> d; if (d == 'L') xd.add(x, -1), yd.add(y, 0); if (d == 'R') xd.add(x, 1), yd.add(y, 0); if (d == 'U') xd.add(x, 0), yd.add(y, 1); if (d == 'D') xd.add(x, 0), yd.add(y, -1); } vector<double> ts; ts.push_back(0); ts.push_back(inf); { auto nts = xd.events(); ts.insert(ts.end(), nts.begin(), nts.end()); } { auto nts = yd.events(); ts.insert(ts.end(), nts.begin(), nts.end()); } sort(ts.begin(), ts.end()); double ans = 1e18; for (double t : ts) { double now = xd.get(t) * yd.get(t); mins(ans, now); } printf("%.10f\n", ans); return 0; }
[]
833,193
833,194
u639032323
cpp
p03004
#include <bits/stdc++.h> #define _overload(_1, _2, _3, name, ...) name #define _rep(i, n) _range(i, 0, n) #define _range(i, a, b) for (int i = (int)(a); i < (int)(b); ++i) #define rep(...) _overload(__VA_ARGS__, _range, _rep, )(__VA_ARGS__) #define _rrep(i, n) _rrange(i, n, 0) #define _rrange(i, a, b) for (int i = (int)(a)-1; i >= (int)(b); --i) #define rrep(...) _overload(__VA_ARGS__, _rrange, _rrep, )(__VA_ARGS__) #define _all(arg) begin(arg), end(arg) #define uniq(arg) sort(_all(arg)), (arg).erase(unique(_all(arg)), end(arg)) #define getidx(ary, key) lower_bound(_all(ary), key) - begin(ary) #define clr(a, b) memset((a), (b), sizeof(a)) #define bit(n) (1LL << (n)) // #define DEBUG #ifdef DEBUG #define dump(...) fprintf(stderr, __VA_ARGS__) #else #define dump(...) #endif template <class T> bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; } template <class T> bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; } using namespace std; using ll = long long; using vi = vector<int>; using vll = vector<ll>; const double EPS = 1e-10; const double PI = acos(-1.0); const int inf = (int)1e9; const ll mod = 1000000007LL; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; ll extgcd(ll a, ll b, ll &x, ll &y) { x = 1, y = 0; ll g = a; if (b != 0) g = extgcd(b, a % b, y, x), y -= a / b * x; return g; } ll ADD(const ll &a, const ll &b, const ll &mod) { return (a + b) % mod; } ll SUB(const ll &a, const ll &b, const ll &mod) { return (a - b + mod) % mod; } ll MUL(const ll &a, const ll &b, const ll &mod) { return (1LL * a * b) % mod; } ll DIV(const ll &a, const ll &b, const ll &mod) { ll x, y; extgcd(b, mod, x, y); return MUL(a, (x + mod) % mod, mod); } random_device rd; mt19937 mt(rd()); uniform_int_distribution<int> dice(1, 6); uniform_real_distribution<double> score(0.0, 10.0); int main(void) { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; map<char, vi> x; map<char, vi> y; for (auto &c : "RLUD") { x[c] = vi(1, -inf), y[c] = vi(1, -inf); } rep(i, n) { int xx, yy; char d; cin >> xx >> yy >> d; x[d].emplace_back(xx); y[d].emplace_back(yy); } vi xmax(300), xmin(300), ymax(300), ymin(300); for (auto &c : "RLUD") { xmax[c] = *max_element(_all(x[c])); ymax[c] = *max_element(_all(y[c])); x[c][0] = inf, y[c][0] = inf; xmin[c] = *min_element(_all(x[c])); ymin[c] = *min_element(_all(y[c])); } int xmab = max(xmax['U'], xmax['D']); int xmib = min(xmin['U'], xmin['D']); int ymab = max(ymax['R'], ymax['L']); int ymib = min(ymin['R'], ymin['L']); int xd = *max_element(_all(xmax)) - *min_element(_all(xmin)); int yd = *max_element(_all(ymax)) - *min_element(_all(ymin)); using R = double; R res = 1LL << 61; rep(_, 2 * max(xd, yd)) { R loop = 0.5 * _; R xma = max(1. * xmab, max(xmax['R'] + loop, xmax['L'] - loop)); R xmi = min(1. * xmib, min(xmin['R'] + loop, xmin['L'] - loop)); R yma = max(1. * ymab, max(ymax['U'] + loop, ymax['D'] - loop)); R ymi = min(1. * ymib, min(ymin['U'] + loop, ymin['D'] - loop)); R cur = (xma - xmi) * (yma - ymi); chmin(res, (xma - xmi) * (yma - ymi)); } cout.precision(20); cout << fixed << res << endl; return 0; }
#include <bits/stdc++.h> #define _overload(_1, _2, _3, name, ...) name #define _rep(i, n) _range(i, 0, n) #define _range(i, a, b) for (int i = (int)(a); i < (int)(b); ++i) #define rep(...) _overload(__VA_ARGS__, _range, _rep, )(__VA_ARGS__) #define _rrep(i, n) _rrange(i, n, 0) #define _rrange(i, a, b) for (int i = (int)(a)-1; i >= (int)(b); --i) #define rrep(...) _overload(__VA_ARGS__, _rrange, _rrep, )(__VA_ARGS__) #define _all(arg) begin(arg), end(arg) #define uniq(arg) sort(_all(arg)), (arg).erase(unique(_all(arg)), end(arg)) #define getidx(ary, key) lower_bound(_all(ary), key) - begin(ary) #define clr(a, b) memset((a), (b), sizeof(a)) #define bit(n) (1LL << (n)) // #define DEBUG #ifdef DEBUG #define dump(...) fprintf(stderr, __VA_ARGS__) #else #define dump(...) #endif template <class T> bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; } template <class T> bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; } using namespace std; using ll = long long; using vi = vector<int>; using vll = vector<ll>; const double EPS = 1e-10; const double PI = acos(-1.0); const int inf = (int)1e9; const ll mod = 1000000007LL; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; ll extgcd(ll a, ll b, ll &x, ll &y) { x = 1, y = 0; ll g = a; if (b != 0) g = extgcd(b, a % b, y, x), y -= a / b * x; return g; } ll ADD(const ll &a, const ll &b, const ll &mod) { return (a + b) % mod; } ll SUB(const ll &a, const ll &b, const ll &mod) { return (a - b + mod) % mod; } ll MUL(const ll &a, const ll &b, const ll &mod) { return (1LL * a * b) % mod; } ll DIV(const ll &a, const ll &b, const ll &mod) { ll x, y; extgcd(b, mod, x, y); return MUL(a, (x + mod) % mod, mod); } random_device rd; mt19937 mt(rd()); uniform_int_distribution<int> dice(1, 6); uniform_real_distribution<double> score(0.0, 10.0); int main(void) { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; map<char, vi> x; map<char, vi> y; for (auto &c : "RLUD") { x[c] = vi(1, -inf), y[c] = vi(1, -inf); } rep(i, n) { int xx, yy; char d; cin >> xx >> yy >> d; x[d].emplace_back(xx); y[d].emplace_back(yy); } vi xmax(300), xmin(300), ymax(300), ymin(300); for (auto &c : "RLUD") { xmax[c] = *max_element(_all(x[c])); ymax[c] = *max_element(_all(y[c])); x[c][0] = inf, y[c][0] = inf; xmin[c] = *min_element(_all(x[c])); ymin[c] = *min_element(_all(y[c])); } int xmab = max(xmax['U'], xmax['D']); int xmib = min(xmin['U'], xmin['D']); int ymab = max(ymax['R'], ymax['L']); int ymib = min(ymin['R'], ymin['L']); int xd = *max_element(_all(xmax)) - *min_element(_all(xmin)); int yd = *max_element(_all(ymax)) - *min_element(_all(ymin)); using R = double; R res = 1LL << 61; rep(_, 2 * (max(xd, yd) + 5)) { R loop = 0.5 * _; R xma = max(1. * xmab, max(xmax['R'] + loop, xmax['L'] - loop)); R xmi = min(1. * xmib, min(xmin['R'] + loop, xmin['L'] - loop)); R yma = max(1. * ymab, max(ymax['U'] + loop, ymax['D'] - loop)); R ymi = min(1. * ymib, min(ymin['U'] + loop, ymin['D'] - loop)); R cur = (xma - xmi) * (yma - ymi); chmin(res, (xma - xmi) * (yma - ymi)); } cout.precision(20); cout << fixed << res << endl; return 0; }
[ "call.arguments.change" ]
833,211
833,212
u704625420
cpp
p03004
#pragma GCC optimize("O3") #include <algorithm> #include <iostream> #include <list> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unordered_map> #include <unordered_set> using namespace std; using QWORD = uint64_t; using SQWORD = int64_t; using DWORD = uint32_t; using SDWORD = int32_t; using WORD = uint16_t; using SWORD = int16_t; using BYTE = uint8_t; using SBYTE = int8_t; using DOUBLE = double; using FLOAT = float; #define MIN_SDWORD (-2147483648) #define MAX_SDWORD (2147483647) #define MIN_SBYTE (-128) #define MAX_SBYTE (127) #define MIN_SQWORD (0x8000000000000000) #define MAX_SQWORD (0x7FFFFFFFFFFFFFFF) #define MAX_QWORD (0xFFFFFFFFFFFFFFFF) #define MAX_DWORD (0xFFFFFFFF) #define MAX_WORD (0xFFFF) #define MAX_BYTE (0xFF) #define MAX_DOUBLE (1.0e+308) #define MIN_DOUBLE_N (-1.0e-308) #define ArrayLength(a) (sizeof(a) / sizeof(a[0])) static inline DOUBLE MAX(DOUBLE a, DOUBLE b) { return a > b ? a : b; } static inline QWORD MAX(QWORD a, QWORD b) { return a > b ? a : b; } static inline DWORD MAX(DWORD a, DWORD b) { return a > b ? a : b; } static inline SDWORD MAX(SDWORD a, SDWORD b) { return a > b ? a : b; } static inline DOUBLE MIN(DOUBLE a, DOUBLE b) { return a < b ? a : b; } static inline QWORD MIN(QWORD a, QWORD b) { return a < b ? a : b; } static inline DWORD MIN(DWORD a, DWORD b) { return a < b ? a : b; } static inline SDWORD MIN(SDWORD a, SDWORD b) { return a < b ? a : b; } #define BYTE_BITS (8) #define WORD_BITS (16) #define DWORD_BITS (32) #define QWORD_BITS (64) static inline void inputStringSpSeparated(char *pcStr) { char *pcCur = pcStr; for (;;) { char c = getchar(); if (('\n' == c) || (EOF == c) || (' ' == c)) { break; } *pcCur = c; pcCur++; } *pcCur = '\0'; } static inline void inputString(char *pcStr) { char *pcCur = pcStr; for (;;) { char c = getchar(); if (('\n' == c) || (EOF == c)) { break; } *pcCur = c; pcCur++; } *pcCur = '\0'; } static inline SQWORD inputSQWORD(void) { SQWORD sqNumber = 0; SQWORD sqMultiplier = 1; bool bRead = false; for (;;) { char c = getchar(); if (!bRead) { if ('-' == c) { sqMultiplier = -1; } } if (('0' <= c) && (c <= '9')) { sqNumber *= 10LL; sqNumber += (SQWORD)(c - '0'); bRead = true; } else { if (bRead) { return sqNumber * sqMultiplier; } } } } static inline SDWORD inputSDWORD(void) { SDWORD lNumber = 0; SDWORD lMultiplier = 1; bool bRead = false; for (;;) { char c = getchar(); if (!bRead) { if ('-' == c) { lMultiplier = -1; } } if (('0' <= c) && (c <= '9')) { lNumber *= 10; lNumber += (c - '0'); bRead = true; } else { if (bRead) { return lNumber * lMultiplier; } } } } static inline DOUBLE inputFP(void) { DOUBLE dInt = 0.0; DOUBLE dFrac = 0.0; DOUBLE dMultiplier = 1.0; DWORD dwFpCnt = 0; DOUBLE *pdCur = &dInt; bool bRead = false; for (;;) { char c = getchar(); if (!bRead) { if ('-' == c) { dMultiplier = -1; } } if ('.' == c) { pdCur = &dFrac; } else if (('0' <= c) && (c <= '9')) { (*pdCur) *= 10; (*pdCur) += (DOUBLE)(c - '0'); bRead = true; if (pdCur == &dFrac) { dwFpCnt++; } } else { if (bRead) { return dMultiplier * (dInt + dFrac / (pow((DOUBLE)10.0, (DOUBLE)dwFpCnt))); } } } } /** * mod による操作ライブラリ */ #define ANS_MOD (1000000007LL) static SQWORD addMod(SQWORD x, SQWORD y) { return (x + y) % ANS_MOD; } static SQWORD subMod(SQWORD x, SQWORD y) { return (x - y + ANS_MOD) % ANS_MOD; } static SQWORD mulMod(SQWORD x, SQWORD y) { return (x * y) % ANS_MOD; } static SQWORD powMod(SQWORD x, SQWORD e) { SQWORD v = 1; for (; e; x = mulMod(x, x), e >>= 1) { if (e & 1) { v = mulMod(v, x); } } return v; } static SQWORD divMod(SQWORD x, SQWORD y) { return mulMod(x, powMod(y, ANS_MOD - 2)); } static SQWORD combMod(SQWORD n, SQWORD k) { SQWORD v = 1; for (SQWORD i = 1; i <= k; i++) { v = divMod(mulMod(v, n - i + 1), i); } return v; } /*----------------------------------------------*/ struct ST_AXIS_MOTION { SQWORD sqInit; SQWORD sqDir; }; /** * 最大と最小を取り出してリストに格納する。 */ static void putMinMax(vector<ST_AXIS_MOTION> &vecstTgt, vector<SQWORD> &vecsqPos, SQWORD sqDir) { sort(vecsqPos.begin(), vecsqPos.end()); if (0 < vecsqPos.size()) { auto it = vecsqPos.begin(); vecstTgt.emplace_back(ST_AXIS_MOTION{*it, sqDir}); } if (1 < vecsqPos.size()) { auto it_e = vecsqPos.end() - 1; vecstTgt.emplace_back(ST_AXIS_MOTION{*it_e, sqDir}); } } /** * 入力を取得する */ static void getInput(vector<ST_AXIS_MOTION> &vecstX, vector<ST_AXIS_MOTION> &vecstY) { SQWORD sqInput_N = inputSQWORD(); char acDir[2]; vector<SQWORD> vecsqX_R; vector<SQWORD> vecsqX_Stop; vector<SQWORD> vecsqX_L; vector<SQWORD> vecsqY_U; vector<SQWORD> vecsqY_Stop; vector<SQWORD> vecsqY_D; for (SQWORD sqIdx = 0; sqIdx < sqInput_N; sqIdx++) { SQWORD sqInput_x = inputSQWORD(); SQWORD sqInput_y = inputSQWORD(); inputStringSpSeparated(acDir); switch (acDir[0]) { case 'U': vecsqX_Stop.emplace_back(sqInput_x); vecsqY_U.emplace_back(sqInput_y); break; case 'D': vecsqX_Stop.emplace_back(sqInput_x); vecsqY_D.emplace_back(sqInput_y); break; case 'R': vecsqX_R.emplace_back(sqInput_x); vecsqY_Stop.emplace_back(sqInput_y); break; case 'L': vecsqX_L.emplace_back(sqInput_x); vecsqY_Stop.emplace_back(sqInput_y); break; default: printf("oops!\n"); } } /** * 最大値と最小値だけを抽出する */ /* X軸方向 */ putMinMax(vecstX, vecsqX_R, 1); putMinMax(vecstX, vecsqX_Stop, 0); putMinMax(vecstX, vecsqX_L, -1); /* Y方向 */ putMinMax(vecstY, vecsqY_U, 1); putMinMax(vecstY, vecsqY_Stop, 0); putMinMax(vecstY, vecsqY_D, -1); } void pushCrossTime(vector<ST_AXIS_MOTION> &vecstMotion, vector<DOUBLE> &vecdCrossTime) { for (auto it1 = vecstMotion.begin(); it1 != vecstMotion.end(); ++it1) { for (auto it2 = vecstMotion.begin(); it2 != vecstMotion.end(); ++it2) { if (it1->sqDir != it2->sqDir) { DOUBLE dCorssTime = (DOUBLE)(it2->sqInit - it1->sqInit) / (DOUBLE)(it1->sqDir - it2->sqDir); if (0.0 < dCorssTime) { vecdCrossTime.emplace_back(dCorssTime); } } } } } DOUBLE getBoundingBoxMinMax(const vector<ST_AXIS_MOTION> &vecstAxis, DOUBLE dCrossTime) { DOUBLE dMax = MIN_DOUBLE_N; DOUBLE dMin = MAX_DOUBLE; for (auto pnt_ax : vecstAxis) { DOUBLE dPos = (DOUBLE)pnt_ax.sqInit + (DOUBLE)pnt_ax.sqDir * dCrossTime; dMax = MAX(dMax, dPos); dMin = MIN(dMin, dPos); } return (dMax - dMin); } DOUBLE getBoudingBox(const vector<ST_AXIS_MOTION> &vecstX, const vector<ST_AXIS_MOTION> &vecstY, DOUBLE dCrossTime) { DOUBLE dWidthX = getBoundingBoxMinMax(vecstX, dCrossTime); DOUBLE dWidthY = getBoundingBoxMinMax(vecstY, dCrossTime); // printf("%f %f\n", dWidthX, dWidthY); return dWidthX * dWidthY; } int main(void) { vector<ST_AXIS_MOTION> vecstX; vector<ST_AXIS_MOTION> vecstY; vector<DOUBLE> vecCrossTime; getInput(vecstX, vecstY); vecCrossTime.emplace_back(0.0); pushCrossTime(vecstX, vecCrossTime); pushCrossTime(vecstY, vecCrossTime); DOUBLE dMinBoudingBox = MAX_DOUBLE; for (auto time : vecCrossTime) { dMinBoudingBox = min(dMinBoudingBox, getBoudingBox(vecstX, vecstY, time)); } printf("%.8f\n", dMinBoudingBox); return 0; }
#pragma GCC optimize("O3") #include <algorithm> #include <iostream> #include <list> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unordered_map> #include <unordered_set> using namespace std; using QWORD = uint64_t; using SQWORD = int64_t; using DWORD = uint32_t; using SDWORD = int32_t; using WORD = uint16_t; using SWORD = int16_t; using BYTE = uint8_t; using SBYTE = int8_t; using DOUBLE = double; using FLOAT = float; #define MIN_SDWORD (-2147483648) #define MAX_SDWORD (2147483647) #define MIN_SBYTE (-128) #define MAX_SBYTE (127) #define MIN_SQWORD (0x8000000000000000) #define MAX_SQWORD (0x7FFFFFFFFFFFFFFF) #define MAX_QWORD (0xFFFFFFFFFFFFFFFF) #define MAX_DWORD (0xFFFFFFFF) #define MAX_WORD (0xFFFF) #define MAX_BYTE (0xFF) #define MAX_DOUBLE (1.0e+308) #define MIN_DOUBLE_N (-1.0e+308) #define ArrayLength(a) (sizeof(a) / sizeof(a[0])) static inline DOUBLE MAX(DOUBLE a, DOUBLE b) { return a > b ? a : b; } static inline QWORD MAX(QWORD a, QWORD b) { return a > b ? a : b; } static inline DWORD MAX(DWORD a, DWORD b) { return a > b ? a : b; } static inline SDWORD MAX(SDWORD a, SDWORD b) { return a > b ? a : b; } static inline DOUBLE MIN(DOUBLE a, DOUBLE b) { return a < b ? a : b; } static inline QWORD MIN(QWORD a, QWORD b) { return a < b ? a : b; } static inline DWORD MIN(DWORD a, DWORD b) { return a < b ? a : b; } static inline SDWORD MIN(SDWORD a, SDWORD b) { return a < b ? a : b; } #define BYTE_BITS (8) #define WORD_BITS (16) #define DWORD_BITS (32) #define QWORD_BITS (64) static inline void inputStringSpSeparated(char *pcStr) { char *pcCur = pcStr; for (;;) { char c = getchar(); if (('\n' == c) || (EOF == c) || (' ' == c)) { break; } *pcCur = c; pcCur++; } *pcCur = '\0'; } static inline void inputString(char *pcStr) { char *pcCur = pcStr; for (;;) { char c = getchar(); if (('\n' == c) || (EOF == c)) { break; } *pcCur = c; pcCur++; } *pcCur = '\0'; } static inline SQWORD inputSQWORD(void) { SQWORD sqNumber = 0; SQWORD sqMultiplier = 1; bool bRead = false; for (;;) { char c = getchar(); if (!bRead) { if ('-' == c) { sqMultiplier = -1; } } if (('0' <= c) && (c <= '9')) { sqNumber *= 10LL; sqNumber += (SQWORD)(c - '0'); bRead = true; } else { if (bRead) { return sqNumber * sqMultiplier; } } } } static inline SDWORD inputSDWORD(void) { SDWORD lNumber = 0; SDWORD lMultiplier = 1; bool bRead = false; for (;;) { char c = getchar(); if (!bRead) { if ('-' == c) { lMultiplier = -1; } } if (('0' <= c) && (c <= '9')) { lNumber *= 10; lNumber += (c - '0'); bRead = true; } else { if (bRead) { return lNumber * lMultiplier; } } } } static inline DOUBLE inputFP(void) { DOUBLE dInt = 0.0; DOUBLE dFrac = 0.0; DOUBLE dMultiplier = 1.0; DWORD dwFpCnt = 0; DOUBLE *pdCur = &dInt; bool bRead = false; for (;;) { char c = getchar(); if (!bRead) { if ('-' == c) { dMultiplier = -1; } } if ('.' == c) { pdCur = &dFrac; } else if (('0' <= c) && (c <= '9')) { (*pdCur) *= 10; (*pdCur) += (DOUBLE)(c - '0'); bRead = true; if (pdCur == &dFrac) { dwFpCnt++; } } else { if (bRead) { return dMultiplier * (dInt + dFrac / (pow((DOUBLE)10.0, (DOUBLE)dwFpCnt))); } } } } /** * mod による操作ライブラリ */ #define ANS_MOD (1000000007LL) static SQWORD addMod(SQWORD x, SQWORD y) { return (x + y) % ANS_MOD; } static SQWORD subMod(SQWORD x, SQWORD y) { return (x - y + ANS_MOD) % ANS_MOD; } static SQWORD mulMod(SQWORD x, SQWORD y) { return (x * y) % ANS_MOD; } static SQWORD powMod(SQWORD x, SQWORD e) { SQWORD v = 1; for (; e; x = mulMod(x, x), e >>= 1) { if (e & 1) { v = mulMod(v, x); } } return v; } static SQWORD divMod(SQWORD x, SQWORD y) { return mulMod(x, powMod(y, ANS_MOD - 2)); } static SQWORD combMod(SQWORD n, SQWORD k) { SQWORD v = 1; for (SQWORD i = 1; i <= k; i++) { v = divMod(mulMod(v, n - i + 1), i); } return v; } /*----------------------------------------------*/ struct ST_AXIS_MOTION { SQWORD sqInit; SQWORD sqDir; }; /** * 最大と最小を取り出してリストに格納する。 */ static void putMinMax(vector<ST_AXIS_MOTION> &vecstTgt, vector<SQWORD> &vecsqPos, SQWORD sqDir) { sort(vecsqPos.begin(), vecsqPos.end()); if (0 < vecsqPos.size()) { auto it = vecsqPos.begin(); vecstTgt.emplace_back(ST_AXIS_MOTION{*it, sqDir}); } if (1 < vecsqPos.size()) { auto it_e = vecsqPos.end() - 1; vecstTgt.emplace_back(ST_AXIS_MOTION{*it_e, sqDir}); } } /** * 入力を取得する */ static void getInput(vector<ST_AXIS_MOTION> &vecstX, vector<ST_AXIS_MOTION> &vecstY) { SQWORD sqInput_N = inputSQWORD(); char acDir[2]; vector<SQWORD> vecsqX_R; vector<SQWORD> vecsqX_Stop; vector<SQWORD> vecsqX_L; vector<SQWORD> vecsqY_U; vector<SQWORD> vecsqY_Stop; vector<SQWORD> vecsqY_D; for (SQWORD sqIdx = 0; sqIdx < sqInput_N; sqIdx++) { SQWORD sqInput_x = inputSQWORD(); SQWORD sqInput_y = inputSQWORD(); inputStringSpSeparated(acDir); switch (acDir[0]) { case 'U': vecsqX_Stop.emplace_back(sqInput_x); vecsqY_U.emplace_back(sqInput_y); break; case 'D': vecsqX_Stop.emplace_back(sqInput_x); vecsqY_D.emplace_back(sqInput_y); break; case 'R': vecsqX_R.emplace_back(sqInput_x); vecsqY_Stop.emplace_back(sqInput_y); break; case 'L': vecsqX_L.emplace_back(sqInput_x); vecsqY_Stop.emplace_back(sqInput_y); break; default: printf("oops!\n"); } } /** * 最大値と最小値だけを抽出する */ /* X軸方向 */ putMinMax(vecstX, vecsqX_R, 1); putMinMax(vecstX, vecsqX_Stop, 0); putMinMax(vecstX, vecsqX_L, -1); /* Y方向 */ putMinMax(vecstY, vecsqY_U, 1); putMinMax(vecstY, vecsqY_Stop, 0); putMinMax(vecstY, vecsqY_D, -1); } void pushCrossTime(vector<ST_AXIS_MOTION> &vecstMotion, vector<DOUBLE> &vecdCrossTime) { for (auto it1 = vecstMotion.begin(); it1 != vecstMotion.end(); ++it1) { for (auto it2 = vecstMotion.begin(); it2 != vecstMotion.end(); ++it2) { if (it1->sqDir != it2->sqDir) { DOUBLE dCorssTime = (DOUBLE)(it2->sqInit - it1->sqInit) / (DOUBLE)(it1->sqDir - it2->sqDir); if (0.0 < dCorssTime) { vecdCrossTime.emplace_back(dCorssTime); } } } } } DOUBLE getBoundingBoxMinMax(const vector<ST_AXIS_MOTION> &vecstAxis, DOUBLE dCrossTime) { DOUBLE dMax = MIN_DOUBLE_N; DOUBLE dMin = MAX_DOUBLE; for (auto pnt_ax : vecstAxis) { DOUBLE dPos = (DOUBLE)pnt_ax.sqInit + (DOUBLE)pnt_ax.sqDir * dCrossTime; dMax = MAX(dMax, dPos); dMin = MIN(dMin, dPos); } return (dMax - dMin); } DOUBLE getBoudingBox(const vector<ST_AXIS_MOTION> &vecstX, const vector<ST_AXIS_MOTION> &vecstY, DOUBLE dCrossTime) { DOUBLE dWidthX = getBoundingBoxMinMax(vecstX, dCrossTime); DOUBLE dWidthY = getBoundingBoxMinMax(vecstY, dCrossTime); // printf("%f %f\n", dWidthX, dWidthY); return dWidthX * dWidthY; } int main(void) { vector<ST_AXIS_MOTION> vecstX; vector<ST_AXIS_MOTION> vecstY; vector<DOUBLE> vecCrossTime; getInput(vecstX, vecstY); vecCrossTime.emplace_back(0.0); pushCrossTime(vecstX, vecCrossTime); pushCrossTime(vecstY, vecCrossTime); DOUBLE dMinBoudingBox = MAX_DOUBLE; for (auto time : vecCrossTime) { dMinBoudingBox = min(dMinBoudingBox, getBoudingBox(vecstX, vecstY, time)); } printf("%.8f\n", dMinBoudingBox); return 0; }
[ "preprocessor.define.value.change", "literal.float.change" ]
833,223
833,224
u487476769
cpp
p03004
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cfloat> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <random> #include <set> #include <sstream> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> #define FOR_LT(i, beg, end) for (int64_t i = beg; i < end; i++) #define FOR_LE(i, beg, end) for (int64_t i = beg; i <= end; i++) #define FOR_DW(i, beg, end) for (int64_t i = beg; end <= i; i--) using namespace std; enum Dir { kR, kL, kU, kD }; struct Point { int64_t x; int64_t y; Dir d; }; pair<bool, int64_t> intersect(int64_t add, int64_t sub) { if (sub < add) return {false, 0}; else return {true, (sub - add) / 2}; } void add_cand(int64_t add, int64_t sub, set<int64_t> &cand) { auto ret = intersect(add, sub); if (ret.first) cand.insert(ret.second); } void add_cand_a(int64_t add, int64_t cons, set<int64_t> &cand) { if (cons < add) return; cand.insert(cons - add); } void add_cand_d(int64_t sub, int64_t cons, set<int64_t> &cand) { if (sub < cons) return; cand.insert(sub - cons); } double evaluate(vector<Point> &ps, double t) { double xmax = DBL_MIN, xmin = DBL_MAX; double ymax = DBL_MIN, ymin = DBL_MAX; for (auto &p : ps) { double x = p.x; double y = p.y; switch (p.d) { case kR: x += t; break; case kL: x -= t; break; case kU: y += t; break; case kD: y -= t; break; } xmax = max(xmax, x); xmin = min(xmin, x); ymax = max(ymax, y); ymin = min(ymin, y); } return (xmax - xmin) * (ymax - ymin); } double trisearch(vector<Point> &ps, double first, double last) { double val = DBL_MAX; FOR_LT(i, 0, 300) { double first_third = evaluate(ps, (first + first + last) / 3); double second_third = evaluate(ps, (first + last + last) / 3); val = min(val, min(first_third, second_third)); if (second_third > first_third) { last = (first + last + last) / 3; } else { first = (first + first + last) / 3; } } return val; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int64_t n; cin >> n; vector<Point> ps(n); for (auto &p : ps) { cin >> p.x >> p.y; char c; cin >> c; if (c == 'R') p.d = kR; if (c == 'L') p.d = kL; if (c == 'U') p.d = kU; if (c == 'D') p.d = kD; } double min_val = DBL_MAX; min_val = trisearch(ps, 0, 10000000000.0); cout << fixed << setprecision(15) << min_val << endl; return 0; }
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cfloat> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <random> #include <set> #include <sstream> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> #define FOR_LT(i, beg, end) for (int64_t i = beg; i < end; i++) #define FOR_LE(i, beg, end) for (int64_t i = beg; i <= end; i++) #define FOR_DW(i, beg, end) for (int64_t i = beg; end <= i; i--) using namespace std; enum Dir { kR, kL, kU, kD }; struct Point { int64_t x; int64_t y; Dir d; }; pair<bool, int64_t> intersect(int64_t add, int64_t sub) { if (sub < add) return {false, 0}; else return {true, (sub - add) / 2}; } void add_cand(int64_t add, int64_t sub, set<int64_t> &cand) { auto ret = intersect(add, sub); if (ret.first) cand.insert(ret.second); } void add_cand_a(int64_t add, int64_t cons, set<int64_t> &cand) { if (cons < add) return; cand.insert(cons - add); } void add_cand_d(int64_t sub, int64_t cons, set<int64_t> &cand) { if (sub < cons) return; cand.insert(sub - cons); } double evaluate(vector<Point> &ps, double t) { double xmax = -DBL_MAX, xmin = DBL_MAX; double ymax = -DBL_MAX, ymin = DBL_MAX; for (auto &p : ps) { double x = p.x; double y = p.y; switch (p.d) { case kR: x += t; break; case kL: x -= t; break; case kU: y += t; break; case kD: y -= t; break; } xmax = max(xmax, x); xmin = min(xmin, x); ymax = max(ymax, y); ymin = min(ymin, y); } return (xmax - xmin) * (ymax - ymin); } double trisearch(vector<Point> &ps, double first, double last) { double val = DBL_MAX; FOR_LT(i, 0, 300) { double first_third = evaluate(ps, (first + first + last) / 3); double second_third = evaluate(ps, (first + last + last) / 3); val = min(val, min(first_third, second_third)); if (second_third > first_third) { last = (first + last + last) / 3; } else { first = (first + first + last) / 3; } } return val; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int64_t n; cin >> n; vector<Point> ps(n); for (auto &p : ps) { cin >> p.x >> p.y; char c; cin >> c; if (c == 'R') p.d = kR; if (c == 'L') p.d = kL; if (c == 'U') p.d = kU; if (c == 'D') p.d = kD; } double min_val = DBL_MAX; min_val = trisearch(ps, 0, 10000000000.0); cout << fixed << setprecision(15) << min_val << endl; return 0; }
[ "expression.operation.unary.add" ]
833,228
833,229
u862095327
cpp
p03018
#include <bits/stdc++.h> #define ll long long #define str string #define pii pair<int, int> #define pll pair<ll, ll> #define fi first #define se second #define vc vector<char> #define vvc vector<vc> #define vi vector<int> #define vll vector<ll> #define vvi vector<vi> #define vvll vector<vll> #define vvvll vector<vvll> #define vs vector<str> #define vvs vector<vs> #define vpii vector<pii> #define vvpii vector<vpii> #define vpll vector<pll> #define vvpll vector<vpll> #define vb vector<bool> #define vvb vector<vb> #define rep(i, a, b) for (int i = (a); i < int(b); i++) #define repi(i, a, b) for (int i = (a); i <= int(b); i++) using namespace std; ll INF = LONG_LONG_MAX; ll mod = 1000000000 + 7; template <typename T, typename L> void read(vector<T> &_data, L &_size, bool _shift) { _data.resize(_size + (ll)_shift); for (ll i = (ll)_shift; i < _size + (ll)_shift; i++) cin >> _data[i]; } template <typename T, typename L> void read(vector<vector<T>> &_data, L &_rows, L &_cols, bool _shiftRows, bool _shiftCols) { _data.resize(_rows + (ll)_shiftRows); for (ll i = 0; i < _rows + (ll)_shiftRows; i++) _data[i].resize(_cols + (ll)_shiftCols); for (ll i = (ll)_shiftRows; i < _rows + (ll)_shiftRows; i++) for (ll j = (ll)_shiftCols; j < _cols + (ll)_shiftCols; j++) cin >> _data[i][j]; } template <typename T> void write(vector<T> &_data, bool _shift) { for (ll i = (ll)_shift; i < _data.size(); i++) cout << _data[i] << " "; cout << endl; } // TODO: SOLUTION void solve() { str s; cin >> s; ll ans = 0; ll bcsuf = 0; for (int i = s.size() - 2; i >= 0; i--) { str sub; sub.resize(2); s[0] = s[i]; s[1] = s[i + 1]; if (sub == "BC") bcsuf++; else if (sub == "BA" || sub == "BB" || sub == "CC" || sub == "AC") bcsuf = 0; else if (sub == "AB" || sub == "AA") ans += bcsuf; } cout << ans << endl; } int main() { // TODO: Set value of this variable manually bool _multipleTestCases = false; if (_multipleTestCases) { ll t; cin >> t; while (t--) solve(); } else { solve(); } return 0; }
#include <bits/stdc++.h> #define ll long long #define str string #define pii pair<int, int> #define pll pair<ll, ll> #define fi first #define se second #define vc vector<char> #define vvc vector<vc> #define vi vector<int> #define vll vector<ll> #define vvi vector<vi> #define vvll vector<vll> #define vvvll vector<vvll> #define vs vector<str> #define vvs vector<vs> #define vpii vector<pii> #define vvpii vector<vpii> #define vpll vector<pll> #define vvpll vector<vpll> #define vb vector<bool> #define vvb vector<vb> #define rep(i, a, b) for (int i = (a); i < int(b); i++) #define repi(i, a, b) for (int i = (a); i <= int(b); i++) using namespace std; ll INF = LONG_LONG_MAX; ll mod = 1000000000 + 7; template <typename T, typename L> void read(vector<T> &_data, L &_size, bool _shift) { _data.resize(_size + (ll)_shift); for (ll i = (ll)_shift; i < _size + (ll)_shift; i++) cin >> _data[i]; } template <typename T, typename L> void read(vector<vector<T>> &_data, L &_rows, L &_cols, bool _shiftRows, bool _shiftCols) { _data.resize(_rows + (ll)_shiftRows); for (ll i = 0; i < _rows + (ll)_shiftRows; i++) _data[i].resize(_cols + (ll)_shiftCols); for (ll i = (ll)_shiftRows; i < _rows + (ll)_shiftRows; i++) for (ll j = (ll)_shiftCols; j < _cols + (ll)_shiftCols; j++) cin >> _data[i][j]; } template <typename T> void write(vector<T> &_data, bool _shift) { for (ll i = (ll)_shift; i < _data.size(); i++) cout << _data[i] << " "; cout << endl; } // TODO: SOLUTION void solve() { str s; cin >> s; ll ans = 0; ll bcsuf = 0; for (int i = s.size() - 2; i >= 0; i--) { str sub; sub.resize(2); sub[0] = s[i]; sub[1] = s[i + 1]; if (sub == "BC") bcsuf++; else if (sub == "BA" || sub == "BB" || sub == "CC" || sub == "AC") bcsuf = 0; else if (sub == "AB" || sub == "AA") ans += bcsuf; } cout << ans << endl; } int main() { // TODO: Set value of this variable manually bool _multipleTestCases = false; if (_multipleTestCases) { ll t; cin >> t; while (t--) solve(); } else { solve(); } return 0; }
[ "assignment.variable.change", "identifier.change" ]
833,251
833,252
u938335949
cpp
p03018
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long ll; typedef pair<int, int> P; int main() { string s; cin >> s; int n = s.size(); int acnt = 0, ans = 0; rep(i, n - 1) { // cout << s[i] << " "; if (s[i] == 'A') { acnt++; } else { if (s[i] == 'B' && s[i + 1] == 'C') { ans += acnt; i += acnt; } else { acnt = 0; } } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long ll; typedef pair<int, int> P; int main() { string s; cin >> s; int n = s.size(); int acnt = 0; ll ans = 0; rep(i, n - 1) { // cout << s[i] << " "; if (s[i] == 'A') { acnt++; } else { if (s[i] == 'B' && s[i + 1] == 'C') { ans += acnt; i++; } else { acnt = 0; } } // cout << acnt << endl; } // cout << s.size() << endl; // cout << n << endl; cout << ans << endl; return 0; }
[]
833,274
833,273
u489302942
cpp
p03018
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long ll; typedef pair<int, int> P; int main() { string s; cin >> s; int n = s.size(); int acnt = 0, ans = 0; rep(i, n - 1) { // cout << s[i] << " "; if (s[i] == 'A') { acnt++; } else { if (s[i] == 'B' && s[i + 1] == 'C') { ans += acnt; acnt = 1; i++; } else { acnt = 0; } } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long ll; typedef pair<int, int> P; int main() { string s; cin >> s; int n = s.size(); int acnt = 0; ll ans = 0; rep(i, n - 1) { // cout << s[i] << " "; if (s[i] == 'A') { acnt++; } else { if (s[i] == 'B' && s[i + 1] == 'C') { ans += acnt; i++; } else { acnt = 0; } } // cout << acnt << endl; } // cout << s.size() << endl; // cout << n << endl; cout << ans << endl; return 0; }
[]
833,275
833,273
u489302942
cpp
p03018
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int64_t MOD = 1000000007; const long long INF = 1LL << 60; int main() { int64_t ans = 0, temp = 0; string S; cin >> S; rep(i, S.size() - 1) { if (S.at(i) == 'A') temp++; else if (S.at(i) == 'B' && S.at(i + 1) == 'C') { ans += temp; S.at(i + 1) = 'A'; temp = 0; } else temp = 0; } cout << ans; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int64_t MOD = 1000000007; const long long INF = 1LL << 60; int main() { int64_t ans = 0, temp = 0; string S; cin >> S; rep(i, S.size() - 1) { if (S.at(i) == 'A') temp++; else if (S.at(i) == 'B' && S.at(i + 1) == 'C') { ans += temp; S.at(i + 1) = 'A'; i++; } else temp = 0; } cout << ans; }
[]
833,278
833,279
u153686508
cpp
p03018
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < (int)(n); i++) typedef long long ll; typedef pair<int, int> P; int main() { string s; cin >> s; ll ans = 0; int l = 0; // Aが連続した回数 REP(i, s.size() - 2) { if (s[i] == 'A') l++; else l = 0; if (s[i] != 'A' || s[i + 1] != 'B' || s[i + 2] != 'C') continue; ans += l; swap(s[i - l + 1], s[i + 1]); swap(s[i - l + 2], s[i + 2]); } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < (int)(n); i++) typedef long long ll; typedef pair<int, int> P; int main() { string s; cin >> s; ll ans = 0; int l = 0; // Aが連続した回数 REP(i, s.size() - 2) { if (s[i] == 'A') l++; else l = 0; if (s[i] != 'A' || s[i + 1] != 'B' || s[i + 2] != 'C') continue; ans += l; swap(s[i - l + 1], s[i + 1]); swap(s[i - l + 2], s[i + 2]); l -= 2; } cout << ans << endl; }
[ "assignment.add" ]
833,286
833,287
u893239355
cpp
p03018
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define rrep(i, n) for (int i = (n - 1); i >= 0; i--) #define ALL(v) v.begin(), v.end() using namespace std; using P = pair<int, int>; typedef long long ll; int main() { string s; cin >> s; int n = s.size(); int a_count = 0; int ans = 0; rep(i, n - 2) { if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') { ans += a_count + 1; s[i + 2] = 'A'; a_count = 0; } else if (s[i] == 'A') { a_count++; } else { a_count = 0; } } cout << ans << endl; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define rrep(i, n) for (int i = (n - 1); i >= 0; i--) #define ALL(v) v.begin(), v.end() using namespace std; using P = pair<int, int>; typedef long long ll; int main() { string s; cin >> s; int n = s.size(); int a_count = 0; ll ans = 0; rep(i, n - 2) { if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') { ans += a_count + 1; s[i + 2] = 'A'; i++; } else if (s[i] == 'A') { a_count++; } else { a_count = 0; } } cout << ans << endl; }
[ "variable_declaration.type.change" ]
833,297
833,298
u233586402
cpp
p03018
#include <bits/stdc++.h> #define rep(i, a, n) for (int i = a; i < n; i++) #define repr(i, a, n) for (int i = n - 1; i >= a; i--) using namespace std; using ll = long long; using P = pair<int, int>; template <typename T> void chmin(T &a, T b) { a = min(a, b); } template <typename T> void chmax(T &a, T b) { a = max(a, b); } int main() { ios::sync_with_stdio(false); cin.tie(0); string s; cin >> s; int n = (int)s.size(); int ac = 0, ans = 0; rep(i, 0, n - 2) { if (s[i] == 'A') ac++; else ac = 0; if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') { ans += ac; ac = 0; s[i + 2] = 'A'; i++; } } cout << ans << endl; }
#include <bits/stdc++.h> #define rep(i, a, n) for (int i = a; i < n; i++) #define repr(i, a, n) for (int i = n - 1; i >= a; i--) using namespace std; using ll = long long; using P = pair<int, int>; template <typename T> void chmin(T &a, T b) { a = min(a, b); } template <typename T> void chmax(T &a, T b) { a = max(a, b); } int main() { ios::sync_with_stdio(false); cin.tie(0); string s; cin >> s; int n = (int)s.size(); ll ac = 0, ans = 0; rep(i, 0, n - 2) { if (s[i] == 'A') ac++; else ac = 0; if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') { ans += ac; ac--; s[i + 2] = 'A'; i++; } } cout << ans << endl; }
[ "variable_declaration.type.change" ]
833,316
833,315
u688789047
cpp
p03018
#include <bits/stdc++.h> using namespace std; #define int long long typedef pair<int, int> P; int INF = 1e16 + 7; int mod = 1e9 + 7; int dx[4] = {1, -1, 0, 0}; int dy[4] = {0, 0, 1, -1}; signed main() { string S; cin >> S; S += "Z"; int cnt = 0; int ans = 0; for (int i = 0; i < S.size() - 1; i++) { if (S[i] == 'A') { cnt++; } else if (S[i] == 'B' && S[i + 1] == 'C') { ans += cnt; i++; cnt = 1; } else { cnt = 0; } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define int long long typedef pair<int, int> P; int INF = 1e16 + 7; int mod = 1e9 + 7; int dx[4] = {1, -1, 0, 0}; int dy[4] = {0, 0, 1, -1}; signed main() { string S; cin >> S; S += "Z"; int cnt = 0; int ans = 0; for (int i = 0; i < S.size() - 1; i++) { if (S[i] == 'A') { cnt++; } else if (S[i] == 'B' && S[i + 1] == 'C') { ans += cnt; i++; } else { cnt = 0; } } cout << ans << endl; }
[]
833,323
833,324
u237390401
cpp
p03018
#include <algorithm> #include <iostream> #include <math.h> #include <queue> #include <string> #include <vector> #define all(x) (x).begin(), (x).end() typedef long long ll; using namespace std; int main() { string s; cin >> s; int l = s.length(); s += "ZZZZZZZZ"; int abc, a, bc, ans; abc = 0; a = 0; bc = 0; ans = 0; int i = 0; while (i < l) { if (s.substr(i, 3) == "ABC") { abc++; ans += abc + a; i += 3; } else if (s.substr(i, 1) == "A") { a++; abc = 0; i++; } else if (abc > 0 && s.substr(i, 2) == "BC") { ans += abc + a; i += 2; } else { abc = 0; a = 0; bc = 0; i++; } } cout << ans << endl; return 0; }
#include <algorithm> #include <iostream> #include <math.h> #include <queue> #include <string> #include <vector> #define all(x) (x).begin(), (x).end() typedef long long ll; using namespace std; int main() { string s; cin >> s; int l = s.length(); s += "ZZZZZZZZ"; ll abc, a, bc, ans; abc = 0; a = 0; bc = 0; ans = 0; int i = 0; while (i < l) { if (s.substr(i, 3) == "ABC") { abc++; ans += abc + a; i += 3; } else if (s.substr(i, 1) == "A") { a++; i++; } else if (abc > 0 && s.substr(i, 2) == "BC") { ans += abc + a; i += 2; } else { abc = 0; a = 0; bc = 0; i++; } } cout << ans << endl; return 0; }
[ "variable_declaration.type.change" ]
833,333
833,334
u841856382
cpp
p03018
#include <bits/stdc++.h> #define irep(i, n) for (int i = 0; i < (int)(n); i++) #define irep2(i, a, n) for (int i = (int)(a); i <= (int)(n); i++) #define irrep(i, n) for (int i = (int)(n - 1); i > -1; i--) #define irrep2(i, n, a) for (int i = (int)(n); i >= (int)(a); i--) #define fi first #define se second using ll = long long; using v_int = std::vector<int>; using v2_int = std::vector<v_int>; using v_ll = std::vector<ll>; using v2_ll = std::vector<v_ll>; using v_string = std::vector<std::string>; using v_bool = std::vector<bool>; using v2_bool = std::vector<v_bool>; using pii = std::pair<int, int>; using pll = std::pair<ll, ll>; using mii = std::map<int, int>; using mll = std::map<ll, ll>; const double PI = 3.1415926535897932; const int INF = 2 * (int)1e9; const ll LINF = (ll)1e18; const ll MOD = 1000000007; // const int dc[4] = {1, -1, 0, 0}; // const int dr[4] = {0, 0, 1, -1}; const int dc[8] = {1, -1, 0, 0, 1, -1, 1, -1}; const int dr[8] = {0, 0, 1, -1, 1, 1, -1, -1}; using namespace std; template <typename T, typename U> inline ostream &operator<<(ostream &o, pair<T, U> &p) { return o << "{" << p.first << "," << p.second << "}"; } template <typename T> inline istream &operator>>(istream &is, vector<T> &v) { int len = (int)v.size(); for (int i = 0; i < len; i++) { is >> v[i]; } return is; } template <typename T> inline ostream &operator<<(ostream &os, vector<T> &v) { int len = (int)v.size(); for (int i = 0; i < len; i++) { os << v[i]; if (i != len - 1) { os << ","; } } return os; } template <typename T> inline void chmin(T &a, T b) { a = min(a, b); } template <typename T> inline void chmax(T &a, T b) { a = max(a, b); } int main(void) { string s; cin >> s; int n = s.size(); int i = 0; int a = 0; ll ans = 0; while (i < n) { if (s[i] == 'A') { a++; i++; } else if (s[i] == 'B') { if (i + 1 < n && s.substr(i, 2) == "BC") { ans += a; i++; } else { a = 0; i++; } } else { a = 0; i++; } } cout << ans << endl; return 0; } /*atcoder*/
#include <bits/stdc++.h> #define irep(i, n) for (int i = 0; i < (int)(n); i++) #define irep2(i, a, n) for (int i = (int)(a); i <= (int)(n); i++) #define irrep(i, n) for (int i = (int)(n - 1); i > -1; i--) #define irrep2(i, n, a) for (int i = (int)(n); i >= (int)(a); i--) #define fi first #define se second using ll = long long; using v_int = std::vector<int>; using v2_int = std::vector<v_int>; using v_ll = std::vector<ll>; using v2_ll = std::vector<v_ll>; using v_string = std::vector<std::string>; using v_bool = std::vector<bool>; using v2_bool = std::vector<v_bool>; using pii = std::pair<int, int>; using pll = std::pair<ll, ll>; using mii = std::map<int, int>; using mll = std::map<ll, ll>; const double PI = 3.1415926535897932; const int INF = 2 * (int)1e9; const ll LINF = (ll)1e18; const ll MOD = 1000000007; // const int dc[4] = {1, -1, 0, 0}; // const int dr[4] = {0, 0, 1, -1}; const int dc[8] = {1, -1, 0, 0, 1, -1, 1, -1}; const int dr[8] = {0, 0, 1, -1, 1, 1, -1, -1}; using namespace std; template <typename T, typename U> inline ostream &operator<<(ostream &o, pair<T, U> &p) { return o << "{" << p.first << "," << p.second << "}"; } template <typename T> inline istream &operator>>(istream &is, vector<T> &v) { int len = (int)v.size(); for (int i = 0; i < len; i++) { is >> v[i]; } return is; } template <typename T> inline ostream &operator<<(ostream &os, vector<T> &v) { int len = (int)v.size(); for (int i = 0; i < len; i++) { os << v[i]; if (i != len - 1) { os << ","; } } return os; } template <typename T> inline void chmin(T &a, T b) { a = min(a, b); } template <typename T> inline void chmax(T &a, T b) { a = max(a, b); } int main(void) { string s; cin >> s; int n = s.size(); int i = 0; int a = 0; ll ans = 0; while (i < n) { if (s[i] == 'A') { a++; i++; } else if (s[i] == 'B') { if (i + 1 < n && s.substr(i, 2) == "BC") { ans += a; i += 2; } else { a = 0; i++; } } else { a = 0; i++; } } cout << ans << endl; return 0; } /*atcoder*/
[]
833,349
833,350
u829260400
cpp
p03018
#include <bits/stdc++.h> using namespace std; // long long using ll = long long; // pair<int, int> using PII = pair<int, int>; //最大値、mod const int MOD = 1000000007; const int mod = 1000000007; const int INF = 1000000000; const long long LINF = 1e18; const int MAX = 510000; //出力系 #define print(x) cout << x << endl #define prints(x) cout << fixed << setprecision(20) << x << endl #define printc(x) cout << setw(2) << setfill('0') << x << endl; #define yes cout << "Yes" << endl #define YES cout << "YES" << endl #define no cout << "No" << endl #define NO cout << "NO" << endl //配列入力 vector<long long> vecin(ll n) { vector<long long> res(n); for (int i = 0; i < n; i++) cin >> res[i]; return res; } // begin() end() #define all(x) (x).begin(), (x).end() // for #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define rrep(i, a, b) for (int i = (a); i > (b); i--) #define rep(i, a, b) for (int i = (a); i < (b); i++) //最大公約数 ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; } // 最小公倍数 unsigned lcm(unsigned a, unsigned b) { return a / gcd(a, b) * b; } // a = max(a, b), a = min(a, b) 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; } // num ^ pow(mod取る) ll pow_mod(ll num, ll pow, ll mod) { ll prod = 1; num %= mod; while (pow > 0) { if (pow & 1) prod = prod * num % mod; num = num * num % mod; pow >>= 1; } return prod; } // 二項係数(MODとる、1 ≦ k ≦ n ≦ 10^7 程度) // COMinit() // COM(x, y) // とコンビで使う // テーブルを作る前処理 long long fac[MAX], finv[MAX], inv[MAX]; void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 long long COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } // UnionFind struct UnionFind { vector<int> par; vector<int> rank; vector<ll> Size; UnionFind(int n = 1) { init(n); } void init(int n = 1) { par.resize(n + 1); rank.resize(n + 1); Size.resize(n + 1); for (int i = 0; i <= n; ++i) par[i] = i, rank[i] = 0, Size[i] = 1; } int root(int x) { if (par[x] == x) { return x; } else { int r = root(par[x]); return par[x] = r; } } bool issame(int x, int y) { return root(x) == root(y); } bool merge(int x, int y) { x = root(x); y = root(y); if (x == y) return false; if (rank[x] < rank[y]) swap(x, y); if (rank[x] == rank[y]) ++rank[x]; par[y] = x; Size[x] += Size[y]; return true; } ll size(int x) { return Size[root(x)]; } }; // modint構造体 struct Mint { int val; Mint inv() const { int tmp, a = val, b = mod, x = 1, y = 0; while (b) tmp = a / b, a -= tmp * b, swap(a, b), x -= tmp * y, swap(x, y); return Mint(x); } public: Mint() : val(0) {} Mint(ll x) { if ((val = x % mod) < 0) val += mod; } Mint pow(ll t) { Mint res = 1, b = *this; while (t) { if (t & 1) res *= b; b *= b; t >>= 1; } return res; } Mint &operator+=(const Mint &x) { if ((val += x.val) >= mod) val -= mod; return *this; } Mint &operator-=(const Mint &x) { if ((val += mod - x.val) >= mod) val -= mod; return *this; } Mint &operator*=(const Mint &x) { val = (ll)val * x.val % mod; return *this; } Mint &operator/=(const Mint &x) { return *this *= x.inv(); } bool operator==(const Mint &x) const { return val == x.val; } bool operator!=(const Mint &x) const { return val != x.val; } bool operator<(const Mint &x) const { return val < x.val; } bool operator<=(const Mint &x) const { return val <= x.val; } bool operator>(const Mint &x) const { return val > x.val; } bool operator>=(const Mint &x) const { return val >= x.val; } Mint operator+(const Mint &x) const { return Mint(*this) += x; } Mint operator-(const Mint &x) const { return Mint(*this) -= x; } Mint operator*(const Mint &x) const { return Mint(*this) *= x; } Mint operator/(const Mint &x) const { return Mint(*this) /= x; } }; struct factorial { vector<Mint> Fact, Finv; public: // factorial fact(10000010); // fact.nCr(a, b) //「fact」の部分は自由に名前変更可能 factorial(int maxx) { Fact.resize(maxx + 1), Finv.resize(maxx + 1); Fact[0] = Mint(1); rep(i, 0, maxx) Fact[i + 1] = Fact[i] * (i + 1); Finv[maxx] = Mint(1) / Fact[maxx]; rrep(i, maxx, 0) Finv[i - 1] = Finv[i] * i; } Mint fact(int n, bool inv = 0) { if (inv) return Finv[n]; else return Fact[n]; } Mint nPr(int n, int r) { if (n < 0 || n < r || r < 0) return Mint(0); else return Fact[n] * Finv[n - r]; } Mint nCr(int n, int r) { if (n < 0 || n < r || r < 0) return Mint(0); else return Fact[n] * Finv[r] * Finv[n - r]; } }; // 1 * 2 * 3 .... * n (mod) ll modfact(ll n) { if (n <= 1) return 1; return (n * modfact(n - 1)) % MOD; } // kが角度だった場合:cos(k * (PI / 180)); // const double PI = acos(-1);のまま使うと円周率(M_PIもあるよ) const double PI = acos(-1); // 多次元 vector 生成 例: auto dp = make_vec<long long>(N+1, 5, 5, 5); template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); } template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); } //素因数分解 vector<pair<long long, int>> factorize(long long n) { vector<pair<long long, int>> res; for (long long i = 2; i * i <= n; ++i) { if (n % i) continue; res.emplace_back(i, 0); while (n % i == 0) { n /= i; res.back().second++; } } if (n != 1) res.emplace_back(n, 1); return res; } // 素数判定 bool primejudge(long long a) { if (a <= 1) return false; for (long long i = 2; i * i <= a; i++) { if (a % i == 0) return false; } return true; } // 累積和 // vector<long long>sums(vector<int>n){ // vector<long long>res(n.size() + 1, 0); // for(int i = 0; i < n.size(); i++) res[i + 1] = n[i] + res[i]; // return res; // } int dy[4] = {0, 1, 0, -1}, dx[4] = {1, 0, -1, 0}; vector<double> v(40010); int main() { string s; cin >> s; ll len = s.length(); ll ans = 0, tmp = 0; REP(i, len - 2) { string target = s.substr(i, 3); if (target == "ABC") { s[i + 2] = 'A'; ans += tmp + 1; i++; tmp = 0; } else if (target[0] == 'A') tmp++; else tmp = 0; } print(ans); return 0; }
#include <bits/stdc++.h> using namespace std; // long long using ll = long long; // pair<int, int> using PII = pair<int, int>; //最大値、mod const int MOD = 1000000007; const int mod = 1000000007; const int INF = 1000000000; const long long LINF = 1e18; const int MAX = 510000; //出力系 #define print(x) cout << x << endl #define prints(x) cout << fixed << setprecision(20) << x << endl #define printc(x) cout << setw(2) << setfill('0') << x << endl; #define yes cout << "Yes" << endl #define YES cout << "YES" << endl #define no cout << "No" << endl #define NO cout << "NO" << endl //配列入力 vector<long long> vecin(ll n) { vector<long long> res(n); for (int i = 0; i < n; i++) cin >> res[i]; return res; } // begin() end() #define all(x) (x).begin(), (x).end() // for #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define rrep(i, a, b) for (int i = (a); i > (b); i--) #define rep(i, a, b) for (int i = (a); i < (b); i++) //最大公約数 ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; } // 最小公倍数 unsigned lcm(unsigned a, unsigned b) { return a / gcd(a, b) * b; } // a = max(a, b), a = min(a, b) 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; } // num ^ pow(mod取る) ll pow_mod(ll num, ll pow, ll mod) { ll prod = 1; num %= mod; while (pow > 0) { if (pow & 1) prod = prod * num % mod; num = num * num % mod; pow >>= 1; } return prod; } // 二項係数(MODとる、1 ≦ k ≦ n ≦ 10^7 程度) // COMinit() // COM(x, y) // とコンビで使う // テーブルを作る前処理 long long fac[MAX], finv[MAX], inv[MAX]; void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 long long COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } // UnionFind struct UnionFind { vector<int> par; vector<int> rank; vector<ll> Size; UnionFind(int n = 1) { init(n); } void init(int n = 1) { par.resize(n + 1); rank.resize(n + 1); Size.resize(n + 1); for (int i = 0; i <= n; ++i) par[i] = i, rank[i] = 0, Size[i] = 1; } int root(int x) { if (par[x] == x) { return x; } else { int r = root(par[x]); return par[x] = r; } } bool issame(int x, int y) { return root(x) == root(y); } bool merge(int x, int y) { x = root(x); y = root(y); if (x == y) return false; if (rank[x] < rank[y]) swap(x, y); if (rank[x] == rank[y]) ++rank[x]; par[y] = x; Size[x] += Size[y]; return true; } ll size(int x) { return Size[root(x)]; } }; // modint構造体 struct Mint { int val; Mint inv() const { int tmp, a = val, b = mod, x = 1, y = 0; while (b) tmp = a / b, a -= tmp * b, swap(a, b), x -= tmp * y, swap(x, y); return Mint(x); } public: Mint() : val(0) {} Mint(ll x) { if ((val = x % mod) < 0) val += mod; } Mint pow(ll t) { Mint res = 1, b = *this; while (t) { if (t & 1) res *= b; b *= b; t >>= 1; } return res; } Mint &operator+=(const Mint &x) { if ((val += x.val) >= mod) val -= mod; return *this; } Mint &operator-=(const Mint &x) { if ((val += mod - x.val) >= mod) val -= mod; return *this; } Mint &operator*=(const Mint &x) { val = (ll)val * x.val % mod; return *this; } Mint &operator/=(const Mint &x) { return *this *= x.inv(); } bool operator==(const Mint &x) const { return val == x.val; } bool operator!=(const Mint &x) const { return val != x.val; } bool operator<(const Mint &x) const { return val < x.val; } bool operator<=(const Mint &x) const { return val <= x.val; } bool operator>(const Mint &x) const { return val > x.val; } bool operator>=(const Mint &x) const { return val >= x.val; } Mint operator+(const Mint &x) const { return Mint(*this) += x; } Mint operator-(const Mint &x) const { return Mint(*this) -= x; } Mint operator*(const Mint &x) const { return Mint(*this) *= x; } Mint operator/(const Mint &x) const { return Mint(*this) /= x; } }; struct factorial { vector<Mint> Fact, Finv; public: // factorial fact(10000010); // fact.nCr(a, b) //「fact」の部分は自由に名前変更可能 factorial(int maxx) { Fact.resize(maxx + 1), Finv.resize(maxx + 1); Fact[0] = Mint(1); rep(i, 0, maxx) Fact[i + 1] = Fact[i] * (i + 1); Finv[maxx] = Mint(1) / Fact[maxx]; rrep(i, maxx, 0) Finv[i - 1] = Finv[i] * i; } Mint fact(int n, bool inv = 0) { if (inv) return Finv[n]; else return Fact[n]; } Mint nPr(int n, int r) { if (n < 0 || n < r || r < 0) return Mint(0); else return Fact[n] * Finv[n - r]; } Mint nCr(int n, int r) { if (n < 0 || n < r || r < 0) return Mint(0); else return Fact[n] * Finv[r] * Finv[n - r]; } }; // 1 * 2 * 3 .... * n (mod) ll modfact(ll n) { if (n <= 1) return 1; return (n * modfact(n - 1)) % MOD; } // kが角度だった場合:cos(k * (PI / 180)); // const double PI = acos(-1);のまま使うと円周率(M_PIもあるよ) const double PI = acos(-1); // 多次元 vector 生成 例: auto dp = make_vec<long long>(N+1, 5, 5, 5); template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); } template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); } //素因数分解 vector<pair<long long, int>> factorize(long long n) { vector<pair<long long, int>> res; for (long long i = 2; i * i <= n; ++i) { if (n % i) continue; res.emplace_back(i, 0); while (n % i == 0) { n /= i; res.back().second++; } } if (n != 1) res.emplace_back(n, 1); return res; } // 素数判定 bool primejudge(long long a) { if (a <= 1) return false; for (long long i = 2; i * i <= a; i++) { if (a % i == 0) return false; } return true; } // 累積和 // vector<long long>sums(vector<int>n){ // vector<long long>res(n.size() + 1, 0); // for(int i = 0; i < n.size(); i++) res[i + 1] = n[i] + res[i]; // return res; // } int dy[4] = {0, 1, 0, -1}, dx[4] = {1, 0, -1, 0}; vector<double> v(40010); int main() { string s; cin >> s; ll len = s.length(); ll ans = 0, tmp = 0; REP(i, len - 2) { string target = s.substr(i, 3); if (target == "ABC") { s[i + 2] = 'A'; ans += tmp + 1; i++; // tmp = 0; } else if (target[0] == 'A') tmp++; else tmp = 0; } print(ans); return 0; }
[]
833,356
833,357
u832995587
cpp
p03018
#include <bits/stdc++.h> using namespace std; // long long using ll = long long; // pair<int, int> using PII = pair<int, int>; //最大値、mod const int MOD = 1000000007; const int mod = 1000000007; const int INF = 1000000000; const long long LINF = 1e18; const int MAX = 510000; //出力系 #define print(x) cout << x << endl #define prints(x) cout << fixed << setprecision(20) << x << endl #define printc(x) cout << setw(2) << setfill('0') << x << endl; #define yes cout << "Yes" << endl #define YES cout << "YES" << endl #define no cout << "No" << endl #define NO cout << "NO" << endl //配列入力 vector<long long> vecin(ll n) { vector<long long> res(n); for (int i = 0; i < n; i++) cin >> res[i]; return res; } // begin() end() #define all(x) (x).begin(), (x).end() // for #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define rrep(i, a, b) for (int i = (a); i > (b); i--) #define rep(i, a, b) for (int i = (a); i < (b); i++) //最大公約数 ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; } // 最小公倍数 unsigned lcm(unsigned a, unsigned b) { return a / gcd(a, b) * b; } // a = max(a, b), a = min(a, b) 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; } // num ^ pow(mod取る) ll pow_mod(ll num, ll pow, ll mod) { ll prod = 1; num %= mod; while (pow > 0) { if (pow & 1) prod = prod * num % mod; num = num * num % mod; pow >>= 1; } return prod; } // 二項係数(MODとる、1 ≦ k ≦ n ≦ 10^7 程度) // COMinit() // COM(x, y) // とコンビで使う // テーブルを作る前処理 long long fac[MAX], finv[MAX], inv[MAX]; void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 long long COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } // UnionFind struct UnionFind { vector<int> par; vector<int> rank; vector<ll> Size; UnionFind(int n = 1) { init(n); } void init(int n = 1) { par.resize(n + 1); rank.resize(n + 1); Size.resize(n + 1); for (int i = 0; i <= n; ++i) par[i] = i, rank[i] = 0, Size[i] = 1; } int root(int x) { if (par[x] == x) { return x; } else { int r = root(par[x]); return par[x] = r; } } bool issame(int x, int y) { return root(x) == root(y); } bool merge(int x, int y) { x = root(x); y = root(y); if (x == y) return false; if (rank[x] < rank[y]) swap(x, y); if (rank[x] == rank[y]) ++rank[x]; par[y] = x; Size[x] += Size[y]; return true; } ll size(int x) { return Size[root(x)]; } }; // modint構造体 struct Mint { int val; Mint inv() const { int tmp, a = val, b = mod, x = 1, y = 0; while (b) tmp = a / b, a -= tmp * b, swap(a, b), x -= tmp * y, swap(x, y); return Mint(x); } public: Mint() : val(0) {} Mint(ll x) { if ((val = x % mod) < 0) val += mod; } Mint pow(ll t) { Mint res = 1, b = *this; while (t) { if (t & 1) res *= b; b *= b; t >>= 1; } return res; } Mint &operator+=(const Mint &x) { if ((val += x.val) >= mod) val -= mod; return *this; } Mint &operator-=(const Mint &x) { if ((val += mod - x.val) >= mod) val -= mod; return *this; } Mint &operator*=(const Mint &x) { val = (ll)val * x.val % mod; return *this; } Mint &operator/=(const Mint &x) { return *this *= x.inv(); } bool operator==(const Mint &x) const { return val == x.val; } bool operator!=(const Mint &x) const { return val != x.val; } bool operator<(const Mint &x) const { return val < x.val; } bool operator<=(const Mint &x) const { return val <= x.val; } bool operator>(const Mint &x) const { return val > x.val; } bool operator>=(const Mint &x) const { return val >= x.val; } Mint operator+(const Mint &x) const { return Mint(*this) += x; } Mint operator-(const Mint &x) const { return Mint(*this) -= x; } Mint operator*(const Mint &x) const { return Mint(*this) *= x; } Mint operator/(const Mint &x) const { return Mint(*this) /= x; } }; struct factorial { vector<Mint> Fact, Finv; public: // factorial fact(10000010); // fact.nCr(a, b) //「fact」の部分は自由に名前変更可能 factorial(int maxx) { Fact.resize(maxx + 1), Finv.resize(maxx + 1); Fact[0] = Mint(1); rep(i, 0, maxx) Fact[i + 1] = Fact[i] * (i + 1); Finv[maxx] = Mint(1) / Fact[maxx]; rrep(i, maxx, 0) Finv[i - 1] = Finv[i] * i; } Mint fact(int n, bool inv = 0) { if (inv) return Finv[n]; else return Fact[n]; } Mint nPr(int n, int r) { if (n < 0 || n < r || r < 0) return Mint(0); else return Fact[n] * Finv[n - r]; } Mint nCr(int n, int r) { if (n < 0 || n < r || r < 0) return Mint(0); else return Fact[n] * Finv[r] * Finv[n - r]; } }; // 1 * 2 * 3 .... * n (mod) ll modfact(ll n) { if (n <= 1) return 1; return (n * modfact(n - 1)) % MOD; } // kが角度だった場合:cos(k * (PI / 180)); // const double PI = acos(-1);のまま使うと円周率(M_PIもあるよ) const double PI = acos(-1); // 多次元 vector 生成 例: auto dp = make_vec<long long>(N+1, 5, 5, 5); template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); } template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); } //素因数分解 vector<pair<long long, int>> factorize(long long n) { vector<pair<long long, int>> res; for (long long i = 2; i * i <= n; ++i) { if (n % i) continue; res.emplace_back(i, 0); while (n % i == 0) { n /= i; res.back().second++; } } if (n != 1) res.emplace_back(n, 1); return res; } // 素数判定 bool primejudge(long long a) { if (a <= 1) return false; for (long long i = 2; i * i <= a; i++) { if (a % i == 0) return false; } return true; } // 累積和 // vector<long long>sums(vector<int>n){ // vector<long long>res(n.size() + 1, 0); // for(int i = 0; i < n.size(); i++) res[i + 1] = n[i] + res[i]; // return res; // } int dy[4] = {0, 1, 0, -1}, dx[4] = {1, 0, -1, 0}; vector<double> v(40010); int main() { string s; cin >> s; int len = s.length(); int ans = 0, tmp = 0; REP(i, len - 2) { string target = s.substr(i, 3); if (target == "ABC") { s[i + 2] = 'A'; ans += tmp + 1; i++; tmp = 0; } else if (target[0] == 'A') tmp++; else tmp = 0; } print(ans); return 0; }
#include <bits/stdc++.h> using namespace std; // long long using ll = long long; // pair<int, int> using PII = pair<int, int>; //最大値、mod const int MOD = 1000000007; const int mod = 1000000007; const int INF = 1000000000; const long long LINF = 1e18; const int MAX = 510000; //出力系 #define print(x) cout << x << endl #define prints(x) cout << fixed << setprecision(20) << x << endl #define printc(x) cout << setw(2) << setfill('0') << x << endl; #define yes cout << "Yes" << endl #define YES cout << "YES" << endl #define no cout << "No" << endl #define NO cout << "NO" << endl //配列入力 vector<long long> vecin(ll n) { vector<long long> res(n); for (int i = 0; i < n; i++) cin >> res[i]; return res; } // begin() end() #define all(x) (x).begin(), (x).end() // for #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define rrep(i, a, b) for (int i = (a); i > (b); i--) #define rep(i, a, b) for (int i = (a); i < (b); i++) //最大公約数 ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; } // 最小公倍数 unsigned lcm(unsigned a, unsigned b) { return a / gcd(a, b) * b; } // a = max(a, b), a = min(a, b) 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; } // num ^ pow(mod取る) ll pow_mod(ll num, ll pow, ll mod) { ll prod = 1; num %= mod; while (pow > 0) { if (pow & 1) prod = prod * num % mod; num = num * num % mod; pow >>= 1; } return prod; } // 二項係数(MODとる、1 ≦ k ≦ n ≦ 10^7 程度) // COMinit() // COM(x, y) // とコンビで使う // テーブルを作る前処理 long long fac[MAX], finv[MAX], inv[MAX]; void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 long long COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } // UnionFind struct UnionFind { vector<int> par; vector<int> rank; vector<ll> Size; UnionFind(int n = 1) { init(n); } void init(int n = 1) { par.resize(n + 1); rank.resize(n + 1); Size.resize(n + 1); for (int i = 0; i <= n; ++i) par[i] = i, rank[i] = 0, Size[i] = 1; } int root(int x) { if (par[x] == x) { return x; } else { int r = root(par[x]); return par[x] = r; } } bool issame(int x, int y) { return root(x) == root(y); } bool merge(int x, int y) { x = root(x); y = root(y); if (x == y) return false; if (rank[x] < rank[y]) swap(x, y); if (rank[x] == rank[y]) ++rank[x]; par[y] = x; Size[x] += Size[y]; return true; } ll size(int x) { return Size[root(x)]; } }; // modint構造体 struct Mint { int val; Mint inv() const { int tmp, a = val, b = mod, x = 1, y = 0; while (b) tmp = a / b, a -= tmp * b, swap(a, b), x -= tmp * y, swap(x, y); return Mint(x); } public: Mint() : val(0) {} Mint(ll x) { if ((val = x % mod) < 0) val += mod; } Mint pow(ll t) { Mint res = 1, b = *this; while (t) { if (t & 1) res *= b; b *= b; t >>= 1; } return res; } Mint &operator+=(const Mint &x) { if ((val += x.val) >= mod) val -= mod; return *this; } Mint &operator-=(const Mint &x) { if ((val += mod - x.val) >= mod) val -= mod; return *this; } Mint &operator*=(const Mint &x) { val = (ll)val * x.val % mod; return *this; } Mint &operator/=(const Mint &x) { return *this *= x.inv(); } bool operator==(const Mint &x) const { return val == x.val; } bool operator!=(const Mint &x) const { return val != x.val; } bool operator<(const Mint &x) const { return val < x.val; } bool operator<=(const Mint &x) const { return val <= x.val; } bool operator>(const Mint &x) const { return val > x.val; } bool operator>=(const Mint &x) const { return val >= x.val; } Mint operator+(const Mint &x) const { return Mint(*this) += x; } Mint operator-(const Mint &x) const { return Mint(*this) -= x; } Mint operator*(const Mint &x) const { return Mint(*this) *= x; } Mint operator/(const Mint &x) const { return Mint(*this) /= x; } }; struct factorial { vector<Mint> Fact, Finv; public: // factorial fact(10000010); // fact.nCr(a, b) //「fact」の部分は自由に名前変更可能 factorial(int maxx) { Fact.resize(maxx + 1), Finv.resize(maxx + 1); Fact[0] = Mint(1); rep(i, 0, maxx) Fact[i + 1] = Fact[i] * (i + 1); Finv[maxx] = Mint(1) / Fact[maxx]; rrep(i, maxx, 0) Finv[i - 1] = Finv[i] * i; } Mint fact(int n, bool inv = 0) { if (inv) return Finv[n]; else return Fact[n]; } Mint nPr(int n, int r) { if (n < 0 || n < r || r < 0) return Mint(0); else return Fact[n] * Finv[n - r]; } Mint nCr(int n, int r) { if (n < 0 || n < r || r < 0) return Mint(0); else return Fact[n] * Finv[r] * Finv[n - r]; } }; // 1 * 2 * 3 .... * n (mod) ll modfact(ll n) { if (n <= 1) return 1; return (n * modfact(n - 1)) % MOD; } // kが角度だった場合:cos(k * (PI / 180)); // const double PI = acos(-1);のまま使うと円周率(M_PIもあるよ) const double PI = acos(-1); // 多次元 vector 生成 例: auto dp = make_vec<long long>(N+1, 5, 5, 5); template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); } template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); } //素因数分解 vector<pair<long long, int>> factorize(long long n) { vector<pair<long long, int>> res; for (long long i = 2; i * i <= n; ++i) { if (n % i) continue; res.emplace_back(i, 0); while (n % i == 0) { n /= i; res.back().second++; } } if (n != 1) res.emplace_back(n, 1); return res; } // 素数判定 bool primejudge(long long a) { if (a <= 1) return false; for (long long i = 2; i * i <= a; i++) { if (a % i == 0) return false; } return true; } // 累積和 // vector<long long>sums(vector<int>n){ // vector<long long>res(n.size() + 1, 0); // for(int i = 0; i < n.size(); i++) res[i + 1] = n[i] + res[i]; // return res; // } int dy[4] = {0, 1, 0, -1}, dx[4] = {1, 0, -1, 0}; vector<double> v(40010); int main() { string s; cin >> s; ll len = s.length(); ll ans = 0, tmp = 0; REP(i, len - 2) { string target = s.substr(i, 3); if (target == "ABC") { s[i + 2] = 'A'; ans += tmp + 1; i++; // tmp = 0; } else if (target[0] == 'A') tmp++; else tmp = 0; } print(ans); return 0; }
[ "variable_declaration.type.change" ]
833,359
833,357
u832995587
cpp
p03018
#include <algorithm> #include <cmath> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define rep1(i, n) for (int i = 1; i < n; i++) #define ll long long #define INF 2147483647 using namespace std; using Graph = vector<vector<int>>; int main() { string s, t = ""; cin >> s; ll n = s.length(), ans = 0, cons = 0; rep(i, s.length()) { if (s[i] == 'A') { cons++; } else if (i < n - 1 && s[i] == 'B' && s[i + 1] == 'C') { ans += cons; } else { cons = 0; } } cout << ans; }
#include <algorithm> #include <cmath> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define rep1(i, n) for (int i = 1; i < n; i++) #define ll long long #define INF 2147483647 using namespace std; using Graph = vector<vector<int>>; int main() { string s, t = ""; cin >> s; ll n = s.length(), ans = 0, cons = 0; rep(i, s.length()) { if (s[i] == 'A') { cons++; } else if (i < n - 1 && s[i] == 'B' && s[i + 1] == 'C') { ans += cons; i++; } else { cons = 0; } } cout << ans; }
[ "expression.unary.arithmetic.add" ]
833,407
833,408
u170301438
cpp
p03018
// includes #include <bits/stdc++.h> // macros #define ll long long int #define pb emplace_back #define mk make_pair #define pq priority_queue #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define rep(i, n) FOR(i, 0, n) #define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--) #define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr) #define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr) #define vrep(v, i) for (int i = 0; i < (v).size(); i++) #define all(x) (x).begin(), (x).end() #define sz(x) ((int)(x).size()) #define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) #define FI first #define SE second #define dump(a, n) \ for (int i = 0; i < n; i++) \ cout << a[i] << "\n "[i + 1 != n]; #define dump2(a, n, m) \ for (int i = 0; i < n; i++) \ for (int j = 0; j < m; j++) \ cout << a[i][j] << "\n "[j + 1 != m]; #define bit(n) (1LL << (n)) #define INT(n) \ int n; \ cin >> n; #define LL(n) \ ll n; \ cin >> n; #define DOUBLE(n) \ double n; \ cin >> n; using namespace std; // types typedef pair<int, int> P; typedef pair<ll, int> Pl; typedef pair<ll, ll> Pll; typedef pair<double, double> Pd; typedef complex<double> cd; // constants const int inf = 1e9; const ll linf = 1LL << 50; const double EPS = 1e-10; const int mod = 1e9 + 7; const int dx[4] = {-1, 0, 1, 0}; const int dy[4] = {0, -1, 0, 1}; // solve template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; } template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (auto &v : vec) is >> v; return is; } template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) { for (int i = 0; i < vec.size(); i++) { os << vec[i]; if (i + 1 != vec.size()) os << " "; } return os; } template <typename T> ostream &operator<<(ostream &os, const set<T> &st) { for (auto itr = st.begin(); itr != st.end(); ++itr) { os << *itr; auto titr = itr; if (++titr != st.end()) os << " "; } return os; } template <typename T> ostream &operator<<(ostream &os, const unordered_set<T> &st) { for (auto itr = st.begin(); itr != st.end(); ++itr) { os << *itr; auto titr = itr; if (++titr != st.end()) os << " "; } return os; } template <typename T> ostream &operator<<(ostream &os, const multiset<T> &st) { for (auto itr = st.begin(); itr != st.end(); ++itr) { os << *itr; auto titr = itr; if (++titr != st.end()) os << " "; } return os; } template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &st) { for (auto itr = st.begin(); itr != st.end(); ++itr) { os << *itr; auto titr = itr; if (++titr != st.end()) os << " "; } return os; } template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << p.first << " " << p.second; return os; } template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp) { for (auto itr = mp.begin(); itr != mp.end(); ++itr) { os << itr->first << ":" << itr->second; auto titr = itr; if (++titr != mp.end()) os << " "; } return os; } template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp) { for (auto itr = mp.begin(); itr != mp.end(); ++itr) { os << itr->first << ":" << itr->second; auto titr = itr; if (++titr != mp.end()) os << " "; } return os; } int main(int argc, char const *argv[]) { ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20); string s; cin >> s; vector<string> t; string curr = ""; for (int i = 0; i < sz(s);) { if (s[i] == 'A') curr += s[i++]; else { if (i < sz(s) - 1 && s[i] == 'B' && s[i + 1] == 'C') { curr += "D"; i += 2; } else { if (sz(curr)) t.pb(curr); curr = ""; i++; } } } if (sz(curr) > 0) t.pb(curr); ll res = 0; for (int i = 0; i < sz(t); i++) { ll all = 0; ll curr = 0; for (int j = 0; j < sz(t[i]); j++) { if (t[i][j] == 'D') all++; } vector<ll> l, r; for (int j = 0; j < sz(t[i]); j++) { if (t[i][j] == 'A') { l.pb(curr); r.pb(all - curr); } else { curr++; } } if (sz(l) == 0) continue; FOR(j, 1, sz(l)) l[j] += l[j - 1]; for (int j = sz(r) - 2; j >= 0; j--) r[j] += r[j + 1]; ll tmp = max(l[sz(l) - 1], r[0]); for (int j = 0; j < sz(l) - 1; j++) { tmp = max(tmp, l[j] + r[j + 1]); } res += tmp; } cout << res << endl; return 0; }
// includes #include <bits/stdc++.h> // macros #define ll long long int #define pb emplace_back #define mk make_pair #define pq priority_queue #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define rep(i, n) FOR(i, 0, n) #define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--) #define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr) #define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr) #define vrep(v, i) for (int i = 0; i < (v).size(); i++) #define all(x) (x).begin(), (x).end() #define sz(x) ((int)(x).size()) #define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) #define FI first #define SE second #define dump(a, n) \ for (int i = 0; i < n; i++) \ cout << a[i] << "\n "[i + 1 != n]; #define dump2(a, n, m) \ for (int i = 0; i < n; i++) \ for (int j = 0; j < m; j++) \ cout << a[i][j] << "\n "[j + 1 != m]; #define bit(n) (1LL << (n)) #define INT(n) \ int n; \ cin >> n; #define LL(n) \ ll n; \ cin >> n; #define DOUBLE(n) \ double n; \ cin >> n; using namespace std; // types typedef pair<int, int> P; typedef pair<ll, int> Pl; typedef pair<ll, ll> Pll; typedef pair<double, double> Pd; typedef complex<double> cd; // constants const int inf = 1e9; const ll linf = 1LL << 50; const double EPS = 1e-10; const int mod = 1e9 + 7; const int dx[4] = {-1, 0, 1, 0}; const int dy[4] = {0, -1, 0, 1}; // solve template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; } template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (auto &v : vec) is >> v; return is; } template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) { for (int i = 0; i < vec.size(); i++) { os << vec[i]; if (i + 1 != vec.size()) os << " "; } return os; } template <typename T> ostream &operator<<(ostream &os, const set<T> &st) { for (auto itr = st.begin(); itr != st.end(); ++itr) { os << *itr; auto titr = itr; if (++titr != st.end()) os << " "; } return os; } template <typename T> ostream &operator<<(ostream &os, const unordered_set<T> &st) { for (auto itr = st.begin(); itr != st.end(); ++itr) { os << *itr; auto titr = itr; if (++titr != st.end()) os << " "; } return os; } template <typename T> ostream &operator<<(ostream &os, const multiset<T> &st) { for (auto itr = st.begin(); itr != st.end(); ++itr) { os << *itr; auto titr = itr; if (++titr != st.end()) os << " "; } return os; } template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &st) { for (auto itr = st.begin(); itr != st.end(); ++itr) { os << *itr; auto titr = itr; if (++titr != st.end()) os << " "; } return os; } template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << p.first << " " << p.second; return os; } template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp) { for (auto itr = mp.begin(); itr != mp.end(); ++itr) { os << itr->first << ":" << itr->second; auto titr = itr; if (++titr != mp.end()) os << " "; } return os; } template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp) { for (auto itr = mp.begin(); itr != mp.end(); ++itr) { os << itr->first << ":" << itr->second; auto titr = itr; if (++titr != mp.end()) os << " "; } return os; } int main(int argc, char const *argv[]) { ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20); string s; cin >> s; vector<string> t; string curr = ""; for (int i = 0; i < sz(s);) { if (s[i] == 'A') curr += s[i++]; else { if (i < sz(s) - 1 && s[i] == 'B' && s[i + 1] == 'C') { curr += "D"; i += 2; } else { if (sz(curr)) t.pb(curr); curr = ""; i++; } } } if (sz(curr) > 0) t.pb(curr); ll res = 0; for (int i = 0; i < sz(t); i++) { ll all = 0; ll curr = 0; for (int j = 0; j < sz(t[i]); j++) { if (t[i][j] == 'D') all++; } vector<ll> l, r; for (int j = 0; j < sz(t[i]); j++) { if (t[i][j] == 'A') { l.pb(curr); r.pb(all - curr); } else { curr++; } } if (sz(l) == 0) continue; FOR(j, 1, sz(l)) l[j] += l[j - 1]; for (int j = sz(r) - 2; j >= 0; j--) r[j] += r[j + 1]; ll tmp = max(l[sz(l) - 1], r[0]); for (int j = 0; j < sz(l) - 1; j++) { tmp = max(tmp, l[j] + r[j + 1]); } // res += tmp; res += r[0]; } cout << res << endl; return 0; }
[ "assignment.value.change" ]
833,451
833,452
u424110125
cpp
p03018
#include <bits/stdc++.h> using namespace std; #define MAXNUM 222222 typedef long long ll; char s[MAXNUM]; int main() { scanf("%s", s); int ssize = strlen(s); int bef = 0; ll res = 0; for (int i = ssize - 1; i >= 0; i--) { if (bef && s[i] == 'C' && s[i + 1] == 'B') bef++; else if (s[i] == 'B' && s[i + 1] == 'C') bef++; else if (s[i] == 'A' && s[i + 1] == 'B') res += bef + 1, s[i] = s[i + 1]; else bef = 0; } printf("%lld\n", res / 2); }
#include <bits/stdc++.h> using namespace std; #define MAXNUM 222222 typedef long long ll; char s[MAXNUM]; int main() { scanf("%s", s); int ssize = strlen(s); int bef = 0; ll res = 0; for (int i = ssize - 1; i >= 0; i--) { if (bef && s[i] == 'C' && s[i + 1] == 'B') bef++; else if (s[i] == 'B' && s[i + 1] == 'C') bef++; else if (s[i] == 'A' && s[i + 1] == 'B' && bef) res += bef + 1, s[i] = s[i + 1]; else bef = 0; } printf("%lld\n", res / 2); }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change" ]
833,489
833,490
u930038564
cpp
p03018
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++) #define reps(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; i++) #define rrep(i, n) for (int i = (n)-1; i >= 0; i--) #define rreps(i, e, n) for (int i = (n)-1; i >= (e); i--) #define all(x) (x).begin(), (x).end() #define sz(x) ((int)(x).size()) #define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end()) int main() { cin.tie(0); ios::sync_with_stdio(false); string s; cin >> s; int sl = s.length(); int ans = 0, acnt = 0; rep(i, sl) { if ((i < (sl - 2)) && (s[i] == 'A') && (s[i + 1] == 'B') && (s[i + 2] == 'C')) { s[i] = 'B'; s[i + 1] = 'C'; s[i + 2] = 'A'; if (acnt > 0) { s[i + 1] = 'A'; } ans += 1 + acnt; acnt = 0; } else if (s[i] == 'A') { acnt++; } else { acnt = 0; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++) #define reps(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; i++) #define rrep(i, n) for (int i = (n)-1; i >= 0; i--) #define rreps(i, e, n) for (int i = (n)-1; i >= (e); i--) #define all(x) (x).begin(), (x).end() #define sz(x) ((int)(x).size()) #define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end()) int main() { cin.tie(0); ios::sync_with_stdio(false); string s; cin >> s; int sl = s.length(); ll ans = 0, acnt = 0; rep(i, sl) { if ((i < (sl - 2)) && (s[i] == 'A') && (s[i + 1] == 'B') && (s[i + 2] == 'C')) { s[i] = 'B'; s[i + 1] = 'C'; s[i + 2] = 'A'; if (acnt > 0) { s[i + 1] = 'A'; } ans += 1 + acnt; acnt--; } else if (s[i] == 'A') { acnt++; } else { acnt = 0; } } cout << ans << endl; return 0; }
[ "variable_declaration.type.change" ]
833,525
833,524
u225581241
cpp
p03018
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int n = s.size(); long long ans = 0; int w = 0; for (int i = 0; i < n; i++) { if (s[i] == 'A') { w++; } else if (s.substr(i, 2) == "BC") { ans += w; } else { w = 0; } } printf("%lld\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int n = s.size(); long long ans = 0; int w = 0; for (int i = 0; i < n; i++) { if (s[i] == 'A') { w++; } else if (s.substr(i, 2) == "BC") { ans += w; i++; } else { w = 0; } } printf("%lld\n", ans); return 0; }
[ "expression.unary.arithmetic.add" ]
833,532
833,533
u123756661
cpp
p03018
#include <iostream> #include <string> using namespace std; typedef long long ll; string s; ll N; int main() { cin >> s; N = s.size(); ll count = 0; ll p = 0; ll ans = 0; while (p < N - 2) { if (s[p] == 'A' && s[p + 1] == 'B' && s[p + 2] == 'C') { ans += count + 1; count = 0; s[p + 2] = 'A'; p += 2; continue; } if (s[p] == 'A') count++; else count = 0; p++; } cout << ans << endl; return 0; }
#include <iostream> #include <string> using namespace std; typedef long long ll; string s; ll N; int main() { cin >> s; N = s.size(); ll count = 0; ll p = 0; ll ans = 0; while (p < N - 2) { if (s[p] == 'A' && s[p + 1] == 'B' && s[p + 2] == 'C') { ans += count + 1; s[p + 2] = 'A'; p += 2; continue; } if (s[p] == 'A') count++; else count = 0; p++; } cout << ans << endl; return 0; }
[]
833,537
833,538
u705230587
cpp
p03018
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; reverse(s.begin(), s.end()); int cnt = 0; long long ans = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == 'B' && s[i + 1] == 'C') { cnt++; i++; } else if (s[i] == 'A') { ans += cnt; } else { cnt = 0; } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; reverse(s.begin(), s.end()); int cnt = 0; long long ans = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == 'C' && s[i + 1] == 'B') { cnt++; i++; } else if (s[i] == 'A') { ans += cnt; } else { cnt = 0; } } cout << ans << endl; }
[ "literal.string.change", "control_flow.branch.if.condition.change" ]
833,549
833,550
u660341491
cpp
p03018
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> Pii; typedef pair<ll, ll> Pll; #define rep(i, n) for (ll i = 0; i < n; ++i) #define rep2(i, a, b) for (ll i = a; i < b; ++i) const ll MOD = 1000000007; string alp = "abcdefghijklmnopqrstuvwxyz"; int main() { string S; cin >> S; ll ans = 0; ll count = 0; rep(i, S.size()) { if (S[i] == 'A') { count++; } else if (S[i] == 'B') { if (count > 0 && S[i + 1] == 'C') { ans += count; count = 1; i++; } else { count = 0; } } else { count = 0; } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> Pii; typedef pair<ll, ll> Pll; #define rep(i, n) for (ll i = 0; i < n; ++i) #define rep2(i, a, b) for (ll i = a; i < b; ++i) const ll MOD = 1000000007; string alp = "abcdefghijklmnopqrstuvwxyz"; int main() { string S; cin >> S; ll ans = 0; ll count = 0; rep(i, S.size()) { if (S[i] == 'A') { count++; } else if (S[i] == 'B') { if (count > 0 && S[i + 1] == 'C') { ans += count; i++; } else { count = 0; } } else { count = 0; } } cout << ans << endl; }
[]
833,563
833,564
u275786410
cpp
p03018
#include <bits/stdc++.h> using namespace std; int move_cnt[200005]; int main(void) { string S; cin >> S; S.push_back('A'); int N = S.length(); int BC_cnt = 0; long long ans = 0; for (int i = N - 1; 0 <= i; i--) { if (0 < i && S[i - 1] == 'B' && S[i] == 'C') { BC_cnt++; i--; } else if (S[i] == 'A') { move_cnt[i] = BC_cnt + move_cnt[i + 2 * BC_cnt + 1]; } else { BC_cnt = 0; } ans += move_cnt[i]; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int move_cnt[200005]; int main(void) { string S; cin >> S; S.push_back('A'); int N = S.length(); int BC_cnt = 0; long long ans = 0; for (int i = N - 1; 0 <= i; i--) { if (0 < i && S[i - 1] == 'B' && S[i] == 'C') { BC_cnt++; i--; } else if (S[i] == 'A') { move_cnt[i] = BC_cnt + move_cnt[i + 2 * BC_cnt + 1]; BC_cnt = 0; } else { BC_cnt = 0; } ans += move_cnt[i]; } cout << ans << endl; }
[ "assignment.add" ]
833,617
833,618
u543284218
cpp
p03018
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; #define MOD 1000000007 #define INF 1 << 30 #define LINF (ll)1 << 62 #define rep(i, n) for (ll i = 0; i < (n); i++) #define REP(i, a, b) for (ll i = (a); i < (b); i++) #define all(x) (x).begin(), (x).end() using namespace std; typedef long long ll; typedef vector<ll> vl; typedef vector<vl> vvl; typedef pair<ll, ll> P; typedef vector<pair<ll, ll>> vpl; ll GCD(ll a, ll b) { if (b == 0) return a; else return GCD(b, a % b); } int main() { string s; cin >> s; ll acount = 0; ll ans = 0; if (s.size() < 3) cout << 0 << endl; else { for (ll i = 0; i < s.size() - 2; i++) { // cout << i << endl; if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') { ans += acount + 1; // cout << "acount : " << acount << endl; // cout << "ans : " << ans << endl; acount = 0; s[i + 2] = 'A'; i++; } else { if (s[i] == 'A') acount++; else acount = 0; } } cout << ans << endl; } }
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; #define MOD 1000000007 #define INF 1 << 30 #define LINF (ll)1 << 62 #define rep(i, n) for (ll i = 0; i < (n); i++) #define REP(i, a, b) for (ll i = (a); i < (b); i++) #define all(x) (x).begin(), (x).end() using namespace std; typedef long long ll; typedef vector<ll> vl; typedef vector<vl> vvl; typedef pair<ll, ll> P; typedef vector<pair<ll, ll>> vpl; ll GCD(ll a, ll b) { if (b == 0) return a; else return GCD(b, a % b); } int main() { string s; cin >> s; ll acount = 0; ll ans = 0; if (s.size() < 3) cout << 0 << endl; else { for (ll i = 0; i < s.size() - 2; i++) { // cout << i << endl; if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') { ans += acount + 1; // cout << "acount : " << acount << endl; // cout << "ans : " << ans << endl; s[i + 2] = 'A'; i++; } else { if (s[i] == 'A') acount++; else acount = 0; } } cout << ans << endl; } }
[]
833,633
833,634
u242679311
cpp
p03018
#include <bits/stdc++.h> #define int long long #define mod (int)(1e9 + 7) #define inf (int)(3e18 + 7) #define rep(i, n) for (int i = 0; i < n; i++) #define REP(i, n) for (int i = 1; i < n; i++) #define P pair<int, int> #define PiP pair<int, pair<int, int>> #define all(v) v.begin(), v.end() #define mkp make_pair #define mkt make_tuple #define prique(T) priority_queue<T, vector<T>, greater<T>> #define vecunique(vec) \ sort(vec.begin(), vec.end()); \ decltype(vec)::iterator result = std::unique(vec.begin(), vec.end()); \ vec.erase(result, vec.end()) using namespace std; bool prime(int x) { for (int i = 2; i * i <= x; i++) { if (x % i == 0) return false; } return x > 1; } int gcd(int x, int y) { if (y == 0) return x; return gcd(y, x % y); } int lcm(int x, int y) { return x / gcd(x, y) * y; } int kai(int x) { if (x == 0) return 1; return kai(x - 1) * x % mod; } int mod_pow(int x, int y, int mod_) { int res = 1; while (y > 0) { if (y & 1) { res = res * x % mod_; } x = x * x % mod_; y >>= 1; } return res; } int comb(int x, int y) { if (y > x) return 0; return kai(x) * mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod; } /*--------Library Zone!--------*/ signed main() { string s; cin >> s; int a = 0, bc = 0, ans = 0; rep(i, s.size()) { if (s[i] == 'A') { bc = 0; a++; } else if (i < s.size() - 1 && s[i] == 'B' && s[i + 1] == 'C') { bc++; if (i >= s.size() - 3 || (i < s.size() - 3 && s[i + 2] != 'B' || s[i + 3] != 'C')) { ans += bc * a; bc = 0, a = 1; } i++; } else { a = 0, bc = 0; } } cout << ans << endl; }
#include <bits/stdc++.h> #define int long long #define mod (int)(1e9 + 7) #define inf (int)(3e18 + 7) #define rep(i, n) for (int i = 0; i < n; i++) #define REP(i, n) for (int i = 1; i < n; i++) #define P pair<int, int> #define PiP pair<int, pair<int, int>> #define all(v) v.begin(), v.end() #define mkp make_pair #define mkt make_tuple #define prique(T) priority_queue<T, vector<T>, greater<T>> #define vecunique(vec) \ sort(vec.begin(), vec.end()); \ decltype(vec)::iterator result = std::unique(vec.begin(), vec.end()); \ vec.erase(result, vec.end()) using namespace std; bool prime(int x) { for (int i = 2; i * i <= x; i++) { if (x % i == 0) return false; } return x > 1; } int gcd(int x, int y) { if (y == 0) return x; return gcd(y, x % y); } int lcm(int x, int y) { return x / gcd(x, y) * y; } int kai(int x) { if (x == 0) return 1; return kai(x - 1) * x % mod; } int mod_pow(int x, int y, int mod_) { int res = 1; while (y > 0) { if (y & 1) { res = res * x % mod_; } x = x * x % mod_; y >>= 1; } return res; } int comb(int x, int y) { if (y > x) return 0; return kai(x) * mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod; } /*--------Library Zone!--------*/ signed main() { string s; cin >> s; int a = 0, bc = 0, ans = 0; rep(i, s.size()) { if (s[i] == 'A') { bc = 0; a++; } else if (i < s.size() - 1 && s[i] == 'B' && s[i + 1] == 'C') { bc++; if (i >= s.size() - 3 || (i < s.size() - 3 && s[i + 2] != 'B' || s[i + 3] != 'C')) { ans += bc * a; bc = 0; } i++; } else { a = 0, bc = 0; } } cout << ans << endl; }
[]
833,639
833,640
u147049801
cpp
p03018
// From Naruto to Hokage //#include <RJ> #include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define eb emplace_back #define endl '\n' #define mii map<ll, ll> #define pii pair<ll, ll> #define vi vector<ll> #define all(a) (a).begin(), (a).end() #define F first #define S second #define sz(x) (ll) x.size() #define hell 1000000007 #define INF (1ll << 60) #define rep(i, a, b) for (ll i = a; i <= b; i++) #define rrep(i, a, b) for (ll i = a; i >= b; i--) #define present(c, x) ((c).find(x) != (c).end()) #define cpresent(c, x) (find(all(c), x) != (c).end()) #define ios \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); #define time \ cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n"; ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); } ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); } const int N = 100005; void solve() { string s; cin >> s; ll ans = 0; ll curr = 0; rep(i, 0, sz(s) - 3) { if (s[i] == 'B' && s[i + 1] == 'C') { ans += curr; i += 1; } else { if (s[i] == 'A') curr++; else curr = 0; } } // ans+=(curr*(curr+1))/2; cout << ans; } signed main() { ios int TESTS = 1; // cin>>TESTS; while (TESTS--) { solve(); } time return 0; }
// From Naruto to Hokage //#include <RJ> #include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define eb emplace_back #define endl '\n' #define mii map<ll, ll> #define pii pair<ll, ll> #define vi vector<ll> #define all(a) (a).begin(), (a).end() #define F first #define S second #define sz(x) (ll) x.size() #define hell 1000000007 #define INF (1ll << 60) #define rep(i, a, b) for (ll i = a; i <= b; i++) #define rrep(i, a, b) for (ll i = a; i >= b; i--) #define present(c, x) ((c).find(x) != (c).end()) #define cpresent(c, x) (find(all(c), x) != (c).end()) #define ios \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); #define time \ cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n"; ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); } ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); } const int N = 100005; void solve() { string s; cin >> s; ll ans = 0; ll curr = 0; rep(i, 0, sz(s) - 2) { if (s[i] == 'B' && s[i + 1] == 'C') { ans += curr; i += 1; } else { if (s[i] == 'A') curr++; else curr = 0; } } // ans+=(curr*(curr+1))/2; cout << ans; } signed main() { ios int TESTS = 1; // cin>>TESTS; while (TESTS--) { solve(); } time return 0; }
[ "literal.number.change", "call.arguments.change", "expression.operation.binary.change" ]
833,647
833,648
u592186586
cpp
p03018
#include <bits/stdc++.h> using namespace std; const int N = 200005; long long ans; int n; char s[N]; int main() { scanf("%s", s + 1); int n = strlen(s + 1), cnt = 0; for (int i = 1; i <= n; i++) { if (s[i] == 'A') cnt++; if (s[i] == 'C') cnt = 0; if (s[i] == 'B') { if (s[i + 1] == 'C') ans += cnt, i++; else cnt = 0; } } printf("%lld\b", ans); }
#include <bits/stdc++.h> using namespace std; const int N = 200005; long long ans; int n; char s[N]; int main() { scanf("%s", s + 1); int n = strlen(s + 1), cnt = 0; for (int i = 1; i <= n; i++) { if (s[i] == 'A') cnt++; if (s[i] == 'C') cnt = 0; if (s[i] == 'B') { if (s[i + 1] == 'C') ans += cnt, i++; else cnt = 0; } } printf("%lld\n", ans); }
[ "literal.string.change", "call.arguments.change", "io.output.change", "io.output.newline.add" ]
833,658
833,659
u768967683
cpp
p03018
#include <bits/stdc++.h> using namespace std; const int N = 200005; const int mod = 1000000007; typedef long long ll; char s[N]; int main() { scanf("%s", s + 1); int len = strlen(s + 1); ll tmp = 0, ans = 0; for (int i = len; i > 0; i--) { if (s[i - 1] == 'B' && s[i] == 'C') { tmp++; i--; } else if (s[i] == 'A') ans += tmp; } printf("%lld\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 200005; const int mod = 1000000007; typedef long long ll; char s[N]; int main() { scanf("%s", s + 1); int len = strlen(s + 1); ll tmp = 0, ans = 0; for (int i = len; i > 0; i--) { if (s[i - 1] == 'B' && s[i] == 'C') { tmp++; i--; } else if (s[i] == 'A') ans += tmp; else tmp = 0; } printf("%lld\n", ans); return 0; }
[ "control_flow.branch.else_if.replace.remove", "control_flow.branch.if.replace.add", "assignment.add" ]
833,664
833,665
u222613738
cpp
p03018
#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int, int> pii; #define pb push_back #define mp make_pair const int N = 2e5 + 10; int n; char s[N]; int main() { while (~scanf("%s", s)) { n = strlen(s); if (n <= 2) { puts("0"); continue; } LL ans = 0; int pre = 0; if (s[0] == 'A' && s[1] == 'B') { pre = 1; } else if (s[0] == 'A' && s[1] == 'A') { pre = 2; } else if (s[1] == 'A') { pre = 1; } for (int i = 2; i < n; i++) { if (s[i - 2] == 'A' && s[i - 1] == 'B' && s[i] == 'C') { ans += pre; s[i - 2] = 'B'; s[i - 1] = 'C'; s[i] = 'A'; } else { if (s[i] == 'A') { if (s[i - 1] == 'A') { pre++; } else { pre = 0; } } else if (s[i] == 'B') { if (s[i - 1] != 'A') pre = 0; } else { pre = 0; } } } printf("%lld\n", ans); } return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int, int> pii; #define pb push_back #define mp make_pair const int N = 2e5 + 10; int n; char s[N]; int main() { while (~scanf("%s", s)) { n = strlen(s); if (n <= 2) { puts("0"); continue; } LL ans = 0; int pre = 0; if (s[0] == 'A' && s[1] == 'B') { pre = 1; } else if (s[0] == 'A' && s[1] == 'A') { pre = 2; } else if (s[1] == 'A') { pre = 1; } for (int i = 2; i < n; i++) { if (s[i - 2] == 'A' && s[i - 1] == 'B' && s[i] == 'C') { ans += pre; s[i - 2] = 'B'; s[i - 1] = 'C'; s[i] = 'A'; } else { if (s[i] == 'A') { if (s[i - 1] == 'A') { pre++; } else { pre = 1; } } else if (s[i] == 'B') { if (s[i - 1] != 'A') pre = 0; } else { pre = 0; } } } printf("%lld\n", ans); } return 0; }
[ "literal.number.change", "assignment.value.change" ]
833,702
833,703
u454658584
cpp
p03018
#include <algorithm> #include <bitset> #include <cmath> #include <functional> #include <iomanip> #include <ios> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define rep1(i, n) for (int i = 1; i <= (int)(n); i++) #define sz(c) ((int)(c).size()) #define mp make_pair using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll; // typedef pair<int, int> P; // typedef pair<int, pair<int, int> > PP; // const int MAX=; int main() { string S; cin >> S; string T; rep(i, sz(S)) { if (S[i] == 'A') T.push_back('A'); else if (S[i] == 'B' && S[i + 1] == 'C') { T.push_back('D'); } else T.push_back('X'); } ll ans = 0; ll tmp = 0; rep(i, sz(T)) { if (T[i] == 'A') tmp++; else if (T[i] == 'D') ans += tmp; else tmp = 0; } cout << ans << endl; }
#include <algorithm> #include <bitset> #include <cmath> #include <functional> #include <iomanip> #include <ios> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define rep1(i, n) for (int i = 1; i <= (int)(n); i++) #define sz(c) ((int)(c).size()) #define mp make_pair using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll; // typedef pair<int, int> P; // typedef pair<int, pair<int, int> > PP; // const int MAX=; int main() { string S; cin >> S; string T; rep(i, sz(S)) { if (S[i] == 'A') T.push_back('A'); else if (S[i] == 'B' && S[i + 1] == 'C') { T.push_back('D'); i++; } else T.push_back('X'); } ll ans = 0; ll tmp = 0; rep(i, sz(T)) { if (T[i] == 'A') tmp++; else if (T[i] == 'D') ans += tmp; else tmp = 0; } cout << ans << endl; }
[ "expression.unary.arithmetic.add" ]
833,704
833,705
u228214259
cpp
p03018
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> using namespace std; typedef long long ll; const int maxn = 2e5 + 7; string s; int main() { cin >> s; int len = s.length(); int cnt = 0; ll ans = 0; for (int i = 0; i < len; i++) { if (s[i] == 'A') ++cnt; else if (s[i] == 'B') { if (s[i + 1] == 'C') { ans += cnt; i += 1; } } else cnt = 0; } printf("%lld\n", ans); return 0; }
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> using namespace std; typedef long long ll; const int maxn = 2e5 + 7; string s; int main() { cin >> s; int len = s.length(); int cnt = 0; ll ans = 0; for (int i = 0; i < len; i++) { if (s[i] == 'A') ++cnt; else if (s[i] == 'B') { if (s[i + 1] == 'C') { ans += cnt; i += 1; } else cnt = 0; } else cnt = 0; } printf("%lld\n", ans); return 0; }
[ "control_flow.branch.else_if.replace.remove", "control_flow.branch.if.replace.add", "assignment.add" ]
833,708
833,709
u291016794
cpp
p03018
#include <iostream> #include <string> using namespace std; int main(void) { string str; cin >> str; long long count = 0; long long sum = 0; long long length = str.length(); for (long long i = 0; i < length - 1; i++) { if (str[i] == 'A') { count++; } else if (str[i] == 'B') { if (count == 0) { // } else { if (str[i + 1] == 'C') { sum += count; count = 1; i++; } else if (str[i] == 'A') { count = 1; i++; } else { count = 0; } } } else { count = 0; } } cout << sum; return 0; }
#include <iostream> #include <string> using namespace std; int main(void) { string str; cin >> str; long long count = 0; long long sum = 0; long long length = str.length(); for (long long i = 0; i < length - 1; i++) { if (str[i] == 'A') { count++; } else if (str[i] == 'B') { if (count == 0) { // } else { if (str[i + 1] == 'C') { sum += count; i++; } else if (str[i] == 'A') { count = 1; i++; } else { count = 0; } } } else { count = 0; } } cout << sum; return 0; }
[]
833,725
833,726
u276796245
cpp
p03018
#include <bits/stdc++.h> using namespace std; #define ll long long ll h[200010], n, tt; char s[200010]; bool bo[200010]; inline int rd() { int x = 0; char ch = getchar(); for (; ch < '0' || ch > '9'; ch = getchar()) ; for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0'; return x; } int main() { scanf("%s", s + 1); n = strlen(s + 1); tt = 0; for (int i = 1; i <= n; i++) if (s[i] == 'A') { tt++; int id = 0; for (int j = i + 1; j <= n - 1; j += 2) if (s[j] == 'B' && s[j + 1] == 'C') h[tt]++; else { id = j; break; } if (id && s[id] == 'A') bo[tt] = true; } for (int i = tt - 1; i; i--) if (bo[i]) h[i] += h[i + 1]; ll ans = 0; for (int i = 1; i <= tt; i++) ans += h[i]; printf("%lld\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long ll h[200010], n, tt; char s[200010]; bool bo[200010]; inline int rd() { int x = 0; char ch = getchar(); for (; ch < '0' || ch > '9'; ch = getchar()) ; for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0'; return x; } int main() { scanf("%s", s + 1); n = strlen(s + 1); tt = 0; for (int i = 1; i <= n; i++) if (s[i] == 'A') { tt++; int id = 0; for (int j = i + 1; j <= n - 1; j += 2) if (s[j] == 'B' && s[j + 1] == 'C') h[tt]++; else { id = j; break; } if (id && s[id] == 'A') bo[tt] = true; } for (int i = tt - 1; i > 0; i--) if (bo[i]) h[i] += h[i + 1]; ll ans = 0; for (int i = 1; i <= tt; i++) ans += h[i]; printf("%lld\n", ans); return 0; }
[ "control_flow.loop.for.condition.change" ]
833,731
833,732
u138339515
cpp
p03018
#include <bits/stdc++.h> using namespace std; char s[200005]; int main() { int num1 = 0; int num2 = 0; scanf("%s", s + 1); int n = strlen(s + 1); long long ans = 0; for (int i = 1; i < n; i++) { if (num1 != 0 && s[i] == 'B' && s[i + 1] == 'C' && i < n) { i++; ans += num1; num1 = 1; } else if (s[i] == 'A') { num1++; } else { num1 = 0; } } printf("%lld\n", ans); }
#include <bits/stdc++.h> using namespace std; char s[200005]; int main() { int num1 = 0; int num2 = 0; scanf("%s", s + 1); int n = strlen(s + 1); long long ans = 0; for (int i = 1; i < n; i++) { if (num1 != 0 && s[i] == 'B' && s[i + 1] == 'C' && i < n) { i++; ans += num1; } else if (s[i] == 'A') { num1++; } else { num1 = 0; } } printf("%lld\n", ans); }
[]
833,750
833,751
u818518063
cpp
p03018
#include <iostream> using namespace std; int main() { int a, ans = 0; string s; cin >> s; for (int i = 0; i < s.size(); i++) { if (s[i] == 'A') s[i] = '1'; if (i < s.size() - 1 && s[i] == 'B' && s[i + 1] == 'C') s.replace(s.begin() + i, s.begin() + i + 2, "2"); } for (int i = 0; i < s.size(); i++) { if (s[i] == '1') a++; else if (s[i] == '2') ans += a; else a = 0; } cout << ans << endl; return 0; }
#include <iostream> using namespace std; int main() { long a = 0, ans = 0; string s; cin >> s; for (int i = 0; i < s.size(); i++) { if (s[i] == 'A') s[i] = '1'; if (i < s.size() - 1 && s[i] == 'B' && s[i + 1] == 'C') s.replace(s.begin() + i, s.begin() + i + 2, "2"); } for (int i = 0; i < s.size(); i++) { if (s[i] == '1') a++; else if (s[i] == '2') ans += a; else a = 0; } cout << ans << endl; return 0; }
[ "variable_declaration.type.primitive.change", "variable_declaration.value.change" ]
833,754
833,753
u612175324
cpp
p03018
#include <algorithm> #include <bits/stdc++.h> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <fstream> #include <iostream> #include <iterator> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string.h> #include <vector> using namespace std; #define all(x) (x).begin(), (x).end() //#define mp make_pair #define pb push_back #define ff first #define ss second #define ll long long typedef vector<ll> vi; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll n, m, i, j, k, ta, tb, l1 = -1, l2, x, c = 0, u = 0, ans = 0; string s; cin >> s; n = s.length(); vi v; if (n < 3) { cout << 0; return 0; } for (i = 0; i < n - 1; i++) { if (s[i] == 'A') v.pb(1); else if (s[i] == 'B' && s[i + 1] == 'C') { v.pb(0); i++; } else v.pb(2); } for (i = 0; i < v.size(); i++) { // cout<<v[i]<<" "; if (v[i] != 2 && l1 == -1) l1 = i; if (v[i] == 1 && c == 0) c = 1; if (v[i] == 0 && c == 1) { ans += (i - l1); l1++; } if (v[i] == 2) { l1 = -1; c = 0; } } cout << ans; return 0; }
#include <algorithm> #include <bits/stdc++.h> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <fstream> #include <iostream> #include <iterator> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string.h> #include <vector> using namespace std; #define all(x) (x).begin(), (x).end() //#define mp make_pair #define pb push_back #define ff first #define ss second #define ll long long typedef vector<ll> vi; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll n, m, i, j, k, ta, tb, l1 = -1, l2, x, c = 0, u = 0, ans = 0; string s; cin >> s; n = s.length(); vi v; if (n < 3) { cout << 0; return 0; } for (i = 0; i < n - 1; i++) { if (s[i] == 'A') v.pb(1); else if (s[i] == 'B' && s[i + 1] == 'C') { v.pb(0); i++; } else v.pb(2); } for (i = 0; i < v.size(); i++) { // cout<<v[i]<<" "; if (v[i] == 1 && l1 == -1) l1 = i; if (v[i] == 1 && c == 0) c = 1; if (v[i] == 0 && c == 1) { ans += (i - l1); l1++; } if (v[i] == 2) { l1 = -1; c = 0; } } cout << ans; return 0; }
[ "control_flow.loop.for.condition.change" ]
833,765
833,766
u415518175
cpp