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
p03167
#include <bits/stdc++.h> using namespace std; char board[1005][1005]; int dp[1005][1005]; int H, W; const int mod = (int)1e9 + 7; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> H >> W; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { cin >> board[i][j]; } } dp[0][0] = 1; // There only 1 way to go at 0,0(because it is starting point :))) ) for (int i = 0; i <= W; i++) { for (int j = 0; j <= H; j++) { if (i + j > 0 && board[i][j] != '#') { dp[i][j] = (i > 0 ? dp[i - 1][j] : 0) + (j > 0 ? dp[i][j - 1] : 0); if (dp[i][j] >= mod) dp[i][j] -= mod; } } } cout << dp[H - 1][W - 1] << "\n"; return 0; } /* dp[i][j]: the maximum number of path from [0,0] to [i,j] The answer will be dp[H-1][W-1] i + j > 0 will be alternative to i != 0 || j != 0 */
#include <bits/stdc++.h> using namespace std; char board[1005][1005]; int dp[1005][1005]; int H, W; const int mod = (int)1e9 + 7; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> H >> W; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { cin >> board[i][j]; } } dp[0][0] = 1; // There only 1 way to go at 0,0(because it is starting point :))) ) for (int i = 0; i <= H; i++) { for (int j = 0; j <= W; j++) { if (i + j > 0 && board[i][j] != '#') { dp[i][j] = (i > 0 ? dp[i - 1][j] : 0) + (j > 0 ? dp[i][j - 1] : 0); if (dp[i][j] >= mod) dp[i][j] -= mod; } } } cout << dp[H - 1][W - 1] << "\n"; return 0; } /* dp[i][j]: the maximum number of path from [0,0] to [i,j] The answer will be dp[H-1][W-1] i + j > 0 will be alternative to i != 0 || j != 0 */
[ "identifier.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
975,762
975,763
u963948625
cpp
p03167
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; #define ff first #define ss second #define int long long #define pb push_back #define mp make_pair #define pii pair<int, int> #define vi vector<int> #define mii map<int, int> #define pqb priority_queue<int> #define pqs priority_queue<int, vi, greater<int>> #define setbits(x) __builtin_popcountll(x) #define zrobits(x) __builtin_ctzll(x) #define mod 1000000007 #define inf 1e18 #define ps(x, y) fixed << setprecision(y) << x #define mk(arr, n, type) type *arr = new type[n]; #define w(x) \ int x; \ cin >> x; \ while (x--) mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; void c_p_c() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int n, m; char arr[1002][1002]; int dp[1002][1002]; int32_t main() { c_p_c(); cin >> n >> m; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> arr[i][j]; } } memset(dp, 0, sizeof(dp)); for (int i = 0; i < n; i++) { if (arr[i][0] == '#') break; else { dp[i][0] = 1; } } for (int i = 0; i < m; i++) { if (arr[0][i] == '#') break; else { dp[0][i] = 1; } } for (int i = 1; i < n; i++) { for (int j = 1; j < m; j++) { if (arr[i][j] == '#') dp[i][j] = 0; else { dp[i][j] = dp[i - 1][j] + dp[i][j - 1]; } } } cout << dp[n - 1][m - 1]; return 0; }
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; #define ff first #define ss second #define int long long #define pb push_back #define mp make_pair #define pii pair<int, int> #define vi vector<int> #define mii map<int, int> #define pqb priority_queue<int> #define pqs priority_queue<int, vi, greater<int>> #define setbits(x) __builtin_popcountll(x) #define zrobits(x) __builtin_ctzll(x) #define mod 1000000007 #define inf 1e18 #define ps(x, y) fixed << setprecision(y) << x #define mk(arr, n, type) type *arr = new type[n]; #define w(x) \ int x; \ cin >> x; \ while (x--) mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; void c_p_c() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int n, m; char arr[1002][1002]; int dp[1002][1002]; int32_t main() { c_p_c(); cin >> n >> m; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> arr[i][j]; } } memset(dp, 0, sizeof(dp)); for (int i = 0; i < n; i++) { if (arr[i][0] == '#') break; else { dp[i][0] = 1; } } for (int i = 0; i < m; i++) { if (arr[0][i] == '#') break; else { dp[0][i] = 1; } } for (int i = 1; i < n; i++) { for (int j = 1; j < m; j++) { if (arr[i][j] == '#') dp[i][j] = 0; else { dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % 1000000007; } } } cout << dp[n - 1][m - 1]; return 0; }
[ "assignment.change" ]
975,776
975,777
u682269149
cpp
p03167
#include <iostream> #include <vector> using namespace std; #define mod 1000000007 long rec(char **grid, int h, int w, int i, int j, long **mem) { if (i == h - 1 && h == w - 1) return 1; if (i >= h or j >= w) return 0; if (mem[i][j] != -1) return mem[i][j]; if (grid[i][j] == '#') { mem[i][j] = 0; return mem[i][j]; } long a = rec(grid, h, w, i + 1, j, mem); long b = rec(grid, h, w, i, j + 1, mem); mem[i][j] = (a % mod + b % mod) % mod; return mem[i][j]; } int main() { int h, w; cin >> h >> w; char **grid = new char *[h]; for (int i = 0; i < h; i++) { grid[i] = new char[w]; for (int j = 0; j < w; j++) cin >> grid[i][j]; } long **mem = new long *[h]; for (int i = 0; i < h; i++) { mem[i] = new long[w]; for (int j = 0; j < w; j++) mem[i][j] = -1; } cout << rec(grid, h, w, 0, 0, mem); /*long dp[h+1][w+1]; for(int i=0;i<=h;i++) dp[i][0]=0; for(int j=0;j<=w;j++) dp[0][j]=0; for(int i=1;i<=h;i++) { for(int j=1;j<=w;j++) { if(i==1&&j==1) { dp[i][j]=1; continue; } if(grid[i-1][j-1]=='#') dp[i][j]=0; else { dp[i][j]=(dp[i-1][j])%mod+(dp[i][j-1])%mod; dp[i][j]=(dp[i][j])%mod; } } } cout<<dp[h][w];*/ }
#include <iostream> #include <vector> using namespace std; #define mod 1000000007 long rec(char **grid, int h, int w, int i, int j, long **mem) { if (i == h - 1 && j == w - 1) return 1; if (i >= h or j >= w) return 0; if (mem[i][j] != -1) return mem[i][j]; if (grid[i][j] == '#') { mem[i][j] = 0; return mem[i][j]; } long a = rec(grid, h, w, i + 1, j, mem); long b = rec(grid, h, w, i, j + 1, mem); mem[i][j] = (a % mod + b % mod) % mod; return mem[i][j]; } int main() { int h, w; cin >> h >> w; char **grid = new char *[h]; for (int i = 0; i < h; i++) { grid[i] = new char[w]; for (int j = 0; j < w; j++) cin >> grid[i][j]; } long **mem = new long *[h]; for (int i = 0; i < h; i++) { mem[i] = new long[w]; for (int j = 0; j < w; j++) mem[i][j] = -1; } cout << rec(grid, h, w, 0, 0, mem); /*long dp[h+1][w+1]; for(int i=0;i<=h;i++) dp[i][0]=0; for(int j=0;j<=w;j++) dp[0][j]=0; for(int i=1;i<=h;i++) { for(int j=1;j<=w;j++) { if(i==1&&j==1) { dp[i][j]=1; continue; } if(grid[i-1][j-1]=='#') dp[i][j]=0; else { dp[i][j]=(dp[i-1][j])%mod+(dp[i][j-1])%mod; dp[i][j]=(dp[i][j])%mod; } } } cout<<dp[h][w];*/ }
[ "identifier.change", "control_flow.branch.if.condition.change" ]
975,844
975,845
u933124026
cpp
p03167
#include <iostream> using namespace std; const int mod = 1000000007; int H, W; int ok[1009][1009]; int dp[1009][1009]; int main() { cin >> H >> W; for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) { char c; cin >> c; ok[i][j] = (c == '.'); // 壁なら 0, そうでないなら 1 } dp[0][0] = 1; for (int i = 0; i < H; i++) { for (int j = !i; j < W; j++) { if (i) dp[i][j] += dp[i - 1][j]; if (j) dp[i][j] += dp[i][j - 1]; dp[i][j] *= ok[i][j]; if (dp[i][j] >= mod) dp[i][j] -= mod; } } cout << dp[H][W] << endl; return 0; }
#include <iostream> using namespace std; const int mod = 1000000007; int H, W; int ok[1009][1009]; int dp[1009][1009]; int main() { cin >> H >> W; for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) { char c; cin >> c; ok[i][j] = (c == '.'); // 壁なら 0, そうでないなら 1 } dp[0][0] = 1; for (int i = 0; i < H; i++) { for (int j = !i; j < W; j++) { if (i) dp[i][j] += dp[i - 1][j]; if (j) dp[i][j] += dp[i][j - 1]; dp[i][j] *= ok[i][j]; if (dp[i][j] >= mod) dp[i][j] -= mod; } } cout << dp[H - 1][W - 1] << endl; return 0; }
[ "expression.operation.binary.add" ]
975,856
975,857
u047554023
cpp
p03167
#include <bits/stdc++.h> using namespace std; #define max1 1005 #define siz 100000 #define mod 1000000009 #define inf 1e18 + 5 #define ll long long int #define debug(x) cout << #x << " " << x << endl #define jam(x) cout << "Case #" << x << ": " typedef pair<ll, ll> pr; vector<vector<ll>> dp(max1, vector<ll>(max1, -1)); vector<vector<char>> a(max1, vector<char>(max1)); ll h, w; ll dfs(ll x, ll y) { if (x == h && y == w) { return 1; } if (x > h || y > w) { return 0; } if (a[x][y] == '#') { return 0; } if (dp[x][y] != -1) { return dp[x][y]; } ll cnt = 0; cnt = dfs(x + 1, y) % mod; cnt = (cnt + dfs(x, y + 1)) % mod; return dp[x][y] = cnt % mod; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); /*#ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif*/ cin >> h >> w; for (ll i = 1; i <= h; i++) { for (ll j = 1; j <= w; j++) { cin >> a[i][j]; } } cout << dfs(1, 1) << endl; }
#include <bits/stdc++.h> using namespace std; #define max1 1005 #define siz 100000 #define mod 1000000007 #define inf 1e18 + 5 #define ll long long int #define debug(x) cout << #x << " " << x << endl #define jam(x) cout << "Case #" << x << ": " typedef pair<ll, ll> pr; vector<vector<ll>> dp(max1, vector<ll>(max1, -1)); vector<vector<char>> a(max1, vector<char>(max1)); ll h, w; ll dfs(ll x, ll y) { if (x == h && y == w) { return 1; } if (x > h || y > w) { return 0; } if (a[x][y] == '#') { return 0; } if (dp[x][y] != -1) { return dp[x][y]; } ll cnt = 0; cnt = dfs(x + 1, y) % mod; cnt = (cnt + dfs(x, y + 1)) % mod; return dp[x][y] = cnt % mod; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); /*#ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif*/ cin >> h >> w; for (ll i = 1; i <= h; i++) { for (ll j = 1; j <= w; j++) { cin >> a[i][j]; } } cout << dfs(1, 1) << endl; }
[ "preprocessor.define.value.change", "literal.integer.change" ]
975,858
975,859
u781876525
cpp
p03167
#include <algorithm> #include <climits> #include <cstring> #include <fstream> #include <iostream> #include <math.h> #include <vector> using namespace std; #define ll long long #define mod 1000000007 int h, w; char a[1001][1001]; ll dp[1001][1001]; ll solve() { dp[h - 1][w - 1] = 1; for (int i = h - 1; i >= 0; i--) { for (int j = w - 1; j >= 0; j--) { if (a[i][j] != '#' and !(i == h - 1 and j == w - 1)) { dp[i][j] = dp[i + 1][j] + dp[i][j + 1]; } } } return dp[0][0]; } int main() { cin >> h >> w; for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) { cin >> a[i][j]; } } memset(dp, 0, sizeof(dp)); cout << solve(); return 0; }
#include <algorithm> #include <climits> #include <cstring> #include <fstream> #include <iostream> #include <math.h> #include <vector> using namespace std; #define ll long long #define mod 1000000007 int h, w; char a[1001][1001]; ll dp[1001][1001]; ll solve() { dp[h - 1][w - 1] = 1; for (int i = h - 1; i >= 0; i--) { for (int j = w - 1; j >= 0; j--) { if (a[i][j] != '#' and !(i == h - 1 and j == w - 1)) { dp[i][j] = (dp[i + 1][j] + dp[i][j + 1]) % mod; } } } return dp[0][0]; } int main() { cin >> h >> w; for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) { cin >> a[i][j]; } } memset(dp, 0, sizeof(dp)); cout << solve(); return 0; }
[ "assignment.change" ]
975,864
975,865
u634851584
cpp
p03167
#include <bits/stdc++.h> #define x first #define y second #define fastio ios_base::sync_with_stdio(0), cin.tie(0) #define pb push_back #define rep(i, a, b) for (int i = a; i < b; i++) #define mem(i) memset((i), (-1), (sizeof(i))) #define all(i) (i).begin(), (i).end() using namespace std; typedef pair<int, int> pii; typedef long long ll; typedef pair<ll, ll> pll; const int MN = 1e3 + 5; const int MOD = 1e9 + 7; int n, m; char a[MN][MN]; int dp[MN][MN]; int f(int x, int y) { if (!(0 <= x && x < n && 0 <= y && y < m)) return 0; if (a[x][y] == '#') return 0; if (x == n - 1 && y == n - 1) return 1; int &ret = dp[x][y]; if (~ret) return ret; ret = f(x + 1, y) + f(x, y + 1); ret %= MOD; return ret; } int main() { cin >> n >> m; rep(i, 0, n) rep(j, 0, m) cin >> a[i][j]; mem(dp); cout << f(0, 0); }
#include <bits/stdc++.h> #define x first #define y second #define fastio ios_base::sync_with_stdio(0), cin.tie(0) #define pb push_back #define rep(i, a, b) for (int i = a; i < b; i++) #define mem(i) memset((i), (-1), (sizeof(i))) #define all(i) (i).begin(), (i).end() using namespace std; typedef pair<int, int> pii; typedef long long ll; typedef pair<ll, ll> pll; const int MN = 1e3 + 5; const int MOD = 1e9 + 7; int n, m; char a[MN][MN]; int dp[MN][MN]; int f(int x, int y) { if (!(0 <= x && x < n && 0 <= y && y < m)) return 0; if (a[x][y] == '#') return 0; if (x == n - 1 && y == m - 1) return 1; int &ret = dp[x][y]; if (~ret) return ret; ret = f(x + 1, y) + f(x, y + 1); ret %= MOD; return ret; } int main() { cin >> n >> m; rep(i, 0, n) rep(j, 0, m) cin >> a[i][j]; mem(dp); cout << f(0, 0); }
[ "identifier.change", "control_flow.branch.if.condition.change" ]
975,870
975,871
u938143205
cpp
p03167
#include <bits/stdc++.h> using namespace std; #define FAST_IO \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cerr.tie(NULL); #define dbg(x) cerr << #x << " = " << x << ", "; #define vw(v) \ cerr << endl << endl << (#v) << " is: " << endl; \ for (int B : (v)) { \ cerr << B << " "; \ } \ cerr << endl #define check(x) cerr << "here " << (x) << "?" << endl #define rep(i, a, b) for (long long i = (a); i < (b); i++) #define per(i, a) for (long long i = (a - 1); i >= 0; i--) #define all(x) (x).begin(), (x).end() #define rv(x) (x).rbegin(), (x).rend() #define pb push_back typedef long long ll; ll const INF = 2147483647, R_INF = 9223372036854775807, MOD = 1e9 + 7; const int N = 1e3 + 2; bool grid[N][N]; int DP[N][N]; int main() { FAST_IO int n, m; cin >> n >> m; rep(i, 1, n + 1) { rep(j, 1, m + 1) { char c; cin >> c; grid[i][j] = c == '*'; } } if (grid[1][1]) return cout << 0, 0; DP[1][1] = 1; rep(i, 1, n + 1) rep(j, 1, m + 1) if (!grid[i][j]) DP[i][j] += (DP[i - 1][j] + DP[i][j - 1]) % MOD; cout << DP[n][m]; }
#include <bits/stdc++.h> using namespace std; #define FAST_IO \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cerr.tie(NULL); #define dbg(x) cerr << #x << " = " << x << ", "; #define vw(v) \ cerr << endl << endl << (#v) << " is: " << endl; \ for (int B : (v)) { \ cerr << B << " "; \ } \ cerr << endl #define check(x) cerr << "here " << (x) << "?" << endl #define rep(i, a, b) for (long long i = (a); i < (b); i++) #define per(i, a) for (long long i = (a - 1); i >= 0; i--) #define all(x) (x).begin(), (x).end() #define rv(x) (x).rbegin(), (x).rend() #define pb push_back typedef long long ll; ll const INF = 2147483647, R_INF = 9223372036854775807, MOD = 1e9 + 7; const int N = 1e3 + 2; bool grid[N][N]; int DP[N][N]; int main() { FAST_IO int n, m; cin >> n >> m; rep(i, 1, n + 1) { rep(j, 1, m + 1) { char c; cin >> c; grid[i][j] = c == '#'; } } if (grid[1][1]) return cout << 0, 0; DP[1][1] = 1; rep(i, 1, n + 1) rep(j, 1, m + 1) if (!grid[i][j]) DP[i][j] += (DP[i - 1][j] + DP[i][j - 1]) % MOD; cout << DP[n][m]; }
[ "literal.string.change", "assignment.value.change", "expression.operation.binary.change" ]
975,879
975,880
u771565679
cpp
p03167
/* _____ ____ _____ ___ ___ ___ ___ |_ _/ __ \_ _| |__ \ / _ \ |__ \ / _ \ | || | | || | ) | | | | ) | | | | | || | | || | / /| | | | / /| | | | _| || |__| || |_ / /_| |_| | / /_| |_| | |_____\____/_____| |____|\___/ |____|\___/ */ #include <bits/stdc++.h> #include <fstream> #define rep(i, a, b) for (int i = (a); i < (b); i++) #define per(i, a, b) for (int i = (a); i > (b); i--) #define a(x) (x.begin(), x.end()) #define ar(x) (x.rbegin(), x.rend()) #define pb push_back #define Pb() pop_back() #define ll long long int #define ull unsigned long long int #define pii pair<int, int> #define pll pair<ll, ll> #define sc scanf #define scin(x) sc("%d", &(x)) #define scln(x) sc("%lld", &(x)) #define pf prllf #define ms(a, b) memset(a, b, sizeof(a)) #define mp make_pair #define db double #define EPS 10E-10 #define ff first #define ss second #define sqr(x) (x) * (x) #define vi vector<int> #define vl vector<ll> #define vii vector<vector<int>> #define vll vector<vector<ll>> #define DBG pf("HI\n") #define MOD 1000000007 #define CIN \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) #define RUN_CASE(t, T) for (__typeof(t) t = 1; t <= T; t++) #define CASE(t) prllf("Case %d: ", t) #define CASEL(t) prllf("Case %d:\n", t) #define intlimit 2147483647 #define longlimit 9223372036854775807 #define infinity (1 << 28) #define gcd(a, b) __gcd(a, b) #define lcm(a, b) ((a) * (b) / gcd(a, b)) #define PI 2 * acos(0.0) // pair<int,int>ert(x==y); gives run time when false using namespace std; int dp[1000][1000]; int main() { CIN; int n, m; cin >> n >> m; char g[n][m]; rep(i, 0, n) { rep(j, 0, m) { cin >> g[i][j]; } } rep(i, 0, n) { if (g[i][0] == '*') break; dp[i][0] = 1; } rep(i, 0, m) { if (g[0][i] == '*') break; dp[0][i] = 1; } rep(i, 1, n) { rep(j, 1, m) { if (g[i][j] == '*') continue; dp[i][j] += dp[i][j - 1]; dp[i][j] %= MOD; dp[i][j] += +dp[i - 1][j]; dp[i][j] %= MOD; } } if (dp[0][0] == 0) { cout << 0; return 0; } cout << dp[n - 1][m - 1]; }
/* _____ ____ _____ ___ ___ ___ ___ |_ _/ __ \_ _| |__ \ / _ \ |__ \ / _ \ | || | | || | ) | | | | ) | | | | | || | | || | / /| | | | / /| | | | _| || |__| || |_ / /_| |_| | / /_| |_| | |_____\____/_____| |____|\___/ |____|\___/ */ #include <bits/stdc++.h> #include <fstream> #define rep(i, a, b) for (int i = (a); i < (b); i++) #define per(i, a, b) for (int i = (a); i > (b); i--) #define a(x) (x.begin(), x.end()) #define ar(x) (x.rbegin(), x.rend()) #define pb push_back #define Pb() pop_back() #define ll long long int #define ull unsigned long long int #define pii pair<int, int> #define pll pair<ll, ll> #define sc scanf #define scin(x) sc("%d", &(x)) #define scln(x) sc("%lld", &(x)) #define pf prllf #define ms(a, b) memset(a, b, sizeof(a)) #define mp make_pair #define db double #define EPS 10E-10 #define ff first #define ss second #define sqr(x) (x) * (x) #define vi vector<int> #define vl vector<ll> #define vii vector<vector<int>> #define vll vector<vector<ll>> #define DBG pf("HI\n") #define MOD 1000000007 #define CIN \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) #define RUN_CASE(t, T) for (__typeof(t) t = 1; t <= T; t++) #define CASE(t) prllf("Case %d: ", t) #define CASEL(t) prllf("Case %d:\n", t) #define intlimit 2147483647 #define longlimit 9223372036854775807 #define infinity (1 << 28) #define gcd(a, b) __gcd(a, b) #define lcm(a, b) ((a) * (b) / gcd(a, b)) #define PI 2 * acos(0.0) // pair<int,int>ert(x==y); gives run time when false using namespace std; int dp[1000][1000]; int main() { CIN; int n, m; cin >> n >> m; char g[n][m]; rep(i, 0, n) { rep(j, 0, m) { cin >> g[i][j]; } } rep(i, 0, n) { if (g[i][0] == '#') break; dp[i][0] = 1; } rep(i, 0, m) { if (g[0][i] == '#') break; dp[0][i] = 1; } rep(i, 1, n) { rep(j, 1, m) { if (g[i][j] == '#') continue; dp[i][j] += dp[i][j - 1]; dp[i][j] %= MOD; dp[i][j] += +dp[i - 1][j]; dp[i][j] %= MOD; } } if (dp[0][0] == 0) { cout << 0; return 0; } cout << dp[n - 1][m - 1]; }
[ "literal.string.change", "control_flow.branch.if.condition.change" ]
975,881
975,882
u054759548
cpp
p03167
#include <bits/stdc++.h> #include <fstream> using namespace std; #define intMax 1000000000000; #define rep(i, a, b) for (long long i = a; i < b; i++) #define repp(i, a, b) for (long long i = a; i >= b; i--) #define be(a) (a.begin(), a.end()) #define rbe(p) (p.rbegin(), p.rend()) #define pb push_back int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, m; cin >> n >> m; vector<vector<char>> A(n + 1, vector<char>(m + 1, '*')); rep(i, 0, n) { rep(j, 0, m) { cin >> A[i][j]; } } if (A[0][0] == '*') { cout << 0; return 0; } vector<vector<long long>> dp(n + 1, vector<long long>(m + 1)); dp[0][0] = 1; rep(i, 0, n) { rep(j, 0, m) { if (i - 1 >= 0 && j - 1 >= 0 && A[i][j] != '*') { dp[i][j] = dp[i - 1][j] + dp[i][j - 1]; } else if (i - 1 >= 0 && A[i][j] != '*') { dp[i][j] = dp[i - 1][j]; } else if (j - 1 >= 0 && A[i][j] != '*') { dp[i][j] = dp[i][j - 1]; } dp[i][j] %= 1000000007; } } // ddd({0, 0}); // rep(i, 0, n) // { // rep(j, 0, n) // { // cout << dp[i][j] << " "; // } // cout << endl; // } cout << dp[n - 1][m - 1]; }
#include <bits/stdc++.h> #include <fstream> using namespace std; #define intMax 1000000000000; #define rep(i, a, b) for (long long i = a; i < b; i++) #define repp(i, a, b) for (long long i = a; i >= b; i--) #define be(a) (a.begin(), a.end()) #define rbe(p) (p.rbegin(), p.rend()) #define pb push_back int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, m; cin >> n >> m; vector<vector<char>> A(n + 1, vector<char>(m + 1, '*')); rep(i, 0, n) { rep(j, 0, m) { cin >> A[i][j]; } } if (A[0][0] == '*') { cout << 0; return 0; } vector<vector<long long>> dp(n + 1, vector<long long>(m + 1)); dp[0][0] = 1; rep(i, 0, n) { rep(j, 0, m) { if (i - 1 >= 0 && j - 1 >= 0 && A[i][j] != '#') { dp[i][j] = dp[i - 1][j] + dp[i][j - 1]; } else if (i - 1 >= 0 && A[i][j] != '#') { dp[i][j] = dp[i - 1][j]; } else if (j - 1 >= 0 && A[i][j] != '#') { dp[i][j] = dp[i][j - 1]; } dp[i][j] %= 1000000007; } } cout << dp[n - 1][m - 1]; }
[ "literal.string.change", "control_flow.branch.if.condition.change" ]
975,887
975,888
u793264122
cpp
p03167
#include <bits/stdc++.h> using namespace std; #define ll long long #define PII pair<ll, ll> #define VI vector<ll> #define VB vector<bool> #define VVI vector<vector<ll>> #define VS vector<string> #define VP vector<PII> #define lf(i, a, b) for (ll i = a; i <= b; i++) #define lr(i, a, b) for (ll i = a; i >= b; i--) #define lfl(i, v) for (ll i = 0; i < v.size(); i++) #define lrl(i, v) for (ll i = (ll)(v.size()) - 1; i >= 0; i--) #define chk2(a, b) cout << "check : " << a << " " << b << endl #define chk3(a, b, c) cout << "check : " << a << " " << b << " " << c << endl #define chk4(a, b, c, d) \ cout << "check : " << a << " " << b << " " << c << " " << d << endl #define chk5(a, b, c, d, e) \ cout << "check : " << a << " " << b << " " << c << " " << d << " " << e \ << endl #define lb(v, k) lower_bound(v.begin(), v.end(), k) - v.begin() #define ub(v, k) upper_bound(v.begin(), v.end(), k) - v.begin() #define mod 1000000007 #define pb push_back #define pf push_front #define m_p make_pair #define fi first #define se second #define sz size() #define sort(v) sort(v.begin(), v.end()) ll n, m; VVI gp; int main() { cin >> n >> m; vector<vector<char>> mat(n + 1, vector<char>(m + 1)); lf(i, 1, n) lf(j, 1, m) cin >> mat[i][j]; ll dp[n + 1][m + 1] = {-1}; memset(dp, 0, sizeof(dp)); lf(i, 1, n) { lf(j, 1, m) { if (i == 1 && j == 1) { dp[i][j] = 1; } else if (mat[i][j] != '#') { ll sum = 0; sum += dp[i - 1][j]; sum += dp[i][j - 1]; dp[i][j] = sum; } } } cout << dp[n][m] << endl; }
#include <bits/stdc++.h> using namespace std; #define ll long long #define PII pair<ll, ll> #define VI vector<ll> #define VB vector<bool> #define VVI vector<vector<ll>> #define VS vector<string> #define VP vector<PII> #define lf(i, a, b) for (ll i = a; i <= b; i++) #define lr(i, a, b) for (ll i = a; i >= b; i--) #define lfl(i, v) for (ll i = 0; i < v.size(); i++) #define lrl(i, v) for (ll i = (ll)(v.size()) - 1; i >= 0; i--) #define chk2(a, b) cout << "check : " << a << " " << b << endl #define chk3(a, b, c) cout << "check : " << a << " " << b << " " << c << endl #define chk4(a, b, c, d) \ cout << "check : " << a << " " << b << " " << c << " " << d << endl #define chk5(a, b, c, d, e) \ cout << "check : " << a << " " << b << " " << c << " " << d << " " << e \ << endl #define lb(v, k) lower_bound(v.begin(), v.end(), k) - v.begin() #define ub(v, k) upper_bound(v.begin(), v.end(), k) - v.begin() #define mod 1000000007 #define pb push_back #define pf push_front #define m_p make_pair #define fi first #define se second #define sz size() #define sort(v) sort(v.begin(), v.end()) ll n, m; VVI gp; int main() { cin >> n >> m; vector<vector<char>> mat(n + 1, vector<char>(m + 1)); lf(i, 1, n) lf(j, 1, m) cin >> mat[i][j]; ll dp[n + 1][m + 1] = {-1}; memset(dp, 0, sizeof(dp)); lf(i, 1, n) { lf(j, 1, m) { if (i == 1 && j == 1) { dp[i][j] = 1; } else if (mat[i][j] != '#') { ll sum = 0; sum += dp[i - 1][j]; sum += dp[i][j - 1]; dp[i][j] = (sum) % mod; } } } cout << dp[n][m] << endl; }
[ "assignment.change" ]
975,899
975,900
u752324944
cpp
p03167
// GRID-H_dp #include <bits/stdc++.h> #define modulu 1000000007 using namespace std; char grid[1001][1001]; int dp[1001][1001]; int NoOFPaths(char grid[1001][1001], int r, int c) { if (dp[r][c] != 0) return (dp[r][c] % modulu); for (int i = 1; i <= c; i++) { // for 1st row if (grid[1][i] != '#') { dp[1][i] = 1; } else break; } for (int i = 1; i <= r; i++) { // for 1st column if (grid[1][i] != '#') { dp[i][1] = 1; } else break; } for (int i = 2; i <= r; i++) { for (int j = 2; j <= c; j++) { if (grid[i][j] != '#') { dp[i][j] = ((dp[i - 1][j] % modulu) + (dp[i][j - 1] % modulu)) % modulu; } else dp[i][j] = 0; } } return (dp[r][c] % modulu); } int main() { int r, c; cin >> r >> c; memset(dp, 0, sizeof dp); for (int i = 1; i <= r; i++) { for (int j = 1; j <= c; j++) { cin >> grid[i][j]; } cout << endl; } cout << NoOFPaths(grid, r, c); return 0; }
// GRID-H_dp #include <bits/stdc++.h> #define modulu 1000000007 using namespace std; char grid[1001][1001]; int dp[1001][1001]; int NoOFPaths(char grid[1001][1001], int r, int c) { if (dp[r][c] != 0) return (dp[r][c] % modulu); for (int i = 1; i <= c; i++) { // for 1st row if (grid[1][i] != '#') { dp[1][i] = 1; } else break; } for (int i = 1; i <= r; i++) { // for 1st column if (grid[i][1] != '#') { dp[i][1] = 1; } else break; } for (int i = 2; i <= r; i++) { for (int j = 2; j <= c; j++) { if (grid[i][j] != '#') { dp[i][j] = ((dp[i - 1][j] % modulu) + (dp[i][j - 1] % modulu)) % modulu; } else dp[i][j] = 0; } } return (dp[r][c] % modulu); } int main() { int r, c; cin >> r >> c; memset(dp, 0, sizeof dp); for (int i = 1; i <= r; i++) { for (int j = 1; j <= c; j++) { cin >> grid[i][j]; } cout << endl; } cout << NoOFPaths(grid, r, c); return 0; }
[ "identifier.replace.add", "literal.replace.remove", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change", "identifier.replace.remove", "literal.replace.add" ]
975,920
975,921
u751364359
cpp
p03167
// GRID-H_dp #include <bits/stdc++.h> #define modulu 1000000007 using namespace std; char grid[1001][1001]; int dp[1001][1001]; int NoOFPaths(char grid[1001][1001], int r, int c) { if (dp[r][c] != 0) return (dp[r][c] % modulu); for (int i = 1; i <= c; i++) { // for 1st row if (grid[1][i] != '#') { dp[1][i] = 1; } else break; } for (int i = 1; i <= c; i++) { // for 1st column if (grid[1][i] != '#') { dp[i][1] = 1; } else break; } for (int i = 2; i <= r; i++) { for (int j = 2; j <= c; j++) { if (grid[i][j] != '#') { dp[i][j] = ((dp[i - 1][j] % modulu) + (dp[i][j - 1] % modulu)) % modulu; } else dp[i][j] = 0; } } return (dp[r][c] % modulu); } int main() { int r, c; cin >> r >> c; memset(dp, 0, sizeof dp); for (int i = 1; i <= r; i++) { for (int j = 1; j <= c; j++) { cin >> grid[i][j]; } cout << endl; } cout << NoOFPaths(grid, r, c); return 0; }
// GRID-H_dp #include <bits/stdc++.h> #define modulu 1000000007 using namespace std; char grid[1001][1001]; int dp[1001][1001]; int NoOFPaths(char grid[1001][1001], int r, int c) { if (dp[r][c] != 0) return (dp[r][c] % modulu); for (int i = 1; i <= c; i++) { // for 1st row if (grid[1][i] != '#') { dp[1][i] = 1; } else break; } for (int i = 1; i <= r; i++) { // for 1st column if (grid[i][1] != '#') { dp[i][1] = 1; } else break; } for (int i = 2; i <= r; i++) { for (int j = 2; j <= c; j++) { if (grid[i][j] != '#') { dp[i][j] = ((dp[i - 1][j] % modulu) + (dp[i][j - 1] % modulu)) % modulu; } else dp[i][j] = 0; } } return (dp[r][c] % modulu); } int main() { int r, c; cin >> r >> c; memset(dp, 0, sizeof dp); for (int i = 1; i <= r; i++) { for (int j = 1; j <= c; j++) { cin >> grid[i][j]; } cout << endl; } cout << NoOFPaths(grid, r, c); return 0; }
[ "identifier.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change", "identifier.replace.add", "literal.replace.remove", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change", "identifier.replace.remove", "literal.replace.add" ]
975,922
975,921
u751364359
cpp
p03167
// GRID-H_dp #include <bits/stdc++.h> #define modulu 1000000007 using namespace std; char grid[1001][1001]; int dp[1001][1001]; int NoOFPaths(char grid[1001][1001], int r, int c) { if (dp[r][c] != 0) return (dp[r][c] % modulu); for (int i = 1; i <= c; i++) { // for 1st row if (grid[1][i] != '#') { dp[1][i] = 1; } else break; } for (int i = 1; i <= c; i++) { // for 1st column if (grid[1][i] != '#') { dp[i][1] = 1; } else break; } for (int i = 2; i <= r; i++) { for (int j = 2; j <= c; j++) { if (grid[i][j] != '#') { dp[i][j] = (dp[i - 1][j] % modulu) + (dp[i][j - 1] % modulu) % modulu; } else dp[i][j] = 0; } } return (dp[r][c] % modulu); } int main() { int r, c; cin >> r >> c; memset(dp, 0, sizeof dp); for (int i = 1; i <= r; i++) { for (int j = 1; j <= c; j++) { cin >> grid[i][j]; } cout << endl; } cout << NoOFPaths(grid, r, c); return 0; }
// GRID-H_dp #include <bits/stdc++.h> #define modulu 1000000007 using namespace std; char grid[1001][1001]; int dp[1001][1001]; int NoOFPaths(char grid[1001][1001], int r, int c) { if (dp[r][c] != 0) return (dp[r][c] % modulu); for (int i = 1; i <= c; i++) { // for 1st row if (grid[1][i] != '#') { dp[1][i] = 1; } else break; } for (int i = 1; i <= r; i++) { // for 1st column if (grid[i][1] != '#') { dp[i][1] = 1; } else break; } for (int i = 2; i <= r; i++) { for (int j = 2; j <= c; j++) { if (grid[i][j] != '#') { dp[i][j] = ((dp[i - 1][j] % modulu) + (dp[i][j - 1] % modulu)) % modulu; } else dp[i][j] = 0; } } return (dp[r][c] % modulu); } int main() { int r, c; cin >> r >> c; memset(dp, 0, sizeof dp); for (int i = 1; i <= r; i++) { for (int j = 1; j <= c; j++) { cin >> grid[i][j]; } cout << endl; } cout << NoOFPaths(grid, r, c); return 0; }
[ "identifier.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change", "identifier.replace.add", "literal.replace.remove", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change", "identifier.replace.remove", "literal.replace.add" ]
975,923
975,921
u751364359
cpp
p03167
#include <bits/stdc++.h> #define ll long long const int mxn = 1e3, mod = 1e9 + 7; using namespace std; int dp[mxn + 1][mxn + 1], grid[mxn + 1][mxn + 1]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); memset(dp, 0, sizeof(dp) / sizeof(int)); int n, m; cin >> n >> m; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { char x; cin >> x; if (x == '#') grid[i][j] = 0; else grid[i][j] = 1; } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { if (!grid[i][j]) continue; if (i == 1 && j == 1) dp[i][j] = 1; dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod; } } cout << dp[n][m] << endl; return 0; }
#include <bits/stdc++.h> #define ll long long const int mxn = 1e3, mod = 1e9 + 7; using namespace std; int dp[mxn + 1][mxn + 1], grid[mxn + 1][mxn + 1]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); memset(dp, 0, sizeof(dp) / sizeof(int)); int n, m; cin >> n >> m; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { char x; cin >> x; if (x == '#') grid[i][j] = 0; else grid[i][j] = 1; } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { if (!grid[i][j]) continue; if (i == 1 && j == 1) dp[i][j] = 1; else dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod; } } cout << dp[n][m] << endl; return 0; }
[ "control_flow.branch.else_if.replace.remove", "control_flow.branch.if.replace.add" ]
975,928
975,929
u124430580
cpp
p03167
#include <bits/stdc++.h> using namespace std; #define ll long long #define MOD 1000000007 #define MAXN 1123 int H, W; int grid[MAXN][MAXN]; int vis[MAXN][MAXN]; ll memo[MAXN][MAXN]; ll solve(int h, int w) { if (h == H - 1 && w == W - 1) return 1; if (vis[h][w] == 1) return memo[h][w]; vis[h][w] = 1; if (grid[h][w] == 0) return 0; return memo[h][w] = (solve(h + 1, w) + solve(h, w + 1)) % MOD; } int main() { cin >> H >> W; char ch; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { cin >> ch; grid[i][j] = (ch == '.'); } cin >> ch; } ll res = solve(0, 0); cout << res << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long #define MOD 1000000007 #define MAXN 1123 int H, W; int grid[MAXN][MAXN]; int vis[MAXN][MAXN]; ll memo[MAXN][MAXN]; ll solve(int h, int w) { if (h == H - 1 && w == W - 1) return 1; if (vis[h][w] == 1) return memo[h][w]; vis[h][w] = 1; if (grid[h][w] == 0) return 0; return memo[h][w] = (solve(h + 1, w) + solve(h, w + 1)) % MOD; } int main() { cin >> H >> W; char ch; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { cin >> ch; grid[i][j] = (ch == '.'); } } ll res = solve(0, 0); cout << res << endl; return 0; }
[]
975,960
975,961
u413315284
cpp
p03167
#include <algorithm> #include <iostream> #include <string.h> using namespace std; #define f(i, a, b) for (int i = (int)(a); i <= (int)(b); i++) char a[1001][1001], dp[1001][1001]; int h, w; int main() { cin >> h >> w; f(i, 1, h) { f(j, 1, w) { cin >> a[i][j]; } } memset(dp, 0, sizeof(dp)); f(i, 1, h) { f(j, 1, w) { if (a[i][j] == '#') continue; if (i == 1 && j == 1) dp[i][j] = 1; else dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % 1000000007; } } cout << dp[h][w] << endl; return 0; }
#include <algorithm> #include <iostream> #include <string.h> using namespace std; #define f(i, a, b) for (int i = (int)(a); i <= (int)(b); i++) char a[1001][1001]; long long int dp[1001][1001]; int h, w; int main() { cin >> h >> w; f(i, 1, h) { f(j, 1, w) { cin >> a[i][j]; } } memset(dp, 0, sizeof(dp)); f(i, 1, h) { f(j, 1, w) { if (a[i][j] == '#') continue; if (i == 1 && j == 1) dp[i][j] = 1; else dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % 1000000007; } } cout << dp[h][w] << endl; return 0; }
[ "variable_declaration.type.widen.change" ]
975,974
975,975
u185496177
cpp
p03167
#include <algorithm> #include <iostream> #include <string.h> using namespace std; #define f(i, a, b) for (int i = (int)(a); i <= (int)(b); i++) char a[1001][1001], dp[1001][1001]; int h, w; int main() { cin >> h >> w; f(i, 1, h) { f(j, 1, w) { cin >> a[i][j]; } } memset(dp, 0, sizeof(dp)); f(i, 1, h) { f(j, 1, w) { if (a[i][j] == '#') continue; if (i == 1 && j == 1) dp[i][j] = 1; else dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % 1000000009; } } cout << dp[h][w] << endl; return 0; }
#include <algorithm> #include <iostream> #include <string.h> using namespace std; #define f(i, a, b) for (int i = (int)(a); i <= (int)(b); i++) char a[1001][1001]; long long int dp[1001][1001]; int h, w; int main() { cin >> h >> w; f(i, 1, h) { f(j, 1, w) { cin >> a[i][j]; } } memset(dp, 0, sizeof(dp)); f(i, 1, h) { f(j, 1, w) { if (a[i][j] == '#') continue; if (i == 1 && j == 1) dp[i][j] = 1; else dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % 1000000007; } } cout << dp[h][w] << endl; return 0; }
[ "literal.number.change", "assignment.value.change", "expression.operation.binary.change" ]
975,976
975,975
u185496177
cpp
p03167
#include <bits/stdc++.h> using namespace std; int mod = 1e9 + 7; int cal(int i, int j, vector<vector<int>> &dp, vector<vector<char>> &grid) { if (i >= grid.size() || j >= grid[0].size()) return 0; if (i == grid.size() - 1 || j == grid[0].size()) return 1; if (dp[i][j] == -1) { if (grid[i][j] == '#') dp[i][j] = 0; else dp[i][j] = (cal(i + 1, j, dp, grid) % mod + cal(i, j + 1, dp, grid) % mod) % mod; return dp[i][j]; } else return dp[i][j]; } int main() { int h, w; cin >> h >> w; vector<vector<char>> grid(h, vector<char>(w)); for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { cin >> grid[i][j]; } } vector<vector<int>> dp(h, vector<int>(w, -1)); int ans = cal(0, 0, dp, grid); cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int mod = 1e9 + 7; int cal(int i, int j, vector<vector<int>> &dp, vector<vector<char>> &grid) { if (i >= grid.size() || j >= grid[0].size()) return 0; if (i == grid.size() - 1 && j == grid[0].size() - 1) return 1; if (dp[i][j] == -1) { if (grid[i][j] == '#') dp[i][j] = 0; else dp[i][j] = (cal(i + 1, j, dp, grid) % mod + cal(i, j + 1, dp, grid) % mod) % mod; return dp[i][j]; } else return dp[i][j]; } int main() { int h, w; cin >> h >> w; vector<vector<char>> grid(h, vector<char>(w)); for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { cin >> grid[i][j]; } } vector<vector<int>> dp(h, vector<int>(w, -1)); int ans = cal(0, 0, dp, grid); cout << ans; return 0; }
[ "misc.opposites", "control_flow.branch.if.condition.change" ]
976,027
976,028
u073062346
cpp
p03167
#include <algorithm> #include <cmath> #include <fstream> #include <iostream> #include <vector> #define f cin #define NMAX 100010 #define MOD 1000000007 using namespace std; // ifstream f("date.in"); long long int n, m; char a[1010][1010]; long long int dp[1010][1010]; int main() { f >> n >> m; for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { f >> a[i][j]; } } dp[0][0] = 1; for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { if (i == 0 && j == 0) continue; if (a[i][j] == '#') { a[i][j] = 0; } else { if (i == 0) { dp[i][j] = dp[i][j - 1] % MOD; } else if (j == 0) { dp[i][j] = dp[i - 1][j] % MOD; } else { dp[i][j] = dp[i - 1][j] + dp[i][j - 1] % MOD; } } } } cout << dp[n - 1][m - 1]; return 0; }
#include <algorithm> #include <cmath> #include <fstream> #include <iostream> #include <vector> #define f cin #define NMAX 100010 #define MOD 1000000007 using namespace std; // ifstream f("date.in"); long long int n, m; char a[1010][1010]; long long int dp[1010][1010]; int main() { f >> n >> m; for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { f >> a[i][j]; } } dp[0][0] = 1; for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { if (i == 0 && j == 0) continue; if (a[i][j] == '#') { a[i][j] = 0; } else { if (i == 0) { dp[i][j] = dp[i][j - 1] % MOD; } else if (j == 0) { dp[i][j] = dp[i - 1][j] % MOD; } else { dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD; } } } } cout << dp[n - 1][m - 1]; return 0; }
[]
976,039
976,040
u648916139
cpp
p03167
#include <algorithm> #include <cmath> #include <fstream> #include <iostream> #include <vector> #define f cin #define NMAX 100010 #define MOD 1000000007 using namespace std; // ifstream f("date.in"); int n, m; char a[1010][1010]; int dp[1010][1010]; int main() { f >> n >> m; for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { f >> a[i][j]; } } dp[0][0] = 1; for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { if (i == 0 && j == 0) continue; if (a[i][j] == '#') { a[i][j] = 0; } else { if (i == 0) { dp[i][j] = dp[i][j - 1] % MOD; } else if (j == 0) { dp[i][j] = dp[i - 1][j] % MOD; } else { dp[i][j] = dp[i - 1][j] + dp[i][j - 1] % MOD; } } } } cout << dp[n - 1][m - 1]; return 0; }
#include <algorithm> #include <cmath> #include <fstream> #include <iostream> #include <vector> #define f cin #define NMAX 100010 #define MOD 1000000007 using namespace std; // ifstream f("date.in"); long long int n, m; char a[1010][1010]; long long int dp[1010][1010]; int main() { f >> n >> m; for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { f >> a[i][j]; } } dp[0][0] = 1; for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { if (i == 0 && j == 0) continue; if (a[i][j] == '#') { a[i][j] = 0; } else { if (i == 0) { dp[i][j] = dp[i][j - 1] % MOD; } else if (j == 0) { dp[i][j] = dp[i - 1][j] % MOD; } else { dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD; } } } } cout << dp[n - 1][m - 1]; return 0; }
[ "variable_declaration.type.widen.change" ]
976,041
976,040
u648916139
cpp
p03167
#include <algorithm> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define MOD 1000000007 using namespace std; long long dp[1010][1010]; signed main() { cin.tie(0); ios::sync_with_stdio(false); int h, w; char a[1010][1010]; cin >> h >> w; for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { cin >> a[i][j]; } } dp[1][1] = 1; for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { if (i != 1 || j != 1) { dp[i][j] = dp[i - 1][j] + dp[i][j - 1] % MOD; } if (a[i][j] == '#') { dp[i][j] = 0; } } } cout << dp[h][w] << "\n"; return 0; }
#include <algorithm> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define MOD 1000000007 using namespace std; long long dp[1010][1010]; signed main() { cin.tie(0); ios::sync_with_stdio(false); int h, w; char a[1010][1010]; cin >> h >> w; for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { cin >> a[i][j]; } } dp[1][1] = 1; for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { if (i != 1 || j != 1) { dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD; } if (a[i][j] == '#') { dp[i][j] = 0; } } } cout << dp[h][w] << "\n"; return 0; }
[]
976,042
976,043
u809287016
cpp
p03167
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e3 + 5; const int INF = 1e9 + 7; #define ll long long #define pb push_back #define endl '\n' #define fast_io \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define F first #define S second ll poww(ll a, ll b, ll md) { return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md)); } ll MOD(ll a) { return ((a % INF) + INF) % INF; } ll inv(ll a) { return poww(a, INF - 2, INF); } char a[MAXN][MAXN]; ll dp[MAXN][MAXN]; int main() { fast_io; // cout << fixed << setprecision(15); int n, m; cin >> n >> m; for (int i = 1; i <= n; ++i) { for (int j = 1; j <= m; ++j) { cin >> a[i][j]; } } dp[1][1] = 1; for (int i = 1; i <= n; ++i) { for (int j = 1; j <= m; ++j) { if ((i || j) && a[i][j] != '#') dp[i][j] = MOD(dp[i - 1][j] + dp[i][j - 1]); } } cout << dp[n][m]; }
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e3 + 5; const int INF = 1e9 + 7; #define ll long long #define pb push_back #define endl '\n' #define fast_io \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define F first #define S second ll poww(ll a, ll b, ll md) { return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md)); } ll MOD(ll a) { return ((a % INF) + INF) % INF; } ll inv(ll a) { return poww(a, INF - 2, INF); } char a[MAXN][MAXN]; ll dp[MAXN][MAXN]; int main() { fast_io; // cout << fixed << setprecision(15); int n, m; cin >> n >> m; for (int i = 1; i <= n; ++i) { for (int j = 1; j <= m; ++j) { cin >> a[i][j]; } } dp[1][1] = 1; for (int i = 1; i <= n; ++i) { for (int j = 1; j <= m; ++j) { if ((i != 1 || j != 1) && a[i][j] != '#') dp[i][j] = MOD(dp[i - 1][j] + dp[i][j - 1]); } } cout << dp[n][m]; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change" ]
976,091
976,092
u839285395
cpp
p03167
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> using namespace std; int n, m; const int Mod = 1e9 + 7; long long f[1010][1010]; int main() { scanf("%d%d", &n, &m); f[1][1] = 1; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { char c; cin >> c; if (c == '#' || (i == 1 && j == 1)) continue; f[i][j] = f[i - 1][j] + f[i][j - 1]; f[i][j] %= Mod; } } printf("%lld", f[n][m] & Mod); return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> using namespace std; int n, m; const int Mod = 1e9 + 7; long long f[1010][1010]; int main() { scanf("%d%d", &n, &m); f[1][1] = 1; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { char c; cin >> c; if (c == '#' || (i == 1 && j == 1)) continue; f[i][j] = f[i - 1][j] + f[i][j - 1]; f[i][j] %= Mod; } } printf("%lld", f[n][m] % Mod); return 0; }
[ "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
976,093
976,094
u623001370
cpp
p03167
#include <bits/stdc++.h> using namespace std; typedef long long lli; typedef unsigned long long int uli; typedef long double Lf; #define fastIO \ std::ios::sync_with_stdio(false); \ cin.tie(NULL) #define mod 1000000009 #define BIGL = 999999999999999999 #define BIGI = 99999999 #define N 1002 #define NN 25 #define SZ(x) ((lli)(x).size()) #define vi vector<int> #define ii <int, int> #define ll <long, long> #define lll <long long, long long> #define loop(i, s, n) for (int(i) = (s); (i) < (n); (i)++) #define loopr(i, n, s) for (int(i) = (n)-1; (i) >= (s); (i)--) #define pb push_back #define o2(a, b) cout << (a) << " " << (b) << endl #define o3(a, b, c) cout << (a) << " " << (b) << " " << (c) << endl #define o4(a, b, c, d) \ cout << (a) << " " << (b) << " " << (c) << " " << (d) << endl #define cl cout << endl #define r0 return 0 #define x first #define y second inline lli modadd(lli n, lli m) { return ((n + m) % mod + mod) % mod; } inline lli modsub(lli n, lli m) { return ((n - m + mod) % mod + mod) % mod; } inline lli modpro(lli n, lli m) { return ((n * m) % mod + mod) % mod; } inline uli powe(lli x, lli y) { uli res = 1; while (y > 0) { if (y & 1) res = res * x; y = y >> 1; x = x * x; } return res; } inline lli powmod(lli x, lli y) { lli res = 1; while (y > 0) { if (y & 1) res = modpro(res, x); y = y >> 1; x = modpro(x, x); } return res; } inline lli modadd3(lli x, lli y, lli z) { return modadd(modadd(x, y), z); } inline lli modadd4(lli x, lli y, lli z, lli w) { return modadd(modadd(x, y), modadd(z, w)); } template <typename T> inline T max3(T x, T y, T z) { return max(max(x, y), z); } template <typename T> inline T max4(T x, T y, T z, T w) { return max(max3(x, y, w), z); } template <typename T> inline T min3(T x, T y, T z) { return min(min(x, y), z); } template <typename T> inline T min4(T x, T y, T z, T w) { return min(min3(x, y, w), z); } template <typename T> void printArr(T *arr, int n) { for (int i = 0; i < n; i++) { cout << arr[i] << " "; } cout << endl; } // // // template <class T, class U> // bool comparep(const pair<T, U>&i, const pair<T, U>&j) //{ // return i.first > j.first; //} // // template <class T, class U> // bool compair2(const pair<T, U>&i, const pair<T, U>&j) //{ // return ((i.second < j.second)||((i.second == j.second)&&i.first < // j.first)); //} // // // template <typename T> // T gcd(T a, T b) //{ // if (a == 0) // return b; // if(b==0) // return a; // T t; // while((a>0)&&(b>0)){ // t = a; // a=b%a; // b=t; // } // // return max(a,b); //} // // template <typename T> // T maxof(T n_args, ...) //{ // va_list ap; // va_start(ap, n_args); // T big = va_arg(ap, T); // for(int i = 2; i <= n_args; i++) { // T a = va_arg(ap, T); // if(a > big) big = a; // } // va_end(ap); // return big; //} // // // // // template <typename T> // T gcdarr(T a[], int n){ // T gc = gcd<T>(a[0],a[1]); // loop(i,2,n) { // gc = gcd<T>(gc,a[i]); // } // return gc; //} // // // template <typename T> // T maxarr(T a[], int n){ // T big = a[0]; // loop(i,1,n) { // big = max(big, a[i]); // } // return big; //} // // // // template <typename T> // T minarr(T a[], int n){ // T small = a[0]; // loop(i,1,n) { // small = min(small, a[i]); // } // return small; //} // // uli choose(uli n, uli k){ // uli res = 1; // // // Since C(n, k) = C(n, n-k) // if ( k > n - k ) // k = n - k; // // // Calculate value of // // [n * (n-1) *---* (n-k+1)] / [k * (k-1) *----* 1] // for (uli i = 0; i < k; ++i) // { // res *= (n - i); // res /= (i + 1); // } // // return res; //} // vector<pair<int, pair<int, int>>> adj[N]; bool visited[N]; // queue<int> q; // int color[N]; class Graph { public: int V; Graph(int V) { this->V = V; } void addEdge(int a, int b, int w, int i) { adj[a].pb({w, {i, b}}); // adj[b].pb(a); } // void dfs(int x){ // visited[x]=1; // for(auto u:adj[x]){ // if(!visited[u]){ // dfs(u); // } // } //} // void dfsTree(int x, int p){ // for(int u:v[x]){ // if(u!=p) dfs(u,x); // } // //} // void bfs(int x){ // visited[x]=1; // q.push(x); // while(!q.empty()) // { // int s = q.front(); // q.pop(); // // for(int u : v[s]){ // if(visited[u]==1) continue; // visited[u]=1; // //cout<<u<<endl; // q.push(u);}}} // int connectedcomponents(int n){ // int ans=0; // loop(i,1,n+1){ // if(!visited[i]){ // ans++; // dfs(i); // } // // } // return ans; //} }; // // // vector<int> parent, rank_; // // void makeSet(int x){ // parent[x]=x; // rank_[x]=0; //} // // int findSet(int x){ // if(x!=parent[x]) // parent[x]=findSet(parent[x]); // // return parent[x]; //} // // void unionSets(int x, int y){ // int px = findSet(x); // int py = findSet(y); // // if(rank_[px]<rank_[py]){ // parent[px]=py; // mm[py]=max(mm[px],mm[py]); // } // else if(rank_[py]<rank_[px]){ // parent[py]=px; // mm[px]=max(mm[px],mm[py]); // } // else{ // parent[py]=px; // mm[px]=max(mm[px],mm[py]); // rank_[px]++; // } // //} // // // template <typename T> // T findpowerfactorial(T n,T p) //{ // T x = 0; // while (n) // { // n /= p; // x += n; // } // return x; //} // // template <typename T> // int getibit(T n, int i){ // //cout<<(n&(1LL<<i))<<endl; // return (n&(1LL<<i))?1:0; //} // // template <typename T> // int findbits(T n, T p){ // int x=0; // while(n>0){ // n/=p; // x++; // } // return x; //} // // // void primeFactors(int n) //{ // while (n % 2 == 0) // { // cout << 2 << " "; // n = n/2; // } // // // for (int i = 3; i <= sqrt(n); i = i + 2) // { // while (n % i == 0) // { // cout << i << " "; // n = n/i; // } // } // if (n > 2) // cout << n << " "; //} // // // // // bool c2(pair<lli, lli> p, pair<lli, lli> q){ // return p.x<q.x||((p.x==q.x)&&(p.y>q.y)); // } // vll v[4]; // // lli gcd(lli a, lli b){ // int ta=max(a,b),tb=min(a,b); // int tr,td; // while(ta>0&&tb>0){ // // tr = ta%tb; // td = ta/tb; // o4(ta,tb,tr,td);cout<<"x"; // v[0].pb(ta);v[1].pb(td);v[2].pb(tb);v[3].pb(tr); // ta=tb; // tb=tr; // // } // return max(ta,tb); //} // // // lli wb,wd; // void fa(int w,int x){ // lli a,b,c,d; // int n=v[0].size(); // lli temp; // cout<<n<<"%"; // if(n==1){ // a=1;b=w; c=w/x-1;d=x; // } // else {b=v[0][n-2];a=1;c=-1*v[1][n-2];d=v[2][n-2]; // loopr(i,v[0].size()-2,0){ // o4(a,b,c,d); // d=b; // temp = c; // c = a-c*v[1][i]; // a=temp; // b=v[0][i]; // }} // cout<<"hi"; // o4(a,b,c,d); // wb=b,wd=d; // //} // lli gcd(lli a, lli b) //{ // if (a == 0) // return b; // if(b==0) // return a; // lli t; // while((a>0)&&(b>0)){ // t = a; // tr = b%a; // // a=b%a; // b=t; // } // // return max(a,b); //} // Returns n^(-1) mod p // int modInverse(int n, lli p) //{ // return powmod(n, p-2, p); //} // // // lli fac[N]; // void facinit(int n){ // fac[0]=1; // for (int i=1 ; i<=n; i++) // fac[i] = fac[i-1]*i%mod; //} // int nCrModPFermat(int n, int r, lli p) //{ // // Base case // if (r==0) // return 1; // // // return (fac[n]* modInverse(fac[r], p) % p * // modInverse(fac[n-r], p) % p) % p; //} /*BITMASK for( int inum = 0 ; inum < ( 1 << n ) ; ++ inum ) { for ( int pos = 0; pos < n ; ++pos ) { if ( ( inum & ( 1 << pos ) ) != 0 ) results[inum] += s [pos] ; //DO SOMETHING } } } */ bool a[N][N]; lli dp[N][N]; int h, w; lli f(int x, int y) { if (dp[x][y] != -1) return dp[x][y]; // if(x==h-1&&y==w-1) {dp[x][y]=1; return 1;} lli sum = 0; if (x + 1 < h) if (a[x + 1][y]) sum = modadd(f(x + 1, y), sum); if (y + 1 < w) if (a[x][y + 1]) sum = modadd(f(x, y + 1), sum); dp[x][y] = sum; return sum; } char x; int main() { // fastIO; int erer = 1; // cin>>erer; loop(erer2, 1, erer + 1) { cin >> h >> w; memset(dp, -1, sizeof(dp)); dp[h - 1][w - 1] = 1; loop(i, 0, h) loop(j, 0, w) { cin >> x; if (x == '.') a[i][j] = 1; } cout << f(0, 0); } return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long lli; typedef unsigned long long int uli; typedef long double Lf; #define fastIO \ std::ios::sync_with_stdio(false); \ cin.tie(NULL) #define mod 1000000007 #define BIGL = 999999999999999999 #define BIGI = 99999999 #define N 1005 #define NN 25 #define SZ(x) ((lli)(x).size()) #define vi vector<int> #define ii <int, int> #define ll <long, long> #define lll <long long, long long> #define loop(i, s, n) for (int(i) = (s); (i) < (n); (i)++) #define loopr(i, n, s) for (int(i) = (n)-1; (i) >= (s); (i)--) #define pb push_back #define o2(a, b) cout << (a) << " " << (b) << endl #define o3(a, b, c) cout << (a) << " " << (b) << " " << (c) << endl #define o4(a, b, c, d) \ cout << (a) << " " << (b) << " " << (c) << " " << (d) << endl #define cl cout << endl #define r0 return 0 #define x first #define y second inline lli modadd(lli n, lli m) { return ((n + m) % mod + mod) % mod; } inline lli modsub(lli n, lli m) { return ((n - m + mod) % mod + mod) % mod; } inline lli modpro(lli n, lli m) { return ((n * m) % mod + mod) % mod; } inline uli powe(lli x, lli y) { uli res = 1; while (y > 0) { if (y & 1) res = res * x; y = y >> 1; x = x * x; } return res; } inline lli powmod(lli x, lli y) { lli res = 1; while (y > 0) { if (y & 1) res = modpro(res, x); y = y >> 1; x = modpro(x, x); } return res; } inline lli modadd3(lli x, lli y, lli z) { return modadd(modadd(x, y), z); } inline lli modadd4(lli x, lli y, lli z, lli w) { return modadd(modadd(x, y), modadd(z, w)); } template <typename T> inline T max3(T x, T y, T z) { return max(max(x, y), z); } template <typename T> inline T max4(T x, T y, T z, T w) { return max(max3(x, y, w), z); } template <typename T> inline T min3(T x, T y, T z) { return min(min(x, y), z); } template <typename T> inline T min4(T x, T y, T z, T w) { return min(min3(x, y, w), z); } template <typename T> void printArr(T *arr, int n) { for (int i = 0; i < n; i++) { cout << arr[i] << " "; } cout << endl; } // // // template <class T, class U> // bool comparep(const pair<T, U>&i, const pair<T, U>&j) //{ // return i.first > j.first; //} // // template <class T, class U> // bool compair2(const pair<T, U>&i, const pair<T, U>&j) //{ // return ((i.second < j.second)||((i.second == j.second)&&i.first < // j.first)); //} // // // template <typename T> // T gcd(T a, T b) //{ // if (a == 0) // return b; // if(b==0) // return a; // T t; // while((a>0)&&(b>0)){ // t = a; // a=b%a; // b=t; // } // // return max(a,b); //} // // template <typename T> // T maxof(T n_args, ...) //{ // va_list ap; // va_start(ap, n_args); // T big = va_arg(ap, T); // for(int i = 2; i <= n_args; i++) { // T a = va_arg(ap, T); // if(a > big) big = a; // } // va_end(ap); // return big; //} // // // // // template <typename T> // T gcdarr(T a[], int n){ // T gc = gcd<T>(a[0],a[1]); // loop(i,2,n) { // gc = gcd<T>(gc,a[i]); // } // return gc; //} // // // template <typename T> // T maxarr(T a[], int n){ // T big = a[0]; // loop(i,1,n) { // big = max(big, a[i]); // } // return big; //} // // // // template <typename T> // T minarr(T a[], int n){ // T small = a[0]; // loop(i,1,n) { // small = min(small, a[i]); // } // return small; //} // // uli choose(uli n, uli k){ // uli res = 1; // // // Since C(n, k) = C(n, n-k) // if ( k > n - k ) // k = n - k; // // // Calculate value of // // [n * (n-1) *---* (n-k+1)] / [k * (k-1) *----* 1] // for (uli i = 0; i < k; ++i) // { // res *= (n - i); // res /= (i + 1); // } // // return res; //} // vector<pair<int, pair<int, int>>> adj[N]; bool visited[N]; // queue<int> q; // int color[N]; class Graph { public: int V; Graph(int V) { this->V = V; } void addEdge(int a, int b, int w, int i) { adj[a].pb({w, {i, b}}); // adj[b].pb(a); } // void dfs(int x){ // visited[x]=1; // for(auto u:adj[x]){ // if(!visited[u]){ // dfs(u); // } // } //} // void dfsTree(int x, int p){ // for(int u:v[x]){ // if(u!=p) dfs(u,x); // } // //} // void bfs(int x){ // visited[x]=1; // q.push(x); // while(!q.empty()) // { // int s = q.front(); // q.pop(); // // for(int u : v[s]){ // if(visited[u]==1) continue; // visited[u]=1; // //cout<<u<<endl; // q.push(u);}}} // int connectedcomponents(int n){ // int ans=0; // loop(i,1,n+1){ // if(!visited[i]){ // ans++; // dfs(i); // } // // } // return ans; //} }; // // // vector<int> parent, rank_; // // void makeSet(int x){ // parent[x]=x; // rank_[x]=0; //} // // int findSet(int x){ // if(x!=parent[x]) // parent[x]=findSet(parent[x]); // // return parent[x]; //} // // void unionSets(int x, int y){ // int px = findSet(x); // int py = findSet(y); // // if(rank_[px]<rank_[py]){ // parent[px]=py; // mm[py]=max(mm[px],mm[py]); // } // else if(rank_[py]<rank_[px]){ // parent[py]=px; // mm[px]=max(mm[px],mm[py]); // } // else{ // parent[py]=px; // mm[px]=max(mm[px],mm[py]); // rank_[px]++; // } // //} // // // template <typename T> // T findpowerfactorial(T n,T p) //{ // T x = 0; // while (n) // { // n /= p; // x += n; // } // return x; //} // // template <typename T> // int getibit(T n, int i){ // //cout<<(n&(1LL<<i))<<endl; // return (n&(1LL<<i))?1:0; //} // // template <typename T> // int findbits(T n, T p){ // int x=0; // while(n>0){ // n/=p; // x++; // } // return x; //} // // // void primeFactors(int n) //{ // while (n % 2 == 0) // { // cout << 2 << " "; // n = n/2; // } // // // for (int i = 3; i <= sqrt(n); i = i + 2) // { // while (n % i == 0) // { // cout << i << " "; // n = n/i; // } // } // if (n > 2) // cout << n << " "; //} // // // // // bool c2(pair<lli, lli> p, pair<lli, lli> q){ // return p.x<q.x||((p.x==q.x)&&(p.y>q.y)); // } // vll v[4]; // // lli gcd(lli a, lli b){ // int ta=max(a,b),tb=min(a,b); // int tr,td; // while(ta>0&&tb>0){ // // tr = ta%tb; // td = ta/tb; // o4(ta,tb,tr,td);cout<<"x"; // v[0].pb(ta);v[1].pb(td);v[2].pb(tb);v[3].pb(tr); // ta=tb; // tb=tr; // // } // return max(ta,tb); //} // // // lli wb,wd; // void fa(int w,int x){ // lli a,b,c,d; // int n=v[0].size(); // lli temp; // cout<<n<<"%"; // if(n==1){ // a=1;b=w; c=w/x-1;d=x; // } // else {b=v[0][n-2];a=1;c=-1*v[1][n-2];d=v[2][n-2]; // loopr(i,v[0].size()-2,0){ // o4(a,b,c,d); // d=b; // temp = c; // c = a-c*v[1][i]; // a=temp; // b=v[0][i]; // }} // cout<<"hi"; // o4(a,b,c,d); // wb=b,wd=d; // //} // lli gcd(lli a, lli b) //{ // if (a == 0) // return b; // if(b==0) // return a; // lli t; // while((a>0)&&(b>0)){ // t = a; // tr = b%a; // // a=b%a; // b=t; // } // // return max(a,b); //} // Returns n^(-1) mod p // int modInverse(int n, lli p) //{ // return powmod(n, p-2, p); //} // // // lli fac[N]; // void facinit(int n){ // fac[0]=1; // for (int i=1 ; i<=n; i++) // fac[i] = fac[i-1]*i%mod; //} // int nCrModPFermat(int n, int r, lli p) //{ // // Base case // if (r==0) // return 1; // // // return (fac[n]* modInverse(fac[r], p) % p * // modInverse(fac[n-r], p) % p) % p; //} /*BITMASK for( int inum = 0 ; inum < ( 1 << n ) ; ++ inum ) { for ( int pos = 0; pos < n ; ++pos ) { if ( ( inum & ( 1 << pos ) ) != 0 ) results[inum] += s [pos] ; //DO SOMETHING } } } */ bool a[N][N]; lli dp[N][N]; int h, w; lli f(int x, int y) { if (dp[x][y] != -1) return dp[x][y]; lli sum = 0; if (x + 1 < h) if (a[x + 1][y]) sum = modadd(f(x + 1, y), sum); if (y + 1 < w) if (a[x][y + 1]) sum = modadd(f(x, y + 1), sum); dp[x][y] = sum; return sum; } char x; int main() { // fastIO; int erer = 1; // cin>>erer; loop(erer2, 1, erer + 1) { cin >> h >> w; memset(dp, -1, sizeof(dp)); dp[h - 1][w - 1] = 1; loop(i, 0, h) loop(j, 0, w) { cin >> x; if (x == '.') a[i][j] = 1; } cout << f(0, 0); } return 0; }
[ "preprocessor.define.value.change", "literal.integer.change" ]
976,131
976,132
u290300767
cpp
p03167
#include <bits/stdc++.h> using namespace std; long dp[1005][1005]; char grid[1005][1005]; #define mod 1000000009 long solve(int m, int n) { if (m < 0 || n < 0) { return 0; } if (grid[m][n] == '#') { return 0; } if (dp[m][n] != -1) { return dp[m][n] % mod; } dp[m][n] = solve(m - 1, n) % mod + solve(m, n - 1) % mod; return dp[m][n] % mod; } int main() { int h, w; cin >> h >> w; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { cin >> grid[i][j]; dp[i][j] = -1; } } dp[0][0] = 0; /*for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ cout<<grid[i][j]; } cout<<'\n'; }*/ if (grid[0][1] == '.') { dp[0][1] = 1; } if (grid[1][0] == '.') { dp[1][0] = 1; } cout << solve(h - 1, w - 1); /*for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ cout<<dp[i][j]; } cout<<'\n'; }*/ }
#include <bits/stdc++.h> using namespace std; long dp[1005][1005]; char grid[1005][1005]; #define mod 1000000007 long solve(int m, int n) { if (m < 0 || n < 0) { return 0; } if (grid[m][n] == '#') { return 0; } if (dp[m][n] != -1) { return dp[m][n] % mod; } dp[m][n] = solve(m - 1, n) % mod + solve(m, n - 1) % mod; return dp[m][n] % mod; } int main() { int h, w; cin >> h >> w; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { cin >> grid[i][j]; dp[i][j] = -1; } } dp[0][0] = 0; /*for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ cout<<grid[i][j]; } cout<<'\n'; }*/ if (grid[0][1] == '.') { dp[0][1] = 1; } if (grid[1][0] == '.') { dp[1][0] = 1; } cout << solve(h - 1, w - 1); /*for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ cout<<dp[i][j]; } cout<<'\n'; }*/ }
[ "preprocessor.define.value.change", "literal.integer.change" ]
976,146
976,147
u427698913
cpp
p03167
/* tarun360 IIT Indore */ #include <bits/stdc++.h> using namespace std; #define ll long long #define ll_s long #define mod 1000000007 #define forn(i, start, lim) for (ll i = start; i < lim; i++) #define forn_d(i, start, lim) for (ll i = start; i >= lim; i--) #define forn_s(i, start, lim) for (ll_s i = start; i < lim; i++) #define forn_d_s(i, start, lim) for (ll_s i = start; i >= lim; i--) #define f first #define s second #define pb push_back #define mp make_pair #define debug1(a) cout << a << endl #define debug2(a, b) cout << a << " " << b << endl #define debug3(a, b, c) cout << a << " " << b << " " << c << endl #define debug4(a) cout << "chu " << a << endl ll dp[1005][1005], a[1005][1005]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll h, w; char ch; cin >> h >> w; forn(i, 0, h) { forn(j, 0, w) { cin >> ch; if (ch == '#') a[i][j] = -1; } } bool f = true; dp[0][0] = 1; forn(i, 1, h) { if (a[i][0] != -1 && f == true) { dp[i][0] = 1; } else { f = false; dp[i][0] = 0; } } f = true; forn(i, 1, w) { if (a[0][i] != -1 && f == true) { dp[0][i] = 1; } else { f = false; dp[i][0] = 0; } } forn(i, 1, h) { forn(j, 1, w) { if (a[i][j] == -1) dp[i][j] = 0; else { dp[i][j] = (dp[i - 1][j] % mod + dp[i][j - 1] % mod) % mod; } } } cout << dp[h - 1][w - 1] << endl; return 0; }
/* tarun360 IIT Indore */ #include <bits/stdc++.h> using namespace std; #define ll long long #define ll_s long #define mod 1000000007 #define forn(i, start, lim) for (ll i = start; i < lim; i++) #define forn_d(i, start, lim) for (ll i = start; i >= lim; i--) #define forn_s(i, start, lim) for (ll_s i = start; i < lim; i++) #define forn_d_s(i, start, lim) for (ll_s i = start; i >= lim; i--) #define f first #define s second #define pb push_back #define mp make_pair #define debug1(a) cout << a << endl #define debug2(a, b) cout << a << " " << b << endl #define debug3(a, b, c) cout << a << " " << b << " " << c << endl #define debug4(a) cout << "chu " << a << endl ll dp[1005][1005], a[1005][1005]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll h, w; char ch; cin >> h >> w; forn(i, 0, h) { forn(j, 0, w) { cin >> ch; if (ch == '#') a[i][j] = -1; } } bool f = true; dp[0][0] = 1; forn(i, 1, h) { if (a[i][0] != -1 && f == true) { dp[i][0] = 1; } else { f = false; dp[i][0] = 0; } } f = true; forn(i, 1, w) { if (a[0][i] != -1 && f == true) { dp[0][i] = 1; } else { f = false; dp[0][i] = 0; } } forn(i, 1, h) { forn(j, 1, w) { if (a[i][j] == -1) dp[i][j] = 0; else { dp[i][j] = (dp[i - 1][j] % mod + dp[i][j - 1] % mod) % mod; } } } cout << dp[h - 1][w - 1] << endl; return 0; }
[ "assignment.variable.change", "identifier.replace.remove", "literal.replace.add", "variable_access.subscript.index.change", "identifier.replace.add", "literal.replace.remove" ]
976,150
976,151
u772514767
cpp
p03167
#include <bits/stdc++.h> #define ll long long int #define M 1000000000000000002 #define N 400003 #define pb push_back #define endl "\n" char a[3000][3000]; ll b[3000][3000]; using namespace std; int main() { ll h, w; cin >> h >> w; for (ll i = 0; i < h; i++) { for (ll j = 0; j < w; j++) { cin >> a[i][j]; } } char ab = '#'; int flag = 0; for (ll i = 1; i < w; i++) { if (a[0][i] == ab) { b[0][i] = 0; flag = 1; } if (flag == 0) b[0][i] = 1; else b[0][i] = 0; } flag = 0; for (ll i = 0; i < h; i++) { if (a[i][0] == ab) { b[i][0] = 0; flag = 1; } else { if (flag == 0) b[i][0] = 1; else { b[i][0] = 0; } } } for (ll i = 1; i < h; i++) { for (ll j = 1; j < w; j++) { if (a[i][j] == ab) { b[i][j] = 0; } else { b[i][j] = (b[i - 1][j] + b[i][j - 1]); } } } cout << b[h - 1][w - 1] << endl; return 0; }
#include <bits/stdc++.h> #define ll long long int #define M 1000000000000000002 #define N 400003 #define pb push_back #define endl "\n" char a[3000][3000]; ll b[3000][3000]; using namespace std; int main() { ll h, w; cin >> h >> w; for (ll i = 0; i < h; i++) { for (ll j = 0; j < w; j++) { cin >> a[i][j]; } } char ab = '#'; int flag = 0; for (ll i = 1; i < w; i++) { if (a[0][i] == ab) { b[0][i] = 0; flag = 1; } if (flag == 0) b[0][i] = 1; else b[0][i] = 0; } flag = 0; for (ll i = 0; i < h; i++) { if (a[i][0] == ab) { b[i][0] = 0; flag = 1; } else { if (flag == 0) b[i][0] = 1; else { b[i][0] = 0; } } } for (ll i = 1; i < h; i++) { for (ll j = 1; j < w; j++) { if (a[i][j] == ab) { b[i][j] = 0; } else { b[i][j] = ((b[i - 1][j] + b[i][j - 1])) % 1000000007; } } } cout << b[h - 1][w - 1] << endl; return 0; }
[ "assignment.change" ]
976,158
976,159
u677600881
cpp
p03167
#include <algorithm> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define loop(i, l, r) for (int i = l; i < r; i++) #define all(x) (x).begin(), (x).end() typedef long long ll; typedef unsigned long long ull; typedef vector<int> vec_i; const int dx[4] = {0, 0, 1, -1}; const int dy[4] = {1, -1, 0, 0}; const int INF = 1e9; const int MOD = 1e9 + 7; int main() { int h, w; cin >> h >> w; vector<vec_i> dp(h + 1, vec_i(w + 1, 0)); rep(i, h) { rep(j, w) { char c; cin >> c; if (i == 0 && j == 0) { dp[i + 1][j + 1] = 1; } else if (c == '.') { dp[i + 1][j + 1] = dp[i][j + 1] + dp[i + 1][j] % MOD; } else { dp[i + 1][j + 1] = 0; } } } cout << dp[h][w] << endl; }
#include <algorithm> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define loop(i, l, r) for (int i = l; i < r; i++) #define all(x) (x).begin(), (x).end() typedef long long ll; typedef unsigned long long ull; typedef vector<int> vec_i; const int dx[4] = {0, 0, 1, -1}; const int dy[4] = {1, -1, 0, 0}; const int INF = 1e9; const int MOD = 1e9 + 7; int main() { int h, w; cin >> h >> w; vector<vec_i> dp(h + 1, vec_i(w + 1, 0)); rep(i, h) { rep(j, w) { char c; cin >> c; if (i == 0 && j == 0) { dp[i + 1][j + 1] = 1; } else if (c == '.') { dp[i + 1][j + 1] = (dp[i][j + 1] + dp[i + 1][j]) % MOD; } else { dp[i + 1][j + 1] = 0; } } } cout << dp[h][w] << endl; }
[]
976,194
976,195
u754144235
cpp
p03167
#include <algorithm> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define loop(i, l, r) for (int i = l; i < r; i++) #define all(x) (x).begin(), (x).end() typedef long long ll; typedef unsigned long long ull; typedef vector<int> vec_i; const int dx[4] = {0, 0, 1, -1}; const int dy[4] = {1, -1, 0, 0}; const int INF = 1e9; const int MOD = 1e9 + 7; int main() { int h, w; cin >> h >> w; vector<vec_i> dp(h + 1, vec_i(w + 1, 0)); rep(i, h) { rep(j, w) { char c; cin >> c; if (i == 0 && j == 0) { dp[i + 1][j + 1] = 1; } else if (c == '.') { dp[i + 1][j + 1] = dp[i][j + 1] + dp[i + 1][j]; } else { dp[i + 1][j + 1] = 0; } } } cout << dp[h][w] << endl; }
#include <algorithm> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define loop(i, l, r) for (int i = l; i < r; i++) #define all(x) (x).begin(), (x).end() typedef long long ll; typedef unsigned long long ull; typedef vector<int> vec_i; const int dx[4] = {0, 0, 1, -1}; const int dy[4] = {1, -1, 0, 0}; const int INF = 1e9; const int MOD = 1e9 + 7; int main() { int h, w; cin >> h >> w; vector<vec_i> dp(h + 1, vec_i(w + 1, 0)); rep(i, h) { rep(j, w) { char c; cin >> c; if (i == 0 && j == 0) { dp[i + 1][j + 1] = 1; } else if (c == '.') { dp[i + 1][j + 1] = (dp[i][j + 1] + dp[i + 1][j]) % MOD; } else { dp[i + 1][j + 1] = 0; } } } cout << dp[h][w] << endl; }
[ "assignment.change" ]
976,196
976,195
u754144235
cpp
p03167
#include <bits/stdc++.h> #define ll long long #define ui unsigned int #define ull unsigned long long #define bug(x) cerr << (#x) << " = " << (x) << endl; #define REP0(i, n) for (int i = 0, _n = (n); i < _n; ++i) #define REP1(i, n) for (int i = 1, _n = (n); i <= _n; ++i) #define REPB0(i, n) for (int i = (n)-1; i >= 0; --i) #define REPB1(i, n) for (int i = (n); i > 0; --i) #define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i) #define FORB(i, a, b) for (int i = (a), _b = (b); i >= _b; --i) #define pb push_back #define pf push_front #define popb pop_back #define popf pop_front #define X first #define Y second using namespace std; typedef pair<int, int> ii; typedef pair<ll, ll> pll; typedef pair<double, double> dd; typedef pair<float, float> ff; const int Hmax = 1001; const int Wmax = 1001; const int MOD = 1000000007; int h, w; int f[Hmax][Wmax]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); scanf("%d %d", &h, &w); char c; f[0][1] = 1; REP1(i, h) { fflush(stdin); REP1(j, w) { scanf("%c", &c); if (c == '.') f[i][j] = (f[i - 1][j] + f[i][j - 1]) % MOD; } } cout << f[h][w]; return 0; }
#include <bits/stdc++.h> #define ll long long #define ui unsigned int #define ull unsigned long long #define bug(x) cerr << (#x) << " = " << (x) << endl; #define REP0(i, n) for (int i = 0, _n = (n); i < _n; ++i) #define REP1(i, n) for (int i = 1, _n = (n); i <= _n; ++i) #define REPB0(i, n) for (int i = (n)-1; i >= 0; --i) #define REPB1(i, n) for (int i = (n); i > 0; --i) #define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i) #define FORB(i, a, b) for (int i = (a), _b = (b); i >= _b; --i) #define pb push_back #define pf push_front #define popb pop_back #define popf pop_front #define X first #define Y second using namespace std; typedef pair<int, int> ii; typedef pair<ll, ll> pll; typedef pair<double, double> dd; typedef pair<float, float> ff; const int Hmax = 1001; const int Wmax = 1001; const int MOD = 1000000007; int h, w; int f[Hmax][Wmax]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); scanf("%d %d", &h, &w); char c; f[0][1] = 1; REP1(i, h) { REP1(j, w) { scanf(" %c", &c); if (c == '.') f[i][j] = (f[i - 1][j] + f[i][j - 1]) % MOD; } } cout << f[h][w]; return 0; }
[ "call.remove", "literal.string.change", "call.arguments.change" ]
976,197
976,198
u300556027
cpp
p03166
#include <bits/stdc++.h> using namespace std; using LL = long long; vector<int> from[100001]; vector<int> dp; int df(int i) { if (dp[i] != -1) return dp[i]; dp[i] = 0; for (int f : from[i]) dp[i] = max(dp[i], df(f) + 1); return dp[i]; } int main() { int N, M; cin >> N >> M; for (int i = 0; i < M; i++) { int x, y; cin >> x >> y; from[y].push_back(x); } dp.resize(N, -1); for (int i = 1; i <= N; i++) if (dp[i] == -1) df(i); cout << *max_element(dp.begin(), dp.end()) << endl; }
#include <bits/stdc++.h> using namespace std; using LL = long long; vector<int> from[100001]; vector<int> dp; int df(int i) { if (dp[i] != -1) return dp[i]; dp[i] = 0; for (int f : from[i]) dp[i] = max(dp[i], df(f) + 1); return dp[i]; } int main() { int N, M; cin >> N >> M; for (int i = 0; i < M; i++) { int x, y; cin >> x >> y; from[y].push_back(x); } dp.resize(N + 1, -1); for (int i = 1; i <= N; i++) if (dp[i] == -1) df(i); cout << *max_element(dp.begin(), dp.end()) << endl; }
[ "expression.operation.binary.add" ]
976,217
976,218
u296096665
cpp
p03166
#include <bits/stdc++.h> using namespace std; vector<int> dp; int helperfn(int i, vector<vector<int>> &matrix) { // cout<<"helperfn"<<" "<<i<<endl; if (matrix[i].size() == 0) return 0; if (dp[i] != -1) return dp[i]; int maxi = 0; for (int j = 0; j <= matrix[i].size(); j++) { maxi = max(maxi, 1 + helperfn(matrix[i][j], matrix)); } dp[i] = maxi; return maxi; } int main() { int n, m; cin >> n >> m; vector<vector<int>> matrix(n + 2); for (int i = 0; i <= n; i++) dp.push_back(-1); for (int i = 0; i < m; i++) { int a, b; cin >> a >> b; matrix[a].push_back(b); } int ans = 0; for (int i = 1; i <= n; i++) { int x = helperfn(i, matrix); } for (int i = 1; i <= n; i++) ans = max(ans, dp[i]); cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; vector<int> dp; int helperfn(int i, vector<vector<int>> &matrix) { // cout<<"helperfn"<<" "<<i<<endl; if (matrix[i].size() == 0) return 0; if (dp[i] != -1) return dp[i]; int maxi = 0; for (int j = 0; j < matrix[i].size(); j++) { maxi = max(maxi, 1 + helperfn(matrix[i][j], matrix)); } dp[i] = maxi; return maxi; } int main() { int n, m; cin >> n >> m; vector<vector<int>> matrix(n + 2); for (int i = 0; i <= n; i++) dp.push_back(-1); for (int i = 0; i < m; i++) { int a, b; cin >> a >> b; matrix[a].push_back(b); } int ans = 0; for (int i = 1; i <= n; i++) { int x = helperfn(i, matrix); } for (int i = 1; i <= n; i++) ans = max(ans, dp[i]); cout << ans; return 0; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
976,219
976,220
u971084072
cpp
p03166
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x, to) for (x = 0; x < (to); x++) #define FORR(x, arr) for (auto &x : arr) #define ITR(x, c) for (__typeof(c.begin()) x = c.begin(); x != c.end(); x++) #define ALL(a) (a.begin()), (a.end()) #define ZERO(a) memset(a, 0, sizeof(a)) #define MINUS(a) memset(a, 0xff, sizeof(a)) //------------------------------------------------------- int N, M; vector<int> E[101010]; int in[101010]; int cur[101010]; void solve() { int i, j, k, l, r, x, y; string s; cin >> N >> M; FOR(i, M) { cin >> x >> y; x--, y--; E[x].push_back(y); in[y]++; } queue<int> Q; FOR(i, N) if (in[i] == 0) Q.push(i); int ma = 0; while (Q.size()) { x = Q.front(); Q.pop(); cur[x]++; ma = max(ma, cur[x]); FORR(e, E[x]) { cur[e] = max(cur[e], cur[x]); in[e]--; if (in[e] == 0) Q.push(e); } } cout << ma << endl; } int main(int argc, char **argv) { string s; int i; if (argc == 1) ios::sync_with_stdio(false), cin.tie(0); FOR(i, argc - 1) s += argv[i + 1], s += '\n'; FOR(i, s.size()) ungetc(s[s.size() - 1 - i], stdin); cout.tie(0); solve(); return 0; }
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x, to) for (x = 0; x < (to); x++) #define FORR(x, arr) for (auto &x : arr) #define ITR(x, c) for (__typeof(c.begin()) x = c.begin(); x != c.end(); x++) #define ALL(a) (a.begin()), (a.end()) #define ZERO(a) memset(a, 0, sizeof(a)) #define MINUS(a) memset(a, 0xff, sizeof(a)) //------------------------------------------------------- int N, M; vector<int> E[101010]; int in[101010]; int cur[101010]; void solve() { int i, j, k, l, r, x, y; string s; cin >> N >> M; FOR(i, M) { cin >> x >> y; x--, y--; E[x].push_back(y); in[y]++; } queue<int> Q; FOR(i, N) if (in[i] == 0) Q.push(i); int ma = 0; while (Q.size()) { x = Q.front(); Q.pop(); cur[x]++; ma = max(ma, cur[x]); FORR(e, E[x]) { cur[e] = max(cur[e], cur[x]); in[e]--; if (in[e] == 0) Q.push(e); } } cout << ma - 1 << endl; } int main(int argc, char **argv) { string s; int i; if (argc == 1) ios::sync_with_stdio(false), cin.tie(0); FOR(i, argc - 1) s += argv[i + 1], s += '\n'; FOR(i, s.size()) ungetc(s[s.size() - 1 - i], stdin); cout.tie(0); solve(); return 0; }
[ "expression.operation.binary.add" ]
976,230
976,231
u452725238
cpp
p03167
#include <bits/stdc++.h> typedef long long ll; typedef unsigned long long ull; typedef long double ld; ll mod = 1e9 + 7; #define EPS 1e-1 #define PI 3.14159265 #define iofile \ freopen("input.txt", "r", stdin); \ freopen("output.txt", "w", stdout); #define fastio ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); using namespace std; ll fastpow(ll base, ll pow) { if (!base) return 0; if (!pow) return 1; if (pow == 1) return base; ll x = fastpow(base, pow / 2) % mod; x *= x; x %= mod; if (pow % 2) x *= base; return x % mod; } ll inverse(ll x) { return fastpow(x, mod - 2) % mod; } ll fact[(int)1e6 + 5], inv[(int)1e6 + 5]; void init() { fact[0] = inv[0] = 1; for (int i = 1; i <= 1e6; i++) { fact[i] = (i * fact[i - 1]) % mod; inv[i] = inverse(fact[i]); } } void factorize(ll x, map<int, int> &ss) { while (x % 2 == 0) ss[2]++, x /= 2; for (int i = 3; i <= sqrt(x); i += 2) while (x % i == 0) ss[i]++, x /= i; if (x > 2) ss[x]++; } ll ncr(ll n, ll r) { return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod; } ll npr(ll n, ll r) { return (fact[n] * inv[n - r]) % mod; } int dx[] = {1, -1, 0, 0}; int dy[] = {0, 0, 1, -1}; char grid[1005][1005]; int dp[2005][2005]; int n, m; ll solve(int i, int j) { if (i >= n || j >= m) return 0; if (grid[i][j] == '#') return 0; if (i == n - 1 || j == m - 1) return 1; if (dp[i][j] != -1) return dp[i][j]; return dp[i][j] = ((solve(i + 1, j) % mod) + (solve(i, j + 1) % mod)) % mod; } int main() { fastio memset(dp, -1, sizeof dp); cin >> n >> m; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) cin >> grid[i][j]; cout << solve(0, 0); return 0; }
#include <bits/stdc++.h> typedef long long ll; typedef unsigned long long ull; typedef long double ld; ll mod = 1e9 + 7; #define EPS 1e-1 #define PI 3.14159265 #define iofile \ freopen("input.txt", "r", stdin); \ freopen("output.txt", "w", stdout); #define fastio ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); using namespace std; ll fastpow(ll base, ll pow) { if (!base) return 0; if (!pow) return 1; if (pow == 1) return base; ll x = fastpow(base, pow / 2) % mod; x *= x; x %= mod; if (pow % 2) x *= base; return x % mod; } ll inverse(ll x) { return fastpow(x, mod - 2) % mod; } ll fact[(int)1e6 + 5], inv[(int)1e6 + 5]; void init() { fact[0] = inv[0] = 1; for (int i = 1; i <= 1e6; i++) { fact[i] = (i * fact[i - 1]) % mod; inv[i] = inverse(fact[i]); } } void factorize(ll x, map<int, int> &ss) { while (x % 2 == 0) ss[2]++, x /= 2; for (int i = 3; i <= sqrt(x); i += 2) while (x % i == 0) ss[i]++, x /= i; if (x > 2) ss[x]++; } ll ncr(ll n, ll r) { return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod; } ll npr(ll n, ll r) { return (fact[n] * inv[n - r]) % mod; } int dx[] = {1, -1, 0, 0}; int dy[] = {0, 0, 1, -1}; char grid[1005][1005]; int dp[2005][2005]; int n, m; ll solve(int i, int j) { if (i >= n || j >= m) return 0; if (grid[i][j] == '#') return 0; if (i == n - 1 && j == m - 1) return 1; if (dp[i][j] != -1) return dp[i][j]; return dp[i][j] = ((solve(i + 1, j) % mod) + (solve(i, j + 1) % mod)) % mod; } int main() { fastio memset(dp, -1, sizeof dp); cin >> n >> m; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) cin >> grid[i][j]; cout << solve(0, 0); return 0; }
[ "misc.opposites", "control_flow.branch.if.condition.change" ]
976,244
976,245
u767097637
cpp
p03167
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> P; // L D U R const int dx[2] = {-1, 0}; const int dy[2] = {0, -1}; // Self settings // clang-format off #define MAX_HW 1000 #define REP(i, N) for (int i = 0; i < (int)(N); ++i) // clang-format on int H, W; bool board[MAX_HW][MAX_HW]; ll dp[MAX_HW + 1][MAX_HW + 1]; const int mod = 1000000007; int neighbor(int x, int y) { ll n = 0; for (int i = 0; i < 2; i++) { int xx = x + dx[i], yy = y + dy[i]; // 盤外か岩なら組み合わせからはずす if (xx < 0 || yy < 0 || !board[xx][yy]) continue; n = (n % mod) + (dp[xx][yy] % mod) % mod; } return n; } void solve() { memset(dp, 0, sizeof(dp)); dp[0][0] = 1; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { if (!board[i][j] || (i == 0 && j == 0)) continue; dp[i][j] = neighbor(i, j); } } cout << dp[H - 1][W - 1] << endl; } int main(void) { cin >> H >> W; REP(i, H) REP(j, W) { char x; cin >> x; if (x == '.') board[i][j] = true; else board[i][j] = false; } solve(); return 0; }
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> P; // L U const int dx[2] = {-1, 0}; const int dy[2] = {0, -1}; // Self settings // clang-format off #define MAX_HW 1000 #define REP(i, N) for (int i = 0; i < (int)(N); ++i) // clang-format on int H, W; bool board[MAX_HW][MAX_HW]; ll dp[MAX_HW + 1][MAX_HW + 1]; const int mod = 1000000007; int neighbor(int x, int y) { ll n = 0; for (int i = 0; i < 2; i++) { int xx = x + dx[i], yy = y + dy[i]; // 盤外か岩なら組み合わせからはずす if (xx < 0 || yy < 0 || !board[xx][yy]) continue; n = (n + dp[xx][yy]) % mod; } return n; } void solve() { memset(dp, 0, sizeof(dp)); dp[0][0] = 1; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { // 岩もしくは最初はスキップ if (!board[i][j] || (i == 0 && j == 0)) continue; dp[i][j] = neighbor(i, j); } } cout << dp[H - 1][W - 1] << endl; } int main(void) { cin >> H >> W; REP(i, H) REP(j, W) { char x; cin >> x; if (x == '.') board[i][j] = true; else board[i][j] = false; } solve(); return 0; }
[ "expression.operation.binary.remove" ]
976,252
976,253
u621104964
cpp
p03167
#include <bits/stdc++.h> using namespace std; #define eb emplace_back #define pb push_back #define pii pair<int64_t, int64_t> #define mp make_pair #define whole(v) begin(v), end(v) #define print(c, n) \ for (int64_t i = 0; i < n; i++) \ cout << c[i] << " "; #define MOD 1000000007 int dp[1006][1006]; void solve() { int n, m; cin >> n >> m; char arr[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> arr[i][j]; } } for (int i = 0; i < m; i++) { if (arr[0][i] == '#') { for (int j = i; j < m; j++) { arr[0][i] = 0; } break; } else { arr[0][i] = 1; } } for (int i = 0; i < n; i++) { if (arr[i][0] == '#') { for (int j = i; j < n; j++) { arr[i][0] = 0; } break; } else { arr[i][0] = 1; } } for (int i = 1; i < n; i++) { for (int j = 1; j < m; j++) { if (arr[i][j] == '#') continue; dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD; } } cout << dp[n - 1][m - 1] << "\n"; } int main() { solve(); }
#include <bits/stdc++.h> using namespace std; #define eb emplace_back #define pb push_back #define pii pair<int64_t, int64_t> #define mp make_pair #define whole(v) begin(v), end(v) #define print(c, n) \ for (int64_t i = 0; i < n; i++) \ cout << c[i] << " "; #define MOD 1000000007 int dp[1006][1006]; void solve() { int n, m; cin >> n >> m; char arr[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> arr[i][j]; } } for (int i = 0; i < m; i++) { if (arr[0][i] == '#') { for (int j = i; j < m; j++) { dp[0][i] = 0; } break; } else { dp[0][i] = 1; } } for (int i = 0; i < n; i++) { if (arr[i][0] == '#') { for (int j = i; j < n; j++) { dp[i][0] = 0; } break; } else { dp[i][0] = 1; } } for (int i = 1; i < n; i++) { for (int j = 1; j < m; j++) { if (arr[i][j] == '#') continue; dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD; } } // for(int i=0;i<n;i++){ // for(int j=0;j<m;j++){ // cout << dp[i][j] << " "; // } // cout << "\n"; // } cout << dp[n - 1][m - 1] << "\n"; } int main() { solve(); }
[ "assignment.variable.change", "identifier.change" ]
976,264
976,265
u806721693
cpp
p03167
#include <bits/stdc++.h> #define pb push_back #define F first #define S second #define all(x) x.begin(), x.end() #define debug(x) cerr << #x << " = " << x << endl using namespace std; typedef long long ll; typedef long double ld; typedef string str; typedef pair<ll, ll> pll; const ld PI = 3.14159265359; const ll MOD = (ll)1e9 + 7; const ll MAXN = (ll)1e3 + 10; const ll INF = (ll)2242545357980376863; const ld EPS = (ld)1e-8; ll dp[MAXN][MAXN]; char mp[MAXN][MAXN]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll n, m; cin >> n >> m; for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) cin >> mp[i][j]; dp[0][1] = 1; for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) { if (mp[i][j] == '#') continue; dp[i][j] = dp[i - 1][j] + dp[i][j - 1]; dp[i][j] %= MOD; } cout << dp[n][m]; return 0; } /* ____ ,----.. ,----.. ,---, ,' , `. / / \ / / \ ' .' \ ,-+-,.' _ | / . : / . : / ; '. ,-+-. ; , || . / ;. \ . / ;. \ : : \ ,--.'|' | ;| . ; / ` ; . ; / ` ; : | /\ \ | | ,', | ': ; | ; \ ; | ; | ; \ ; | | : ' ;. : | | / | | || | : | ; | ' | : | ; | ' | | ;/ \ \ ' | : | : |, . | ' ' ' : . | ' ' ' : ' : | \ \ ,' ; . | ; |--' ' ; \; / | ' ; \; / | | | ' '--' | : | | , \ \ ', / \ \ ', / | : : | : ' |/ ; : / ; : / | | ,' ; | |`-' \ \ .' \ \ .' `--'' | ;/ `---` `---` '---' */
#include <bits/stdc++.h> #define pb push_back #define F first #define S second #define all(x) x.begin(), x.end() #define debug(x) cerr << #x << " = " << x << endl using namespace std; typedef long long ll; typedef long double ld; typedef string str; typedef pair<ll, ll> pll; const ld PI = 3.14159265359; const ll MOD = (ll)1e9 + 7; const ll MAXN = (ll)1e3 + 10; const ll INF = (ll)2242545357980376863; const ld EPS = (ld)1e-8; ll dp[MAXN][MAXN]; char mp[MAXN][MAXN]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll n, m; cin >> n >> m; for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) cin >> mp[i][j]; dp[0][1] = 1; for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) { if (mp[i][j] == '#') continue; dp[i][j] = dp[i - 1][j] + dp[i][j - 1]; dp[i][j] %= MOD; } cout << dp[n][m]; return 0; } /* ____ ,----.. ,----.. ,---, ,' , `. / / \ / / \ ' .' \ ,-+-,.' _ | / . : / . : / ; '. ,-+-. ; , || . / ;. \ . / ;. \ : : \ ,--.'|' | ;| . ; / ` ; . ; / ` ; : | /\ \ | | ,', | ': ; | ; \ ; | ; | ; \ ; | | : ' ;. : | | / | | || | : | ; | ' | : | ; | ' | | ;/ \ \ ' | : | : |, . | ' ' ' : . | ' ' ' : ' : | \ \ ,' ; . | ; |--' ' ; \; / | ' ; \; / | | | ' '--' | : | | , \ \ ', / \ \ ', / | : : | : ' |/ ; : / ; : / | | ,' ; | |`-' \ \ .' \ \ .' `--'' | ;/ `---` `---` '---' */
[ "identifier.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
976,280
976,281
u787690200
cpp
p03167
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e3 + 5, MOD = 1e9 + 7; int H, W; char grid[MAXN][MAXN]; int dp[MAXN][MAXN]; int calcDp(int r, int c) { if (r < 0 || c < 0 || grid[r][c] == '#') return 0; if (dp[r][c] != -1) return dp[r][c]; if (r == 0 && c == 0) dp[r][c] = 1; else dp[r][c] = calcDp(r - 1, c) + calcDp(r, c - 1); return dp[r][c]; } signed main() { cin >> H >> W; for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) { cin >> grid[i][j]; dp[i][j] = -1; } cout << calcDp(H - 1, W - 1) << endl; // dp[0][0] = 1; // for (int r = 0; r < MAXN; r++) // for (int c = 0; c < MAXN; c++) { // if (grid[r][c] == '#') // continue; // if (r > 0) // dp[r][c] += dp[r - 1][c]; // if (c > 0) // dp[r][c] += dp[r][c - 1]; // } // cout << dp[H - 1][W - 1] << endl; }
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e3 + 5, MOD = 1e9 + 7; int H, W; char grid[MAXN][MAXN]; int dp[MAXN][MAXN]; int calcDp(int r, int c) { if (r < 0 || c < 0 || grid[r][c] == '#') return 0; if (dp[r][c] != -1) return dp[r][c]; if (r == 0 && c == 0) dp[r][c] = 1; else dp[r][c] = (calcDp(r - 1, c) + calcDp(r, c - 1)) % MOD; return dp[r][c]; } signed main() { cin >> H >> W; for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) { cin >> grid[i][j]; dp[i][j] = -1; } cout << calcDp(H - 1, W - 1) << endl; // dp[0][0] = 1; // for (int r = 0; r < MAXN; r++) // for (int c = 0; c < MAXN; c++) { // if (grid[r][c] == '#') // continue; // if (r > 0) // dp[r][c] += dp[r - 1][c]; // if (c > 0) // dp[r][c] += dp[r][c - 1]; // } // cout << dp[H - 1][W - 1] << endl; }
[ "assignment.change" ]
976,307
976,308
u883813944
cpp
p03167
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <float.h> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define endl '\n' #define MOD 1000000007 #define INF 1ll << 30 #define MAX 100010 #define eps 1e-11 #define bit_max 1ll << 32 #define _USE_MATH_DEFINES int grid[1005][1005]; long long int dp[1005][1005]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); int n, m; cin >> n >> m; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { char c; cin >> c; if (c == '.') { grid[i][j] = 1; } else grid[i][j] = 0; } } dp[1][1] = 1; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { if (i == 1 && j == 1) continue; if (grid[i - 1][j - 1] == 0) dp[i][j] = 0; else { if (i == 1) { if (grid[i][j - 2] == 0) dp[i][j] = 0; else dp[i][j] = dp[i][j - 1]; } else if (j == 1) { if (grid[i - 2][j] == 0) dp[i][j] = 0; else dp[i][j] = dp[i - 1][j]; } else { // if(grid[i-2][j-1] !=0 && grid[i-1][j-2]!=0) // { // cout<<i<<" "<<j<<" "<<grid[i-1][j-1]<<endl; // dp[i][j] = (dp[i-1][j]+dp[i][j-1])%1000000007; // } // else dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % 1000000007; } } } } // for(int i=0;i<=n;i++) // { // for(int j=0;j<=m;j++) // cout<<dp[i][j]<<" "; // cout<<endl; // } cout << dp[n][m]; return 0; }
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <float.h> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; #define endl '\n' #define MOD 1000000007 #define INF 1ll << 30 #define MAX 100010 #define eps 1e-11 #define bit_max 1ll << 32 #define _USE_MATH_DEFINES int grid[1005][1005]; long long int dp[1005][1005]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); int n, m; cin >> n >> m; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { char c; cin >> c; if (c == '.') { grid[i][j] = 1; } else grid[i][j] = 0; } } dp[1][1] = 1; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { if (i == 1 && j == 1) continue; if (grid[i - 1][j - 1] == 0) dp[i][j] = 0; else { if (i == 1) { if (grid[i - 1][j - 2] == 0) dp[i][j] = 0; else dp[i][j] = dp[i][j - 1]; } else if (j == 1) { if (grid[i - 2][j - 1] == 0) dp[i][j] = 0; else dp[i][j] = dp[i - 1][j]; } else { dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % 1000000007; } } } } cout << dp[n][m]; return 0; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "misc.off_by_one" ]
976,309
976,310
u566864240
cpp
p03167
#include <bits/stdc++.h> #define MAXN 1010 #define pii pair<int, int> #define pb push_back typedef long long ll; using namespace std; int n, m, dp[MAXN][MAXN], mod = 1e9 + 7; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { char a; cin >> a; if (i == 0 and j == 0) { if (a == '#') dp[1][1] = 0; else dp[1][1] = 1; continue; } dp[i + 1][j + 1] = dp[i][j + 1] + dp[i + 1][j] % mod; if (a == '#') dp[i + 1][j + 1] = 0; } } cout << dp[n][m]; }
#include <bits/stdc++.h> #define MAXN 1010 #define pii pair<int, int> #define pb push_back typedef long long ll; using namespace std; int n, m, dp[MAXN][MAXN], mod = 1e9 + 7; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { char a; cin >> a; if (i == 0 and j == 0) { if (a == '#') dp[1][1] = 0; else dp[1][1] = 1; continue; } dp[i + 1][j + 1] = (dp[i][j + 1] + dp[i + 1][j]) % mod; if (a == '#') dp[i + 1][j + 1] = 0; } } cout << dp[n][m]; }
[]
976,315
976,316
u190314045
cpp
p03167
#include <bits/stdc++.h> using namespace std; #define SPEED \ ios::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0) #define read() freopen("fibsubseq.in", "r", stdin) #define write() freopen("fibsubseq.out", "w", stdout) #define sf(n) scanf("%d", &n) #define sfd(n) scanf("%lf", &n) #define sl(x) scanf("%I64d", &x) #define sfl(n) scanf("%lld", &n) #define sfc(n) scanf(" %c", &n) #define sful(n) scanf("%llu", &n) #define ull unsigned long long int #define endll printf("\n") #define pf printf #define pi acos(-1.0) #define eps 1e-10 #define mem(a, b) memset(a, b, sizeof(a)) #define pb push_back #define xx first #define yy second #define pii pair<int, int> #define pll pair<ll, ll> #define MP make_pair #define ll long long #define uniq(a) a.erase(unique(a.begin(), a.end()), a.end()) bool Check(unsigned int N, int pos) { return (bool)(N & (1LL << pos)); } ll Set(unsigned int N, int pos) { return N = N | (1LL << pos); } #define cnd tree[idx] #define lnd tree[idx << 1] #define rnd tree[(idx << 1) + 1] #define lndp (idx << 1), (b), ((b + e) >> 1) #define rndp ((idx << 1) + 1), (((b + e) >> 1) + 1), (e) #define inf 1999999999 #define MX 100005 #define mod 1000000007 #define mod1 1000000009 #define var int ii, i, j, k, z = 0, c = 0, t, x, y, l, r, mid, n, m // int dx[8]={0,0,1,1,-1,-1,1,-1}; //8 direction // int dy[8]={1,-1,1,-1,1,-1,0,0}; ll a[1005][1005], b[1005][1005]; int main() { ll var; sfl(n); sfl(m); for (i = 1; i <= n; i++) { for (j = 1; j <= m; j++) { char ch; cin >> ch; b[i][j] = ch == '#'; } } a[1][1] = 1; if (b[1][1] == 1) a[1][1] = 0; for (i = 1; i <= n; i++) { for (j = 1; j <= n; j++) { if (b[i][j] != 1) a[i][j] += a[i - 1][j] + a[i][j - 1], a[i][j] %= mod; } } cout << a[n][m] << endl; }
#include <bits/stdc++.h> using namespace std; #define SPEED \ ios::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0) #define read() freopen("fibsubseq.in", "r", stdin) #define write() freopen("fibsubseq.out", "w", stdout) #define sf(n) scanf("%d", &n) #define sfd(n) scanf("%lf", &n) #define sl(x) scanf("%I64d", &x) #define sfl(n) scanf("%lld", &n) #define sfc(n) scanf(" %c", &n) #define sful(n) scanf("%llu", &n) #define ull unsigned long long int #define endll printf("\n") #define pf printf #define pi acos(-1.0) #define eps 1e-10 #define mem(a, b) memset(a, b, sizeof(a)) #define pb push_back #define xx first #define yy second #define pii pair<int, int> #define pll pair<ll, ll> #define MP make_pair #define ll long long #define uniq(a) a.erase(unique(a.begin(), a.end()), a.end()) bool Check(unsigned int N, int pos) { return (bool)(N & (1LL << pos)); } ll Set(unsigned int N, int pos) { return N = N | (1LL << pos); } #define cnd tree[idx] #define lnd tree[idx << 1] #define rnd tree[(idx << 1) + 1] #define lndp (idx << 1), (b), ((b + e) >> 1) #define rndp ((idx << 1) + 1), (((b + e) >> 1) + 1), (e) #define inf 1999999999 #define MX 100005 #define mod 1000000007 #define mod1 1000000009 #define var int ii, i, j, k, z = 0, c = 0, t, x, y, l, r, mid, n, m // int dx[8]={0,0,1,1,-1,-1,1,-1}; //8 direction // int dy[8]={1,-1,1,-1,1,-1,0,0}; ll a[1005][1005], b[1005][1005]; int main() { ll var; sfl(n); sfl(m); for (i = 1; i <= n; i++) { for (j = 1; j <= m; j++) { char ch; cin >> ch; b[i][j] = ch == '#'; } } a[1][1] = 1; if (b[1][1] == 1) a[1][1] = 0; for (i = 1; i <= n; i++) { for (j = 1; j <= m; j++) { if (b[i][j] != 1) a[i][j] += a[i - 1][j] + a[i][j - 1], a[i][j] %= mod; } } cout << a[n][m] << endl; }
[ "identifier.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
976,355
976,356
u302781973
cpp
p03167
#include <bits/stdc++.h> using namespace std; long n, m, kq = 0; long f[2000][2000], a[2000][2000]; vector<long> c[100005]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> m >> n; for (long i = 1; i <= m; i++) { for (long j = 1; j <= n; j++) { char v; cin >> v; if (v == '.') a[i][j] = 0; else a[i][j] = 1; } } f[1][1] = 1; for (long i = 1; i <= m; i++) { for (long j = 1; j <= n; j++) { if (i == 1 && j == 1) continue; if (a[i][j] == 1) f[i][j] = 0; else f[i][j] = f[i - 1][j] + f[i][j - 1]; } } cout << f[m][n]; }
#include <bits/stdc++.h> using namespace std; long n, m, kq = 0; long f[2000][2000], a[2000][2000]; vector<long> c[100005]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> m >> n; for (long i = 1; i <= m; i++) { for (long j = 1; j <= n; j++) { char v; cin >> v; if (v == '.') a[i][j] = 0; else a[i][j] = 1; } } f[1][1] = 1; for (long i = 1; i <= m; i++) { for (long j = 1; j <= n; j++) { if (i == 1 && j == 1) continue; if (a[i][j] == 1) f[i][j] = 0; else f[i][j] = (f[i - 1][j] + f[i][j - 1]) % 1000000007; } } cout << f[m][n]; }
[ "assignment.change" ]
976,357
976,358
u927331900
cpp
p03167
#include <bits/stdc++.h> #pragma comment(linker, "/stack:200000000") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define FASTIO \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define IN freopen("input.txt", "r", stdin); #define OUT freopen("output.txt", "w", stdout); #define LL long long #define MOD 1000000007 #define INF 1000000000000000000 #define all(x) (x).begin(), (x).end() #define pb(x) push_back(x) using namespace std; const int N = 1001; char a[N][N]; int H, W, F[N][N]; int dp(int x, int y) { if (x == 1 and y == 1) return 1; if (x < 1 or y < 1) return 0; if (a[x][y] == '#') return 0; if (F[x][y] > -1) return F[x][y]; int ans = dp(x - 1, y) + dp(y - 1, x); ans %= MOD; F[x][y] = ans; return ans; } int main() { // IN;OUT; FASTIO; cin >> H >> W; for (int i = 1; i <= H; i++) for (int j = 1; j <= W; j++) { cin >> a[i][j]; F[i][j] = -1; } cout << dp(H, W); return 0; }
#include <bits/stdc++.h> #pragma comment(linker, "/stack:200000000") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define FASTIO \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define IN freopen("input.txt", "r", stdin); #define OUT freopen("output.txt", "w", stdout); #define LL long long #define MOD 1000000007 #define INF 1000000000000000000 #define all(x) (x).begin(), (x).end() #define pb(x) push_back(x) using namespace std; const int N = 1001; char a[N][N]; int H, W; int F[N][N]; int dp(int x, int y) { if (x == 1 and y == 1) return 1; if (x < 1 or y < 1) return 0; if (a[x][y] == '#') return 0; if (F[x][y] > -1) return F[x][y]; int ans = dp(x - 1, y) + dp(x, y - 1); ans %= MOD; F[x][y] = ans; return ans; } int main() { // IN;OUT; FASTIO; cin >> H >> W; for (int i = 1; i <= H; i++) for (int j = 1; j <= W; j++) { cin >> a[i][j]; F[i][j] = -1; } cout << dp(H, W); return 0; } // 965601742
[ "call.arguments.add", "call.arguments.change" ]
976,386
976,387
u030635914
cpp
p03167
#include <iostream> #include <queue> using namespace std; int main() { int MOD = 1e9 + 7; int dp[1003][1003]; char map[1003][1003]; int H, W; cin >> H >> W; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { cin >> map[i][j]; } } for (int i = 0; i <= H; i++) { for (int j = 0; j <= W; j++) { dp[i][j] = 0; } } dp[1][1] = 1; for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++) { if (map[i][j] != '#') dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD; } } cout << dp[H][W] << endl; }
#include <iostream> #include <queue> using namespace std; int main() { int MOD = 1e9 + 7; int dp[1003][1003]; char map[1003][1003]; int H, W; cin >> H >> W; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { cin >> map[i][j]; } } for (int i = 0; i <= H; i++) { for (int j = 0; j <= W; j++) { dp[i][j] = 0; } } dp[0][1] = 1; for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++) { if (map[i - 1][j - 1] != '#') dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD; } } /*for (int i = 0; i <= H; i ++) { for (int j = 0; j <= W; j++) { cout << dp[i][j] << ' '; } cout << endl; }*/ cout << dp[H][W] << endl; }
[ "literal.number.change", "assignment.variable.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "misc.off_by_one" ]
976,395
976,396
u058186113
cpp
p03167
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL); } ll mod = 1e9 + 7; int main() { fast(); ll r, c; cin >> r >> c; ll dp[r][c]; char arr[r][c]; for (ll i = 0; i < r; i++) { for (ll j = 0; j < c; j++) cin >> arr[i][j]; } for (ll i = 0; i <= r; i++) { for (ll j = 0; j < c; j++) { dp[i][j] = 0; } } dp[r - 1][c - 1] = 1; for (ll i = r - 2; i >= 0; i--) { if (arr[i][c - 1] == '#') dp[i][c - 1] = 0; else dp[i][c - 1] = dp[i + 1][c - 1]; } for (ll i = c - 2; i >= 0; i--) { if (arr[r - 1][i] == '#') dp[r - 1][i] = 0; else dp[r - 1][i] = dp[r - 1][i + 1]; } for (ll i = r - 2; i >= 0; i--) { for (ll j = c - 2; j >= 0; j--) { if (arr[i][j] == '#') { dp[i][j] = 0; } else { dp[i][j] = (dp[i][j + 1] + dp[i + 1][j]) % mod; } } } cout << dp[0][0]; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL); } ll mod = 1e9 + 7; int main() { fast(); ll r, c; cin >> r >> c; ll dp[r][c]; char arr[r][c]; for (ll i = 0; i < r; i++) { for (ll j = 0; j < c; j++) cin >> arr[i][j]; } for (ll i = 0; i < r; i++) { for (ll j = 0; j < c; j++) { dp[i][j] = 0; } } dp[r - 1][c - 1] = 1; for (ll i = r - 2; i >= 0; i--) { if (arr[i][c - 1] == '#') dp[i][c - 1] = 0; else dp[i][c - 1] = dp[i + 1][c - 1]; } for (ll i = c - 2; i >= 0; i--) { if (arr[r - 1][i] == '#') dp[r - 1][i] = 0; else dp[r - 1][i] = dp[r - 1][i + 1]; } for (ll i = r - 2; i >= 0; i--) { for (ll j = c - 2; j >= 0; j--) { if (arr[i][j] == '#') { dp[i][j] = 0; } else { dp[i][j] = (dp[i][j + 1] + dp[i + 1][j]) % mod; } } } cout << dp[0][0]; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
976,403
976,404
u811604715
cpp
p03167
#include <bits/stdc++.h> using namespace std; long long n, m, dp[1005][1005], mod = 1e9 + 5; char grid[1005][1005]; long long go(int i, int j) { if (i == n || j == m || grid[i][j] == '#') return 0; else if (i == n - 1 && j == m - 1) return 1; if (dp[i][j] != -1) return dp[i][j]; return dp[i][j] = (go(i + 1, j) + go(i, j + 1)) % mod; } int main() { cin >> n >> m; memset(dp, -1, sizeof dp); for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) cin >> grid[i][j]; cout << go(0, 0); return 0; }
#include <bits/stdc++.h> using namespace std; long long n, m, dp[1005][1005], mod = 1e9 + 7; char grid[1005][1005]; long long go(int i, int j) { if (i == n || j == m || grid[i][j] == '#') return 0; else if (i == n - 1 && j == m - 1) return 1; if (dp[i][j] != -1) return dp[i][j]; return dp[i][j] = (go(i + 1, j) + go(i, j + 1)) % mod; } int main() { cin >> n >> m; memset(dp, -1, sizeof dp); for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) cin >> grid[i][j]; cout << go(0, 0); return 0; }
[ "literal.number.change", "expression.operation.binary.change" ]
976,431
976,432
u427647736
cpp
p03167
/* ID: computerbox --> Huseyn Hajiyev LANG: C++ TASK: target_mode_on */ #include <bits/stdc++.h> //#pragma comment(linker, "/stack:200000000") //#pragma GCC optimize("Ofast") //#pragma GCC optimize ("unroll-loops") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //#define _CRT_SECURE_NO_WARNINGS //#include <boost/multiprecision/cpp_int.hpp> // using boost::multiprecision::cpp_int; #define FAST_READ ios_base::sync_with_stdio(0); #define in freopen("input.txt", "r", stdin); #define out freopen("output.txt", "w", stdout); #define ll long long #define debt(x, y) \ cout << "#x = " << (x) << " and " \ << "#y = " << (y) << endl; #define deb(x) cout << "#x = " << (x) << endl; #define COUT(n, a) cout << fixed << setprecision(a) << n << endl #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() #define endl "\n" #define arr(a, n) \ for (ll i = 1; i <= n; i++) \ cout << a[i] << " "; \ cout << "\n"; #define vecc(a, n) \ for (ll i = 0; i < n; i++) \ cout << a[i] << " "; \ cout << "\n"; #define CURTIME() cerr << clock() * 1.0 / CLOCKS_PER_SEC << endl #define DTIME(ccc) \ __begin = clock(); \ ccc; \ cerr << "Time of work = " << (clock() - __begin) / CLOCKS_PER_SEC << endl; #define MAXN 2000 // cin.ignore (7777, '\n'); using namespace std; #define debug(args...) (Debugger()), args class Debugger { public: Debugger(const std::string &_separator = ", ") : first(true), separator(_separator) {} template <typename ObjectType> Debugger &operator,(const ObjectType &v) { if (!first) cerr << separator; cerr << v; first = false; return *this; } ~Debugger() { cerr << endl; } private: bool first; string separator; }; template <typename T1, typename T2> inline ostream &operator<<(std::ostream &os, const std::pair<T1, T2> &p) { return os << "(" << p.first << ", " << p.second << ")"; } template <typename T> inline ostream &operator<<(ostream &os, const vector<T> &v) { bool first = true; os << "["; for (unsigned ll i = 0; i < v.size(); i++) { if (!first) os << ", "; os << v[i]; first = false; } return os << "]"; } template <typename T> inline ostream &operator<<(ostream &os, const set<T> &v) { bool first = true; os << "["; for (typename set<T>::const_iterator ii = v.begin(); ii != v.end(); ++ii) { if (!first) os << ", "; os << *ii; first = false; } return os << "]"; } template <typename T1, typename T2> inline ostream &operator<<(ostream &os, const map<T1, T2> &v) { bool first = true; os << "["; for (typename map<T1, T2>::const_iterator ii = v.begin(); ii != v.end(); ++ii) { if (!first) os << ", "; os << *ii; first = false; } return os << "]"; } ll n, m; char massiv[MAXN][MAXN]; ll dp[MAXN][MAXN]; ll mod = 100000007; int main() { FAST_READ; cin >> n >> m; for (ll i = 1; i <= n; i++) { for (ll j = 1; j <= m; j++) { cin >> massiv[i][j]; } } if (massiv[1][1] != '#') dp[1][1] = 1; for (ll i = 1; i <= n; i++) { for (ll j = 1; j <= m; j++) { if (i == 1 && j == 1) continue; if (massiv[i][j] != '#') { if (i - 1 >= 1) dp[i][j] += dp[i - 1][j]; if (j - 1 >= 1) dp[i][j] += dp[i][j - 1]; dp[i][j] %= mod; } } } cout << dp[n][m] % mod << endl; return 0; }
/* ID: computerbox --> Huseyn Hajiyev LANG: C++ TASK: target_mode_on */ #include <bits/stdc++.h> //#pragma comment(linker, "/stack:200000000") //#pragma GCC optimize("Ofast") //#pragma GCC optimize ("unroll-loops") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //#define _CRT_SECURE_NO_WARNINGS //#include <boost/multiprecision/cpp_int.hpp> // using boost::multiprecision::cpp_int; #define FAST_READ ios_base::sync_with_stdio(0); #define in freopen("input.txt", "r", stdin); #define out freopen("output.txt", "w", stdout); #define ll long long #define debt(x, y) \ cout << "#x = " << (x) << " and " \ << "#y = " << (y) << endl; #define deb(x) cout << "#x = " << (x) << endl; #define COUT(n, a) cout << fixed << setprecision(a) << n << endl #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() #define endl "\n" #define arr(a, n) \ for (ll i = 1; i <= n; i++) \ cout << a[i] << " "; \ cout << "\n"; #define vecc(a, n) \ for (ll i = 0; i < n; i++) \ cout << a[i] << " "; \ cout << "\n"; #define CURTIME() cerr << clock() * 1.0 / CLOCKS_PER_SEC << endl #define DTIME(ccc) \ __begin = clock(); \ ccc; \ cerr << "Time of work = " << (clock() - __begin) / CLOCKS_PER_SEC << endl; #define MAXN 2000 // cin.ignore (7777, '\n'); using namespace std; #define debug(args...) (Debugger()), args class Debugger { public: Debugger(const std::string &_separator = ", ") : first(true), separator(_separator) {} template <typename ObjectType> Debugger &operator,(const ObjectType &v) { if (!first) cerr << separator; cerr << v; first = false; return *this; } ~Debugger() { cerr << endl; } private: bool first; string separator; }; template <typename T1, typename T2> inline ostream &operator<<(std::ostream &os, const std::pair<T1, T2> &p) { return os << "(" << p.first << ", " << p.second << ")"; } template <typename T> inline ostream &operator<<(ostream &os, const vector<T> &v) { bool first = true; os << "["; for (unsigned ll i = 0; i < v.size(); i++) { if (!first) os << ", "; os << v[i]; first = false; } return os << "]"; } template <typename T> inline ostream &operator<<(ostream &os, const set<T> &v) { bool first = true; os << "["; for (typename set<T>::const_iterator ii = v.begin(); ii != v.end(); ++ii) { if (!first) os << ", "; os << *ii; first = false; } return os << "]"; } template <typename T1, typename T2> inline ostream &operator<<(ostream &os, const map<T1, T2> &v) { bool first = true; os << "["; for (typename map<T1, T2>::const_iterator ii = v.begin(); ii != v.end(); ++ii) { if (!first) os << ", "; os << *ii; first = false; } return os << "]"; } ll n, m; char massiv[MAXN][MAXN]; ll dp[MAXN][MAXN]; ll mod = 1000000007; int main() { FAST_READ; cin >> n >> m; for (ll i = 1; i <= n; i++) { for (ll j = 1; j <= m; j++) { cin >> massiv[i][j]; } } if (massiv[1][1] != '#') dp[1][1] = 1; for (ll i = 1; i <= n; i++) { for (ll j = 1; j <= m; j++) { if (i == 1 && j == 1) continue; if (massiv[i][j] != '#') { if (i - 1 >= 1) dp[i][j] += dp[i - 1][j]; if (j - 1 >= 1) dp[i][j] += dp[i][j - 1]; dp[i][j] %= mod; } } } cout << dp[n][m] % mod << endl; return 0; }
[ "literal.number.change", "variable_declaration.value.change" ]
976,439
976,440
u805343140
cpp
p03168
#pragma GCC optimize("O3") #include <algorithm> #include <bits/stdc++.h> #include <cstring> #include <iomanip> #include <iostream> #include <map> #define forr(i, a, b) for (int i = a; i <= b; i++) #define F first #define S second #define input \ ios_base::sync_with_stdio(0); \ cin.tie(0); const double PI = acos(-1.0); using namespace std; // typedef pair<double,double>pdd; typedef long long ll; typedef pair<ll, ll> pii; // typedef complex<double> point; // int x[8]={1,0,0,-1,-1,-1,1,1}; // int y[8]={0,1,-1,0,-1,1,-1,1}; // char rv[4]={'D','R','L','U'}; const double EPS = 1e-9; const int N = 3000 + 9; int n, m; double a[N], mem[N][N]; double dp(int i, int h) { if (i > n) { if (h > n - h) return 1; return 0; } if (mem[i][h] == mem[i][h]) return mem[i][h]; double c1 = a[i] * dp(i + 1, h + 1); double c2 = (1.0 - a[i]) * dp(i + 1, h); return mem[i][h] = c1 + c2; } int main() { // freopen("calc.in","r",stdin); // freopen("calc.out","w",stdout); //__builtin_popcount() input cin >> n; forr(i, 1, n) cin >> a[i]; memset(mem, -1, sizeof mem); cout << fixed << setprecision(3) << dp(1, 0) << endl; return 0; }
#pragma GCC optimize("O3") #include <algorithm> #include <bits/stdc++.h> #include <cstring> #include <iomanip> #include <iostream> #include <map> #define forr(i, a, b) for (int i = a; i <= b; i++) #define F first #define S second #define input \ ios_base::sync_with_stdio(0); \ cin.tie(0); const double PI = acos(-1.0); using namespace std; // typedef pair<double,double>pdd; typedef long long ll; typedef pair<ll, ll> pii; // typedef complex<double> point; // int x[8]={1,0,0,-1,-1,-1,1,1}; // int y[8]={0,1,-1,0,-1,1,-1,1}; // char rv[4]={'D','R','L','U'}; const double EPS = 1e-9; const int N = 3000 + 9; int n, m; double a[N], mem[N][N]; double dp(int i, int h) { if (i > n) { if (h > n - h) return 1; return 0; } if (mem[i][h] == mem[i][h]) return mem[i][h]; double c1 = a[i] * dp(i + 1, h + 1); double c2 = (1.0 - a[i]) * dp(i + 1, h); return mem[i][h] = c1 + c2; } int main() { // freopen("calc.in","r",stdin); // freopen("calc.out","w",stdout); //__builtin_popcount() input cin >> n; forr(i, 1, n) cin >> a[i]; memset(mem, -1, sizeof mem); cout << fixed << setprecision(9) << dp(1, 0) << endl; return 0; }
[ "literal.number.change", "io.output.change" ]
976,449
976,450
u922603181
cpp
p03168
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <fstream> #include <iomanip> #include <iostream> #include <iterator> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; using ll = long long; using vll = vector<long long>; using vvll = vector<vll>; const double EPS = 1e-9; const ll MOD = 1e9 + 7; ll dx4[4] = {1, 0, -1, 0}; ll dy4[4] = {0, -1, 0, 1}; ll dx8[8] = {1, 0, -1, 1, -1, 1, 0, -1}; ll dy8[8] = {1, 1, 1, 0, 0, -1, -1, -1}; #define rep(i, n) REP(i, 0, n) #define ALL(v) v.begin(), v.end() #define MSG(a) cout << #a << " " << a << endl; #define REP(i, x, n) for (int i = x; i < n; i++) #define SZ(x) ((int)(x).size()) 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 (b < a) { a = b; return 1; } return 0; } int main() { ll n; cin >> n; vector<double> p(n); rep(i, n) cin >> p[i]; vector<vector<double>> dp(n, vector<double>(n + 1, 0.0)); dp[0][0] = 1 - p[0]; dp[0][1] = p[0]; for (ll i = 1; i < n; i++) { dp[i][0] = dp[i - 1][0] * (1 - p[i]); for (ll j = 1; j <= i + 1; j++) { dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1 - p[i]); } } double psum = accumulate(dp[n - 1].begin() + (n >> 1) + 1, dp[n - 1].end(), 0.0); cout << psum << endl; }
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <fstream> #include <iomanip> #include <iostream> #include <iterator> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; using ll = long long; using vll = vector<long long>; using vvll = vector<vll>; const double EPS = 1e-9; const ll MOD = 1e9 + 7; ll dx4[4] = {1, 0, -1, 0}; ll dy4[4] = {0, -1, 0, 1}; ll dx8[8] = {1, 0, -1, 1, -1, 1, 0, -1}; ll dy8[8] = {1, 1, 1, 0, 0, -1, -1, -1}; #define rep(i, n) REP(i, 0, n) #define ALL(v) v.begin(), v.end() #define MSG(a) cout << #a << " " << a << endl; #define REP(i, x, n) for (int i = x; i < n; i++) #define SZ(x) ((int)(x).size()) 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 (b < a) { a = b; return 1; } return 0; } int main() { ll n; cin >> n; vector<double> p(n); rep(i, n) cin >> p[i]; vector<vector<double>> dp(n, vector<double>(n + 1, 0.0)); dp[0][0] = 1 - p[0]; dp[0][1] = p[0]; for (ll i = 1; i < n; i++) { dp[i][0] = dp[i - 1][0] * (1 - p[i]); for (ll j = 1; j <= i + 1; j++) { dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1 - p[i]); } } double psum = accumulate(dp[n - 1].begin() + (n >> 1) + 1, dp[n - 1].end(), 0.0); cout << setprecision(10) << psum << endl; }
[ "io.output.change" ]
976,457
976,458
u430536466
cpp
p03168
#include <bits/stdc++.h> using namespace std; #define ll long long int #define pb push_back #define F first #define S second #define mod 1000000007 int main() { int n, i, j, k, l, p; cin >> n; vector<double> prob(n); vector<vector<double>> dp(n + 1, vector<double>(n + 1, 0)); dp[0][0] = 1; for (auto &i : prob) cin >> i; for (j = 0; j <= n; j++) { for (i = 0; i < n; i++) { dp[i + 1][j] = dp[i][j] * (1 - prob[i]); if (j) dp[i + 1][j] += dp[i][j - 1] * prob[i]; } } double ans = 0; for (i = n / 2 + 1; i <= n; i++) { ans += dp[n][i]; } setprecision(20); cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define ll long long int #define pb push_back #define F first #define S second #define mod 1000000007 int main() { int n, i, j, k, l, p; cin >> n; vector<double> prob(n); vector<vector<double>> dp(n + 1, vector<double>(n + 1, 0)); dp[0][0] = 1; for (auto &i : prob) cin >> i; for (j = 0; j <= n; j++) { for (i = 0; i < n; i++) { dp[i + 1][j] = dp[i][j] * (1 - prob[i]); if (j) dp[i + 1][j] += dp[i][j - 1] * prob[i]; } } double ans = 0; for (i = n / 2 + 1; i <= n; i++) { ans += dp[n][i]; } cout << setprecision((20)); cout << ans << endl; }
[ "io.output.change", "call.arguments.change" ]
976,459
976,460
u883654549
cpp
p03168
/* -ensure correct output format -ensure printing required output -reread the problem statement */ #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<ll, ll> pll; typedef pair<ll, pair<ll, ll>> plll; #define fastread() (ios_base::sync_with_stdio(false), cin.tie(NULL)); #define vll(v) v.begin(), v.end() #define all(x) x.rbegin(), x.rend() #define min3(a, b, c) min(a, min(b, c)) #define max3(a, b, c) max(a, max(b, c)) #define F first #define S second #define in freopen("input.txt", "r", stdin) #define out freopen("output.txt", "w", stdout) #define minheap int, vector<int>, greater<int> #define pb push_back #define eb emplace_back #define ischar(x) (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z')) #define isvowel(ch) \ ((ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') || \ (ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U')) #define bug cout << "BUG" << endl; const int Max = 2999 + 20; const int Mod = 1e9 + 7; const double PI = 3.141592653589793238463; bool compare(const pair<ll, ll> &a, const pair<ll, ll> &b) { return (a.first > b.first); } ll lcm(ll a, ll b) { if (a == 0 || b == 0) return 0; return a / __gcd(a, b) * b; } void input(ll ara[], ll n) { for (ll i = 0; i < n; i++) cin >> ara[i]; } double dp[Max][Max]; ll n; double ara[Max + 10]; bool vis[Max + 10][Max + 10]; double call(int i, int head) { double &ret = dp[i][head]; if (head < 0) return 0.0; // vis[i][head]=true; if (i == 0) return (head == 0); if (vis[i][head]) return ret; vis[i][head] = true; ret = (ara[i] * call(i - 1, head - 1)) + ((1.0 - ara[i]) * call(i - 1, head)); return ret; } int main() { fastread(); ll i, j, m, p, a, sum = 0, k, t, b, c, d, cnt = 0, q, l, r; bool flag = false; memset(dp, 0, sizeof(dp)); memset(vis, false, sizeof(vis)); cin >> n; for (i = 0; i < n; i++) cin >> ara[i]; double ans = 0; for (ll head = 0; head <= n; head++) { ll tail = n - head; // cout<<head<<" "<<tail<<endl; if (head > tail) { ans += call(n, head); // cout<<head<<endl; } } cout << setprecision(9) << fixed << ans << endl; }
/* -ensure correct output format -ensure printing required output -reread the problem statement */ #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<ll, ll> pll; typedef pair<ll, pair<ll, ll>> plll; #define fastread() (ios_base::sync_with_stdio(false), cin.tie(NULL)); #define vll(v) v.begin(), v.end() #define all(x) x.rbegin(), x.rend() #define min3(a, b, c) min(a, min(b, c)) #define max3(a, b, c) max(a, max(b, c)) #define F first #define S second #define in freopen("input.txt", "r", stdin) #define out freopen("output.txt", "w", stdout) #define minheap int, vector<int>, greater<int> #define pb push_back #define eb emplace_back #define ischar(x) (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z')) #define isvowel(ch) \ ((ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') || \ (ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U')) #define bug cout << "BUG" << endl; const int Max = 2999 + 20; const int Mod = 1e9 + 7; const double PI = 3.141592653589793238463; bool compare(const pair<ll, ll> &a, const pair<ll, ll> &b) { return (a.first > b.first); } ll lcm(ll a, ll b) { if (a == 0 || b == 0) return 0; return a / __gcd(a, b) * b; } void input(ll ara[], ll n) { for (ll i = 0; i < n; i++) cin >> ara[i]; } double dp[Max][Max]; ll n; double ara[Max + 10]; bool vis[Max + 10][Max + 10]; double call(int i, int head) { double &ret = dp[i][head]; if (head < 0) return 0.0; // vis[i][head]=true; if (i < 0) return (head == 0); if (vis[i][head]) return ret; vis[i][head] = true; ret = (ara[i] * call(i - 1, head - 1)) + ((1.0 - ara[i]) * call(i - 1, head)); return ret; } int main() { fastread(); ll i, j, m, p, a, sum = 0, k, t, b, c, d, cnt = 0, q, l, r; bool flag = false; memset(dp, 0, sizeof(dp)); memset(vis, false, sizeof(vis)); cin >> n; for (i = 0; i < n; i++) cin >> ara[i]; double ans = 0; for (ll head = 0; head <= n; head++) { ll tail = n - head; // cout<<head<<" "<<tail<<endl; if (head > tail) { ans += call(n - 1, head); // cout<<head<<endl; } } cout << setprecision(9) << fixed << ans << endl; }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change", "assignment.change" ]
976,485
976,486
u089230684
cpp
p03165
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < n; i++) #define SORT(v, n) sort(v, v + n); #define VSORT(v) sort(v.begin(), v.end()) #define VRSORT(v) sort(v.rbegin(), v.rend()) #define ll int64_t #define pb(a) push_back(a) #define INF 1000000000 #define MOD 1000000007 using namespace std; typedef pair<int, int> P; typedef pair<ll, ll> LP; typedef pair<int, P> PP; typedef pair<ll, LP> LPP; typedef vector<unsigned int> vec; typedef vector<vec> mat; 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 add(T &a, T b) { a = ((a + b) % MOD + MOD) % MOD; }; int dy[] = {0, 0, 1, -1, 0}; int dx[] = {1, -1, 0, 0, 0}; int dp[3030][3030]; int main() { cin.tie(0); ios::sync_with_stdio(false); string s, t; cin >> s >> t; REP(i, s.size()) { REP(j, t.size()) { if (s[i] == t[i]) chmax(dp[i + 1][j + 1], dp[i][j] + 1); chmax(dp[i + 1][j + 1], dp[i + 1][j]); chmax(dp[i + 1][j + 1], dp[i][j + 1]); } } string res = ""; int i = s.size(), j = t.size(); while (i > 0 && j > 0) { if (dp[i][j] == dp[i - 1][j]) --i; else if (dp[i][j] == dp[i][j - 1]) --j; else { res = s[i - 1] + res; --i, --j; } } cout << res << endl; }
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < n; i++) #define SORT(v, n) sort(v, v + n); #define VSORT(v) sort(v.begin(), v.end()) #define VRSORT(v) sort(v.rbegin(), v.rend()) #define ll int64_t #define pb(a) push_back(a) #define INF 1000000000 #define MOD 1000000007 using namespace std; typedef pair<int, int> P; typedef pair<ll, ll> LP; typedef pair<int, P> PP; typedef pair<ll, LP> LPP; typedef vector<unsigned int> vec; typedef vector<vec> mat; 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 add(T &a, T b) { a = ((a + b) % MOD + MOD) % MOD; }; int dy[] = {0, 0, 1, -1, 0}; int dx[] = {1, -1, 0, 0, 0}; int dp[3030][3030]; int main() { cin.tie(0); ios::sync_with_stdio(false); string s, t; cin >> s >> t; REP(i, s.size()) { REP(j, t.size()) { if (s[i] == t[j]) chmax(dp[i + 1][j + 1], dp[i][j] + 1); chmax(dp[i + 1][j + 1], dp[i + 1][j]); chmax(dp[i + 1][j + 1], dp[i][j + 1]); } } string res = ""; int i = s.size(), j = t.size(); while (i > 0 && j > 0) { if (dp[i][j] == dp[i - 1][j]) --i; else if (dp[i][j] == dp[i][j - 1]) --j; else { res = s[i - 1] + res; --i, --j; } } cout << res << endl; }
[ "identifier.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change" ]
976,538
976,539
u493750228
cpp
p03165
/* _ _ ___ __ _ _ _ _ _ _ ___| | |/ _ \__ __/ _| | || | ___| |__ | | | |/ _ \ | | | | \ \ /\ / / |_| | || |_/ __| '_ \ | |_| | __/ | | |_| |\ V V /| _| |__ _\__ \ | | | \__, |\___|_|_|\___/ \_/\_/ |_| |_| |_| |___/_| |_| |___/ */ #include <bits/stdc++.h> using namespace std; #define sz(x) (ll)(x).size() #define trav(x) for (auto &it : x) #define all(x) x.begin(), x.end() #define stp fixed << setprecision(20) #define db(x) cout << #x << ": " << x << endl #define tc \ ll tt; \ cin >> tt; \ while (tt--) #define For(i, st, en) for (ll i = st; i < en; i++) #define rFor(i, st, en) for (ll i = st; i >= en; i--) #define present(c, x) ((c).find(x) != (c).end()) #define cpresent(c, x) (find(all(c), x) != (c).end()) #define tr(x) for (auto it = x.begin(); it != x.end(); it++) #define fast \ std::ios::sync_with_stdio(false); \ cin.tie(NULL); #define printv(x) \ For(i, 0, sz(x)) { cout << x[i] << " "; } \ cout << endl; #define print2v(x) \ For(i, 0, sz(x)) { \ For(j, 0, sz(x[i])) { cout << x[i][j] << " "; } \ cout << endl; \ } #define ll long long #define int long long #define F first #define S second #define pb push_back #define lb lower_bound #define ub upper_bound typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<vi> vvi; typedef vector<pii> vpi; #define endl '\n' #define MAXN 300005 #define MOD 1000000007 #define INF 1000000000000000007 #define bitc __builtin_popcountll int begtime = clock(); #define end_routine() \ cout << "\n\nTime elapsed: " \ << (double)(clock() - begtime) * 1000 / CLOCKS_PER_SEC << " ms\n"; #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__) template <typename Arg1> void __f(const char *name, Arg1 &&arg1) { cout << name << " : " << arg1 << endl; } template <typename Arg1, typename... Args> void __f(const char *names, Arg1 &&arg1, Args &&...args) { const char *comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...); } void splitx(string s, char c, vector<string> &v) { int i = 0, j; while (i < sz(s)) { j = i; string temp; while (j < sz(s) && s[j] != c) { temp += s[j]; j++; } v.pb(temp); i = j + 1; } } /*################################ ¯\_(ツ)_/¯ ################################*/ signed main() { fast string s, t; cin >> s >> t; int n = sz(s); int m = sz(t); vvi dp(n, vi(m, 0)); For(i, 0, n) { For(j, 0, m) { if (i == 0) { if (s[i] == t[j]) { dp[i][j] = 1; } else if (j && dp[i][j - 1] == 1) { dp[i][j] = 1; } } else if (j == 0) { if (s[i] == t[j]) { dp[i][j] = 1; } else { dp[i][j] = dp[i - 1][j]; } } else { if (s[i] == t[j]) { dp[i][j] = dp[i - 1][j - 1] + 1; } dp[i][j] = max(dp[i][j], max(dp[i - 1][j], dp[i][j - 1])); } } } // print2v(dp); vi inds; int val = dp[n - 1][m - 1]; int i = n - 1, j = m - 1; while (j >= 0 && i >= 0) { while (i && dp[i - 1][j] == dp[i][j]) i--; while (j && dp[i][j - 1] == dp[i][j]) j--; if (j != 0) inds.pb(j); else if (dp[0][0]) inds.pb(0); j--; } // printv(inds); reverse(all(inds)); string ans; trav(inds) { ans += t[it]; } cout << ans << endl; // end_routine() return 0; }
/* _ _ ___ __ _ _ _ _ _ _ ___| | |/ _ \__ __/ _| | || | ___| |__ | | | |/ _ \ | | | | \ \ /\ / / |_| | || |_/ __| '_ \ | |_| | __/ | | |_| |\ V V /| _| |__ _\__ \ | | | \__, |\___|_|_|\___/ \_/\_/ |_| |_| |_| |___/_| |_| |___/ */ #include <bits/stdc++.h> using namespace std; #define sz(x) (ll)(x).size() #define trav(x) for (auto &it : x) #define all(x) x.begin(), x.end() #define stp fixed << setprecision(20) #define db(x) cout << #x << ": " << x << endl #define tc \ ll tt; \ cin >> tt; \ while (tt--) #define For(i, st, en) for (ll i = st; i < en; i++) #define rFor(i, st, en) for (ll i = st; i >= en; i--) #define present(c, x) ((c).find(x) != (c).end()) #define cpresent(c, x) (find(all(c), x) != (c).end()) #define tr(x) for (auto it = x.begin(); it != x.end(); it++) #define fast \ std::ios::sync_with_stdio(false); \ cin.tie(NULL); #define printv(x) \ For(i, 0, sz(x)) { cout << x[i] << " "; } \ cout << endl; #define print2v(x) \ For(i, 0, sz(x)) { \ For(j, 0, sz(x[i])) { cout << x[i][j] << " "; } \ cout << endl; \ } #define ll long long #define int long long #define F first #define S second #define pb push_back #define lb lower_bound #define ub upper_bound typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<vi> vvi; typedef vector<pii> vpi; #define endl '\n' #define MAXN 300005 #define MOD 1000000007 #define INF 1000000000000000007 #define bitc __builtin_popcountll int begtime = clock(); #define end_routine() \ cout << "\n\nTime elapsed: " \ << (double)(clock() - begtime) * 1000 / CLOCKS_PER_SEC << " ms\n"; #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__) template <typename Arg1> void __f(const char *name, Arg1 &&arg1) { cout << name << " : " << arg1 << endl; } template <typename Arg1, typename... Args> void __f(const char *names, Arg1 &&arg1, Args &&...args) { const char *comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...); } void splitx(string s, char c, vector<string> &v) { int i = 0, j; while (i < sz(s)) { j = i; string temp; while (j < sz(s) && s[j] != c) { temp += s[j]; j++; } v.pb(temp); i = j + 1; } } /*################################ ¯\_(ツ)_/¯ ################################*/ signed main() { fast string s, t; cin >> s >> t; int n = sz(s); int m = sz(t); vvi dp(n, vi(m, 0)); For(i, 0, n) { For(j, 0, m) { if (i == 0) { if (s[i] == t[j]) { dp[i][j] = 1; } else if (j && dp[i][j - 1] == 1) { dp[i][j] = 1; } } else if (j == 0) { if (s[i] == t[j]) { dp[i][j] = 1; } else { dp[i][j] = dp[i - 1][j]; } } else { if (s[i] == t[j]) { dp[i][j] = dp[i - 1][j - 1] + 1; } dp[i][j] = max(dp[i][j], max(dp[i - 1][j], dp[i][j - 1])); } } } // print2v(dp); vi inds; int val = dp[n - 1][m - 1]; int i = n - 1, j = m - 1; while (j >= 0 && i >= 0) { while (i && dp[i - 1][j] == dp[i][j]) i--; while (j && dp[i][j - 1] == dp[i][j]) j--; if (j != 0) inds.pb(j); else if (dp[i][j]) inds.pb(0); j--; } // printv(inds); reverse(all(inds)); string ans; trav(inds) { ans += t[it]; } cout << ans << endl; // end_routine() return 0; }
[ "identifier.replace.add", "literal.replace.remove", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change" ]
976,564
976,565
u278136654
cpp
p03165
#include <bits/stdc++.h> using namespace std; int main() { string s, t; cin >> s >> t; vector<vector<int>> dp(s.size() + 1, vector<int>(t.size() + 1)); for (int i = 1; i <= s.size(); i++) { for (int j = 1; j <= t.size(); j++) { if (s[i - 1] == t[j - 1]) dp[i][j] = max(dp[i][j], 1 + dp[i - 1][j - 1]); else { dp[i][j] = max(dp[i][j], max(dp[i - 1][j], dp[i][j - 1])); } } } int i = s.size(), j = t.size(); string ans = ""; while (j > 0) { // cout<<i<<" "<<j<<" "<<dp[i][j]<<endl; if (dp[i][j] == dp[i - 1][j]) { i--; } else if (dp[i][j] == dp[i][j - 1]) { j--; } else { ans = s[i - 1] + ans; i--; j--; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s, t; cin >> s >> t; vector<vector<int>> dp(s.size() + 1, vector<int>(t.size() + 1)); for (int i = 1; i <= s.size(); i++) { for (int j = 1; j <= t.size(); j++) { if (s[i - 1] == t[j - 1]) dp[i][j] = max(dp[i][j], 1 + dp[i - 1][j - 1]); else { dp[i][j] = max(dp[i][j], max(dp[i - 1][j], dp[i][j - 1])); } } } int i = s.size(), j = t.size(); string ans = ""; while (j > 0 && i > 0) { // cout<<i<<" "<<j<<" "<<dp[i][j]<<endl; if (dp[i][j] == dp[i - 1][j]) { i--; } else if (dp[i][j] == dp[i][j - 1]) { j--; } else { ans = s[i - 1] + ans; i--; j--; } } cout << ans << endl; return 0; }
[ "control_flow.loop.condition.change" ]
976,581
976,582
u658234551
cpp
p03165
#include <bits/stdc++.h> #define all(x) (x).begin(), (x).end() typedef long long ll; #define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i) #define REP(i, num, n) for (ll i = num, i##_len = (n); i < i##_len; ++i) #define repprev(i, a, b) for (ll i = b - 1; i >= a; i--) #define reprev(i, n) repprev(i, 0, n) using namespace std; #define sz(x) ((int)(x).size()) #define ZERO(a) memset(a, 0, sizeof(a)) #define MINUS(a) memset(a, 0xff, sizeof(a)) #define MEMSET(v, h) memset((v), h, sizeof(v)) 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 (b < a) { a = b; return 1; } return 0; } template <class T> int former(const vector<T> &v, T x) { return upper_bound(v.begin(), v.end(), x) - v.begin() - 1; } template <class T> int latter(const vector<T> &v, T x) { return lower_bound(v.begin(), v.end(), x) - v.begin(); } #define pb push_back #define mp make_pair using P = pair<ll, ll>; using vl = vector<ll>; using vb = vector<bool>; using vs = vector<string>; using vd = vector<double>; using vc = vector<char>; using vp = vector<P>; #define V vector #define o_vvt(o1, o2, o3, o4, name, ...) name #define vvt0(t) V<V<t>> #define vvt1(t, a) V<V<t>> a #define vvt2(t, a, b) V<V<t>> a(b) #define vvt3(t, a, b, c) V<V<t>> a(b, V<t>(c)) #define vvt4(t, a, b, c, d) V<V<t>> a(b, V<t>(c, d)) #define vvl(...) \ o_vvt(__VA_ARGS__, vvt4, vvt3, vvt2, vvt1, vvt0)(ll, __VA_ARGS__) #define vvb(...) \ o_vvt(__VA_ARGS__, vvt4, vvt3, vvt2, vvt1, vvt0)(bool, __VA_ARGS__) #define vvs(...) \ o_vvt(__VA_ARGS__, vvt4, vvt3, vvt2, vvt1, vvt0)(string, __VA_ARGS__) #define vvd(...) \ o_vvt(__VA_ARGS__, vvt4, vvt3, vvt2, vvt1, vvt0)(double, __VA_ARGS__) #define vvc(...) \ o_vvt(__VA_ARGS__, vvt4, vvt3, vvt2, vvt1, vvt0)(char, __VA_ARGS__) #define vvp(...) \ o_vvt(__VA_ARGS__, vvt4, vvt3, vvt2, vvt1, vvt0)(P, __VA_ARGS__) template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); } template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); } #define vni(name, ...) auto name = make_v<ll>(__VA_ARGS__) #define vnb(name, ...) auto name = make_v<bool>(__VA_ARGS__) #define vns(name, ...) auto name = make_v<string>(__VA_ARGS__) #define vnd(name, ...) auto name = make_v<double>(__VA_ARGS__) #define vnc(name, ...) auto name = make_v<char>(__VA_ARGS__) #define vnp(name, ...) auto name = make_v<P>(__VA_ARGS__) ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } const ll LLINF = 1LL << 60; const int INTINF = 1 << 30; const int MAX = 510000; 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; } struct UnionFind { vector<ll> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2 UnionFind(ll n) : par(n, -1) {} void init(ll n) { par.assign(n, -1); } ll root(ll x) { if (par[x] < 0) return x; else return par[x] = root(par[x]); } bool issame(ll x, ll y) { return root(x) == root(y); } bool merge(ll x, ll y) { x = root(x); y = root(y); if (x == y) return false; if (par[x] > par[y]) swap(x, y); // merge technique par[x] += par[y]; par[y] = x; return true; } ll size(ll x) { return -par[root(x)]; } }; template <typename T> vector<T> dijkstra(int s, vector<vector<pair<int, T>>> &G) { const T INF = numeric_limits<T>::max(); using P = pair<T, int>; int n = G.size(); vector<T> d(n, INF); vector<int> b(n, -1); priority_queue<P, vector<P>, greater<P>> q; d[s] = 0; q.emplace(d[s], s); while (!q.empty()) { P p = q.top(); q.pop(); int v = p.second; if (d[v] < p.first) continue; for (auto &e : G[v]) { int u = e.first; T c = e.second; if (d[u] > d[v] + c) { d[u] = d[v] + c; b[u] = v; q.emplace(d[u], u); } } } return d; } int64_t power(int64_t x, int64_t n, int64_t mod) { int64_t ret = 1; while (n > 0) { if (n & 1) (ret *= x) %= mod; (x *= x) %= mod; n >>= 1; } return ret; } vector<int> sieve_of_eratosthenes(int n) { vector<int> primes(n); for (int i = 2; i < n; ++i) primes[i] = i; for (int i = 2; i * i < n; ++i) if (primes[i]) for (int j = i * i; j < n; j += i) primes[j] = 0; return primes; } struct Dice { int s[6]; int &top() { return s[0]; } int &south() { return s[1]; } int &east() { return s[2]; } int &west() { return s[3]; } int &north() { return s[4]; } int &bottom() { return s[5]; } void roll(char c) { // the view from above // N // W E // S string b("EWNSRL"); int v[6][4] = {{0, 3, 5, 2}, {0, 2, 5, 3}, {0, 1, 5, 4}, {0, 4, 5, 1}, {1, 2, 4, 3}, {1, 3, 4, 2}}; for (int k = 0; k < 6; k++) { if (b[k] != c) continue; int t = s[v[k][0]]; s[v[k][0]] = s[v[k][1]]; s[v[k][1]] = s[v[k][2]]; s[v[k][2]] = s[v[k][3]]; s[v[k][3]] = t; } } using ll = long long; ll hash() { ll res = 0; for (int i = 0; i < 6; i++) res = res * 256 + s[i]; return res; } bool operator==(const Dice &d) const { for (int i = 0; i < 6; i++) if (s[i] != d.s[i]) return 0; return 1; } }; vector<Dice> makeDices(Dice d) { vector<Dice> res; for (int i = 0; i < 6; i++) { Dice t(d); if (i == 1) t.roll('N'); if (i == 2) t.roll('S'); if (i == 3) t.roll('S'), t.roll('S'); if (i == 4) t.roll('L'); if (i == 5) t.roll('R'); for (int k = 0; k < 4; k++) { res.push_back(t); t.roll('E'); } } return res; } std::vector<ll> divisor(ll n) // nの約数を列挙 { std::vector<ll> ret; for (ll i = 1; i * i <= n; ++i) { if (n % i == 0) { ret.push_back(i); if (i != 1 && i * i != n) { ret.push_back(n / i); } } } return ret; } // 多次元 vector 生成 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...)); } using Graph = vector<vector<int>>; // 深さ優先探索 vector<bool> seen; void gdfs(const Graph &G, int v) { seen[v] = true; // v を訪問済にする // v から行ける各頂点 next_v について for (auto next_v : G[v]) { if (seen[next_v]) continue; // next_v が探索済だったらスルー gdfs(G, next_v); // 再帰的に探索 } } const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; int main(void) { cin.tie(0); ios::sync_with_stdio(false); string s, t; cin >> s >> t; vvl(dp, s.size() + 1, t.size() + 1); rep(i, s.size()) { rep(j, t.size()) { if (s[i] == t[j]) chmax(dp[i + 1][j + 1], dp[i][j] + 1); chmax(dp[i + 1][j + 1], dp[i][j + 1]); chmax(dp[i + 1][j + 1], dp[i + 1][j]); } } string ans = ""; ll i = s.size(); ll j = t.size(); while (i > 0 && j > 0) { if (dp[i][j] == dp[i - 1][j]) --i; else if (dp[i][j] == dp[i][j - 1]) --j; else { ans += s[i - 1]; --i, --j; } } cout << ans << endl; }
#include <bits/stdc++.h> #define all(x) (x).begin(), (x).end() typedef long long ll; #define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i) #define REP(i, num, n) for (ll i = num, i##_len = (n); i < i##_len; ++i) #define repprev(i, a, b) for (ll i = b - 1; i >= a; i--) #define reprev(i, n) repprev(i, 0, n) using namespace std; #define sz(x) ((int)(x).size()) #define ZERO(a) memset(a, 0, sizeof(a)) #define MINUS(a) memset(a, 0xff, sizeof(a)) #define MEMSET(v, h) memset((v), h, sizeof(v)) 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 (b < a) { a = b; return 1; } return 0; } template <class T> int former(const vector<T> &v, T x) { return upper_bound(v.begin(), v.end(), x) - v.begin() - 1; } template <class T> int latter(const vector<T> &v, T x) { return lower_bound(v.begin(), v.end(), x) - v.begin(); } #define pb push_back #define mp make_pair using P = pair<ll, ll>; using vl = vector<ll>; using vb = vector<bool>; using vs = vector<string>; using vd = vector<double>; using vc = vector<char>; using vp = vector<P>; #define V vector #define o_vvt(o1, o2, o3, o4, name, ...) name #define vvt0(t) V<V<t>> #define vvt1(t, a) V<V<t>> a #define vvt2(t, a, b) V<V<t>> a(b) #define vvt3(t, a, b, c) V<V<t>> a(b, V<t>(c)) #define vvt4(t, a, b, c, d) V<V<t>> a(b, V<t>(c, d)) #define vvl(...) \ o_vvt(__VA_ARGS__, vvt4, vvt3, vvt2, vvt1, vvt0)(ll, __VA_ARGS__) #define vvb(...) \ o_vvt(__VA_ARGS__, vvt4, vvt3, vvt2, vvt1, vvt0)(bool, __VA_ARGS__) #define vvs(...) \ o_vvt(__VA_ARGS__, vvt4, vvt3, vvt2, vvt1, vvt0)(string, __VA_ARGS__) #define vvd(...) \ o_vvt(__VA_ARGS__, vvt4, vvt3, vvt2, vvt1, vvt0)(double, __VA_ARGS__) #define vvc(...) \ o_vvt(__VA_ARGS__, vvt4, vvt3, vvt2, vvt1, vvt0)(char, __VA_ARGS__) #define vvp(...) \ o_vvt(__VA_ARGS__, vvt4, vvt3, vvt2, vvt1, vvt0)(P, __VA_ARGS__) template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); } template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); } #define vni(name, ...) auto name = make_v<ll>(__VA_ARGS__) #define vnb(name, ...) auto name = make_v<bool>(__VA_ARGS__) #define vns(name, ...) auto name = make_v<string>(__VA_ARGS__) #define vnd(name, ...) auto name = make_v<double>(__VA_ARGS__) #define vnc(name, ...) auto name = make_v<char>(__VA_ARGS__) #define vnp(name, ...) auto name = make_v<P>(__VA_ARGS__) ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } const ll LLINF = 1LL << 60; const int INTINF = 1 << 30; const int MAX = 510000; 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; } struct UnionFind { vector<ll> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2 UnionFind(ll n) : par(n, -1) {} void init(ll n) { par.assign(n, -1); } ll root(ll x) { if (par[x] < 0) return x; else return par[x] = root(par[x]); } bool issame(ll x, ll y) { return root(x) == root(y); } bool merge(ll x, ll y) { x = root(x); y = root(y); if (x == y) return false; if (par[x] > par[y]) swap(x, y); // merge technique par[x] += par[y]; par[y] = x; return true; } ll size(ll x) { return -par[root(x)]; } }; template <typename T> vector<T> dijkstra(int s, vector<vector<pair<int, T>>> &G) { const T INF = numeric_limits<T>::max(); using P = pair<T, int>; int n = G.size(); vector<T> d(n, INF); vector<int> b(n, -1); priority_queue<P, vector<P>, greater<P>> q; d[s] = 0; q.emplace(d[s], s); while (!q.empty()) { P p = q.top(); q.pop(); int v = p.second; if (d[v] < p.first) continue; for (auto &e : G[v]) { int u = e.first; T c = e.second; if (d[u] > d[v] + c) { d[u] = d[v] + c; b[u] = v; q.emplace(d[u], u); } } } return d; } int64_t power(int64_t x, int64_t n, int64_t mod) { int64_t ret = 1; while (n > 0) { if (n & 1) (ret *= x) %= mod; (x *= x) %= mod; n >>= 1; } return ret; } vector<int> sieve_of_eratosthenes(int n) { vector<int> primes(n); for (int i = 2; i < n; ++i) primes[i] = i; for (int i = 2; i * i < n; ++i) if (primes[i]) for (int j = i * i; j < n; j += i) primes[j] = 0; return primes; } struct Dice { int s[6]; int &top() { return s[0]; } int &south() { return s[1]; } int &east() { return s[2]; } int &west() { return s[3]; } int &north() { return s[4]; } int &bottom() { return s[5]; } void roll(char c) { // the view from above // N // W E // S string b("EWNSRL"); int v[6][4] = {{0, 3, 5, 2}, {0, 2, 5, 3}, {0, 1, 5, 4}, {0, 4, 5, 1}, {1, 2, 4, 3}, {1, 3, 4, 2}}; for (int k = 0; k < 6; k++) { if (b[k] != c) continue; int t = s[v[k][0]]; s[v[k][0]] = s[v[k][1]]; s[v[k][1]] = s[v[k][2]]; s[v[k][2]] = s[v[k][3]]; s[v[k][3]] = t; } } using ll = long long; ll hash() { ll res = 0; for (int i = 0; i < 6; i++) res = res * 256 + s[i]; return res; } bool operator==(const Dice &d) const { for (int i = 0; i < 6; i++) if (s[i] != d.s[i]) return 0; return 1; } }; vector<Dice> makeDices(Dice d) { vector<Dice> res; for (int i = 0; i < 6; i++) { Dice t(d); if (i == 1) t.roll('N'); if (i == 2) t.roll('S'); if (i == 3) t.roll('S'), t.roll('S'); if (i == 4) t.roll('L'); if (i == 5) t.roll('R'); for (int k = 0; k < 4; k++) { res.push_back(t); t.roll('E'); } } return res; } std::vector<ll> divisor(ll n) // nの約数を列挙 { std::vector<ll> ret; for (ll i = 1; i * i <= n; ++i) { if (n % i == 0) { ret.push_back(i); if (i != 1 && i * i != n) { ret.push_back(n / i); } } } return ret; } // 多次元 vector 生成 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...)); } using Graph = vector<vector<int>>; // 深さ優先探索 vector<bool> seen; void gdfs(const Graph &G, int v) { seen[v] = true; // v を訪問済にする // v から行ける各頂点 next_v について for (auto next_v : G[v]) { if (seen[next_v]) continue; // next_v が探索済だったらスルー gdfs(G, next_v); // 再帰的に探索 } } const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; int main(void) { cin.tie(0); ios::sync_with_stdio(false); string s, t; cin >> s >> t; vvl(dp, s.size() + 1, t.size() + 1); rep(i, s.size()) { rep(j, t.size()) { if (s[i] == t[j]) chmax(dp[i + 1][j + 1], dp[i][j] + 1); chmax(dp[i + 1][j + 1], dp[i][j + 1]); chmax(dp[i + 1][j + 1], dp[i + 1][j]); } } string ans = ""; ll i = s.size(); ll j = t.size(); while (i > 0 && j > 0) { if (dp[i][j] == dp[i - 1][j]) --i; else if (dp[i][j] == dp[i][j - 1]) --j; else { ans = s[i - 1] + ans; --i, --j; } } cout << ans << endl; }
[ "assignment.value.change", "assignment.change" ]
976,583
976,584
u135572611
cpp
p03165
#include <bits/stdc++.h> #define all(x) (x).begin(), (x).end() typedef long long ll; #define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i) #define REP(i, num, n) for (ll i = num, i##_len = (n); i < i##_len; ++i) #define repprev(i, a, b) for (ll i = b - 1; i >= a; i--) #define reprev(i, n) repprev(i, 0, n) using namespace std; #define sz(x) ((int)(x).size()) #define ZERO(a) memset(a, 0, sizeof(a)) #define MINUS(a) memset(a, 0xff, sizeof(a)) #define MEMSET(v, h) memset((v), h, sizeof(v)) 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 (b < a) { a = b; return 1; } return 0; } template <class T> int former(const vector<T> &v, T x) { return upper_bound(v.begin(), v.end(), x) - v.begin() - 1; } template <class T> int latter(const vector<T> &v, T x) { return lower_bound(v.begin(), v.end(), x) - v.begin(); } #define pb push_back #define mp make_pair using P = pair<ll, ll>; using vl = vector<ll>; using vb = vector<bool>; using vs = vector<string>; using vd = vector<double>; using vc = vector<char>; using vp = vector<P>; #define V vector #define o_vvt(o1, o2, o3, o4, name, ...) name #define vvt0(t) V<V<t>> #define vvt1(t, a) V<V<t>> a #define vvt2(t, a, b) V<V<t>> a(b) #define vvt3(t, a, b, c) V<V<t>> a(b, V<t>(c)) #define vvt4(t, a, b, c, d) V<V<t>> a(b, V<t>(c, d)) #define vvl(...) \ o_vvt(__VA_ARGS__, vvt4, vvt3, vvt2, vvt1, vvt0)(ll, __VA_ARGS__) #define vvb(...) \ o_vvt(__VA_ARGS__, vvt4, vvt3, vvt2, vvt1, vvt0)(bool, __VA_ARGS__) #define vvs(...) \ o_vvt(__VA_ARGS__, vvt4, vvt3, vvt2, vvt1, vvt0)(string, __VA_ARGS__) #define vvd(...) \ o_vvt(__VA_ARGS__, vvt4, vvt3, vvt2, vvt1, vvt0)(double, __VA_ARGS__) #define vvc(...) \ o_vvt(__VA_ARGS__, vvt4, vvt3, vvt2, vvt1, vvt0)(char, __VA_ARGS__) #define vvp(...) \ o_vvt(__VA_ARGS__, vvt4, vvt3, vvt2, vvt1, vvt0)(P, __VA_ARGS__) template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); } template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); } #define vni(name, ...) auto name = make_v<ll>(__VA_ARGS__) #define vnb(name, ...) auto name = make_v<bool>(__VA_ARGS__) #define vns(name, ...) auto name = make_v<string>(__VA_ARGS__) #define vnd(name, ...) auto name = make_v<double>(__VA_ARGS__) #define vnc(name, ...) auto name = make_v<char>(__VA_ARGS__) #define vnp(name, ...) auto name = make_v<P>(__VA_ARGS__) ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } const ll LLINF = 1LL << 60; const int INTINF = 1 << 30; const int MAX = 510000; 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; } struct UnionFind { vector<ll> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2 UnionFind(ll n) : par(n, -1) {} void init(ll n) { par.assign(n, -1); } ll root(ll x) { if (par[x] < 0) return x; else return par[x] = root(par[x]); } bool issame(ll x, ll y) { return root(x) == root(y); } bool merge(ll x, ll y) { x = root(x); y = root(y); if (x == y) return false; if (par[x] > par[y]) swap(x, y); // merge technique par[x] += par[y]; par[y] = x; return true; } ll size(ll x) { return -par[root(x)]; } }; template <typename T> vector<T> dijkstra(int s, vector<vector<pair<int, T>>> &G) { const T INF = numeric_limits<T>::max(); using P = pair<T, int>; int n = G.size(); vector<T> d(n, INF); vector<int> b(n, -1); priority_queue<P, vector<P>, greater<P>> q; d[s] = 0; q.emplace(d[s], s); while (!q.empty()) { P p = q.top(); q.pop(); int v = p.second; if (d[v] < p.first) continue; for (auto &e : G[v]) { int u = e.first; T c = e.second; if (d[u] > d[v] + c) { d[u] = d[v] + c; b[u] = v; q.emplace(d[u], u); } } } return d; } int64_t power(int64_t x, int64_t n, int64_t mod) { int64_t ret = 1; while (n > 0) { if (n & 1) (ret *= x) %= mod; (x *= x) %= mod; n >>= 1; } return ret; } vector<int> sieve_of_eratosthenes(int n) { vector<int> primes(n); for (int i = 2; i < n; ++i) primes[i] = i; for (int i = 2; i * i < n; ++i) if (primes[i]) for (int j = i * i; j < n; j += i) primes[j] = 0; return primes; } struct Dice { int s[6]; int &top() { return s[0]; } int &south() { return s[1]; } int &east() { return s[2]; } int &west() { return s[3]; } int &north() { return s[4]; } int &bottom() { return s[5]; } void roll(char c) { // the view from above // N // W E // S string b("EWNSRL"); int v[6][4] = {{0, 3, 5, 2}, {0, 2, 5, 3}, {0, 1, 5, 4}, {0, 4, 5, 1}, {1, 2, 4, 3}, {1, 3, 4, 2}}; for (int k = 0; k < 6; k++) { if (b[k] != c) continue; int t = s[v[k][0]]; s[v[k][0]] = s[v[k][1]]; s[v[k][1]] = s[v[k][2]]; s[v[k][2]] = s[v[k][3]]; s[v[k][3]] = t; } } using ll = long long; ll hash() { ll res = 0; for (int i = 0; i < 6; i++) res = res * 256 + s[i]; return res; } bool operator==(const Dice &d) const { for (int i = 0; i < 6; i++) if (s[i] != d.s[i]) return 0; return 1; } }; vector<Dice> makeDices(Dice d) { vector<Dice> res; for (int i = 0; i < 6; i++) { Dice t(d); if (i == 1) t.roll('N'); if (i == 2) t.roll('S'); if (i == 3) t.roll('S'), t.roll('S'); if (i == 4) t.roll('L'); if (i == 5) t.roll('R'); for (int k = 0; k < 4; k++) { res.push_back(t); t.roll('E'); } } return res; } std::vector<ll> divisor(ll n) // nの約数を列挙 { std::vector<ll> ret; for (ll i = 1; i * i <= n; ++i) { if (n % i == 0) { ret.push_back(i); if (i != 1 && i * i != n) { ret.push_back(n / i); } } } return ret; } // 多次元 vector 生成 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...)); } using Graph = vector<vector<int>>; // 深さ優先探索 vector<bool> seen; void gdfs(const Graph &G, int v) { seen[v] = true; // v を訪問済にする // v から行ける各頂点 next_v について for (auto next_v : G[v]) { if (seen[next_v]) continue; // next_v が探索済だったらスルー gdfs(G, next_v); // 再帰的に探索 } } const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; int main(void) { cin.tie(0); ios::sync_with_stdio(false); string s, t; cin >> s >> t; vvl(dp, s.size(), t.size()); rep(i, s.size()) { rep(j, t.size()) { if (s[i] == t[j]) chmax(dp[i + 1][j + 1], dp[i][j] + 1); chmax(dp[i + 1][j + 1], dp[i][j + 1]); chmax(dp[i + 1][j + 1], dp[i + 1][j]); } } string ans = ""; ll i = s.size(); ll j = t.size(); while (i > 0 && j > 0) { if (dp[i][j] == dp[i - 1][j]) --i; else if (dp[i][j] == dp[i][j - 1]) --j; else { ans = s[i - 1] + ans; --i, --j; } } cout << ans << endl; }
#include <bits/stdc++.h> #define all(x) (x).begin(), (x).end() typedef long long ll; #define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i) #define REP(i, num, n) for (ll i = num, i##_len = (n); i < i##_len; ++i) #define repprev(i, a, b) for (ll i = b - 1; i >= a; i--) #define reprev(i, n) repprev(i, 0, n) using namespace std; #define sz(x) ((int)(x).size()) #define ZERO(a) memset(a, 0, sizeof(a)) #define MINUS(a) memset(a, 0xff, sizeof(a)) #define MEMSET(v, h) memset((v), h, sizeof(v)) 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 (b < a) { a = b; return 1; } return 0; } template <class T> int former(const vector<T> &v, T x) { return upper_bound(v.begin(), v.end(), x) - v.begin() - 1; } template <class T> int latter(const vector<T> &v, T x) { return lower_bound(v.begin(), v.end(), x) - v.begin(); } #define pb push_back #define mp make_pair using P = pair<ll, ll>; using vl = vector<ll>; using vb = vector<bool>; using vs = vector<string>; using vd = vector<double>; using vc = vector<char>; using vp = vector<P>; #define V vector #define o_vvt(o1, o2, o3, o4, name, ...) name #define vvt0(t) V<V<t>> #define vvt1(t, a) V<V<t>> a #define vvt2(t, a, b) V<V<t>> a(b) #define vvt3(t, a, b, c) V<V<t>> a(b, V<t>(c)) #define vvt4(t, a, b, c, d) V<V<t>> a(b, V<t>(c, d)) #define vvl(...) \ o_vvt(__VA_ARGS__, vvt4, vvt3, vvt2, vvt1, vvt0)(ll, __VA_ARGS__) #define vvb(...) \ o_vvt(__VA_ARGS__, vvt4, vvt3, vvt2, vvt1, vvt0)(bool, __VA_ARGS__) #define vvs(...) \ o_vvt(__VA_ARGS__, vvt4, vvt3, vvt2, vvt1, vvt0)(string, __VA_ARGS__) #define vvd(...) \ o_vvt(__VA_ARGS__, vvt4, vvt3, vvt2, vvt1, vvt0)(double, __VA_ARGS__) #define vvc(...) \ o_vvt(__VA_ARGS__, vvt4, vvt3, vvt2, vvt1, vvt0)(char, __VA_ARGS__) #define vvp(...) \ o_vvt(__VA_ARGS__, vvt4, vvt3, vvt2, vvt1, vvt0)(P, __VA_ARGS__) template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); } template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); } #define vni(name, ...) auto name = make_v<ll>(__VA_ARGS__) #define vnb(name, ...) auto name = make_v<bool>(__VA_ARGS__) #define vns(name, ...) auto name = make_v<string>(__VA_ARGS__) #define vnd(name, ...) auto name = make_v<double>(__VA_ARGS__) #define vnc(name, ...) auto name = make_v<char>(__VA_ARGS__) #define vnp(name, ...) auto name = make_v<P>(__VA_ARGS__) ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } const ll LLINF = 1LL << 60; const int INTINF = 1 << 30; const int MAX = 510000; 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; } struct UnionFind { vector<ll> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2 UnionFind(ll n) : par(n, -1) {} void init(ll n) { par.assign(n, -1); } ll root(ll x) { if (par[x] < 0) return x; else return par[x] = root(par[x]); } bool issame(ll x, ll y) { return root(x) == root(y); } bool merge(ll x, ll y) { x = root(x); y = root(y); if (x == y) return false; if (par[x] > par[y]) swap(x, y); // merge technique par[x] += par[y]; par[y] = x; return true; } ll size(ll x) { return -par[root(x)]; } }; template <typename T> vector<T> dijkstra(int s, vector<vector<pair<int, T>>> &G) { const T INF = numeric_limits<T>::max(); using P = pair<T, int>; int n = G.size(); vector<T> d(n, INF); vector<int> b(n, -1); priority_queue<P, vector<P>, greater<P>> q; d[s] = 0; q.emplace(d[s], s); while (!q.empty()) { P p = q.top(); q.pop(); int v = p.second; if (d[v] < p.first) continue; for (auto &e : G[v]) { int u = e.first; T c = e.second; if (d[u] > d[v] + c) { d[u] = d[v] + c; b[u] = v; q.emplace(d[u], u); } } } return d; } int64_t power(int64_t x, int64_t n, int64_t mod) { int64_t ret = 1; while (n > 0) { if (n & 1) (ret *= x) %= mod; (x *= x) %= mod; n >>= 1; } return ret; } vector<int> sieve_of_eratosthenes(int n) { vector<int> primes(n); for (int i = 2; i < n; ++i) primes[i] = i; for (int i = 2; i * i < n; ++i) if (primes[i]) for (int j = i * i; j < n; j += i) primes[j] = 0; return primes; } struct Dice { int s[6]; int &top() { return s[0]; } int &south() { return s[1]; } int &east() { return s[2]; } int &west() { return s[3]; } int &north() { return s[4]; } int &bottom() { return s[5]; } void roll(char c) { // the view from above // N // W E // S string b("EWNSRL"); int v[6][4] = {{0, 3, 5, 2}, {0, 2, 5, 3}, {0, 1, 5, 4}, {0, 4, 5, 1}, {1, 2, 4, 3}, {1, 3, 4, 2}}; for (int k = 0; k < 6; k++) { if (b[k] != c) continue; int t = s[v[k][0]]; s[v[k][0]] = s[v[k][1]]; s[v[k][1]] = s[v[k][2]]; s[v[k][2]] = s[v[k][3]]; s[v[k][3]] = t; } } using ll = long long; ll hash() { ll res = 0; for (int i = 0; i < 6; i++) res = res * 256 + s[i]; return res; } bool operator==(const Dice &d) const { for (int i = 0; i < 6; i++) if (s[i] != d.s[i]) return 0; return 1; } }; vector<Dice> makeDices(Dice d) { vector<Dice> res; for (int i = 0; i < 6; i++) { Dice t(d); if (i == 1) t.roll('N'); if (i == 2) t.roll('S'); if (i == 3) t.roll('S'), t.roll('S'); if (i == 4) t.roll('L'); if (i == 5) t.roll('R'); for (int k = 0; k < 4; k++) { res.push_back(t); t.roll('E'); } } return res; } std::vector<ll> divisor(ll n) // nの約数を列挙 { std::vector<ll> ret; for (ll i = 1; i * i <= n; ++i) { if (n % i == 0) { ret.push_back(i); if (i != 1 && i * i != n) { ret.push_back(n / i); } } } return ret; } // 多次元 vector 生成 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...)); } using Graph = vector<vector<int>>; // 深さ優先探索 vector<bool> seen; void gdfs(const Graph &G, int v) { seen[v] = true; // v を訪問済にする // v から行ける各頂点 next_v について for (auto next_v : G[v]) { if (seen[next_v]) continue; // next_v が探索済だったらスルー gdfs(G, next_v); // 再帰的に探索 } } const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; int main(void) { cin.tie(0); ios::sync_with_stdio(false); string s, t; cin >> s >> t; vvl(dp, s.size() + 1, t.size() + 1); rep(i, s.size()) { rep(j, t.size()) { if (s[i] == t[j]) chmax(dp[i + 1][j + 1], dp[i][j] + 1); chmax(dp[i + 1][j + 1], dp[i][j + 1]); chmax(dp[i + 1][j + 1], dp[i + 1][j]); } } string ans = ""; ll i = s.size(); ll j = t.size(); while (i > 0 && j > 0) { if (dp[i][j] == dp[i - 1][j]) --i; else if (dp[i][j] == dp[i][j - 1]) --j; else { ans = s[i - 1] + ans; --i, --j; } } cout << ans << endl; }
[ "expression.operation.binary.add" ]
976,585
976,584
u135572611
cpp
p03168
#include <algorithm> #include <cmath> #include <cstdio> #include <deque> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef vector<ll> vl; typedef vector<vector<ll>> vvl; typedef pair<ll, ll> P; #define rep(i, n) for (ll i = 0; i < n; i++) #define exrep(i, a, b) for (ll i = a; i <= b; i++) #define out(x) cout << x << endl #define exout(x) printf("%.10f\n", x) #define chmax(x, y) x = max(x, y) #define chmin(x, y) x = min(x, y) #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define pb push_back #define re0 return 0 const ll mod = 1000000007; const ll INF = 1e16; int main() { ll n; cin >> n; vector<double> p(n); rep(i, n) { cin >> p[i]; } vector<vector<double>> dp( n + 1, vector<double>(n + 1)); // dp[i][j] : i枚目までで表がj枚の確率 dp[0][0] = 1.0; rep(i, n) { rep(j, i) { dp[i + 1][j + 1] = p[i] * dp[i][j]; dp[i + 1][j] = (1 - p[i]) * dp[i][j]; } } double ans = 0.0; exrep(j, n / 2 + 1, n) { ans += dp[n][j]; } exout(ans); re0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <deque> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef vector<ll> vl; typedef vector<vector<ll>> vvl; typedef pair<ll, ll> P; #define rep(i, n) for (ll i = 0; i < n; i++) #define exrep(i, a, b) for (ll i = a; i <= b; i++) #define out(x) cout << x << endl #define exout(x) printf("%.10f\n", x) #define chmax(x, y) x = max(x, y) #define chmin(x, y) x = min(x, y) #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define pb push_back #define re0 return 0 const ll mod = 1000000007; const ll INF = 1e16; int main() { ll n; cin >> n; vector<double> p(n); rep(i, n) { cin >> p[i]; } vector<vector<double>> dp( n + 1, vector<double>(n + 1)); // dp[i][j] : i枚目までで表がj枚の確率 dp[0][0] = 1.0; rep(i, n) { exrep(j, 0, i) { dp[i + 1][j + 1] += p[i] * dp[i][j]; dp[i + 1][j] += (1 - p[i]) * dp[i][j]; } } double ans = 0.0; exrep(j, n / 2 + 1, n) { ans += dp[n][j]; } exout(ans); re0; }
[ "call.arguments.add", "assignment.value.change" ]
976,591
976,592
u828388155
cpp
p03168
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int N; cin >> N; long double arr[N]; for (int i = 0; i < N; ++i) { cin >> arr[i]; } long double dp[N + 1][N + 1]; dp[0][0] = 1.0; for (int i = 1; i < N + 1; ++i) { dp[i][0] = dp[i - 1][0] * (1 - arr[i - 1]); } for (int i = 1; i < N + 1; ++i) { dp[0][i] = 0.0; } for (int r = 1; r < N + 1; ++r) { for (int c = 1; c < N + 1; ++c) { dp[r][c] = dp[r - 1][c - 1] * arr[r - 1] + (1 - arr[r - 1]) * dp[r - 1][c]; } } long double result = 0; for (int i = ceil(N / 2.0); i < N + 1; ++i) { result += dp[N][i]; } cout << result << "\n"; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int N; cin >> N; long double arr[N]; for (int i = 0; i < N; ++i) { cin >> arr[i]; } long double dp[N + 1][N + 1]; dp[0][0] = 1.0; for (int i = 1; i < N + 1; ++i) { dp[i][0] = dp[i - 1][0] * (1 - arr[i - 1]); } for (int i = 1; i < N + 1; ++i) { dp[0][i] = 0.0; } for (int r = 1; r < N + 1; ++r) { for (int c = 1; c < N + 1; ++c) { dp[r][c] = dp[r - 1][c - 1] * arr[r - 1] + (1 - arr[r - 1]) * dp[r - 1][c]; } } long double result = 0; for (int i = ceil(N / 2.0); i < N + 1; ++i) { result += dp[N][i]; } cout << setprecision(15) << result << "\n"; }
[ "io.output.change" ]
976,593
976,594
u951243324
cpp
p03168
#include <bits/stdc++.h> using namespace std; using ll = long long; #define itn int #define rep(i, n) for (int i = 0; i < n; i++) long double dp[3000][3000]; int main() { int n; cin >> n; long double p[n]; for (int i = 0; i < n; i++) cin >> p[i]; dp[0][0] = 1; for (int i = 0; i < n; i++) { for (int j = 0; j <= n; j++) { if (j > 0) dp[i + 1][j] = dp[i][j] * (1 - p[i]) + dp[i][j - 1] * p[i]; else dp[i + 1][j] = dp[i][j] * (1 - p[i]); } } long double ans = 0; for (int i = (n + 1) / 2; i <= n; i++) { ans += dp[n][i]; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; #define itn int #define rep(i, n) for (int i = 0; i < n; i++) long double dp[3000][3000]; int main() { int n; cin >> n; long double p[n]; for (int i = 0; i < n; i++) cin >> p[i]; dp[0][0] = 1; for (int i = 0; i < n; i++) { for (int j = 0; j <= n; j++) { if (j > 0) dp[i + 1][j] = dp[i][j] * (1 - p[i]) + dp[i][j - 1] * p[i]; else dp[i + 1][j] = dp[i][j] * (1 - p[i]); } } long double ans = 0; for (int i = (n + 1) / 2; i <= n; i++) { ans += dp[n][i]; } cout << setprecision(12) << ans << endl; }
[ "io.output.change" ]
976,595
976,596
u512624048
cpp
p03168
#include <bits/stdc++.h> using namespace std; #define lc "\n" #define fast_io \ ios::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(0) #define mp make_pair #define pb push_back #define fi first #define se second #define int long long #define c(a, n) \ for (int i = 0; i < n; i++) \ cin >> a[i]; #define ffor(n) for (int i = 0; i < n; i++) typedef vector<int> vi; typedef vector<float> vf; typedef vector<vi> vii; typedef vector<string> vs; typedef vector<long long> vll; typedef map<string, int> msi; typedef map<int, int> mii; typedef unordered_map<string, int> umsi; int32_t main() { fast_io; int n; cin >> n; vector<float> a(n); c(a, n); vector<vector<float>> dp(n + 1, vector<float>(n + 1, 0.00)); dp[1][1] = a[0]; dp[1][0] = 1 - a[0]; for (int i = 2; i <= n; i++) { for (int j = 0; j <= i; j++) { if (j == 0) { dp[i][j] = (1.00 - a[i - 1]) * dp[i - 1][j]; continue; } if (j == i) { dp[i][j] = dp[i - 1][j - 1] * a[i - 1]; continue; } dp[i][j] += (a[i - 1] * dp[i - 1][j - 1]); dp[i][j] += (dp[i - 1][j] * (1.00 - a[i - 1])); } } float ans = 0.00; for (int i = n / 2 + 1; i <= n; i++) ans += dp[n][i]; cout << setprecision(9) << ans << lc; return 0; }
#include <bits/stdc++.h> using namespace std; #define lc "\n" #define fast_io \ ios::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(0) #define mp make_pair #define pb push_back #define fi first #define se second #define int long long #define c(a, n) \ for (int i = 0; i < n; i++) \ cin >> a[i]; #define ffor(n) for (int i = 0; i < n; i++) #define float long double typedef vector<int> vi; typedef vector<float> vf; typedef vector<vi> vii; typedef vector<string> vs; typedef vector<long long> vll; typedef map<string, int> msi; typedef map<int, int> mii; typedef unordered_map<string, int> umsi; int32_t main() { fast_io; int n; cin >> n; vector<float> a(n); c(a, n); vector<vector<float>> dp(n + 1, vector<float>(n + 1, 0.00)); dp[1][1] = a[0]; dp[1][0] = 1 - a[0]; for (int i = 2; i <= n; i++) { for (int j = 0; j <= i; j++) { if (j == 0) { dp[i][j] = (1.00 - a[i - 1]) * dp[i - 1][j]; continue; } if (j == i) { dp[i][j] = dp[i - 1][j - 1] * a[i - 1]; continue; } dp[i][j] += (a[i - 1] * dp[i - 1][j - 1]); dp[i][j] += (dp[i - 1][j] * (1.00 - a[i - 1])); } } float ans = 0.00; for (int i = n / 2 + 1; i <= n; i++) ans += dp[n][i]; cout << setprecision(10) << ans << lc; return 0; }
[ "literal.number.change", "io.output.change" ]
976,627
976,628
u900229905
cpp
p03168
#include <bits/stdc++.h> using namespace std; #define lc "\n" #define fast_io \ ios::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(0) #define mp make_pair #define pb push_back #define fi first #define se second #define int long long #define c(a, n) \ for (int i = 0; i < n; i++) \ cin >> a[i]; #define ffor(n) for (int i = 0; i < n; i++) typedef vector<int> vi; typedef vector<float> vf; typedef vector<vi> vii; typedef vector<string> vs; typedef vector<long long> vll; typedef map<string, int> msi; typedef map<int, int> mii; typedef unordered_map<string, int> umsi; int32_t main() { fast_io; int n; cin >> n; vector<float> a(n); c(a, n); vector<vector<float>> dp(n + 1, vector<float>(n + 1, 0.00)); dp[1][1] = a[0]; dp[1][0] = 1 - a[0]; for (int i = 2; i <= n; i++) { for (int j = 0; j <= i; j++) { if (j == 0) { dp[i][j] = (1.00 - a[i - 1]) * dp[i - 1][j]; continue; } if (j == i) { dp[i][j] = dp[i - 1][j - 1] * a[i - 1]; continue; } dp[i][j] += (a[i - 1] * dp[i - 1][j - 1]); dp[i][j] += (dp[i - 1][j] * (1.00 - a[i - 1])); } } float ans = 0.00; for (int i = n / 2 + 1; i <= n; i++) ans += dp[n][i]; cout << setprecision(10) << ans << lc; return 0; }
#include <bits/stdc++.h> using namespace std; #define lc "\n" #define fast_io \ ios::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(0) #define mp make_pair #define pb push_back #define fi first #define se second #define int long long #define c(a, n) \ for (int i = 0; i < n; i++) \ cin >> a[i]; #define ffor(n) for (int i = 0; i < n; i++) #define float long double typedef vector<int> vi; typedef vector<float> vf; typedef vector<vi> vii; typedef vector<string> vs; typedef vector<long long> vll; typedef map<string, int> msi; typedef map<int, int> mii; typedef unordered_map<string, int> umsi; int32_t main() { fast_io; int n; cin >> n; vector<float> a(n); c(a, n); vector<vector<float>> dp(n + 1, vector<float>(n + 1, 0.00)); dp[1][1] = a[0]; dp[1][0] = 1 - a[0]; for (int i = 2; i <= n; i++) { for (int j = 0; j <= i; j++) { if (j == 0) { dp[i][j] = (1.00 - a[i - 1]) * dp[i - 1][j]; continue; } if (j == i) { dp[i][j] = dp[i - 1][j - 1] * a[i - 1]; continue; } dp[i][j] += (a[i - 1] * dp[i - 1][j - 1]); dp[i][j] += (dp[i - 1][j] * (1.00 - a[i - 1])); } } float ans = 0.00; for (int i = n / 2 + 1; i <= n; i++) ans += dp[n][i]; cout << setprecision(10) << ans << lc; return 0; }
[]
976,629
976,628
u900229905
cpp
p03168
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; double p[n + 1], dp[n + 1][n + 1], h = 1; for (int i = 1; i <= n; i++) cin >> p[i]; dp[0][0] = 1; for (int i = 1; i <= n; i++) { dp[i][i] = dp[i - 1][i - 1] * p[i]; dp[i][0] = dp[i - 1][0] * (1 - p[i]); } for (int i = 1; i <= n; i++) { for (int j = 1; j < i; j++) { dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1 - p[i]); } } for (int i = n / 2 + 1; i <= n; i++) h += dp[n][i]; cout << fixed << setprecision(10) << h; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; double p[n + 1], dp[n + 1][n + 1], h = 0; for (int i = 1; i <= n; i++) cin >> p[i]; dp[0][0] = 1; for (int i = 1; i <= n; i++) { dp[i][i] = dp[i - 1][i - 1] * p[i]; dp[i][0] = dp[i - 1][0] * (1 - p[i]); } for (int i = 1; i <= n; i++) { for (int j = 1; j < i; j++) { dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1 - p[i]); } } for (int i = n / 2 + 1; i <= n; i++) h += dp[n][i]; cout << fixed << setprecision(10) << h; }
[ "literal.number.change", "variable_declaration.value.change" ]
976,635
976,636
u698089327
cpp
p03168
#include <bits/stdc++.h> using namespace std; typedef double ll; int main() { int n, i, j; cin >> n; ll a[n + 2]; for (i = 1; i <= n; i++) cin >> a[i]; vector<vector<ll>> dp(n + 1, vector<ll>(n + 2, 0.000000)); dp[0][0] = 1.000000; // dp[0][1]=a[1]; for (i = 1; i <= n; i++) dp[0][i] = dp[0][i - 1] * (1.000000 - a[i]); for (i = 1; i <= n; i++) { for (j = 1; j <= n; j++) { if (j < i) dp[i][j] = 0.000000; else { dp[i][j] = dp[i][j - 1] * (1.000000 - a[j]); dp[i][j] += dp[i - 1][j - 1] * a[j]; } } } ll ans = 0.0; for (i = (n + 1) / 2; i <= n; i++) ans += dp[i][n]; cout << setprecision(6) << ans; return 0; }
#include <bits/stdc++.h> using namespace std; typedef double ll; int main() { int n, i, j; cin >> n; ll a[n + 2]; for (i = 1; i <= n; i++) cin >> a[i]; vector<vector<ll>> dp(n + 1, vector<ll>(n + 2, 0.000000)); dp[0][0] = 1.000000; // dp[0][1]=a[1]; for (i = 1; i <= n; i++) dp[0][i] = dp[0][i - 1] * (1.000000 - a[i]); for (i = 1; i <= n; i++) { for (j = 1; j <= n; j++) { if (j < i) dp[i][j] = 0.000000; else { dp[i][j] = dp[i][j - 1] * (1.000000 - a[j]); dp[i][j] += dp[i - 1][j - 1] * a[j]; } } } ll ans = 0.000000; for (i = (n + 1) / 2; i <= n; i++) ans += dp[i][n]; cout << setprecision(10) << ans; return 0; }
[ "literal.number.change", "variable_declaration.value.change", "io.output.change" ]
976,641
976,642
u431812145
cpp
p03168
#include "bits/stdc++.h" #define ll long long #define inf 100005 #define mod 1000000007 using namespace std; vector<vector<ll>> g(inf); vector<ll> indgree(inf); vector<ll> dist(inf); bool visted[inf]; int main() { ll n; cin >> n; vector<double> p(n + 1); for (ll i = 1; i <= n; i++) { cin >> p[i]; } vector<vector<double>> dp(n + 1, vector<double>(n + 1)); dp[0][0] = 1; for (ll i = 1; i <= n; i++) { for (ll j = 0; j <= n; j++) { if (j == 0) { dp[i][j] = (1 - p[i]) * dp[i - 1][j]; } else { dp[i][j] = (p[i]) * dp[i - 1][j - 1] + (1 - p[i]) * dp[i - 1][j]; } } } double res = 0; for (ll i = n / 2 + 1; i <= n; i++) { res += dp[n][i]; } printf("%lf.10\n", res); return 0; }
#include "bits/stdc++.h" #define ll long long #define inf 100005 #define mod 1000000007 using namespace std; vector<vector<ll>> g(inf); vector<ll> indgree(inf); vector<ll> dist(inf); bool visted[inf]; int main() { ll n; cin >> n; vector<double> p(n + 1); for (ll i = 1; i <= n; i++) { cin >> p[i]; } vector<vector<double>> dp(n + 1, vector<double>(n + 1)); dp[0][0] = 1; for (ll i = 1; i <= n; i++) { for (ll j = 0; j <= n; j++) { if (j == 0) { dp[i][j] = (1 - p[i]) * dp[i - 1][j]; } else { dp[i][j] = (p[i]) * dp[i - 1][j - 1] + (1 - p[i]) * dp[i - 1][j]; } } } double res = 0; for (ll i = n / 2 + 1; i <= n; i++) { res += dp[n][i]; } printf("%.10lf\n", res); return 0; }
[ "literal.string.change", "call.arguments.change", "io.output.change" ]
976,645
976,646
u165543937
cpp
p03168
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; double arr[n + 1]; arr[0] = 0.0; for (int i = 1; i <= n; i++) cin >> arr[i]; double dp[n + 1][n + 1]; dp[0][0] = 1.0; // 0 heads lane ki probability whith 0 coins for (int i = 1; i <= n; i++) // number of coins { for (int j = 0; j <= n; j++) // no. of heads { if (j == 0) dp[i][j] = dp[i - 1][j] * (1 - arr[i]); else dp[i][j] = dp[i - 1][j] * (1 - arr[i]) + dp[i - 1][j - 1] * arr[i]; } } double ans = 0.0; for (int i = (n + 1) / 2; i <= n; i++) ans += dp[n][i]; // n coins with probability of getting i coins cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; double arr[n + 1]; arr[0] = 0.0; for (int i = 1; i <= n; i++) cin >> arr[i]; double dp[n + 1][n + 1]; dp[0][0] = 1.0; // 0 heads lane ki probability whith 0 coins for (int i = 1; i <= n; i++) // number of coins { for (int j = 0; j <= n; j++) // no. of heads { if (j == 0) dp[i][j] = dp[i - 1][j] * (1 - arr[i]); else dp[i][j] = dp[i - 1][j] * (1 - arr[i]) + dp[i - 1][j - 1] * arr[i]; } } double ans = 0.0; for (int i = (n + 1) / 2; i <= n; i++) ans += dp[n][i]; // n coins with probability of getting i coins cout << setprecision(10) << ans << endl; return 0; }
[ "io.output.change" ]
976,654
976,655
u733347296
cpp
p03168
// code.begin(); #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; #define pb push_back #define what_is(x) cerr << #x << " is " << x << endl; #define print(v) \ for (auto i : v) \ cout << i << " "; \ cout << endl; #define my_time \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define ll long long #define endl "\n" #define MOD 1000000007 const long long int INF = 1e18; #define mod 1000000007 #pragma GCC target("avx2") #pragma GCC optimization("O3") #pragma GCC optimization("unroll-loops") typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // find_by_order(x) // order_of_key(x) int power(int x, unsigned int y) { int res = 1; while (y > 0) { // if y is odd multiply with result if (y & 1) res = res * x; y = y >> 1; // y=y/2; x = x * x; } return res; } int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } ll max3(ll a, ll b, ll c) { return max(c, max(a, b)); } int min3(int a, int b, int c) { return min(a, min(b, c)); } int powermod(int x, int y, int p) { int res = 1; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res % p; } int logg(int a) { int x = 0; while (a > 1) { x++; a /= 2; } return x; } int modinv(int x) { return powermod(x, mod - 2, mod); } double dp[3100][3100]; double p[3100]; int main() { my_time; int t; t = 1; // cin>>t;int test=0; while (t--) { int a; scanf("%d", &a); for (int i = 0; i < a; i++) { scanf("%lf", p + i); } dp[0][0] = 1; for (int i = 1; i <= a; i++) { for (int j = 0; j <= i; j++) { if (j) dp[i][j] += dp[i - 1][j - 1] * p[i]; dp[i][j] += dp[i - 1][j] * (1 - p[i]); } } double ret = 0; for (int i = 0; i <= a; i++) { if (i > a - i) ret += dp[a][i]; } printf("%.10f", ret); } return 0; } // code.end();
// code.begin(); #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; #define pb push_back #define what_is(x) cerr << #x << " is " << x << endl; #define print(v) \ for (auto i : v) \ cout << i << " "; \ cout << endl; #define my_time \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define ll long long #define endl "\n" #define MOD 1000000007 const long long int INF = 1e18; #define mod 1000000007 #pragma GCC target("avx2") #pragma GCC optimization("O3") #pragma GCC optimization("unroll-loops") typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // find_by_order(x) // order_of_key(x) int power(int x, unsigned int y) { int res = 1; while (y > 0) { // if y is odd multiply with result if (y & 1) res = res * x; y = y >> 1; // y=y/2; x = x * x; } return res; } int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } ll max3(ll a, ll b, ll c) { return max(c, max(a, b)); } int min3(int a, int b, int c) { return min(a, min(b, c)); } int powermod(int x, int y, int p) { int res = 1; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res % p; } int logg(int a) { int x = 0; while (a > 1) { x++; a /= 2; } return x; } int modinv(int x) { return powermod(x, mod - 2, mod); } double dp[3100][3100]; double p[3100]; int main() { my_time; int t; t = 1; // cin>>t;int test=0; while (t--) { int a; scanf("%d", &a); for (int i = 0; i < a; i++) { scanf("%lf", p + i); } dp[0][0] = 1; for (int i = 1; i <= a; i++) { for (int j = 0; j <= i; j++) { if (j) dp[i][j] += dp[i - 1][j - 1] * p[i - 1]; dp[i][j] += dp[i - 1][j] * (1 - p[i - 1]); } } double ret = 0; for (int i = 0; i <= a; i++) { if (i > a - i) ret += dp[a][i]; } printf("%.10f", ret); } return 0; } // code.end();
[ "assignment.change" ]
976,665
976,666
u089014020
cpp
p03168
#include <bits/stdc++.h> #define ll long long using namespace std; double dp[3001][3001]; double solve(double p[], int i, int x) { if (x == 0) return 1; if (i == 0) return 0; if (dp[i][x] > -0.9) return dp[i][x]; return dp[i][x] = p[i] * solve(p, i - 1, x - 1) + (1 - p[i] * solve(p, i - 1, x)); } int main() { int n; cin >> n; memset(dp, -1, sizeof dp); double p[n]; for (int i = 0; i < n; i++) cin >> p[i]; cout << fixed << setprecision(10) << solve(p, n, n / 2 + 1) << endl; return 0; }
#include <bits/stdc++.h> #define ll long long using namespace std; double dp[3001][3001]; double solve(double p[], int i, int x) { if (x == 0) return 1; if (i == 0) return 0; if (dp[i][x] > -0.9) return dp[i][x]; return dp[i][x] = p[i] * solve(p, i - 1, x - 1) + (1 - p[i]) * solve(p, i - 1, x); } int main() { int n; cin >> n; memset(dp, -1, sizeof dp); double p[n + 1]; for (int i = 1; i <= n; i++) cin >> p[i]; cout << fixed << setprecision(10) << solve(p, n, n / 2 + 1) << endl; return 0; }
[ "function.return_value.change", "call.arguments.change", "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one", "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.operation.binary.cha...
976,667
976,668
u746113754
cpp
p03168
#include <bits/stdc++.h> #define fast \ ios_base::sync_with_stdio(0); \ cin.tie(NULL); \ cout.tie(NULL) #define f(i, a, b) for (i = a; i < b; i++) #define fr(i, a, b) for (i = a; i >= b; i--) #define endl '\n' #define ll long long int #define ff first #define ss second #define pb push_back #define mod 1000000007 using namespace std; int n, i, j; double p[3000], ans; double dp[3000][3005]; int main() { cin >> n; f(i, 0, n) cin >> p[i]; memset(dp, 0, sizeof dp); dp[0][0] = 1 - p[0]; dp[0][1] = p[0]; f(i, 1, n) { f(j, 0, i + 1) { dp[i][j] += (1 - p[i]) * dp[i - 1][j]; dp[i][j + 1] += p[i] * dp[i - 1][j]; } } /*f(i,0,n) { f(j,0,i+2) cout<<dp[i][j]<<' '; cout<<endl; }*/ f(i, n / 2 + 1, 3005) ans += dp[n - 1][i]; printf("%.10llf", ans); }
#include <bits/stdc++.h> #define fast \ ios_base::sync_with_stdio(0); \ cin.tie(NULL); \ cout.tie(NULL) #define f(i, a, b) for (i = a; i < b; i++) #define fr(i, a, b) for (i = a; i >= b; i--) #define endl '\n' #define ll long long int #define ff first #define ss second #define pb push_back #define mod 1000000007 using namespace std; int n, i, j; double p[3000], ans; double dp[3000][3005]; int main() { cin >> n; f(i, 0, n) cin >> p[i]; memset(dp, 0, sizeof dp); dp[0][0] = 1 - p[0]; dp[0][1] = p[0]; f(i, 1, n) { f(j, 0, i + 2) { dp[i][j] += (1 - p[i]) * dp[i - 1][j]; dp[i][j + 1] += p[i] * dp[i - 1][j]; } } /*f(i,0,n) { f(j,0,i+2) cout<<dp[i][j]<<' '; cout<<endl; }*/ f(i, n / 2 + 1, 3005) ans += dp[n - 1][i]; printf("%.10lf", ans); // cout<<ans; }
[ "literal.number.change", "call.arguments.change", "expression.operation.binary.change", "literal.string.change", "io.output.change" ]
976,671
976,672
u733037402
cpp
p03168
#include <bits/stdc++.h> using namespace std; vector<vector<double>> dp; double solve(double a[], int i, int x) { if (x == 0) return 1; if (i == 0) return 0; if (dp[i][x] >= -0.9) return dp[i][x]; return dp[i][x] = (a[i] * solve(a, i - 1, x - 1)) + ((1 - a[i]) * solve(a, i - 1, x)); } int main() { int n; cin >> n; double a[n + 1]; for (int i = 1; i <= n; i++) cin >> a[i]; dp.resize(n, vector<double>(n, -1)); cout << fixed << setprecision(10) << solve(a, n, (n + 1) / 2); return 0; }
#include <bits/stdc++.h> using namespace std; vector<vector<double>> dp; double solve(double a[], int i, int x) { if (x == 0) return 1; if (i == 0) return 0; if (dp[i][x] >= -0.9) return dp[i][x]; return dp[i][x] = (a[i] * solve(a, i - 1, x - 1)) + ((1 - a[i]) * solve(a, i - 1, x)); } int main() { int n; cin >> n; double a[n + 1]; for (int i = 1; i <= n; i++) cin >> a[i]; dp.resize(n + 1, vector<double>(n + 1, -1)); cout << fixed << setprecision(10) << solve(a, n, (n + 1) / 2); return 0; }
[ "expression.operation.binary.add" ]
976,675
976,676
u590450959
cpp
p03168
#include <bits/stdc++.h> #include <iostream> using namespace std; typedef long long int ll; void solve() { int n; cin >> n; vector<double> dp(n + 1); dp[0] = 1; for (int i = 0; i < n; i++) { double p; cin >> p; for (int j = i + 1; j >= 0; j--) { dp[j] = (j > 0 ? dp[j - 1] * p : 0) + dp[j] * (1 - p); } } double ans = 0; for (int i = (n + 1) / 2; i <= n; i++) ans += dp[i]; cout << ans; } int main() { // your code goes here // freopen("inptmp0.txt","r",stdin); int T; // cin>>T; T = 1; while (T--) { solve(); } return 0; }
#include <bits/stdc++.h> #include <iostream> using namespace std; typedef long long int ll; void solve() { int n; cin >> n; vector<double> dp(n + 1); dp[0] = 1; for (int i = 0; i < n; i++) { double p; cin >> p; for (int j = i + 1; j >= 0; j--) { dp[j] = (j > 0 ? dp[j - 1] * p : 0) + dp[j] * (1 - p); } } double ans = 0; for (int i = (n + 1) / 2; i <= n; i++) ans += dp[i]; cout << setprecision(10) << ans; } int main() { // your code goes here // freopen("inptmp0.txt","r",stdin); int T; // cin>>T; T = 1; while (T--) { solve(); } return 0; }
[ "io.output.change" ]
976,680
976,681
u633290196
cpp
p03168
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<float> v(n); for (int i = 0; i < n; i++) cin >> v[i]; vector<vector<float>> v1(n + 1, vector<float>(n + 1)); v1[0][0] = 1.0; for (int i = 1; i <= n; i++) { v1[i][0] = 0; } for (int i = 1; i <= n; i++) { v1[0][i] = (1.0 - v[i - 1]) * v1[0][i - 1]; } for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { v1[i][j] = ((1.0 - v[j - 1]) * v1[i][j - 1]) + (v1[i - 1][j - 1] * v[j - 1]); } } float ans = 0.0; for (int i = n; i >= (n + 1) / 2; i--) { ans += v1[i][n]; } cout << fixed << setprecision(11) << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<double> v(n); for (int i = 0; i < n; i++) cin >> v[i]; vector<vector<double>> v1(n + 1, vector<double>(n + 1)); v1[0][0] = 1.0; for (int i = 1; i <= n; i++) { v1[i][0] = 0; } for (int i = 1; i <= n; i++) { v1[0][i] = (1.0 - v[i - 1]) * v1[0][i - 1]; } for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { v1[i][j] = ((1.0 - v[j - 1]) * v1[i][j - 1]) + (v1[i - 1][j - 1] * v[j - 1]); } } double ans = 0.0; for (int i = n; i >= (n + 1) / 2; i--) { ans += v1[i][n]; } cout << fixed << setprecision(11) << ans << endl; return 0; }
[ "variable_declaration.type.primitive.change" ]
976,688
976,689
u486307811
cpp
p03168
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; double a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } double dp[n + 1][n + 1]; for (int i = 0; i <= n; i++) { for (int j = 0; j <= n; j++) { if (i == 0 && j == 0) { dp[i][j] = 1; } else if (i == 0 && j != 0) { dp[i][j] = 0; } else if (j == 0) { dp[i][j] = (1 - a[i - 1]) * dp[i - 1][j]; } else dp[i][j] = a[i - 1] * (dp[i - 1][j - 1]) + (1 - a[i - 1]) * dp[i - 1][j]; } } double ans = 0; for (int i = 1; i <= n; i++) { if (i > n - i) { ans = ans + dp[n][i]; } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; double a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } double dp[n + 1][n + 1]; for (int i = 0; i <= n; i++) { for (int j = 0; j <= n; j++) { if (i == 0 && j == 0) { dp[i][j] = 1; } else if (i == 0 && j != 0) { dp[i][j] = 0; } else if (j == 0) { dp[i][j] = (1 - a[i - 1]) * dp[i - 1][j]; } else dp[i][j] = a[i - 1] * (dp[i - 1][j - 1]) + (1 - a[i - 1]) * dp[i - 1][j]; } } double ans = 0; for (int i = 1; i <= n; i++) { if (i > n - i) { ans = ans + dp[n][i]; } } cout << setprecision(9) << ans << endl; }
[ "io.output.change" ]
976,712
976,713
u466076667
cpp
p03168
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; double p[n]; int i, j; for (i = 0; i < n; i++) cin >> p[i]; double dp[n + 1][n + 1]; for (i = 0; i <= n; i++) dp[0][i] = 0.0; dp[0][0] = 1.0; for (i = 1; i <= n; i++) dp[i][0] = dp[i - 1][0] * (1 - p[i - 1]); for (i = 1; i <= n; i++) { for (j = 1; j <= n; j++) dp[i][j] = ((1 - p[i - 1]) * dp[i - 1][j]) + (p[i - 1] * dp[i - 1][j - 1]); } double sum = 0; for (i = (n + 1) / 2; i <= n; i++) sum = sum + dp[n][i]; cout << sum; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; double p[n]; int i, j; for (i = 0; i < n; i++) cin >> p[i]; double dp[n + 1][n + 1]; for (i = 0; i <= n; i++) dp[0][i] = 0.0; dp[0][0] = 1.0; for (i = 1; i <= n; i++) dp[i][0] = dp[i - 1][0] * (1 - p[i - 1]); for (i = 1; i <= n; i++) { for (j = 1; j <= n; j++) dp[i][j] = ((1 - p[i - 1]) * dp[i - 1][j]) + (p[i - 1] * dp[i - 1][j - 1]); } double sum = 0; for (i = (n + 1) / 2; i <= n; i++) sum = sum + dp[n][i]; cout << setprecision(9) << sum; }
[ "io.output.change" ]
976,714
976,715
u483599072
cpp
p03168
#include <algorithm> #include <iostream> #include <map> #include <numeric> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; typedef long long int ll; typedef vector<ll> vll; typedef vector<char> vc; typedef vector<vc> vvc; typedef vector<vll> vvl; typedef pair<ll, ll> pll; typedef pair<string, ll> psl; typedef vector<psl> vpsl; typedef vector<pll> vpl; typedef unordered_set<ll> usl; typedef set<ll> sl; typedef unordered_map<ll, ll> uml; typedef map<ll, ll> ml; typedef vector<bool> vb; typedef vector<vb> vvb; typedef vector<string> vs; #define all(v) v.begin(), v.end() #define IOS \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); const ll inf = 1e9 + 7; const double pie = 3.14159265358979323846; const char nl = '\n'; template <typename Type> istream &operator>>(istream &in, vector<Type> &v) { ll n = v.size(); for (int i = 0; i < n; i++) in >> v[i]; return in; } template <typename Type> ostream &operator<<(ostream &out, vector<Type> &v) { for (auto value : v) out << value << " "; out << endl; return out; } void solve() { ll n; cin >> n; vector<float> p(n + 1); for (ll i = 1; i <= n; ++i) cin >> p[i]; vector<vector<float>> dp(n + 1, vector<float>(n + 1, 0.0)); dp[0][0] = 1.0; for (ll i = 1; i <= n; ++i) { for (ll j = 0; j <= i; ++j) { if (j == 0) dp[i][j] = (1.0 - p[i]) * dp[i - 1][j]; else dp[i][j] = (p[i] * dp[i - 1][j - 1]) + (1.0 - p[i]) * dp[i - 1][j]; } } // for (const auto& v : dp) // { // for (float i : v) // cout << i << ' '; // cout << nl; // } float ans = 0.0; for (ll j = 0; j <= n; ++j) { if (j > n - j) ans += dp[n][j]; } printf("%.10lf\n", ans); } int main() { IOS ll t; t = 1; // cin >> t; while (t--) { solve(); } return 0; }
#include <algorithm> #include <iostream> #include <map> #include <numeric> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; typedef long long int ll; typedef vector<ll> vll; typedef vector<char> vc; typedef vector<vc> vvc; typedef vector<vll> vvl; typedef pair<ll, ll> pll; typedef pair<string, ll> psl; typedef vector<psl> vpsl; typedef vector<pll> vpl; typedef unordered_set<ll> usl; typedef set<ll> sl; typedef unordered_map<ll, ll> uml; typedef map<ll, ll> ml; typedef vector<bool> vb; typedef vector<vb> vvb; typedef vector<string> vs; #define all(v) v.begin(), v.end() #define IOS \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); const ll inf = 1e9 + 7; const double pie = 3.14159265358979323846; const char nl = '\n'; template <typename Type> istream &operator>>(istream &in, vector<Type> &v) { ll n = v.size(); for (int i = 0; i < n; i++) in >> v[i]; return in; } template <typename Type> ostream &operator<<(ostream &out, vector<Type> &v) { for (auto value : v) out << value << " "; out << endl; return out; } void solve() { ll n; cin >> n; vector<double> p(n + 1); for (ll i = 1; i <= n; ++i) cin >> p[i]; vector<vector<double>> dp(n + 1, vector<double>(n + 1, 0.0)); dp[0][0] = 1.0; for (ll i = 1; i <= n; ++i) { for (ll j = 0; j <= i; ++j) { if (j == 0) dp[i][j] = (1.0 - p[i]) * dp[i - 1][j]; else dp[i][j] = (p[i] * dp[i - 1][j - 1]) + (1.0 - p[i]) * dp[i - 1][j]; } } // for (const auto& v : dp) // { // for (float i : v) // cout << i << ' '; // cout << nl; // } double ans = 0.0; for (ll j = 0; j <= n; ++j) { if (j > n - j) ans += dp[n][j]; } printf("%.10f\n", ans); } int main() { IOS ll t; t = 1; // cin >> t; while (t--) { solve(); } return 0; }
[ "variable_declaration.type.primitive.change", "literal.string.change", "call.arguments.change", "io.output.change" ]
976,716
976,717
u361568750
cpp
p03168
#include <algorithm> #include <iostream> #include <map> #include <numeric> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; typedef long long int ll; typedef vector<ll> vll; typedef vector<char> vc; typedef vector<vc> vvc; typedef vector<vll> vvl; typedef pair<ll, ll> pll; typedef pair<string, ll> psl; typedef vector<psl> vpsl; typedef vector<pll> vpl; typedef unordered_set<ll> usl; typedef set<ll> sl; typedef unordered_map<ll, ll> uml; typedef map<ll, ll> ml; typedef vector<bool> vb; typedef vector<vb> vvb; typedef vector<string> vs; #define all(v) v.begin(), v.end() #define IOS \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); const ll inf = 1e9 + 7; const double pie = 3.14159265358979323846; const char nl = '\n'; template <typename Type> istream &operator>>(istream &in, vector<Type> &v) { ll n = v.size(); for (int i = 0; i < n; i++) in >> v[i]; return in; } template <typename Type> ostream &operator<<(ostream &out, vector<Type> &v) { for (auto value : v) out << value << " "; out << endl; return out; } void solve() { ll n; cin >> n; vector<float> p(n + 1); for (ll i = 1; i <= n; ++i) cin >> p[i]; vector<vector<float>> dp(n + 1, vector<float>(n + 1, 0.0)); dp[0][0] = 1.0; for (ll i = 1; i <= n; ++i) { for (ll j = 0; j <= i; ++j) { if (j == 0) dp[i][j] = (1.0 - p[i]) * dp[i - 1][j]; else dp[i][j] = (p[i] * dp[i - 1][j - 1]) + (1.0 - p[i]) * dp[i - 1][j]; } } // for (const auto& v : dp) // { // for (float i : v) // cout << i << ' '; // cout << nl; // } float ans = 0.0; for (ll j = 0; j <= n; ++j) { if (j > n - j) ans += dp[n][j]; } printf("%.10lf\n", ans); } int main() { IOS ll t; t = 1; // cin >> t; while (t--) { solve(); } return 0; }
#include <algorithm> #include <iostream> #include <map> #include <numeric> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; typedef long long int ll; typedef vector<ll> vll; typedef vector<char> vc; typedef vector<vc> vvc; typedef vector<vll> vvl; typedef pair<ll, ll> pll; typedef pair<string, ll> psl; typedef vector<psl> vpsl; typedef vector<pll> vpl; typedef unordered_set<ll> usl; typedef set<ll> sl; typedef unordered_map<ll, ll> uml; typedef map<ll, ll> ml; typedef vector<bool> vb; typedef vector<vb> vvb; typedef vector<string> vs; #define all(v) v.begin(), v.end() #define IOS \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); const ll inf = 1e9 + 7; const double pie = 3.14159265358979323846; const char nl = '\n'; template <typename Type> istream &operator>>(istream &in, vector<Type> &v) { ll n = v.size(); for (int i = 0; i < n; i++) in >> v[i]; return in; } template <typename Type> ostream &operator<<(ostream &out, vector<Type> &v) { for (auto value : v) out << value << " "; out << endl; return out; } void solve() { ll n; cin >> n; vector<double> p(n + 1); for (ll i = 1; i <= n; ++i) cin >> p[i]; vector<vector<double>> dp(n + 1, vector<double>(n + 1, 0.0)); dp[0][0] = 1.0; for (ll i = 1; i <= n; ++i) { for (ll j = 0; j <= i; ++j) { if (j == 0) dp[i][j] = (1.0 - p[i]) * dp[i - 1][j]; else dp[i][j] = (p[i] * dp[i - 1][j - 1]) + (1.0 - p[i]) * dp[i - 1][j]; } } // for (const auto& v : dp) // { // for (float i : v) // cout << i << ' '; // cout << nl; // } double ans = 0.0; for (ll j = 0; j <= n; ++j) { if (j > n - j) ans += dp[n][j]; } printf("%.10lf\n", ans); } int main() { IOS ll t; t = 1; // cin >> t; while (t--) { solve(); } return 0; }
[ "variable_declaration.type.primitive.change" ]
976,716
976,718
u361568750
cpp
p03168
#include <bits/stdc++.h> using namespace std; #define ll long long #define forr(i, n) for (ll i = 0; i < n; i++) #define f(i, a, b) for (int i = a; i < b; i++) #define F first #define S second #define pb push_back #define mp make_pair #define vi vector<ll> #define endl '\n' #define ce(ele) cout << ele << ' ' #define cs(ele) cout << ele << '\n' #define CASE(t) \ ll t; \ cin >> t; \ while (t--) #define sor(v) sort(v.begin(), v.end()) #define rev(v) reverse(v.begin(), v.end()) ll power(ll a, ll b) { ll r = 1; while (b--) r *= a; return r; } const ll INF = 1e17L + 5; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector<vector<long double>> dp(n, vector<long double>(n + 1, 0.0)); vector<long double> p(n); f(i, 0, n) cin >> p[i]; dp[0][0] = (1 - p[0]) * 1.0; dp[0][1] = p[0]; f(i, 0, n - 1) { f(j, 0, i + 2) { dp[i + 1][j] += dp[i][j] * (1 - p[i]) * 1.0; dp[i + 1][j + 1] += dp[i][j] * p[i] * 1.0; } } long double ans = 0; for (int h = n / 2 + 1; h <= n; h++) { ans += dp[n - 1][h]; } cout << fixed << setprecision(9) << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define ll long long #define forr(i, n) for (ll i = 0; i < n; i++) #define f(i, a, b) for (int i = a; i < b; i++) #define F first #define S second #define pb push_back #define mp make_pair #define vi vector<ll> #define endl '\n' #define ce(ele) cout << ele << ' ' #define cs(ele) cout << ele << '\n' #define CASE(t) \ ll t; \ cin >> t; \ while (t--) #define sor(v) sort(v.begin(), v.end()) #define rev(v) reverse(v.begin(), v.end()) ll power(ll a, ll b) { ll r = 1; while (b--) r *= a; return r; } const ll INF = 1e17L + 5; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector<vector<long double>> dp(n, vector<long double>(n + 1, 0.0)); vector<long double> p(n); f(i, 0, n) cin >> p[i]; dp[0][0] = (1 - p[0]) * 1.0; dp[0][1] = p[0]; f(i, 0, n - 1) { f(j, 0, i + 2) { dp[i + 1][j] += dp[i][j] * (1 - p[i + 1]) * 1.0; dp[i + 1][j + 1] += dp[i][j] * p[i + 1] * 1.0; } } long double ans = 0; for (int h = n / 2 + 1; h <= n; h++) { ans += dp[n - 1][h]; } cout << fixed << setprecision(9) << ans << endl; }
[ "assignment.change" ]
976,724
976,725
u987274574
cpp
p03168
#include <bits/stdc++.h> using namespace std; //#define ll long long; double a[3000][3000] = {0}; int main() { int n, i, j, l; double k; cin >> n; double pro[n]; for (i = 0; i < n; i++) { cin >> pro[i]; if (i == 0) a[0][i] = pro[i]; else { a[0][i] = pro[i] * a[0][i - 1]; } } a[1][0] = 1 - pro[0]; for (i = 1; i <= n; i++) { for (j = 1; j < n; j++) { a[i][j] = (a[i - 1][j - 1] * ((double)1 - pro[j])) + (a[i][j - 1] * pro[j]); // cout<<a[i-1][j-1]<<" "<<1-pro[j]<<" | "<<a[i][j-1]<<" "<<pro[j]<<" // |||||| "; } // cout<<endl; } k = 0; for (i = 0; (n - i) > i; i++) { // cout<<a[i][n-1]<<" "; k += a[i][n - 1]; } cout << k; }
#include <bits/stdc++.h> using namespace std; //#define ll long long; double a[3000][3000] = {0}; int main() { int n, i, j, l; double k; cin >> n; double pro[n]; for (i = 0; i < n; i++) { cin >> pro[i]; if (i == 0) a[0][i] = pro[i]; else { a[0][i] = pro[i] * a[0][i - 1]; } } a[1][0] = 1 - pro[0]; for (i = 1; i <= n; i++) { for (j = 1; j < n; j++) { a[i][j] = (a[i - 1][j - 1] * ((double)1 - pro[j])) + (a[i][j - 1] * pro[j]); // cout<<a[i-1][j-1]<<" "<<1-pro[j]<<" | "<<a[i][j-1]<<" "<<pro[j]<<" // |||||| "; } // cout<<endl; } k = 0; for (i = 0; (n - i) > i; i++) { // cout<<a[i][n-1]<<" "; k += a[i][n - 1]; } cout << setprecision(15) << k; }
[ "io.output.change" ]
976,735
976,736
u222821788
cpp
p03168
#include <bits/stdc++.h> using namespace std; double dp[3001][3001] = {}; double solve(double *arr, int n, int head) { if (head == 0) return 1; if (n == 0) return 0; if (dp[n][head] != -1) return dp[n][head]; return dp[n][head] = (arr[n]) * solve(arr, n - 1, head - 1) + (1 - arr[n]) * solve(arr, n - 1, head); } int main() { int n; cin >> n; double arr[n + 1]; for (int i = 1; i <= n; i++) cin >> arr[i]; memset(dp, -1, sizeof dp); cout << fixed << setprecision(11) << solve(arr, n, (n + 1) / 2); }
#include <bits/stdc++.h> using namespace std; double dp[3001][3001] = {}; double solve(double *arr, int n, int head) { if (head == 0) return 1; if (n == 0) return 0; if (dp[n][head] > -1) return dp[n][head]; return dp[n][head] = (arr[n]) * solve(arr, n - 1, head - 1) + (1 - arr[n]) * solve(arr, n - 1, head); } int main() { int n; cin >> n; double arr[n + 1]; for (int i = 1; i <= n; i++) cin >> arr[i]; memset(dp, -1, sizeof dp); cout << fixed << setprecision(11) << solve(arr, n, (n + 1) / 2); }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
976,737
976,738
u659210268
cpp
p03168
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long double p[n + 1], dp[n + 1][n + 1], s = 0.0; for (int i = 1; i <= n; i++) cin >> p[i]; dp[0][0] = 1.0; for (int i = 1; i <= n; i++) dp[i][0] = dp[i - 1][0] * (1.0 - p[i]); for (int i = 1; i <= n; i++) dp[i][i] = dp[i - 1][i - 1] * p[i]; for (int i = 1; i <= n; i++) for (int j = 1; j <= i - 1; j++) dp[i][j] = (dp[i - 1][j] * (1.0 - p[i]) + dp[i - 1][j - 1] * p[i]); for (int i = (n + 1) / 2; i <= n; i++) s += dp[n][i]; cout << s; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long double p[n + 1], dp[n + 1][n + 1], s = 0.0; for (int i = 1; i <= n; i++) cin >> p[i]; dp[0][0] = 1.0; for (int i = 1; i <= n; i++) dp[i][0] = dp[i - 1][0] * (1.0 - p[i]); for (int i = 1; i <= n; i++) dp[i][i] = dp[i - 1][i - 1] * p[i]; for (int i = 1; i <= n; i++) for (int j = 1; j <= i - 1; j++) dp[i][j] = (dp[i - 1][j] * (1.0 - p[i]) + dp[i - 1][j - 1] * p[i]); for (int i = (n + 1) / 2; i <= n; i++) s += dp[n][i]; cout << setprecision(10) << s; }
[ "io.output.change" ]
976,741
976,742
u659211619
cpp
p03168
#include <bits/stdc++.h> #define ll long long int using namespace std; const int mod = 1e9 + 7; int main() { //#ifndef ONLINE_JUDGE // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); //#endif int n; cin >> n; vector<long double> in(n); for (int i = 0; i < n; i++) cin >> in[i]; vector<long double> dp(n + 1); // dp[i] is the probability with i heads dp[0] = 1; for (int i = 0; i < n; i++) { for (int j = i + 1; j >= 0; j--) { dp[j] = (j == 0 ? 0 : dp[j - 1] * in[i]) + dp[j] * (1 - in[i]); } } long double ans = 0; for (int i = 0; i < n; i++) { if (i > n - i) ans += dp[i]; } cout << setprecision(10) << ans << '\n'; return 0; }
#include <bits/stdc++.h> #define ll long long int using namespace std; const int mod = 1e9 + 7; int main() { //#ifndef ONLINE_JUDGE // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); //#endif int n; cin >> n; vector<long double> in(n); for (int i = 0; i < n; i++) cin >> in[i]; vector<long double> dp(n + 1); // dp[i] is the probability with i heads dp[0] = 1; for (int i = 0; i < n; i++) { for (int j = i + 1; j >= 0; j--) { dp[j] = (j == 0 ? 0 : dp[j - 1] * in[i]) + dp[j] * (1 - in[i]); } } long double ans = 0; for (int i = 0; i <= n; i++) { if (i > n - i) ans += dp[i]; } cout << setprecision(10) << ans << '\n'; return 0; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
976,745
976,746
u064544517
cpp
p03168
#include <bits/stdc++.h> using namespace std; // DEFINE and // TYPEDEF-------------------------------------------------------------- // For actual content check from line 85 #define FORG(i, a, n) \ for (lld i = (lld)a; a < n ? i < (lld)n : (lld)n < i; \ a < n ? ++i : --i) // for - general #define FORZ(i, n) for (lld i = 0; i < (lld)n; ++i) // for - zero #define FORGI(i, a, n, inc) \ for (lld i = (lld)a; a < n ? i < (lld)n : (lld)n < i; \ a < n ? i += inc : i -= inc) // for - general incremental #define FORZI(i, n, inc) \ for (lld i = 0; i < (lld)n; i += inc) // for - zero incremental #define SPEEDUP \ ios_base::sync_with_stdio(0); \ cin.tie(NULL); \ cout.tie(NULL); #define MEM(a, val) memset(a, val, sizeof(a)); #define all(m) m.begin(), m.end() #define sz(m) (lld) m.size() #define st first #define nd second #define pb push_back #define DEC(x) fixed << setprecision(x) typedef long long int lld; typedef unsigned long long int ulld; template <typename T1, typename T2> istream &operator>>(istream &in, pair<T1, T2> &a) { in >> a.st >> a.nd; return in; } template <typename T1, typename T2> ostream &operator<<(ostream &out, pair<T1, T2> a) { out << a.st << " " << a.nd; return out; } template <typename T, typename T1> T amax(T &a, T1 b) { if (b > a) a = b; return a; } template <typename T, typename T1> T amin(T &a, T1 b) { if (b < a) a = b; return a; } // DEBUGGER------------------------------------------------------------------------ // #define DEBUG(x) cerr<<(#x)<<" is "<<(x)<<"\n" //to debug values of variables #define DEBUGON #define ZINDA \ cerr << "\nIdhar-ich hai apun!!\n"; // to debug if code reached that point #ifdef DEBUGON vector<string> vec_splitter(string s) { for (char &c : s) c = c == ',' ? ' ' : c; stringstream ss; ss << s; vector<string> res; for (string z; ss >> z; res.push_back(z)) ; return res; } void debug_out(vector<string> __attribute__((unused)) args, __attribute__((unused)) int idx, __attribute__((unused)) int LINE_NUM) { cerr << endl; } template <typename Head, typename... Tail> void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) { if (idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << "): "; stringstream ss; ss << H; cerr << args[idx] << " = " << ss.str(); debug_out(args, idx + 1, LINE_NUM, T...); } #define debug(...) \ debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__); #define DEBUG(...) \ debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__); #else #define debug(...) 320; #define DEBUG(...) 320; #endif lld power(lld b, lld e) { assert(e >= 0); if (e == 0) return 1; if (e % 2 == 1) return b * power(b * b, (e - 1) / 2); else return power(b * b, e / 2); } lld power(lld b, lld e, lld m) { assert(e >= 0); if (e == 0) return 1; if (e % 2 == 1) return b * power(((b % m) * (b % m)) % m, (e - 1) / 2, m) % m; else return power(((b % m) * (b % m)) % m, e / 2, m) % m; } #define endl '\n' const long double pi = acos(-1); constexpr int mod = 1e9 + 7; // 1000000007 // endl : changed to '\n', to flush comment that definition //-------------------------------------------------------------------------------- long double dp[3007][3007]; void swagWaalaFunction() { lld n; cin >> n; long double ar[n]; FORZ(i, n) cin >> ar[i]; long double ans = 0; MEM(dp, 0); dp[0][0] = 1 - ar[0]; dp[0][1] = ar[0]; FORG(i, 1, n) FORZ(j, 3000) { dp[i][j] += dp[i - 1][j] * (1 - ar[i]); if (j) dp[i][j] += dp[i - 1][j - 1] * ar[i]; } FORG(i, n / 2 + 1, 3000) ans += dp[n - 1][i]; cout << ans; return; } int main() { SPEEDUP; lld tc = 1; // cin>>tc; #ifdef PRIMES sieve(); #endif #ifdef CHOOSE nCrModInit(); #endif FORZ(i, tc) { // cout<<"Case #"<<i+1<<": "; swagWaalaFunction(); } // cerr<<"\n"<<timeKyaHorhaH; return 0; }
#include <bits/stdc++.h> using namespace std; // DEFINE and // TYPEDEF-------------------------------------------------------------- // For actual content check from line 85 #define FORG(i, a, n) \ for (lld i = (lld)a; a < n ? i < (lld)n : (lld)n < i; \ a < n ? ++i : --i) // for - general #define FORZ(i, n) for (lld i = 0; i < (lld)n; ++i) // for - zero #define FORGI(i, a, n, inc) \ for (lld i = (lld)a; a < n ? i < (lld)n : (lld)n < i; \ a < n ? i += inc : i -= inc) // for - general incremental #define FORZI(i, n, inc) \ for (lld i = 0; i < (lld)n; i += inc) // for - zero incremental #define SPEEDUP \ ios_base::sync_with_stdio(0); \ cin.tie(NULL); \ cout.tie(NULL); #define MEM(a, val) memset(a, val, sizeof(a)); #define all(m) m.begin(), m.end() #define sz(m) (lld) m.size() #define st first #define nd second #define pb push_back #define DEC(x) fixed << setprecision(x) typedef long long int lld; typedef unsigned long long int ulld; template <typename T1, typename T2> istream &operator>>(istream &in, pair<T1, T2> &a) { in >> a.st >> a.nd; return in; } template <typename T1, typename T2> ostream &operator<<(ostream &out, pair<T1, T2> a) { out << a.st << " " << a.nd; return out; } template <typename T, typename T1> T amax(T &a, T1 b) { if (b > a) a = b; return a; } template <typename T, typename T1> T amin(T &a, T1 b) { if (b < a) a = b; return a; } // DEBUGGER------------------------------------------------------------------------ // #define DEBUG(x) cerr<<(#x)<<" is "<<(x)<<"\n" //to debug values of variables #define DEBUGON #define ZINDA \ cerr << "\nIdhar-ich hai apun!!\n"; // to debug if code reached that point #ifdef DEBUGON vector<string> vec_splitter(string s) { for (char &c : s) c = c == ',' ? ' ' : c; stringstream ss; ss << s; vector<string> res; for (string z; ss >> z; res.push_back(z)) ; return res; } void debug_out(vector<string> __attribute__((unused)) args, __attribute__((unused)) int idx, __attribute__((unused)) int LINE_NUM) { cerr << endl; } template <typename Head, typename... Tail> void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) { if (idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << "): "; stringstream ss; ss << H; cerr << args[idx] << " = " << ss.str(); debug_out(args, idx + 1, LINE_NUM, T...); } #define debug(...) \ debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__); #define DEBUG(...) \ debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__); #else #define debug(...) 320; #define DEBUG(...) 320; #endif lld power(lld b, lld e) { assert(e >= 0); if (e == 0) return 1; if (e % 2 == 1) return b * power(b * b, (e - 1) / 2); else return power(b * b, e / 2); } lld power(lld b, lld e, lld m) { assert(e >= 0); if (e == 0) return 1; if (e % 2 == 1) return b * power(((b % m) * (b % m)) % m, (e - 1) / 2, m) % m; else return power(((b % m) * (b % m)) % m, e / 2, m) % m; } #define endl '\n' const long double pi = acos(-1); constexpr int mod = 1e9 + 7; // 1000000007 // endl : changed to '\n', to flush comment that definition //-------------------------------------------------------------------------------- long double dp[3007][3007]; void swagWaalaFunction() { lld n; cin >> n; long double ar[n]; FORZ(i, n) cin >> ar[i]; long double ans = 0; MEM(dp, 0); dp[0][0] = 1 - ar[0]; dp[0][1] = ar[0]; FORG(i, 1, n) FORZ(j, 3000) { dp[i][j] += dp[i - 1][j] * (1 - ar[i]); if (j) dp[i][j] += dp[i - 1][j - 1] * ar[i]; } FORG(i, n / 2 + 1, 3000) ans += dp[n - 1][i]; cout << DEC(10) << ans; return; } int main() { SPEEDUP; lld tc = 1; // cin>>tc; #ifdef PRIMES sieve(); #endif #ifdef CHOOSE nCrModInit(); #endif FORZ(i, tc) { // cout<<"Case #"<<i+1<<": "; swagWaalaFunction(); } // cerr<<"\n"<<timeKyaHorhaH; return 0; }
[ "io.output.change" ]
976,752
976,753
u531151228
cpp
p03168
#include <bits/stdc++.h> using namespace std; #define int long long #define Int int32_t #define all(c) c.begin(), c.end() #define FAST ios_base::sync_with_stdio(false), cin.tie(NULL); #define pii pair<int, int> #define pb push_back #define F first #define S second #define endl "\n" #define bitcnt(n) __builtin_popcountll(n) #define setpre(n) cout << fixed << setprecision(n) #define tr(c) \ for (const auto &x : c) \ cout << x << " "; \ cout << "\n"; #define ol(c, s, e) \ for (int pos = s; pos < e; pos++) \ cout << c[pos] << " "; \ cout << "\n"; #define PI acos(-1LL) const int M = 1000000007; const int N = 2e5 + 5; const long long INF = 1e9 + 12; vector<double> v; vector<vector<double>> dp; int n; void solve() { cin >> n; v.resize(n + 1); dp.resize(n + 1, vector<double>(n + 1, 0)); for (int i = 1; i <= n; i++) { cin >> v[i]; } for (int i = 1; i <= n; i++) dp[0][i] = 0; dp[0][0] = 1; double ans = 0.0; for (int i = 1; i <= n; i++) { for (int j = 0; j <= n; j++) { dp[i][j] = (j > 0 ? dp[i - 1][j - 1] * v[i] : 0) + dp[i - 1][j] * (1.0 - v[i]); } } for (int j = (n + 1) / 2; j <= n; j++) { ans += dp[n][j]; } cout << ans; } signed main() { FAST int tc = 1; // TODO: check for tc // cin >> tc; for (int t = 1; t <= tc; t++) { solve(); } }
#include <bits/stdc++.h> using namespace std; #define int long long #define Int int32_t #define all(c) c.begin(), c.end() #define FAST ios_base::sync_with_stdio(false), cin.tie(NULL); #define pii pair<int, int> #define pb push_back #define F first #define S second #define endl "\n" #define bitcnt(n) __builtin_popcountll(n) #define setpre(n) cout << fixed << setprecision(n) #define tr(c) \ for (const auto &x : c) \ cout << x << " "; \ cout << "\n"; #define ol(c, s, e) \ for (int pos = s; pos < e; pos++) \ cout << c[pos] << " "; \ cout << "\n"; #define PI acos(-1LL) const int M = 1000000007; const int N = 2e5 + 5; const long long INF = 1e9 + 12; vector<double> v; vector<vector<double>> dp; int n; void solve() { cin >> n; v.resize(n + 1); dp.resize(n + 1, vector<double>(n + 1, 0)); for (int i = 1; i <= n; i++) { cin >> v[i]; } for (int i = 1; i <= n; i++) dp[0][i] = 0; dp[0][0] = 1; double ans = 0.0; for (int i = 1; i <= n; i++) { for (int j = 0; j <= n; j++) { dp[i][j] = (j > 0 ? dp[i - 1][j - 1] * v[i] : 0) + dp[i - 1][j] * (1.0 - v[i]); } } for (int j = (n + 1) / 2; j <= n; j++) { ans += dp[n][j]; } setpre(12) << ans; } signed main() { FAST int tc = 1; // TODO: check for tc // cin >> tc; for (int t = 1; t <= tc; t++) { solve(); } }
[ "expression.operation.binary.change", "call.arguments.add" ]
976,761
976,762
u272870143
cpp
p03168
#include <bits/stdc++.h> using namespace std; vector<double> p(3000, 0); int n; vector<vector<double>> dp(3000, vector<double>(3000, -1)); double totalP(int i, int cnt) { if (i == n) { if (cnt > n / 2) return 1; return 0; } if (dp[i][cnt] != -1) return dp[i][cnt]; else { dp[i][cnt] = totalP(i + 1, cnt + 1) * p[i] + totalP(i + 1, cnt) * (1 - p[i]); } return dp[i][cnt]; } int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> p[i]; } if (n == 1) { cout << p[0]; } else { cout << totalP(0, 0); } return 0; }
#include <bits/stdc++.h> using namespace std; vector<double> p(3000, 0); int n; vector<vector<double>> dp(3000, vector<double>(3000, -1)); double totalP(int i, int cnt) { if (i == n) { if (cnt > n / 2) return 1; return 0; } if (dp[i][cnt] != -1) return dp[i][cnt]; else { dp[i][cnt] = totalP(i + 1, cnt + 1) * p[i] + totalP(i + 1, cnt) * (1 - p[i]); } return dp[i][cnt]; } int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> p[i]; } if (n == 1) { cout << p[0]; } else { cout << setprecision(10) << totalP(0, 0); } return 0; }
[ "io.output.change" ]
976,769
976,770
u061594873
cpp
p03168
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define uu unsigned #define io \ ios_base::sync_with_stdio(false); \ cin.tie(NULL) #define MOD 1000000007 #define pl pair<ll, ll> #define mkp make_pair #define ss second #define ff first #define mit(a, b) map<a, b>::iterator #define sit(a) set<a>::iterator #define vi vector<int> #define vl vector<ll> #define pb push_back //#define printf __mingw_printf #define printcas cout << "Case " << cas << ": " #define _ continue; #define endl '\n' #define __ \ cout << endl; \ continue; const ll oo = (1ll << 60); int gi() { int x = 0, w = 1; char ch = getchar(); while ((ch < '0' || ch > '9') && ch != '-') ch = getchar(); if (ch == '-') w = 0, ch = getchar(); while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar(); return w ? x : -x; } int main() { io; // string hudai(1000000,'a'); int T = 1; // T=gi(); for (int cas = 1; cas <= T; cas++) { ll n = gi(), i, j; double ph, sum = 0.0; vector<double> dp(n + 5); dp[0] = 1; for (i = 1; i <= n; i++) { cin >> ph; for (j = i; j >= 0; j--) { dp[j] = (!j ? 0 : dp[j - 1] * ph) + dp[j] * (1.0 - ph); } } for (i = (n >> 1) + 1; i <= n; i++) sum += dp[i]; printf("%.10lf\n", sum); } return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define uu unsigned #define io \ ios_base::sync_with_stdio(false); \ cin.tie(NULL) #define MOD 1000000007 #define pl pair<ll, ll> #define mkp make_pair #define ss second #define ff first #define mit(a, b) map<a, b>::iterator #define sit(a) set<a>::iterator #define vi vector<int> #define vl vector<ll> #define pb push_back //#define printf __mingw_printf #define printcas cout << "Case " << cas << ": " #define _ continue; #define endl '\n' #define __ \ cout << endl; \ continue; const ll oo = (1ll << 60); int gi() { int x = 0, w = 1; char ch = getchar(); while ((ch < '0' || ch > '9') && ch != '-') ch = getchar(); if (ch == '-') w = 0, ch = getchar(); while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar(); return w ? x : -x; } int main() { // io; // string hudai(1000000,'a'); int T = 1; // T=gi(); for (int cas = 1; cas <= T; cas++) { ll n = gi(), i, j; double ph, sum = 0.0; vector<double> dp(n + 5); dp[0] = 1; for (i = 1; i <= n; i++) { cin >> ph; for (j = i; j >= 0; j--) { dp[j] = (!j ? 0 : dp[j - 1] * ph) + dp[j] * (1.0 - ph); } } for (i = (n >> 1) + 1; i <= n; i++) sum += dp[i]; printf("%.10lf\n", sum); } return 0; }
[]
976,779
976,780
u652421746
cpp
p03168
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define uu unsigned #define io \ ios_base::sync_with_stdio(false); \ cin.tie(NULL) #define MOD 1000000007 #define pl pair<ll, ll> #define mkp make_pair #define ss second #define ff first #define mit(a, b) map<a, b>::iterator #define sit(a) set<a>::iterator #define vi vector<int> #define vl vector<ll> #define pb push_back //#define printf __mingw_printf #define printcas cout << "Case " << cas << ": " #define _ continue; #define endl '\n' #define __ \ cout << endl; \ continue; const ll oo = (1ll << 60); int gi() { int x = 0, w = 1; char ch = getchar(); while ((ch < '0' || ch > '9') && ch != '-') ch = getchar(); if (ch == '-') w = 0, ch = getchar(); while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar(); return w ? x : -x; } int main() { io; // string hudai(1000000,'a'); int T = 1; // T=gi(); for (int cas = 1; cas <= T; cas++) { ll n = gi(), i, j; double ph, sum = 0.0; vector<double> dp(n + 5); dp[0] = 1; for (i = 1; i <= n; i++) { cin >> ph; for (j = i; j >= 0; j--) { dp[j] = (!j ? 0 : dp[j - 1] * ph) + dp[j] * (1.0 - ph); } } for (i = (n >> 1) + 1; i <= n; i++) sum += dp[i]; printf("%.10lf", sum); } return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define uu unsigned #define io \ ios_base::sync_with_stdio(false); \ cin.tie(NULL) #define MOD 1000000007 #define pl pair<ll, ll> #define mkp make_pair #define ss second #define ff first #define mit(a, b) map<a, b>::iterator #define sit(a) set<a>::iterator #define vi vector<int> #define vl vector<ll> #define pb push_back //#define printf __mingw_printf #define printcas cout << "Case " << cas << ": " #define _ continue; #define endl '\n' #define __ \ cout << endl; \ continue; const ll oo = (1ll << 60); int gi() { int x = 0, w = 1; char ch = getchar(); while ((ch < '0' || ch > '9') && ch != '-') ch = getchar(); if (ch == '-') w = 0, ch = getchar(); while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar(); return w ? x : -x; } int main() { // io; // string hudai(1000000,'a'); int T = 1; // T=gi(); for (int cas = 1; cas <= T; cas++) { ll n = gi(), i, j; double ph, sum = 0.0; vector<double> dp(n + 5); dp[0] = 1; for (i = 1; i <= n; i++) { cin >> ph; for (j = i; j >= 0; j--) { dp[j] = (!j ? 0 : dp[j - 1] * ph) + dp[j] * (1.0 - ph); } } for (i = (n >> 1) + 1; i <= n; i++) sum += dp[i]; printf("%.10lf\n", sum); } return 0; }
[ "literal.string.change", "call.arguments.change", "io.output.change", "io.output.newline.add" ]
976,781
976,780
u652421746
cpp
p03168
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define uu unsigned #define io \ ios_base::sync_with_stdio(false); \ cin.tie(NULL) #define MOD 1000000007 #define pl pair<ll, ll> #define mkp make_pair #define ss second #define ff first #define mit(a, b) map<a, b>::iterator #define sit(a) set<a>::iterator #define vi vector<int> #define vl vector<ll> #define pb push_back //#define printf __mingw_printf #define printcas cout << "Case " << cas << ": " #define _ continue; #define endl '\n' #define __ \ cout << endl; \ continue; const ll oo = (1ll << 60); int gi() { int x = 0, w = 1; char ch = getchar(); while ((ch < '0' || ch > '9') && ch != '-') ch = getchar(); if (ch == '-') w = 0, ch = getchar(); while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar(); return w ? x : -x; } int main() { io; // string hudai(1000000,'a'); int T = 1; // T=gi(); for (int cas = 1; cas <= T; cas++) { ll n = gi(), i, j; double ph, sum = 0.0; vector<double> dp(n + 5); dp[0] = 1; for (i = 1; i <= n; i++) { cin >> ph; for (j = i; j >= 0; j--) { dp[j] = (!j ? 0 : dp[j - 1] * ph) + dp[j] * (1.0 - ph); } } for (i = (n >> 1) + 1; i <= n; i++) sum += dp[i]; printf("%.11lf", sum); } return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define uu unsigned #define io \ ios_base::sync_with_stdio(false); \ cin.tie(NULL) #define MOD 1000000007 #define pl pair<ll, ll> #define mkp make_pair #define ss second #define ff first #define mit(a, b) map<a, b>::iterator #define sit(a) set<a>::iterator #define vi vector<int> #define vl vector<ll> #define pb push_back //#define printf __mingw_printf #define printcas cout << "Case " << cas << ": " #define _ continue; #define endl '\n' #define __ \ cout << endl; \ continue; const ll oo = (1ll << 60); int gi() { int x = 0, w = 1; char ch = getchar(); while ((ch < '0' || ch > '9') && ch != '-') ch = getchar(); if (ch == '-') w = 0, ch = getchar(); while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar(); return w ? x : -x; } int main() { // io; // string hudai(1000000,'a'); int T = 1; // T=gi(); for (int cas = 1; cas <= T; cas++) { ll n = gi(), i, j; double ph, sum = 0.0; vector<double> dp(n + 5); dp[0] = 1; for (i = 1; i <= n; i++) { cin >> ph; for (j = i; j >= 0; j--) { dp[j] = (!j ? 0 : dp[j - 1] * ph) + dp[j] * (1.0 - ph); } } for (i = (n >> 1) + 1; i <= n; i++) sum += dp[i]; printf("%.10lf\n", sum); } return 0; }
[ "literal.string.change", "call.arguments.change", "io.output.change", "io.output.newline.add" ]
976,782
976,780
u652421746
cpp
p03168
using namespace std; #include <bits/stdc++.h> #define pb push_back #define mk make_pair #define vect vector<ll> #define maap map<ll, ll> #define MOD 1000000007 #define mit map::iterator #define pii pair<ll, ll> #define rep(i, a, b) for (ll i = a; i < b; i++) #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); #define ZERO(a) memset(a, 0, sizeof(a)) #define MINUS(a) memset(a, 0xff, sizeof(a)) #define ITR(x, c) for (__typeof(c.begin()) x = c.begin(); x != c.end(); x++) typedef long long int ll; // stringstream convert; // convert << number; // string s = convert.str(); ll fact[500005], invfact[500005]; ll power(ll x, ll y) { ll z = 1; while (y > 0) { if (y % 2 == 1) z = (z * x) % MOD; x = (x * x) % MOD; y /= 2; } return z; } ll inv(ll x) { return power(x, MOD - 2); } ll divide(ll x, ll y) { return (x * inv(y)) % MOD; } ll C(ll n, ll k) { if (k > n) return 0; return divide(fact[n], (fact[n - k] * fact[k]) % MOD); } ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a); } bool isPrime(int n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; } void init() { ll p = MOD; fact[0] = 1; ll i; for (i = 1; i < 500005; i++) { fact[i] = (i * fact[i - 1]) % p; } i--; invfact[i] = power(fact[i], p - 2); for (i--; i >= 0; i--) { invfact[i] = (invfact[i + 1] * (i + 1)) % p; } } ll s; ll fun(ll a) { if (a == 0) return 0; return a + fun(a - 1); } priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> gq; #define MAXN 10000001 ll spf[MAXN]; void sieve() { spf[1] = 1; for (ll i = 2; i < MAXN; i++) spf[i] = i; for (ll i = 4; i < MAXN; i += 2) spf[i] = 2; for (ll i = 3; i * i < MAXN; i++) { if (spf[i] == i) { for (ll j = i * i; j < MAXN; j += i) if (spf[j] == j) spf[j] = i; } } } set<ll> getFactorization(ll x) { set<ll> ret; while (x != 1) { ret.insert(spf[x]); x = x / spf[x]; } return ret; } ll sm(ll n) { ll i; ll k = 0; while (n > 0) { k = k + n % 10; n = n / 10; } return k; } void ghost() { ll i = 0, j = 0, k = 0, n, r = 0, q = 0, t = 0, y = 100000000000, m, w; cin >> n; double a[n]; double l = 0.0; for (i = 0; i < n; i++) cin >> a[i]; double dp[n + 1][n + 1]; memset(dp, 0.0, sizeof(dp)); dp[0][0] = 1.0; for (i = 1; i <= n; i++) { for (j = 0; j <= i; j++) { if (j == 0) dp[i][j] = dp[i - 1][j] * (1.0 - a[i - 1]); else dp[i][j] = dp[i - 1][j] * (1.0 - a[i - 1]) + dp[i - 1][j - 1] * a[i - 1]; } } for (j = (n + 1) / 2; j <= n; j++) l = l + dp[n][j]; cout << l << endl; } signed main() { int test = 1; // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); fast // cin>>test; while (test--) ghost(); return 0; }
using namespace std; #include <bits/stdc++.h> #define pb push_back #define mk make_pair #define vect vector<ll> #define maap map<ll, ll> #define MOD 1000000007 #define mit map::iterator #define pii pair<ll, ll> #define rep(i, a, b) for (ll i = a; i < b; i++) #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); #define ZERO(a) memset(a, 0, sizeof(a)) #define MINUS(a) memset(a, 0xff, sizeof(a)) #define ITR(x, c) for (__typeof(c.begin()) x = c.begin(); x != c.end(); x++) typedef long long int ll; // stringstream convert; // convert << number; // string s = convert.str(); ll fact[500005], invfact[500005]; ll power(ll x, ll y) { ll z = 1; while (y > 0) { if (y % 2 == 1) z = (z * x) % MOD; x = (x * x) % MOD; y /= 2; } return z; } ll inv(ll x) { return power(x, MOD - 2); } ll divide(ll x, ll y) { return (x * inv(y)) % MOD; } ll C(ll n, ll k) { if (k > n) return 0; return divide(fact[n], (fact[n - k] * fact[k]) % MOD); } ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a); } bool isPrime(int n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; } void init() { ll p = MOD; fact[0] = 1; ll i; for (i = 1; i < 500005; i++) { fact[i] = (i * fact[i - 1]) % p; } i--; invfact[i] = power(fact[i], p - 2); for (i--; i >= 0; i--) { invfact[i] = (invfact[i + 1] * (i + 1)) % p; } } ll s; ll fun(ll a) { if (a == 0) return 0; return a + fun(a - 1); } priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> gq; #define MAXN 10000001 ll spf[MAXN]; void sieve() { spf[1] = 1; for (ll i = 2; i < MAXN; i++) spf[i] = i; for (ll i = 4; i < MAXN; i += 2) spf[i] = 2; for (ll i = 3; i * i < MAXN; i++) { if (spf[i] == i) { for (ll j = i * i; j < MAXN; j += i) if (spf[j] == j) spf[j] = i; } } } set<ll> getFactorization(ll x) { set<ll> ret; while (x != 1) { ret.insert(spf[x]); x = x / spf[x]; } return ret; } ll sm(ll n) { ll i; ll k = 0; while (n > 0) { k = k + n % 10; n = n / 10; } return k; } void ghost() { ll i = 0, j = 0, k = 0, n, r = 0, q = 0, t = 0, y = 100000000000, m, w; cin >> n; double a[n]; double l = 0.0; for (i = 0; i < n; i++) cin >> a[i]; double dp[n + 1][n + 1]; memset(dp, 0.0, sizeof(dp)); dp[0][0] = 1.0; for (i = 1; i <= n; i++) { for (j = 0; j <= i; j++) { if (j == 0) dp[i][j] = dp[i - 1][j] * (1.0 - a[i - 1]); else dp[i][j] = dp[i - 1][j] * (1.0 - a[i - 1]) + dp[i - 1][j - 1] * a[i - 1]; } } for (j = (n + 1) / 2; j <= n; j++) l = l + dp[n][j]; cout << setprecision(10) << l << endl; } signed main() { int test = 1; // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); fast // cin>>test; while (test--) ghost(); return 0; }
[ "io.output.change" ]
976,783
976,784
u379844185
cpp
p03168
#include <bits/stdc++.h> #define F first #define S second #define REP(i, a, b, c) for (int i = a; i <= b; i += c) #define pb push_back #define int long long int #define MOD 1000000007 using namespace std; double dp[3001][3001]; int32_t main() { ios ::sync_with_stdio(false); cin.tie(0); int t = 1; for (int i9 = 1; i9 <= t; i9++) { int n; cin >> n; double a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } memset(dp, 0.0, sizeof(dp)); for (int i = 0; i <= n; i++) { for (int x = 0; x <= (n + 1) / 2; x++) { if (x == 0) dp[i][x] = 1.0; else if (i == 0 and x != 0) dp[i][x] = 0; else dp[i][x] = a[i - 1] * dp[i - 1][x - 1] + (1 - a[i - 1]) * dp[i - 1][x]; } } cout << dp[n][(n + 1) / 2]; } }
#include <bits/stdc++.h> #define F first #define S second #define REP(i, a, b, c) for (int i = a; i <= b; i += c) #define pb push_back #define int long long int #define MOD 1000000007 using namespace std; double dp[3001][3001]; int32_t main() { ios ::sync_with_stdio(false); cin.tie(0); int t = 1; for (int i9 = 1; i9 <= t; i9++) { int n; cin >> n; double a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } memset(dp, 0.0, sizeof(dp)); for (int i = 0; i <= n; i++) { for (int x = 0; x <= (n + 1) / 2; x++) { if (x == 0) dp[i][x] = 1.0; else if (i == 0 and x != 0) dp[i][x] = 0; else dp[i][x] = a[i - 1] * dp[i - 1][x - 1] + (1 - a[i - 1]) * dp[i - 1][x]; } } cout << setprecision(9) << dp[n][(n + 1) / 2]; } }
[ "io.output.change" ]
976,799
976,800
u833947449
cpp
p03168
#include <bits/stdc++.h> #define endl '\n' using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; double a[n + 1]; double dp[n + 1][n + 1]; for (int i = 1; i <= n; i++) cin >> a[i]; dp[0][0] = 1; for (int i = 1; i <= n; i++) dp[0][i] = dp[0][i - 1] * (1 - a[i]); ; for (int i = 1; i <= n; i++) { for (int j = 0; j <= n; j++) { if (i > j) dp[i][j] = 1; else if (i == j) { dp[i][j] = dp[i - 1][j - 1] * a[j]; } else { dp[i][j] = dp[i - 1][j - 1] * a[j] + dp[i][j - 1] * (1 - a[j]); } } } double ans = 0; for (int i = n / 2 + 1; i <= n; i++) { ans += dp[i][n]; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define endl '\n' using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; double a[n + 1]; double dp[n + 1][n + 1]; for (int i = 1; i <= n; i++) cin >> a[i]; dp[0][0] = 1; for (int i = 1; i <= n; i++) dp[0][i] = dp[0][i - 1] * (1 - a[i]); ; for (int i = 1; i <= n; i++) { for (int j = 0; j <= n; j++) { if (i > j) dp[i][j] = 1; else if (i == j) { dp[i][j] = dp[i - 1][j - 1] * a[j]; } else { dp[i][j] = dp[i - 1][j - 1] * a[j] + dp[i][j - 1] * (1 - a[j]); } } } double ans = 0; for (int i = n / 2 + 1; i <= n; i++) { ans += dp[i][n]; } cout << setprecision(10) << ans << endl; return 0; }
[ "io.output.change" ]
976,812
976,813
u928828066
cpp
p03168
#include <bits/stdc++.h> using namespace std; #define PI 3.14159265358979323 #define ll long long int #define vi vector<int> #define vl vector<ll> #define all(v) (v).begin(), (v).end() #define pb push_back #define watch(x) cout << (#x) << " is " << (x) << "\n" #define MOD 1000000007 ll power(ll a, ll b) { // a^b ll res = 1; while (b > 0) { if (b & 1) { res = (res * a); b--; } a = (a * a); b >>= 1; } return res; } ll n; ll gcd(ll a, ll b) { return (b == 0) ? a : gcd(b, a % b); } int main() { ll n; cin >> n; double p[n]; for (ll i = 0; i < n; i++) cin >> p[i]; double dp[n + 1][n + 1]; for (ll i = 0; i <= n; i++) for (ll j = 0; j <= n; j++) dp[i][j] = 0; dp[0][0] = 1; for (ll i = 1; i <= n; i++) { for (ll j = 0; j <= i; j++) { if (j == 0) dp[i][j] = (1 - p[i - 1]) * (dp[i - 1][j]); else dp[i][j] = p[i - 1] * dp[i - 1][j - 1] + (1 - p[i - 1]) * dp[i - 1][j]; } } double sum = 0; for (ll i = n / 2 + 1; i <= n; i++) sum += dp[n][i]; printf("%llf\n", sum); }
#include <bits/stdc++.h> using namespace std; #define PI 3.14159265358979323 #define ll long long int #define vi vector<int> #define vl vector<ll> #define all(v) (v).begin(), (v).end() #define pb push_back #define watch(x) cout << (#x) << " is " << (x) << "\n" #define MOD 1000000007 ll power(ll a, ll b) { // a^b ll res = 1; while (b > 0) { if (b & 1) { res = (res * a); b--; } a = (a * a); b >>= 1; } return res; } ll n; ll gcd(ll a, ll b) { return (b == 0) ? a : gcd(b, a % b); } int main() { ll n; cin >> n; double p[n]; for (ll i = 0; i < n; i++) cin >> p[i]; double dp[n + 1][n + 1]; for (ll i = 0; i <= n; i++) for (ll j = 0; j <= n; j++) dp[i][j] = 0; dp[0][0] = 1; for (ll i = 1; i <= n; i++) { for (ll j = 0; j <= i; j++) { if (j == 0) dp[i][j] = (1 - p[i - 1]) * (dp[i - 1][j]); else dp[i][j] = p[i - 1] * dp[i - 1][j - 1] + (1 - p[i - 1]) * dp[i - 1][j]; } } double sum = 0; for (ll i = n / 2 + 1; i <= n; i++) sum += dp[n][i]; printf("%0.10lf\n", sum); }
[ "literal.string.change", "call.arguments.change", "io.output.change" ]
976,814
976,815
u859671712
cpp
p03168
#include <cmath> #include <iostream> #include <vector> typedef long long int ll; using namespace std; double foo(vector<double> &prob) { int n = prob.size(); vector<vector<double>> dp(n + 1, vector<double>(n + 1)); dp[0][0] = 1; for (int i = 1; i <= n; ++i) { dp[i][0] = dp[i - 1][0] * (1 - prob[i - 1]); } for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) { dp[i][j] = dp[i - 1][j - 1] * prob[i - 1] + dp[i - 1][j] * (1 - prob[i - 1]); // cout<<dp[i][j]<<" "; } // cout<<endl; } /** for (int i=0;i<=n;++i) { for (int j=0;j<=n;++j) { cout<<dp[i][j]<<" "; } cout<<endl; } **/ double ans = 0; int x = ceil(double(n) / 2); for (int i = x; i <= n; ++i) { // cout<<dp[n][i]<<endl; ans += dp[n][i]; } return ans; } int main() { int n; cin >> n; vector<double> prob(n); for (int i = 0; i < n; ++i) { cin >> prob[i]; } cout << foo(prob) << endl; return 0; }
#include <cmath> #include <iomanip> #include <iostream> #include <vector> typedef long long int ll; using namespace std; double foo(vector<double> &prob) { int n = prob.size(); vector<vector<double>> dp(n + 1, vector<double>(n + 1)); dp[0][0] = 1; for (int i = 1; i <= n; ++i) { dp[i][0] = dp[i - 1][0] * (1 - prob[i - 1]); } for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) { dp[i][j] = dp[i - 1][j - 1] * prob[i - 1] + dp[i - 1][j] * (1 - prob[i - 1]); // cout<<dp[i][j]<<" "; } // cout<<endl; } /** for (int i=0;i<=n;++i) { for (int j=0;j<=n;++j) { cout<<dp[i][j]<<" "; } cout<<endl; } **/ double ans = 0; int x = ceil(double(n) / 2); for (int i = x; i <= n; ++i) { // cout<<dp[n][i]<<endl; ans += dp[n][i]; } return ans; } int main() { int n; cin >> n; vector<double> prob(n); for (int i = 0; i < n; ++i) { cin >> prob[i]; } cout << setprecision(10) << foo(prob) << endl; return 0; }
[ "import.add" ]
976,820
976,821
u197841453
cpp
p03168
#include <bits/stdc++.h> using namespace std; #define ll long long int #define vl vector<long long int> #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); #define all(x) x.begin(), x.end() #define vi vector<int> #define vb vector<bool> #define vvl vector<vector<ll>> #define vvi vector<vector<int>> #define pl pair<ll, ll> #define pb push_back #define PI 3.14159265 #define mod 1000000007 #define pb push_back #define mp make_pair #define fri(s, n) for (int i = s; i < n; i++) #define frj(s, n) for (int j = s; j < n; j++) #define T(i) \ int i = 1; \ cin >> i; \ while (i--) #define vsi vector<set<int>> #define pii pair<int, int> #define inf 1e9 #define vpii vector<pair<int, int>> ll power(ll a, ll b) { if (b == 0) return 1; if (b & 1) return a * power(a, b - 1); ll temp = power(a, b / 2); return temp * temp; } ll mycompare(ll a, ll b) { return a > b; } int n; double max_prob(int c, int heads, vector<double> &p, vector<vector<double>> &dp) { if (c == 0 && heads <= n / 2) return 0; if (c == 0) return 1; if (dp[c][heads] != -1) return dp[c][heads]; return dp[c][heads] = p[c] * max_prob(c - 1, heads + 1, p, dp) + (1 - p[c]) * max_prob(c - 1, heads, p, dp); } int main() { // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); fast; cin >> n; vector<double> p(n + 1); fri(1, n + 1) cin >> p[i]; vector<vector<double>> dp(n + 1, vector<double>(n + 1, -1)); cout << max_prob(n, 0, p, dp); }
#include <bits/stdc++.h> using namespace std; #define ll long long int #define vl vector<long long int> #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); #define all(x) x.begin(), x.end() #define vi vector<int> #define vb vector<bool> #define vvl vector<vector<ll>> #define vvi vector<vector<int>> #define pl pair<ll, ll> #define pb push_back #define PI 3.14159265 #define mod 1000000007 #define pb push_back #define mp make_pair #define fri(s, n) for (int i = s; i < n; i++) #define frj(s, n) for (int j = s; j < n; j++) #define T(i) \ int i = 1; \ cin >> i; \ while (i--) #define vsi vector<set<int>> #define pii pair<int, int> #define inf 1e9 #define vpii vector<pair<int, int>> ll power(ll a, ll b) { if (b == 0) return 1; if (b & 1) return a * power(a, b - 1); ll temp = power(a, b / 2); return temp * temp; } ll mycompare(ll a, ll b) { return a > b; } int n; double max_prob(int c, int heads, vector<double> &p, vector<vector<double>> &dp) { if (c == 0 && heads <= n / 2) return 0; if (c == 0) return 1; if (dp[c][heads] != -1) return dp[c][heads]; return dp[c][heads] = p[c] * max_prob(c - 1, heads + 1, p, dp) + (1 - p[c]) * max_prob(c - 1, heads, p, dp); } int main() { // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); fast; cin >> n; vector<double> p(n + 1); fri(1, n + 1) cin >> p[i]; vector<vector<double>> dp(n + 1, vector<double>(n + 1, -1)); cout << setprecision(9) << max_prob(n, 0, p, dp); }
[ "io.output.change" ]
976,828
976,829
u709648815
cpp
p03168
#pragma region #include <algorithm> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <stack> #include <string> #include <vector> typedef long long ll; #define tr t[root] #define lson t[root << 1] #define rson t[root << 1 | 1] #define rep(i, a, n) for (long long i = a; i <= n; ++i) #define per(i, a, n) for (long long i = n; i >= a; --i) #define IO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) template <typename T> void read(T &x) { x = 0; char ch = getchar(); ll f = 1; while (!isdigit(ch)) { if (ch == '-') f *= -1; ch = getchar(); } while (isdigit(ch)) { x = x * 10 + ch - 48; ch = getchar(); } x *= f; } using namespace std; /* * __----~~~~~~~~~~~------___ * . . ~~//====...... __--~ ~~ * -. \_|// |||\\ ~~~~~~::::... /~ * ___-==_ _-~o~ \/ ||| \\ _/~~- * __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ * _-~~ .=~ | \\-_ '-~7 /- / || \ / * .~ .~ | \\ -_ / /- / || \ / * / ____ / | \\ ~-_/ /|- _/ .|| \ / * |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ * ' ~-| /| |-~\~~ __--~~ * |-~~-_/ | | ~\_ _-~ /\ * / \ \__ \/~ \__ * _--~ _/ | .-~~____--~-/ ~~==. * ((->/~ '.|||' -_| ~~-/ , . _|| * -_ ~\ ~~---l__i__i__i--~~_/ * _-~-__ ~) \--______________--~~ * //.-~~~-~_--~- |-------~~~~~~~~ * //.-~~~--\ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma endregion const int maxn = 3e3 + 5; int n; double p[maxn], dp[maxn][maxn]; int main() { IO; cin >> n; rep(i, 1, n) cin >> p[i]; dp[0][0] = 1; rep(i, 1, n) per(j, i, 0) if (!j) dp[i][j] = dp[i - 1][j] * (1 - p[i]); else dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1 - p[i]); double ans = 0; for (int i = n / 2 + 1; i <= n; ++i) ans += dp[n][i]; cout << fixed << setprecision(10) << ans << endl; }
#pragma region #include <algorithm> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <stack> #include <string> #include <vector> typedef long long ll; #define tr t[root] #define lson t[root << 1] #define rson t[root << 1 | 1] #define rep(i, a, n) for (long long i = a; i <= n; ++i) #define per(i, a, n) for (long long i = n; i >= a; --i) #define IO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) template <typename T> void read(T &x) { x = 0; char ch = getchar(); ll f = 1; while (!isdigit(ch)) { if (ch == '-') f *= -1; ch = getchar(); } while (isdigit(ch)) { x = x * 10 + ch - 48; ch = getchar(); } x *= f; } using namespace std; /* * __----~~~~~~~~~~~------___ * . . ~~//====...... __--~ ~~ * -. \_|// |||\\ ~~~~~~::::... /~ * ___-==_ _-~o~ \/ ||| \\ _/~~- * __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ * _-~~ .=~ | \\-_ '-~7 /- / || \ / * .~ .~ | \\ -_ / /- / || \ / * / ____ / | \\ ~-_/ /|- _/ .|| \ / * |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ * ' ~-| /| |-~\~~ __--~~ * |-~~-_/ | | ~\_ _-~ /\ * / \ \__ \/~ \__ * _--~ _/ | .-~~____--~-/ ~~==. * ((->/~ '.|||' -_| ~~-/ , . _|| * -_ ~\ ~~---l__i__i__i--~~_/ * _-~-__ ~) \--______________--~~ * //.-~~~-~_--~- |-------~~~~~~~~ * //.-~~~--\ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma endregion const int maxn = 3e3 + 5; int n; double p[maxn], dp[maxn][maxn]; int main() { IO; cin >> n; rep(i, 1, n) cin >> p[i]; dp[0][0] = 1; rep(i, 1, n) per(j, 0, i) if (!j) dp[i][j] = dp[i - 1][j] * (1 - p[i]); else dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1 - p[i]); double ans = 0; for (int i = n / 2 + 1; i <= n; ++i) ans += dp[n][i]; cout << fixed << setprecision(10) << ans << endl; }
[ "call.arguments.change", "call.arguments.add" ]
976,832
976,833
u035226457
cpp
p03168
#pragma region #include <algorithm> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <stack> #include <string> #include <vector> typedef long long ll; #define tr t[root] #define lson t[root << 1] #define rson t[root << 1 | 1] #define rep(i, a, n) for (long long i = a; i <= n; ++i) #define per(i, a, n) for (long long i = n; i >= a; --i) #define IO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) template <typename T> void read(T &x) { x = 0; char ch = getchar(); ll f = 1; while (!isdigit(ch)) { if (ch == '-') f *= -1; ch = getchar(); } while (isdigit(ch)) { x = x * 10 + ch - 48; ch = getchar(); } x *= f; } using namespace std; /* * __----~~~~~~~~~~~------___ * . . ~~//====...... __--~ ~~ * -. \_|// |||\\ ~~~~~~::::... /~ * ___-==_ _-~o~ \/ ||| \\ _/~~- * __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ * _-~~ .=~ | \\-_ '-~7 /- / || \ / * .~ .~ | \\ -_ / /- / || \ / * / ____ / | \\ ~-_/ /|- _/ .|| \ / * |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ * ' ~-| /| |-~\~~ __--~~ * |-~~-_/ | | ~\_ _-~ /\ * / \ \__ \/~ \__ * _--~ _/ | .-~~____--~-/ ~~==. * ((->/~ '.|||' -_| ~~-/ , . _|| * -_ ~\ ~~---l__i__i__i--~~_/ * _-~-__ ~) \--______________--~~ * //.-~~~-~_--~- |-------~~~~~~~~ * //.-~~~--\ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma endregion const int maxn = 3e3 + 5; int n; double p[maxn], dp[maxn][maxn]; int main() { IO; cin >> n; rep(i, 1, n) cin >> p[i]; dp[0][0] = 1; rep(i, 1, n) per(j, i, 0) if (!j) dp[i][j] = dp[i - 1][j] * (1 - p[i]); else dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1 - p[i]); double ans = 0; for (int i = n / 2 + 1; i <= n; ++i) ans += dp[n][i]; cout << fixed << setprecision(10) << ans << endl; }
#pragma region #include <algorithm> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <stack> #include <string> #include <vector> typedef long long ll; #define tr t[root] #define lson t[root << 1] #define rson t[root << 1 | 1] #define rep(i, a, n) for (long long i = a; i <= n; ++i) #define per(i, a, n) for (long long i = n; i >= a; --i) #define IO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) template <typename T> void read(T &x) { x = 0; char ch = getchar(); ll f = 1; while (!isdigit(ch)) { if (ch == '-') f *= -1; ch = getchar(); } while (isdigit(ch)) { x = x * 10 + ch - 48; ch = getchar(); } x *= f; } using namespace std; /* * __----~~~~~~~~~~~------___ * . . ~~//====...... __--~ ~~ * -. \_|// |||\\ ~~~~~~::::... /~ * ___-==_ _-~o~ \/ ||| \\ _/~~- * __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~ * _-~~ .=~ | \\-_ '-~7 /- / || \ / * .~ .~ | \\ -_ / /- / || \ / * / ____ / | \\ ~-_/ /|- _/ .|| \ / * |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\ * ' ~-| /| |-~\~~ __--~~ * |-~~-_/ | | ~\_ _-~ /\ * / \ \__ \/~ \__ * _--~ _/ | .-~~____--~-/ ~~==. * ((->/~ '.|||' -_| ~~-/ , . _|| * -_ ~\ ~~---l__i__i__i--~~_/ * _-~-__ ~) \--______________--~~ * //.-~~~-~_--~- |-------~~~~~~~~ * //.-~~~--\ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #pragma endregion const int maxn = 3e3 + 5; int n; double p[maxn], dp[maxn][maxn]; int main() { IO; cin >> n; rep(i, 1, n) cin >> p[i]; dp[0][0] = 1; rep(i, 1, n) rep(j, 0, i) if (!j) dp[i][j] = dp[i - 1][j] * (1 - p[i]); else dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1 - p[i]); double ans = 0; for (int i = n / 2 + 1; i <= n; ++i) ans += dp[n][i]; cout << fixed << setprecision(10) << ans << endl; }
[ "identifier.change", "call.function.change", "call.arguments.change", "call.arguments.add" ]
976,832
976,834
u035226457
cpp
p03168
#include <bits/stdc++.h> using namespace std; double recurse(int i, int j, vector<vector<double>> &dp, vector<double> &arr) { // i denotes the number of heads, j denotes the number of items remaining. if (i == 0 && j == 0) return 1; else if (i > 0 && j == 0) return 0; else if (i == 0 && j > 0) { if (dp[i][j] >= 0) return dp[i][j]; else dp[i][j] = recurse(i, j - 1, dp, arr) * (1 - arr[j - 1]); return dp[i][j]; } else { if (dp[i][j] >= 0) return dp[i][j]; else dp[i][j] = recurse(i - 1, j - 1, dp, arr) * arr[j - 1] + recurse(i, j - 1, dp, arr) * (1 - arr[j - 1]); return dp[i][j]; } } int main(int argc, char const *argv[]) { int n; double temp; cin >> n; vector<double> arr(n, -1.0); // denotes the number of heads remaining on one axis and ith item on second. vector<vector<double>> dp(n + 1, vector<double>(n + 1, -1.0)); for (int i = 0; i < n; i++) { cin >> temp; arr[i] = temp; } double result = 0.0; for (int i = n / 2 + 1; i <= n; i++) { dp[i][n] = recurse(i, n, dp, arr); result += dp[i][n]; } cout << result; return 0; }
#include <bits/stdc++.h> using namespace std; double recurse(int i, int j, vector<vector<double>> &dp, vector<double> &arr) { // i denotes the number of heads, j denotes the number of items remaining. if (i == 0 && j == 0) return 1; else if (i > 0 && j == 0) return 0; else if (i == 0 && j > 0) { if (dp[i][j] >= 0) return dp[i][j]; else dp[i][j] = recurse(i, j - 1, dp, arr) * (1 - arr[j - 1]); return dp[i][j]; } else { if (dp[i][j] >= 0) return dp[i][j]; else dp[i][j] = recurse(i - 1, j - 1, dp, arr) * arr[j - 1] + recurse(i, j - 1, dp, arr) * (1 - arr[j - 1]); return dp[i][j]; } } int main(int argc, char const *argv[]) { int n; double temp; cin >> n; vector<double> arr(n, -1.0); // denotes the number of heads remaining on one axis and ith item on second. vector<vector<double>> dp(n + 1, vector<double>(n + 1, -1.0)); for (int i = 0; i < n; i++) { cin >> temp; arr[i] = temp; } double result = 0.0; for (int i = n / 2 + 1; i <= n; i++) { dp[i][n] = recurse(i, n, dp, arr); result += dp[i][n]; } cout << setprecision(11) << result; return 0; }
[ "io.output.change" ]
976,837
976,838
u270850105
cpp
p03168
// ABHISHEK AGRAWAL// // Newbie......You have to be odd to be no. ONE :)// #include <bits/stdc++.h> using namespace std; #define ll long long int #define ld long double #define fl float #define lcm(a, b) (a * (b / __gcd(a, b))) #define vs vector<string> #define vc vector<char> #define vll vector<ll> #define sll set<ll> #define pll pair<ll, ll> #define plc pair<ll, char> #define tlll tuple<ll, ll, ll> #define mt make_tuple #define vpll vector<pair<ll, ll>> #define vtll vector<tuple<ll, ll, ll>> #define vvll vector<vector<ll>> #define lb lower_bound #define pb push_back #define pob pop_back #define f first #define s second #define mll map<ll, ll> #define mp make_pair #define sp(n) fixed << setprecision(n) #define mcl map<char, ll> #define mcc map<char, char> #define msl map<string, ll> #define mss map<string, string> #define mod (ll)1000000007 #define flash \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define test \ ll t; \ read(t); \ while (t--) #define sortv(v) sort(v.begin(), v.end()) #define INF (ll)(1e15) #define loop(i, n) for (ll i = 0; i < n; i++) #define loop1(i, n) for (ll i = 1; i <= n; i++) #define rloop(n, i) for (ll i = n - 1; i >= 0; i--) #define loopab(i, a, b, c) for (ll i = a; i <= b; i += c) #define max3(a, b, c) max(max(a, b), c) #define min3(a, b, c) min(min(a, b), c) #define reada(a, n) loop(i, n) cin >> a[i]; #define reada1(a, n) loop1(i, n) cin >> a[i]; #define sorta(a) sort(a, a + n, greater<ll>()) #define countone(n) __builtin_popcount(n) #define numoftrailzero(n) __builtin_ctz(n) #define maxpowoftwo(n) __builtin_clz(n) #define leastindexwithone(n) __builtin_ffs(n) #define what_is(x) cerr << #x << " is " << x << endl; #define pfv(v) \ cout << v.size() << "\n"; \ loop(i, v.size()) cout << v[i] << " "; #define pv(v) loop(i, v.size()) cout << v[i] << " "; // if we need to devide any given number in powers of term the power of max term #define answer(n) ceil(log2(n + 1)) ll n, q; ll gcd(ll a, ll b) { if (b == 0) { return a; } return gcd(b, a % b); } ll powe(ll a, ll b) { ll res = 1; while (b > 0) { if (b % 2 == 1) { res = (res * a); } a = (a * a); b /= 2; } return res; } ll power(ll a, ll b, ll M) { a %= M; ll res = 1; while (b > 0) { if (b % 2 == 1) { res = (res * a) % M; } a = (a * a) % M; b /= 2; } return res; } ll extendedEuclid(ll A, ll B, ll &x, ll &y) { if (B == 0) { x = 1; y = 0; return A; } else { ll x1, y1; ll gcd = extendedEuclid(B, A % B, x1, y1); y = x1 - (A / B) * y1; x = y1; return gcd; } } ll mi(ll A, ll M) { ll x, y; extendedEuclid(A, M, x, y); if (x < 0) { x += mod; } return x; } template <typename T> void read(T &x) { cin >> x; } template <typename T, typename T0> void read(T &x, T0 &y) { cin >> x >> y; } template <typename T, typename T0, typename T1> void read(T &x, T0 &y, T1 &z) { cin >> x >> y >> z; } template <typename T, typename T0, typename T1, typename T2> void read(T &x, T0 &y, T1 &z, T2 &w) { cin >> x >> y >> z >> w; } // pair// // read pair// template <typename T, typename T0> void read(pair<T, T0> &p) { cin >> p.f >> p.s; } // write pair// template <typename T, typename T0> void write(pair<T, T0> &p) { write(p.f); write(p.s); } // vector// // read vector// template <typename T> void read(vector<T> &oneD, ll n) { loop(i, n) { ll x; read(x); oneD.pb(x); } } // array// // read array// template <typename T> void read(T oneD[], ll n) { loop(i, n) { read(oneD[i]); } } // write array// template <typename T> void write(T oneD[], int n) { loop(i, n) { write(oneD[i]); } cout << endl; } vector<bool> sieve(1000000, true); void Sieve() { sieve[0] = false; sieve[1] = false; for (ll i = 2; i * i <= 1000000; i++) { if (sieve[i] == true) { for (ll j = i * i; j < 1000000; j += i) sieve[j] = false; } } } vll sieve_spf; void Sieve_spf() { const ll n = 1e6 + 5; sieve_spf.resize(n); loop(i, n) sieve_spf[i] = i; sieve_spf[0] = -1; sieve_spf[1] = 1; loopab(i, 2, n, 2) sieve_spf[i] = 2; loopab(i, 3, n, 2) if (sieve_spf[i] == i) loopab(j, i * i, n, i) if (sieve_spf[j] == j) sieve_spf[j] = i; } bool oppositeSigns(ll x, ll y) { return ((x ^ y) < 0); } int mpt(ll n) { ll c = 0; ll n1 = pow(2, c); while (n1 < n) { c++; n1 = pow(2, c); } return c; } void the_happiest_place_on_earth() { flash; #ifdef ENABLE_FILE_IO freopen("in", "r", stdin); freopen("out", "w", stdout); #endif } const int N = 3000; ld a[N], dp[N][N]; void solve() { read(n); loop1(i, n) read(a[i]); ld ans = 0; loop(i, n + 1) loop(j, n + 1) { if (i < j) dp[i][j] = 0; else if (i == 0 && j == 0) dp[i][j] = 1; else if (j == 0 && i > 0) dp[i][j] = dp[i - 1][0] * (1 - a[i]); else dp[i][j] = dp[i - 1][j - 1] * a[i] + dp[i - 1][j] * (1 - a[i]); if (i == n && j > n / 2) ans += dp[i][j]; } cout << ans; return; } int main() { the_happiest_place_on_earth(); // Today's thought: Push yourself, because no one else is going to do it for // you. Things aren’t always #000000 and #FFFFFF START OF PROGRAM LOGIC solve(); cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n"; // END OF PROGRAM LOGIC return 0; }
// ABHISHEK AGRAWAL// // Newbie......You have to be odd to be no. ONE :)// #include <bits/stdc++.h> using namespace std; #define ll long long int #define ld long double #define fl float #define lcm(a, b) (a * (b / __gcd(a, b))) #define vs vector<string> #define vc vector<char> #define vll vector<ll> #define sll set<ll> #define pll pair<ll, ll> #define plc pair<ll, char> #define tlll tuple<ll, ll, ll> #define mt make_tuple #define vpll vector<pair<ll, ll>> #define vtll vector<tuple<ll, ll, ll>> #define vvll vector<vector<ll>> #define lb lower_bound #define pb push_back #define pob pop_back #define f first #define s second #define mll map<ll, ll> #define mp make_pair #define sp(n) fixed << setprecision(n) #define mcl map<char, ll> #define mcc map<char, char> #define msl map<string, ll> #define mss map<string, string> #define mod (ll)1000000007 #define flash \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define test \ ll t; \ read(t); \ while (t--) #define sortv(v) sort(v.begin(), v.end()) #define INF (ll)(1e15) #define loop(i, n) for (ll i = 0; i < n; i++) #define loop1(i, n) for (ll i = 1; i <= n; i++) #define rloop(n, i) for (ll i = n - 1; i >= 0; i--) #define loopab(i, a, b, c) for (ll i = a; i <= b; i += c) #define max3(a, b, c) max(max(a, b), c) #define min3(a, b, c) min(min(a, b), c) #define reada(a, n) loop(i, n) cin >> a[i]; #define reada1(a, n) loop1(i, n) cin >> a[i]; #define sorta(a) sort(a, a + n, greater<ll>()) #define countone(n) __builtin_popcount(n) #define numoftrailzero(n) __builtin_ctz(n) #define maxpowoftwo(n) __builtin_clz(n) #define leastindexwithone(n) __builtin_ffs(n) #define what_is(x) cerr << #x << " is " << x << endl; #define pfv(v) \ cout << v.size() << "\n"; \ loop(i, v.size()) cout << v[i] << " "; #define pv(v) loop(i, v.size()) cout << v[i] << " "; // if we need to devide any given number in powers of term the power of max term #define answer(n) ceil(log2(n + 1)) ll n, q; ll gcd(ll a, ll b) { if (b == 0) { return a; } return gcd(b, a % b); } ll powe(ll a, ll b) { ll res = 1; while (b > 0) { if (b % 2 == 1) { res = (res * a); } a = (a * a); b /= 2; } return res; } ll power(ll a, ll b, ll M) { a %= M; ll res = 1; while (b > 0) { if (b % 2 == 1) { res = (res * a) % M; } a = (a * a) % M; b /= 2; } return res; } ll extendedEuclid(ll A, ll B, ll &x, ll &y) { if (B == 0) { x = 1; y = 0; return A; } else { ll x1, y1; ll gcd = extendedEuclid(B, A % B, x1, y1); y = x1 - (A / B) * y1; x = y1; return gcd; } } ll mi(ll A, ll M) { ll x, y; extendedEuclid(A, M, x, y); if (x < 0) { x += mod; } return x; } template <typename T> void read(T &x) { cin >> x; } template <typename T, typename T0> void read(T &x, T0 &y) { cin >> x >> y; } template <typename T, typename T0, typename T1> void read(T &x, T0 &y, T1 &z) { cin >> x >> y >> z; } template <typename T, typename T0, typename T1, typename T2> void read(T &x, T0 &y, T1 &z, T2 &w) { cin >> x >> y >> z >> w; } // pair// // read pair// template <typename T, typename T0> void read(pair<T, T0> &p) { cin >> p.f >> p.s; } // write pair// template <typename T, typename T0> void write(pair<T, T0> &p) { write(p.f); write(p.s); } // vector// // read vector// template <typename T> void read(vector<T> &oneD, ll n) { loop(i, n) { ll x; read(x); oneD.pb(x); } } // array// // read array// template <typename T> void read(T oneD[], ll n) { loop(i, n) { read(oneD[i]); } } // write array// template <typename T> void write(T oneD[], int n) { loop(i, n) { write(oneD[i]); } cout << endl; } vector<bool> sieve(1000000, true); void Sieve() { sieve[0] = false; sieve[1] = false; for (ll i = 2; i * i <= 1000000; i++) { if (sieve[i] == true) { for (ll j = i * i; j < 1000000; j += i) sieve[j] = false; } } } vll sieve_spf; void Sieve_spf() { const ll n = 1e6 + 5; sieve_spf.resize(n); loop(i, n) sieve_spf[i] = i; sieve_spf[0] = -1; sieve_spf[1] = 1; loopab(i, 2, n, 2) sieve_spf[i] = 2; loopab(i, 3, n, 2) if (sieve_spf[i] == i) loopab(j, i * i, n, i) if (sieve_spf[j] == j) sieve_spf[j] = i; } bool oppositeSigns(ll x, ll y) { return ((x ^ y) < 0); } int mpt(ll n) { ll c = 0; ll n1 = pow(2, c); while (n1 < n) { c++; n1 = pow(2, c); } return c; } void the_happiest_place_on_earth() { flash; #ifdef ENABLE_FILE_IO freopen("in", "r", stdin); freopen("out", "w", stdout); #endif } const int N = 3000; ld a[N], dp[N][N]; void solve() { read(n); loop1(i, n) read(a[i]); ld ans = 0; loop(i, n + 1) loop(j, n + 1) { if (i < j) dp[i][j] = 0; else if (i == 0 && j == 0) dp[i][j] = 1; else if (j == 0 && i > 0) dp[i][j] = dp[i - 1][0] * (1 - a[i]); else dp[i][j] = dp[i - 1][j - 1] * a[i] + dp[i - 1][j] * (1 - a[i]); if (i == n && j > n / 2) ans += dp[i][j]; } cout << sp(10) << ans; return; } int main() { the_happiest_place_on_earth(); // Today's thought: Push yourself, because no one else is going to do it for // you. Things aren’t always #000000 and #FFFFFF START OF PROGRAM LOGIC solve(); cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n"; // END OF PROGRAM LOGIC return 0; }
[ "io.output.change" ]
976,845
976,846
u625460396
cpp
p03168
#include <bits/stdc++.h> #define endl '\n' #define N 1000001 #define mod 1e9 + 7 using namespace std; typedef long long ll; double p[3000]; double dp[3000][3000]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ll n; cin >> n; for (ll i = 0; i < n; i++) { cin >> p[i]; } dp[0][0] = 1; for (ll i = 1; i <= n; i++) { for (ll j = 0; j <= i; j++) { if (j) dp[i][j] += dp[i - 1][j - 1] * p[i - 1]; dp[i][j] += dp[i - 1][j] * (1 - p[i - 1]); } } double ans = 0; for (ll i = 0; i <= n; i++) { if (i > n - i) ans += dp[n][i]; } printf("%.2f", ans); return 0; }
#include <bits/stdc++.h> #define endl '\n' #define N 1000001 #define mod 1e9 + 7 using namespace std; typedef long long ll; double p[3000]; double dp[3000][3000]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ll n; cin >> n; for (ll i = 0; i < n; i++) { cin >> p[i]; } dp[0][0] = 1; for (ll i = 1; i <= n; i++) { for (ll j = 0; j <= i; j++) { if (j) dp[i][j] += dp[i - 1][j - 1] * p[i - 1]; dp[i][j] += dp[i - 1][j] * (1 - p[i - 1]); } } double ans = 0; for (ll i = 0; i <= n; i++) { if (i > n - i) ans += dp[n][i]; } printf("%.12f", ans); return 0; }
[ "literal.string.change", "call.arguments.change", "io.output.change" ]
976,849
976,850
u447009922
cpp
p03168
#include <bits/stdc++.h> using namespace std; using vi = vector<int>; using vb = vector<bool>; using vl = vector<long>; using vs = vector<string>; using vvi = vector<vector<int>>; using vvb = vector<vector<bool>>; using vvc = vector<vector<char>>; using vvl = vector<vector<long>>; using pii = pair<int, int>; using pil = pair<int, long>; using pll = pair<long, long>; #define fix20 cout << fixed << setprecision(20) #define YES cout << "Yes" << endl #define NO cout << "No" << endl #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define REP(i, s, t) for (int i = s; i < t; i++) #define RNG(i, s, t, u) for (int i = s; i < t; i += u) #define MOD 1000000007 #define all(vec) vec.begin(), vec.end() int main() { int n; cin >> n; vector<double> p(n); rep(i, n) cin >> p[i]; vector<vector<double>> dp(n + 1, vector<double>(n + 1, 0)); dp[0][0] = 1.0; rep(i, n) { rep(j, n + 1) { if (j == 0) dp[i + 1][j] = dp[i][j] * (1.0 - p[i]); else dp[i + 1][j] = dp[i][j] * (1.0 - p[i]) + dp[i][j - 1] * p[i]; } } double ans = 0; rep(i, n + 1) { if (i > n - i) ans += dp[n][i]; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; using vi = vector<int>; using vb = vector<bool>; using vl = vector<long>; using vs = vector<string>; using vvi = vector<vector<int>>; using vvb = vector<vector<bool>>; using vvc = vector<vector<char>>; using vvl = vector<vector<long>>; using pii = pair<int, int>; using pil = pair<int, long>; using pll = pair<long, long>; #define fix20 cout << fixed << setprecision(20) #define YES cout << "Yes" << endl #define NO cout << "No" << endl #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define REP(i, s, t) for (int i = s; i < t; i++) #define RNG(i, s, t, u) for (int i = s; i < t; i += u) #define MOD 1000000007 #define all(vec) vec.begin(), vec.end() int main() { fix20; int n; cin >> n; vector<double> p(n); rep(i, n) cin >> p[i]; vector<vector<double>> dp(n + 1, vector<double>(n + 1, 0)); dp[0][0] = 1.0; rep(i, n) { rep(j, n + 1) { if (j == 0) dp[i + 1][j] = dp[i][j] * (1.0 - p[i]); else dp[i + 1][j] = dp[i][j] * (1.0 - p[i]) + dp[i][j - 1] * p[i]; } } double ans = 0; rep(i, n + 1) { if (i > n - i) ans += dp[n][i]; } cout << ans << endl; }
[]
976,859
976,860
u184335045
cpp
p03168
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define endl '\n' #define ff first #define ss second #define pb push_back #define pf push_front #define rep(i, a, b) for (ll i = a; i < (b); ++i) #define reb(i, a, b) for (ll i = a; i >= (b); --i) #define trav(a, x) for (auto &a : x) #define all(x) x.begin(), x.end() #define sz(x) (ll)(x).size() typedef pair<ll, ll> pii; typedef vector<ll> vi; int main() { // #ifndef ONLINE_JUDGE // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); // #endif ll n; ld p_head; cin >> n; vector<ld> dp(n + 1); dp[0] = 1.0; rep(i, 0, n) { cin >> p_head; reb(j, i + 1, 1) { dp[j] = (j == 0 ? 0 : dp[j - 1] * p_head) + dp[j] * (1 - p_head); } } double ans = 0.0; rep(i, 1, n + 1) { ll ch = n - i; if (i > ch) ans += dp[i]; } cout << setprecision(10) << ans << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define endl '\n' #define ff first #define ss second #define pb push_back #define pf push_front #define rep(i, a, b) for (ll i = a; i < (b); ++i) #define reb(i, a, b) for (ll i = a; i >= (b); --i) #define trav(a, x) for (auto &a : x) #define all(x) x.begin(), x.end() #define sz(x) (ll)(x).size() typedef pair<ll, ll> pii; typedef vector<ll> vi; int main() { // #ifndef ONLINE_JUDGE // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); // #endif ll n; ld p_head; cin >> n; vector<ld> dp(n + 1); dp[0] = 1.0; rep(i, 0, n) { cin >> p_head; reb(j, i + 1, 0) { dp[j] = (j == 0 ? 0 : dp[j - 1] * p_head) + dp[j] * (1 - p_head); } } double ans = 0.0; rep(i, 1, n + 1) { ll ch = n - i; if (i > ch) ans += dp[i]; } cout << setprecision(10) << ans << endl; }
[ "literal.number.change", "call.arguments.change" ]
976,871
976,872
u309862422
cpp