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 |
|---|---|---|---|---|---|---|---|
p03013 | #include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
typedef long long ll;
ll dp[101010];
ll MOD = 1000000007;
bool ban[101010];
int main() {
int N, M;
cin >> N >> M;
ll ans;
for (int i = 0; i < M; i++) {
int x;
cin >> x;
ban[x] = true;
}
dp[0] = 1;
for (int i = 1; i <= N; i++) {
if (!ban[i])
(dp[i] = dp[i - 1] + dp[i - 2]) % MOD;
}
cout << dp[N] << endl;
}
| #include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
typedef long long ll;
ll dp[101010];
ll MOD = 1000000007;
bool ban[101010];
int main() {
int N, M;
cin >> N >> M;
ll ans;
for (int i = 0; i < M; i++) {
int x;
cin >> x;
ban[x] = true;
}
dp[0] = 1;
for (int i = 1; i <= N; i++) {
if (!ban[i])
(dp[i] = dp[i - 1] + dp[i - 2]) %= MOD;
}
cout << dp[N] << endl;
}
| [
"assignment.compound.arithmetic.replace.add",
"expression.operator.arithmetic.replace.remove",
"expression.operation.binary.change"
] | 827,346 | 827,347 | u390901416 | cpp |
p03013 | #include <bits/stdc++.h>
using namespace std;
const int mod = 1E9 + 7;
int main() {
int n, m;
cin >> n >> m;
vector<int> A(n + 1, 0);
vector<int> flg(n, 0);
for (int i = 1; i <= m; i++) {
int x;
cin >> x;
A[x] = 1;
}
flg[0] = 1;
for (int i = 1; i <= n; i++) {
if (!A[i])
flg[i] = (flg[i - 1] + flg[i - 2]) % mod;
}
cout << flg[n] << endl;
} | #include <bits/stdc++.h>
using namespace std;
const int mod = 1E9 + 7;
int main() {
int n, m;
cin >> n >> m;
vector<int> A(n + 1, 0);
vector<int> flg(n + 1, 0);
for (int i = 1; i <= m; i++) {
int x;
cin >> x;
A[x] = 1;
}
flg[0] = 1;
for (int i = 1; i <= n; i++) {
if (!A[i])
flg[i] = (flg[i - 1] + flg[i - 2]) % mod;
}
cout << flg[n] << endl;
} | [
"assignment.change"
] | 827,383 | 827,384 | u577189232 | cpp |
p03013 | #include <stack>
#include <stdio.h>
using namespace std;
#define MAX_N (100000 + 1)
#define MOD (1000000007)
int cannot_step[MAX_N] = {0};
long long num_path[MAX_N] = {0};
long long mod(long long val, long long m) {
long long res = val % m;
if (res < 0)
res += m;
return res;
}
int main(void) {
int n, m;
int impossible = 0;
stack<int> index_stack;
for (int i = 0; i < MAX_N; ++i) {
num_path[i] = -1;
}
scanf("%d %d", &n, &m);
for (int i = 0; i < m; ++i) {
int a;
scanf("%d", &a);
cannot_step[a] = 1;
if (cannot_step[a] == cannot_step[a - 1] == 1) {
impossible = 1;
}
}
if (impossible) {
printf("0\n");
return 0;
}
num_path[0] = 1;
num_path[1] = 1;
index_stack.push(n);
while (index_stack.empty() == 0) {
int index = index_stack.top();
if (index < 0) {
// 範囲外のため解決不要
index_stack.pop();
}
if (num_path[index] != -1) {
// 解決済み
index_stack.pop();
}
if (num_path[index - 1] == -1 && cannot_step[index - 1] == 0) {
// 解決必要
index_stack.push(index - 1);
}
if (num_path[index - 2] == -1 && cannot_step[index - 2] == 0) {
// 解決必要
index_stack.push(index - 2);
}
long long ans = 0;
if ((num_path[index - 1] != -1 || cannot_step[index - 1]) &&
(num_path[index - 2] != -1 || cannot_step[index - 2])) {
// 解決
if (cannot_step[index - 1] == 0) {
ans += num_path[index - 1];
ans = mod(ans, MOD);
}
if (cannot_step[index - 2] == 0) {
ans += num_path[index - 2];
ans = mod(ans, MOD);
}
num_path[index] = ans;
index_stack.pop();
}
}
printf("%lld\n", num_path[n]);
return 0;
}
| #include <stack>
#include <stdio.h>
using namespace std;
#define MAX_N (100000 + 1)
#define MOD (1000000007)
int cannot_step[MAX_N] = {0};
long long num_path[MAX_N] = {0};
long long mod(long long val, long long m) {
long long res = val % m;
if (res < 0)
res += m;
return res;
}
int main(void) {
int n, m;
int impossible = 0;
stack<int> index_stack;
for (int i = 0; i < MAX_N; ++i) {
num_path[i] = -1;
}
scanf("%d %d", &n, &m);
for (int i = 0; i < m; ++i) {
int a;
scanf("%d", &a);
cannot_step[a] = 1;
if (cannot_step[a] == cannot_step[a - 1] == 1) {
impossible = 1;
}
}
if (impossible) {
printf("0\n");
return 0;
}
num_path[0] = 1;
num_path[1] = 1;
index_stack.push(n);
while (index_stack.empty() == 0) {
int index = index_stack.top();
if (index < 0) {
// 範囲外のため解決不要
index_stack.pop();
continue;
}
if (num_path[index] != -1) {
// 解決済み
index_stack.pop();
continue;
}
if (num_path[index - 1] == -1 && cannot_step[index - 1] == 0) {
// 解決必要
index_stack.push(index - 1);
}
if (num_path[index - 2] == -1 && cannot_step[index - 2] == 0) {
// 解決必要
index_stack.push(index - 2);
}
long long ans = 0;
if ((num_path[index - 1] != -1 || cannot_step[index - 1]) &&
(num_path[index - 2] != -1 || cannot_step[index - 2])) {
// 解決
if (cannot_step[index - 1] == 0) {
ans += num_path[index - 1];
ans = mod(ans, MOD);
}
if (cannot_step[index - 2] == 0) {
ans += num_path[index - 2];
ans = mod(ans, MOD);
}
num_path[index] = ans;
index_stack.pop();
}
}
printf("%lld\n", num_path[n]);
return 0;
}
| [] | 827,391 | 827,392 | u546618578 | cpp |
p03013 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
static const ll MOD = 1000000007;
int main() {
ll n, m;
cin >> n >> m;
vector<ll> a(n);
map<ll, ll> M;
for (int i = 0; i < m; i++) {
cin >> a[i];
M[a[i]] = 1;
}
vector<ll> dp(n + 2);
dp[0] = 0;
dp[1] = 1;
if (M[1] == 1 && M[2] == 1) {
cout << 0 << endl;
return 0;
}
for (int i = 2; i <= n + 1; i++) {
if (M[i - 1]) {
dp[i] = 0;
continue;
}
if (dp[i - 1] == 0 && dp[i - 2] == 0) {
cout << 0 << endl;
return 0;
}
// if (i - 1 != 3) { dp[i] += dp[i - 1]; }
// if (i - 2 != 3) { dp[i] += dp[i - 2]; }
dp[i] = dp[i - 1] + dp[i - 2];
}
cout << dp[n + 1] % MOD << endl;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
static const ll MOD = 1000000007;
int main() {
ll n, m;
cin >> n >> m;
vector<ll> a(n);
map<ll, ll> M;
for (int i = 0; i < m; i++) {
cin >> a[i];
M[a[i]] = 1;
}
vector<ll> dp(n + 2);
dp[0] = 0;
dp[1] = 1;
if (M[1] == 1 && M[2] == 1) {
cout << 0 << endl;
return 0;
}
for (int i = 2; i <= n + 1; i++) {
if (M[i - 1]) {
dp[i] = 0;
continue;
}
if (dp[i - 1] == 0 && dp[i - 2] == 0) {
cout << 0 << endl;
return 0;
}
// if (i - 1 != 3) { dp[i] += dp[i - 1]; }
// if (i - 2 != 3) { dp[i] += dp[i - 2]; }
dp[i] = (dp[i - 1]) % MOD + dp[i - 2] % MOD;
}
cout << dp[n + 1] % MOD << endl;
} | [
"assignment.change"
] | 827,438 | 827,439 | u881599732 | cpp |
p03014 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
const int M = 2001;
int L[M][M] = {0}, R[M][M] = {0}, U[M][M] = {0}, D[M][M] = {0};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int h, w;
cin >> h >> w;
vector<string> S(h);
rep(i, h) cin >> S[i];
// 上下・左右方向の累積和を求めておく
for (int y = 0; y < h; y++) {
int cur = 0;
for (int x = 0; x < w; x++) {
if (S[y][x] == '#')
cur = 0;
else
cur++;
L[y][x] = cur;
}
}
for (int y = 0; y < h; y++) {
int cur = 0;
for (int x = w - 1; x >= 0; x--) {
if (S[y][x] == '#')
cur = 0;
else
cur++;
R[y][x] = cur;
}
}
for (int x = 0; x < w; x++) {
int cur = 0;
for (int y = 0; y < h; y++) {
if (S[y][x] == '#')
cur = 0;
else
cur++;
U[y][x] = cur;
}
}
for (int x = 0; x < w; x++) {
int cur = 0;
for (int y = h - 1; y > 0; y--) {
if (S[y][x] == '#')
cur = 0;
else
cur++;
D[y][x] = cur;
}
}
// 全探索
int ans = 0;
rep(i, h) {
rep(j, w) {
if (S[i][j] == '#')
continue;
int t = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3;
ans = max(ans, t);
}
}
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
const int M = 2001;
int L[M][M] = {0}, R[M][M] = {0}, U[M][M] = {0}, D[M][M] = {0};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int h, w;
cin >> h >> w;
vector<string> S(h);
rep(i, h) cin >> S[i];
// 上下・左右方向の累積和を求めておく
for (int y = 0; y < h; y++) {
int cur = 0;
for (int x = 0; x < w; x++) {
if (S[y][x] == '#')
cur = 0;
else
cur++;
L[y][x] = cur;
}
}
for (int y = 0; y < h; y++) {
int cur = 0;
for (int x = w - 1; x >= 0; x--) {
if (S[y][x] == '#')
cur = 0;
else
cur++;
R[y][x] = cur;
}
}
for (int x = 0; x < w; x++) {
int cur = 0;
for (int y = 0; y < h; y++) {
if (S[y][x] == '#')
cur = 0;
else
cur++;
U[y][x] = cur;
}
}
for (int x = 0; x < w; x++) {
int cur = 0;
for (int y = h - 1; y >= 0; y--) {
if (S[y][x] == '#')
cur = 0;
else
cur++;
D[y][x] = cur;
}
}
// 全探索
int ans = 0;
rep(i, h) {
rep(j, w) {
if (S[i][j] == '#')
continue;
int t = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3;
ans = max(ans, t);
}
}
cout << ans << endl;
} | [
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 827,442 | 827,443 | u989306199 | cpp |
p03014 | #include <bits/stdc++.h>
using namespace std;
const int N = 2010;
char C[N][N];
int A[N][N];
int B[N][N];
int X[N][N];
int Y[N][N];
int h, w;
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cin >> h >> w;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
cin >> C[i][j];
}
}
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if (C[i][j] == '#')
A[i][j] = 0;
else {
if (j > 0)
A[i][j] = A[i][j - 1] + 1;
else
A[i][j] = 1;
}
}
}
for (int i = 0; i < h; i++) {
for (int j = w - 1; j >= 0; j--) {
if (C[i][j] == '#')
B[i][j] = 0;
else {
if (j < w - 1)
B[i][j] = B[i][j + 1] + 1;
else
B[i][j] = 1;
}
}
}
for (int i = 0; i < w; i++) {
for (int j = 0; j < h; j++) {
if (C[j][i] == '#')
X[j][i] = 0;
else {
if (j > 0)
X[j][i] = X[j - 1][i] + 1;
else
X[j][i] = 1;
}
}
}
for (int i = 0; i < w; i++) {
for (int j = h - 1; j >= 0; j--) {
if (C[j][i] == '#')
Y[j][i] = 0;
else {
if (j < h - 1)
Y[j][i] = Y[j + 1][i] + 1;
else
Y[j][i] = 1;
}
}
}
/*
for(int i = 0; i < h; i++){
for(int j = 0; j < w; j++){
cout << Y[i][j] << ' ';
}
cout << endl;
}
*/
int ans = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if (C[i][j] == '#')
continue;
int cnt = 1;
if (j != 0 and j != w - 1) {
cnt += A[i][j - 1] + B[i][j + 1];
} else if (j == 0 and j != w - 1) {
cnt += B[i][j + 1];
} else if (j != 0 and j == w - 1) {
cnt += A[i][j - 1];
}
if (i != 0 and i != h - 1) {
cnt += X[i - 1][j] + Y[i + 1][j];
} else if (i == 0 and j != h - 1) {
cnt += Y[i + 1][j];
} else if (i != 0 and j == h - 1) {
cnt += X[i - 1][j];
}
ans = max(ans, cnt);
}
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
const int N = 2010;
char C[N][N];
int A[N][N];
int B[N][N];
int X[N][N];
int Y[N][N];
int h, w;
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cin >> h >> w;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
cin >> C[i][j];
}
}
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if (C[i][j] == '#')
A[i][j] = 0;
else {
if (j > 0)
A[i][j] = A[i][j - 1] + 1;
else
A[i][j] = 1;
}
}
}
for (int i = 0; i < h; i++) {
for (int j = w - 1; j >= 0; j--) {
if (C[i][j] == '#')
B[i][j] = 0;
else {
if (j < w - 1)
B[i][j] = B[i][j + 1] + 1;
else
B[i][j] = 1;
}
}
}
for (int i = 0; i < w; i++) {
for (int j = 0; j < h; j++) {
if (C[j][i] == '#')
X[j][i] = 0;
else {
if (j > 0)
X[j][i] = X[j - 1][i] + 1;
else
X[j][i] = 1;
}
}
}
for (int i = 0; i < w; i++) {
for (int j = h - 1; j >= 0; j--) {
if (C[j][i] == '#')
Y[j][i] = 0;
else {
if (j < h - 1)
Y[j][i] = Y[j + 1][i] + 1;
else
Y[j][i] = 1;
}
}
}
/*
for(int i = 0; i < h; i++){
for(int j = 0; j < w; j++){
cout << Y[i][j] << ' ';
}
cout << endl;
}
*/
int ans = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if (C[i][j] == '#')
continue;
int cnt = 1;
if (j != 0 and j != w - 1) {
cnt += A[i][j - 1] + B[i][j + 1];
} else if (j == 0 and j != w - 1) {
cnt += B[i][j + 1];
} else if (j != 0 and j == w - 1) {
cnt += A[i][j - 1];
}
if (i != 0 and i != h - 1) {
cnt += X[i - 1][j] + Y[i + 1][j];
} else if (i == 0 and i != h - 1) {
cnt += Y[i + 1][j];
} else if (i != 0 and i == h - 1) {
cnt += X[i - 1][j];
}
ans = max(ans, cnt);
}
}
cout << ans << endl;
return 0;
} | [
"identifier.change",
"control_flow.branch.if.condition.change"
] | 827,462 | 827,463 | u136869985 | cpp |
p03014 | /*Code by Codercjh*/
#include <bits/stdc++.h>
#define fr(i, a, b) for (int i = (a); i <= (b); ++i)
#define rf(i, a, b) for (int i = (a); i >= (b); --i)
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
using namespace std;
typedef long long ll;
template <typename T> inline void read(T &x) {
char c = getchar();
T fh = 0;
bool f = false;
while (!isdigit(c))
f |= (c == '-'), c = getchar();
while (isdigit(c))
fh = (fh << 1) + (fh << 3) + (c ^ 48), c = getchar();
x = f ? -fh : fh;
return;
}
char s[2005][2005];
int n, m, u[2005][2005], d[2005][2005], l[2005][2005], r[2005][2005], ans;
int main() {
read(n), read(m);
fr(i, 1, n) cin >> s[i] + 1;
fr(i, 1, n) fr(j, 1, m) if (s[i][j] == '.') {
u[i][j] = s[i - 1][j] == '.' ? u[i - 1][j] + 1 : 1;
l[i][j] = s[i][j - 1] == '.' ? l[i][j - 1] + 1 : 1;
}
rf(i, n, 1) rf(j, m, 1) if (s[i][j] == '.') {
d[i][j] = s[i + 1][j] == '.' ? d[i + 1][j] + 1 : 1;
r[i][j] = s[i][j + 1] == '.' ? r[i][j + 1] + 1 : 1;
}
fr(i, 1, n) fr(j, 1, n) ans =
max(ans, u[i][j] + d[i][j] + l[i][j] + r[i][j] - 3);
printf("%d\n", ans);
return 0;
} | /*Code by Codercjh*/
#include <bits/stdc++.h>
#define fr(i, a, b) for (int i = (a); i <= (b); ++i)
#define rf(i, a, b) for (int i = (a); i >= (b); --i)
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
using namespace std;
typedef long long ll;
template <typename T> inline void read(T &x) {
char c = getchar();
T fh = 0;
bool f = false;
while (!isdigit(c))
f |= (c == '-'), c = getchar();
while (isdigit(c))
fh = (fh << 1) + (fh << 3) + (c ^ 48), c = getchar();
x = f ? -fh : fh;
return;
}
char s[2005][2005];
int n, m, u[2005][2005], d[2005][2005], l[2005][2005], r[2005][2005], ans;
int main() {
read(n), read(m);
fr(i, 1, n) cin >> s[i] + 1;
fr(i, 1, n) fr(j, 1, m) if (s[i][j] == '.') {
u[i][j] = s[i - 1][j] == '.' ? u[i - 1][j] + 1 : 1;
l[i][j] = s[i][j - 1] == '.' ? l[i][j - 1] + 1 : 1;
}
rf(i, n, 1) rf(j, m, 1) if (s[i][j] == '.') {
d[i][j] = s[i + 1][j] == '.' ? d[i + 1][j] + 1 : 1;
r[i][j] = s[i][j + 1] == '.' ? r[i][j + 1] + 1 : 1;
}
fr(i, 1, n) fr(j, 1, m) ans =
max(ans, u[i][j] + d[i][j] + l[i][j] + r[i][j] - 3);
printf("%d\n", ans);
return 0;
} | [
"assignment.variable.change",
"identifier.change",
"call.arguments.change"
] | 827,469 | 827,470 | u132878214 | cpp |
p03014 | #include <bits/stdc++.h>
using namespace std;
int main() {
int h, w;
cin >> h >> w;
vector<string> s(h);
int light[h][w];
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
light[i][j] = 0;
}
}
for (int i = 0; i < h; i++) {
cin >> s[i];
}
for (int i = 0; i < h; i++) {
vector<int> memo(w);
int cnt = 0;
for (int j = 0; j < w; j++) {
if (s[i][j] == '.') {
cnt++;
} else {
memo[j] = cnt;
cnt = 0;
}
}
for (int j = w - 1; j >= 0; j--) {
if (memo[j] == 0 && s[i][j] != '#') {
light[i][j] += cnt;
} else {
cnt = memo[j];
}
}
}
for (int j = 0; j < h; j++) {
vector<int> memo(h);
int cnt = 0;
for (int i = 0; i < h; i++) {
if (s[i][j] == '.') {
cnt++;
} else {
memo[i] = cnt;
cnt = 0;
}
}
for (int i = h - 1; i >= 0; i--) {
if (memo[i] == 0 && s[i][j] != '#') {
light[i][j] += cnt;
} else {
cnt = memo[i];
}
}
}
// for (int i=0; i<h; i++) {
// for (int j=0; j<w; j++) {
// cout << light[i][j] << " ";
// }
// cout << endl;
//}
int ans = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
ans = max(ans, light[i][j]);
}
}
cout << ans - 1 << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int h, w;
cin >> h >> w;
vector<string> s(h);
int light[h][w];
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
light[i][j] = 0;
}
}
for (int i = 0; i < h; i++) {
cin >> s[i];
}
for (int i = 0; i < h; i++) {
vector<int> memo(w);
int cnt = 0;
for (int j = 0; j < w; j++) {
if (s[i][j] == '.') {
cnt++;
} else {
memo[j] = cnt;
cnt = 0;
}
}
for (int j = w - 1; j >= 0; j--) {
if (memo[j] == 0 && s[i][j] != '#') {
light[i][j] += cnt;
} else {
cnt = memo[j];
}
}
}
for (int j = 0; j < w; j++) {
vector<int> memo(h);
int cnt = 0;
for (int i = 0; i < h; i++) {
if (s[i][j] == '.') {
cnt++;
} else {
memo[i] = cnt;
cnt = 0;
}
}
for (int i = h - 1; i >= 0; i--) {
if (memo[i] == 0 && s[i][j] != '#') {
light[i][j] += cnt;
} else {
cnt = memo[i];
}
}
}
// for (int i=0; i<h; i++) {
// for (int j=0; j<w; j++) {
// cout << light[i][j] << " ";
// }
// cout << endl;
//}
int ans = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
ans = max(ans, light[i][j]);
}
}
cout << ans - 1 << endl;
return 0;
}
| [
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 827,476 | 827,477 | u749475370 | cpp |
p03014 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i, size) cin >> arr[i];
#define int long long
struct lights {
int height = -1, width = -1;
};
int H, W;
vector<string> fmap;
vector<vector<lights>> lmap;
bool is_within_map(int x, int y) { return 0 <= x && x < W && 0 <= y && y < H; }
void lamp_search(int x, int y) {
if (fmap[y][x] == '#')
return;
// search horizontally
if (lmap[y][x].width == -1) {
int left = x, right = x;
while (is_within_map(left - 1, y)) {
if (fmap[y][left - 1] == '#')
break;
left--;
}
while (is_within_map(right + 1, y)) {
if (fmap[y][right + 1] == '#')
break;
right++;
}
reps(i, left, right) { lmap[y][i].width = right - left + 1; }
}
// search vertically
if (lmap[y][x].height == -1) {
int top = y, bottom = y;
while (is_within_map(x, bottom - 1)) {
if (fmap[bottom - 1][x] == '#')
break;
bottom--;
}
while (is_within_map(x, top + 1)) {
if (fmap[top + 1][x] == '#')
break;
top++;
}
reps(i, bottom, top) { lmap[y][i].height = top - bottom + 1; }
}
}
signed main() {
cin >> H >> W;
fmap = vector<string>(H);
collect(fmap, H);
lmap = vector<vector<lights>>(H, vector<lights>(W));
rep(x, W) rep(y, H) { lamp_search(x, y); }
int maximum = -1;
rep(x, W) rep(y, H) {
maximum = max(maximum, lmap[y][x].height + lmap[y][x].width - 1);
}
cout << maximum << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i, size) cin >> arr[i];
#define int long long
struct lights {
int height = -1, width = -1;
};
int H, W;
vector<string> fmap;
vector<vector<lights>> lmap;
bool is_within_map(int x, int y) { return 0 <= x && x < W && 0 <= y && y < H; }
void lamp_search(int x, int y) {
if (fmap[y][x] == '#')
return;
// search horizontally
if (lmap[y][x].width == -1) {
int left = x, right = x;
while (is_within_map(left - 1, y)) {
if (fmap[y][left - 1] == '#')
break;
left--;
}
while (is_within_map(right + 1, y)) {
if (fmap[y][right + 1] == '#')
break;
right++;
}
reps(i, left, right) { lmap[y][i].width = right - left + 1; }
}
// search vertically
if (lmap[y][x].height == -1) {
int top = y, bottom = y;
while (is_within_map(x, bottom - 1)) {
if (fmap[bottom - 1][x] == '#')
break;
bottom--;
}
while (is_within_map(x, top + 1)) {
if (fmap[top + 1][x] == '#')
break;
top++;
}
reps(i, bottom, top) { lmap[i][x].height = top - bottom + 1; }
}
}
signed main() {
cin >> H >> W;
fmap = vector<string>(H);
collect(fmap, H);
lmap = vector<vector<lights>>(H, vector<lights>(W));
rep(x, W) rep(y, H) { lamp_search(x, y); }
int maximum = -1;
rep(x, W) rep(y, H) {
maximum = max(maximum, lmap[y][x].height + lmap[y][x].width - 1);
}
cout << maximum << endl;
return 0;
} | [
"assignment.variable.change",
"identifier.change",
"variable_access.subscript.index.change"
] | 827,480 | 827,481 | u979852867 | cpp |
p03014 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main() {
int h, w;
cin >> h >> w;
vector<string> s(h);
rep(i, h) cin >> s[i];
vector<vector<int>> cnt(h, vector<int>(w));
rep(i, h) {
vector<int> done(w);
rep(j, w) {
if (s[i][j] == '#')
continue;
if (done[j])
continue;
int l = 0;
while (j + l < w) {
if (s[i][j + l] == '#')
break;
l++;
}
rep(k, l) {
cnt[i][j + k] += l;
done[j + k] = 1;
}
}
}
rep(j, w) {
vector<int> done(h);
rep(i, h) {
if (s[i][j] == '#')
continue;
if (done[i])
continue;
int l = 0;
while (i + l < h) {
if (s[i + 1][j] == '#')
break;
l++;
}
rep(k, l) {
cnt[i + k][j] += l;
done[i + k] = 1;
}
}
}
int ans = 0;
rep(i, h) rep(j, w) ans = max(ans, cnt[i][j] - 1);
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main() {
int h, w;
cin >> h >> w;
vector<string> s(h);
rep(i, h) cin >> s[i];
vector<vector<int>> cnt(h, vector<int>(w));
rep(i, h) {
vector<int> done(w);
rep(j, w) {
if (s[i][j] == '#')
continue;
if (done[j])
continue;
int l = 0;
while (j + l < w) {
if (s[i][j + l] == '#')
break;
l++;
}
rep(k, l) {
cnt[i][j + k] += l;
done[j + k] = 1;
}
}
}
rep(j, w) {
vector<int> done(h);
rep(i, h) {
if (s[i][j] == '#')
continue;
if (done[i])
continue;
int l = 0;
while (i + l < h) {
if (s[i + l][j] == '#')
break;
l++;
}
rep(k, l) {
cnt[i + k][j] += l;
done[i + k] = 1;
}
}
}
int ans = 0;
rep(i, h) rep(j, w) ans = max(ans, cnt[i][j] - 1);
cout << ans << endl;
return 0;
}
| [
"identifier.replace.add",
"literal.replace.remove",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change"
] | 827,482 | 827,483 | u369813073 | cpp |
p03014 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main() {
int h, w;
cin >> h >> w;
vector<string> s(h);
rep(i, h) cin >> s[i];
vector<vector<int>> cnt(h, vector<int>(w));
rep(i, h) {
vector<int> done(w);
rep(j, w) {
if (s[i][j] == '#')
continue;
if (done[j])
continue;
int l = 0;
while (j + l < w) {
if (s[i][j + l] == '#')
break;
l++;
}
rep(k, l) {
cnt[i][j + k] += l;
done[j + k] = 1;
}
}
}
rep(j, w) {
vector<int> done(h);
rep(i, h) {
if (s[i][j] == '#')
continue;
if (done[i])
continue;
int l = 0;
while (i + l < w) {
if (s[i + 1][j] == '#')
break;
l++;
}
rep(k, l) {
cnt[i + k][j] += l;
done[i + k] = 1;
}
}
}
int ans = 0;
rep(i, h) rep(j, w) ans = max(ans, cnt[i][j] - 1);
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main() {
int h, w;
cin >> h >> w;
vector<string> s(h);
rep(i, h) cin >> s[i];
vector<vector<int>> cnt(h, vector<int>(w));
rep(i, h) {
vector<int> done(w);
rep(j, w) {
if (s[i][j] == '#')
continue;
if (done[j])
continue;
int l = 0;
while (j + l < w) {
if (s[i][j + l] == '#')
break;
l++;
}
rep(k, l) {
cnt[i][j + k] += l;
done[j + k] = 1;
}
}
}
rep(j, w) {
vector<int> done(h);
rep(i, h) {
if (s[i][j] == '#')
continue;
if (done[i])
continue;
int l = 0;
while (i + l < h) {
if (s[i + l][j] == '#')
break;
l++;
}
rep(k, l) {
cnt[i + k][j] += l;
done[i + k] = 1;
}
}
}
int ans = 0;
rep(i, h) rep(j, w) ans = max(ans, cnt[i][j] - 1);
cout << ans << endl;
return 0;
}
| [
"identifier.change",
"control_flow.loop.condition.change",
"identifier.replace.add",
"literal.replace.remove",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change"
] | 827,484 | 827,483 | u369813073 | cpp |
p03014 | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for (int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
ll N, T, W, H, M, C, V;
const int MAX = 510000;
const int MOD = 1e9;
const double PI = 3.14159265358979323846;
/*
long long fac[MAX], finv[MAX], inv[MAX];
vector<double> cx, cy, c;
ll MM = 1e12;
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;
}
std::vector<int> Eratosthenes(int n ){
std::vector<bool> is_prime( n + 1 );
for( int i = 0; i <= n; i++ ) is_prime[ i ] = true;
std::vector<int> P;
for( int i = 2; i <= n; i++ ){
if( is_prime[ i ] ){
for( int j = 2 * i; j <= n; j += i ){
is_prime[ j ] = false;
}
P.emplace_back( i );
}
}
return P;
}*/
int length(vector<int> v, int u, int HW) {
if (v.size() == 0)
return HW;
if (v[0] > u)
return v[0];
if (v[v.size() - 1] < u)
return HW - v[v.size() - 1] - 1;
else {
int i = lower_bound(ALL(v), u) - v.begin();
return v[i] - v[i - 1] - 1;
}
}
int main() {
cin >> H >> W;
vector<vector<int>> row(H);
vector<vector<int>> col(W);
vector<vector<int>> ok(H, vector<int>(W, 0));
string str;
REP(i, H) {
cin >> str;
REP(j, W) {
if (str[j] == '#') {
ok[i][j] = 1;
row[i].push_back(j);
col[j].push_back(i);
}
}
}
int ans = 0;
REP(i, H) {
REP(j, W) {
if (ok[i][j])
continue;
int cnd = length(row[i], j, H) + length(col[j], i, W);
ans = max(ans, cnd - 3);
}
}
cout << ans;
return 0;
}
| #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for (int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
ll N, T, W, H, M, C, V;
const int MAX = 510000;
const int MOD = 1e9;
const double PI = 3.14159265358979323846;
/*
long long fac[MAX], finv[MAX], inv[MAX];
vector<double> cx, cy, c;
ll MM = 1e12;
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;
}
std::vector<int> Eratosthenes(int n ){
std::vector<bool> is_prime( n + 1 );
for( int i = 0; i <= n; i++ ) is_prime[ i ] = true;
std::vector<int> P;
for( int i = 2; i <= n; i++ ){
if( is_prime[ i ] ){
for( int j = 2 * i; j <= n; j += i ){
is_prime[ j ] = false;
}
P.emplace_back( i );
}
}
return P;
}*/
int length(vector<int> v, int u, int HW) {
if (v.size() == 0)
return HW;
if (v[0] > u)
return v[0];
if (v[v.size() - 1] < u)
return HW - v[v.size() - 1] - 1;
else {
int i = lower_bound(ALL(v), u) - v.begin();
return v[i] - v[i - 1] - 1;
}
}
int main() {
cin >> H >> W;
vector<vector<int>> row(H);
vector<vector<int>> col(W);
vector<vector<int>> ok(H, vector<int>(W, 0));
string str;
REP(i, H) {
cin >> str;
REP(j, W) {
if (str[j] == '#') {
ok[i][j] = 1;
row[i].push_back(j);
col[j].push_back(i);
}
}
}
int ans = 0;
REP(i, H) {
REP(j, W) {
if (ok[i][j])
continue;
int cnd = length(row[i], j, W) + length(col[j], i, H);
ans = max(ans, cnd - 1);
}
}
cout << ans;
return 0;
}
| [
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change",
"literal.number.change",
"assignment.value.change"
] | 827,487 | 827,488 | u178618463 | cpp |
p03014 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main() {
int h, w;
cin >> h >> w;
vector<string> s(h);
rep(i, h) cin >> s[i];
vector<vector<int>> cnt(h, vector<int>(w));
rep(i, h) {
vector<int> done(w);
rep(j, w) {
if (s[i][j] == '#')
continue;
if (done[j])
continue;
int l = 0;
while (j + l < w) {
if (s[i][j + l])
break;
l++;
}
rep(k, l) {
cnt[i][j + k] += l;
done[j + k] = 1;
}
}
}
rep(j, w) {
vector<int> done(h);
rep(i, h) {
if (s[i][j] == '#')
continue;
if (done[i])
continue;
int l = 0;
while (i + l < h) {
if (s[i + l][j] == '#')
break;
l++;
}
rep(k, l) {
cnt[i + k][j] += l;
done[i + k] = 1;
}
}
}
int ans = 0;
rep(i, w) {
rep(j, h) { ans = max(ans, cnt[j][i] - 1); }
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main() {
int h, w;
cin >> h >> w;
vector<string> s(h);
rep(i, h) cin >> s[i];
vector<vector<int>> cnt(h, vector<int>(w));
rep(i, h) {
vector<int> done(w);
rep(j, w) {
if (s[i][j] == '#')
continue;
if (done[j])
continue;
int l = 0;
while (j + l < w) {
if (s[i][j + l] == '#')
break;
l++;
}
rep(k, l) {
cnt[i][j + k] += l;
done[j + k] = 1;
}
}
}
rep(j, w) {
vector<int> done(h);
rep(i, h) {
if (s[i][j] == '#')
continue;
if (done[i])
continue;
int l = 0;
while (i + l < h) {
if (s[i + l][j] == '#')
break;
l++;
}
rep(k, l) {
cnt[i + k][j] += l;
done[i + k] = 1;
}
}
}
int ans = 0;
rep(i, w) {
rep(j, h) { ans = max(ans, cnt[j][i] - 1); }
}
cout << ans << endl;
}
| [
"control_flow.branch.if.condition.change"
] | 827,496 | 827,497 | u147556624 | cpp |
p03014 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main() {
int h, w;
cin >> h >> w;
vector<string> s(w);
rep(i, h) cin >> s[i];
vector<vector<int>> cnt(h, vector<int>(w));
rep(i, h) {
vector<int> done(w);
rep(j, w) {
if (s[i][j] == '#')
continue;
if (done[j])
continue;
int l = 0;
while (j + l < w) {
if (s[i][j + l])
break;
l++;
}
rep(k, l) {
cnt[i][j + k] += l;
done[j + k] = 1;
}
}
}
rep(j, w) {
vector<int> done(h);
rep(i, h) {
if (s[i][j] == '#')
continue;
if (done[i])
continue;
int l = 0;
while (i + l < h) {
if (s[i + l][j] == '#')
break;
l++;
}
rep(k, l) {
cnt[i + k][j] += l;
done[i + k] = 1;
}
}
}
int ans = 0;
rep(i, w) {
rep(j, h) { ans = max(ans, cnt[j][i] - 1); }
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main() {
int h, w;
cin >> h >> w;
vector<string> s(h);
rep(i, h) cin >> s[i];
vector<vector<int>> cnt(h, vector<int>(w));
rep(i, h) {
vector<int> done(w);
rep(j, w) {
if (s[i][j] == '#')
continue;
if (done[j])
continue;
int l = 0;
while (j + l < w) {
if (s[i][j + l] == '#')
break;
l++;
}
rep(k, l) {
cnt[i][j + k] += l;
done[j + k] = 1;
}
}
}
rep(j, w) {
vector<int> done(h);
rep(i, h) {
if (s[i][j] == '#')
continue;
if (done[i])
continue;
int l = 0;
while (i + l < h) {
if (s[i + l][j] == '#')
break;
l++;
}
rep(k, l) {
cnt[i + k][j] += l;
done[i + k] = 1;
}
}
}
int ans = 0;
rep(i, w) {
rep(j, h) { ans = max(ans, cnt[j][i] - 1); }
}
cout << ans << endl;
}
| [
"control_flow.branch.if.condition.change"
] | 827,498 | 827,497 | u147556624 | cpp |
p03014 | #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
int H, W;
cin >> H >> W;
vector<string> S(H);
for (int i = 0; i < H; i++)
cin >> S[i];
int ans = 0;
vector<vector<int>> U(H, vector<int>(W)), D(H, vector<int>(W)),
L(H, vector<int>(W)), R(H, vector<int>(W));
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
if (j == 0) {
if (S[i][j] == '.')
L[i][j] = 1;
else
L[i][j] = 0;
} else {
if (S[i][j] == '.')
L[i][j] = L[i][j - 1] + 1;
else
S[i][j] = 0;
}
if (i == 0) {
if (S[i][j] == '.')
U[i][j] = 1;
else
U[i][j] = 0;
} else {
if (S[i][j] == '.')
U[i][j] = U[i - 1][j] + 1;
else
U[i][j] = 0;
}
}
}
for (int i = H - 1; i >= 0; i--) {
for (int j = W - 1; j >= 0; j--) {
if (j == W - 1) {
if (S[i][j] == '.')
R[i][j] = 1;
else
R[i][j] = 0;
} else {
if (S[i][j] == '.')
R[i][j] = R[i][j + 1] + 1;
else
R[i][j] = 0;
}
if (i == H - 1) {
if (S[i][j] == '.')
D[i][j] = 1;
else
D[i][j] = 0;
} else {
if (S[i][j] == '.')
D[i][j] = D[i + 1][j] + 1;
else
D[i][j] = 0;
}
}
}
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
int u = U[i][j], d = D[i][j], l = L[i][j], r = R[i][j];
if (u > 0)
u--;
if (d > 0)
d--;
if (l > 0)
r--;
if (r > 0)
u--;
ans = max(ans, u + d + r + l + 1);
// cout << i << " " << j << " " << U[i][j]+D[i][j]+R[i][j]+L[i][j]-4 <<
// endl;
}
}
cout << ans << endl;
} | #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
int H, W;
cin >> H >> W;
vector<string> S(H);
for (int i = 0; i < H; i++)
cin >> S[i];
int ans = 0;
vector<vector<int>> U(H, vector<int>(W)), D(H, vector<int>(W)),
L(H, vector<int>(W)), R(H, vector<int>(W));
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
if (j == 0) {
if (S[i][j] == '.')
L[i][j] = 1;
else
L[i][j] = 0;
} else {
if (S[i][j] == '.')
L[i][j] = L[i][j - 1] + 1;
else
S[i][j] = 0;
}
if (i == 0) {
if (S[i][j] == '.')
U[i][j] = 1;
else
U[i][j] = 0;
} else {
if (S[i][j] == '.')
U[i][j] = U[i - 1][j] + 1;
else
U[i][j] = 0;
}
}
}
for (int i = H - 1; i >= 0; i--) {
for (int j = W - 1; j >= 0; j--) {
if (j == W - 1) {
if (S[i][j] == '.')
R[i][j] = 1;
else
R[i][j] = 0;
} else {
if (S[i][j] == '.')
R[i][j] = R[i][j + 1] + 1;
else
R[i][j] = 0;
}
if (i == H - 1) {
if (S[i][j] == '.')
D[i][j] = 1;
else
D[i][j] = 0;
} else {
if (S[i][j] == '.')
D[i][j] = D[i + 1][j] + 1;
else
D[i][j] = 0;
}
}
}
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
int u = U[i][j], d = D[i][j], l = L[i][j], r = R[i][j];
if (u > 0)
u--;
if (d > 0)
d--;
if (l > 0)
l--;
if (r > 0)
r--;
ans = max(ans, u + d + r + l + 1);
// cout << i << " " << j << " " << U[i][j]+D[i][j]+R[i][j]+L[i][j]-4 <<
// endl;
}
}
cout << ans << endl;
} | [
"identifier.change"
] | 827,503 | 827,504 | u521973174 | cpp |
p03014 | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;
int getBlock(vector<int> &r, int fd) {
if (r.empty())
return -1;
auto tp = upper_bound(r.begin(), r.end(), fd);
if (tp == r.begin())
return -1;
tp--;
return *tp;
}
int getBlockB(vector<int> &r, int fd) {
if (r.empty())
return -1;
auto tp = lower_bound(r.begin(), r.end(), fd);
if (tp == r.end())
return -1;
return *tp;
}
void solve() {
int h, w;
cin >> h >> w;
vector<string> v(w);
for (int i = 0; i < h; i++)
cin >> v[i];
vector<int> row[h], col[w];
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if (v[i][j] == '#')
row[i].push_back(j);
}
}
for (int i = 0; i < w; i++) {
for (int j = 0; j < h; j++) {
if (v[j][i] == '#')
col[i].push_back(j);
}
}
int ans = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
int pans = 0;
if (v[i][j] == '#')
continue;
int block = getBlock(row[i], j - 1);
pans += j - block;
block = getBlock(col[j], i - 1);
pans += i - block;
block = getBlockB(row[i], j + 1);
if (block == -1)
block = w;
pans += block - j;
block = getBlockB(col[j], i + 1);
if (block == -1)
block = h;
pans += block - i;
ans = max(ans, pans - 3);
}
}
cout << ans << endl;
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
// cin >> t;
while (t--)
solve();
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;
int getBlock(vector<int> &r, int fd) {
if (r.empty())
return -1;
auto tp = upper_bound(r.begin(), r.end(), fd);
if (tp == r.begin())
return -1;
tp--;
return *tp;
}
int getBlockB(vector<int> &r, int fd) {
if (r.empty())
return -1;
auto tp = lower_bound(r.begin(), r.end(), fd);
if (tp == r.end())
return -1;
return *tp;
}
void solve() {
int h, w;
cin >> h >> w;
vector<string> v(h);
for (int i = 0; i < h; i++)
cin >> v[i];
vector<int> row[h], col[w];
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if (v[i][j] == '#')
row[i].push_back(j);
}
}
for (int i = 0; i < w; i++) {
for (int j = 0; j < h; j++) {
if (v[j][i] == '#')
col[i].push_back(j);
}
}
int ans = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
int pans = 0;
if (v[i][j] == '#')
continue;
int block = getBlock(row[i], j - 1);
pans += j - block;
block = getBlock(col[j], i - 1);
pans += i - block;
block = getBlockB(row[i], j + 1);
if (block == -1)
block = w;
pans += block - j;
block = getBlockB(col[j], i + 1);
if (block == -1)
block = h;
pans += block - i;
ans = max(ans, pans - 3);
}
}
cout << ans << endl;
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
// cin >> t;
while (t--)
solve();
return 0;
} | [] | 827,523 | 827,524 | u845356047 | cpp |
p03014 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int h, w;
cin >> h >> w;
string s[h];
for (int i = 0; i < h; i++)
cin >> s[i];
int l[h][w]{}, r[h][w]{}, u[h][w]{}, d[h][w]{};
for (int i = 0; i < h; i++)
for (int j = 1; j < w; j++)
if (s[i][j - 1] == '.' && s[i][j] == '.')
l[i][j] = l[i][j - 1] + 1;
for (int i = 0; i < h; i++)
for (int j = w - 2; j >= 0; j++)
if (s[i][j + 1] == '.' && s[i][j] == '.')
r[i][j] = r[i][j + 1] + 1;
for (int i = 0; i < w; i++)
for (int j = 1; j < h; j++)
if (s[j - 1][i] == '.' && s[j][i] == '.')
u[j][i] = u[j - 1][i] + 1;
for (int i = 0; i < w; i++)
for (int j = h - 2; j >= 0; j++)
if (s[j + 1][i] == '.' && s[j][i] == '.')
d[j][i] = d[j + 1][i] + 1;
int mx = 0;
for (int i = 0; i < h; i++)
for (int j = 0; j < w; j++)
if (s[i][j] == '.')
mx = max(mx, l[i][j] + r[i][j] + u[i][j] + d[i][j] + 1);
cout << mx << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int h, w;
cin >> h >> w;
string s[h];
for (int i = 0; i < h; i++)
cin >> s[i];
int l[h][w]{}, r[h][w]{}, u[h][w]{}, d[h][w]{};
for (int i = 0; i < h; i++)
for (int j = 1; j < w; j++)
if (s[i][j - 1] == '.' && s[i][j] == '.')
l[i][j] = l[i][j - 1] + 1;
for (int i = 0; i < h; i++)
for (int j = w - 2; j >= 0; j--)
if (s[i][j + 1] == '.' && s[i][j] == '.')
r[i][j] = r[i][j + 1] + 1;
for (int i = 0; i < w; i++)
for (int j = 1; j < h; j++)
if (s[j - 1][i] == '.' && s[j][i] == '.')
u[j][i] = u[j - 1][i] + 1;
for (int i = 0; i < w; i++)
for (int j = h - 2; j >= 0; j--)
if (s[j + 1][i] == '.' && s[j][i] == '.')
d[j][i] = d[j + 1][i] + 1;
int mx = 0;
for (int i = 0; i < h; i++)
for (int j = 0; j < w; j++)
if (s[i][j] == '.')
mx = max(mx, l[i][j] + r[i][j] + u[i][j] + d[i][j] + 1);
cout << mx << endl;
return 0;
} | [] | 827,538 | 827,539 | u804999113 | cpp |
p03014 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int h, w;
cin >> h >> w;
string s[h];
for (int i = 0; i < h; i++)
cin >> s[i];
int l[h][w]{}, r[h][w]{}, u[h][w]{}, d[h][w]{};
for (int i = 0; i < h; i++)
for (int j = 1; j < w; j++)
if (s[i][j - 1] == '.' && s[i][j] == '.')
l[i][j] = l[i][j - 1] + 1;
for (int i = 0; i < h; i++)
for (int j = w - 2; j >= 0; j++)
if (s[i][j + 1] == '.' && s[i][j] == '.')
r[i][j] = r[i][j + 1] + 1;
for (int i = 0; i < w; i++)
for (int j = 1; j < h; j++)
if (s[j - 1][i] == '.' && s[j][i] == '.')
u[j][i] = u[j - 1][i] + 1;
for (int i = 0; i < w; i++)
for (int j = h - 2; j >= 0; j++)
if (s[j + 1][i] == '.' && s[j][i] == '.')
d[j][i] = d[j + 1][i] + 1;
int mx = 0;
for (int i = 0; i < h; i++)
for (int j = 0; j < w; j++)
if (s[i][j] == '.')
mx = max(mx, l[i][j] + r[i][j] + u[i][j] + d[i][j] + 1);
cout << mx << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int h, w;
cin >> h >> w;
string s[h];
for (int i = 0; i < h; i++)
cin >> s[i];
int l[h][w]{}, r[h][w]{}, u[h][w]{}, d[h][w]{};
for (int i = 0; i < h; i++)
for (int j = 1; j < w; j++)
if (s[i][j - 1] == '.' && s[i][j] == '.')
l[i][j] = l[i][j - 1] + 1;
for (int i = 0; i < h; i++)
for (int j = w - 2; j >= 0; j--)
if (s[i][j + 1] == '.' && s[i][j] == '.')
r[i][j] = r[i][j + 1] + 1;
for (int i = 0; i < w; i++)
for (int j = 1; j < h; j++)
if (s[j - 1][i] == '.' && s[j][i] == '.')
u[j][i] = u[j - 1][i] + 1;
for (int i = 0; i < w; i++)
for (int j = h - 2; j >= 0; j--)
if (s[j + 1][i] == '.' && s[j][i] == '.')
d[j][i] = d[j + 1][i] + 1;
int mx = 0;
for (int i = 0; i < h; i++)
for (int j = 0; j < w; j++)
if (s[i][j] == '.')
mx = max(mx, l[i][j] + r[i][j] + u[i][j] + d[i][j] + 1);
cout << mx << endl;
return 0;
} | [] | 827,538 | 827,540 | u804999113 | cpp |
p03014 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef int _loop_int;
#define REP(i, n) for (_loop_int i = 0; i < (_loop_int)(n); ++i)
#define FOR(i, a, b) for (_loop_int i = (_loop_int)(a); i < (_loop_int)(b); ++i)
#define FORR(i, a, b) \
for (_loop_int i = (_loop_int)(b)-1; i >= (_loop_int)(a); --i)
#define DEBUG(x) cout << #x << ": " << x << endl
#define DEBUG2(x, y) cout << #x << ": " << x << " " << #y << ": " << y << endl
#define DEBUG_VEC(v) \
cout << #v << ":"; \
REP(i, v.size()) cout << " " << v[i]; \
cout << endl
#define DEBUG_ARR(v, n) \
cout << #v << ":"; \
REP(i, n) cout << " " << v[i]; \
cout << endl
#define ALL(a) (a).begin(), (a).end()
const ll MOD = 1000000007ll;
#define FIX(a) ((a) % MOD + MOD) % MOD
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> void DEBUG_DP(T *viewdp, int ilen, int jlen) {
REP(i, ilen) {
REP(j, jlen) {
if (viewdp[i][j] != -1)
printf("[% 4d]", viewdp[i][j]);
else
printf("[ ]");
}
puts("");
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int h, w;
cin >> h >> w;
vector<string> m(h + 1);
REP(i, h) {
cin >> m[i];
m[i] += "#";
}
vector<vi> cs(h + 1, vi(w + 2, 0));
// yoko
REP(i, h) REP(j, w) {
if (m[i][j] == '.') {
cs[i][j + 1] = cs[i][j] + 1;
}
}
// tate
int ans = 0;
FORR(j, 0, w) {
int yokomx = 1;
int tatecnt = 0;
REP(i, h) {
if (cs[i][j] != 0)
chmax(cs[i][j], cs[i][j + 1]);
chmax(yokomx, cs[i][j]);
if (m[i][j] == '.') {
tatecnt += 1;
} else {
ans = max(ans, tatecnt + yokomx - 1);
tatecnt = 0;
yokomx = 1;
}
// DEBUG2(tatecnt, yokomx);
// DEBUG(ans);
}
ans = max(ans, tatecnt + yokomx - 1);
}
// REP(ji,h){
// DEBUG_VEC(cs[ji]);
// }
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef int _loop_int;
#define REP(i, n) for (_loop_int i = 0; i < (_loop_int)(n); ++i)
#define FOR(i, a, b) for (_loop_int i = (_loop_int)(a); i < (_loop_int)(b); ++i)
#define FORR(i, a, b) \
for (_loop_int i = (_loop_int)(b)-1; i >= (_loop_int)(a); --i)
#define DEBUG(x) cout << #x << ": " << x << endl
#define DEBUG2(x, y) cout << #x << ": " << x << " " << #y << ": " << y << endl
#define DEBUG_VEC(v) \
cout << #v << ":"; \
REP(i, v.size()) cout << " " << v[i]; \
cout << endl
#define DEBUG_ARR(v, n) \
cout << #v << ":"; \
REP(i, n) cout << " " << v[i]; \
cout << endl
#define ALL(a) (a).begin(), (a).end()
const ll MOD = 1000000007ll;
#define FIX(a) ((a) % MOD + MOD) % MOD
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> void DEBUG_DP(T *viewdp, int ilen, int jlen) {
REP(i, ilen) {
REP(j, jlen) {
if (viewdp[i][j] != -1)
printf("[% 4d]", viewdp[i][j]);
else
printf("[ ]");
}
puts("");
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int h, w;
cin >> h >> w;
vector<string> m(h + 1);
REP(i, h) {
cin >> m[i];
m[i] += "#";
}
vector<vi> cs(h + 1, vi(w + 2, 0));
// yoko
REP(i, h) REP(j, w) {
if (m[i][j] == '.') {
cs[i][j + 1] = cs[i][j] + 1;
}
}
// tate
int ans = 0;
FORR(j, 1, w + 1) {
int yokomx = 1;
int tatecnt = 0;
REP(i, h) {
// DEBUG2(i,j);
if (cs[i][j] != 0)
chmax(cs[i][j], cs[i][j + 1]);
chmax(yokomx, cs[i][j]);
if (m[i][j - 1] == '.') {
tatecnt += 1;
} else {
ans = max(ans, tatecnt + yokomx - 1);
tatecnt = 0;
yokomx = 1;
}
// DEBUG2(tatecnt, yokomx);
// DEBUG(ans);
}
ans = max(ans, tatecnt + yokomx - 1);
}
// REP(ji,h){
// DEBUG_VEC(cs[ji]);
// }
cout << ans << endl;
return 0;
} | [
"literal.number.change",
"call.arguments.change",
"control_flow.branch.if.condition.change"
] | 827,547 | 827,548 | u568353080 | cpp |
p03014 | #include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
using lint = long long;
int main() {
lint h, w;
scanf("%lld", &h);
scanf("%lld", &w);
std::vector<std::vector<lint>> maze(h, std::vector<lint>(w, 0));
std::vector<std::vector<lint>> lit_h(h, std::vector<lint>(w, 0));
std::vector<std::vector<lint>> lit_v(h, std::vector<lint>(w, 0));
for (int i = 0; i < h; ++i) {
std::string s;
std::cin >> s;
for (int j = 0; j < w; ++j) {
if (s[j] == '#')
maze[i][j] = 1;
}
}
for (int i = 0; i < h; ++i) {
lint stream = 0;
std::vector<lint> write_cells;
for (int j = 0; j <= w; ++j) {
if (j == w || maze[i][j] == 1) {
for (auto write = write_cells.begin(); write != write_cells.end();
write++) {
lit_h[i][*write] = stream;
}
stream = 0;
write_cells.clear();
} else {
stream++;
write_cells.push_back(j);
}
}
}
for (int j = 0; j < w; ++j) {
lint stream = 0;
std::vector<lint> write_cells;
for (int i = 0; i <= h; ++i) {
if (i == h || maze[i][j] == 1) {
for (auto write = write_cells.begin(); write != write_cells.end();
write++) {
lit_v[*write][j] = stream;
}
stream = 0;
write_cells.clear();
} else {
stream++;
write_cells.push_back(i);
}
}
}
lint ans = 0;
for (int i = 0; i < h; ++i) {
for (int j = 0; j <= w; ++j) {
lint cand = lit_h[i][j] + lit_v[i][j] - 1;
ans = std::max(ans, cand);
}
}
printf("%lld", ans);
return 0;
}
| #include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
using lint = long long;
int main() {
lint h, w;
scanf("%lld", &h);
scanf("%lld", &w);
std::vector<std::vector<lint>> maze(h, std::vector<lint>(w, 0));
std::vector<std::vector<lint>> lit_h(h, std::vector<lint>(w, 0));
std::vector<std::vector<lint>> lit_v(h, std::vector<lint>(w, 0));
for (int i = 0; i < h; ++i) {
std::string s;
std::cin >> s;
for (int j = 0; j < w; ++j) {
if (s[j] == '#')
maze[i][j] = 1;
}
}
for (int i = 0; i < h; ++i) {
lint stream = 0;
std::vector<lint> write_cells;
for (int j = 0; j <= w; ++j) {
if (j == w || maze[i][j] == 1) {
for (auto write = write_cells.begin(); write != write_cells.end();
write++) {
lit_h[i][*write] = stream;
}
stream = 0;
write_cells.clear();
} else {
stream++;
write_cells.push_back(j);
}
}
}
for (int j = 0; j < w; ++j) {
lint stream = 0;
std::vector<lint> write_cells;
for (int i = 0; i <= h; ++i) {
if (i == h || maze[i][j] == 1) {
for (auto write = write_cells.begin(); write != write_cells.end();
write++) {
lit_v[*write][j] = stream;
}
stream = 0;
write_cells.clear();
} else {
stream++;
write_cells.push_back(i);
}
}
}
lint ans = 0;
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
lint cand = lit_h[i][j] + lit_v[i][j] - 1;
ans = std::max(ans, cand);
}
}
printf("%lld", ans);
return 0;
}
| [
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.off_by_one",
"expression.operation.binary.change"
] | 827,549 | 827,550 | u353402627 | cpp |
p03014 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
int main() {
ll h, w;
cin >> h >> w;
vector<string> s(w);
rep(i, 0, h) cin >> s[i];
vector<vector<int>> pts(h, vector<int>(w, 0));
rep(i, 0, h) {
char pre = s[i][0];
ll pi = 0;
rep(j, 1, w) {
if (pre != s[i][j]) {
if (pre == '.') {
rep(k, pi, j) { pts[i][k] += (j - pi); }
}
pre = s[i][j];
pi = j;
}
}
if (pre == '.') {
rep(k, pi, w) {
if (pts[i][k] != 0)
pts[i][k]--;
pts[i][k] += (w - pi);
}
}
}
// cerr << pts[2][5] << endl;
rep(i, 0, w) {
char pre = s[0][i];
ll pi = 0;
rep(j, 1, h) {
if (pre != s[j][i]) {
if (pre == '.') {
rep(k, pi, j) {
if (pts[k][i] != 0)
pts[k][i]--;
pts[k][i] += (j - pi);
}
}
pre = s[j][i];
pi = j;
}
}
if (pre == '.') {
rep(k, pi, h) {
if (pts[k][i] != 0)
pts[k][i]--;
pts[k][i] += (h - pi);
}
}
}
// cerr << pts[2][5] << endl;
int ans = 0;
rep(i, 0, h) {
rep(j, 0, w) { ans = max(ans, pts[i][j]); }
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
int main() {
ll h, w;
cin >> h >> w;
vector<string> s(h);
rep(i, 0, h) cin >> s[i];
vector<vector<int>> pts(h, vector<int>(w, 0));
rep(i, 0, h) {
char pre = s[i][0];
ll pi = 0;
rep(j, 1, w) {
if (pre != s[i][j]) {
if (pre == '.') {
rep(k, pi, j) { pts[i][k] += (j - pi); }
}
pre = s[i][j];
pi = j;
}
}
if (pre == '.') {
rep(k, pi, w) {
if (pts[i][k] != 0)
pts[i][k]--;
pts[i][k] += (w - pi);
}
}
}
rep(i, 0, w) {
char pre = s[0][i];
ll pi = 0;
rep(j, 1, h) {
if (pre != s[j][i]) {
if (pre == '.') {
rep(k, pi, j) {
if (pts[k][i] != 0)
pts[k][i]--;
pts[k][i] += (j - pi);
}
}
pre = s[j][i];
pi = j;
}
}
if (pre == '.') {
rep(k, pi, h) {
if (pts[k][i] != 0)
pts[k][i]--;
pts[k][i] += (h - pi);
}
}
}
int ans = 0;
rep(i, 0, h) {
rep(j, 0, w) { ans = max(ans, pts[i][j]); }
}
cout << ans << endl;
return 0;
} | [] | 827,573 | 827,574 | u893584578 | cpp |
p03014 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
int main() {
ll h, w;
cin >> h >> w;
vector<string> s(w);
rep(i, 0, h) cin >> s[i];
vector<vector<ll>> pts(h, vector<ll>(w, 0));
rep(i, 0, h) {
char pre = s[i][0];
ll pi = 0;
rep(j, 1, w) {
if (pre != s[i][j]) {
if (pre == '.') {
rep(k, pi, j) { pts[i][k] += (j - pi); }
}
pre = s[i][j];
pi = j;
}
}
if (pre == '.') {
rep(k, pi, w) {
if (pts[i][k] != 0)
pts[i][k]--;
pts[i][k] += (w - pi);
}
}
}
// cerr << pts[2][5] << endl;
rep(i, 0, w) {
char pre = s[0][i];
ll pi = 0;
rep(j, 1, h) {
if (pre != s[j][i]) {
if (pre == '.') {
rep(k, pi, j) {
if (pts[k][i] != 0)
pts[k][i]--;
pts[k][i] += (j - pi);
}
}
pre = s[j][i];
pi = j;
}
}
if (pre == '.') {
rep(k, pi, h) {
if (pts[k][i] != 0)
pts[k][i]--;
pts[k][i] += (h - pi);
}
}
}
// cerr << pts[2][5] << endl;
ll ans = 0;
rep(i, 0, h) {
rep(j, 0, w) { ans = max(ans, pts[i][j]); }
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
int main() {
ll h, w;
cin >> h >> w;
vector<string> s(h);
rep(i, 0, h) cin >> s[i];
vector<vector<int>> pts(h, vector<int>(w, 0));
rep(i, 0, h) {
char pre = s[i][0];
ll pi = 0;
rep(j, 1, w) {
if (pre != s[i][j]) {
if (pre == '.') {
rep(k, pi, j) { pts[i][k] += (j - pi); }
}
pre = s[i][j];
pi = j;
}
}
if (pre == '.') {
rep(k, pi, w) {
if (pts[i][k] != 0)
pts[i][k]--;
pts[i][k] += (w - pi);
}
}
}
rep(i, 0, w) {
char pre = s[0][i];
ll pi = 0;
rep(j, 1, h) {
if (pre != s[j][i]) {
if (pre == '.') {
rep(k, pi, j) {
if (pts[k][i] != 0)
pts[k][i]--;
pts[k][i] += (j - pi);
}
}
pre = s[j][i];
pi = j;
}
}
if (pre == '.') {
rep(k, pi, h) {
if (pts[k][i] != 0)
pts[k][i]--;
pts[k][i] += (h - pi);
}
}
}
int ans = 0;
rep(i, 0, h) {
rep(j, 0, w) { ans = max(ans, pts[i][j]); }
}
cout << ans << endl;
return 0;
} | [
"call.arguments.change",
"variable_declaration.type.change"
] | 827,575 | 827,574 | u893584578 | cpp |
p03014 | #include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <queue>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <stdio.h>
#include <string>
#include <vector>
#define cinf(n, x) \
for (int i = 0; i < n; i++) \
cin >> x[i];
#define pi pair<int, int>
using namespace std;
using ll = long long;
int main() {
int h, w;
cin >> h >> w;
char s[h][w];
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
cin >> s[i][j];
}
}
int u[h][w] = {}, d[h][w] = {}, r[h][w] = {}, l[h][w] = {};
for (int i = 0; i < h; i++) {
r[i][w - 1] = 0;
l[i][0] = 0;
for (int j = 1; j < w; j++) {
if (s[i][j] == '#' || s[i][j - 1] == '#')
l[i][j] = 0;
else
l[i][j] = l[i][j - 1] + 1;
}
for (int j = w - 2; j >= 0; j--) {
if (s[i][j] == '#' || s[i][j + 1] == '#')
r[i][j] = 0;
else
r[i][j] = r[i][j + 1] + 1;
}
}
for (int j = 0; j < w; j++) {
u[0][j] = 0;
d[h][j] = 0;
for (int i = 1; i < h; i++) {
if (s[i][j] == '#' || s[i + 1][j] == '#')
u[i][j] = 0;
else
u[i][j] = u[i - 1][j] + 1;
}
for (int i = h - 2; i >= 0; i--) {
if (s[i][j] == '#' || s[i - 1][j] == '#')
d[i][j] = 0;
else
d[i][j] = d[i + 1][j] + 1;
}
}
int ans = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
ans = max(ans, u[i][j] + r[i][j] + l[i][j] + d[i][j] + 1);
}
}
cout << ans;
return 0;
} | #include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <queue>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <stdio.h>
#include <string>
#include <vector>
#define cinf(n, x) \
for (int i = 0; i < n; i++) \
cin >> x[i];
#define pi pair<int, int>
using namespace std;
using ll = long long;
int main() {
int h, w;
cin >> h >> w;
char s[h][w];
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
cin >> s[i][j];
}
}
int u[h][w] = {}, d[h][w] = {}, r[h][w] = {}, l[h][w] = {};
for (int i = 0; i < h; i++) {
r[i][w - 1] = 0;
l[i][0] = 0;
for (int j = 1; j < w; j++) {
if (s[i][j] == '#' || s[i][j - 1] == '#')
l[i][j] = 0;
else
l[i][j] = l[i][j - 1] + 1;
}
for (int j = w - 2; j >= 0; j--) {
if (s[i][j] == '#' || s[i][j + 1] == '#')
r[i][j] = 0;
else
r[i][j] = r[i][j + 1] + 1;
}
}
for (int j = 0; j < w; j++) {
u[0][j] = 0;
d[h][j] = 0;
for (int i = 1; i < h; i++) {
if (s[i][j] == '#' || s[i - 1][j] == '#')
u[i][j] = 0;
else
u[i][j] = u[i - 1][j] + 1;
}
for (int i = h - 2; i >= 0; i--) {
if (s[i][j] == '#' || s[i + 1][j] == '#')
d[i][j] = 0;
else
d[i][j] = d[i + 1][j] + 1;
}
}
int ans = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
ans = max(ans, u[i][j] + r[i][j] + l[i][j] + d[i][j] + 1);
}
}
cout << ans;
return 0;
} | [
"misc.opposites",
"expression.operator.arithmetic.change",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change"
] | 827,576 | 827,577 | u139300044 | cpp |
p03014 | #include <bits/stdc++.h>
using namespace std;
int main() {
int h, w;
cin >> h >> w;
vector<vector<char>> s(h, vector<char>(w));
vector<vector<int>> yoko(h, vector<int>(1));
vector<vector<int>> tate(w, vector<int>(1));
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
cin >> s[i][j];
if (s[i][j] == '#') {
yoko[i].push_back(j + 1);
tate[j].push_back(i + 1);
}
}
yoko[i].push_back(w + 1);
}
for (int i = 0; i < w; i++)
tate[i].push_back(h + 1);
int x = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if (s[i][j] == '#')
continue;
int a = upper_bound(yoko[i].begin(), yoko[i].end(), i) - yoko[i].begin();
int b = upper_bound(tate[j].begin(), tate[j].end(), j) - tate[j].begin();
x = max(x, yoko[i][a] - yoko[i][a - 1] + tate[j][b] - tate[j][b - 1] - 3);
}
}
cout << x << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int h, w;
cin >> h >> w;
vector<vector<char>> s(h, vector<char>(w));
vector<vector<int>> yoko(h, vector<int>(1));
vector<vector<int>> tate(w, vector<int>(1));
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
cin >> s[i][j];
if (s[i][j] == '#') {
yoko[i].push_back(j + 1);
tate[j].push_back(i + 1);
}
}
yoko[i].push_back(w + 1);
}
for (int i = 0; i < w; i++)
tate[i].push_back(h + 1);
int x = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if (s[i][j] == '#')
continue;
int a = upper_bound(yoko[i].begin(), yoko[i].end(), j) - yoko[i].begin();
int b = upper_bound(tate[j].begin(), tate[j].end(), i) - tate[j].begin();
x = max(x, yoko[i][a] - yoko[i][a - 1] + tate[j][b] - tate[j][b - 1] - 3);
}
}
cout << x << endl;
return 0;
} | [
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 827,582 | 827,583 | u507850687 | cpp |
p03014 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i, s, f) for (ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))
int main() {
FAST int n, m;
cin >> n >> m;
vector<int> rows[n + 2];
vector<int> cols[m + 2];
int lastOR[n + 2];
int lastOC[m + 2];
mm(lastOR);
mm(lastOC);
string mat[n + 2];
string s = " ";
for (int i = 0; i < m + 2; i++) {
s += '#';
}
mat[0] = s;
mat[n + 1] = s;
for (int i = 1; i <= n; i++) {
cin >> mat[i];
mat[i] = '#' + mat[i];
mat[i] += '#';
}
for (int i = 0; i <= n + 1; i++) {
for (int j = 0; j <= m + 1; j++) {
if (mat[i][j] == '#') {
rows[i].pb(j);
cols[j].pb(i);
}
}
}
int ans = 0;
for (int i = 0; i <= n + 1; i++) {
for (int j = 0; j <= m + 1; j++) {
if (mat[i][j] == '.') {
int curr = j - lastOR[i] + i - lastOC[j] - 1;
int ind =
lower_bound(rows[i].begin(), rows[i].end(), j) - rows[i].begin();
if (rows[i].size() == ind) {
curr += m - j - 1;
} else {
ind = rows[i][ind];
curr += ind - j - 1;
}
ind = lower_bound(cols[j].begin(), cols[j].end(), i) - cols[j].begin();
if (ind == cols[j].size()) {
curr += n - i - 1;
} else {
ind = cols[j][ind];
curr += ind - i - 1;
}
ans = max(ans, curr);
} else {
lastOR[i] = j;
lastOR[j] = i;
}
}
}
cout << ans;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i, s, f) for (ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))
int main() {
FAST int n, m;
cin >> n >> m;
vector<int> rows[n + 2];
vector<int> cols[m + 2];
int lastOR[n + 2];
int lastOC[m + 2];
mm(lastOR);
mm(lastOC);
string mat[n + 2];
string s = " ";
for (int i = 0; i < m + 2; i++) {
s += '#';
}
mat[0] = s;
mat[n + 1] = s;
for (int i = 1; i <= n; i++) {
cin >> mat[i];
mat[i] = '#' + mat[i];
mat[i] += '#';
}
for (int i = 0; i <= n + 1; i++) {
for (int j = 0; j <= m + 1; j++) {
if (mat[i][j] == '#') {
rows[i].pb(j);
cols[j].pb(i);
}
}
}
int ans = 0;
for (int i = 0; i <= n + 1; i++) {
for (int j = 0; j <= m + 1; j++) {
if (mat[i][j] == '.') {
int curr = j - lastOR[i] + i - lastOC[j] - 1;
int ind =
lower_bound(rows[i].begin(), rows[i].end(), j) - rows[i].begin();
if (rows[i].size() == ind) {
curr += m - j - 1;
} else {
ind = rows[i][ind];
curr += ind - j - 1;
}
ind = lower_bound(cols[j].begin(), cols[j].end(), i) - cols[j].begin();
if (ind == cols[j].size()) {
curr += n - i - 1;
} else {
ind = cols[j][ind];
curr += ind - i - 1;
}
ans = max(ans, curr);
} else {
lastOR[i] = j;
lastOC[j] = i;
}
}
}
cout << ans;
return 0;
}
| [
"assignment.variable.change",
"identifier.change"
] | 827,584 | 827,585 | u021108615 | cpp |
p03014 | #include <bits/stdc++.h>
using namespace std;
/*2進数配列+1*/
vector<int> twoadd(vector<int> v, int N) {
v[N - 1] += 1;
int ind = N - 1;
int j = N - 1;
for (j = N - 1; j >= 1; j--) {
if (v[j] > 1) {
v[j - 1] += 1;
v[j] = 0;
}
}
return v;
}
/*フィボナッチ*/
long long fibonatti(long long d) {
long long count = 0;
long long f1 = 1;
long long f2 = 1; /*ここを変える*/
long long temp;
if (d == 1) {
count = f1;
} else if (d == 2) {
count = f2;
} else if (d == 0) {
count = 1;
} else {
for (int i = 0; i < d - 2; i++) {
temp = f1 + f2;
f1 = f2;
f2 = temp;
}
count = temp;
}
return count;
}
/*ここから*/
int main() {
int H, W;
cin >> H >> W;
vector<vector<int>> v(H, vector<int>(W));
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
char w;
cin >> w;
if (w == '#') {
v[i][j] = 1;
} else {
v[i][j] = 0;
}
}
}
int ans = 0;
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
int count = 0;
if (v[i][j] == 0) {
for (int k = i; k < H; k++) {
if (v[k][j] == 1) {
break;
}
count++;
}
for (int k = i; k >= 0; k--) {
if (v[k][j] == 1) {
break;
}
count++;
}
for (int k = j; k < W; k++) {
if (v[i][k] == 1) {
break;
}
count++;
}
for (int k = j; k >= 0; k--) {
if (v[i][k] == 1) {
break;
}
count++;
}
}
if (ans < count) {
ans = count;
}
if (ans == H + W - 1) {
break;
}
}
}
ans -= 3;
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
/*2進数配列+1*/
vector<int> twoadd(vector<int> v, int N) {
v[N - 1] += 1;
int ind = N - 1;
int j = N - 1;
for (j = N - 1; j >= 1; j--) {
if (v[j] > 1) {
v[j - 1] += 1;
v[j] = 0;
}
}
return v;
}
/*フィボナッチ*/
long long fibonatti(long long d) {
long long count = 0;
long long f1 = 1;
long long f2 = 1; /*ここを変える*/
long long temp;
if (d == 1) {
count = f1;
} else if (d == 2) {
count = f2;
} else if (d == 0) {
count = 1;
} else {
for (int i = 0; i < d - 2; i++) {
temp = f1 + f2;
f1 = f2;
f2 = temp;
}
count = temp;
}
return count;
}
/*ここから*/
int main() {
int H, W;
cin >> H >> W;
vector<vector<int>> v(H, vector<int>(W));
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
char w;
cin >> w;
if (w == '#') {
v[i][j] = 1;
} else {
v[i][j] = 0;
}
}
}
int ans = 0;
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
int count = 0;
if (v[i][j] == 0) {
for (int k = i; k < H; k++) {
if (v[k][j] == 1) {
break;
}
count++;
}
for (int k = i; k >= 0; k--) {
if (v[k][j] == 1) {
break;
}
count++;
}
for (int k = j; k < W; k++) {
if (v[i][k] == 1) {
break;
}
count++;
}
for (int k = j; k >= 0; k--) {
if (v[i][k] == 1) {
break;
}
count++;
}
}
if (ans < count) {
ans = count;
}
if (ans == H + W + 2) {
break;
}
}
}
ans -= 3;
cout << ans << endl;
} | [
"control_flow.loop.for.condition.change"
] | 827,586 | 827,587 | u770067864 | cpp |
p03014 | #include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
int main() {
int h, w;
cin >> h >> w;
vector<string> s(h);
rep(i, h) cin >> s[i];
vector<vector<int>> row_ptr(h, vector<int>(1, -1));
rep(i, h) {
rep(j, w) {
if (s[i][j] == '#')
row_ptr[i].push_back(j);
}
row_ptr[i].push_back(w);
}
vector<vector<int>> col_ptr(w, vector<int>(1, -1));
rep(i, w) {
rep(j, h) {
if (s[j][i] == '#')
col_ptr[i].push_back(j);
}
col_ptr[i].push_back(h);
}
int ans = 0;
rep(i, h) rep(j, w) {
if (s[i][j] == '#')
continue;
int tmp = 0;
/*
* row
*/
int l = 0, r = row_ptr[i].size() - 1;
while (l + 1 < r) {
int m = (l + r) / 2;
if (row_ptr[i][m] > j)
r = m;
else
l = m;
}
tmp += row_ptr[i][r] - row_ptr[i][l] - 1;
/*
* col
*/
l = 0;
r = col_ptr[j].size() - 1;
while (l + 1 < r) {
int m = (l + r) / 2;
if (col_ptr[j][m] > j)
r = m;
else
l = m;
}
tmp += col_ptr[j][r] - col_ptr[j][l] - 1;
ans = max(ans, tmp - 1);
}
cout << ans << endl;
}
| #include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
int main() {
int h, w;
cin >> h >> w;
vector<string> s(h);
rep(i, h) cin >> s[i];
vector<vector<int>> row_ptr(h, vector<int>(1, -1));
rep(i, h) {
rep(j, w) {
if (s[i][j] == '#')
row_ptr[i].push_back(j);
}
row_ptr[i].push_back(w);
}
vector<vector<int>> col_ptr(w, vector<int>(1, -1));
rep(i, w) {
rep(j, h) {
if (s[j][i] == '#')
col_ptr[i].push_back(j);
}
col_ptr[i].push_back(h);
}
int ans = 0;
rep(i, h) rep(j, w) {
if (s[i][j] == '#')
continue;
int tmp = 0;
/*
* row
*/
int l = 0, r = row_ptr[i].size() - 1;
while (l + 1 < r) {
int m = (l + r) / 2;
if (row_ptr[i][m] > j)
r = m;
else
l = m;
}
tmp += row_ptr[i][r] - row_ptr[i][l] - 1;
/*
* col
*/
l = 0;
r = col_ptr[j].size() - 1;
while (l + 1 < r) {
int m = (l + r) / 2;
if (col_ptr[j][m] > i)
r = m;
else
l = m;
}
tmp += col_ptr[j][r] - col_ptr[j][l] - 1;
ans = max(ans, tmp - 1);
}
cout << ans << endl;
}
| [
"identifier.change",
"control_flow.branch.if.condition.change"
] | 827,588 | 827,589 | u637220270 | cpp |
p03014 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(x) x.begin(), x.end()
typedef long long ll;
ll mod = 1000000007;
ll inf = 1e18;
int main() {
int h, w;
cin >> h >> w;
vector<string> s(h);
rep(i, h) cin >> s[i];
vector<vector<int>> l(h, vector<int>(w, -1));
int n = 0;
rep(j, w) {
rep(i, h) {
if (s[i][j] == '.') {
n++;
} else {
rep(k, n) l[i - k][j] += n;
n = 0;
}
if (i == h - 1) {
rep(k, n) l[i - k][j] += n;
n = 0;
}
}
}
rep(i, h) {
rep(j, w) {
if (s[i][j] == '.') {
n++;
} else {
rep(k, n) l[i][j - k] += n;
n = 0;
}
if (j == w - 1) {
rep(k, n) l[i][j - k] += n;
n = 0;
}
}
}
int ans = 0;
rep(i, h) { rep(j, w) ans = max(ans, l[i][j]); }
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(x) x.begin(), x.end()
typedef long long ll;
ll mod = 1000000007;
ll inf = 1e18;
int main() {
int h, w;
cin >> h >> w;
vector<string> s(h);
rep(i, h) cin >> s[i];
vector<vector<int>> l(h, vector<int>(w, -1));
int n = 0;
rep(j, w) {
rep(i, h) {
if (s[i][j] == '.') {
n++;
} else {
rep(k, n) l[i - k - 1][j] += n;
n = 0;
}
if (i == h - 1) {
rep(k, n) l[i - k][j] += n;
n = 0;
}
}
}
rep(i, h) {
rep(j, w) {
if (s[i][j] == '.') {
n++;
} else {
rep(k, n) l[i][j - k - 1] += n;
n = 0;
}
if (j == w - 1) {
rep(k, n) l[i][j - k] += n;
n = 0;
}
}
}
int ans = 0;
rep(i, h) {
rep(j, w) {
ans = max(ans, l[i][j]);
// cout << l[i][j];
// if(j!=w-1) cout << ' ';
// else cout << endl;
}
}
cout << ans << endl;
return 0;
} | [
"assignment.change"
] | 827,596 | 827,597 | u291332466 | cpp |
p03014 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define P pair<int, int>
char grid[2020][2020];
vector<int> bh[2020], bw[2020];
bool isOK(int index, int i, vector<int> &vec) {
if (vec[index] < i)
return 1;
else
return 0;
}
int nibutan(int i, vector<int> &vec) {
int left = 0, right = vec.size() - 1;
while (right - left > 1) {
int middle = (left + right) / 2;
if (isOK(middle, i, vec))
left = middle;
else
right = middle;
}
return vec[right] - vec[left] - 1;
}
int main() {
int h, w;
cin >> h >> w;
rep(i, h) rep(j, w) cin >> grid[i][j];
rep(i, h) {
bh[i].push_back(-1);
rep(j, w) {
if (grid[i][j] == '#')
bh[i].push_back(j);
}
bh[i].push_back(w);
}
rep(j, w) {
bw[j].push_back(-1);
rep(i, h) {
if (grid[i][j] == '#')
bw[j].push_back(i);
}
bw[j].push_back(h);
}
int ans = 0;
rep(hi, h) rep(wi, w) {
if (grid[hi][wi] == '#')
continue;
int H = nibutan(hi, bh[hi]), W = nibutan(wi, bw[wi]);
ans = max(ans, H + W - 1);
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define P pair<int, int>
char grid[2020][2020];
vector<int> bh[2020], bw[2020];
bool isOK(int index, int i, vector<int> &vec) {
if (vec[index] < i)
return 1;
else
return 0;
}
int nibutan(int i, vector<int> &vec) {
int left = 0, right = vec.size() - 1;
while (right - left > 1) {
int middle = (left + right) / 2;
if (isOK(middle, i, vec))
left = middle;
else
right = middle;
}
return vec[right] - vec[left] - 1;
}
int main() {
int h, w;
cin >> h >> w;
rep(i, h) rep(j, w) cin >> grid[i][j];
rep(i, h) {
bh[i].push_back(-1);
rep(j, w) {
if (grid[i][j] == '#')
bh[i].push_back(j);
}
bh[i].push_back(w);
}
rep(j, w) {
bw[j].push_back(-1);
rep(i, h) {
if (grid[i][j] == '#')
bw[j].push_back(i);
}
bw[j].push_back(h);
}
int ans = 0;
rep(hi, h) rep(wi, w) {
if (grid[hi][wi] == '#')
continue;
int H = nibutan(wi, bh[hi]), W = nibutan(hi, bw[wi]);
ans = max(ans, H + W - 1);
}
cout << ans << endl;
}
| [
"identifier.change",
"call.arguments.change"
] | 827,598 | 827,599 | u692550512 | cpp |
p03014 | #include <bits/stdc++.h>
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
using namespace std;
const int MOD = 1000000007;
int main() {
int h, w;
cin >> h >> w;
vector<string> s(h);
rep(i, h) { cin >> s[i]; }
vector<vector<int>> l(h + 2, vector<int>(w + 2, 0));
vector<vector<int>> r(h + 2, vector<int>(w + 2, 0));
vector<vector<int>> u(h + 2, vector<int>(w + 2, 0));
vector<vector<int>> d(h + 2, vector<int>(w + 2, 0));
for (int i = 1; i < h; i++) {
for (int j = 1; j < w; j++) {
if (s[i - 1][j - 1] == '#')
continue;
// int temp=l[i-1][j]+1;
l[i][j] = l[i][j - 1] + 1;
}
}
for (int i = h; i > 0; i--) {
for (int j = w; j > 0; j--) {
if (s[i - 1][j - 1] == '#')
continue;
r[i][j] = r[i][j + 1] + 1;
}
}
for (int j = 1; j < w; j++) {
for (int i = 1; i < h; i++) {
if (s[i - 1][j - 1] == '#')
continue;
u[i][j] = u[i - 1][j] + 1;
}
}
for (int j = w; j > 0; j--) {
for (int i = h; i > 0; i--) {
if (s[i - 1][j - 1] == '#')
continue;
d[i][j] = d[i + 1][j] + 1;
}
}
int ans = 0;
for (int i = 1; i < h + 1; i++) {
for (int j = 1; j < w + 1; j++) {
ans = max(ans, l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3);
}
}
cout << ans;
}
| #include <bits/stdc++.h>
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
using namespace std;
const int MOD = 1000000007;
int main() {
int h, w;
cin >> h >> w;
vector<string> s(h);
rep(i, h) { cin >> s[i]; }
vector<vector<int>> l(h + 2, vector<int>(w + 2, 0));
vector<vector<int>> r(h + 2, vector<int>(w + 2, 0));
vector<vector<int>> u(h + 2, vector<int>(w + 2, 0));
vector<vector<int>> d(h + 2, vector<int>(w + 2, 0));
for (int i = 1; i <= h; i++) {
for (int j = 1; j <= w; j++) {
if (s[i - 1][j - 1] == '#')
continue;
// int temp=l[i-1][j]+1;
l[i][j] = l[i][j - 1] + 1;
}
}
for (int i = h; i > 0; i--) {
for (int j = w; j > 0; j--) {
if (s[i - 1][j - 1] == '#')
continue;
r[i][j] = r[i][j + 1] + 1;
}
}
for (int j = 1; j <= w; j++) {
for (int i = 1; i <= h; i++) {
if (s[i - 1][j - 1] == '#')
continue;
u[i][j] = u[i - 1][j] + 1;
}
}
for (int j = w; j > 0; j--) {
for (int i = h; i > 0; i--) {
if (s[i - 1][j - 1] == '#')
continue;
d[i][j] = d[i + 1][j] + 1;
}
}
int ans = 0;
for (int i = 1; i < h + 1; i++) {
for (int j = 1; j < w + 1; j++) {
ans = max(ans, l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3);
}
}
cout << ans;
}
| [
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.off_by_one",
"expression.operation.binary.change"
] | 827,606 | 827,607 | u289381123 | cpp |
p03014 | #include <bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()), ((v).end())
#define ll long long
#define fastIO \
cout << fixed << setprecision(12), ios::sync_with_stdio(false), \
cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 1e6 + 9, M = 5e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;
char arr[M][M];
int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
int bestX[M][M], bestY[M][M];
int main() {
fastIO;
#ifdef LOCAL
freopen("input.in", "rt", stdin);
#endif
int n, m;
vector<pair<int, int>> vv;
cin >> n >> m;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
cin >> arr[i][j];
if (arr[i][j] == '.')
vv.push_back({i, j});
}
}
for (int i = 0; i < n; ++i) {
int cur = 0;
for (int j = 0; j < m; ++j) {
if (arr[i][j] == '#') {
if (cur) {
int temp = cur;
bestX[i][j - temp] = temp;
while (cur--) {
if (!cur)
break;
bestX[i][j - cur] = temp;
}
}
cur = 0;
continue;
}
++cur;
}
int temp = cur;
if (cur > 0) {
bestX[i][m] = temp;
}
while (cur--) {
if (cur <= 0)
break;
bestX[i][m - cur] = temp;
}
}
for (int i = 0; i < m; ++i) {
int cur = 0;
for (int j = 0; j < n; ++j) {
if (arr[j][i] == '#') {
if (cur) {
int temp = cur;
bestY[j - temp][i] = temp;
while (cur--) {
if (!cur)
break;
bestY[j - cur][i] = temp;
}
}
cur = 0;
continue;
}
++cur;
}
int temp = cur;
if (cur > 0) {
bestY[0][i] = temp;
}
while (cur--) {
if (cur <= 0)
break;
bestY[n - cur][i] = temp;
}
}
int best = 0;
// cerr << bestX[1][1] << ' ' << bestY[1][1];
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
best = max(best, bestX[i][j] + bestY[i][j] - 1);
}
}
cout << best;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()), ((v).end())
#define ll long long
#define fastIO \
cout << fixed << setprecision(12), ios::sync_with_stdio(false), \
cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 1e6 + 9, M = 5e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;
char arr[M][M];
int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
int bestX[M][M], bestY[M][M];
int main() {
fastIO;
#ifdef LOCAL
freopen("input.in", "rt", stdin);
#endif
int n, m;
vector<pair<int, int>> vv;
cin >> n >> m;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
cin >> arr[i][j];
if (arr[i][j] == '.')
vv.push_back({i, j});
}
}
for (int i = 0; i < n; ++i) {
int cur = 0;
for (int j = 0; j < m; ++j) {
if (arr[i][j] == '#') {
if (cur) {
int temp = cur;
bestX[i][j - temp] = temp;
while (cur--) {
if (!cur)
break;
bestX[i][j - cur] = temp;
}
}
cur = 0;
continue;
}
++cur;
}
int temp = cur;
if (cur > 0) {
bestX[i][m - temp] = temp;
}
while (cur--) {
if (cur <= 0)
break;
bestX[i][m - cur] = temp;
}
}
for (int i = 0; i < m; ++i) {
int cur = 0;
for (int j = 0; j < n; ++j) {
if (arr[j][i] == '#') {
if (cur) {
int temp = cur;
bestY[j - temp][i] = temp;
while (cur--) {
if (!cur)
break;
bestY[j - cur][i] = temp;
}
}
cur = 0;
continue;
}
++cur;
}
int temp = cur;
if (cur > 0) {
bestY[0][i] = temp;
}
while (cur--) {
if (cur <= 0)
break;
bestY[n - cur][i] = temp;
}
}
int best = 0;
// cerr << bestX[1][1] << ' ' << bestY[1][1];
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
best = max(best, bestX[i][j] + bestY[i][j] - 1);
}
}
cout << best;
return 0;
} | [
"assignment.change"
] | 827,622 | 827,623 | u863370423 | cpp |
p03014 | #include <bits/stdc++.h>
using namespace std;
const int64_t MOD = 1000000007;
#define FOR(i, start, end) for (uint64_t i = start; i < end; i++)
#define REP(i, n) FOR(i, 0, n)
typedef long long ll;
typedef unsigned long long ull;
// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
uint64_t temp;
while (m % n != 0) {
temp = n;
n = m % n;
m = temp;
}
return n;
}
uint64_t lcm(uint64_t m, uint64_t n) { return (m * n) / gcd(m, n); }
// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector<uint64_t>> &v) {
for (uint64_t i = 0; i < v.size(); i++) {
v[i][0] = 1;
v[i][i] = 1;
}
for (uint64_t k = 1; k < v.size(); k++) {
for (uint64_t j = 1; j < k; j++) {
v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
v[k][j] %= MOD;
}
}
}
// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {
uint64_t prod = a * b;
return (prod / b != a);
}
//素因数分解
void primeFactorization(
uint64_t a, list<uint64_t> &factors) { //素因数分解を出力するプログラム
long i, sq;
if (a % 2 == 0) { //偶数の場合
factors.push_back(2);
primeFactorization(a / 2, factors); // 2で割った値で再帰
return;
}
sq = sqrt(a);
for (i = 3; i <= sq; i += 2) { // 3以上√a以下の奇数の場合
if (a % i == 0) {
factors.push_back(i);
primeFactorization(a / i, factors); //割れた値で再帰
return;
}
}
//偶数でも3以上√a以下の奇数の場合でも割り切れない場合
if (a != 1) { // aが1でないなら、a自身は素数
factors.push_back(a);
}
}
// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m
int64_t modinv(int64_t a, int64_t m) {
int64_t b = m, u = 1, v = 0;
while (b) {
int64_t t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
u %= m;
if (u < 0)
u += m;
return u;
}
// 円周率
// M_PI
// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;
// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;
signed main() {
int h, w;
cin >> h >> w;
string s[h];
char row[h][w] = {};
char col[h][w] = {};
for (int i = 0; i < h; i++) {
cin >> s[i];
}
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if ('.' == s[i][j]) {
if (i > 0) {
col[i][j] = col[i - 1][j] + 1;
} else {
col[i][j] = 1;
}
if (j > 0) {
row[i][j] = row[i][j - 1] + 1;
} else {
row[i][j] = 1;
}
}
}
}
int maxGrid = 0;
for (int i = h - 1; i >= 0; i--) {
for (int j = w - 1; j > 0; j--) {
if (i < h - 1 && col[i][j] > 0 && col[i][j] < col[i + 1][j]) {
col[i][j] = col[i + 1][j];
}
if (j < w - 1 && row[i][j] > 0 && row[i][j] < row[i][j + 1]) {
row[i][j] = row[i][j + 1];
}
maxGrid = max(maxGrid, row[i][j] + col[i][j] - 1);
}
}
cout << maxGrid << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
const int64_t MOD = 1000000007;
#define FOR(i, start, end) for (uint64_t i = start; i < end; i++)
#define REP(i, n) FOR(i, 0, n)
typedef long long ll;
typedef unsigned long long ull;
// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
uint64_t temp;
while (m % n != 0) {
temp = n;
n = m % n;
m = temp;
}
return n;
}
uint64_t lcm(uint64_t m, uint64_t n) { return (m * n) / gcd(m, n); }
// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector<uint64_t>> &v) {
for (uint64_t i = 0; i < v.size(); i++) {
v[i][0] = 1;
v[i][i] = 1;
}
for (uint64_t k = 1; k < v.size(); k++) {
for (uint64_t j = 1; j < k; j++) {
v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
v[k][j] %= MOD;
}
}
}
// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {
uint64_t prod = a * b;
return (prod / b != a);
}
//素因数分解
void primeFactorization(
uint64_t a, list<uint64_t> &factors) { //素因数分解を出力するプログラム
long i, sq;
if (a % 2 == 0) { //偶数の場合
factors.push_back(2);
primeFactorization(a / 2, factors); // 2で割った値で再帰
return;
}
sq = sqrt(a);
for (i = 3; i <= sq; i += 2) { // 3以上√a以下の奇数の場合
if (a % i == 0) {
factors.push_back(i);
primeFactorization(a / i, factors); //割れた値で再帰
return;
}
}
//偶数でも3以上√a以下の奇数の場合でも割り切れない場合
if (a != 1) { // aが1でないなら、a自身は素数
factors.push_back(a);
}
}
// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m
int64_t modinv(int64_t a, int64_t m) {
int64_t b = m, u = 1, v = 0;
while (b) {
int64_t t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
u %= m;
if (u < 0)
u += m;
return u;
}
// 円周率
// M_PI
// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;
// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;
signed main() {
int h, w;
cin >> h >> w;
string s[h];
int row[h][w] = {};
int col[h][w] = {};
for (int i = 0; i < h; i++) {
cin >> s[i];
}
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if ('.' == s[i][j]) {
if (i > 0) {
col[i][j] = col[i - 1][j] + 1;
} else {
col[i][j] = 1;
}
if (j > 0) {
row[i][j] = row[i][j - 1] + 1;
} else {
row[i][j] = 1;
}
}
}
}
int maxGrid = 0;
for (int i = h - 1; i >= 0; i--) {
for (int j = w - 1; j >= 0; j--) {
if (i < h - 1 && col[i][j] > 0 && col[i][j] < col[i + 1][j]) {
col[i][j] = col[i + 1][j];
}
if (j < w - 1 && row[i][j] > 0 && row[i][j] < row[i][j + 1]) {
row[i][j] = row[i][j + 1];
}
maxGrid = max(maxGrid, row[i][j] + col[i][j] - 1);
}
}
cout << maxGrid << endl;
return 0;
}
| [
"variable_declaration.type.primitive.change",
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 827,630 | 827,629 | u925478083 | cpp |
p03014 | // ABC 129 D Lamp
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int solve(int H, int W, vector<vector<char>> masu) {
vector<vector<int>> ue(H, vector<int>(W));
for (int j = 0; j < W; j++) {
for (int i = H - 1; i >= 0; i--) {
if (masu.at(i).at(j) == '#') {
ue.at(i).at(j) = 0;
continue;
}
if (i + 1 >= H) {
ue.at(i).at(j) = 1;
continue;
}
ue.at(i).at(j) = ue.at(i + 1).at(j) + 1;
}
}
vector<vector<int>> shita(H, vector<int>(W));
for (int j = 0; j < W; j++) {
for (int i = 0; i < H; i++) {
if (masu.at(i).at(j) == '#') {
shita.at(i).at(j) = 0;
continue;
}
if (i - 1 < 0) {
shita.at(i).at(j) = 1;
continue;
}
shita.at(i).at(j) = ue.at(i - 1).at(j) + 1;
}
}
vector<vector<int>> migi(H, vector<int>(W));
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
if (masu.at(i).at(j) == '#') {
migi.at(i).at(j) = 0;
continue;
}
if (j - 1 < 0) {
migi.at(i).at(j) = 1;
continue;
}
migi.at(i).at(j) = migi.at(i).at(j - 1) + 1;
}
}
vector<vector<int>> hidari(H, vector<int>(W));
for (int i = 0; i < H; i++) {
for (int j = W - 1; j >= 0; j--) {
if (masu.at(i).at(j) == '#') {
hidari.at(i).at(j) = 0;
continue;
}
if (j + 1 >= W) {
hidari.at(i).at(j) = 1;
continue;
}
hidari.at(i).at(j) = hidari.at(i).at(j + 1) + 1;
}
}
int max = 0;
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
int value = ue.at(i).at(j) + migi.at(i).at(j) + shita.at(i).at(j) +
hidari.at(i).at(j) - 3;
if (max < value) {
max = value;
}
}
}
return max;
}
int main() {
int H, W;
cin >> H >> W;
vector<vector<char>> masu(H, vector<char>(W));
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
cin >> masu.at(i).at(j);
}
}
cout << solve(H, W, masu) << endl;
return 0;
}
| // ABC 129 D Lamp
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int solve(int H, int W, vector<vector<char>> masu) {
vector<vector<int>> ue(H, vector<int>(W));
for (int j = 0; j < W; j++) {
for (int i = H - 1; i >= 0; i--) {
if (masu.at(i).at(j) == '#') {
ue.at(i).at(j) = 0;
continue;
}
if (i + 1 >= H) {
ue.at(i).at(j) = 1;
continue;
}
ue.at(i).at(j) = ue.at(i + 1).at(j) + 1;
}
}
vector<vector<int>> shita(H, vector<int>(W));
for (int j = 0; j < W; j++) {
for (int i = 0; i < H; i++) {
if (masu.at(i).at(j) == '#') {
shita.at(i).at(j) = 0;
continue;
}
if (i - 1 < 0) {
shita.at(i).at(j) = 1;
continue;
}
shita.at(i).at(j) = shita.at(i - 1).at(j) + 1;
}
}
vector<vector<int>> migi(H, vector<int>(W));
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
if (masu.at(i).at(j) == '#') {
migi.at(i).at(j) = 0;
continue;
}
if (j - 1 < 0) {
migi.at(i).at(j) = 1;
continue;
}
migi.at(i).at(j) = migi.at(i).at(j - 1) + 1;
}
}
vector<vector<int>> hidari(H, vector<int>(W));
for (int i = 0; i < H; i++) {
for (int j = W - 1; j >= 0; j--) {
if (masu.at(i).at(j) == '#') {
hidari.at(i).at(j) = 0;
continue;
}
if (j + 1 >= W) {
hidari.at(i).at(j) = 1;
continue;
}
hidari.at(i).at(j) = hidari.at(i).at(j + 1) + 1;
}
}
int max = 0;
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
int value = ue.at(i).at(j) + migi.at(i).at(j) + shita.at(i).at(j) +
hidari.at(i).at(j) - 3;
if (max < value) {
max = value;
}
}
}
return max;
}
int main() {
int H, W;
cin >> H >> W;
vector<vector<char>> masu(H, vector<char>(W));
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
cin >> masu.at(i).at(j);
}
}
cout << solve(H, W, masu) << endl;
return 0;
}
| [
"assignment.value.change",
"identifier.change",
"expression.operation.binary.change"
] | 827,631 | 827,632 | u947535482 | cpp |
p03014 | #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
typedef long long ll;
const int siz = 2000;
int top[siz][siz];
int bottom[siz][siz];
int left[siz][siz];
int right[siz][siz];
int center[siz][siz];
long long lamp(std::vector<std::vector<char>> area) {
int h = area.size();
int w = area.at(0).size();
/*
for(int i =0;i<h;i++) {
for(int j=0;j<w;j++) {
std::cout << area[i][j];
}
std::cout << std::endl;
}
*/
for (int i = 0; i < h; i++) {
// std::cout << i << std::endl;
for (int j = 0; j < w; j++) {
// center
if (area[i][j] == '.') {
center[i][j] = 1;
}
// left
if (i == 0 || area[i][j - 1] == '#') {
} else {
left[i][j] += left[i][j - 1] + 1;
}
// top
if (i == 0 || area[i - 1][j] == '#') {
} else {
top[i][j] += top[i - 1][j] + 1;
}
}
}
int ans = 0;
for (int i = h - 1; i >= 0; i--) {
for (int j = w - 1; j >= 0; j--) {
// right
if (j == w - 1 || area[i][j + 1] == '#') {
} else {
right[i][j] += right[i][j + 1] + 1;
}
// std::cout << right[i][j] <<std::endl;
// bottom
if (i == h - 1 || area[i + 1][j] == '#') {
} else {
bottom[i][j] += bottom[i + 1][j] + 1;
}
// std::cout << bottom[i][j];
if (area[i][j] != '#') {
ans = std::max(ans, center[i][j] + top[i][j] + bottom[i][j] +
left[i][j] + right[i][j]);
}
}
}
return ans;
// return -1;
}
int main() {
long long h, w;
std::cin >> h;
std::cin >> w;
std::string s;
std::getline(std::cin, s);
std::vector<std::vector<char>> area(h);
for (ll i = 0; i < h; i++) {
std::getline(std::cin, s);
std::vector<char> v(w);
area[i] = v;
for (ll j = 0; j < w; j++) {
area[i][j] = s[j];
}
}
std::cout << lamp(area);
} | #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
typedef long long ll;
const int siz = 2000;
int top[siz][siz];
int bottom[siz][siz];
int left[siz][siz];
int right[siz][siz];
int center[siz][siz];
long long lamp(std::vector<std::vector<char>> area) {
int h = area.size();
int w = area.at(0).size();
/*
for(int i =0;i<h;i++) {
for(int j=0;j<w;j++) {
std::cout << area[i][j];
}
std::cout << std::endl;
}
*/
for (int i = 0; i < h; i++) {
// std::cout << i << std::endl;
for (int j = 0; j < w; j++) {
// center
if (area[i][j] == '.') {
center[i][j] = 1;
}
// left
if (j == 0 || area[i][j - 1] == '#') {
} else {
left[i][j] += left[i][j - 1] + 1;
}
// top
if (i == 0 || area[i - 1][j] == '#') {
} else {
top[i][j] += top[i - 1][j] + 1;
}
}
}
int ans = 0;
for (int i = h - 1; i >= 0; i--) {
for (int j = w - 1; j >= 0; j--) {
// right
if (j == w - 1 || area[i][j + 1] == '#') {
} else {
right[i][j] += right[i][j + 1] + 1;
}
// std::cout << right[i][j] <<std::endl;
// bottom
if (i == h - 1 || area[i + 1][j] == '#') {
} else {
bottom[i][j] += bottom[i + 1][j] + 1;
}
// std::cout << bottom[i][j];
if (area[i][j] != '#') {
// std::cout << i << " " << j << "->" << center[i][j] << " " <<
// left[i][j] << " " << top[i][j] << " " << right[i][j] << " " <<
// bottom[i][j] << std::endl;
ans = std::max(ans, center[i][j] + top[i][j] + bottom[i][j] +
left[i][j] + right[i][j]);
}
}
}
return ans;
// return -1;
}
int main() {
long long h, w;
std::cin >> h;
std::cin >> w;
std::string s;
std::getline(std::cin, s);
std::vector<std::vector<char>> area(h);
for (ll i = 0; i < h; i++) {
std::getline(std::cin, s);
std::vector<char> v(w);
area[i] = v;
for (ll j = 0; j < w; j++) {
area[i][j] = s[j];
}
}
std::cout << lamp(area);
} | [
"identifier.change",
"control_flow.branch.if.condition.change"
] | 827,635 | 827,636 | u570229212 | cpp |
p03014 | #include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define print(x) cout << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
vector<string> G(3000);
int mp[3000][3000];
int main() {
int h, w;
cin >> h >> w;
rep(i, h) cin >> G[i];
rep(i, h) {
int j = 0;
while (j < w) {
if (G[i][j] == '#') {
j++;
continue;
}
if (j >= w)
break;
int s = j;
int cnt = 0;
while (G[i][j] != '#' && j < w) {
cnt++;
j++;
}
int e = j - 1;
srep(k, s, e) { mp[i][k] += cnt; }
}
}
rep(i, w) {
int j = 0;
while (j < h) {
if (G[j][i] == '#') {
j++;
continue;
}
int cnt = 0;
if (j >= h)
break;
int s = j;
while (G[j][i] != '#' && j < h) {
cnt++;
j++;
}
int e = j - 1;
srep(k, s, e) { mp[k][i] += cnt; }
}
}
int ans = 0;
rep(i, h) {
rep(j, w) { maxs(ans, mp[i][j]); }
}
print(ans - 1);
return 0;
} | #include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define print(x) cout << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
vector<string> G(3000);
int mp[3000][3000];
int main() {
int h, w;
cin >> h >> w;
rep(i, h) cin >> G[i];
rep(i, h) {
int j = 0;
while (j < w) {
if (G[i][j] == '#') {
j++;
continue;
}
if (j >= w)
break;
int s = j;
int cnt = 0;
while (G[i][j] != '#' && j < w) {
cnt++;
j++;
}
int e = j;
srep(k, s, e) { mp[i][k] += cnt; }
}
}
rep(i, w) {
int j = 0;
while (j < h) {
if (G[j][i] == '#') {
j++;
continue;
}
int cnt = 0;
if (j >= h)
break;
int s = j;
while (G[j][i] != '#' && j < h) {
cnt++;
j++;
}
int e = j;
srep(k, s, e) { mp[k][i] += cnt; }
}
}
int ans = 0;
rep(i, h) {
rep(j, w) { maxs(ans, mp[i][j]); }
}
print(ans - 1);
return 0;
} | [
"expression.operation.binary.remove"
] | 827,640 | 827,641 | u814715203 | cpp |
p03014 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL << 62
#define inf 1000000007
ll h, w;
ll H[2010][2010];
ll W[2010][2010];
char ch[2010][2010];
int main() {
cin >> h >> w;
for (ll i = 0; i < h; i++) {
for (ll j = 0; j < w; j++) {
cin >> ch[i][j];
}
}
for (ll i = 0; i < h; i++) {
ll cnt = 0;
for (ll j = 0; j < w; j++) {
if (ch[i][j] == '#') {
cnt = 0;
continue;
}
cnt++;
H[i][j] = cnt;
}
cnt = H[i][w - 1];
for (ll j = w - 1; j >= 0; j--) {
if (ch[i][j] == '#') {
cnt = 0;
continue;
}
cnt = max(cnt, H[i][j]);
H[i][j] = cnt;
}
}
for (ll i = 0; i < w; i++) {
ll cnt = 0;
for (ll j = 0; j < h; j++) {
if (ch[j][i] == '#') {
cnt = 0;
continue;
}
cnt++;
W[j][i] = cnt;
}
cnt = W[h - 1][i];
for (ll j = h - 1; j >= 0; j--) {
if (ch[j][i] == '#') {
cnt = 0;
continue;
}
cnt = max(cnt, W[j][i]);
H[j][i] = cnt;
}
}
ll ans = 0;
for (ll i = 0; i < h; i++) {
for (ll j = 0; j < w; j++) {
ans = max(ans, H[i][j] + W[i][j]);
}
}
cout << ans;
// your code goes here
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL << 62
#define inf 1000000007
ll h, w;
ll H[2010][2010];
ll W[2010][2010];
char ch[2010][2010];
int main() {
cin >> h >> w;
for (ll i = 0; i < h; i++) {
for (ll j = 0; j < w; j++) {
cin >> ch[i][j];
}
}
for (ll i = 0; i < h; i++) {
ll cnt = 0;
for (ll j = 0; j < w; j++) {
if (ch[i][j] == '#') {
cnt = 0;
continue;
}
cnt++;
H[i][j] = cnt;
}
cnt = H[i][w - 1];
for (ll j = w - 1; j >= 0; j--) {
if (ch[i][j] == '#') {
cnt = 0;
continue;
}
cnt = max(cnt, H[i][j]);
H[i][j] = cnt;
}
}
for (ll i = 0; i < w; i++) {
ll cnt = 0;
for (ll j = 0; j < h; j++) {
if (ch[j][i] == '#') {
cnt = 0;
continue;
}
cnt++;
W[j][i] = cnt;
}
cnt = W[h - 1][i];
for (ll j = h - 1; j >= 0; j--) {
if (ch[j][i] == '#') {
cnt = 0;
continue;
}
cnt = max(cnt, W[j][i]);
W[j][i] = cnt;
}
}
ll ans = 0;
for (ll i = 0; i < h; i++) {
for (ll j = 0; j < w; j++) {
// cout << W[i][j];
ans = max(ans, H[i][j] + W[i][j]);
}
// cout <<endl;
}
cout << ans - 1;
// your code goes here
return 0;
} | [
"assignment.variable.change",
"identifier.change"
] | 827,650 | 827,651 | u166378830 | cpp |
p03014 | #include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int h, w;
cin >> h >> w;
vector<string> s(h);
rep(i, h) cin >> s[i];
vector<vector<pair<char, int>>> wcnt(h);
rep(i, h) {
vector<pair<char, int>> c;
c.push_back(make_pair(s[i][0], 1));
rep1(j, w) {
if (s[i][j] == c.back().first)
++c.back().second;
else
c.push_back(make_pair(s[i][j], 1));
}
wcnt[i] = c;
}
vector<vector<pair<char, int>>> hcnt(w);
rep(i, w) {
vector<pair<char, int>> c;
c.push_back(make_pair(s[0][i], 1));
rep1(j, h) {
if (s[j][i] == c.back().first)
++c.back().second;
else
c.push_back(make_pair(s[j][i], 1));
}
hcnt[i] = c;
}
vector<vector<int>> wmap(h, vector<int>(w, -1));
rep(i, h) {
int ptr = 0;
rep(j, wcnt[i].size()) {
int val = -1;
if (wcnt[i][j].first == '.')
val = wcnt[i][j].second;
for (int k = ptr; k < ptr + wcnt[i][j].second; ++k)
wmap[i][k] = val;
ptr += wcnt[i][j].second;
}
}
vector<vector<int>> hmap(h, vector<int>(w, -1));
rep(i, h) {
int ptr = 0;
rep(j, hcnt[i].size()) {
int val = -1;
if (hcnt[i][j].first == '.')
val = hcnt[i][j].second;
for (int k = ptr; k < ptr + hcnt[i][j].second; ++k)
hmap[k][i] = val;
ptr += hcnt[i][j].second;
}
}
int res = 0;
rep(i, h) rep(j, w) {
if (wmap[i][j] == -1 || hmap[i][j] == -1)
continue;
res = max(res, wmap[i][j] + hmap[i][j] - 1);
}
cout << res << endl;
return 0;
} | #include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int h, w;
cin >> h >> w;
vector<string> s(h);
rep(i, h) cin >> s[i];
vector<vector<pair<char, int>>> wcnt(h);
rep(i, h) {
vector<pair<char, int>> c;
c.push_back(make_pair(s[i][0], 1));
rep1(j, w) {
if (s[i][j] == c.back().first)
++c.back().second;
else
c.push_back(make_pair(s[i][j], 1));
}
wcnt[i] = c;
}
vector<vector<pair<char, int>>> hcnt(w);
rep(i, w) {
vector<pair<char, int>> c;
c.push_back(make_pair(s[0][i], 1));
rep1(j, h) {
if (s[j][i] == c.back().first)
++c.back().second;
else
c.push_back(make_pair(s[j][i], 1));
}
hcnt[i] = c;
}
vector<vector<int>> wmap(h, vector<int>(w, -1));
rep(i, h) {
int ptr = 0;
rep(j, wcnt[i].size()) {
int val = -1;
if (wcnt[i][j].first == '.')
val = wcnt[i][j].second;
for (int k = ptr; k < ptr + wcnt[i][j].second; ++k)
wmap[i][k] = val;
ptr += wcnt[i][j].second;
}
}
vector<vector<int>> hmap(h, vector<int>(w, -1));
rep(i, w) {
int ptr = 0;
rep(j, hcnt[i].size()) {
int val = -1;
if (hcnt[i][j].first == '.')
val = hcnt[i][j].second;
for (int k = ptr; k < ptr + hcnt[i][j].second; ++k)
hmap[k][i] = val;
ptr += hcnt[i][j].second;
}
}
int res = 0;
rep(i, h) rep(j, w) {
if (wmap[i][j] == -1 || hmap[i][j] == -1)
continue;
res = max(res, wmap[i][j] + hmap[i][j] - 1);
}
cout << res << endl;
return 0;
} | [] | 827,654 | 827,655 | u374051158 | cpp |
p03014 | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
}
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, n) for (ll i = n - 1; i >= 0; i--)
#define rept(i, m, n) for (ll i = m; i < n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) \
for (auto v : (V)) \
cout << v << " "
// charを整数に
int ctoi(char c) {
if (c >= '0' && c <= '9') {
return c - '0';
}
return 0;
}
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i];
void cum_sum(int N, vector<double> a, vector<double> &s) {
for (int i = 0; i < N; i++) {
s[i + 1] = s[i] + a[i];
}
}
//ユークリッドの控除法
ll gcd(ll a, ll b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
ll g = gcd(a, b);
return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
if (n <= 1)
return false;
for (long long p = 2; p * p <= n; ++p) {
if (n % p == 0)
return false;
}
return true;
}
int getdigit(ll num) {
unsigned digit = 0;
while (num != 0) {
num /= 10;
digit++;
}
return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll H, W;
cin >> H >> W;
VS S(H);
rep(i, H) { cin >> S[i]; }
vector<vector<ll>> light_r(H, vector<ll>(W));
vector<vector<ll>> light_l(H, vector<ll>(W));
vector<vector<ll>> light_u(H, vector<ll>(W));
vector<vector<ll>> light_d(H, vector<ll>(W));
rep(i, H) {
if (S[i][0] != '#')
light_l[i][0] = 1;
if (S[i][W - 1] != '#')
light_r[i][W - 1] = 1;
}
rep(i, W) {
if (S[0][i] != '#')
light_u[0][i] = 1;
if (S[H - 1][i] != '#')
light_d[H - 1][i] = 1;
}
rep(i, H) {
rept(j, 1, W) {
if (S[i][j] == '#') {
light_l[i][j] = 0;
} else {
light_l[i][j] = light_l[i][j - 1] + 1;
}
}
}
rep(i, H) {
for (int j = W - 1; j >= 0; j--) {
if (S[i][j] == '#') {
light_r[i][j] = 0;
} else {
light_r[i][j] = light_r[i][j + 1] + 1;
}
}
}
rept(i, 1, H) {
rep(j, W) {
if (S[i][j] == '#') {
light_u[i][j] = 0;
} else {
light_u[i][j] = light_u[i - 1][j] + 1;
}
}
}
for (int i = H - 2; i >= 0; i--) {
rep(j, W) {
if (S[i][j] == '#') {
light_d[i][j] = 0;
} else {
light_d[i][j] = light_d[i + 1][j] + 1;
}
}
}
ll ans = 0;
rep(i, H) {
rep(j, W) {
ans = max(ans,
light_l[i][j] + light_r[i][j] + light_u[i][j] + light_d[i][j]);
// cout << light_l[i][j];
}
// cout << endl;
}
cout << ans - 3 << endl;
} | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
}
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, n) for (ll i = n - 1; i >= 0; i--)
#define rept(i, m, n) for (ll i = m; i < n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) \
for (auto v : (V)) \
cout << v << " "
// charを整数に
int ctoi(char c) {
if (c >= '0' && c <= '9') {
return c - '0';
}
return 0;
}
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i];
void cum_sum(int N, vector<double> a, vector<double> &s) {
for (int i = 0; i < N; i++) {
s[i + 1] = s[i] + a[i];
}
}
//ユークリッドの控除法
ll gcd(ll a, ll b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
ll g = gcd(a, b);
return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
if (n <= 1)
return false;
for (long long p = 2; p * p <= n; ++p) {
if (n % p == 0)
return false;
}
return true;
}
int getdigit(ll num) {
unsigned digit = 0;
while (num != 0) {
num /= 10;
digit++;
}
return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll H, W;
cin >> H >> W;
VS S(H);
rep(i, H) { cin >> S[i]; }
vector<vector<ll>> light_r(H, vector<ll>(W));
vector<vector<ll>> light_l(H, vector<ll>(W));
vector<vector<ll>> light_u(H, vector<ll>(W));
vector<vector<ll>> light_d(H, vector<ll>(W));
rep(i, H) {
if (S[i][0] != '#')
light_l[i][0] = 1;
if (S[i][W - 1] != '#')
light_r[i][W - 1] = 1;
}
rep(i, W) {
if (S[0][i] != '#')
light_u[0][i] = 1;
if (S[H - 1][i] != '#')
light_d[H - 1][i] = 1;
}
rep(i, H) {
rept(j, 1, W) {
if (S[i][j] == '#') {
light_l[i][j] = 0;
} else {
light_l[i][j] = light_l[i][j - 1] + 1;
}
}
}
rep(i, H) {
for (int j = W - 2; j >= 0; j--) {
if (S[i][j] == '#') {
light_r[i][j] = 0;
} else {
light_r[i][j] = light_r[i][j + 1] + 1;
}
}
}
rept(i, 1, H) {
rep(j, W) {
if (S[i][j] == '#') {
light_u[i][j] = 0;
} else {
light_u[i][j] = light_u[i - 1][j] + 1;
}
}
}
for (int i = H - 2; i >= 0; i--) {
rep(j, W) {
if (S[i][j] == '#') {
light_d[i][j] = 0;
} else {
light_d[i][j] = light_d[i + 1][j] + 1;
}
}
}
ll ans = 0;
rep(i, H) {
rep(j, W) {
ans = max(ans,
light_l[i][j] + light_r[i][j] + light_u[i][j] + light_d[i][j]);
// cout << light_l[i][j]+light_r[i][j]+light_u[i][j]+light_d[i][j];
}
// cout << endl;
}
cout << ans - 3 << endl;
} | [
"literal.number.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one",
"expression.operation.binary.change"
] | 827,656 | 827,657 | u690326065 | cpp |
p03014 | #include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <unordered_map>
#include <vector>
const int mod = 1e9 + 7;
const int kmax = 510000;
const int last_days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
long long fact[kmax], fact_inv[kmax], inv[kmax];
void init_comb() {
fact[0] = fact[1] = 1;
fact_inv[0] = fact_inv[1] = 1;
inv[1] = 1;
for (int i = 2; i < kmax; i++) {
fact[i] = fact[i - 1] * i % mod;
inv[i] = mod - inv[mod % i] * (mod / i) % mod;
fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
}
}
long long comb(int n, int r) {
if (n < r) {
return 0;
}
if (n < 0 || r < 0) {
return 0;
}
return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}
template <typename T, T N> class UnionFind {
T parent_[N];
T rank_[N];
T size_[N];
public:
UnionFind();
T Root(T idx);
bool IsSame(T x, T y);
void Unite(T x, T y);
T GetSize(T idx);
};
template <typename T, T N> UnionFind<T, N>::UnionFind() {
for (T i = 0; i < N; i++) {
parent_[i] = i;
rank_[i] = 0;
size_[i] = 1;
}
}
template <typename T, T N> T UnionFind<T, N>::Root(T idx) {
return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}
template <typename T, T N> bool UnionFind<T, N>::IsSame(T x, T y) {
return Root(x) == Root(y);
}
template <typename T, T N> void UnionFind<T, N>::Unite(T x, T y) {
x = Root(x);
y = Root(y);
if (x == y) {
return;
}
if (rank_[x] < rank_[y]) {
parent_[x] = y;
size_[y] += size_[x];
} else {
parent_[y] = x;
size_[x] += size_[y];
if (rank_[x] == rank_[y]) {
rank_[x]++;
}
}
}
template <typename T, T N> T UnionFind<T, N>::GetSize(T idx) {
return size_[Root(idx)];
}
template <typename T> T pow_mod(T n, T p, T m) {
if (p == 0) {
return 1;
}
if (p % 2 == 0) {
T t = pow_mod(n, p / 2, m);
return t * t % m;
}
return n * pow_mod(n, p - 1, m) % mod;
}
template <typename T> T nCr_mod(T n, T r) {
T x = 1;
for (T i = n - r + 1; i <= n; i++) {
x *= i;
x %= mod;
}
T a = 1;
for (T i = 1; i <= r; i++) {
a *= i;
a %= mod;
}
T y = pow_mod(a, mod - 2, mod) % mod;
return x * y % mod;
}
template <typename T> bool is_prime(T n) {
if (n == 1) {
return false;
}
for (T i = 2; i * i <= n; i++) {
if (n % i == 0) {
return false;
}
}
return true;
}
template <typename T> bool is_leap(T y) {
return (y % 4 == 0 && y % 100 != 0) || y % 400 == 0;
}
template <typename T> void next_day(T &y, T &m, T &d) {
d++;
if (d > last_days[m - 1] + (m == 2 && is_leap(y) ? 1 : 0)) {
d = 1;
m++;
}
if (m > 12) {
y++;
m = 1;
}
}
template <typename T> T fib(T n) {
T a = 0, b = 1;
for (T i = 0; i < n; i++) {
T t = a;
a = b;
b = a + t;
}
return a;
}
// Note that the order of this function is O(n**n).
template <typename T>
std::vector<size_t> calculate_ranks(const std::vector<T> &v) {
std::vector<T> sorted = v;
std::sort(sorted.begin(), sorted.end());
std::map<T, long long> m;
for (auto i = 0LU; i < v.size(); i++) {
m.insert(std::make_pair(sorted[i], i));
}
std::vector<size_t> rank(v.size());
for (auto i = 0LU; i < v.size(); i++) {
rank[i] = m.find(v[i])->second + 1;
}
return rank;
}
template <typename T> std::map<T, T> prime_factors_and_num(T n) {
std::map<T, T> m;
for (T i = 2; i <= n; i++) {
while (n % i == 0) {
m[i]++;
n /= i;
}
}
return m;
}
inline long long calculate_sum(const std::vector<long long> &v) {
return std::accumulate(v.begin(), v.end(), 0LL);
}
template <typename T, T N> class Graph {
std::vector<std::vector<T>> weights_;
std::vector<T> predecessors_;
std::vector<T> shortest_path_estimate_;
std::vector<std::vector<T>> edges_;
void InitializeSingleSource(T start);
void Relax(T v, T u);
public:
Graph(std::vector<std::vector<T>> weights, std::vector<std::vector<T>> edges);
Graph(std::vector<std::vector<T>> weights, T inf);
T BellmanFord(T start, T end);
T Dijkstra(T start, T end);
};
template <typename T, T N>
Graph<T, N>::Graph(std::vector<std::vector<T>> weights,
std::vector<std::vector<T>> edges) {
weights_ = weights;
predecessors_ = std::vector<T>(N, -1);
shortest_path_estimate_ = std::vector<T>(N, mod);
edges_ = edges;
}
template <typename T, T N>
Graph<T, N>::Graph(std::vector<std::vector<T>> weights, T inf) {
weights_ = weights;
predecessors_ = std::vector<T>(N, -1);
shortest_path_estimate_ = std::vector<T>(N, inf);
edges_ = std::vector<std::vector<T>>(N, std::vector<T>());
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
if (weights_[i][j] != inf) {
edges_[i].push_back(j);
}
}
}
}
template <typename T, T N> void Graph<T, N>::InitializeSingleSource(T start) {
for (int i = 0; i < N; i++) {
shortest_path_estimate_[i] = mod;
predecessors_[i] = -1;
}
shortest_path_estimate_[start] = 0;
}
template <typename T, T N> void Graph<T, N>::Relax(T u, T v) {
if (shortest_path_estimate_[v] >
shortest_path_estimate_[u] + weights_[u][v]) {
shortest_path_estimate_[v] = shortest_path_estimate_[u] + weights_[u][v];
predecessors_[v] = u;
}
}
template <typename T, T N> T Graph<T, N>::BellmanFord(T start, T end) {
InitializeSingleSource(start);
for (int i = 0; i < N - 1; i++) {
for (int j = 0; j < N; j++) {
for (auto edge : edges_[j]) {
Relax(j, edge);
}
}
}
for (int i = 0; i < N; i++) {
for (auto edge : edges_[i]) {
if (shortest_path_estimate_[edge] >
shortest_path_estimate_[i] + weights_[i][edge]) {
fprintf(stderr, "Graph contains negative circle!\n");
exit(1);
}
}
}
return shortest_path_estimate_[end];
}
template <typename T, T N> T Graph<T, N>::Dijkstra(T start, T end) {
InitializeSingleSource(start);
std::set<T> s;
auto compare_d = [=](const T &x, const T &y) {
return shortest_path_estimate_[x] > shortest_path_estimate_[y];
};
std::priority_queue<T, std::vector<T>, decltype(compare_d)> q(compare_d);
for (int i = 0; i < N; i++) {
q.push(i);
}
while (q.size()) {
T u = q.top();
q.pop();
s.insert(u);
for (auto v : edges_[u]) {
Relax(u, v);
}
}
return shortest_path_estimate_[end];
}
int main() {
long long h, w;
std::cin >> h >> w;
std::vector<std::string> s(h);
for (int i = 0; i < h; i++) {
std::cin >> s[i];
}
std::vector<std::vector<long long>> h_table(h, std::vector<long long>(w, 0)),
w_table(h, std::vector<long long>(w, 0));
for (int i = 0; i < h; i++) {
if (s[i][0] != '#') {
w_table[i][0] = 1;
}
for (int j = 1; j < w; j++) {
if (s[i][j] != '#') {
w_table[i][j] = w_table[i][j - 1] + 1;
}
}
for (int j = w - 2; j >= 0; j--) {
if (s[i][j] != '#') {
w_table[i][j] = std::max(w_table[i][j], w_table[i][j + 1]);
}
}
}
for (int i = 0; i < w; i++) {
if (s[0][i] != '#') {
h_table[0][i] = 1;
}
for (int j = 1; j < h; j++) {
if (s[j][i] != '#') {
h_table[j][i] = h_table[j - 1][i] + 1;
}
}
for (int j = h - 2; j >= 0; j--) {
if (s[i][j] != '#') {
h_table[j][i] = std::max(h_table[j][i], h_table[j + 1][i]);
}
}
}
long long ans = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
ans = std::max(ans, h_table[i][j] + w_table[i][j]);
}
}
std::cout << std::max(ans - 1, 0LL) << std::endl;
}
| #include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <unordered_map>
#include <vector>
const int mod = 1e9 + 7;
const int kmax = 510000;
const int last_days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
long long fact[kmax], fact_inv[kmax], inv[kmax];
void init_comb() {
fact[0] = fact[1] = 1;
fact_inv[0] = fact_inv[1] = 1;
inv[1] = 1;
for (int i = 2; i < kmax; i++) {
fact[i] = fact[i - 1] * i % mod;
inv[i] = mod - inv[mod % i] * (mod / i) % mod;
fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
}
}
long long comb(int n, int r) {
if (n < r) {
return 0;
}
if (n < 0 || r < 0) {
return 0;
}
return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}
template <typename T, T N> class UnionFind {
T parent_[N];
T rank_[N];
T size_[N];
public:
UnionFind();
T Root(T idx);
bool IsSame(T x, T y);
void Unite(T x, T y);
T GetSize(T idx);
};
template <typename T, T N> UnionFind<T, N>::UnionFind() {
for (T i = 0; i < N; i++) {
parent_[i] = i;
rank_[i] = 0;
size_[i] = 1;
}
}
template <typename T, T N> T UnionFind<T, N>::Root(T idx) {
return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}
template <typename T, T N> bool UnionFind<T, N>::IsSame(T x, T y) {
return Root(x) == Root(y);
}
template <typename T, T N> void UnionFind<T, N>::Unite(T x, T y) {
x = Root(x);
y = Root(y);
if (x == y) {
return;
}
if (rank_[x] < rank_[y]) {
parent_[x] = y;
size_[y] += size_[x];
} else {
parent_[y] = x;
size_[x] += size_[y];
if (rank_[x] == rank_[y]) {
rank_[x]++;
}
}
}
template <typename T, T N> T UnionFind<T, N>::GetSize(T idx) {
return size_[Root(idx)];
}
template <typename T> T pow_mod(T n, T p, T m) {
if (p == 0) {
return 1;
}
if (p % 2 == 0) {
T t = pow_mod(n, p / 2, m);
return t * t % m;
}
return n * pow_mod(n, p - 1, m) % mod;
}
template <typename T> T nCr_mod(T n, T r) {
T x = 1;
for (T i = n - r + 1; i <= n; i++) {
x *= i;
x %= mod;
}
T a = 1;
for (T i = 1; i <= r; i++) {
a *= i;
a %= mod;
}
T y = pow_mod(a, mod - 2, mod) % mod;
return x * y % mod;
}
template <typename T> bool is_prime(T n) {
if (n == 1) {
return false;
}
for (T i = 2; i * i <= n; i++) {
if (n % i == 0) {
return false;
}
}
return true;
}
template <typename T> bool is_leap(T y) {
return (y % 4 == 0 && y % 100 != 0) || y % 400 == 0;
}
template <typename T> void next_day(T &y, T &m, T &d) {
d++;
if (d > last_days[m - 1] + (m == 2 && is_leap(y) ? 1 : 0)) {
d = 1;
m++;
}
if (m > 12) {
y++;
m = 1;
}
}
template <typename T> T fib(T n) {
T a = 0, b = 1;
for (T i = 0; i < n; i++) {
T t = a;
a = b;
b = a + t;
}
return a;
}
// Note that the order of this function is O(n**n).
template <typename T>
std::vector<size_t> calculate_ranks(const std::vector<T> &v) {
std::vector<T> sorted = v;
std::sort(sorted.begin(), sorted.end());
std::map<T, long long> m;
for (auto i = 0LU; i < v.size(); i++) {
m.insert(std::make_pair(sorted[i], i));
}
std::vector<size_t> rank(v.size());
for (auto i = 0LU; i < v.size(); i++) {
rank[i] = m.find(v[i])->second + 1;
}
return rank;
}
template <typename T> std::map<T, T> prime_factors_and_num(T n) {
std::map<T, T> m;
for (T i = 2; i <= n; i++) {
while (n % i == 0) {
m[i]++;
n /= i;
}
}
return m;
}
inline long long calculate_sum(const std::vector<long long> &v) {
return std::accumulate(v.begin(), v.end(), 0LL);
}
template <typename T, T N> class Graph {
std::vector<std::vector<T>> weights_;
std::vector<T> predecessors_;
std::vector<T> shortest_path_estimate_;
std::vector<std::vector<T>> edges_;
void InitializeSingleSource(T start);
void Relax(T v, T u);
public:
Graph(std::vector<std::vector<T>> weights, std::vector<std::vector<T>> edges);
Graph(std::vector<std::vector<T>> weights, T inf);
T BellmanFord(T start, T end);
T Dijkstra(T start, T end);
};
template <typename T, T N>
Graph<T, N>::Graph(std::vector<std::vector<T>> weights,
std::vector<std::vector<T>> edges) {
weights_ = weights;
predecessors_ = std::vector<T>(N, -1);
shortest_path_estimate_ = std::vector<T>(N, mod);
edges_ = edges;
}
template <typename T, T N>
Graph<T, N>::Graph(std::vector<std::vector<T>> weights, T inf) {
weights_ = weights;
predecessors_ = std::vector<T>(N, -1);
shortest_path_estimate_ = std::vector<T>(N, inf);
edges_ = std::vector<std::vector<T>>(N, std::vector<T>());
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
if (weights_[i][j] != inf) {
edges_[i].push_back(j);
}
}
}
}
template <typename T, T N> void Graph<T, N>::InitializeSingleSource(T start) {
for (int i = 0; i < N; i++) {
shortest_path_estimate_[i] = mod;
predecessors_[i] = -1;
}
shortest_path_estimate_[start] = 0;
}
template <typename T, T N> void Graph<T, N>::Relax(T u, T v) {
if (shortest_path_estimate_[v] >
shortest_path_estimate_[u] + weights_[u][v]) {
shortest_path_estimate_[v] = shortest_path_estimate_[u] + weights_[u][v];
predecessors_[v] = u;
}
}
template <typename T, T N> T Graph<T, N>::BellmanFord(T start, T end) {
InitializeSingleSource(start);
for (int i = 0; i < N - 1; i++) {
for (int j = 0; j < N; j++) {
for (auto edge : edges_[j]) {
Relax(j, edge);
}
}
}
for (int i = 0; i < N; i++) {
for (auto edge : edges_[i]) {
if (shortest_path_estimate_[edge] >
shortest_path_estimate_[i] + weights_[i][edge]) {
fprintf(stderr, "Graph contains negative circle!\n");
exit(1);
}
}
}
return shortest_path_estimate_[end];
}
template <typename T, T N> T Graph<T, N>::Dijkstra(T start, T end) {
InitializeSingleSource(start);
std::set<T> s;
auto compare_d = [=](const T &x, const T &y) {
return shortest_path_estimate_[x] > shortest_path_estimate_[y];
};
std::priority_queue<T, std::vector<T>, decltype(compare_d)> q(compare_d);
for (int i = 0; i < N; i++) {
q.push(i);
}
while (q.size()) {
T u = q.top();
q.pop();
s.insert(u);
for (auto v : edges_[u]) {
Relax(u, v);
}
}
return shortest_path_estimate_[end];
}
int main() {
long long h, w;
std::cin >> h >> w;
std::vector<std::string> s(h);
for (int i = 0; i < h; i++) {
std::cin >> s[i];
}
std::vector<std::vector<long long>> h_table(h, std::vector<long long>(w, 0)),
w_table(h, std::vector<long long>(w, 0));
for (int i = 0; i < h; i++) {
if (s[i][0] != '#') {
w_table[i][0] = 1;
}
for (int j = 1; j < w; j++) {
if (s[i][j] != '#') {
w_table[i][j] = w_table[i][j - 1] + 1;
}
}
for (int j = w - 2; j >= 0; j--) {
if (s[i][j] != '#') {
w_table[i][j] = std::max(w_table[i][j], w_table[i][j + 1]);
}
}
}
for (int i = 0; i < w; i++) {
if (s[0][i] != '#') {
h_table[0][i] = 1;
}
for (int j = 1; j < h; j++) {
if (s[j][i] != '#') {
h_table[j][i] = h_table[j - 1][i] + 1;
}
}
for (int j = h - 2; j >= 0; j--) {
if (s[j][i] != '#') {
h_table[j][i] = std::max(h_table[j][i], h_table[j + 1][i]);
}
}
}
long long ans = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
ans = std::max(ans, h_table[i][j] + w_table[i][j]);
}
}
std::cout << std::max(ans - 1, 0LL) << std::endl;
}
| [
"identifier.change",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change"
] | 827,666 | 827,667 | u083910207 | cpp |
p03014 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using vi = vector<int>;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
template <typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template <typename T, typename... Args>
void ndarray(vector<T> &vec, int len, Args... args) {
vec.resize(len);
for (auto &v : vec)
ndarray(v, args...);
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int h, w;
cin >> h >> w;
vector<vector<int>> dp(h + 5, vector<int>(w + 5, 0));
vector<vector<int>> t(w), y(h);
rep(i, h) {
int x = i;
y[x].push_back(0);
}
rep(i, w) {
int z = i;
t[z].push_back(0);
}
rep(i, h) {
string s;
cin >> s;
rep(j, w) {
if (s[j] == '.')
continue;
int x = i, z = j;
t[z].push_back(x + 1);
y[x].push_back(z + 1);
}
}
rep(i, h) {
int x = i;
y[x].push_back(w + 1);
}
rep(i, w) {
int z = i;
t[z].push_back(h + 1);
}
rep(i, w) {
for (size_t j = 1; j < t[i].size(); ++j) {
if ((t[i][j - 1] + 1) == t[i][j])
continue;
for (int k = t[i][j - 1]; k < t[i][j] - 1; ++k) {
dp[i][k] = t[i][j] - t[i][j - 1] - 1;
}
}
}
rep(i, h) {
for (size_t j = 1; j < y[i].size(); ++j) {
if ((y[i][j - 1] + 1) == y[i][j])
continue;
for (int k = y[i][j - 1]; k < y[i][j] - 1; ++k) {
dp[k][i] += y[i][j] - y[i][j - 1] - 2;
}
}
}
int ans = 0;
rep(i, w) {
rep(j, h) { ans = max(ans, dp[i][j]); }
}
cout << ans << "\n";
return 0;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using vi = vector<int>;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
template <typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template <typename T, typename... Args>
void ndarray(vector<T> &vec, int len, Args... args) {
vec.resize(len);
for (auto &v : vec)
ndarray(v, args...);
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int h, w;
cin >> h >> w;
vector<vector<int>> dp(w + 5, vector<int>(h + 5, 0));
vector<vector<int>> t(w), y(h);
rep(i, h) {
int x = i;
y[x].push_back(0);
}
rep(i, w) {
int z = i;
t[z].push_back(0);
}
rep(i, h) {
string s;
cin >> s;
rep(j, w) {
if (s[j] == '.')
continue;
int x = i, z = j;
t[z].push_back(x + 1);
y[x].push_back(z + 1);
}
}
rep(i, h) {
int x = i;
y[x].push_back(w + 1);
}
rep(i, w) {
int z = i;
t[z].push_back(h + 1);
}
rep(i, w) {
for (size_t j = 1; j < t[i].size(); ++j) {
if ((t[i][j - 1] + 1) == t[i][j])
continue;
for (int k = t[i][j - 1]; k < t[i][j] - 1; ++k) {
dp[i][k] = t[i][j] - t[i][j - 1] - 1;
}
}
}
rep(i, h) {
for (size_t j = 1; j < y[i].size(); ++j) {
if ((y[i][j - 1] + 1) == y[i][j])
continue;
for (int k = y[i][j - 1]; k < y[i][j] - 1; ++k) {
dp[k][i] += y[i][j] - y[i][j - 1] - 2;
}
}
}
int ans = 0;
rep(i, h) {
rep(j, w) { ans = max(ans, dp[j][i]); }
}
cout << ans << "\n";
return 0;
} | [
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change",
"assignment.value.change",
"variable_access.subscript.index.change"
] | 827,670 | 827,671 | u070335689 | cpp |
p03014 | #include <bits/stdc++.h>
//#define int long long
#define endl '\n'
#define IOS \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define bug1(x) \
{ cerr << (#x) << "=" << x << endl; }
#define bug2(x, y) \
{ cerr << (#x) << "=" << (x) << " " << (#y) << "=" << (y) << endl; }
#define bug3(x, y, z) \
{ \
cerr << (#x) << "=" << (x) << " " << (#y) << "=" << (y) << " " \
<< (#z) << "=" << (z) << endl; \
}
#define bug4(x, y, z, w) \
{ \
cerr << (#x) << "=" << (x) << " " << (#y) << "=" << (y) << " " \
<< (#z) << "=" << (z) << " " << (#w) << "=" << w << endl; \
}
#define bug5(x, y, z, w, p) \
{ \
cerr << (#x) << "=" << (x) << " " << (#y) << "=" << (y) << " " \
<< (#z) << "=" << (z) << " " << (#w) << "=" << w << " " << (#p) \
<< "=" << p << endl; \
}
#define bug6(x, y, z, w, p, q) \
{ \
cerr << (#x) << "=" << (x) << " " << (#y) << "=" << (y) << " " \
<< (#z) << "=" << (z) << " " << (#w) << "=" << w << " " << (#p) \
<< "=" << p << " " << (#q) << "=" << q << endl; \
}
#define bugn(x, n) \
{ \
cerr << (#x) << ":"; \
for (int i = 0; i < n; i++) \
cerr << x[i] << " "; \
cerr << endl; \
}
#define bugnm(x, n, m) \
{ \
cerr << (#x) << endl; \
for (int i = 0; i < n; i++) { \
cerr << "Row #" << i << ":"; \
for (int j = 0; j < m; j++) \
cerr << x[i][j] << " "; \
cerr << endl; \
} \
}
typedef long long ll;
typedef long double ld;
using namespace std;
const int maxn = 2000 + 10;
int l[maxn][maxn], r[maxn][maxn], u[maxn][maxn], d[maxn][maxn];
int32_t main() {
IOS for (int i = 0; i < maxn; i++) {
for (int j = 0; j < maxn; j++) {
l[i][j] = r[i][j] = u[i][j] = d[i][j] = 0;
}
}
int n, m;
cin >> n >> m;
vector<string> s(n + 1);
for (int i = 1; i <= n; i++) {
cin >> s[i];
s[i] = '$' + s[i];
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
u[i][j] = s[i][j] == '#' ? 0 : u[i - 1][j] + 1;
}
}
for (int i = n; i >= 1; i--) {
for (int j = 1; j <= m; j++) {
d[i][j] = s[i][j] == '#' ? 0 : d[i + 1][j] + 1;
}
}
for (int j = 1; j <= m; j++) {
for (int i = 1; i <= n; i++) {
l[i][j] = s[i][j] == '#' ? 0 : l[i][j - 1] + 1;
}
}
for (int j = m; j >= 1; j--) {
for (int i = 1; i <= n; i++) {
r[i][j] = s[i][j] == '#' ? 0 : r[i][j + 1] + 1;
}
}
int ans = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
// bug6(i,j,u[i][j],d[i][j],l[i][j],r[i][j]);
if (s[i][j] == '.') {
ans = max(ans, l[i][j] + r[i][j] + u[i][j] + d[i][j] - 4 + 1);
}
}
}
cout << ans;
}
/*
* long long or int?
* index out of bound?
* Tested on own test case?corner?
* Make more general solution.
* Read Read Read Read ....
*/
| #include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define bug1(x) \
{ cerr << (#x) << "=" << x << endl; }
#define bug2(x, y) \
{ cerr << (#x) << "=" << (x) << " " << (#y) << "=" << (y) << endl; }
#define bug3(x, y, z) \
{ \
cerr << (#x) << "=" << (x) << " " << (#y) << "=" << (y) << " " \
<< (#z) << "=" << (z) << endl; \
}
#define bug4(x, y, z, w) \
{ \
cerr << (#x) << "=" << (x) << " " << (#y) << "=" << (y) << " " \
<< (#z) << "=" << (z) << " " << (#w) << "=" << w << endl; \
}
#define bug5(x, y, z, w, p) \
{ \
cerr << (#x) << "=" << (x) << " " << (#y) << "=" << (y) << " " \
<< (#z) << "=" << (z) << " " << (#w) << "=" << w << " " << (#p) \
<< "=" << p << endl; \
}
#define bug6(x, y, z, w, p, q) \
{ \
cerr << (#x) << "=" << (x) << " " << (#y) << "=" << (y) << " " \
<< (#z) << "=" << (z) << " " << (#w) << "=" << w << " " << (#p) \
<< "=" << p << " " << (#q) << "=" << q << endl; \
}
#define bugn(x, n) \
{ \
cerr << (#x) << ":"; \
for (int i = 0; i < n; i++) \
cerr << x[i] << " "; \
cerr << endl; \
}
#define bugnm(x, n, m) \
{ \
cerr << (#x) << endl; \
for (int i = 0; i < n; i++) { \
cerr << "Row #" << i << ":"; \
for (int j = 0; j < m; j++) \
cerr << x[i][j] << " "; \
cerr << endl; \
} \
}
typedef long long ll;
typedef long double ld;
using namespace std;
const int maxn = 2000 + 10;
int l[maxn][maxn], r[maxn][maxn], u[maxn][maxn], d[maxn][maxn];
int32_t main() {
IOS for (int i = 0; i < maxn; i++) {
for (int j = 0; j < maxn; j++) {
l[i][j] = r[i][j] = u[i][j] = d[i][j] = 0;
}
}
int n, m;
cin >> n >> m;
vector<string> s(n + 1);
for (int i = 1; i <= n; i++) {
cin >> s[i];
s[i] = '$' + s[i];
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
u[i][j] = s[i][j] == '#' ? 0 : u[i - 1][j] + 1;
}
}
for (int i = n; i >= 1; i--) {
for (int j = 1; j <= m; j++) {
d[i][j] = s[i][j] == '#' ? 0 : d[i + 1][j] + 1;
}
}
for (int j = 1; j <= m; j++) {
for (int i = 1; i <= n; i++) {
l[i][j] = s[i][j] == '#' ? 0 : l[i][j - 1] + 1;
}
}
for (int j = m; j >= 1; j--) {
for (int i = 1; i <= n; i++) {
r[i][j] = s[i][j] == '#' ? 0 : r[i][j + 1] + 1;
}
}
int ans = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
// bug6(i,j,u[i][j],d[i][j],l[i][j],r[i][j]);
if (s[i][j] == '.') {
ans = max(ans, l[i][j] + r[i][j] + u[i][j] + d[i][j] - 4 + 1);
}
}
}
cout << ans;
}
/*
* long long or int?
* index out of bound?
* Tested on own test case?corner?
* Make more general solution.
* Read Read Read Read ....
*/
| [
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 827,672 | 827,673 | u392058778 | cpp |
p03014 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
// curという変数に「最後の壁から何マス来たのかを格納しておいて、iが壁なら0に戻し、iが通路ならお¥インクリメントする
// 4方向分のcurの情報をleft,right,up,downに格納する
int Left[2100][2100], Right[2100][2100], Up[2100][2100], Down[2100][2100];
int h, w;
int main() {
cin >> h >> w;
vector<string> s(h);
rep(i, h) cin >> s.at(i);
//前処理
rep(i, h) {
int cur = 0;
rep(j, w) {
if (s[i][j] == '#')
cur = 0;
else
cur++;
Left[i][j] = cur;
}
}
rep(i, h) {
int cur = 0;
for (int j = w - 1; j >= 0; j--) {
if (s[i][j] == '#')
cur = 0;
else
cur++;
Right[i][j] = cur;
}
}
rep(j, w) {
int cur = 0;
rep(i, h) {
if (s[i][j] == '#')
cur = 0;
else
cur++;
Up[i][j] = cur;
}
}
rep(j, w) {
int cur = 0;
for (int i = h - 1; i >= 0; i--) {
if (s[i][j] == '#')
cur = 0;
else
cur++;
Down[i][j] = cur;
}
}
//集計
int res = 0;
rep(i, h) {
rep(j, w) {
if (s[i][j] == '#')
continue; //壁に光源は置けないので無視
res = max(res, Left[i][j] + Right[i][j] + Up[i][j] + Down[i][j]);
}
}
cout << res << endl;
} |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
// curという変数に「最後の壁から何マス来たのかを格納しておいて、iが壁なら0に戻し、iが通路ならお¥インクリメントする
// 4方向分のcurの情報をleft,right,up,downに格納する
int Left[2100][2100], Right[2100][2100], Up[2100][2100], Down[2100][2100];
int h, w;
int main() {
cin >> h >> w;
vector<string> s(h);
rep(i, h) cin >> s.at(i);
//前処理
rep(i, h) {
int cur = 0;
rep(j, w) {
if (s[i][j] == '#')
cur = 0;
else
cur++;
Left[i][j] = cur;
}
}
rep(i, h) {
int cur = 0;
for (int j = w - 1; j >= 0; j--) {
if (s[i][j] == '#')
cur = 0;
else
cur++;
Right[i][j] = cur;
}
}
rep(j, w) {
int cur = 0;
rep(i, h) {
if (s[i][j] == '#')
cur = 0;
else
cur++;
Up[i][j] = cur;
}
}
rep(j, w) {
int cur = 0;
for (int i = h - 1; i >= 0; i--) {
if (s[i][j] == '#')
cur = 0;
else
cur++;
Down[i][j] = cur;
}
}
//集計
int res = 0;
rep(i, h) {
rep(j, w) {
if (s[i][j] == '#')
continue; //壁に光源は置けないので無視
res = max(res, Left[i][j] + Right[i][j] + Up[i][j] + Down[i][j] - 3);
}
}
cout << res << endl;
} | [
"assignment.change"
] | 827,678 | 827,679 | u412057008 | cpp |
p03013 | #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned int ui;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
#define All(v) (v).begin(), (v).end()
#define Rep(i, n) for (int i = 0; i < (int)n; i++)
#define Reps(i, n) for (int i = 1; i <= (int)n; i++)
#define For(i, m, n) for (int i = m; i < n; i++)
#define Fors(i, m, n) for (int i = m; i <= n; i++)
#define Inf 2e9
#define F first
#define S second
#define pb push_back
#define mp make_pair
struct speed {
speed() {
cin.tie();
ios::sync_with_stdio(false);
cout << fixed << setprecision(18);
}
} speed;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
ll gcd(ll a, ll b) {
if (b == 0)
return a;
else
return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
int main() {
int n, m;
cin >> n >> m;
vector<bool> b(n + 1, true);
vector<ll> cnt(n + 1, 1);
Rep(i, m) {
int tmp;
cin >> tmp;
b[tmp] = false;
}
cnt[0] = 1;
cnt[1] = (b[1] == true) ? 1 : 0;
Fors(i, 2, n) { cnt[i] = (b[i] == true) ? cnt[i - 1] + cnt[i - 2] : 0; }
cout << cnt[n] % 1000000007 << "\n";
} | #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned int ui;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
#define All(v) (v).begin(), (v).end()
#define Rep(i, n) for (int i = 0; i < (int)n; i++)
#define Reps(i, n) for (int i = 1; i <= (int)n; i++)
#define For(i, m, n) for (int i = m; i < n; i++)
#define Fors(i, m, n) for (int i = m; i <= n; i++)
#define Inf 2e9
#define F first
#define S second
#define pb push_back
#define mp make_pair
struct speed {
speed() {
cin.tie();
ios::sync_with_stdio(false);
cout << fixed << setprecision(18);
}
} speed;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
ll gcd(ll a, ll b) {
if (b == 0)
return a;
else
return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
int main() {
int n, m;
cin >> n >> m;
vector<bool> b(n + 1, true);
vector<ll> cnt(n + 1, 1);
Rep(i, m) {
int tmp;
cin >> tmp;
b[tmp] = false;
}
cnt[0] = 1;
cnt[1] = (b[1] == true) ? 1 : 0;
Fors(i, 2, n) {
cnt[i] = (b[i] == true) ? (cnt[i - 1] + cnt[i - 2]) % 1000000007 : 0;
}
cout << cnt[n] << "\n";
} | [
"expression.operation.binary.remove"
] | 827,691 | 827,692 | u658899890 | cpp |
p03013 | #include <bits/stdc++.h>
using namespace std;
#define all(x) begin(x), end(x)
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n, m;
cin >> n >> m;
vi a(n + 1, 0);
vi b(n + 1, 0);
for (int i = 0; i < n; ++i) {
int x;
cin >> x;
b[x] = 1;
}
constexpr int MOD = 1e9 + 7;
a[0] = 1;
for (int i = 0; i < n; ++i) {
if (b[i])
continue;
for (int j = 1; j <= 2; ++j) {
if (i + j <= n) {
a[i + j] += a[i];
a[i + j] %= MOD;
}
}
}
cout << a[n] << '\n';
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define all(x) begin(x), end(x)
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n, m;
cin >> n >> m;
vi a(n + 1, 0);
vi b(n + 1, 0);
for (int i = 0; i < m; ++i) {
int x;
cin >> x;
b[x] = 1;
}
constexpr int MOD = 1e9 + 7;
a[0] = 1;
for (int i = 0; i < n; ++i) {
if (b[i])
continue;
for (int j = 1; j <= 2; ++j) {
if (i + j <= n) {
a[i + j] += a[i];
a[i + j] %= MOD;
}
}
}
cout << a[n] << '\n';
return 0;
}
| [
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 827,695 | 827,696 | u906129425 | cpp |
p03013 | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) loop(i, 0, n)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll, ll>
#define vpll vector<pll>
int main() {
int n, m;
cin >> n >> m;
vector<bool> f(n + 1);
rep(i, n + 1) {
int tmp;
cin >> tmp;
f[tmp] = true;
}
vl dp(n + 2);
ll int con = 1000000007;
dp[n] = 1;
for (int i = n - 1; i >= 0; i--) {
if (f[i]) {
dp[i] = 0;
continue;
}
dp[i] = (dp[i + 1] + dp[i + 2]) % con;
}
cout << dp[0] << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) loop(i, 0, n)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll, ll>
#define vpll vector<pll>
int main() {
int n, m;
cin >> n >> m;
vector<bool> f(n + 1);
rep(i, m) {
int tmp;
cin >> tmp;
f[tmp] = true;
}
vl dp(n + 2);
ll int con = 1000000007;
dp[n] = 1;
for (int i = n - 1; i >= 0; i--) {
if (f[i]) {
dp[i] = 0;
continue;
}
dp[i] = (dp[i + 1] + dp[i + 2]) % con;
}
cout << dp[0] << endl;
}
| [
"call.arguments.change",
"expression.operation.binary.change",
"expression.operation.binary.remove"
] | 827,718 | 827,719 | u445922306 | cpp |
p03013 | #include <bits/stdc++.h>
#define int long long
using namespace std;
// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<PII> VP;
// REPEAT
//------------------------------------------
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define RFOR(i, m, n) for (int i = m; i > n; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, m) RFOR(i, m, 0)
// container util
//------------------------------------------
#define pb(a) push_back(a)
#define fst first
#define snd second
#define SORT(V) sort((V).begin(), (V).end())
#define REV(V) reverse((V).begin(), (V).end())
// constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI = acos(-1.0);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
// grobal variable
//------------------------------------------
// def function, class
//------------------------------------------
// main
//------------------------------------------
signed main() {
int N, M;
cin >> N >> M;
VI broken(N + 1); //壊れているブロックのbool表
REP(i, M) {
int a = 0;
cin >> a;
broken[a] = 1;
}
VI dp(N + 1);
dp[N] = 1;
dp[N + 1] = 0;
REP(i, N) {
if (broken[N - i - 1])
continue;
dp[N - i - 1] = (dp[N - i] + dp[N - i + 1]) % MOD;
}
cout << dp[0] << endl;
return 0;
}
| #include <bits/stdc++.h>
#define int long long
using namespace std;
// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<PII> VP;
// REPEAT
//------------------------------------------
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define RFOR(i, m, n) for (int i = m; i > n; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, m) RFOR(i, m, 0)
// container util
//------------------------------------------
#define pb(a) push_back(a)
#define fst first
#define snd second
#define SORT(V) sort((V).begin(), (V).end())
#define REV(V) reverse((V).begin(), (V).end())
// constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI = acos(-1.0);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
// grobal variable
//------------------------------------------
// def function, class
//------------------------------------------
// main
//------------------------------------------
signed main() {
int N, M;
cin >> N >> M;
VI broken(N + 1); //壊れているブロックのbool表
REP(i, M) {
int a = 0;
cin >> a;
broken[a] = 1;
}
VI dp(N + 10);
dp[N] = 1;
dp[N + 1] = 0;
REP(i, N) {
if (broken[N - i - 1])
continue;
dp[N - i - 1] = (dp[N - i] + dp[N - i + 1]) % MOD;
}
cout << dp[0] << endl;
return 0;
}
| [
"literal.number.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 827,748 | 827,749 | u055131803 | cpp |
p03013 | #include <bits/stdc++.h>
using namespace std;
int N, M;
int main() {
cin >> N >> M;
vector<int> a(N + 1, 1);
int c;
for (int j = 0; j < M; j++) {
cin >> c;
a.at(c) = 0;
}
if (N < 3) {
cout << 1 << endl;
return 0;
}
for (int j = N - 2; j >= 0; j--) {
if (a.at(j) == 1)
a.at(j) = (a.at(j + 1) + a.at(j + 2)) % 1000000007;
}
cout << a[0] << endl;
} | #include <bits/stdc++.h>
using namespace std;
int N, M;
int main() {
cin >> N >> M;
vector<int> a(N + 1, 1);
int c;
for (int j = 0; j < M; j++) {
cin >> c;
a.at(c) = 0;
}
if (N == 1) {
cout << 1 << endl;
return 0;
}
for (int j = N - 2; j >= 0; j--) {
if (a.at(j) == 1)
a.at(j) = (a.at(j + 1) + a.at(j + 2)) % 1000000007;
}
cout << a[0] << endl;
} | [] | 827,828 | 827,829 | u326609687 | cpp |
p03014 | /*
これを入れて実行
g++ code.cpp
./a.out
*/
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef long double ld;
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
bool greaterSecond(const pair<int, int> &f, const pair<int, int> &s) {
return f.second > s.second;
}
ll gcd(ll a, ll b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll nCr(ll n, ll r) {
if (r == 0 || r == n) {
return 1;
} else if (r == 1) {
return n;
}
return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
ll nPr(ll n, ll r) {
r = n - r;
ll ret = 1;
for (ll i = n; i >= r + 1; i--)
ret *= i;
return ret;
}
//-----------------------ここから-----------
int main(void) {
int h, w;
cin >> h >> w;
vector<string> s(h);
for (int i = 0; i < h; i++)
cin >> s[i];
vector<vector<int>> holi(h, vector<int>(w, 0));
vector<vector<int>> vert(h, vector<int>(w, 0));
int cnt = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if (j == w - 1 && s[i][j] == '.')
cnt++;
if (s[i][j] == '#' || j == w - 1) {
for (int k = j - 1; k >= max(j - cnt, 0); k--) {
holi[i][k] = cnt;
}
cnt = 0;
} else {
cnt++;
}
}
cnt = 0;
}
cnt = 0;
for (int j = 0; j < w; j++) {
for (int i = 0; i < h; i++) {
if (i == h - 1 && s[i][j] == '.')
cnt++;
if (s[i][j] == '#' || i == h - 1) {
for (int k = i - 1; k >= max(i - cnt, 0); k--) {
vert[k][j] = cnt;
}
cnt = 0;
} else {
cnt++;
}
}
cnt = 0;
}
int ans = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if (s[i][j] == '#')
continue;
ans = max(ans, holi[i][j] + vert[i][j] - 1);
}
}
cout << ans << endl;
}
| /*
これを入れて実行
g++ code.cpp
./a.out
*/
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef long double ld;
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
bool greaterSecond(const pair<int, int> &f, const pair<int, int> &s) {
return f.second > s.second;
}
ll gcd(ll a, ll b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll nCr(ll n, ll r) {
if (r == 0 || r == n) {
return 1;
} else if (r == 1) {
return n;
}
return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
ll nPr(ll n, ll r) {
r = n - r;
ll ret = 1;
for (ll i = n; i >= r + 1; i--)
ret *= i;
return ret;
}
//-----------------------ここから-----------
int main(void) {
int h, w;
cin >> h >> w;
vector<string> s(h);
for (int i = 0; i < h; i++)
cin >> s[i];
vector<vector<int>> holi(h, vector<int>(w, 0));
vector<vector<int>> vert(h, vector<int>(w, 0));
int cnt = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if (j == w - 1 && s[i][j] == '.')
cnt++;
if (s[i][j] == '#' || j == w - 1) {
for (int k = j; k >= max(j - cnt, 0); k--) {
holi[i][k] = cnt;
}
cnt = 0;
} else {
cnt++;
}
}
cnt = 0;
}
cnt = 0;
for (int j = 0; j < w; j++) {
for (int i = 0; i < h; i++) {
if (i == h - 1 && s[i][j] == '.')
cnt++;
if (s[i][j] == '#' || i == h - 1) {
for (int k = i; k >= max(i - cnt, 0); k--) {
vert[k][j] = cnt;
}
cnt = 0;
} else {
cnt++;
}
}
cnt = 0;
}
int ans = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if (s[i][j] == '#')
continue;
ans = max(ans, holi[i][j] + vert[i][j] - 1);
}
}
cout << ans << endl;
}
| [
"control_flow.loop.for.initializer.change",
"expression.operation.binary.remove"
] | 827,840 | 827,841 | u845000384 | cpp |
p03014 | /*
** Vishal Raj Roy
** Indian Institute of Technology Kharagpur
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define at(X, N) get<N>(X)
#define xx first
#define yy second
#define sz(x) ((int)x.size())
#define nl cout << "\n";
// FOR(i,1,10) gives 1,2,3,....,9 and FOR(i,10,1) gives 9,8,....,1 also FOR(it,
// end(v), begin(v)) and FOR(it, begin(v), end(v))
#define FOR(i, begin, end) \
for (__typeof(end) i = (begin) - ((begin) > (end)); \
i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define SEL(X, C) for (auto &X : C)
#define ima INT_MAX
#define imi INT_MIN
#define lma LLONG_MAX
#define lmi LLONG_MIN
#define name(X) (#X)
#define tl(args...) \
{ \
string _s = #args; \
replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); \
istream_iterator<string> _it(_ss); \
tell(_it, args); \
}
#define tk(args...) take(args);
void tell(istream_iterator<string> it) {}
template <typename T, typename... Args>
void tell(istream_iterator<string> it, T a, Args... args) {
cout << *it << " = " << a << "\n";
tell(++it, args...);
}
void take() {}
template <typename T, typename... Args> void take(T &a, Args &...args) {
cin >> a;
take(args...);
}
template <class T> struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
T operator()(uint64_t x) const {
static const uint64_t FIXED_RANDOM =
chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(x + FIXED_RANDOM);
}
T operator()(tuple<uint64_t, uint64_t> x) const {
static const uint64_t FIXED_RANDOM =
chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(get<0>(x) + FIXED_RANDOM) ^
(splitmix64(get<1>(x) + FIXED_RANDOM) >> 1);
}
}; // T operator()(pair<uint64_t,uint64_t> x) const { static const uint64_t
// FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
// return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second +
// FIXED_RANDOM) >> 1); } };
template <class L, class R> ostream &operator<<(ostream &os, pair<L, R> P) {
return os << "(" << P.xx << "," << P.yy << ")";
}
template <class L, class R> ostream &operator<<(ostream &os, tuple<L, R> P) {
return os << "(" << get<0>(P) << "," << get<1>(P) << ")";
}
template <class L, class R, class S>
ostream &operator<<(ostream &os, tuple<L, R, S> P) {
return os << "(" << get<0>(P) << "," << get<1>(P) << "," << get<2>(P) << ")";
}
template <class T, class A> ostream &operator<<(ostream &os, vector<T, A> V) {
os /*<< name(V)<< " is "*/ << "\n";
FOR(i, 0, sz(V)) os << " " << name(V) << "[" << i << "] = " << V[i] << "\n";
return os; /*<<"\n";*/
}
template <class T, class H, class P, class A>
ostream &operator<<(ostream &os, unordered_set<T, H, P, A> S) {
os /*name(S) << " is"*/ << " [";
int i = 0;
for (auto ELE : S) {
os << ELE;
if (i < sz(S) - 1)
os << ", ";
i++;
}
return os << "]"; /*<<"\n"; */
}
template <class S, class T, class H, class P, class A>
ostream &operator<<(ostream &os, unordered_map<S, T, H, P, A> M) {
os /*name(S) << " is"*/ << "\n";
for (auto ELE : M)
os << " " << name(M) << "[" << ELE.xx << "] = " << ELE.yy << "\n";
return os; /*<<"\n";*/
}
template <class T, class C, class A>
ostream &operator<<(ostream &os, multiset<T, C, A> S) {
os /*name(S) << " is"*/ << "[";
int i = 0;
for (auto ELE : S) {
os << ELE;
if (i < sz(S) - 1)
os << ", ";
i++;
}
return os << "]"; /*<<"\n"; */
}
template <class T, class R>
ostream &operator<<(ostream &os,
gp_hash_table<T, null_type, custom_hash<R>> S) {
os /*name(S) << " is"*/ << " [";
int i = 0;
for (auto ELE : S) {
os << ELE;
if (i < sz(S) - 1)
os << ", ";
i++;
}
return os << "]"; /*<<"\n"; */
}
template <class T, class Z, class R>
ostream &operator<<(ostream &os, gp_hash_table<T, Z, custom_hash<R>> M) {
os /*name(S) << " is"*/ << "\n";
for (auto ELE : M)
os << " " << name(M) << "[" << ELE.xx << "] = " << ELE.yy << "\n";
return os; /*<<"\n";*/
}
template <class T, class R>
ostream &operator<<(ostream &os,
cc_hash_table<T, null_type, custom_hash<R>> S) {
os /*name(S) << " is"*/ << " [";
int i = 0;
for (auto ELE : S) {
os << ELE;
if (i < sz(S) - 1)
os << ", ";
i++;
}
return os << "]"; /*<<"\n"; */
}
template <class T, class Z, class R>
ostream &operator<<(ostream &os, cc_hash_table<T, Z, custom_hash<R>> M) {
os /*name(S) << " is"*/ << "\n";
for (auto ELE : M)
os << " " << name(M) << "[" << ELE.xx << "] = " << ELE.yy << "\n";
return os; /*<<"\n";*/
}
template <class L, class R> istream &operator>>(ostream &os, pair<L, R> &P) {
return os >> P.xx >> P.yy;
}
template <class L> istream &operator>>(istream &os, vector<L> &V) {
FOR(i, 0, sz(V)) os >> V[i];
return os;
}
template <class L> istream &operator>>(istream &os, vector<vector<L>> &V) {
FOR(i, 0, sz(V)) os >> V[i];
return os;
}
using st = string;
typedef long long int li;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef tuple<int, int> i2;
typedef tuple<int, int, int> i3;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<i2> vi2;
typedef vector<i3> vi3;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<li, li> ll;
typedef pair<li, ll> lll;
typedef tuple<li, li> l2;
typedef tuple<li, li, li> l3;
typedef vector<li> vl;
typedef vector<ll> vll;
typedef vector<l2> vl2;
typedef vector<l3> vl3;
typedef vector<lll> vlll;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef double db;
typedef complex<db> cd;
typedef vector<cd> vcd;
template <class S> using ve = vector<S>;
template <class S> using gr = greater<S>;
template <class S> using le = less<S>;
template <class S, class T = le<S>> using ms = multiset<S, T>;
template <class S, class T = null_type, class R = size_t>
using gp = gp_hash_table<S, T, custom_hash<R>>;
template <class S, class T = null_type, class R = size_t>
using cc = cc_hash_table<S, T, custom_hash<R>>;
template <class S, class T, class R = size_t>
using um = unordered_map<S, T, custom_hash<R>>;
template <class S, class R = size_t>
using us = unordered_set<S, custom_hash<R>>;
const double pi = 2 * acos(0.0);
const int oo = 0x3f3f3f3f; // don't use for long long
const double inf = 1.0 / 0.0;
int main() {
ios_base::sync_with_stdio(0);
int h, w;
tk(h, w);
char m[h][w];
FOR(i, 0, h) {
FOR(j, 0, w) { cin >> m[i][j]; }
}
int a[4][h][w] = {-1};
FOR(i, 0, h) {
int le = -1;
FOR(j, 0, w) {
if (m[i][j] == '#') {
le = max(le, j);
} else
a[0][i][j] = le;
}
int ri = w;
FOR(j, w, 0) {
if (m[i][j] == '#') {
ri = min(ri, j);
} else
a[1][i][j] = ri;
}
}
FOR(j, 0, w) {
int le = -1;
FOR(i, 0, h) {
if (m[i][j] == '#') {
le = max(le, j);
} else
a[2][i][j] = le;
}
int ri = h;
FOR(i, h, 0) {
if (m[i][j] == '#') {
ri = min(ri, j);
} else
a[3][i][j] = ri;
}
}
int val = 1;
FOR(i, 0, h) {
FOR(j, 0, w) {
if (m[i][j] != '#') {
val = max(val, -a[0][i][j] + a[1][i][j] - a[2][i][j] + a[3][i][j] - 3);
}
}
}
cout << val << "\n";
return 0;
}
| /*
** Vishal Raj Roy
** Indian Institute of Technology Kharagpur
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define at(X, N) get<N>(X)
#define xx first
#define yy second
#define sz(x) ((int)x.size())
#define nl cout << "\n";
// FOR(i,1,10) gives 1,2,3,....,9 and FOR(i,10,1) gives 9,8,....,1 also FOR(it,
// end(v), begin(v)) and FOR(it, begin(v), end(v))
#define FOR(i, begin, end) \
for (__typeof(end) i = (begin) - ((begin) > (end)); \
i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define SEL(X, C) for (auto &X : C)
#define ima INT_MAX
#define imi INT_MIN
#define lma LLONG_MAX
#define lmi LLONG_MIN
#define name(X) (#X)
#define tl(args...) \
{ \
string _s = #args; \
replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); \
istream_iterator<string> _it(_ss); \
tell(_it, args); \
}
#define tk(args...) take(args);
void tell(istream_iterator<string> it) {}
template <typename T, typename... Args>
void tell(istream_iterator<string> it, T a, Args... args) {
cout << *it << " = " << a << "\n";
tell(++it, args...);
}
void take() {}
template <typename T, typename... Args> void take(T &a, Args &...args) {
cin >> a;
take(args...);
}
template <class T> struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
T operator()(uint64_t x) const {
static const uint64_t FIXED_RANDOM =
chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(x + FIXED_RANDOM);
}
T operator()(tuple<uint64_t, uint64_t> x) const {
static const uint64_t FIXED_RANDOM =
chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(get<0>(x) + FIXED_RANDOM) ^
(splitmix64(get<1>(x) + FIXED_RANDOM) >> 1);
}
}; // T operator()(pair<uint64_t,uint64_t> x) const { static const uint64_t
// FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
// return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second +
// FIXED_RANDOM) >> 1); } };
template <class L, class R> ostream &operator<<(ostream &os, pair<L, R> P) {
return os << "(" << P.xx << "," << P.yy << ")";
}
template <class L, class R> ostream &operator<<(ostream &os, tuple<L, R> P) {
return os << "(" << get<0>(P) << "," << get<1>(P) << ")";
}
template <class L, class R, class S>
ostream &operator<<(ostream &os, tuple<L, R, S> P) {
return os << "(" << get<0>(P) << "," << get<1>(P) << "," << get<2>(P) << ")";
}
template <class T, class A> ostream &operator<<(ostream &os, vector<T, A> V) {
os /*<< name(V)<< " is "*/ << "\n";
FOR(i, 0, sz(V)) os << " " << name(V) << "[" << i << "] = " << V[i] << "\n";
return os; /*<<"\n";*/
}
template <class T, class H, class P, class A>
ostream &operator<<(ostream &os, unordered_set<T, H, P, A> S) {
os /*name(S) << " is"*/ << " [";
int i = 0;
for (auto ELE : S) {
os << ELE;
if (i < sz(S) - 1)
os << ", ";
i++;
}
return os << "]"; /*<<"\n"; */
}
template <class S, class T, class H, class P, class A>
ostream &operator<<(ostream &os, unordered_map<S, T, H, P, A> M) {
os /*name(S) << " is"*/ << "\n";
for (auto ELE : M)
os << " " << name(M) << "[" << ELE.xx << "] = " << ELE.yy << "\n";
return os; /*<<"\n";*/
}
template <class T, class C, class A>
ostream &operator<<(ostream &os, multiset<T, C, A> S) {
os /*name(S) << " is"*/ << "[";
int i = 0;
for (auto ELE : S) {
os << ELE;
if (i < sz(S) - 1)
os << ", ";
i++;
}
return os << "]"; /*<<"\n"; */
}
template <class T, class R>
ostream &operator<<(ostream &os,
gp_hash_table<T, null_type, custom_hash<R>> S) {
os /*name(S) << " is"*/ << " [";
int i = 0;
for (auto ELE : S) {
os << ELE;
if (i < sz(S) - 1)
os << ", ";
i++;
}
return os << "]"; /*<<"\n"; */
}
template <class T, class Z, class R>
ostream &operator<<(ostream &os, gp_hash_table<T, Z, custom_hash<R>> M) {
os /*name(S) << " is"*/ << "\n";
for (auto ELE : M)
os << " " << name(M) << "[" << ELE.xx << "] = " << ELE.yy << "\n";
return os; /*<<"\n";*/
}
template <class T, class R>
ostream &operator<<(ostream &os,
cc_hash_table<T, null_type, custom_hash<R>> S) {
os /*name(S) << " is"*/ << " [";
int i = 0;
for (auto ELE : S) {
os << ELE;
if (i < sz(S) - 1)
os << ", ";
i++;
}
return os << "]"; /*<<"\n"; */
}
template <class T, class Z, class R>
ostream &operator<<(ostream &os, cc_hash_table<T, Z, custom_hash<R>> M) {
os /*name(S) << " is"*/ << "\n";
for (auto ELE : M)
os << " " << name(M) << "[" << ELE.xx << "] = " << ELE.yy << "\n";
return os; /*<<"\n";*/
}
template <class L, class R> istream &operator>>(ostream &os, pair<L, R> &P) {
return os >> P.xx >> P.yy;
}
template <class L> istream &operator>>(istream &os, vector<L> &V) {
FOR(i, 0, sz(V)) os >> V[i];
return os;
}
template <class L> istream &operator>>(istream &os, vector<vector<L>> &V) {
FOR(i, 0, sz(V)) os >> V[i];
return os;
}
using st = string;
typedef long long int li;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef tuple<int, int> i2;
typedef tuple<int, int, int> i3;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<i2> vi2;
typedef vector<i3> vi3;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<li, li> ll;
typedef pair<li, ll> lll;
typedef tuple<li, li> l2;
typedef tuple<li, li, li> l3;
typedef vector<li> vl;
typedef vector<ll> vll;
typedef vector<l2> vl2;
typedef vector<l3> vl3;
typedef vector<lll> vlll;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef double db;
typedef complex<db> cd;
typedef vector<cd> vcd;
template <class S> using ve = vector<S>;
template <class S> using gr = greater<S>;
template <class S> using le = less<S>;
template <class S, class T = le<S>> using ms = multiset<S, T>;
template <class S, class T = null_type, class R = size_t>
using gp = gp_hash_table<S, T, custom_hash<R>>;
template <class S, class T = null_type, class R = size_t>
using cc = cc_hash_table<S, T, custom_hash<R>>;
template <class S, class T, class R = size_t>
using um = unordered_map<S, T, custom_hash<R>>;
template <class S, class R = size_t>
using us = unordered_set<S, custom_hash<R>>;
const double pi = 2 * acos(0.0);
const int oo = 0x3f3f3f3f; // don't use for long long
const double inf = 1.0 / 0.0;
int main() {
ios_base::sync_with_stdio(0);
int h, w;
tk(h, w);
char m[h][w];
FOR(i, 0, h) {
FOR(j, 0, w) { cin >> m[i][j]; }
}
int a[4][h][w] = {-1};
FOR(i, 0, h) {
int le = -1;
FOR(j, 0, w) {
if (m[i][j] == '#') {
le = max(le, j);
} else
a[0][i][j] = le;
}
int ri = w;
FOR(j, w, 0) {
if (m[i][j] == '#') {
ri = min(ri, j);
} else
a[1][i][j] = ri;
}
}
FOR(j, 0, w) {
int le = -1;
FOR(i, 0, h) {
if (m[i][j] == '#') {
le = max(le, i);
} else
a[2][i][j] = le;
}
int ri = h;
FOR(i, h, 0) {
if (m[i][j] == '#') {
ri = min(ri, i);
} else
a[3][i][j] = ri;
}
}
int val = 1;
FOR(i, 0, h) {
FOR(j, 0, w) {
if (m[i][j] != '#') {
val = max(val, -a[0][i][j] + a[1][i][j] - a[2][i][j] + a[3][i][j] - 3);
}
}
}
cout << val << "\n";
return 0;
}
| [
"assignment.value.change",
"identifier.change",
"call.arguments.change"
] | 827,842 | 827,843 | u027266662 | cpp |
p03014 | /*
** Vishal Raj Roy
** Indian Institute of Technology Kharagpur
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define at(X, N) get<N>(X)
#define xx first
#define yy second
#define sz(x) ((int)x.size())
#define nl cout << "\n";
// FOR(i,1,10) gives 1,2,3,....,9 and FOR(i,10,1) gives 9,8,....,1 also FOR(it,
// end(v), begin(v)) and FOR(it, begin(v), end(v))
#define FOR(i, begin, end) \
for (__typeof(end) i = (begin) - ((begin) > (end)); \
i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define SEL(X, C) for (auto &X : C)
#define ima INT_MAX
#define imi INT_MIN
#define lma LLONG_MAX
#define lmi LLONG_MIN
#define name(X) (#X)
#define tl(args...) \
{ \
string _s = #args; \
replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); \
istream_iterator<string> _it(_ss); \
tell(_it, args); \
}
#define tk(args...) take(args);
void tell(istream_iterator<string> it) {}
template <typename T, typename... Args>
void tell(istream_iterator<string> it, T a, Args... args) {
cout << *it << " = " << a << "\n";
tell(++it, args...);
}
void take() {}
template <typename T, typename... Args> void take(T &a, Args &...args) {
cin >> a;
take(args...);
}
template <class T> struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
T operator()(uint64_t x) const {
static const uint64_t FIXED_RANDOM =
chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(x + FIXED_RANDOM);
}
T operator()(tuple<uint64_t, uint64_t> x) const {
static const uint64_t FIXED_RANDOM =
chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(get<0>(x) + FIXED_RANDOM) ^
(splitmix64(get<1>(x) + FIXED_RANDOM) >> 1);
}
}; // T operator()(pair<uint64_t,uint64_t> x) const { static const uint64_t
// FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
// return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second +
// FIXED_RANDOM) >> 1); } };
template <class L, class R> ostream &operator<<(ostream &os, pair<L, R> P) {
return os << "(" << P.xx << "," << P.yy << ")";
}
template <class L, class R> ostream &operator<<(ostream &os, tuple<L, R> P) {
return os << "(" << get<0>(P) << "," << get<1>(P) << ")";
}
template <class L, class R, class S>
ostream &operator<<(ostream &os, tuple<L, R, S> P) {
return os << "(" << get<0>(P) << "," << get<1>(P) << "," << get<2>(P) << ")";
}
template <class T, class A> ostream &operator<<(ostream &os, vector<T, A> V) {
os /*<< name(V)<< " is "*/ << "\n";
FOR(i, 0, sz(V)) os << " " << name(V) << "[" << i << "] = " << V[i] << "\n";
return os; /*<<"\n";*/
}
template <class T, class H, class P, class A>
ostream &operator<<(ostream &os, unordered_set<T, H, P, A> S) {
os /*name(S) << " is"*/ << " [";
int i = 0;
for (auto ELE : S) {
os << ELE;
if (i < sz(S) - 1)
os << ", ";
i++;
}
return os << "]"; /*<<"\n"; */
}
template <class S, class T, class H, class P, class A>
ostream &operator<<(ostream &os, unordered_map<S, T, H, P, A> M) {
os /*name(S) << " is"*/ << "\n";
for (auto ELE : M)
os << " " << name(M) << "[" << ELE.xx << "] = " << ELE.yy << "\n";
return os; /*<<"\n";*/
}
template <class T, class C, class A>
ostream &operator<<(ostream &os, multiset<T, C, A> S) {
os /*name(S) << " is"*/ << "[";
int i = 0;
for (auto ELE : S) {
os << ELE;
if (i < sz(S) - 1)
os << ", ";
i++;
}
return os << "]"; /*<<"\n"; */
}
template <class T, class R>
ostream &operator<<(ostream &os,
gp_hash_table<T, null_type, custom_hash<R>> S) {
os /*name(S) << " is"*/ << " [";
int i = 0;
for (auto ELE : S) {
os << ELE;
if (i < sz(S) - 1)
os << ", ";
i++;
}
return os << "]"; /*<<"\n"; */
}
template <class T, class Z, class R>
ostream &operator<<(ostream &os, gp_hash_table<T, Z, custom_hash<R>> M) {
os /*name(S) << " is"*/ << "\n";
for (auto ELE : M)
os << " " << name(M) << "[" << ELE.xx << "] = " << ELE.yy << "\n";
return os; /*<<"\n";*/
}
template <class T, class R>
ostream &operator<<(ostream &os,
cc_hash_table<T, null_type, custom_hash<R>> S) {
os /*name(S) << " is"*/ << " [";
int i = 0;
for (auto ELE : S) {
os << ELE;
if (i < sz(S) - 1)
os << ", ";
i++;
}
return os << "]"; /*<<"\n"; */
}
template <class T, class Z, class R>
ostream &operator<<(ostream &os, cc_hash_table<T, Z, custom_hash<R>> M) {
os /*name(S) << " is"*/ << "\n";
for (auto ELE : M)
os << " " << name(M) << "[" << ELE.xx << "] = " << ELE.yy << "\n";
return os; /*<<"\n";*/
}
template <class L, class R> istream &operator>>(ostream &os, pair<L, R> &P) {
return os >> P.xx >> P.yy;
}
template <class L> istream &operator>>(istream &os, vector<L> &V) {
FOR(i, 0, sz(V)) os >> V[i];
return os;
}
template <class L> istream &operator>>(istream &os, vector<vector<L>> &V) {
FOR(i, 0, sz(V)) os >> V[i];
return os;
}
using st = string;
typedef long long int li;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef tuple<int, int> i2;
typedef tuple<int, int, int> i3;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<i2> vi2;
typedef vector<i3> vi3;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<li, li> ll;
typedef pair<li, ll> lll;
typedef tuple<li, li> l2;
typedef tuple<li, li, li> l3;
typedef vector<li> vl;
typedef vector<ll> vll;
typedef vector<l2> vl2;
typedef vector<l3> vl3;
typedef vector<lll> vlll;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef double db;
typedef complex<db> cd;
typedef vector<cd> vcd;
template <class S> using ve = vector<S>;
template <class S> using gr = greater<S>;
template <class S> using le = less<S>;
template <class S, class T = le<S>> using ms = multiset<S, T>;
template <class S, class T = null_type, class R = size_t>
using gp = gp_hash_table<S, T, custom_hash<R>>;
template <class S, class T = null_type, class R = size_t>
using cc = cc_hash_table<S, T, custom_hash<R>>;
template <class S, class T, class R = size_t>
using um = unordered_map<S, T, custom_hash<R>>;
template <class S, class R = size_t>
using us = unordered_set<S, custom_hash<R>>;
const double pi = 2 * acos(0.0);
const int oo = 0x3f3f3f3f; // don't use for long long
const double inf = 1.0 / 0.0;
int main() {
ios_base::sync_with_stdio(0);
int h, w;
tk(h, w);
char m[h][w];
FOR(i, 0, h) {
FOR(j, 0, w) { cin >> m[i][j]; }
}
int a[4][h][w] = {-1};
FOR(i, 0, h) {
int le = -1;
FOR(j, 0, w) {
if (m[i][j] == '#') {
le = max(le, j);
} else
a[0][i][j] = le;
}
int ri = w;
FOR(j, w, 0) {
if (m[i][j] == '#') {
ri = min(ri, j);
} else
a[1][i][j] = ri;
}
}
FOR(j, 0, w) {
int le = -1;
FOR(i, 0, h) {
if (m[i][j] == '#') {
le = max(le, j);
} else
a[2][i][j] = le;
}
int ri = h;
FOR(i, h, 0) {
if (m[i][j] == '#') {
ri = min(ri, j);
} else
a[3][i][j] = ri;
}
}
int val = 0;
FOR(i, 0, h) {
FOR(j, 0, w) {
if (m[i][j] != '#') {
val = max(val, -a[0][i][j] + a[1][i][j] - a[2][i][j] + a[3][i][j] - 3);
}
}
}
cout << val << "\n";
return 0;
}
| /*
** Vishal Raj Roy
** Indian Institute of Technology Kharagpur
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define at(X, N) get<N>(X)
#define xx first
#define yy second
#define sz(x) ((int)x.size())
#define nl cout << "\n";
// FOR(i,1,10) gives 1,2,3,....,9 and FOR(i,10,1) gives 9,8,....,1 also FOR(it,
// end(v), begin(v)) and FOR(it, begin(v), end(v))
#define FOR(i, begin, end) \
for (__typeof(end) i = (begin) - ((begin) > (end)); \
i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define SEL(X, C) for (auto &X : C)
#define ima INT_MAX
#define imi INT_MIN
#define lma LLONG_MAX
#define lmi LLONG_MIN
#define name(X) (#X)
#define tl(args...) \
{ \
string _s = #args; \
replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); \
istream_iterator<string> _it(_ss); \
tell(_it, args); \
}
#define tk(args...) take(args);
void tell(istream_iterator<string> it) {}
template <typename T, typename... Args>
void tell(istream_iterator<string> it, T a, Args... args) {
cout << *it << " = " << a << "\n";
tell(++it, args...);
}
void take() {}
template <typename T, typename... Args> void take(T &a, Args &...args) {
cin >> a;
take(args...);
}
template <class T> struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
T operator()(uint64_t x) const {
static const uint64_t FIXED_RANDOM =
chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(x + FIXED_RANDOM);
}
T operator()(tuple<uint64_t, uint64_t> x) const {
static const uint64_t FIXED_RANDOM =
chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(get<0>(x) + FIXED_RANDOM) ^
(splitmix64(get<1>(x) + FIXED_RANDOM) >> 1);
}
}; // T operator()(pair<uint64_t,uint64_t> x) const { static const uint64_t
// FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
// return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second +
// FIXED_RANDOM) >> 1); } };
template <class L, class R> ostream &operator<<(ostream &os, pair<L, R> P) {
return os << "(" << P.xx << "," << P.yy << ")";
}
template <class L, class R> ostream &operator<<(ostream &os, tuple<L, R> P) {
return os << "(" << get<0>(P) << "," << get<1>(P) << ")";
}
template <class L, class R, class S>
ostream &operator<<(ostream &os, tuple<L, R, S> P) {
return os << "(" << get<0>(P) << "," << get<1>(P) << "," << get<2>(P) << ")";
}
template <class T, class A> ostream &operator<<(ostream &os, vector<T, A> V) {
os /*<< name(V)<< " is "*/ << "\n";
FOR(i, 0, sz(V)) os << " " << name(V) << "[" << i << "] = " << V[i] << "\n";
return os; /*<<"\n";*/
}
template <class T, class H, class P, class A>
ostream &operator<<(ostream &os, unordered_set<T, H, P, A> S) {
os /*name(S) << " is"*/ << " [";
int i = 0;
for (auto ELE : S) {
os << ELE;
if (i < sz(S) - 1)
os << ", ";
i++;
}
return os << "]"; /*<<"\n"; */
}
template <class S, class T, class H, class P, class A>
ostream &operator<<(ostream &os, unordered_map<S, T, H, P, A> M) {
os /*name(S) << " is"*/ << "\n";
for (auto ELE : M)
os << " " << name(M) << "[" << ELE.xx << "] = " << ELE.yy << "\n";
return os; /*<<"\n";*/
}
template <class T, class C, class A>
ostream &operator<<(ostream &os, multiset<T, C, A> S) {
os /*name(S) << " is"*/ << "[";
int i = 0;
for (auto ELE : S) {
os << ELE;
if (i < sz(S) - 1)
os << ", ";
i++;
}
return os << "]"; /*<<"\n"; */
}
template <class T, class R>
ostream &operator<<(ostream &os,
gp_hash_table<T, null_type, custom_hash<R>> S) {
os /*name(S) << " is"*/ << " [";
int i = 0;
for (auto ELE : S) {
os << ELE;
if (i < sz(S) - 1)
os << ", ";
i++;
}
return os << "]"; /*<<"\n"; */
}
template <class T, class Z, class R>
ostream &operator<<(ostream &os, gp_hash_table<T, Z, custom_hash<R>> M) {
os /*name(S) << " is"*/ << "\n";
for (auto ELE : M)
os << " " << name(M) << "[" << ELE.xx << "] = " << ELE.yy << "\n";
return os; /*<<"\n";*/
}
template <class T, class R>
ostream &operator<<(ostream &os,
cc_hash_table<T, null_type, custom_hash<R>> S) {
os /*name(S) << " is"*/ << " [";
int i = 0;
for (auto ELE : S) {
os << ELE;
if (i < sz(S) - 1)
os << ", ";
i++;
}
return os << "]"; /*<<"\n"; */
}
template <class T, class Z, class R>
ostream &operator<<(ostream &os, cc_hash_table<T, Z, custom_hash<R>> M) {
os /*name(S) << " is"*/ << "\n";
for (auto ELE : M)
os << " " << name(M) << "[" << ELE.xx << "] = " << ELE.yy << "\n";
return os; /*<<"\n";*/
}
template <class L, class R> istream &operator>>(ostream &os, pair<L, R> &P) {
return os >> P.xx >> P.yy;
}
template <class L> istream &operator>>(istream &os, vector<L> &V) {
FOR(i, 0, sz(V)) os >> V[i];
return os;
}
template <class L> istream &operator>>(istream &os, vector<vector<L>> &V) {
FOR(i, 0, sz(V)) os >> V[i];
return os;
}
using st = string;
typedef long long int li;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef tuple<int, int> i2;
typedef tuple<int, int, int> i3;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<i2> vi2;
typedef vector<i3> vi3;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<li, li> ll;
typedef pair<li, ll> lll;
typedef tuple<li, li> l2;
typedef tuple<li, li, li> l3;
typedef vector<li> vl;
typedef vector<ll> vll;
typedef vector<l2> vl2;
typedef vector<l3> vl3;
typedef vector<lll> vlll;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef double db;
typedef complex<db> cd;
typedef vector<cd> vcd;
template <class S> using ve = vector<S>;
template <class S> using gr = greater<S>;
template <class S> using le = less<S>;
template <class S, class T = le<S>> using ms = multiset<S, T>;
template <class S, class T = null_type, class R = size_t>
using gp = gp_hash_table<S, T, custom_hash<R>>;
template <class S, class T = null_type, class R = size_t>
using cc = cc_hash_table<S, T, custom_hash<R>>;
template <class S, class T, class R = size_t>
using um = unordered_map<S, T, custom_hash<R>>;
template <class S, class R = size_t>
using us = unordered_set<S, custom_hash<R>>;
const double pi = 2 * acos(0.0);
const int oo = 0x3f3f3f3f; // don't use for long long
const double inf = 1.0 / 0.0;
int main() {
ios_base::sync_with_stdio(0);
int h, w;
tk(h, w);
char m[h][w];
FOR(i, 0, h) {
FOR(j, 0, w) { cin >> m[i][j]; }
}
int a[4][h][w] = {-1};
FOR(i, 0, h) {
int le = -1;
FOR(j, 0, w) {
if (m[i][j] == '#') {
le = max(le, j);
} else
a[0][i][j] = le;
}
int ri = w;
FOR(j, w, 0) {
if (m[i][j] == '#') {
ri = min(ri, j);
} else
a[1][i][j] = ri;
}
}
FOR(j, 0, w) {
int le = -1;
FOR(i, 0, h) {
if (m[i][j] == '#') {
le = max(le, i);
} else
a[2][i][j] = le;
}
int ri = h;
FOR(i, h, 0) {
if (m[i][j] == '#') {
ri = min(ri, i);
} else
a[3][i][j] = ri;
}
}
int val = 1;
FOR(i, 0, h) {
FOR(j, 0, w) {
if (m[i][j] != '#') {
val = max(val, -a[0][i][j] + a[1][i][j] - a[2][i][j] + a[3][i][j] - 3);
}
}
}
cout << val << "\n";
return 0;
}
| [
"assignment.value.change",
"identifier.change",
"call.arguments.change",
"literal.number.change",
"variable_declaration.value.change"
] | 827,844 | 827,843 | u027266662 | cpp |
p03014 | #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int h, w;
cin >> h >> w;
vector<string> s(h);
for (int i = 0; i < h; ++i)
cin >> s[i];
vector<vector<int>> cnt(h, vector<int>(w));
for (int i = 0; i < h; ++i) {
vector<int> done(w);
for (int j = 0; j < w; ++j) {
if (s[i][j] == '#')
continue;
if (done[j])
continue;
int l = 0;
while (j + l < w) {
if (s[i][j + l] == '#')
break;
++l;
}
for (int k = 0; k < l; ++k) {
cnt[i][j + k] += l;
done[j + k] = 1;
}
}
}
for (int j = 0; j < h; ++j) {
vector<int> done(h);
for (int i = 0; i < h; ++i) {
if (s[i][j] == '#')
continue;
if (done[i])
continue;
int l = 0;
while (i + l < h) {
if (s[i + l][j] == '#')
break;
++l;
}
for (int k = 0; k < l; ++k) {
cnt[i + k][j] += l;
done[i + k] = 1;
}
}
}
int ans = 0;
for (int i = 0; i < h; ++i)
for (int j = 0; j < w; ++j)
ans = max(ans, cnt[i][j] - 1);
cout << ans << endl;
return 0;
} | #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int h, w;
cin >> h >> w;
vector<string> s(h);
for (int i = 0; i < h; ++i)
cin >> s[i];
vector<vector<int>> cnt(h, vector<int>(w));
for (int i = 0; i < h; ++i) {
vector<int> done(w);
for (int j = 0; j < w; ++j) {
if (s[i][j] == '#')
continue;
if (done[j])
continue;
int l = 0;
while (j + l < w) {
if (s[i][j + l] == '#')
break;
++l;
}
for (int k = 0; k < l; ++k) {
cnt[i][j + k] += l;
done[j + k] = 1;
}
}
}
for (int j = 0; j < w; ++j) {
vector<int> done(h);
for (int i = 0; i < h; ++i) {
if (s[i][j] == '#')
continue;
if (done[i])
continue;
int l = 0;
while (i + l < h) {
if (s[i + l][j] == '#')
break;
++l;
}
for (int k = 0; k < l; ++k) {
cnt[i + k][j] += l;
done[i + k] = 1;
}
}
}
int ans = 0;
for (int i = 0; i < h; ++i)
for (int j = 0; j < w; ++j)
ans = max(ans, cnt[i][j] - 1);
cout << ans << endl;
return 0;
} | [
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 827,866 | 827,867 | u707498674 | cpp |
p03014 | #include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int h, w;
cin >> h >> w;
vector<string> s(h);
for (int i = 0; i < h; ++i)
cin >> s[i];
vector<vector<int>> cnt(h, vector<int>(w));
for (int i = 0; i < h; ++i) {
vector<int> done(w);
for (int j = 0; j < w; ++j) {
if (s[i][j] == '#')
continue;
if (done[j])
continue;
int l = 0;
while (j + l < w) {
if (s[i][j + l] == '#')
break;
++l;
}
for (int k = 0; k < l; ++k) {
cnt[i][j + k] += l;
done[j + k] = 1;
}
}
}
for (int j = 0; j < h; ++j) {
vector<int> done(h);
for (int i = 0; i < h; ++i) {
if (s[i][j] == '#')
continue;
if (done[i])
continue;
int l = 0;
while (i + l < h) {
if (s[i + l][j] == '#')
break;
++l;
}
for (int k = 0; k < l; ++k) {
cnt[i + k][j] += l;
done[i + k] = 1;
}
}
}
int ans = 0;
for (int i = 0; i < h; ++i)
for (int j = 0; j < w; ++j)
ans = max(ans, cnt[i][j] - 1);
cout << ans << endl;
return 0;
} | #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int h, w;
cin >> h >> w;
vector<string> s(h);
for (int i = 0; i < h; ++i)
cin >> s[i];
vector<vector<int>> cnt(h, vector<int>(w));
for (int i = 0; i < h; ++i) {
vector<int> done(w);
for (int j = 0; j < w; ++j) {
if (s[i][j] == '#')
continue;
if (done[j])
continue;
int l = 0;
while (j + l < w) {
if (s[i][j + l] == '#')
break;
++l;
}
for (int k = 0; k < l; ++k) {
cnt[i][j + k] += l;
done[j + k] = 1;
}
}
}
for (int j = 0; j < w; ++j) {
vector<int> done(h);
for (int i = 0; i < h; ++i) {
if (s[i][j] == '#')
continue;
if (done[i])
continue;
int l = 0;
while (i + l < h) {
if (s[i + l][j] == '#')
break;
++l;
}
for (int k = 0; k < l; ++k) {
cnt[i + k][j] += l;
done[i + k] = 1;
}
}
}
int ans = 0;
for (int i = 0; i < h; ++i)
for (int j = 0; j < w; ++j)
ans = max(ans, cnt[i][j] - 1);
cout << ans << endl;
return 0;
} | [
"import.add",
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 827,869 | 827,867 | u707498674 | cpp |
p03014 | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
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;
typedef vector<vector<int>> Graph;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000; // 1e18
const ll MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;
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 UP[2020][2020], DOWN[2020][2020], LEFT[2020][2020], RIGHT[2020][2020];
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int H, W;
cin >> H >> W;
vector<string> fi(H);
REP(i, H) cin >> fi[i];
REP(i, H) {
int cur = 0;
for (int j = 0; j < W; j++) {
if (fi[i][j] == '#')
cur = 0;
else
cur++;
RIGHT[i][j] = cur;
}
}
REP(i, H) {
int cur = 0;
for (int j = W - 1; j >= 0; j--) {
if (fi[i][j] == '#')
cur = 0;
else
cur++;
LEFT[i][j] = cur;
}
}
REP(j, W) {
int cur = 0;
for (int i = 0; i < H; i++) {
if (fi[i][j] == '#')
cur = 0;
else
cur++;
UP[i][j] = cur;
}
}
REP(j, H) {
int cur = 0;
for (int i = H - 1; i >= 0; i--) {
if (fi[i][j] == '#')
cur = 0;
else
cur++;
DOWN[i][j] = cur;
}
}
int ans = 0;
REP(i, H) REP(j, W) {
if (fi[i][j] == '#')
continue;
chmax(ans, UP[i][j] + DOWN[i][j] + LEFT[i][j] + RIGHT[i][j] - 3);
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
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;
typedef vector<vector<int>> Graph;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000; // 1e18
const ll MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;
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 UP[2020][2020], DOWN[2020][2020], LEFT[2020][2020], RIGHT[2020][2020];
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int H, W;
cin >> H >> W;
vector<string> fi(H);
REP(i, H) cin >> fi[i];
REP(i, H) {
int cur = 0;
for (int j = 0; j < W; j++) {
if (fi[i][j] == '#')
cur = 0;
else
cur++;
RIGHT[i][j] = cur;
}
}
REP(i, H) {
int cur = 0;
for (int j = W - 1; j >= 0; j--) {
if (fi[i][j] == '#')
cur = 0;
else
cur++;
LEFT[i][j] = cur;
}
}
REP(j, W) {
int cur = 0;
for (int i = 0; i < H; i++) {
if (fi[i][j] == '#')
cur = 0;
else
cur++;
UP[i][j] = cur;
}
}
REP(j, W) {
int cur = 0;
for (int i = H - 1; i >= 0; i--) {
if (fi[i][j] == '#')
cur = 0;
else
cur++;
DOWN[i][j] = cur;
}
}
int ans = 0;
REP(i, H) REP(j, W) {
if (fi[i][j] == '#')
continue;
chmax(ans, UP[i][j] + DOWN[i][j] + LEFT[i][j] + RIGHT[i][j] - 3);
}
cout << ans << endl;
}
| [] | 827,889 | 827,890 | u493750228 | cpp |
p03014 | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
int H, W;
string S[2005];
int U[2005][2005];
int D[2005][2005];
int L[2005][2005];
int R[2005][2005];
int main() {
ios_base::sync_with_stdio(false);
cin >> H >> W;
for (int i = 0; i < H; i++)
cin >> S[i];
for (int i = 0; i < H; i++) {
int cnt = 0;
for (int j = 0; j < W; j++) {
cnt = S[i][j] == '.' ? cnt + 1 : 0;
L[i][j] = cnt;
}
}
for (int i = 0; i < H; i++) {
int cnt = 0;
for (int j = W - 1; j >= 0; j--) {
cnt = S[i][j] == '.' ? cnt + 1 : 0;
R[i][j] = cnt;
}
}
for (int i = 0; i < W; i++) {
int cnt = 0;
for (int j = 0; j < H; j++) {
cnt = S[j][i] == '.' ? cnt + 1 : 0;
U[j][i] = cnt;
}
}
for (int i = 0; i < W; i++) {
int cnt = 0;
for (int j = H - 1; j >= 0; j--) {
cnt = S[j][i] == '.' ? cnt + 1 : 0;
D[j][i] = cnt;
}
}
int ans = 0;
for (int i = 0; i < W; i++)
for (int j = 0; j < H; j++)
ans = max(ans, L[i][j] + R[i][j] + D[i][j] + U[i][j] - 3);
cout << ans;
} | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
int H, W;
string S[2005];
int U[2005][2005];
int D[2005][2005];
int L[2005][2005];
int R[2005][2005];
int main() {
ios_base::sync_with_stdio(false);
cin >> H >> W;
for (int i = 0; i < H; i++)
cin >> S[i];
for (int i = 0; i < H; i++) {
int cnt = 0;
for (int j = 0; j < W; j++) {
cnt = S[i][j] == '.' ? cnt + 1 : 0;
L[i][j] = cnt;
}
}
for (int i = 0; i < H; i++) {
int cnt = 0;
for (int j = W - 1; j >= 0; j--) {
cnt = S[i][j] == '.' ? cnt + 1 : 0;
R[i][j] = cnt;
}
}
for (int i = 0; i < W; i++) {
int cnt = 0;
for (int j = 0; j < H; j++) {
cnt = S[j][i] == '.' ? cnt + 1 : 0;
U[j][i] = cnt;
}
}
for (int i = 0; i < W; i++) {
int cnt = 0;
for (int j = H - 1; j >= 0; j--) {
cnt = S[j][i] == '.' ? cnt + 1 : 0;
D[j][i] = cnt;
}
}
int ans = 0;
for (int i = 0; i < H; i++)
for (int j = 0; j < W; j++)
ans = max(ans, L[i][j] + R[i][j] + D[i][j] + U[i][j] - 3);
cout << ans;
}
| [
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 827,899 | 827,900 | u450096124 | cpp |
p03014 | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
int H, W;
string S[2005];
int U[2005][2005];
int D[2005][2005];
int L[2005][2005];
int R[2005][2005];
int main() {
ios_base::sync_with_stdio(false);
cin >> H >> W;
for (int i = 0; i < H; i++)
cin >> S[i];
for (int i = 0; i < H; i++) {
int cnt = 0;
for (int j = 0; j < W; j++) {
cnt = S[i][j] == '.' ? cnt + 1 : 0;
L[i][j] = cnt;
}
}
for (int i = 0; i < H; i++) {
int cnt = 0;
for (int j = W - 1; j >= 0; j--) {
cnt = S[i][j] == '.' ? cnt + 1 : 0;
R[i][j] = cnt;
}
}
for (int i = 0; i < W; i++) {
int cnt = 0;
for (int j = 0; j < H; j++) {
cnt = S[j][i] == '.' ? cnt + 1 : 0;
U[j][i] = cnt;
}
}
for (int i = 0; i < W; i++) {
int cnt = 0;
for (int j = H - 1; j >= 0; j--) {
cnt = S[j][i] == '.' ? cnt + 1 : 0;
D[j][i] = cnt;
}
}
int ans = 0;
for (int i = 0; i < W; i++)
for (int j = 0; j < H; j++)
ans = max(ans, L[i][j] + R[i][j] + D[i][j] + U[i][j] - 3);
cout << ans;
} | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
int H, W;
string S[2005];
int U[2005][2005];
int D[2005][2005];
int L[2005][2005];
int R[2005][2005];
int main() {
ios_base::sync_with_stdio(false);
cin >> H >> W;
for (int i = 0; i < H; i++)
cin >> S[i];
for (int i = 0; i < H; i++) {
int cnt = 0;
for (int j = 0; j < W; j++) {
cnt = S[i][j] == '.' ? cnt + 1 : 0;
L[i][j] = cnt;
}
}
for (int i = 0; i < H; i++) {
int cnt = 0;
for (int j = W - 1; j >= 0; j--) {
cnt = S[i][j] == '.' ? cnt + 1 : 0;
R[i][j] = cnt;
}
}
for (int i = 0; i < W; i++) {
int cnt = 0;
for (int j = 0; j < H; j++) {
cnt = S[j][i] == '.' ? cnt + 1 : 0;
U[j][i] = cnt;
}
}
for (int i = 0; i < W; i++) {
int cnt = 0;
for (int j = H - 1; j >= 0; j--) {
cnt = S[j][i] == '.' ? cnt + 1 : 0;
D[j][i] = cnt;
}
}
int ans = 0;
for (int i = 0; i < H; i++)
for (int j = 0; j < W; j++)
ans = max(ans, L[i][j] + R[i][j] + D[i][j] + U[i][j] - 3);
cout << ans;
} | [
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 827,899 | 827,901 | u450096124 | cpp |
p03014 |
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int H, W;
cin >> H >> W;
vector<string> S(H);
for (int i = 0; i < H; i++) {
cin >> S[i];
}
vector<vector<int>> cnt(H, vector<int>(W));
for (int i = 0; i < H; i++) {
vector<int> done(W, 0);
for (int j = 0; j < W; j++) {
if (S[i][j] == '#') {
continue;
}
if (done[j] != 0) {
continue;
}
int l = 0;
while (j + 1 < W) {
if (S[i][j + l] == '#') {
break;
}
l++;
}
for (int k = 0; k < l; k++) {
cnt[i][j + k] += l;
done[j + k] = 1;
}
}
}
for (int j = 0; j < W; j++) {
vector<int> done(H, 0);
for (int i = 0; i < H; i++) {
if (S[i][j] == '#') {
continue;
}
if (done[i] != 0) {
continue;
}
int l = 0;
while (i + 1 < H) {
if (S[i + l][j] == '#') {
break;
}
l++;
}
for (int k = 0; k < l; k++) {
cnt[i + k][j] += l;
done[i + k] = 1;
}
}
}
int ans = 0;
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
ans = max(ans, cnt[i][j] - 1);
}
}
cout << ans << endl;
return 0;
} |
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int H, W;
cin >> H >> W;
vector<string> S(H);
for (int i = 0; i < H; i++) {
cin >> S[i];
}
vector<vector<int>> cnt(H, vector<int>(W));
for (int i = 0; i < H; i++) {
vector<int> done(W, 0);
for (int j = 0; j < W; j++) {
if (S[i][j] == '#') {
continue;
}
if (done[j] != 0) {
continue;
}
int l = 0;
while (j + l < W) {
if (S[i][j + l] == '#') {
break;
}
l++;
}
for (int k = 0; k < l; k++) {
cnt[i][j + k] += l;
done[j + k] = 1;
}
}
}
for (int j = 0; j < W; j++) {
vector<int> done(H, 0);
for (int i = 0; i < H; i++) {
if (S[i][j] == '#') {
continue;
}
if (done[i] != 0) {
continue;
}
int l = 0;
while (i + l < H) {
if (S[i + l][j] == '#') {
break;
}
l++;
}
for (int k = 0; k < l; k++) {
cnt[i + k][j] += l;
done[i + k] = 1;
}
}
}
int ans = 0;
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
ans = max(ans, cnt[i][j] - 1);
}
}
cout << ans << endl;
return 0;
} | [
"identifier.replace.add",
"literal.replace.remove",
"control_flow.loop.condition.change"
] | 827,906 | 827,907 | u289709148 | cpp |
p03014 |
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int H, W;
cin >> H >> W;
vector<string> S(H);
for (int i = 0; i < H; i++) {
cin >> S[i];
}
vector<vector<int>> cnt(H, vector<int>(W));
for (int i = 0; i < H; i++) {
vector<int> done(W, 0);
for (int j = 0; j < W; j++) {
if (S[i][j] == '#') {
continue;
}
if (done[j] != 0) {
continue;
}
int l = 0;
while (j + 1 < W) {
if (S[i][j + l] == '#') {
break;
}
l++;
}
for (int k = 0; k < l; k++) {
cnt[i][j + k] += l;
done[j + k] = 1;
}
}
}
for (int j = 0; j < W; j++) {
vector<int> done(H, 0);
for (int i = 0; i < H; i++) {
if (S[i][j] == '#') {
continue;
}
if (done[i] != 0) {
continue;
}
int l = 0;
while (i + 1 < H) {
if (S[i + l][j] == '#') {
break;
}
l++;
}
for (int k = 0; k < l; k++) {
cnt[i + k][j] += l;
done[i + k] = 1;
}
}
}
int ans = 0;
for (int i = 0; i < W; i++) {
for (int j = 0; j < H; j++) {
ans = max(ans, cnt[i][j] - 1);
}
}
cout << ans << endl;
return 0;
} |
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int H, W;
cin >> H >> W;
vector<string> S(H);
for (int i = 0; i < H; i++) {
cin >> S[i];
}
vector<vector<int>> cnt(H, vector<int>(W));
for (int i = 0; i < H; i++) {
vector<int> done(W, 0);
for (int j = 0; j < W; j++) {
if (S[i][j] == '#') {
continue;
}
if (done[j] != 0) {
continue;
}
int l = 0;
while (j + l < W) {
if (S[i][j + l] == '#') {
break;
}
l++;
}
for (int k = 0; k < l; k++) {
cnt[i][j + k] += l;
done[j + k] = 1;
}
}
}
for (int j = 0; j < W; j++) {
vector<int> done(H, 0);
for (int i = 0; i < H; i++) {
if (S[i][j] == '#') {
continue;
}
if (done[i] != 0) {
continue;
}
int l = 0;
while (i + l < H) {
if (S[i + l][j] == '#') {
break;
}
l++;
}
for (int k = 0; k < l; k++) {
cnt[i + k][j] += l;
done[i + k] = 1;
}
}
}
int ans = 0;
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
ans = max(ans, cnt[i][j] - 1);
}
}
cout << ans << endl;
return 0;
} | [
"identifier.replace.add",
"literal.replace.remove",
"control_flow.loop.condition.change",
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 827,908 | 827,907 | u289709148 | cpp |
p03014 | #include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
// order statistics tree
typedef tree<pii, null_type, less<pii>, rb_tree_tag,
tree_order_statistics_node_update>
indexed_set;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define rrep(i, b, a) for (int i = b; i >= a; --i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
const int N = 2e3 + 10;
int h, w;
string s[N];
int ans;
int main() {
cin.tie(0);
cin.exceptions(cin.failbit);
scanf("%d%d", &h, &w);
rep(i, 0, h) { cin >> s[i]; }
vector<vector<int>> row(h), col(w);
rep(i, 0, h) {
rep(j, 0, w) {
if (s[i][j] == '#') {
row[i].PB(j);
col[j].PB(i);
}
}
}
rep(i, 0, h) {
rep(j, 0, w) {
if (s[i][j] == '.') {
int lo = 0, hi = sz(row[i]) - 1;
int l = -1, r = w;
// search for left
// greatest value < i
while (lo <= hi) {
int mid = (hi + lo) / 2;
if (row[i][mid] < i) {
lo = mid + 1;
l = row[i][mid];
} else {
hi = mid - 1;
}
}
// search for right
lo = 0;
hi = sz(row[i]) - 1;
while (lo <= hi) {
int mid = (hi + lo) / 2;
if (row[i][mid] > i) {
hi = mid - 1;
r = row[i][mid];
} else {
lo = mid + 1;
}
}
lo = 0;
hi = sz(col[j]) - 1;
int d = -1, u = h;
// search down
while (lo <= hi) {
int mid = (hi + lo) / 2;
// greatest value < i
if (col[j][mid] < i) {
d = col[j][mid];
lo = mid + 1;
} else {
hi = mid - 1;
}
}
lo = 0;
hi = sz(col[j]) - 1;
while (lo <= hi) {
int mid = (hi + lo) / 2;
// lowest value > i
if (col[j][mid] > i) {
u = col[j][mid];
hi = mid - 1;
} else {
lo = mid + 1;
}
}
ans = max(ans, (r - l - 1) + (u - d - 1) - 1);
}
}
}
printf("%d\n", ans);
}
| #include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
// order statistics tree
typedef tree<pii, null_type, less<pii>, rb_tree_tag,
tree_order_statistics_node_update>
indexed_set;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define rrep(i, b, a) for (int i = b; i >= a; --i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
const int N = 2e3 + 10;
int h, w;
string s[N];
int ans;
int main() {
cin.tie(0);
cin.exceptions(cin.failbit);
scanf("%d%d", &h, &w);
rep(i, 0, h) { cin >> s[i]; }
vector<vector<int>> row(h), col(w);
rep(i, 0, h) {
rep(j, 0, w) {
if (s[i][j] == '#') {
row[i].PB(j);
col[j].PB(i);
}
}
}
rep(i, 0, h) {
rep(j, 0, w) {
if (s[i][j] == '.') {
int lo = 0, hi = sz(row[i]) - 1;
int l = -1, r = w;
// search for left
// greatest value < j
while (lo <= hi) {
int mid = (hi + lo) / 2;
if (row[i][mid] < j) {
lo = mid + 1;
l = row[i][mid];
} else {
hi = mid - 1;
}
}
// search for right
lo = 0;
hi = sz(row[i]) - 1;
while (lo <= hi) {
int mid = (hi + lo) / 2;
if (row[i][mid] > j) {
hi = mid - 1;
r = row[i][mid];
} else {
lo = mid + 1;
}
}
lo = 0;
hi = sz(col[j]) - 1;
int d = -1, u = h;
// search down
while (lo <= hi) {
int mid = (hi + lo) / 2;
// greatest value < i
if (col[j][mid] < i) {
d = col[j][mid];
lo = mid + 1;
} else {
hi = mid - 1;
}
}
lo = 0;
hi = sz(col[j]) - 1;
while (lo <= hi) {
int mid = (hi + lo) / 2;
// lowest value > i
if (col[j][mid] > i) {
u = col[j][mid];
hi = mid - 1;
} else {
lo = mid + 1;
}
}
ans = max(ans, (r - l - 1) + (u - d - 1) - 1);
// printf("i:%d, j:%d, val:%d\n", i, j, (r-l-1) + (u-d-1)-1);
}
}
}
printf("%d\n", ans);
}
| [
"identifier.change",
"control_flow.branch.if.condition.change"
] | 827,917 | 827,918 | u625416773 | cpp |
p03014 | #include <iostream>
using namespace std;
const int N = 2050;
char s[N][N];
int dp[N][N][5], ans;
int main() {
int n, m;
cin >> n >> m;
for (int i = 0; i <= n - 1; ++i)
cin >> s[i];
for (int i = 0; i <= n - 1; ++i)
for (int j = 0; j <= m - 1; ++j) {
if (s[i][j] == '.') {
dp[i][j][1] = dp[i][j][2] = 1;
if (j > 0 && dp[i][j - 1][1] > 0)
dp[i][j][1] = dp[i][j - 1][1] + 1;
if (i > 0 && dp[i - 1][j][2] > 0)
dp[i][j][2] = dp[i - 1][j][2] + 1;
}
}
for (int i = n - 1; i >= 0; i--)
for (int j = m - 1; j >= 0; j--) {
if (s[i][j] == '.') {
dp[i][j][3] = dp[i][j][4] = 1;
if (j < m - 1 && dp[i][j + 1][3] > 0)
dp[i][j][3] = dp[i][j + 1][3] + 1;
if (i < n - 1 && dp[i + 1][j][4] > 0)
dp[i][j][4] = dp[i + 1][j][4] + 1;
}
}
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++) {
if (s[i][j] == '#')
continue;
int temp = 1;
for (int cnt = 1; cnt <= 4; cnt++)
temp += dp[i][j][cnt];
ans = max(ans, temp - 4);
}
cout << ans;
} | #include <iostream>
using namespace std;
const int N = 2050;
char s[N][N];
int dp[N][N][5], ans;
int main() {
int n, m;
cin >> n >> m;
for (int i = 0; i <= n - 1; ++i)
cin >> s[i];
for (int i = 0; i <= n - 1; ++i)
for (int j = 0; j <= m - 1; ++j) {
if (s[i][j] == '.') {
dp[i][j][1] = dp[i][j][2] = 1;
if (j > 0 && dp[i][j - 1][1] > 0)
dp[i][j][1] = dp[i][j - 1][1] + 1;
if (i > 0 && dp[i - 1][j][2] > 0)
dp[i][j][2] = dp[i - 1][j][2] + 1;
}
}
for (int i = n - 1; i >= 0; i--)
for (int j = m - 1; j >= 0; j--) {
if (s[i][j] == '.') {
dp[i][j][3] = dp[i][j][4] = 1;
if (j < m - 1 && dp[i][j + 1][3] > 0)
dp[i][j][3] = dp[i][j + 1][3] + 1;
if (i < n - 1 && dp[i + 1][j][4] > 0)
dp[i][j][4] = dp[i + 1][j][4] + 1;
}
}
for (int i = 0; i <= n - 1; i++)
for (int j = 0; j <= m - 1; j++) {
if (s[i][j] == '#')
continue;
int temp = 1;
for (int cnt = 1; cnt <= 4; cnt++)
temp += dp[i][j][cnt];
ans = max(ans, temp - 4);
}
cout << ans;
} | [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one",
"control_flow.loop.for.condition.change",
"misc.off_by_one"
] | 827,922 | 827,923 | u180882510 | cpp |
p03014 | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fst first
#define snd second
#define pf push_front
#define pb push_back
#define eb emplace_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int L[2001][2001], R[2001][2001], U[2001][2001], D[2001][2001];
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
int h, w;
cin >> h >> w;
vector<string> s(h);
rep(i, h) cin >> s[i];
rep(i, h) {
rep(j, w) {
if (s[i][j] == '#')
L[i][j] = 0;
else {
if (j == 0)
L[i][j] = 1;
else
L[i][j] = L[i][j - 1] + 1;
}
}
}
rep(i, h) {
for (int j = h - 1; j >= 0; --j) {
if (s[i][j] == '#')
R[i][j] = 0;
else {
if (j == w - 1)
R[i][j] = 1;
else
R[i][j] = R[i][j + 1] + 1;
}
}
}
rep(j, w) {
rep(i, h) {
if (s[i][j] == '#')
U[i][j] = 0;
else {
if (i == 0)
U[i][j] = 1;
else
U[i][j] = U[i - 1][j] + 1;
}
}
}
rep(j, w) {
for (int i = h - 1; i >= 0; --i) {
if (s[i][j] == '#')
D[i][j] = 0;
else {
if (i == h - 1)
D[i][j] = 1;
else
D[i][j] = D[i + 1][j] + 1;
}
}
}
int ans = 0;
rep(i, h) {
rep(j, w) { ans = max(ans, L[i][j] + R[i][j] + D[i][j] + U[i][j] - 3); }
}
out(ans);
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fst first
#define snd second
#define pf push_front
#define pb push_back
#define eb emplace_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int L[2001][2001], R[2001][2001], U[2001][2001], D[2001][2001];
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
int h, w;
cin >> h >> w;
vector<string> s(h);
rep(i, h) cin >> s[i];
rep(i, h) {
rep(j, w) {
if (s[i][j] == '#')
L[i][j] = 0;
else {
if (j == 0)
L[i][j] = 1;
else
L[i][j] = L[i][j - 1] + 1;
}
}
}
rep(i, h) {
for (int j = w - 1; j >= 0; --j) {
if (s[i][j] == '#')
R[i][j] = 0;
else {
if (j == w - 1)
R[i][j] = 1;
else
R[i][j] = R[i][j + 1] + 1;
}
}
}
rep(j, w) {
rep(i, h) {
if (s[i][j] == '#')
U[i][j] = 0;
else {
if (i == 0)
U[i][j] = 1;
else
U[i][j] = U[i - 1][j] + 1;
}
}
}
rep(j, w) {
for (int i = h - 1; i >= 0; --i) {
if (s[i][j] == '#')
D[i][j] = 0;
else {
if (i == h - 1)
D[i][j] = 1;
else
D[i][j] = D[i + 1][j] + 1;
}
}
}
int ans = 0;
rep(i, h) {
rep(j, w) { ans = max(ans, L[i][j] + R[i][j] + D[i][j] + U[i][j] - 3); }
}
out(ans);
return 0;
}
| [
"identifier.change",
"control_flow.loop.for.initializer.change",
"expression.operation.binary.change"
] | 827,938 | 827,939 | u019780057 | cpp |
p03014 | /**
* code generated by JHelper
* More info: https://github.com/AlexeyDmitriev/JHelper
* @author alireza_kaviani
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <class T>
using Tree =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define all(x) (x).begin(), (x).end()
#define Sort(x) sort(all((x)))
#define X first
#define Y second
#define Mp make_pair
#define sep ' '
#define endl '\n'
#define debug(x) cerr << #x << " = " << x << endl
#define SZ(x) ll(x.size())
#define fast_io \
ios::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define set_random \
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
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));
}
set_random;
const ll MAXN = 2e3 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;
ll n, m, ans;
string s[MAXN];
vector<ll> x[MAXN], y[MAXN];
int main() {
fast_io;
cin >> n >> m;
s[0] = string(m + 2, '#');
s[n + 1] = s[0];
for (ll i = 1; i <= n; i++) {
cin >> s[i];
s[i] = '#' + s[i] + "#";
}
for (ll i = 0; i <= n + 1; i++) {
for (ll j = 0; j <= m + 1; j++) {
if (s[i][j] == '#') {
x[i].push_back(j);
y[j].push_back(i);
}
}
}
for (ll i = 1; i <= n; i++) {
for (ll j = 1; j <= n; j++) {
if (s[i][j] == '#')
continue;
ll indx = lower_bound(all(x[i]), j) - x[i].begin();
ll indy = lower_bound(all(y[j]), i) - y[j].begin();
ans = max(ans,
x[i][indx] - x[i][indx - 1] + y[j][indy] - y[j][indy - 1] - 3);
}
}
cout << ans << endl;
return 0;
}
/*
*/
| /**
* code generated by JHelper
* More info: https://github.com/AlexeyDmitriev/JHelper
* @author alireza_kaviani
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <class T>
using Tree =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define all(x) (x).begin(), (x).end()
#define Sort(x) sort(all((x)))
#define X first
#define Y second
#define Mp make_pair
#define sep ' '
#define endl '\n'
#define debug(x) cerr << #x << " = " << x << endl
#define SZ(x) ll(x.size())
#define fast_io \
ios::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define set_random \
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
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));
}
set_random;
const ll MAXN = 2e3 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;
ll n, m, ans;
string s[MAXN];
vector<ll> x[MAXN], y[MAXN];
int main() {
fast_io;
cin >> n >> m;
s[0] = string(m + 2, '#');
s[n + 1] = s[0];
for (ll i = 1; i <= n; i++) {
cin >> s[i];
s[i] = '#' + s[i] + "#";
}
for (ll i = 0; i <= n + 1; i++) {
for (ll j = 0; j <= m + 1; j++) {
if (s[i][j] == '#') {
x[i].push_back(j);
y[j].push_back(i);
}
}
}
for (ll i = 1; i <= n; i++) {
for (ll j = 1; j <= m; j++) {
if (s[i][j] == '#')
continue;
ll indx = lower_bound(all(x[i]), j) - x[i].begin();
ll indy = lower_bound(all(y[j]), i) - y[j].begin();
ans = max(ans,
x[i][indx] - x[i][indx - 1] + y[j][indy] - y[j][indy - 1] - 3);
}
}
cout << ans << endl;
return 0;
}
/*
*/
| [
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 827,940 | 827,941 | u631674931 | cpp |
p03014 | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int h, w;
cin >> h >> w;
vector<vector<int>> s(h, vector<int>(w, 0));
vector<vector<int>> cnt(h, vector<int>(w, 0));
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
char c;
cin >> c;
if (c == '.')
;
else if (c == '#')
s[i][j] = -1;
}
}
for (int i = 0; i < h; i++) {
vector<int> done(w, 0);
for (int j = 0; j < w; j++) {
if (s[i][j] == -1)
continue;
if (done[j])
continue;
int l = 0;
while (j + l < w) {
if (s[i][j + l] == -1)
break;
l++;
}
for (int k = 0; k < l; k++) {
cnt[i][j + k] += l;
done[j + k] = 1;
}
}
}
for (int j = 0; j < w; j++) {
vector<int> done(h, 0);
for (int i = 0; i < h; i++) {
if (s[i][j] == -1)
continue;
if (done[i])
continue;
int l = 0;
while (i + l < h) {
if (s[i + 1][j] == -1)
break;
l++;
}
for (int k = 0; k < l; k++) {
cnt[i + k][j] += l;
done[i + k] = 1;
}
}
}
int ans = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
ans = max(ans, cnt[i][j] - 1);
}
}
cout << ans << endl;
} | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int h, w;
cin >> h >> w;
vector<vector<int>> s(h, vector<int>(w, 0));
vector<vector<int>> cnt(h, vector<int>(w, 0));
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
char c;
cin >> c;
if (c == '.')
;
else if (c == '#')
s[i][j] = -1;
}
}
for (int i = 0; i < h; i++) {
vector<int> done(w, 0);
for (int j = 0; j < w; j++) {
if (s[i][j] == -1)
continue;
if (done[j])
continue;
int l = 0;
while (j + l < w) {
if (s[i][j + l] == -1)
break;
l++;
}
for (int k = 0; k < l; k++) {
cnt[i][j + k] += l;
done[j + k] = 1;
}
}
}
for (int j = 0; j < w; j++) {
vector<int> done(h, 0);
for (int i = 0; i < h; i++) {
if (s[i][j] == -1)
continue;
if (done[i])
continue;
int l = 0;
while (i + l < h) {
if (s[i + l][j] == -1)
break;
l++;
}
for (int k = 0; k < l; k++) {
cnt[i + k][j] += l;
done[i + k] = 1;
}
}
}
int ans = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
ans = max(ans, cnt[i][j] - 1);
}
}
cout << ans << endl;
} | [
"identifier.replace.add",
"literal.replace.remove",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change"
] | 827,946 | 827,947 | u056123277 | cpp |
p03014 | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int h, w;
cin >> h >> w;
vector<vector<char>> c(2 * h, vector<char>(2 * w));
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
cin >> c[i][j];
}
}
vector<vector<int>> l(2 * h, vector<int>(2 * w));
vector<vector<int>> r(2 * h, vector<int>(2 * w));
vector<vector<int>> d(2 * h, vector<int>(2 * w));
vector<vector<int>> u(2 * h, vector<int>(2 * w));
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if (c[i][j] == '#')
l[i][j] = 0;
else if (j == 0)
l[i][j] = 1;
else
l[i][j] = l[i][j - 1] + 1;
}
}
for (int i = 0; i < h; i++) {
for (int j = w - 1; j >= 0; j--) {
if (c[i][j] == '#')
r[i][j] = 0;
else if (j == w - 1)
r[i][j] = 1;
else
r[i][j] = r[i][j + 1] + 1;
}
}
for (int j = 0; j < w; j++) {
for (int i = 0; i < h; i++) {
if (c[i][j] == '#')
u[i][j] = 0;
else if (i == 0)
u[i][j] = 1;
else
u[i][j] = u[i - 1][j] + 1;
}
}
for (int j = 0; j < w; j++) {
for (int i = h - 1; i >= 0; i--) {
if (d[i][j] == '#')
d[i][j] = 0;
else if (i == h - 1)
d[i][j] = 1;
else
d[i][j] = d[i + 1][j] + 1;
}
}
int max_c = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
max_c = max(max_c, l[i][j] + r[i][j] + d[i][j] + u[i][j] - 3);
}
}
cout << max_c << endl;
} | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int h, w;
cin >> h >> w;
vector<vector<char>> c(2 * h, vector<char>(2 * w));
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
cin >> c[i][j];
}
}
vector<vector<int>> l(2 * h, vector<int>(2 * w));
vector<vector<int>> r(2 * h, vector<int>(2 * w));
vector<vector<int>> d(2 * h, vector<int>(2 * w));
vector<vector<int>> u(2 * h, vector<int>(2 * w));
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if (c[i][j] == '#')
l[i][j] = 0;
else if (j == 0)
l[i][j] = 1;
else
l[i][j] = l[i][j - 1] + 1;
}
}
for (int i = 0; i < h; i++) {
for (int j = w - 1; j >= 0; j--) {
if (c[i][j] == '#')
r[i][j] = 0;
else if (j == w - 1)
r[i][j] = 1;
else
r[i][j] = r[i][j + 1] + 1;
}
}
for (int j = 0; j < w; j++) {
for (int i = 0; i < h; i++) {
if (c[i][j] == '#')
u[i][j] = 0;
else if (i == 0)
u[i][j] = 1;
else
u[i][j] = u[i - 1][j] + 1;
}
}
for (int j = 0; j < w; j++) {
for (int i = h - 1; i >= 0; i--) {
if (c[i][j] == '#')
d[i][j] = 0;
else if (i == h - 1)
d[i][j] = 1;
else
d[i][j] = d[i + 1][j] + 1;
}
}
int max_c = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
max_c = max(max_c, l[i][j] + r[i][j] + d[i][j] + u[i][j] - 3);
}
}
cout << max_c << endl;
} | [
"identifier.change",
"control_flow.branch.if.condition.change"
] | 827,950 | 827,951 | u240685518 | cpp |
p03014 | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int h, w;
cin >> h >> w;
vector<vector<char>> c(2 * h, vector<char>(2 * w));
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
cin >> c[i][j];
}
}
vector<vector<int>> l(2 * h, vector<int>(2 * w));
vector<vector<int>> r(2 * h, vector<int>(2 * w));
vector<vector<int>> d(2 * h, vector<int>(2 * w));
vector<vector<int>> u(2 * h, vector<int>(2 * w));
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if (c[i][j] == '#')
l[i][j] = 0;
else if (j == 0)
l[i][j] = 1;
else
l[i][j] = l[i][j - 1] + 1;
}
}
for (int i = 0; i < h; i++) {
for (int j = w - 1; j >= 0; j--) {
if (c[i][j] == '#')
r[i][j] = 0;
else if (j == w - 1)
r[i][j] = 1;
else
r[i][j] = r[i][j + 1] + 1;
}
}
for (int j = 0; j < w; j++) {
for (int i = 0; i < h; i++) {
if (c[i][j] == '#')
u[i][j] = 0;
else if (i == 0)
u[i][j] = 1;
else
u[i][j] = u[i - 1][j] + 1;
}
}
for (int j = 0; j < w; j++) {
for (int i = h - 1; i >= 0; i--) {
if (d[i][j] == '#')
d[i][j] = 0;
else if (i == h - 1)
d[i][j] = 1;
else
d[i][j] = d[i + 1][j] + 1;
}
}
int max_c = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j < h; j++) {
max_c = max(max_c, l[i][j] + r[i][j] + d[i][j] + u[i][j] - 3);
}
}
cout << max_c << endl;
} | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int h, w;
cin >> h >> w;
vector<vector<char>> c(2 * h, vector<char>(2 * w));
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
cin >> c[i][j];
}
}
vector<vector<int>> l(2 * h, vector<int>(2 * w));
vector<vector<int>> r(2 * h, vector<int>(2 * w));
vector<vector<int>> d(2 * h, vector<int>(2 * w));
vector<vector<int>> u(2 * h, vector<int>(2 * w));
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if (c[i][j] == '#')
l[i][j] = 0;
else if (j == 0)
l[i][j] = 1;
else
l[i][j] = l[i][j - 1] + 1;
}
}
for (int i = 0; i < h; i++) {
for (int j = w - 1; j >= 0; j--) {
if (c[i][j] == '#')
r[i][j] = 0;
else if (j == w - 1)
r[i][j] = 1;
else
r[i][j] = r[i][j + 1] + 1;
}
}
for (int j = 0; j < w; j++) {
for (int i = 0; i < h; i++) {
if (c[i][j] == '#')
u[i][j] = 0;
else if (i == 0)
u[i][j] = 1;
else
u[i][j] = u[i - 1][j] + 1;
}
}
for (int j = 0; j < w; j++) {
for (int i = h - 1; i >= 0; i--) {
if (c[i][j] == '#')
d[i][j] = 0;
else if (i == h - 1)
d[i][j] = 1;
else
d[i][j] = d[i + 1][j] + 1;
}
}
int max_c = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
max_c = max(max_c, l[i][j] + r[i][j] + d[i][j] + u[i][j] - 3);
}
}
cout << max_c << endl;
} | [
"identifier.change",
"control_flow.branch.if.condition.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 827,952 | 827,951 | u240685518 | cpp |
p03014 | #include <bits/stdc++.h>
#define ll unsigned long long
using namespace std;
int main() {
int H, W;
int i, j;
cin >> H >> W;
vector<string> s(H * 2);
int L[H * 2][W * 2];
int R[H * 2][W * 2];
int D[H * 2][W * 2];
int U[H * 2][W * 2];
for (i = 0; i < H; i++) {
cin >> s[i];
}
for (i = 0; i < H; i++) {
for (j = 0; j < W; j++) {
if (s[i][j] == '#')
L[i][j] = 0;
else if (j == 0)
L[i][j] = 1;
else
L[i][j] = L[i][j - 1] + 1;
}
}
for (i = H - 1; i >= 0; i--) {
for (j = W - 1; j >= 0; j--) {
if (s[i][j] == '#')
R[i][j] = 0;
else if (j == W - 1)
R[i][j] = 1;
else
R[i][j] = R[i][j + 1] + 1;
}
}
for (i = 0; i < H; i++) {
for (j = 0; j < W; j++) {
if (s[i][j] == '#')
U[i][j] = 0;
else if (i == 0)
U[i][j] = 1;
else
U[i][j] = U[i - 1][j] + 1;
}
}
for (i = H - 1; i >= 0; i--) {
for (j = W - 1; j >= 0; j--) {
if (s[i][j] == '#')
D[i][j] = 0;
else if (j == H - 1)
D[i][j] = 1;
else
D[i][j] = D[i + 1][j] + 1;
}
}
int max = 0;
for (i = 0; i < H; i++) {
for (j = 0; j < W; j++) {
int tmp = U[i][j] + R[i][j] + D[i][j] + L[i][j] - 3;
if (max < tmp)
max = tmp;
// cout << max << endl;
}
}
cout << max << endl;
return 0;
}
| #include <bits/stdc++.h>
#define ll unsigned long long
using namespace std;
int main() {
int H, W;
int i, j;
cin >> H >> W;
vector<string> s(H * 2);
int L[H * 2][W * 2];
int R[H * 2][W * 2];
int D[H * 2][W * 2];
int U[H * 2][W * 2];
for (i = 0; i < H; i++) {
cin >> s[i];
}
for (i = 0; i < H; i++) {
for (j = 0; j < W; j++) {
if (s[i][j] == '#')
L[i][j] = 0;
else if (j == 0)
L[i][j] = 1;
else
L[i][j] = L[i][j - 1] + 1;
}
}
for (i = H - 1; i >= 0; i--) {
for (j = W - 1; j >= 0; j--) {
if (s[i][j] == '#')
R[i][j] = 0;
else if (j == W - 1)
R[i][j] = 1;
else
R[i][j] = R[i][j + 1] + 1;
}
}
for (i = 0; i < H; i++) {
for (j = 0; j < W; j++) {
if (s[i][j] == '#')
U[i][j] = 0;
else if (i == 0)
U[i][j] = 1;
else
U[i][j] = U[i - 1][j] + 1;
}
}
for (i = H - 1; i >= 0; i--) {
for (j = W - 1; j >= 0; j--) {
if (s[i][j] == '#')
D[i][j] = 0;
else if (i == H - 1)
D[i][j] = 1;
else
D[i][j] = D[i + 1][j] + 1;
}
}
int max = 0;
for (i = 0; i < H; i++) {
for (j = 0; j < W; j++) {
int tmp = U[i][j] + R[i][j] + D[i][j] + L[i][j] - 3;
if (max < tmp)
max = tmp;
// cout << max << endl;
}
}
cout << max << endl;
return 0;
}
| [
"identifier.change",
"control_flow.branch.if.condition.change"
] | 827,953 | 827,954 | u209053759 | cpp |
p03014 | #include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(ALL(x)), (x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it, x) \
for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define debug(x) cerr << #x << "=" << (x) << endl
#define gett() cerr << "Time:" << clock() << "ms." << endl
int n, m;
vector<int> heng[2200], zong[2200];
string s[2200];
int main() {
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n >> m;
for (int i = 0; i < n; i++)
cin >> s[i];
for (int i = 0; i < n; i++)
heng[i].push_back(-1);
for (int i = 0; i < m; i++)
zong[i].push_back(-1);
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (s[i][j] == '#') {
heng[i].push_back(j);
zong[j].push_back(i);
}
}
}
for (int i = 0; i < n; i++)
heng[i].push_back(n);
for (int i = 0; i < m; i++)
zong[i].push_back(n);
int res = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (s[i][j] == '#')
continue;
int ri = upper_bound(heng[i].begin(), heng[i].end(), j) - heng[i].begin();
int dn = upper_bound(zong[j].begin(), zong[j].end(), i) - zong[j].begin();
res = max(res, heng[i][ri] - heng[i][ri - 1] + zong[j][dn] -
zong[j][dn - 1] - 3);
}
}
cout << res << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(ALL(x)), (x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it, x) \
for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define debug(x) cerr << #x << "=" << (x) << endl
#define gett() cerr << "Time:" << clock() << "ms." << endl
int n, m;
vector<int> heng[2200], zong[2200];
string s[2200];
int main() {
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n >> m;
for (int i = 0; i < n; i++)
cin >> s[i];
for (int i = 0; i < n; i++)
heng[i].push_back(-1);
for (int i = 0; i < m; i++)
zong[i].push_back(-1);
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (s[i][j] == '#') {
heng[i].push_back(j);
zong[j].push_back(i);
}
}
}
for (int i = 0; i < n; i++)
heng[i].push_back(m);
for (int i = 0; i < m; i++)
zong[i].push_back(n);
int res = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (s[i][j] == '#')
continue;
int ri = upper_bound(heng[i].begin(), heng[i].end(), j) - heng[i].begin();
int dn = upper_bound(zong[j].begin(), zong[j].end(), i) - zong[j].begin();
res = max(res, heng[i][ri] - heng[i][ri - 1] + zong[j][dn] -
zong[j][dn - 1] - 3);
}
}
cout << res << endl;
return 0;
}
| [
"identifier.change",
"call.arguments.change"
] | 827,955 | 827,956 | u313427116 | cpp |
p03014 | #include <bits/stdc++.h>
using namespace std;
int N, M;
int pre[2005][2005], suf[2005][2005], up[2005][2005], down[2005][2005];
int main() {
cin >> N >> M;
for (int i = 1; i <= N; i++) {
string s;
cin >> s;
for (int j = 1; j <= M; j++) {
suf[i][j] = down[i][j] = N * M;
if (s[j - 1] == '#') {
pre[i][j] = suf[i][j] = j;
up[i][j] = down[i][j] = i;
}
}
}
for (int i = 1; i <= N; i++) {
pre[i][M + 1] = suf[i][M + 1] = M + 1;
}
for (int j = 1; j <= M; j++) {
up[N + 1][j] = down[N + 1][j] = N + 1;
}
for (int i = 1; i <= N; i++) {
for (int j = 1; j <= M; j++) {
pre[i][j] = max(pre[i][j - 1], pre[i][j]);
up[i][j] = max(up[i - 1][j], up[i][j]);
}
}
for (int i = N; i > 0; i--) {
for (int j = M; j > 0; j--) {
down[i][j] = min(down[i + 1][j], down[i][j]);
suf[i][j] = min(suf[i][j + 1], suf[i][j]);
}
}
int ans = 0;
for (int i = 1; i <= N; i++) {
for (int j = 1; j <= M; j++) {
ans = max(ans, suf[i][j] - pre[i][j] + down[i][j] - up[i][j] - 3);
}
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
int N, M;
int pre[2005][2005], suf[2005][2005], up[2005][2005], down[2005][2005];
int main() {
cin >> N >> M;
for (int i = 1; i <= N; i++) {
string s;
cin >> s;
for (int j = 1; j <= M; j++) {
suf[i][j] = down[i][j] = N * M + 100;
if (s[j - 1] == '#') {
pre[i][j] = suf[i][j] = j;
up[i][j] = down[i][j] = i;
}
}
}
for (int i = 1; i <= N; i++) {
pre[i][M + 1] = suf[i][M + 1] = M + 1;
}
for (int j = 1; j <= M; j++) {
up[N + 1][j] = down[N + 1][j] = N + 1;
}
for (int i = 1; i <= N; i++) {
for (int j = 1; j <= M; j++) {
pre[i][j] = max(pre[i][j - 1], pre[i][j]);
up[i][j] = max(up[i - 1][j], up[i][j]);
}
}
for (int i = N; i > 0; i--) {
for (int j = M; j > 0; j--) {
down[i][j] = min(down[i + 1][j], down[i][j]);
suf[i][j] = min(suf[i][j + 1], suf[i][j]);
}
}
int ans = 0;
for (int i = 1; i <= N; i++) {
for (int j = 1; j <= M; j++) {
ans = max(ans, suf[i][j] - pre[i][j] + down[i][j] - up[i][j] - 3);
}
}
cout << ans << endl;
}
| [
"assignment.change"
] | 827,959 | 827,960 | u937063359 | cpp |
p03014 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fr(i, n) for (int i = 0; i < n; i++)
#define ifr(i, n) for (int i = n - 1; i >= 0; i--)
int main() {
int h, w;
int x = 0;
cin >> h >> w;
string kari[h];
int tate[h + 2][w + 2];
int yoko[h + 2][w + 2];
int max = 0;
int r = 0;
fr(i, h + 2) {
fr(j, w + 2) {
tate[i][j] = -1;
yoko[i][j] = -1;
}
}
fr(i, h) { cin >> kari[i]; }
fr(i, h) {
fr(j, w) {
if (kari[i].substr(j, 1) == "#") {
tate[i + 1][j + 1] = -1;
yoko[i + 1][j + 1] = -1;
}
if (kari[i].substr(j, 1) == ".") {
tate[i + 1][j + 1] = 0;
yoko[i + 1][j + 1] = 0;
}
}
}
for (int x = 1; x < w + 1; x++) {
for (int y = 1; y < h + 1; y++) {
if (tate[y][x] == -1) {
} else if (tate[y - 1][x] == -1)
tate[y][x] = 1;
else
tate[y][x] = tate[y - 1][x] + 1;
}
}
for (int x = w; x > 0; x--) {
for (int y = h; y > 0; y--) {
if (tate[y][x] == -1) {
} else if (tate[y + 1][x] == -1) {
} else
tate[y][x] = tate[y + 1][x];
}
}
for (int y = 1; y < h + 1; y++) {
for (int x = 1; x < w + 1; x++) {
if (yoko[y][x] == -1) {
} else if (yoko[y][x - 1] == -1)
yoko[y][x] = 1;
else
yoko[y][x] = yoko[y][x - 1] + 1;
}
}
for (int y = h; y > 0; y--) {
for (int x = w; x > 0; x--) {
if (yoko[y][x] == -1) {
} else if (yoko[y][x + 1] == -1) {
} else
yoko[y][x] = yoko[y][x + 1];
}
}
for (int x = 1; x < w + 1; x++) {
for (int y = 1; y < h + 1; y++) {
if (tate[y][x] + yoko[y][x] > max)
max = tate[y][x] + yoko[y][x];
}
}
cout << max << endl;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fr(i, n) for (int i = 0; i < n; i++)
#define ifr(i, n) for (int i = n - 1; i >= 0; i--)
int main() {
int h, w;
int x = 0;
cin >> h >> w;
string kari[h];
int tate[h + 2][w + 2];
int yoko[h + 2][w + 2];
int max = 0;
int r = 0;
fr(i, h + 2) {
fr(j, w + 2) {
tate[i][j] = -1;
yoko[i][j] = -1;
}
}
fr(i, h) { cin >> kari[i]; }
fr(i, h) {
fr(j, w) {
if (kari[i].substr(j, 1) == "#") {
tate[i + 1][j + 1] = -1;
yoko[i + 1][j + 1] = -1;
}
if (kari[i].substr(j, 1) == ".") {
tate[i + 1][j + 1] = 0;
yoko[i + 1][j + 1] = 0;
}
}
}
for (int x = 1; x < w + 1; x++) {
for (int y = 1; y < h + 1; y++) {
if (tate[y][x] == -1) {
} else if (tate[y - 1][x] == -1)
tate[y][x] = 1;
else
tate[y][x] = tate[y - 1][x] + 1;
}
}
for (int x = w; x > 0; x--) {
for (int y = h; y > 0; y--) {
if (tate[y][x] == -1) {
} else if (tate[y + 1][x] == -1) {
} else
tate[y][x] = tate[y + 1][x];
}
}
for (int y = 1; y < h + 1; y++) {
for (int x = 1; x < w + 1; x++) {
if (yoko[y][x] == -1) {
} else if (yoko[y][x - 1] == -1)
yoko[y][x] = 1;
else
yoko[y][x] = yoko[y][x - 1] + 1;
}
}
for (int y = h; y > 0; y--) {
for (int x = w; x > 0; x--) {
if (yoko[y][x] == -1) {
} else if (yoko[y][x + 1] == -1) {
} else
yoko[y][x] = yoko[y][x + 1];
}
}
for (int x = 1; x < w + 1; x++) {
for (int y = 1; y < h + 1; y++) {
if (tate[y][x] + yoko[y][x] > max)
max = tate[y][x] + yoko[y][x];
}
}
cout << max - 1 << endl;
}
| [
"expression.operation.binary.add"
] | 827,965 | 827,966 | u806159048 | cpp |
p03014 | #include <bits/stdc++.h>
#include <iomanip>
#include <numeric>
using namespace std;
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll md = mod;
constexpr ll inf = 1e15;
int main() {
int h, w;
cin >> h >> w;
vector<string> s(h);
for (auto &a : s)
cin >> a;
vector<vector<int>> l(h, vector<int>(w));
auto r = l, u = l, d = l;
for (int i = 0; i < h; ++i) {
for (int j = 0; j < h; ++j)
if (s[i][j] != '#') {
l[i][j] = 1;
if (j)
l[i][j] += l[i][j - 1];
}
for (int j = h - 1; j >= 0; --j)
if (s[i][j] != '#') {
r[i][j] = 1;
if (j != h - 1)
r[i][j] += r[i][j + 1];
}
}
for (int j = 0; j < w; ++j) {
for (int i = 0; i < h; ++i)
if (s[i][j] != '#') {
u[i][j] = 1;
if (i)
u[i][j] += u[i - 1][j];
}
for (int i = h - 1; i >= 0; i--)
if (s[i][j] != '#') {
d[i][j] = 1;
if (i != h - 1)
d[i][j] += d[i + 1][j];
}
}
ll ret = 0;
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
ret = max(ret, (ll)l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3ll);
}
}
cout << ret << endl;
return 0;
}
| #include <bits/stdc++.h>
#include <iomanip>
#include <numeric>
using namespace std;
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll md = mod;
constexpr ll inf = 1e15;
int main() {
int h, w;
cin >> h >> w;
vector<string> s(h);
for (auto &a : s)
cin >> a;
vector<vector<int>> l(h, vector<int>(w));
auto r = l, u = l, d = l;
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j)
if (s[i][j] != '#') {
l[i][j] = 1;
if (j)
l[i][j] += l[i][j - 1];
}
for (int j = w - 1; j >= 0; --j)
if (s[i][j] != '#') {
r[i][j] = 1;
if (j != w - 1)
r[i][j] += r[i][j + 1];
}
}
for (int j = 0; j < w; ++j) {
for (int i = 0; i < h; ++i)
if (s[i][j] != '#') {
u[i][j] = 1;
if (i)
u[i][j] += u[i - 1][j];
}
for (int i = h - 1; i >= 0; i--)
if (s[i][j] != '#') {
d[i][j] = 1;
if (i != h - 1)
d[i][j] += d[i + 1][j];
}
}
ll ret = 0;
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
ret = max(ret, (ll)l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3ll);
}
}
cout << ret << endl;
return 0;
}
| [
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change",
"control_flow.loop.for.initializer.change",
"control_flow.branch.if.condition.change"
] | 827,973 | 827,974 | u699193595 | cpp |
p03014 | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define mod 1000000007
#define INF2 9999999999
#define INF (1 << 30)
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
using namespace std;
using ll = __int64_t;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int DX[] = {1, 1, 0, -1, -1, -1, 0, 1};
int DY[] = {0, -1, -1, -1, 0, 1, 1, 1};
bool comp(const pair<int, ll> &p1, const pair<int, ll> &p2) {
return p1.second > p2.second;
}
int h, w;
char s[2000][2000];
int L[2000][2000], R[2000][2000], D[2000][2000], U[2000][2000];
void solve() {
cin >> h >> w;
int res = 0;
rep(i, h) {
rep(j, w) { cin >> s[i][j]; }
}
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if (s[i][j] == '#') {
L[i][j] = 0;
} else if (j == 0) {
L[i][j] = 1;
} else {
L[i][j] = L[i][j - 1] + 1;
}
}
}
for (int i = 0; i < h; i++) {
for (int j = w - 1; j > 0; j--) {
if (s[i][j] == '#') {
R[i][j] = 0;
} else if (j == w - 1) {
R[i][j] = 1;
} else {
R[i][j] = R[i][j + 1] + 1;
}
}
}
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if (s[i][j] == '#') {
U[i][j] = 0;
} else if (i == 0) {
U[i][j] = 1;
} else {
U[i][j] = U[i - 1][j] + 1;
}
}
}
for (int i = h - 1; i > 0; i--) {
for (int j = 0; j < w; j++) {
if (s[i][j] == '#') {
D[i][j] = 0;
} else if (i == h - 1) {
D[i][j] = 1;
} else {
D[i][j] = D[i + 1][j] + 1;
}
}
}
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
res = max(res, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3);
}
}
cout << res << endl;
}
int main() {
solve();
return 0;
} | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define mod 1000000007
#define INF2 9999999999
#define INF (1 << 30)
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
using namespace std;
using ll = __int64_t;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int DX[] = {1, 1, 0, -1, -1, -1, 0, 1};
int DY[] = {0, -1, -1, -1, 0, 1, 1, 1};
bool comp(const pair<int, ll> &p1, const pair<int, ll> &p2) {
return p1.second > p2.second;
}
int h, w;
char s[2000][2000];
int L[2000][2000], R[2000][2000], D[2000][2000], U[2000][2000];
void solve() {
cin >> h >> w;
int res = 0;
rep(i, h) {
rep(j, w) { cin >> s[i][j]; }
}
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if (s[i][j] == '#') {
L[i][j] = 0;
} else if (j == 0) {
L[i][j] = 1;
} else {
L[i][j] = L[i][j - 1] + 1;
}
}
}
for (int i = 0; i < h; i++) {
for (int j = w - 1; j >= 0; j--) {
if (s[i][j] == '#') {
R[i][j] = 0;
} else if (j == w - 1) {
R[i][j] = 1;
} else {
R[i][j] = R[i][j + 1] + 1;
}
}
}
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if (s[i][j] == '#') {
U[i][j] = 0;
} else if (i == 0) {
U[i][j] = 1;
} else {
U[i][j] = U[i - 1][j] + 1;
}
}
}
for (int i = h - 1; i >= 0; i--) {
for (int j = 0; j < w; j++) {
if (s[i][j] == '#') {
D[i][j] = 0;
} else if (i == h - 1) {
D[i][j] = 1;
} else {
D[i][j] = D[i + 1][j] + 1;
}
}
}
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
res = max(res, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3);
}
}
cout << res << endl;
}
int main() {
solve();
return 0;
} | [
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 827,980 | 827,981 | u679071005 | cpp |
p03014 | #define FOR_IDE
#define REP(i, t, n) for (int i = t; i < n; i++)
#define ALL(n) (n).begin(), (n).end()
#include <algorithm>
#include <cmath>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <stdio.h>
#include <string>
#include <unordered_map>
#include <vector>
#define INF (1000000000)
using namespace std;
typedef bool BOOL;
typedef short WORD;
typedef unsigned short U_WORD;
typedef long DWORD;
typedef unsigned long U_DWORD;
typedef long long QWORD;
typedef unsigned long long U_QWORD;
#define H_MAX (2000)
#define W_MAX (2000)
// . = 1, # = 0 とする
bool Field[H_MAX + 2][W_MAX + 2] = {};
QWORD ansTable[H_MAX + 2][W_MAX + 2] = {};
DWORD H, W;
void calcLightNum(int idxH, int idxW, int *lightNum) {
if (Field[idxH][idxW]) {
(*lightNum)++;
} else {
(*lightNum) = 0;
}
}
void solve_main() {
QWORD qwAns = 0;
cin >> H >> W;
REP(i, 0, H_MAX + 2) {
REP(j, 0, W_MAX + 2) { ansTable[i][j] = 0; }
}
REP(i, 1, H + 1) {
string input;
cin >> input;
REP(j, 1, W + 1) {
if (input[j - 1] == '.') {
Field[i][j] = true;
}
}
}
//左方向への光確認
REP(idxH, 1, (H + 1)) {
int lightNum = 0;
REP(idxW, 1, (W + 1)) {
calcLightNum(idxH, idxW, &lightNum);
ansTable[idxH][idxW] += lightNum;
}
}
//右方向への光確認
REP(idxH, 1, (H + 1)) {
int lightNum = 0;
for (int idxW = W; idxW > 0; idxW--) {
calcLightNum(idxH, idxW, &lightNum);
ansTable[idxH][idxW] += lightNum;
}
}
//下方向への光確認
REP(idxW, 1, (W + 1)) {
int lightNum = 0;
REP(idxH, 1, (H + 1)) {
calcLightNum(idxH, idxW, &lightNum);
ansTable[idxH][idxW] += lightNum;
}
}
//上方向への光確認
REP(idxW, 1, (W + 1)) {
int lightNum = 0;
for (int idxH = H; idxH > 0; idxH--) {
calcLightNum(idxH, idxW, &lightNum);
ansTable[idxH][idxW] += lightNum;
}
}
REP(idxH, 1, (H + 1)) {
REP(idxW, 1, (W + 1)) {
ansTable[idxH][idxW] -= 3; // 重複をマイナス
qwAns = max(qwAns, ansTable[idxH][idxW]);
}
}
cout << qwAns << endl;
}
int main() {
#ifdef FOR_IDE
ifstream in("input.txt");
cin.rdbuf(in.rdbuf());
#endif
solve_main();
return 0;
}
| #define REP(i, t, n) for (int i = t; i < n; i++)
#define ALL(n) (n).begin(), (n).end()
#include <algorithm>
#include <cmath>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <stdio.h>
#include <string>
#include <unordered_map>
#include <vector>
#define INF (1000000000)
using namespace std;
typedef bool BOOL;
typedef short WORD;
typedef unsigned short U_WORD;
typedef long DWORD;
typedef unsigned long U_DWORD;
typedef long long QWORD;
typedef unsigned long long U_QWORD;
#define H_MAX (2000)
#define W_MAX (2000)
// . = 1, # = 0 とする
bool Field[H_MAX + 2][W_MAX + 2] = {};
QWORD ansTable[H_MAX + 2][W_MAX + 2] = {};
DWORD H, W;
void calcLightNum(int idxH, int idxW, int *lightNum) {
if (Field[idxH][idxW]) {
(*lightNum)++;
} else {
(*lightNum) = 0;
}
}
void solve_main() {
QWORD qwAns = 0;
cin >> H >> W;
REP(i, 0, H_MAX + 2) {
REP(j, 0, W_MAX + 2) { ansTable[i][j] = 0; }
}
REP(i, 1, H + 1) {
string input;
cin >> input;
REP(j, 1, W + 1) {
if (input[j - 1] == '.') {
Field[i][j] = true;
}
}
}
//左方向への光確認
REP(idxH, 1, (H + 1)) {
int lightNum = 0;
REP(idxW, 1, (W + 1)) {
calcLightNum(idxH, idxW, &lightNum);
ansTable[idxH][idxW] += lightNum;
}
}
//右方向への光確認
REP(idxH, 1, (H + 1)) {
int lightNum = 0;
for (int idxW = W; idxW > 0; idxW--) {
calcLightNum(idxH, idxW, &lightNum);
ansTable[idxH][idxW] += lightNum;
}
}
//下方向への光確認
REP(idxW, 1, (W + 1)) {
int lightNum = 0;
REP(idxH, 1, (H + 1)) {
calcLightNum(idxH, idxW, &lightNum);
ansTable[idxH][idxW] += lightNum;
}
}
//上方向への光確認
REP(idxW, 1, (W + 1)) {
int lightNum = 0;
for (int idxH = H; idxH > 0; idxH--) {
calcLightNum(idxH, idxW, &lightNum);
ansTable[idxH][idxW] += lightNum;
}
}
REP(idxH, 1, (H + 1)) {
REP(idxW, 1, (W + 1)) {
ansTable[idxH][idxW] -= 3; // 重複をマイナス
qwAns = max(qwAns, ansTable[idxH][idxW]);
}
}
cout << qwAns << endl;
}
int main() {
#ifdef FOR_IDE
ifstream in("input.txt");
cin.rdbuf(in.rdbuf());
#endif
solve_main();
return 0;
}
| [] | 827,991 | 827,992 | u717315282 | cpp |
p03014 | #include <bits/stdc++.h>
using namespace std;
#define N 2019
int n, m;
char s[N][N];
int a[N][N];
int ans, cnt;
int main() {
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i++)
scanf("%s", &s[i]);
ans = 1;
for (int i = 0; i < n; i++)
for (int j = 0; j <= m; j++)
if (j == n || s[i][j] == '#') {
for (int k = j - 1; k >= 0 && s[i][k] == '.'; k--)
a[i][k] = cnt;
cnt = 0;
} else
cnt++;
for (int j = 0; j < m; j++)
for (int i = 0; i <= n; i++)
if (i == n || s[i][j] == '#') {
for (int k = i - 1; k >= 0 && s[k][j] == '.'; k--)
a[k][j] += cnt;
cnt = 0;
} else
cnt++;
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
ans = max(ans, a[i][j]);
printf("%d\n", ans - 1);
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define N 2019
int n, m;
char s[N][N];
int a[N][N];
int ans, cnt;
int main() {
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i++)
scanf("%s", &s[i]);
ans = 1;
for (int i = 0; i < n; i++)
for (int j = 0; j <= m; j++)
if (j == m || s[i][j] == '#') {
for (int k = j - 1; k >= 0 && s[i][k] == '.'; k--)
a[i][k] = cnt;
cnt = 0;
} else
cnt++;
for (int j = 0; j < m; j++)
for (int i = 0; i <= n; i++)
if (i == n || s[i][j] == '#') {
for (int k = i - 1; k >= 0 && s[k][j] == '.'; k--)
a[k][j] += cnt;
cnt = 0;
} else
cnt++;
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
ans = max(ans, a[i][j]);
printf("%d\n", ans - 1);
return 0;
} | [
"identifier.change",
"control_flow.branch.if.condition.change"
] | 827,993 | 827,994 | u095721761 | cpp |
p03014 | #include <bits/stdc++.h>
using namespace std;
#define N 2019
int n, m;
char s[N][N];
int a[N][N];
int ans, cnt;
int main() {
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i++)
scanf("%s", &s[i]);
for (int i = 0; i < n; i++)
for (int j = 0; j <= m; j++)
if (j == n || s[i][j] == '#') {
for (int k = j - 1; k >= 0 && s[i][k] == '.'; k--)
a[i][k] = cnt;
cnt = 0;
} else
cnt++;
for (int j = 0; j < m; j++)
for (int i = 0; i <= n; i++)
if (i == n || s[i][j] == '#') {
for (int k = i - 1; k >= 0 && s[k][j] == '.'; k--)
a[k][j] += cnt;
cnt = 0;
} else
cnt++;
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
ans = max(ans, a[i][j]);
printf("%d\n", ans - 1);
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define N 2019
int n, m;
char s[N][N];
int a[N][N];
int ans, cnt;
int main() {
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i++)
scanf("%s", &s[i]);
ans = 1;
for (int i = 0; i < n; i++)
for (int j = 0; j <= m; j++)
if (j == m || s[i][j] == '#') {
for (int k = j - 1; k >= 0 && s[i][k] == '.'; k--)
a[i][k] = cnt;
cnt = 0;
} else
cnt++;
for (int j = 0; j < m; j++)
for (int i = 0; i <= n; i++)
if (i == n || s[i][j] == '#') {
for (int k = i - 1; k >= 0 && s[k][j] == '.'; k--)
a[k][j] += cnt;
cnt = 0;
} else
cnt++;
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
ans = max(ans, a[i][j]);
printf("%d\n", ans - 1);
return 0;
} | [
"assignment.add",
"identifier.change",
"control_flow.branch.if.condition.change"
] | 827,995 | 827,994 | u095721761 | cpp |
p03014 | #include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define debug(x) cout << #x << " = " << (x) << endl;
using namespace std;
typedef long long int LL;
typedef unsigned long long int ULL;
int main() {
int h, w;
cin >> h >> w;
vector<string> s(h);
rep(i, h) { cin >> s[i]; }
vector<vector<LL>> left(h, vector<LL>(w, 0));
vector<vector<LL>> right(h, vector<LL>(w, 0));
vector<vector<LL>> up(h, vector<LL>(w, 0));
vector<vector<LL>> down(h, vector<LL>(w, 0));
rep(y, h) {
int acc = 0;
rep(x, w) {
if (s[x][y] == '#') {
acc = 0;
continue;
}
acc++;
left[y][x] = acc;
}
}
rep(y, h) {
int acc = 0;
for (int x = w - 1; x >= 0; x--) {
if (s[y][x] == '#') {
acc = 0;
continue;
}
acc++;
right[y][x] = acc;
}
}
rep(x, w) {
int acc = 0;
rep(y, h) {
if (s[y][x] == '#') {
acc = 0;
continue;
}
acc++;
up[y][x] = acc;
}
}
rep(x, w) {
int acc = 0;
for (int y = h - 1; y >= 0; y--) {
if (s[y][x] == '#') {
acc = 0;
continue;
}
acc++;
down[y][x] = acc;
}
}
LL ans = 0;
rep(y, h) {
rep(x, w) {
ans = max(ans, left[y][x] + right[y][x] + up[y][x] + down[y][x] - 3);
}
}
cout << ans << endl;
return 0;
}
| #include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define debug(x) cout << #x << " = " << (x) << endl;
using namespace std;
typedef long long int LL;
typedef unsigned long long int ULL;
int main() {
int h, w;
cin >> h >> w;
vector<string> s(h);
rep(i, h) { cin >> s[i]; }
vector<vector<LL>> left(h, vector<LL>(w, 0));
vector<vector<LL>> right(h, vector<LL>(w, 0));
vector<vector<LL>> up(h, vector<LL>(w, 0));
vector<vector<LL>> down(h, vector<LL>(w, 0));
rep(y, h) {
int acc = 0;
rep(x, w) {
if (s[y][x] == '#') {
acc = 0;
continue;
}
acc++;
left[y][x] = acc;
}
}
rep(y, h) {
int acc = 0;
for (int x = w - 1; x >= 0; x--) {
if (s[y][x] == '#') {
acc = 0;
continue;
}
acc++;
right[y][x] = acc;
}
}
rep(x, w) {
int acc = 0;
rep(y, h) {
if (s[y][x] == '#') {
acc = 0;
continue;
}
acc++;
up[y][x] = acc;
}
}
rep(x, w) {
int acc = 0;
for (int y = h - 1; y >= 0; y--) {
if (s[y][x] == '#') {
acc = 0;
continue;
}
acc++;
down[y][x] = acc;
}
}
LL ans = 0;
rep(y, h) {
rep(x, w) {
ans = max(ans, left[y][x] + right[y][x] + up[y][x] + down[y][x] - 3);
}
}
cout << ans << endl;
return 0;
}
| [
"identifier.change",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change"
] | 828,000 | 828,001 | u614063956 | cpp |
p03014 | #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int H, W;
cin >> H >> W;
vector<string> S(H);
for (int i = 0; i < H; i++) {
cin >> S[i];
}
vector<vector<int>> L(H, vector<int>(W, 0));
vector<vector<int>> R(H, vector<int>(W, 0));
vector<vector<int>> U(H, vector<int>(W, 0));
vector<vector<int>> D(H, vector<int>(W, 0));
for (int i = 0; i < H; i++) {
int cnt = 0;
for (int j = 0; j < W; j++) {
if (S[i][j] == '#') {
cnt = 0;
} else {
cnt++;
}
L[i][j] = cnt;
}
} //(i,j)自身も数えていることに注意
for (int i = 0; i < H; i++) {
int cnt = 0;
for (int j = W - 1; j >= 0; j--) {
if (S[i][j] == '#') {
cnt = 0;
} else {
cnt++;
}
R[i][j] = cnt;
}
}
for (int j = 0; j < W; j++) {
int cnt = 0;
for (int i = 0; i < H; i++) {
if (S[i][j] = '#') {
cnt = 0;
} else {
cnt++;
}
U[i][j] = cnt;
}
}
for (int j = 0; j < W; j++) {
int cnt = 0;
for (int i = H - 1; i >= 0; i--) {
if (S[i][j] == '#') {
cnt = 0;
} else {
cnt++;
}
D[i][j] = cnt;
}
}
int max_cnt = 0;
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
if (S[i][j] == '#') {
continue;
}
int M = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3;
max_cnt = max(max_cnt, M);
}
}
cout << max_cnt << endl;
return 0;
}
| #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int H, W;
cin >> H >> W;
vector<string> S(H);
for (int i = 0; i < H; i++) {
cin >> S[i];
}
vector<vector<int>> L(H, vector<int>(W, 0));
vector<vector<int>> R(H, vector<int>(W, 0));
vector<vector<int>> U(H, vector<int>(W, 0));
vector<vector<int>> D(H, vector<int>(W, 0));
for (int i = 0; i < H; i++) {
int cnt = 0;
for (int j = 0; j < W; j++) {
if (S[i][j] == '#') {
cnt = 0;
} else {
cnt++;
}
L[i][j] = cnt;
}
} //(i,j)自身も数えていることに注意
for (int i = 0; i < H; i++) {
int cnt = 0;
for (int j = W - 1; j >= 0; j--) {
if (S[i][j] == '#') {
cnt = 0;
} else {
cnt++;
}
R[i][j] = cnt;
}
}
for (int j = 0; j < W; j++) {
int cnt = 0;
for (int i = 0; i < H; i++) {
if (S[i][j] == '#') {
cnt = 0;
} else {
cnt++;
}
U[i][j] = cnt;
}
}
for (int j = 0; j < W; j++) {
int cnt = 0;
for (int i = H - 1; i >= 0; i--) {
if (S[i][j] == '#') {
cnt = 0;
} else {
cnt++;
}
D[i][j] = cnt;
}
}
int max_cnt = 0;
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
if (S[i][j] == '#') {
continue;
}
int M = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3;
max_cnt = max(max_cnt, M);
}
}
cout << max_cnt << endl;
return 0;
}
| [
"expression.operation.compare.replace.add",
"assignment.replace.remove",
"misc.typo"
] | 828,014 | 828,015 | u904123392 | cpp |
p03014 | #include <algorithm>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int main() {
int H, W;
cin >> H >> W;
vector<string> S(H);
for (int i = 0; i < H; i++) {
cin >> S[i];
}
vector<vector<int>> L(H, vector<int>(W));
vector<vector<int>> R(H, vector<int>(W));
vector<vector<int>> U(H, vector<int>(W));
vector<vector<int>> D(H, vector<int>(W));
for (int i = 0; i < H; i++) {
int cnt = 0;
for (int j = 0; j < W; j++) {
if (S[i][j] == '#') {
cnt = 0;
} else {
cnt++;
}
L[i][j] = cnt;
}
}
for (int i = 0; i < H; i++) {
int cnt = 0;
for (int j = W - 1; j >= 0; j--) {
if (S[i][j] == '#') {
cnt = 0;
} else {
cnt++;
}
R[i][j] = cnt;
}
}
for (int i = 0; i < W; i++) {
int cnt = 0;
for (int j = 0; j < H; j++) {
if (S[j][i] == '#') {
cnt = 0;
} else {
cnt++;
}
U[j][i] = cnt;
}
}
for (int i = 0; i < W; i++) {
int cnt = 0;
for (int j = H - 1; j >= 0; j--) {
if (S[j][i] == '#') {
cnt = 0;
} else {
cnt++;
}
D[i][j] = cnt;
}
}
int max_sum = 0;
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
int c = U[i][j] + D[i][j] + L[i][j] + R[i][j] - 3;
max_sum = max(c, max_sum);
}
}
cout << max_sum << endl;
return 0;
}
| #include <algorithm>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int main() {
int H, W;
cin >> H >> W;
vector<string> S(H);
for (int i = 0; i < H; i++) {
cin >> S[i];
}
vector<vector<int>> L(H, vector<int>(W));
vector<vector<int>> R(H, vector<int>(W));
vector<vector<int>> U(H, vector<int>(W));
vector<vector<int>> D(H, vector<int>(W));
for (int i = 0; i < H; i++) {
int cnt = 0;
for (int j = 0; j < W; j++) {
if (S[i][j] == '#') {
cnt = 0;
} else {
cnt++;
}
L[i][j] = cnt;
}
}
for (int i = 0; i < H; i++) {
int cnt = 0;
for (int j = W - 1; j >= 0; j--) {
if (S[i][j] == '#') {
cnt = 0;
} else {
cnt++;
}
R[i][j] = cnt;
}
}
for (int i = 0; i < W; i++) {
int cnt = 0;
for (int j = 0; j < H; j++) {
if (S[j][i] == '#') {
cnt = 0;
} else {
cnt++;
}
U[j][i] = cnt;
}
}
for (int i = 0; i < W; i++) {
int cnt = 0;
for (int j = H - 1; j >= 0; j--) {
if (S[j][i] == '#') {
cnt = 0;
} else {
cnt++;
}
D[j][i] = cnt;
}
}
int max_sum = 0;
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
int c = U[i][j] + D[i][j] + L[i][j] + R[i][j] - 3;
max_sum = max(c, max_sum);
}
}
cout << max_sum << endl;
return 0;
}
| [
"assignment.variable.change",
"identifier.change",
"variable_access.subscript.index.change"
] | 828,016 | 828,017 | u904123392 | cpp |
p03014 | #include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(), (x).end()
ll power(ll base, ll exponent, ll module) {
if (exponent % 2) {
return power(base, exponent - 1, module) * base % module;
} else if (exponent) {
ll root_ans = power(base, exponent / 2, module);
return root_ans * root_ans % module;
} else {
return 1;
}
}
ll inverse(ll x) { return power(x, mod - 2, mod); }
ll gcd(ll a, ll b) {
if (a < b)
gcd(b, a);
ll r;
while (r = a % b) {
a = b;
b = r;
}
return b;
}
struct combination {
vector<ll> fact, inv;
combination(int sz) : fact(sz + 1), inv(sz + 1) {
fact[0] = 1;
for (int i = 1; i <= sz; i++) {
fact[i] = fact[i - 1] * i % mod;
}
inv[sz] = power(fact[sz], mod - 2, mod);
for (int i = sz - 1; i >= 0; i--) {
inv[i] = inv[i + 1] * (i + 1) % mod;
}
}
ll C(int p, int q) const {
if (q < 0 || p < q)
return 0;
return (fact[p] * inv[q] % mod * inv[p - q] % mod);
}
};
signed main() {
ios::sync_with_stdio(false);
int h, w;
cin >> h >> w;
vector<string> s(h);
REP(i, h) cin >> s[i];
vector<vector<ll>> cumx = vector<vector<ll>>(h, vector<ll>(w, 0));
vector<vector<ll>> cumy = vector<vector<ll>>(h, vector<ll>(w, 0));
REP(y, h) {
int left = 0;
REP(x, w) {
if (s[y][x] == '#') {
REP_FROM(i, left, x) { cumx[y][i] = x - left; }
left = x + 1;
}
}
if (s[y][w - 1] == '.') {
REP_FROM(i, left, w) { cumx[y][i] = w - left; }
}
}
REP(x, w) {
int left = 0;
REP(y, h) {
if (s[y][x] == '#') {
REP_FROM(i, left, y) { cumy[i][x] = y - left; }
left = y;
}
}
if (s[h - 1][x] == '.') {
REP_FROM(i, left, h) { cumy[i][x] = h - left; }
}
}
ll ans = 0;
REP(i, h) {
REP(j, w) { ans = max(ans, cumx[i][j] + cumy[i][j] - 1); }
}
cout << ans << endl;
return 0;
}
| #include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(), (x).end()
ll power(ll base, ll exponent, ll module) {
if (exponent % 2) {
return power(base, exponent - 1, module) * base % module;
} else if (exponent) {
ll root_ans = power(base, exponent / 2, module);
return root_ans * root_ans % module;
} else {
return 1;
}
}
ll inverse(ll x) { return power(x, mod - 2, mod); }
ll gcd(ll a, ll b) {
if (a < b)
gcd(b, a);
ll r;
while (r = a % b) {
a = b;
b = r;
}
return b;
}
struct combination {
vector<ll> fact, inv;
combination(int sz) : fact(sz + 1), inv(sz + 1) {
fact[0] = 1;
for (int i = 1; i <= sz; i++) {
fact[i] = fact[i - 1] * i % mod;
}
inv[sz] = power(fact[sz], mod - 2, mod);
for (int i = sz - 1; i >= 0; i--) {
inv[i] = inv[i + 1] * (i + 1) % mod;
}
}
ll C(int p, int q) const {
if (q < 0 || p < q)
return 0;
return (fact[p] * inv[q] % mod * inv[p - q] % mod);
}
};
signed main() {
ios::sync_with_stdio(false);
int h, w;
cin >> h >> w;
vector<string> s(h);
REP(i, h) cin >> s[i];
vector<vector<ll>> cumx = vector<vector<ll>>(h, vector<ll>(w, 0));
vector<vector<ll>> cumy = vector<vector<ll>>(h, vector<ll>(w, 0));
REP(y, h) {
int left = 0;
REP(x, w) {
if (s[y][x] == '#') {
REP_FROM(i, left, x) { cumx[y][i] = x - left; }
left = x + 1;
}
}
if (s[y][w - 1] == '.') {
REP_FROM(i, left, w) { cumx[y][i] = w - left; }
}
}
REP(x, w) {
int left = 0;
REP(y, h) {
if (s[y][x] == '#') {
REP_FROM(i, left, y) { cumy[i][x] = y - left; }
left = y + 1;
}
}
if (s[h - 1][x] == '.') {
REP_FROM(i, left, h) { cumy[i][x] = h - left; }
}
}
ll ans = 0;
REP(i, h) {
REP(j, w) { ans = max(ans, cumx[i][j] + cumy[i][j] - 1); }
}
// REP(y, h) {
// REP(x, w) {
// cout << cumx[y][x] << " ";
// }
// cout << endl;
// }
// cout << endl;
// REP(y, h) {
// REP(x, w) {
// cout << cumy[y][x] << " ";
// }
// cout << endl;
// }
cout << ans << endl;
return 0;
}
| [
"assignment.change"
] | 828,023 | 828,024 | u702582248 | cpp |
p03014 | #include <bits/stdc++.h>
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define per(i, a, n) for (ll i = n - 1; i >= a; i--)
#define fill0(n) setfill('0') << right << setw(n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000
using namespace std;
typedef long long ll;
// typedef pair<ll,ll> p;
int h, w;
int R[2000][2000], L[2000][2000], U[2000][2000], D[2000][2000];
int main() {
cin >> h >> w;
vector<string> s(h);
for (int i = 0; i < w; i++)
cin >> s[i];
//左の探索
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
int cnt = 0;
if (s[i][j] == '#')
L[i][j] = 0;
else if (j == 0)
L[i][j] = 1;
else
L[i][j] = L[i][j - 1] + 1;
}
}
//右の探索
for (int i = 0; i < h; i++) {
for (int j = w - 1; j >= 0; j--) {
int cnt = 0;
if (s[i][j] == '#')
R[i][j] = 0;
else if (j == w - 1)
R[i][j] = 1;
else
R[i][j] = R[i][j + 1] + 1;
}
}
//下の探索
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
int cnt = 0;
if (s[i][j] == '#')
D[i][j] = 0;
else if (i == 0)
D[i][j] = 1;
else
D[i][j] = D[i - 1][j] + 1;
// cout << D[i][j] << "";
}
}
for (int i = h - 1; i >= 0; i--) {
for (int j = 0; j < w; j++) {
int cnt = 0;
if (s[i][j] == '#')
U[i][j] = 0;
else if (i == h - 1)
U[i][j] = 1;
else
U[i][j] = U[i + 1][j] + 1;
}
}
int ans = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
ans = max(ans, U[i][j] + D[i][j] + R[i][j] + L[i][j] - 3);
}
}
cout << ans << endl;
} | #include <bits/stdc++.h>
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define per(i, a, n) for (ll i = n - 1; i >= a; i--)
#define fill0(n) setfill('0') << right << setw(n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000
using namespace std;
typedef long long ll;
// typedef pair<ll,ll> p;
int h, w;
int R[2000][2000], L[2000][2000], U[2000][2000], D[2000][2000];
int main() {
cin >> h >> w;
vector<string> s(h);
for (int i = 0; i < h; i++)
cin >> s[i];
//左の探索
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
int cnt = 0;
if (s[i][j] == '#')
L[i][j] = 0;
else if (j == 0)
L[i][j] = 1;
else
L[i][j] = L[i][j - 1] + 1;
}
}
//右の探索
for (int i = 0; i < h; i++) {
for (int j = w - 1; j >= 0; j--) {
int cnt = 0;
if (s[i][j] == '#')
R[i][j] = 0;
else if (j == w - 1)
R[i][j] = 1;
else
R[i][j] = R[i][j + 1] + 1;
}
}
//下の探索
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
int cnt = 0;
if (s[i][j] == '#')
D[i][j] = 0;
else if (i == 0)
D[i][j] = 1;
else
D[i][j] = D[i - 1][j] + 1;
// cout << D[i][j] << "";
}
}
for (int i = h - 1; i >= 0; i--) {
for (int j = 0; j < w; j++) {
int cnt = 0;
if (s[i][j] == '#')
U[i][j] = 0;
else if (i == h - 1)
U[i][j] = 1;
else
U[i][j] = U[i + 1][j] + 1;
}
}
int ans = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
ans = max(ans, U[i][j] + D[i][j] + R[i][j] + L[i][j] - 3);
}
}
cout << ans << endl;
}
| [
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 828,025 | 828,026 | u255001744 | cpp |
p03014 | #include <bits/stdc++.h>
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define per(i, a, n) for (ll i = n - 1; i >= a; i--)
#define fill0(n) setfill('0') << right << setw(n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000
using namespace std;
typedef long long ll;
// typedef pair<ll,ll> p;
int h, w;
int r[2010][2010], l[2010][2010], u[2010][2010], d[2010][2010];
template <typename T> bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
};
int main() {
cin >> h >> w;
vector<string> c(h);
for (int i = 0; i < w; i++)
cin >> c[i];
//左からの探索
// for(int i = 0; i < h; i++){
// for(int j = 0; j < w; j++){
// if(c[i][j]=='#')l[i][j] = 0;
// else if (j==0)l[i][j] = 1;
// else l[i][j] = l[i][j-1]+1;
// }
// }
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if (c[i][j] == '#') {
l[i][j] = 0;
} else {
if (j > 0) {
l[i][j] = l[i][j - 1] + 1;
} else {
l[i][j] = 1;
}
}
}
}
//右からの探索
// for(int i = 0; i < h; i++){
// for(int j = w-1; j >= 0; j--){
// if(c[i][j]=='#')r[i][j] = 0;
// else if (j==w-1)r[i][j] = 1;
// else r[i][j] = r[i][j+1]+1;
// }
// }
for (int i = 0; i < h; i++) {
for (int j = w - 1; j >= 0; j--) {
if (c[i][j] == '#') {
r[i][j] = 0;
} else {
if (j < w - 1) {
r[i][j] = r[i][j + 1] + 1;
} else {
r[i][j] = 1;
}
}
}
}
//下からの探索
// for(int i = 0; i < h; i++){
// for(int j = 0; j < w; j++){
// if(c[i][j]=='#')u[i][j] = 0;
// else if (i==0)u[i][j] = 1;
// else u[i][j] = u[i-1][j] + 1;
// }
// }
for (int j = 0; j < w; j++) {
for (int i = 0; i < h; i++) {
if (c[i][j] == '#') {
u[i][j] = 0;
} else {
if (i > 0) {
u[i][j] = u[i - 1][j] + 1;
} else {
u[i][j] = 1;
}
}
}
}
// 上からの探索
// for(int i = h-1; i >= 0; i--){
// for(int j = 0; j < w; j++){
// if(c[i][j]=='#')d[i][j] = 0;
// else if (i==h-1)d[i][j] = 1;
// else d[i][j] = d[i+1][j] + 1;
// }
// }
for (int j = 0; j < w; j++) {
for (int i = h - 1; i >= 0; i--) {
if (c[i][j] == '#') {
d[i][j] = 0;
} else {
if (i < h - 1) {
d[i][j] = d[i + 1][j] + 1;
} else {
d[i][j] = 1;
}
}
}
}
// int ans = 0;
// for(int i=0; i<h;i++){
// for(int j=0; j<w; j++){
// if(c[i][j] == '.'){
// ans = max(ans, u[i][j]+d[i][j]+r[i][j]+l[i][j]-3);
// }
// }
// }
int ans = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if (c[i][j] == '.') {
chmax(ans, l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3);
}
}
}
cout << ans << endl;
} | #include <bits/stdc++.h>
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define per(i, a, n) for (ll i = n - 1; i >= a; i--)
#define fill0(n) setfill('0') << right << setw(n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000
using namespace std;
typedef long long ll;
// typedef pair<ll,ll> p;
int h, w;
int r[2010][2010], l[2010][2010], u[2010][2010], d[2010][2010];
template <typename T> bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
};
int main() {
cin >> h >> w;
vector<string> c(h);
for (int i = 0; i < h; i++)
cin >> c[i];
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if (c[i][j] == '#') {
l[i][j] = 0;
} else {
if (j > 0) {
l[i][j] = l[i][j - 1] + 1;
} else {
l[i][j] = 1;
}
}
}
}
for (int i = 0; i < h; i++) {
for (int j = w - 1; j >= 0; j--) {
if (c[i][j] == '#') {
r[i][j] = 0;
} else {
if (j < w - 1) {
r[i][j] = r[i][j + 1] + 1;
} else {
r[i][j] = 1;
}
}
}
}
for (int j = 0; j < w; j++) {
for (int i = 0; i < h; i++) {
if (c[i][j] == '#') {
u[i][j] = 0;
} else {
if (i > 0) {
u[i][j] = u[i - 1][j] + 1;
} else {
u[i][j] = 1;
}
}
}
}
for (int j = 0; j < w; j++) {
for (int i = h - 1; i >= 0; i--) {
if (c[i][j] == '#') {
d[i][j] = 0;
} else {
if (i < h - 1) {
d[i][j] = d[i + 1][j] + 1;
} else {
d[i][j] = 1;
}
}
}
}
int ans = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if (c[i][j] == '.') {
chmax(ans, l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3);
}
}
}
cout << ans << endl;
} | [
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 828,027 | 828,028 | u255001744 | cpp |
p03014 | #include <iostream>
#include <string>
#include <vector>
using namespace std;
int solve(int h, int w, vector<string> s) {
vector<vector<int>> L(h, vector<int>(w));
for (int i = 0; i < h; ++i) {
int prev = -1;
for (int j = 0; j < w; ++j) {
if (s[i][j] == '#') {
prev = j;
}
L[i][j] = prev;
}
}
vector<vector<int>> R(h, vector<int>(w));
for (int i = 0; i < h; ++i) {
int prev = w;
for (int j = w - 1; j >= 0; --j) {
if (s[i][j] == '#') {
prev = j;
}
R[i][j] = prev;
}
}
vector<vector<int>> T(h, vector<int>(w));
for (int j = 0; j < w; ++j) {
int prev = -1;
for (int i = 0; i < h; ++i) {
if (s[i][j] == '#') {
prev = j;
}
T[i][j] = prev;
}
}
vector<vector<int>> B(h, vector<int>(w));
for (int j = 0; j < w; ++j) {
int prev = h;
for (int i = h - 1; i >= 0; --i) {
if (s[i][j] == '#') {
prev = j;
}
B[i][j] = prev;
}
}
int ans = 0;
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
ans = max(ans, R[i][j] - L[i][j] + B[i][j] - T[i][j] - 3);
}
}
return ans;
}
int main() {
int h, w;
cin >> h >> w;
vector<string> s;
for (int i = 0; i < h; ++i) {
string l;
cin >> l;
s.push_back(l);
}
cout << solve(h, w, s) << endl;
return 0;
} | #include <iostream>
#include <string>
#include <vector>
using namespace std;
int solve(int h, int w, vector<string> s) {
vector<vector<int>> L(h, vector<int>(w));
for (int i = 0; i < h; ++i) {
int prev = -1;
for (int j = 0; j < w; ++j) {
if (s[i][j] == '#') {
prev = j;
}
L[i][j] = prev;
}
}
vector<vector<int>> R(h, vector<int>(w));
for (int i = 0; i < h; ++i) {
int prev = w;
for (int j = w - 1; j >= 0; --j) {
if (s[i][j] == '#') {
prev = j;
}
R[i][j] = prev;
}
}
vector<vector<int>> T(h, vector<int>(w));
for (int j = 0; j < w; ++j) {
int prev = -1;
for (int i = 0; i < h; ++i) {
if (s[i][j] == '#') {
prev = i;
}
T[i][j] = prev;
}
}
vector<vector<int>> B(h, vector<int>(w));
for (int j = 0; j < w; ++j) {
int prev = h;
for (int i = h - 1; i >= 0; --i) {
if (s[i][j] == '#') {
prev = i;
}
B[i][j] = prev;
}
}
int ans = 0;
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
ans = max(ans, R[i][j] - L[i][j] + B[i][j] - T[i][j] - 3);
}
}
return ans;
}
int main() {
int h, w;
cin >> h >> w;
vector<string> s;
for (int i = 0; i < h; ++i) {
string l;
cin >> l;
s.push_back(l);
}
cout << solve(h, w, s) << endl;
return 0;
} | [
"assignment.value.change",
"identifier.change"
] | 828,029 | 828,030 | u879309973 | cpp |
p03014 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll << 50;
template <typename T> void printv(const vector<T> &s) {
for (int i = 0; i < (int)(s.size()); ++i) {
cout << s[i];
if (i == (int)(s.size()) - 1)
cout << endl;
else
cout << " ";
}
}
int main() {
cin.tie(0);
cout << fixed << setprecision(10);
int h, w;
cin >> h >> w;
vector<string> g(h);
for (int i = 0; i < h; ++i) {
cin >> g[i];
}
vector<vector<int>> l(h, vector<int>(w)), r(h, vector<int>(w)),
u(h, vector<int>(w)), d(h, vector<int>(w));
for (int i = 0; i < h; ++i) {
l[i][0] = 0;
for (int j = 1; j < w; ++j) {
if (g[i][j - 1] == '#')
l[i][j] = 0;
else
l[i][j] = l[i][j - 1] + 1;
}
}
for (int i = 0; i < h; ++i) {
r[i][w - 1] = 0;
for (int j = w - 2; j >= 0; --j) {
if (g[i][j + 1] == '#')
r[i][j] = 0;
else
r[i][j] = r[i][j + 1] + 1;
}
}
for (int i = 0; i < w; ++i) {
u[0][i] = 0;
for (int j = 1; j < h; ++j) {
if (g[j - 1][i] == '#')
u[j][i] = 0;
else
u[j][i] = u[j - 1][i] + 1;
}
}
for (int i = 0; i < w; ++i) {
d[h - 1][i] = 0;
for (int j = h - 2; j >= 0; --j) {
if (g[j + 1][i] == '#')
d[j][i] = 0;
else
d[j][i] = d[j + 1][i] + 1;
}
}
int ans = 0;
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
if (g[i][j] == '.')
ans = max(ans, l[i][j] + r[i][j] + u[i][j] + d[i][j]);
}
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll << 50;
template <typename T> void printv(const vector<T> &s) {
for (int i = 0; i < (int)(s.size()); ++i) {
cout << s[i];
if (i == (int)(s.size()) - 1)
cout << endl;
else
cout << " ";
}
}
int main() {
cin.tie(0);
cout << fixed << setprecision(10);
int h, w;
cin >> h >> w;
vector<string> g(h);
for (int i = 0; i < h; ++i) {
cin >> g[i];
}
vector<vector<int>> l(h, vector<int>(w)), r(h, vector<int>(w)),
u(h, vector<int>(w)), d(h, vector<int>(w));
for (int i = 0; i < h; ++i) {
l[i][0] = 0;
for (int j = 1; j < w; ++j) {
if (g[i][j - 1] == '#')
l[i][j] = 0;
else
l[i][j] = l[i][j - 1] + 1;
}
}
for (int i = 0; i < h; ++i) {
r[i][w - 1] = 0;
for (int j = w - 2; j >= 0; --j) {
if (g[i][j + 1] == '#')
r[i][j] = 0;
else
r[i][j] = r[i][j + 1] + 1;
}
}
for (int i = 0; i < w; ++i) {
u[0][i] = 0;
for (int j = 1; j < h; ++j) {
if (g[j - 1][i] == '#')
u[j][i] = 0;
else
u[j][i] = u[j - 1][i] + 1;
}
}
for (int i = 0; i < w; ++i) {
d[h - 1][i] = 0;
for (int j = h - 2; j >= 0; --j) {
if (g[j + 1][i] == '#')
d[j][i] = 0;
else
d[j][i] = d[j + 1][i] + 1;
}
}
int ans = 0;
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
if (g[i][j] == '.')
ans = max(ans, l[i][j] + r[i][j] + u[i][j] + d[i][j]);
}
}
cout << ans + 1 << endl;
}
| [
"expression.operation.binary.add"
] | 828,031 | 828,032 | u334351654 | cpp |
p03014 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 2e3 + 10;
char s[maxn][maxn];
int dp1[maxn][maxn], dp2[maxn][maxn], dp3[maxn][maxn], dp4[maxn][maxn];
int main() {
int n, m;
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; i++) {
scanf("%s", &s[i]);
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (s[i][j] == '.')
dp1[i][j] = dp1[i - 1][j] + 1, dp2[i][j] = dp2[i][j - 1] + 1;
}
}
for (int i = n; i >= 0; i--) {
for (int j = m; j >= 0; j--) {
if (s[i][j] == '.')
dp3[i][j] = dp3[i + 1][j] + 1, dp4[i][j] = dp4[i][j + 1] + 1;
}
}
int ans = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (s[i][j] == '.')
ans = max(ans, dp1[i][j] + dp2[i][j] + dp3[i][j] + dp4[i][j] - 3);
}
}
cout << ans << endl;
}
/*
4 6
#..#..
.....#
....#.
#.#...
*/ | #include <bits/stdc++.h>
using namespace std;
const int maxn = 2e3 + 10;
char s[maxn][maxn];
int dp1[maxn][maxn], dp2[maxn][maxn], dp3[maxn][maxn], dp4[maxn][maxn];
int main() {
int n, m;
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; i++) {
scanf("%s", s[i] + 1);
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (s[i][j] == '.')
dp1[i][j] = dp1[i - 1][j] + 1, dp2[i][j] = dp2[i][j - 1] + 1;
}
}
for (int i = n; i >= 1; i--) {
for (int j = m; j >= 1; j--) {
if (s[i][j] == '.')
dp3[i][j] = dp3[i + 1][j] + 1, dp4[i][j] = dp4[i][j + 1] + 1;
}
}
int ans = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (s[i][j] == '.')
ans = max(ans, dp1[i][j] + dp2[i][j] + dp3[i][j] + dp4[i][j] - 3);
}
}
cout << ans << endl;
}
/*
4 6
#..#..
.....#
....#.
#.#...
*/ | [
"call.arguments.change",
"literal.number.change",
"control_flow.loop.for.condition.change",
"expression.off_by_one",
"expression.operation.binary.change"
] | 828,049 | 828,050 | u573035837 | cpp |
p03014 | #include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
const int MOD = 1e9 + 7;
#ifndef HOME
#define cerr \
if (0) \
cerr
#endif
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, m;
cin >> n >> m;
int a[n][m];
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
char x;
cin >> x;
if (x == '.')
a[i][j] = 1;
if (x == '#')
a[i][j] = 0;
}
}
int u[n][m], d[n][m], r[n][m], l[n][m];
// Left
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (!a[i][j]) {
l[i][j] = 0;
} else {
if (j == 0) {
l[i][j] = 1;
} else {
l[i][j] = 1 + l[i][j - 1];
}
}
}
}
// Right
for (int i = 0; i < n; i++) {
for (int j = m - 1; j >= 0; j--) {
if (!a[i][j]) {
r[i][j] = 0;
} else {
if (j == m - 1) {
r[i][j] = 1;
} else {
r[i][j] = 1 + r[i][j + 1];
}
}
}
}
// Up
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
if (!a[j][i]) {
u[j][i] = 0;
} else {
if (j == 0) {
u[j][i] = 1;
} else {
u[j][i] = 1 + u[j - 1][i];
}
}
}
}
// Down
for (int i = 0; i < m; i++) {
for (int j = n - 1; j >= 0; j--) {
if (!a[j][i]) {
d[j][i] = 0;
} else {
if (j == n - 1) {
d[j][i] = 1;
} else {
d[j][i] = 1 + d[j + 1][i];
}
}
}
}
int ans = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (a[i][j]) {
ans = max(u[i][j] + d[i][j] + r[i][j] + l[i][j] - 3, ans);
}
}
}
cout << ans << endl;
// for(int i=0;i<n;i++){
// for(int j=0;j<m;j++){
// //cerr<<i<<" "<<j<<endl;
// cout<<d[i][j]<<" ";
// }
// cout<<endl;
// }
// for(int i=0;i<m;i++){
// for(int j=0;j<n;j++){
// cerr<<i<<" "<<j<<endl;
// cout<<a[j][i]<<" ";
// }
// cout<<endl;
// }
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
const int MOD = 1e9 + 7;
#ifndef HOME
#define cerr \
if (0) \
cerr
#endif
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, m;
cin >> n >> m;
int a[n][m];
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
char x;
cin >> x;
if (x == '.')
a[i][j] = 1;
if (x == '#')
a[i][j] = 0;
}
}
int u[n][m], d[n][m], r[n][m], l[n][m];
// Left
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (!a[i][j]) {
l[i][j] = 0;
} else {
if (j == 0) {
l[i][j] = 1;
} else {
l[i][j] = 1 + l[i][j - 1];
}
}
}
}
// Right
for (int i = 0; i < n; i++) {
for (int j = m - 1; j >= 0; j--) {
if (!a[i][j]) {
r[i][j] = 0;
} else {
if (j == m - 1) {
r[i][j] = 1;
} else {
r[i][j] = 1 + r[i][j + 1];
}
}
}
}
// Up
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
if (!a[j][i]) {
u[j][i] = 0;
} else {
if (j == 0) {
u[j][i] = 1;
} else {
u[j][i] = 1 + u[j - 1][i];
}
}
}
}
// Down
for (int i = 0; i < m; i++) {
for (int j = n - 1; j >= 0; j--) {
if (!a[j][i]) {
d[j][i] = 0;
} else {
if (j == n - 1) {
d[j][i] = 1;
} else {
d[j][i] = 1 + d[j + 1][i];
}
}
}
}
int ans = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (a[i][j]) {
ans = max(u[i][j] + d[i][j] + r[i][j] + l[i][j] - 3, ans);
}
}
}
cout << ans << endl;
// for(int i=0;i<n;i++){
// for(int j=0;j<m;j++){
// //cerr<<i<<" "<<j<<endl;
// cout<<d[i][j]<<" ";
// }
// cout<<endl;
// }
// for(int i=0;i<m;i++){
// for(int j=0;j<n;j++){
// cerr<<i<<" "<<j<<endl;
// cout<<a[j][i]<<" ";
// }
// cout<<endl;
// }
return 0;
}
| [
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 828,052 | 828,053 | u124992729 | cpp |
p03014 | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define REP(i, a, n) for (int i = a; i < n; ++i)
#define REPR(i, a, n) for (int i = a; i > n; --i)
#define RUP(a, b) ((a + b - 1) / (b))
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX
typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;
template <class T> bool chmax(T a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
template <class T> void YesNo(T a) { cout << (a ? "Yes" : "No") << endl; }
template <class T> void YESNO(T a) { cout << (a ? "YES" : "NO") << endl; }
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
void start() {
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(false);
}
signed main() {
start();
int h, w, ans = 0;
cin >> h >> w;
Vs s(h);
VVi yoko(h, Vi(w)), tate(h, Vi(w));
REP(i, 0, h) cin >> s[i];
REP(i, 0, h) {
REP(j, 0, w) {
if (j > 0) {
if (s[i][j] == '.' && yoko[i][j - 1] > 0) {
yoko[i][j] = yoko[i][j - 1];
continue;
}
}
int tj = j, t = 0;
while (s[i][tj] == '.' && tj < w) {
t++;
tj++;
}
yoko[i][j] = t;
}
}
REP(i, 0, w) {
REP(j, 0, h) {
if (j > 0) {
if (s[j][i] == '.' && tate[j - 1][i] > 0) {
tate[j][i] = tate[j - 1][i];
continue;
}
}
int tj = j, t = 0;
while (s[tj][i] == '.') {
t++;
tj++;
if (tj == h)
break;
}
tate[j][i] = t;
}
}
REP(i, 0, h) {
REP(j, 0, w) { chmax(ans, yoko[i][j] + tate[i][j] - 1); }
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define REP(i, a, n) for (int i = a; i < n; ++i)
#define REPR(i, a, n) for (int i = a; i > n; --i)
#define RUP(a, b) ((a + b - 1) / (b))
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX
typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
template <class T> void YesNo(T a) { cout << (a ? "Yes" : "No") << endl; }
template <class T> void YESNO(T a) { cout << (a ? "YES" : "NO") << endl; }
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
void start() {
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(false);
}
signed main() {
start();
int h, w, ans = 0;
cin >> h >> w;
Vs s(h);
VVi yoko(h, Vi(w)), tate(h, Vi(w));
REP(i, 0, h) cin >> s[i];
REP(i, 0, h) {
REP(j, 0, w) {
if (j > 0) {
if (s[i][j] == '.' && yoko[i][j - 1] > 0) {
yoko[i][j] = yoko[i][j - 1];
continue;
}
}
int tj = j, t = 0;
while (s[i][tj] == '.' && tj < w) {
t++;
tj++;
}
yoko[i][j] = t;
}
}
REP(i, 0, w) {
REP(j, 0, h) {
if (j > 0) {
if (s[j][i] == '.' && tate[j - 1][i] > 0) {
tate[j][i] = tate[j - 1][i];
continue;
}
}
int tj = j, t = 0;
while (s[tj][i] == '.') {
t++;
tj++;
if (tj == h)
break;
}
tate[j][i] = t;
}
}
REP(i, 0, h) {
REP(j, 0, w) { chmax(ans, yoko[i][j] + tate[i][j] - 1); }
}
cout << ans << endl;
}
| [] | 828,054 | 828,055 | u635484372 | cpp |
p03014 | #include <bits/stdc++.h>
using namespace std;
int main() {
int H, W, i, j;
scanf("%d%d", &H, &W);
vector<string> S(H + 2, string(W + 2, '#'));
for (i = 1; i <= H; i++) {
string sub;
cin >> sub;
for (j = 1; j <= W; j++) {
S[i][j] = sub[j - 1];
}
}
vector<vector<int>> L(H + 2, vector<int>(W + 2, 0));
vector<vector<int>> R(H + 2, vector<int>(W + 2, 0));
vector<vector<int>> U(H + 2, vector<int>(W + 2, 0));
vector<vector<int>> D(H + 2, vector<int>(W + 2, 0));
for (i = 1; i <= H; i++) {
for (j = 1; j <= W; j++) {
if (S[i][j] == '.') {
L[i][j] = L[i][j - 1] + 1;
U[i][j] = U[i - 1][j] + 1;
}
}
}
for (i = H; i > 0; i--) {
for (j = W; j > 0; j--) {
if (S[i][j] == '.') {
R[i][j] = R[i][j + 1] + 1;
D[i][j] = D[i + 1][j] + 1;
}
}
}
int ans = 0;
for (i = 1; i <= H; i++) {
for (j = 1; j <= W; j++) {
if (S[i][j] == '.') {
ans = max(ans, L[i][j - 1] + R[i][j + 1] + U[i - 1][j] + D[i + 1][j]);
}
}
printf("%d\n", ans);
return 0;
}
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int H, W, i, j;
scanf("%d%d", &H, &W);
vector<string> S(H + 2, string(W + 2, '#'));
for (i = 1; i <= H; i++) {
string sub;
cin >> sub;
for (j = 1; j <= W; j++) {
S[i][j] = sub[j - 1];
}
}
vector<vector<int>> L(H + 2, vector<int>(W + 2, 0));
vector<vector<int>> R(H + 2, vector<int>(W + 2, 0));
vector<vector<int>> U(H + 2, vector<int>(W + 2, 0));
vector<vector<int>> D(H + 2, vector<int>(W + 2, 0));
for (i = 1; i <= H; i++) {
for (j = 1; j <= W; j++) {
if (S[i][j] == '.') {
L[i][j] = L[i][j - 1] + 1;
U[i][j] = U[i - 1][j] + 1;
}
}
}
for (i = H; i > 0; i--) {
for (j = W; j > 0; j--) {
if (S[i][j] == '.') {
R[i][j] = R[i][j + 1] + 1;
D[i][j] = D[i + 1][j] + 1;
}
}
}
/* printf("L:\n");
for(i = 0; i <= H + 1; i++){
for(j = 0; j <= W + 1; j++){
printf("%d ", L[i][j]);
}
printf("\n");
}
printf("R:\n");
for(i = 0; i <= H + 1; i++){
for(j = 0; j <= W + 1; j++){
printf("%d ", R[i][j]);
}
printf("\n");
}
printf("U:\n");
for(i = 0; i <= H + 1; i++){
for(j = 0; j <= W + 1; j++){
printf("%d ", U[i][j]);
}
printf("\n");
}
printf("D:\n");
for(i = 0; i <= H + 1; i++){
for(j = 0; j <= W + 1; j++){
printf("%d ", D[i][j]);
}
printf("\n");
}
*/
int ans = 0;
for (i = 1; i <= H; i++) {
for (j = 1; j <= W; j++) {
// printf("(i, j) = (%d, %d)\n", i, j);
if (S[i][j] == '.') {
// printf("(%d, %d, %d, %d)\n", L[i][j - 1],
//R[i][j + 1], U[i - 1][j], D[i + 1][j]);
ans =
max(ans, L[i][j - 1] + R[i][j + 1] + U[i - 1][j] + D[i + 1][j] + 1);
}
}
}
printf("%d\n", ans);
return 0;
} | [
"assignment.change"
] | 828,056 | 828,057 | u208608367 | cpp |
p03014 | #include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<ULL> VULL;
typedef vector<VLL> VVLL;
class MYCP {
public:
static const LL MOD_CONST = (LL)1000 * 1000 * 1000 + 7;
static LL DebugFlag;
//数値を区切って文字列にする
static string MakeString_LongLong(vector<long long> const &numbers,
string const &str) {
if (numbers.size() == 0)
return "";
string result = "" + to_string(numbers[0]);
for (long long i = 1; i < numbers.size(); i++) {
result += str;
result += to_string(numbers[i]);
}
return result;
}
//空白で区切る為のオーバーロード
static string MakeString_LongLong(vector<long long> const &numbers) {
if (numbers.size() == 0)
return "";
string result = "" + to_string(numbers[0]);
for (long long i = 1; i < numbers.size(); i++) {
result += " ";
result += to_string(numbers[i]);
}
return result;
}
//文字列の配列を改行を挟んでまとめる
static string MakeString_VectorString(vector<string> const &str) {
string result = "";
for (long long i = 0; i < str.size(); i++) {
result += str[i] + "\n";
}
return result;
}
//文字列を必要な個数だけ読み取る
static vector<string> MyReadLineSplit(LL n) {
vector<string> str(n);
for (long long i = 0; i < n; i++) {
std::cin >> str[i];
}
return str;
}
//数値を必要な個数だけ読み取る
static vector<long long> ReadInts(long long number) {
vector<long long> a(number);
for (int i = 0; i < number; i++) {
std::cin >> a[i];
}
return a;
}
//渡された自然数が素数ならtureを返す
static bool PrimeCheck_Int(long long number) {
if (number < 2)
return false;
for (ULL i = 2; i * i <= number; i++) {
if (number % i == 0)
return false;
}
return true;
}
//渡された数値以下の素数表を作る
static vector<long long> MakePrimeList(long long n) {
vector<long long> list;
LL i, j, p;
bool flag;
for (i = 2; i <= n; i++) {
flag = true;
for (j = 0; j < list.size(); j++) {
if (!(list[j] * list[j] <= i))
break;
if (i % list[j] == 0) {
flag = false;
break;
}
}
if (flag)
list.push_back(i);
}
return list;
}
//文字列の分割
static vector<string> split(string const &str, char sep) {
vector<std::string> v; // 分割結果を格納するベクター
auto first = str.begin(); // テキストの最初を指すイテレータ
while (first != str.end()) { // テキストが残っている間ループ
auto last = first; // 分割文字列末尾へのイテレータ
while (last != str.end() &&
*last != sep) // 末尾 or セパレータ文字まで進める
last++;
v.push_back(string(first, last)); // 分割文字を出力
if (last != str.end())
last++;
first = last; // 次の処理のためにイテレータを設定
}
return v;
}
//合計を求める
template <typename T> static LL Sum(T const &a) {
LL sum = 0;
auto itr = a.begin();
while (itr != a.end()) {
sum += (*itr);
itr++;
}
return sum;
}
//小文字ならtrueを返す
static bool Komoji(char a) {
if (a >= 'a' && a <= 'z')
return true;
return false;
}
//大文字ならtrueを返す
static bool Oomoji(char a) {
if (a >= 'A' && a <= 'Z')
return true;
return false;
}
//切り上げの整数値割り算
static LL KiriageWarizan(LL a, LL b) {
LL result = a / b;
if (a % b > 0)
result++;
return result;
}
//最大公約数を求める
static LL GreatestCommonFactor(LL a, LL b) {
a = abs(a);
b = abs(b);
LL temp;
if (a < b) {
temp = b;
b = a;
a = temp;
}
while (b > 0) {
temp = a % b;
a = b;
b = temp;
}
return a;
}
//最小公倍数を求める
static LL LeastCommonMultiple(LL a, LL b) {
return (a / GreatestCommonFactor(a, b)) * b;
}
//二次元配列を行列とみなして転置する
static VVLL VVLLturn(VVLL a) {
if (a.size() == 0)
return VVLL(0);
VVLL result(a[0].size(), VLL(a.size()));
LL i, j;
for (i = 0; i < a.size(); i++) {
for (j = 0; j < a[0].size(); j++) {
result[j][i] = a[i][j];
}
}
return result;
}
//素因数分解、素数、指数の順
static vector<VLL> PrimeFactorization(LL n) {
VLL p_list, s_list;
LL i, j, k, count;
for (i = 2; n > 1; i++) {
if (i * i > n) {
p_list.push_back(n);
s_list.push_back(1);
break;
}
if (n % i == 0) {
count = 0;
while (n % i == 0) {
n /= i;
count++;
}
p_list.push_back(i);
s_list.push_back(count);
}
}
vector<VLL> result;
result.push_back(p_list);
result.push_back(s_list);
return MYCP::VVLLturn(result);
}
//整数nの約数の配列を作る
static VLL MakeYakusuList(LL n) {
auto primes = MYCP::PrimeFactorization(n);
VLL ans;
VLL roop(primes.size(), 0);
LL i, j, k, m, size = roop.size();
while (true) {
LL a = 1;
for (i = 0; i < size; i++) {
for (j = 0; j < roop[i]; j++) {
a *= primes[i][0];
}
}
ans.push_back(a);
roop[0]++;
for (i = 0; i < size; i++) {
if (i + 1 < size) {
roop[i + 1] += (roop[i] / (primes[i][1] + 1));
}
roop[i] %= (primes[i][1] + 1);
}
bool flag = true;
for (i = 0; i < size; i++) {
if (roop[i] != 0)
flag = false;
}
if (flag)
break;
}
return MYCP::Sort(ans);
}
//組み合わせ nCr
static LL Combination(LL n, LL r) {
r = min(r, n - r);
VLL p(n + 1, 0);
LL i, j, k, a, b, c;
for (i = 1; i <= r; i++) {
auto temp = MYCP::PrimeFactorization(i);
temp = MYCP::VVLLturn(temp);
if (temp.size() == 0) {
temp = VVLL(2, VLL(0));
}
for (j = 0; j < temp[0].size(); j++) {
p[temp[0][j]] -= temp[1][j];
}
a = i + n - r;
temp = MYCP::PrimeFactorization(a);
temp = MYCP::VVLLturn(temp);
if (temp.size() == 0) {
temp = VVLL(2, VLL(0));
}
for (j = 0; j < temp[0].size(); j++) {
p[temp[0][j]] += temp[1][j];
}
}
LL result = 1;
for (i = 0; i < p.size(); i++) {
if (p[i] > 0) {
for (j = 0; j < p[i]; j++) {
result *= i;
result %= MYCP::MOD_CONST;
}
}
}
return result;
}
//符号
static LL sign(LL const x) {
if (x > 0)
return 1;
if (x < 0)
return -1;
return 0;
}
//円周率
static double PI() { return (double)3.1415926535898; }
//指定した桁でdoubleを出す。改行はしない。
static void CoutDoubleKeta(double a, LL keta) {
cout << setprecision(keta) << a << flush;
}
//コンテナクラスの出力
template <typename T> static T CoutVector(T const &ls) {
LL i, j, k, size = distance(ls.begin(), ls.end());
auto itr = ls.begin();
for (i = 0; i < size - 1; i++) {
cout << *itr << " " << flush;
itr++;
}
cout << *itr << flush;
return ls;
}
//コンテナクラスをソートする
template <typename T> static T Sort(T &ls) {
sort(ls.begin(), ls.end());
return ls;
}
//順序関数付きでコンテナクラスをソートする
template <typename T, typename F> static T Sort(T &ls, F func) {
sort(ls.begin(), ls.end(), func);
return ls;
}
//コンテナクラスを逆順に並び替える
template <typename T> static T Reverse(T &ls) {
reverse(ls.begin(), ls.end());
return ls;
}
//コンテナクラスの条件を満たす要素を数え上げる。bool func(S x)
template <typename T, typename S> static LL Count(T const &ls, S func) {
LL ans = 0;
auto itr = ls.begin();
while (itr != ls.end()) {
if (func(*itr))
ans++;
itr++;
}
return ans;
}
//コンテナクラスの要素をすべて更新する。S func(S x)
template <typename T, typename S> static T AllUpdate(T &ls, S func) {
auto itr = ls.begin();
while (itr != ls.end()) {
*itr = func(*itr);
itr++;
}
return ls;
}
//リストをベクターに変換する
template <typename T> static vector<T> FromListToVector(list<T> a) {
vector<T> ans;
for (auto itr = a.begin(); itr != a.end(); itr++) {
ans.push_back(*itr);
}
return ans;
}
//ベクターをリストに変換する
template <typename T> static list<T> FromVectorToList(vector<T> a) {
list<T> ans;
for (auto itr = a.begin(); itr != a.end(); itr++) {
ans.push_back(*itr);
}
return ans;
}
//デバッグ用出力
template <typename T> static LL DebugPrintf(T output) {
if (MYCP::DebugFlag) {
std::cout << output << endl;
}
return MYCP::DebugFlag;
}
//デバッグ用入力
static LL DebugCin() {
LL a;
if (MYCP::DebugFlag) {
cin >> a;
}
return a;
}
};
LL MYCP::DebugFlag = 0;
//累積和を求めるクラス
class Ruisekiwa {
private:
vector<LL> list;
public:
void MakeArray(vector<LL> data) {
LL i;
list = data;
list.push_back(0);
list[0] = 0;
for (i = 1; i < list.size(); i++) {
list[i] = list[i - 1] + data[i - 1];
}
}
LL Sum(LL start, LL end) {
if (end < start) {
std::cout << "startがendより大きいです";
return 0;
}
if (start < 0 || end >= list.size()) {
std::cout << "範囲が異常";
return 0;
}
return list[end] - list[start];
}
};
// n進数を管理するクラス
class N_Number {
public:
N_Number(LL n, LL keta) {
this->N_Shinsuu = n;
VLL temp(keta, 0);
this->numbers = temp;
}
//数を足す
void plus(LL a) {
if (a < 0) {
a *= (-1);
this->minus(a);
return;
}
this->numbers[0] += a;
LL size = this->numbers.size();
for (LL i = 0; i < size; i++) {
if (i + 1 < size) {
this->numbers[i + 1] += this->numbers[i] / this->N_Shinsuu;
}
this->numbers[i] %= this->N_Shinsuu;
}
}
//全ての桁が同じ数字になっていればその数字を返す。それ以外の場合は -1 を返す
LL check() {
LL a = this->numbers[0];
for (LL i = 0; i < this->numbers.size(); i++) {
if (this->numbers[i] != a)
return -1;
}
return a;
}
LL getNumber(LL keta) { return this->numbers[keta]; }
LL getKeta() { return this->numbers.size(); }
LL getShinsuu() { return this->N_Shinsuu; }
void setNumber(LL keta, LL number) {
if (0 <= number && number < this->getShinsuu()) {
if (0 <= keta && keta < this->getKeta()) {
this->numbers[keta] = number;
return;
}
}
cout << "er" << endl;
}
void setAllNumbers(LL number) {
LL size = this->getKeta(), i;
for (i = 0; i < size; i++) {
this->setNumber(i, number);
}
}
string to_string_KetaSoroe() {
string s = "";
for (LL i = this->getKeta() - 1; i >= 0; i--) {
s += to_string(this->getNumber(i));
}
return s;
}
private:
void minus(LL a) {
LL i, j, k, zettaiti = abs(a);
k = MYCP::KiriageWarizan(zettaiti, this->N_Shinsuu);
j = k * (this->N_Shinsuu - 1);
for (i = 0; i < this->getKeta(); i++) {
this->numbers[i] += j;
}
this->numbers[0] += k - a;
this->plus(0);
}
VLL numbers;
LL N_Shinsuu;
};
// UnionFind
class Union_Find {
private:
VLL tree;
VLL count;
LL root(LL a) {
if (this->tree[a] == a)
return a;
return this->tree[a] = this->root(this->tree[a]);
}
public:
Union_Find(LL n) {
VLL set(n);
this->tree = set;
this->count = set;
for (LL i = 0; i < n; i++) {
this->tree[i] = i;
this->count[i] = 1;
}
}
void unite(LL a, LL b) {
LL x, y;
if (!this->Check(a, b)) {
x = this->getCount(a) + getCount(b);
y = this->root(a);
this->count[y] = x;
y = this->root(b);
this->count[y] = x;
}
x = this->root(a);
y = this->root(b);
this->tree[x] = y;
}
bool Check(LL a, LL b) { return this->root(a) == this->root(b); }
LL getCount(LL index) {
LL temp = this->root(index);
return this->count[temp];
}
VLL getList() {
VLL ans(this->tree.size(), 0);
for (LL i = 0; i < ans.size(); i++) {
ans[i] = this->root(i);
}
return ans;
}
};
//プラスマイナス無限に対応したlong long型
class INF_LONG_LONG {
private:
LL inf, n;
public:
//コンストラクタ
INF_LONG_LONG(LL a) {
this->n = a;
this->inf = 0;
this->Syusei();
}
INF_LONG_LONG() { *this = INF_LONG_LONG(0); }
INF_LONG_LONG(INF_LONG_LONG const &a) {
this->n = a.n;
this->inf = a.inf;
this->Syusei();
}
//ゲッター
LL getN() const { return this->n; }
LL getInf() const { return this->inf; }
//正の無限大生成
static INF_LONG_LONG plus_inf() {
INF_LONG_LONG a;
a.n = 0;
a.inf = 1;
a.Syusei();
return a;
}
//負の無限大生成
static INF_LONG_LONG minus_inf() {
INF_LONG_LONG a;
a.n = 0;
a.inf = -1;
a.Syusei();
return a;
}
//符号を取得
LL sign() const {
if (this->inf != 0) {
return this->inf;
}
return MYCP::sign(this->n);
}
//代入演算子
INF_LONG_LONG operator=(INF_LONG_LONG const &b) {
this->n = b.n;
this->inf = b.inf;
this->Syusei();
return *this;
}
INF_LONG_LONG operator=(LL const &b) {
*this = INF_LONG_LONG(b);
this->Syusei();
return *this;
}
//比較演算子
bool operator==(INF_LONG_LONG const &b) const {
if (this->n == b.n && this->inf == b.inf)
return true;
return false;
}
bool operator!=(INF_LONG_LONG const &b) const { return !(*this == b); }
bool operator<(INF_LONG_LONG const &b) const {
if (this->inf < b.inf)
return true;
if (this->inf > b.inf)
return false;
return this->n < b.n;
}
bool operator>(INF_LONG_LONG const &b) const { return b < *this; }
bool operator<=(INF_LONG_LONG const &b) const { return !(*this > b); }
bool operator>=(INF_LONG_LONG const &b) const { return !(*this < b); }
//算術演算子
INF_LONG_LONG operator+(INF_LONG_LONG const &b) const {
if (max(this->inf, b.inf) > 0)
return INF_LONG_LONG::plus_inf();
if (min(this->inf, b.inf) < 0)
return INF_LONG_LONG::minus_inf();
auto ans = *this;
ans.n += b.n;
ans.Syusei();
return ans;
}
INF_LONG_LONG operator*(INF_LONG_LONG const &b) const {
if (*this == INF_LONG_LONG(0) || b == INF_LONG_LONG(0)) {
return INF_LONG_LONG(0);
}
if (this->inf != 0 || b.inf != 0) {
LL s = this->sign() * b.sign();
INF_LONG_LONG ans(0);
ans.n = 0;
ans.inf = s;
ans.Syusei();
return ans;
}
INF_LONG_LONG ans(0);
ans.n = this->n * b.n;
ans.Syusei();
return ans;
}
INF_LONG_LONG operator-(INF_LONG_LONG const &b) const {
auto ans = (*this + (INF_LONG_LONG(-1) * b));
ans.Syusei();
return ans;
}
INF_LONG_LONG operator/(INF_LONG_LONG const &b) const {
if (b == INF_LONG_LONG(0)) {
LL a = this->n / b.n;
return INF_LONG_LONG(a);
}
if (b.inf != 0) {
return INF_LONG_LONG(0);
}
if (*this == INF_LONG_LONG(0)) {
return INF_LONG_LONG(0);
}
if (this->inf != 0) {
LL s = this->sign() * b.sign();
return INF_LONG_LONG::plus_inf() * INF_LONG_LONG(s);
}
INF_LONG_LONG ans;
ans.n = this->n / b.n;
ans.Syusei();
return ans;
}
INF_LONG_LONG operator%(INF_LONG_LONG const &b) const {
if (this->inf == 0 && b.inf == 0) {
INF_LONG_LONG ans;
ans.n = this->n % b.n;
ans.Syusei();
return ans;
}
auto x = *this / b;
x.Syusei();
auto ans = *this - b * x;
ans.Syusei();
return ans;
}
//複合代入演算子
INF_LONG_LONG operator+=(INF_LONG_LONG const &b) {
auto ans = *this + b;
*this = ans;
return *this;
}
INF_LONG_LONG operator-=(INF_LONG_LONG const &b) {
auto ans = *this - b;
*this = ans;
return *this;
}
INF_LONG_LONG operator*=(INF_LONG_LONG const &b) {
auto ans = *this * b;
*this = ans;
return *this;
}
INF_LONG_LONG operator/=(INF_LONG_LONG const &b) {
auto ans = *this / b;
*this = ans;
return *this;
}
INF_LONG_LONG operator%=(INF_LONG_LONG const &b) {
auto ans = *this % b;
*this = ans;
return *this;
}
//符号演算子
INF_LONG_LONG operator+() const { return *this; }
INF_LONG_LONG operator-() const { return *this * INF_LONG_LONG(-1); }
//前置きインクリメント・デクリメント
INF_LONG_LONG operator++() {
this->n++;
this->Syusei();
return *this;
}
INF_LONG_LONG operator--() {
this->n--;
this->Syusei();
return *this;
}
//後置きインクリメント・デクリメント
INF_LONG_LONG operator++(int) {
auto copy = *this;
++(*this);
return copy;
}
INF_LONG_LONG operator--(int) {
auto copy = *this;
--(*this);
return copy;
}
//文字列への変換
string ToString() const {
if (this->inf == 1) {
return "+INF";
}
if (this->inf == -1) {
return "-INF";
}
return to_string(this->n);
}
private:
void Syusei() {
if (this->inf != 0) {
this->n = 0;
}
}
};
typedef INF_LONG_LONG ILL_TYPE;
typedef vector<ILL_TYPE> VILL_TYPE;
typedef vector<VILL_TYPE> VVILL_TYPE;
//ワーシャルフロイド
class WarshallFloyd {
public:
//最短距離を記録
VVILL_TYPE d;
//頂点数
LL v;
// vは頂点数、edge_cost_listは辺の情報{始点、終点、コスト}の配列。無向グラフの場合、逆矢印の辺に注意。
WarshallFloyd(LL v, VVLL edge_cost_list) {
this->v = v;
this->d = VVILL_TYPE(v, VILL_TYPE(v, ILL_TYPE::plus_inf()));
LL i, j, k, a, b, c;
for (i = 0; i < edge_cost_list.size(); i++) {
a = edge_cost_list[i][0];
b = edge_cost_list[i][1];
c = edge_cost_list[i][2];
this->d[a][b] = ILL_TYPE(c);
}
for (i = 0; i < v; i++) {
this->d[i][i] = ILL_TYPE(0);
}
//ここから計算
for (k = 0; k < v; k++) {
for (i = 0; i < v; i++) {
for (j = 0; j < v; j++) {
d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}
}
}
}
};
//ベルマンフォード
class BellmanFord {
public:
//辺のリスト
VVILL_TYPE edge;
//頂点数、辺数
LL v, e;
//始点
LL s;
//最短距離
VILL_TYPE d;
// vは頂点数、startは始点、edge_cost_listは辺の情報{始点、終点、コスト}の配列。
BellmanFord(LL v, LL start, VVLL edge_cost_list) {
this->v = v;
this->s = start;
this->e = edge_cost_list.size();
this->d = VILL_TYPE(v, ILL_TYPE::plus_inf());
this->d[start] = 0;
LL i, j, k;
for (i = 0; i < this->e; i++) {
VILL_TYPE temp;
LL a, b, c;
a = edge_cost_list[i][0];
b = edge_cost_list[i][1];
c = edge_cost_list[i][2];
temp.push_back(ILL_TYPE(a));
temp.push_back(ILL_TYPE(b));
temp.push_back(ILL_TYPE(c));
this->edge.push_back(temp);
}
this->DoUpdata();
auto cpy = this->d;
this->DoUpdata();
for (i = 0; i < this->d.size(); i++) {
if (this->d[i] != cpy[i]) {
this->d[i] = ILL_TYPE::minus_inf();
}
}
this->DoUpdata();
}
private:
void DoUpdata() {
LL i, j, k;
for (i = 0; i <= this->v; i++) {
bool update = true;
for (j = 0; j < this->e; j++) {
ILL_TYPE c;
LL a, b;
a = this->edge[j][0].getN();
b = this->edge[j][1].getN();
c = this->edge[j][2];
if (this->d[a] < ILL_TYPE::plus_inf()) {
if (this->d[a] + c < this->d[b]) {
update = false;
this->d[b] = this->d[a] + c;
}
}
}
if (update)
break;
}
}
};
//ダイクストラ
class Dijkstra {
public:
Dijkstra(LL v, LL start, VVLL edge_cost_list) {}
};
//ライブラリはここまで
//ここから下を書く
//ここからメイン
int main(void) {
MYCP::DebugFlag = 0;
LL i, j, k, n, m;
char ten = '.', shape = '#';
LL h, w;
cin >> h >> w;
VVLL s(h, VLL(w, 0));
VVLL ans1, ans2;
ans1 = ans2 = s;
for (i = 0; i < h; i++) {
string temp;
cin >> temp;
for (j = 0; j < w; j++) {
if (temp[j] == '#') {
s[i][j] = 1;
}
}
}
VLL ls;
LL count = 0;
for (i = 0; i < h; i++) {
count = 0;
for (j = 0; j < w; j++) {
if (s[i][j] == 0) {
count++;
ans1[i][j] = ls.size();
} else {
ls.push_back(count);
count = 0;
}
}
ls.push_back(count);
}
for (j = 0; j < w; j++) {
count = 0;
for (i = 0; i < h; i++) {
if (s[i][j] == 0) {
count++;
ans2[i][j] = ls.size();
} else {
ls.push_back(count);
count = 0;
}
}
ls.push_back(count);
}
LL mx = -1;
for (i = 0; i < h; i++) {
for (j = 0; j < w; j++) {
LL a, b;
a = ls[ans1[i][j]];
b = ls[ans2[i][j]];
mx = max(mx, a + b);
}
}
cout << mx << endl;
return 0;
}
| #include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<ULL> VULL;
typedef vector<VLL> VVLL;
class MYCP {
public:
static const LL MOD_CONST = (LL)1000 * 1000 * 1000 + 7;
static LL DebugFlag;
//数値を区切って文字列にする
static string MakeString_LongLong(vector<long long> const &numbers,
string const &str) {
if (numbers.size() == 0)
return "";
string result = "" + to_string(numbers[0]);
for (long long i = 1; i < numbers.size(); i++) {
result += str;
result += to_string(numbers[i]);
}
return result;
}
//空白で区切る為のオーバーロード
static string MakeString_LongLong(vector<long long> const &numbers) {
if (numbers.size() == 0)
return "";
string result = "" + to_string(numbers[0]);
for (long long i = 1; i < numbers.size(); i++) {
result += " ";
result += to_string(numbers[i]);
}
return result;
}
//文字列の配列を改行を挟んでまとめる
static string MakeString_VectorString(vector<string> const &str) {
string result = "";
for (long long i = 0; i < str.size(); i++) {
result += str[i] + "\n";
}
return result;
}
//文字列を必要な個数だけ読み取る
static vector<string> MyReadLineSplit(LL n) {
vector<string> str(n);
for (long long i = 0; i < n; i++) {
std::cin >> str[i];
}
return str;
}
//数値を必要な個数だけ読み取る
static vector<long long> ReadInts(long long number) {
vector<long long> a(number);
for (int i = 0; i < number; i++) {
std::cin >> a[i];
}
return a;
}
//渡された自然数が素数ならtureを返す
static bool PrimeCheck_Int(long long number) {
if (number < 2)
return false;
for (ULL i = 2; i * i <= number; i++) {
if (number % i == 0)
return false;
}
return true;
}
//渡された数値以下の素数表を作る
static vector<long long> MakePrimeList(long long n) {
vector<long long> list;
LL i, j, p;
bool flag;
for (i = 2; i <= n; i++) {
flag = true;
for (j = 0; j < list.size(); j++) {
if (!(list[j] * list[j] <= i))
break;
if (i % list[j] == 0) {
flag = false;
break;
}
}
if (flag)
list.push_back(i);
}
return list;
}
//文字列の分割
static vector<string> split(string const &str, char sep) {
vector<std::string> v; // 分割結果を格納するベクター
auto first = str.begin(); // テキストの最初を指すイテレータ
while (first != str.end()) { // テキストが残っている間ループ
auto last = first; // 分割文字列末尾へのイテレータ
while (last != str.end() &&
*last != sep) // 末尾 or セパレータ文字まで進める
last++;
v.push_back(string(first, last)); // 分割文字を出力
if (last != str.end())
last++;
first = last; // 次の処理のためにイテレータを設定
}
return v;
}
//合計を求める
template <typename T> static LL Sum(T const &a) {
LL sum = 0;
auto itr = a.begin();
while (itr != a.end()) {
sum += (*itr);
itr++;
}
return sum;
}
//小文字ならtrueを返す
static bool Komoji(char a) {
if (a >= 'a' && a <= 'z')
return true;
return false;
}
//大文字ならtrueを返す
static bool Oomoji(char a) {
if (a >= 'A' && a <= 'Z')
return true;
return false;
}
//切り上げの整数値割り算
static LL KiriageWarizan(LL a, LL b) {
LL result = a / b;
if (a % b > 0)
result++;
return result;
}
//最大公約数を求める
static LL GreatestCommonFactor(LL a, LL b) {
a = abs(a);
b = abs(b);
LL temp;
if (a < b) {
temp = b;
b = a;
a = temp;
}
while (b > 0) {
temp = a % b;
a = b;
b = temp;
}
return a;
}
//最小公倍数を求める
static LL LeastCommonMultiple(LL a, LL b) {
return (a / GreatestCommonFactor(a, b)) * b;
}
//二次元配列を行列とみなして転置する
static VVLL VVLLturn(VVLL a) {
if (a.size() == 0)
return VVLL(0);
VVLL result(a[0].size(), VLL(a.size()));
LL i, j;
for (i = 0; i < a.size(); i++) {
for (j = 0; j < a[0].size(); j++) {
result[j][i] = a[i][j];
}
}
return result;
}
//素因数分解、素数、指数の順
static vector<VLL> PrimeFactorization(LL n) {
VLL p_list, s_list;
LL i, j, k, count;
for (i = 2; n > 1; i++) {
if (i * i > n) {
p_list.push_back(n);
s_list.push_back(1);
break;
}
if (n % i == 0) {
count = 0;
while (n % i == 0) {
n /= i;
count++;
}
p_list.push_back(i);
s_list.push_back(count);
}
}
vector<VLL> result;
result.push_back(p_list);
result.push_back(s_list);
return MYCP::VVLLturn(result);
}
//整数nの約数の配列を作る
static VLL MakeYakusuList(LL n) {
auto primes = MYCP::PrimeFactorization(n);
VLL ans;
VLL roop(primes.size(), 0);
LL i, j, k, m, size = roop.size();
while (true) {
LL a = 1;
for (i = 0; i < size; i++) {
for (j = 0; j < roop[i]; j++) {
a *= primes[i][0];
}
}
ans.push_back(a);
roop[0]++;
for (i = 0; i < size; i++) {
if (i + 1 < size) {
roop[i + 1] += (roop[i] / (primes[i][1] + 1));
}
roop[i] %= (primes[i][1] + 1);
}
bool flag = true;
for (i = 0; i < size; i++) {
if (roop[i] != 0)
flag = false;
}
if (flag)
break;
}
return MYCP::Sort(ans);
}
//組み合わせ nCr
static LL Combination(LL n, LL r) {
r = min(r, n - r);
VLL p(n + 1, 0);
LL i, j, k, a, b, c;
for (i = 1; i <= r; i++) {
auto temp = MYCP::PrimeFactorization(i);
temp = MYCP::VVLLturn(temp);
if (temp.size() == 0) {
temp = VVLL(2, VLL(0));
}
for (j = 0; j < temp[0].size(); j++) {
p[temp[0][j]] -= temp[1][j];
}
a = i + n - r;
temp = MYCP::PrimeFactorization(a);
temp = MYCP::VVLLturn(temp);
if (temp.size() == 0) {
temp = VVLL(2, VLL(0));
}
for (j = 0; j < temp[0].size(); j++) {
p[temp[0][j]] += temp[1][j];
}
}
LL result = 1;
for (i = 0; i < p.size(); i++) {
if (p[i] > 0) {
for (j = 0; j < p[i]; j++) {
result *= i;
result %= MYCP::MOD_CONST;
}
}
}
return result;
}
//符号
static LL sign(LL const x) {
if (x > 0)
return 1;
if (x < 0)
return -1;
return 0;
}
//円周率
static double PI() { return (double)3.1415926535898; }
//指定した桁でdoubleを出す。改行はしない。
static void CoutDoubleKeta(double a, LL keta) {
cout << setprecision(keta) << a << flush;
}
//コンテナクラスの出力
template <typename T> static T CoutVector(T const &ls) {
LL i, j, k, size = distance(ls.begin(), ls.end());
auto itr = ls.begin();
for (i = 0; i < size - 1; i++) {
cout << *itr << " " << flush;
itr++;
}
cout << *itr << flush;
return ls;
}
//コンテナクラスをソートする
template <typename T> static T Sort(T &ls) {
sort(ls.begin(), ls.end());
return ls;
}
//順序関数付きでコンテナクラスをソートする
template <typename T, typename F> static T Sort(T &ls, F func) {
sort(ls.begin(), ls.end(), func);
return ls;
}
//コンテナクラスを逆順に並び替える
template <typename T> static T Reverse(T &ls) {
reverse(ls.begin(), ls.end());
return ls;
}
//コンテナクラスの条件を満たす要素を数え上げる。bool func(S x)
template <typename T, typename S> static LL Count(T const &ls, S func) {
LL ans = 0;
auto itr = ls.begin();
while (itr != ls.end()) {
if (func(*itr))
ans++;
itr++;
}
return ans;
}
//コンテナクラスの要素をすべて更新する。S func(S x)
template <typename T, typename S> static T AllUpdate(T &ls, S func) {
auto itr = ls.begin();
while (itr != ls.end()) {
*itr = func(*itr);
itr++;
}
return ls;
}
//リストをベクターに変換する
template <typename T> static vector<T> FromListToVector(list<T> a) {
vector<T> ans;
for (auto itr = a.begin(); itr != a.end(); itr++) {
ans.push_back(*itr);
}
return ans;
}
//ベクターをリストに変換する
template <typename T> static list<T> FromVectorToList(vector<T> a) {
list<T> ans;
for (auto itr = a.begin(); itr != a.end(); itr++) {
ans.push_back(*itr);
}
return ans;
}
//デバッグ用出力
template <typename T> static LL DebugPrintf(T output) {
if (MYCP::DebugFlag) {
std::cout << output << endl;
}
return MYCP::DebugFlag;
}
//デバッグ用入力
static LL DebugCin() {
LL a;
if (MYCP::DebugFlag) {
cin >> a;
}
return a;
}
};
LL MYCP::DebugFlag = 0;
//累積和を求めるクラス
class Ruisekiwa {
private:
vector<LL> list;
public:
void MakeArray(vector<LL> data) {
LL i;
list = data;
list.push_back(0);
list[0] = 0;
for (i = 1; i < list.size(); i++) {
list[i] = list[i - 1] + data[i - 1];
}
}
LL Sum(LL start, LL end) {
if (end < start) {
std::cout << "startがendより大きいです";
return 0;
}
if (start < 0 || end >= list.size()) {
std::cout << "範囲が異常";
return 0;
}
return list[end] - list[start];
}
};
// n進数を管理するクラス
class N_Number {
public:
N_Number(LL n, LL keta) {
this->N_Shinsuu = n;
VLL temp(keta, 0);
this->numbers = temp;
}
//数を足す
void plus(LL a) {
if (a < 0) {
a *= (-1);
this->minus(a);
return;
}
this->numbers[0] += a;
LL size = this->numbers.size();
for (LL i = 0; i < size; i++) {
if (i + 1 < size) {
this->numbers[i + 1] += this->numbers[i] / this->N_Shinsuu;
}
this->numbers[i] %= this->N_Shinsuu;
}
}
//全ての桁が同じ数字になっていればその数字を返す。それ以外の場合は -1 を返す
LL check() {
LL a = this->numbers[0];
for (LL i = 0; i < this->numbers.size(); i++) {
if (this->numbers[i] != a)
return -1;
}
return a;
}
LL getNumber(LL keta) { return this->numbers[keta]; }
LL getKeta() { return this->numbers.size(); }
LL getShinsuu() { return this->N_Shinsuu; }
void setNumber(LL keta, LL number) {
if (0 <= number && number < this->getShinsuu()) {
if (0 <= keta && keta < this->getKeta()) {
this->numbers[keta] = number;
return;
}
}
cout << "er" << endl;
}
void setAllNumbers(LL number) {
LL size = this->getKeta(), i;
for (i = 0; i < size; i++) {
this->setNumber(i, number);
}
}
string to_string_KetaSoroe() {
string s = "";
for (LL i = this->getKeta() - 1; i >= 0; i--) {
s += to_string(this->getNumber(i));
}
return s;
}
private:
void minus(LL a) {
LL i, j, k, zettaiti = abs(a);
k = MYCP::KiriageWarizan(zettaiti, this->N_Shinsuu);
j = k * (this->N_Shinsuu - 1);
for (i = 0; i < this->getKeta(); i++) {
this->numbers[i] += j;
}
this->numbers[0] += k - a;
this->plus(0);
}
VLL numbers;
LL N_Shinsuu;
};
// UnionFind
class Union_Find {
private:
VLL tree;
VLL count;
LL root(LL a) {
if (this->tree[a] == a)
return a;
return this->tree[a] = this->root(this->tree[a]);
}
public:
Union_Find(LL n) {
VLL set(n);
this->tree = set;
this->count = set;
for (LL i = 0; i < n; i++) {
this->tree[i] = i;
this->count[i] = 1;
}
}
void unite(LL a, LL b) {
LL x, y;
if (!this->Check(a, b)) {
x = this->getCount(a) + getCount(b);
y = this->root(a);
this->count[y] = x;
y = this->root(b);
this->count[y] = x;
}
x = this->root(a);
y = this->root(b);
this->tree[x] = y;
}
bool Check(LL a, LL b) { return this->root(a) == this->root(b); }
LL getCount(LL index) {
LL temp = this->root(index);
return this->count[temp];
}
VLL getList() {
VLL ans(this->tree.size(), 0);
for (LL i = 0; i < ans.size(); i++) {
ans[i] = this->root(i);
}
return ans;
}
};
//プラスマイナス無限に対応したlong long型
class INF_LONG_LONG {
private:
LL inf, n;
public:
//コンストラクタ
INF_LONG_LONG(LL a) {
this->n = a;
this->inf = 0;
this->Syusei();
}
INF_LONG_LONG() { *this = INF_LONG_LONG(0); }
INF_LONG_LONG(INF_LONG_LONG const &a) {
this->n = a.n;
this->inf = a.inf;
this->Syusei();
}
//ゲッター
LL getN() const { return this->n; }
LL getInf() const { return this->inf; }
//正の無限大生成
static INF_LONG_LONG plus_inf() {
INF_LONG_LONG a;
a.n = 0;
a.inf = 1;
a.Syusei();
return a;
}
//負の無限大生成
static INF_LONG_LONG minus_inf() {
INF_LONG_LONG a;
a.n = 0;
a.inf = -1;
a.Syusei();
return a;
}
//符号を取得
LL sign() const {
if (this->inf != 0) {
return this->inf;
}
return MYCP::sign(this->n);
}
//代入演算子
INF_LONG_LONG operator=(INF_LONG_LONG const &b) {
this->n = b.n;
this->inf = b.inf;
this->Syusei();
return *this;
}
INF_LONG_LONG operator=(LL const &b) {
*this = INF_LONG_LONG(b);
this->Syusei();
return *this;
}
//比較演算子
bool operator==(INF_LONG_LONG const &b) const {
if (this->n == b.n && this->inf == b.inf)
return true;
return false;
}
bool operator!=(INF_LONG_LONG const &b) const { return !(*this == b); }
bool operator<(INF_LONG_LONG const &b) const {
if (this->inf < b.inf)
return true;
if (this->inf > b.inf)
return false;
return this->n < b.n;
}
bool operator>(INF_LONG_LONG const &b) const { return b < *this; }
bool operator<=(INF_LONG_LONG const &b) const { return !(*this > b); }
bool operator>=(INF_LONG_LONG const &b) const { return !(*this < b); }
//算術演算子
INF_LONG_LONG operator+(INF_LONG_LONG const &b) const {
if (max(this->inf, b.inf) > 0)
return INF_LONG_LONG::plus_inf();
if (min(this->inf, b.inf) < 0)
return INF_LONG_LONG::minus_inf();
auto ans = *this;
ans.n += b.n;
ans.Syusei();
return ans;
}
INF_LONG_LONG operator*(INF_LONG_LONG const &b) const {
if (*this == INF_LONG_LONG(0) || b == INF_LONG_LONG(0)) {
return INF_LONG_LONG(0);
}
if (this->inf != 0 || b.inf != 0) {
LL s = this->sign() * b.sign();
INF_LONG_LONG ans(0);
ans.n = 0;
ans.inf = s;
ans.Syusei();
return ans;
}
INF_LONG_LONG ans(0);
ans.n = this->n * b.n;
ans.Syusei();
return ans;
}
INF_LONG_LONG operator-(INF_LONG_LONG const &b) const {
auto ans = (*this + (INF_LONG_LONG(-1) * b));
ans.Syusei();
return ans;
}
INF_LONG_LONG operator/(INF_LONG_LONG const &b) const {
if (b == INF_LONG_LONG(0)) {
LL a = this->n / b.n;
return INF_LONG_LONG(a);
}
if (b.inf != 0) {
return INF_LONG_LONG(0);
}
if (*this == INF_LONG_LONG(0)) {
return INF_LONG_LONG(0);
}
if (this->inf != 0) {
LL s = this->sign() * b.sign();
return INF_LONG_LONG::plus_inf() * INF_LONG_LONG(s);
}
INF_LONG_LONG ans;
ans.n = this->n / b.n;
ans.Syusei();
return ans;
}
INF_LONG_LONG operator%(INF_LONG_LONG const &b) const {
if (this->inf == 0 && b.inf == 0) {
INF_LONG_LONG ans;
ans.n = this->n % b.n;
ans.Syusei();
return ans;
}
auto x = *this / b;
x.Syusei();
auto ans = *this - b * x;
ans.Syusei();
return ans;
}
//複合代入演算子
INF_LONG_LONG operator+=(INF_LONG_LONG const &b) {
auto ans = *this + b;
*this = ans;
return *this;
}
INF_LONG_LONG operator-=(INF_LONG_LONG const &b) {
auto ans = *this - b;
*this = ans;
return *this;
}
INF_LONG_LONG operator*=(INF_LONG_LONG const &b) {
auto ans = *this * b;
*this = ans;
return *this;
}
INF_LONG_LONG operator/=(INF_LONG_LONG const &b) {
auto ans = *this / b;
*this = ans;
return *this;
}
INF_LONG_LONG operator%=(INF_LONG_LONG const &b) {
auto ans = *this % b;
*this = ans;
return *this;
}
//符号演算子
INF_LONG_LONG operator+() const { return *this; }
INF_LONG_LONG operator-() const { return *this * INF_LONG_LONG(-1); }
//前置きインクリメント・デクリメント
INF_LONG_LONG operator++() {
this->n++;
this->Syusei();
return *this;
}
INF_LONG_LONG operator--() {
this->n--;
this->Syusei();
return *this;
}
//後置きインクリメント・デクリメント
INF_LONG_LONG operator++(int) {
auto copy = *this;
++(*this);
return copy;
}
INF_LONG_LONG operator--(int) {
auto copy = *this;
--(*this);
return copy;
}
//文字列への変換
string ToString() const {
if (this->inf == 1) {
return "+INF";
}
if (this->inf == -1) {
return "-INF";
}
return to_string(this->n);
}
private:
void Syusei() {
if (this->inf != 0) {
this->n = 0;
}
}
};
typedef INF_LONG_LONG ILL_TYPE;
typedef vector<ILL_TYPE> VILL_TYPE;
typedef vector<VILL_TYPE> VVILL_TYPE;
//ワーシャルフロイド
class WarshallFloyd {
public:
//最短距離を記録
VVILL_TYPE d;
//頂点数
LL v;
// vは頂点数、edge_cost_listは辺の情報{始点、終点、コスト}の配列。無向グラフの場合、逆矢印の辺に注意。
WarshallFloyd(LL v, VVLL edge_cost_list) {
this->v = v;
this->d = VVILL_TYPE(v, VILL_TYPE(v, ILL_TYPE::plus_inf()));
LL i, j, k, a, b, c;
for (i = 0; i < edge_cost_list.size(); i++) {
a = edge_cost_list[i][0];
b = edge_cost_list[i][1];
c = edge_cost_list[i][2];
this->d[a][b] = ILL_TYPE(c);
}
for (i = 0; i < v; i++) {
this->d[i][i] = ILL_TYPE(0);
}
//ここから計算
for (k = 0; k < v; k++) {
for (i = 0; i < v; i++) {
for (j = 0; j < v; j++) {
d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}
}
}
}
};
//ベルマンフォード
class BellmanFord {
public:
//辺のリスト
VVILL_TYPE edge;
//頂点数、辺数
LL v, e;
//始点
LL s;
//最短距離
VILL_TYPE d;
// vは頂点数、startは始点、edge_cost_listは辺の情報{始点、終点、コスト}の配列。
BellmanFord(LL v, LL start, VVLL edge_cost_list) {
this->v = v;
this->s = start;
this->e = edge_cost_list.size();
this->d = VILL_TYPE(v, ILL_TYPE::plus_inf());
this->d[start] = 0;
LL i, j, k;
for (i = 0; i < this->e; i++) {
VILL_TYPE temp;
LL a, b, c;
a = edge_cost_list[i][0];
b = edge_cost_list[i][1];
c = edge_cost_list[i][2];
temp.push_back(ILL_TYPE(a));
temp.push_back(ILL_TYPE(b));
temp.push_back(ILL_TYPE(c));
this->edge.push_back(temp);
}
this->DoUpdata();
auto cpy = this->d;
this->DoUpdata();
for (i = 0; i < this->d.size(); i++) {
if (this->d[i] != cpy[i]) {
this->d[i] = ILL_TYPE::minus_inf();
}
}
this->DoUpdata();
}
private:
void DoUpdata() {
LL i, j, k;
for (i = 0; i <= this->v; i++) {
bool update = true;
for (j = 0; j < this->e; j++) {
ILL_TYPE c;
LL a, b;
a = this->edge[j][0].getN();
b = this->edge[j][1].getN();
c = this->edge[j][2];
if (this->d[a] < ILL_TYPE::plus_inf()) {
if (this->d[a] + c < this->d[b]) {
update = false;
this->d[b] = this->d[a] + c;
}
}
}
if (update)
break;
}
}
};
//ダイクストラ
class Dijkstra {
public:
Dijkstra(LL v, LL start, VVLL edge_cost_list) {}
};
//ライブラリはここまで
//ここから下を書く
//ここからメイン
int main(void) {
MYCP::DebugFlag = 0;
LL i, j, k, n, m;
char ten = '.', shape = '#';
LL h, w;
cin >> h >> w;
VVLL s(h, VLL(w, 0));
VVLL ans1, ans2;
ans1 = ans2 = s;
for (i = 0; i < h; i++) {
string temp;
cin >> temp;
for (j = 0; j < w; j++) {
if (temp[j] == '#') {
s[i][j] = 1;
}
}
}
VLL ls;
LL count = 0;
for (i = 0; i < h; i++) {
count = 0;
for (j = 0; j < w; j++) {
if (s[i][j] == 0) {
count++;
ans1[i][j] = ls.size();
} else {
ls.push_back(count);
count = 0;
}
}
ls.push_back(count);
}
for (j = 0; j < w; j++) {
count = 0;
for (i = 0; i < h; i++) {
if (s[i][j] == 0) {
count++;
ans2[i][j] = ls.size();
} else {
ls.push_back(count);
count = 0;
}
}
ls.push_back(count);
}
LL mx = -1;
for (i = 0; i < h; i++) {
for (j = 0; j < w; j++) {
LL a, b;
a = ls[ans1[i][j]];
b = ls[ans2[i][j]];
mx = max(mx, a + b);
}
}
cout << mx - 1 << endl;
return 0;
}
| [
"expression.operation.binary.add"
] | 828,058 | 828,059 | u304318875 | cpp |
p03014 | #include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<ULL> VULL;
typedef vector<VLL> VVLL;
class MYCP {
public:
static const LL MOD_CONST = (LL)1000 * 1000 * 1000 + 7;
static LL DebugFlag;
//数値を区切って文字列にする
static string MakeString_LongLong(vector<long long> const &numbers,
string const &str) {
if (numbers.size() == 0)
return "";
string result = "" + to_string(numbers[0]);
for (long long i = 1; i < numbers.size(); i++) {
result += str;
result += to_string(numbers[i]);
}
return result;
}
//空白で区切る為のオーバーロード
static string MakeString_LongLong(vector<long long> const &numbers) {
if (numbers.size() == 0)
return "";
string result = "" + to_string(numbers[0]);
for (long long i = 1; i < numbers.size(); i++) {
result += " ";
result += to_string(numbers[i]);
}
return result;
}
//文字列の配列を改行を挟んでまとめる
static string MakeString_VectorString(vector<string> const &str) {
string result = "";
for (long long i = 0; i < str.size(); i++) {
result += str[i] + "\n";
}
return result;
}
//文字列を必要な個数だけ読み取る
static vector<string> MyReadLineSplit(LL n) {
vector<string> str(n);
for (long long i = 0; i < n; i++) {
std::cin >> str[i];
}
return str;
}
//数値を必要な個数だけ読み取る
static vector<long long> ReadInts(long long number) {
vector<long long> a(number);
for (int i = 0; i < number; i++) {
std::cin >> a[i];
}
return a;
}
//渡された自然数が素数ならtureを返す
static bool PrimeCheck_Int(long long number) {
if (number < 2)
return false;
for (ULL i = 2; i * i <= number; i++) {
if (number % i == 0)
return false;
}
return true;
}
//渡された数値以下の素数表を作る
static vector<long long> MakePrimeList(long long n) {
vector<long long> list;
LL i, j, p;
bool flag;
for (i = 2; i <= n; i++) {
flag = true;
for (j = 0; j < list.size(); j++) {
if (!(list[j] * list[j] <= i))
break;
if (i % list[j] == 0) {
flag = false;
break;
}
}
if (flag)
list.push_back(i);
}
return list;
}
//文字列の分割
static vector<string> split(string const &str, char sep) {
vector<std::string> v; // 分割結果を格納するベクター
auto first = str.begin(); // テキストの最初を指すイテレータ
while (first != str.end()) { // テキストが残っている間ループ
auto last = first; // 分割文字列末尾へのイテレータ
while (last != str.end() &&
*last != sep) // 末尾 or セパレータ文字まで進める
last++;
v.push_back(string(first, last)); // 分割文字を出力
if (last != str.end())
last++;
first = last; // 次の処理のためにイテレータを設定
}
return v;
}
//合計を求める
template <typename T> static LL Sum(T const &a) {
LL sum = 0;
auto itr = a.begin();
while (itr != a.end()) {
sum += (*itr);
itr++;
}
return sum;
}
//小文字ならtrueを返す
static bool Komoji(char a) {
if (a >= 'a' && a <= 'z')
return true;
return false;
}
//大文字ならtrueを返す
static bool Oomoji(char a) {
if (a >= 'A' && a <= 'Z')
return true;
return false;
}
//切り上げの整数値割り算
static LL KiriageWarizan(LL a, LL b) {
LL result = a / b;
if (a % b > 0)
result++;
return result;
}
//最大公約数を求める
static LL GreatestCommonFactor(LL a, LL b) {
a = abs(a);
b = abs(b);
LL temp;
if (a < b) {
temp = b;
b = a;
a = temp;
}
while (b > 0) {
temp = a % b;
a = b;
b = temp;
}
return a;
}
//最小公倍数を求める
static LL LeastCommonMultiple(LL a, LL b) {
return (a / GreatestCommonFactor(a, b)) * b;
}
//二次元配列を行列とみなして転置する
static VVLL VVLLturn(VVLL a) {
if (a.size() == 0)
return VVLL(0);
VVLL result(a[0].size(), VLL(a.size()));
LL i, j;
for (i = 0; i < a.size(); i++) {
for (j = 0; j < a[0].size(); j++) {
result[j][i] = a[i][j];
}
}
return result;
}
//素因数分解、素数、指数の順
static vector<VLL> PrimeFactorization(LL n) {
VLL p_list, s_list;
LL i, j, k, count;
for (i = 2; n > 1; i++) {
if (i * i > n) {
p_list.push_back(n);
s_list.push_back(1);
break;
}
if (n % i == 0) {
count = 0;
while (n % i == 0) {
n /= i;
count++;
}
p_list.push_back(i);
s_list.push_back(count);
}
}
vector<VLL> result;
result.push_back(p_list);
result.push_back(s_list);
return MYCP::VVLLturn(result);
}
//整数nの約数の配列を作る
static VLL MakeYakusuList(LL n) {
auto primes = MYCP::PrimeFactorization(n);
VLL ans;
VLL roop(primes.size(), 0);
LL i, j, k, m, size = roop.size();
while (true) {
LL a = 1;
for (i = 0; i < size; i++) {
for (j = 0; j < roop[i]; j++) {
a *= primes[i][0];
}
}
ans.push_back(a);
roop[0]++;
for (i = 0; i < size; i++) {
if (i + 1 < size) {
roop[i + 1] += (roop[i] / (primes[i][1] + 1));
}
roop[i] %= (primes[i][1] + 1);
}
bool flag = true;
for (i = 0; i < size; i++) {
if (roop[i] != 0)
flag = false;
}
if (flag)
break;
}
return MYCP::Sort(ans);
}
//組み合わせ nCr
static LL Combination(LL n, LL r) {
r = min(r, n - r);
VLL p(n + 1, 0);
LL i, j, k, a, b, c;
for (i = 1; i <= r; i++) {
auto temp = MYCP::PrimeFactorization(i);
temp = MYCP::VVLLturn(temp);
if (temp.size() == 0) {
temp = VVLL(2, VLL(0));
}
for (j = 0; j < temp[0].size(); j++) {
p[temp[0][j]] -= temp[1][j];
}
a = i + n - r;
temp = MYCP::PrimeFactorization(a);
temp = MYCP::VVLLturn(temp);
if (temp.size() == 0) {
temp = VVLL(2, VLL(0));
}
for (j = 0; j < temp[0].size(); j++) {
p[temp[0][j]] += temp[1][j];
}
}
LL result = 1;
for (i = 0; i < p.size(); i++) {
if (p[i] > 0) {
for (j = 0; j < p[i]; j++) {
result *= i;
result %= MYCP::MOD_CONST;
}
}
}
return result;
}
//符号
static LL sign(LL const x) {
if (x > 0)
return 1;
if (x < 0)
return -1;
return 0;
}
//円周率
static double PI() { return (double)3.1415926535898; }
//指定した桁でdoubleを出す。改行はしない。
static void CoutDoubleKeta(double a, LL keta) {
cout << setprecision(keta) << a << flush;
}
//コンテナクラスの出力
template <typename T> static T CoutVector(T const &ls) {
LL i, j, k, size = distance(ls.begin(), ls.end());
auto itr = ls.begin();
for (i = 0; i < size - 1; i++) {
cout << *itr << " " << flush;
itr++;
}
cout << *itr << flush;
return ls;
}
//コンテナクラスをソートする
template <typename T> static T Sort(T &ls) {
sort(ls.begin(), ls.end());
return ls;
}
//順序関数付きでコンテナクラスをソートする
template <typename T, typename F> static T Sort(T &ls, F func) {
sort(ls.begin(), ls.end(), func);
return ls;
}
//コンテナクラスを逆順に並び替える
template <typename T> static T Reverse(T &ls) {
reverse(ls.begin(), ls.end());
return ls;
}
//コンテナクラスの条件を満たす要素を数え上げる。bool func(S x)
template <typename T, typename S> static LL Count(T const &ls, S func) {
LL ans = 0;
auto itr = ls.begin();
while (itr != ls.end()) {
if (func(*itr))
ans++;
itr++;
}
return ans;
}
//コンテナクラスの要素をすべて更新する。S func(S x)
template <typename T, typename S> static T AllUpdate(T &ls, S func) {
auto itr = ls.begin();
while (itr != ls.end()) {
*itr = func(*itr);
itr++;
}
return ls;
}
//リストをベクターに変換する
template <typename T> static vector<T> FromListToVector(list<T> a) {
vector<T> ans;
for (auto itr = a.begin(); itr != a.end(); itr++) {
ans.push_back(*itr);
}
return ans;
}
//ベクターをリストに変換する
template <typename T> static list<T> FromVectorToList(vector<T> a) {
list<T> ans;
for (auto itr = a.begin(); itr != a.end(); itr++) {
ans.push_back(*itr);
}
return ans;
}
//デバッグ用出力
template <typename T> static LL DebugPrintf(T output) {
if (MYCP::DebugFlag) {
std::cout << output << endl;
}
return MYCP::DebugFlag;
}
//デバッグ用入力
static LL DebugCin() {
LL a;
if (MYCP::DebugFlag) {
cin >> a;
}
return a;
}
};
LL MYCP::DebugFlag = 0;
//累積和を求めるクラス
class Ruisekiwa {
private:
vector<LL> list;
public:
void MakeArray(vector<LL> data) {
LL i;
list = data;
list.push_back(0);
list[0] = 0;
for (i = 1; i < list.size(); i++) {
list[i] = list[i - 1] + data[i - 1];
}
}
LL Sum(LL start, LL end) {
if (end < start) {
std::cout << "startがendより大きいです";
return 0;
}
if (start < 0 || end >= list.size()) {
std::cout << "範囲が異常";
return 0;
}
return list[end] - list[start];
}
};
// n進数を管理するクラス
class N_Number {
public:
N_Number(LL n, LL keta) {
this->N_Shinsuu = n;
VLL temp(keta, 0);
this->numbers = temp;
}
//数を足す
void plus(LL a) {
if (a < 0) {
a *= (-1);
this->minus(a);
return;
}
this->numbers[0] += a;
LL size = this->numbers.size();
for (LL i = 0; i < size; i++) {
if (i + 1 < size) {
this->numbers[i + 1] += this->numbers[i] / this->N_Shinsuu;
}
this->numbers[i] %= this->N_Shinsuu;
}
}
//全ての桁が同じ数字になっていればその数字を返す。それ以外の場合は -1 を返す
LL check() {
LL a = this->numbers[0];
for (LL i = 0; i < this->numbers.size(); i++) {
if (this->numbers[i] != a)
return -1;
}
return a;
}
LL getNumber(LL keta) { return this->numbers[keta]; }
LL getKeta() { return this->numbers.size(); }
LL getShinsuu() { return this->N_Shinsuu; }
void setNumber(LL keta, LL number) {
if (0 <= number && number < this->getShinsuu()) {
if (0 <= keta && keta < this->getKeta()) {
this->numbers[keta] = number;
return;
}
}
cout << "er" << endl;
}
void setAllNumbers(LL number) {
LL size = this->getKeta(), i;
for (i = 0; i < size; i++) {
this->setNumber(i, number);
}
}
string to_string_KetaSoroe() {
string s = "";
for (LL i = this->getKeta() - 1; i >= 0; i--) {
s += to_string(this->getNumber(i));
}
return s;
}
private:
void minus(LL a) {
LL i, j, k, zettaiti = abs(a);
k = MYCP::KiriageWarizan(zettaiti, this->N_Shinsuu);
j = k * (this->N_Shinsuu - 1);
for (i = 0; i < this->getKeta(); i++) {
this->numbers[i] += j;
}
this->numbers[0] += k - a;
this->plus(0);
}
VLL numbers;
LL N_Shinsuu;
};
// UnionFind
class Union_Find {
private:
VLL tree;
VLL count;
LL root(LL a) {
if (this->tree[a] == a)
return a;
return this->tree[a] = this->root(this->tree[a]);
}
public:
Union_Find(LL n) {
VLL set(n);
this->tree = set;
this->count = set;
for (LL i = 0; i < n; i++) {
this->tree[i] = i;
this->count[i] = 1;
}
}
void unite(LL a, LL b) {
LL x, y;
if (!this->Check(a, b)) {
x = this->getCount(a) + getCount(b);
y = this->root(a);
this->count[y] = x;
y = this->root(b);
this->count[y] = x;
}
x = this->root(a);
y = this->root(b);
this->tree[x] = y;
}
bool Check(LL a, LL b) { return this->root(a) == this->root(b); }
LL getCount(LL index) {
LL temp = this->root(index);
return this->count[temp];
}
VLL getList() {
VLL ans(this->tree.size(), 0);
for (LL i = 0; i < ans.size(); i++) {
ans[i] = this->root(i);
}
return ans;
}
};
//プラスマイナス無限に対応したlong long型
class INF_LONG_LONG {
private:
LL inf, n;
public:
//コンストラクタ
INF_LONG_LONG(LL a) {
this->n = a;
this->inf = 0;
this->Syusei();
}
INF_LONG_LONG() { *this = INF_LONG_LONG(0); }
INF_LONG_LONG(INF_LONG_LONG const &a) {
this->n = a.n;
this->inf = a.inf;
this->Syusei();
}
//ゲッター
LL getN() const { return this->n; }
LL getInf() const { return this->inf; }
//正の無限大生成
static INF_LONG_LONG plus_inf() {
INF_LONG_LONG a;
a.n = 0;
a.inf = 1;
a.Syusei();
return a;
}
//負の無限大生成
static INF_LONG_LONG minus_inf() {
INF_LONG_LONG a;
a.n = 0;
a.inf = -1;
a.Syusei();
return a;
}
//符号を取得
LL sign() const {
if (this->inf != 0) {
return this->inf;
}
return MYCP::sign(this->n);
}
//代入演算子
INF_LONG_LONG operator=(INF_LONG_LONG const &b) {
this->n = b.n;
this->inf = b.inf;
this->Syusei();
return *this;
}
INF_LONG_LONG operator=(LL const &b) {
*this = INF_LONG_LONG(b);
this->Syusei();
return *this;
}
//比較演算子
bool operator==(INF_LONG_LONG const &b) const {
if (this->n == b.n && this->inf == b.inf)
return true;
return false;
}
bool operator!=(INF_LONG_LONG const &b) const { return !(*this == b); }
bool operator<(INF_LONG_LONG const &b) const {
if (this->inf < b.inf)
return true;
if (this->inf > b.inf)
return false;
return this->n < b.n;
}
bool operator>(INF_LONG_LONG const &b) const { return b < *this; }
bool operator<=(INF_LONG_LONG const &b) const { return !(*this > b); }
bool operator>=(INF_LONG_LONG const &b) const { return !(*this < b); }
//算術演算子
INF_LONG_LONG operator+(INF_LONG_LONG const &b) const {
if (max(this->inf, b.inf) > 0)
return INF_LONG_LONG::plus_inf();
if (min(this->inf, b.inf) < 0)
return INF_LONG_LONG::minus_inf();
auto ans = *this;
ans.n += b.n;
ans.Syusei();
return ans;
}
INF_LONG_LONG operator*(INF_LONG_LONG const &b) const {
if (*this == INF_LONG_LONG(0) || b == INF_LONG_LONG(0)) {
return INF_LONG_LONG(0);
}
if (this->inf != 0 || b.inf != 0) {
LL s = this->sign() * b.sign();
INF_LONG_LONG ans(0);
ans.n = 0;
ans.inf = s;
ans.Syusei();
return ans;
}
INF_LONG_LONG ans(0);
ans.n = this->n * b.n;
ans.Syusei();
return ans;
}
INF_LONG_LONG operator-(INF_LONG_LONG const &b) const {
auto ans = (*this + (INF_LONG_LONG(-1) * b));
ans.Syusei();
return ans;
}
INF_LONG_LONG operator/(INF_LONG_LONG const &b) const {
if (b == INF_LONG_LONG(0)) {
LL a = this->n / b.n;
return INF_LONG_LONG(a);
}
if (b.inf != 0) {
return INF_LONG_LONG(0);
}
if (*this == INF_LONG_LONG(0)) {
return INF_LONG_LONG(0);
}
if (this->inf != 0) {
LL s = this->sign() * b.sign();
return INF_LONG_LONG::plus_inf() * INF_LONG_LONG(s);
}
INF_LONG_LONG ans;
ans.n = this->n / b.n;
ans.Syusei();
return ans;
}
INF_LONG_LONG operator%(INF_LONG_LONG const &b) const {
if (this->inf == 0 && b.inf == 0) {
INF_LONG_LONG ans;
ans.n = this->n % b.n;
ans.Syusei();
return ans;
}
auto x = *this / b;
x.Syusei();
auto ans = *this - b * x;
ans.Syusei();
return ans;
}
//複合代入演算子
INF_LONG_LONG operator+=(INF_LONG_LONG const &b) {
auto ans = *this + b;
*this = ans;
return *this;
}
INF_LONG_LONG operator-=(INF_LONG_LONG const &b) {
auto ans = *this - b;
*this = ans;
return *this;
}
INF_LONG_LONG operator*=(INF_LONG_LONG const &b) {
auto ans = *this * b;
*this = ans;
return *this;
}
INF_LONG_LONG operator/=(INF_LONG_LONG const &b) {
auto ans = *this / b;
*this = ans;
return *this;
}
INF_LONG_LONG operator%=(INF_LONG_LONG const &b) {
auto ans = *this % b;
*this = ans;
return *this;
}
//符号演算子
INF_LONG_LONG operator+() const { return *this; }
INF_LONG_LONG operator-() const { return *this * INF_LONG_LONG(-1); }
//前置きインクリメント・デクリメント
INF_LONG_LONG operator++() {
this->n++;
this->Syusei();
return *this;
}
INF_LONG_LONG operator--() {
this->n--;
this->Syusei();
return *this;
}
//後置きインクリメント・デクリメント
INF_LONG_LONG operator++(int) {
auto copy = *this;
++(*this);
return copy;
}
INF_LONG_LONG operator--(int) {
auto copy = *this;
--(*this);
return copy;
}
//文字列への変換
string ToString() const {
if (this->inf == 1) {
return "+INF";
}
if (this->inf == -1) {
return "-INF";
}
return to_string(this->n);
}
private:
void Syusei() {
if (this->inf != 0) {
this->n = 0;
}
}
};
typedef INF_LONG_LONG ILL_TYPE;
typedef vector<ILL_TYPE> VILL_TYPE;
typedef vector<VILL_TYPE> VVILL_TYPE;
//ワーシャルフロイド
class WarshallFloyd {
public:
//最短距離を記録
VVILL_TYPE d;
//頂点数
LL v;
// vは頂点数、edge_cost_listは辺の情報{始点、終点、コスト}の配列。無向グラフの場合、逆矢印の辺に注意。
WarshallFloyd(LL v, VVLL edge_cost_list) {
this->v = v;
this->d = VVILL_TYPE(v, VILL_TYPE(v, ILL_TYPE::plus_inf()));
LL i, j, k, a, b, c;
for (i = 0; i < edge_cost_list.size(); i++) {
a = edge_cost_list[i][0];
b = edge_cost_list[i][1];
c = edge_cost_list[i][2];
this->d[a][b] = ILL_TYPE(c);
}
for (i = 0; i < v; i++) {
this->d[i][i] = ILL_TYPE(0);
}
//ここから計算
for (k = 0; k < v; k++) {
for (i = 0; i < v; i++) {
for (j = 0; j < v; j++) {
d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}
}
}
}
};
//ベルマンフォード
class BellmanFord {
public:
//辺のリスト
VVILL_TYPE edge;
//頂点数、辺数
LL v, e;
//始点
LL s;
//最短距離
VILL_TYPE d;
// vは頂点数、startは始点、edge_cost_listは辺の情報{始点、終点、コスト}の配列。
BellmanFord(LL v, LL start, VVLL edge_cost_list) {
this->v = v;
this->s = start;
this->e = edge_cost_list.size();
this->d = VILL_TYPE(v, ILL_TYPE::plus_inf());
this->d[start] = 0;
LL i, j, k;
for (i = 0; i < this->e; i++) {
VILL_TYPE temp;
LL a, b, c;
a = edge_cost_list[i][0];
b = edge_cost_list[i][1];
c = edge_cost_list[i][2];
temp.push_back(ILL_TYPE(a));
temp.push_back(ILL_TYPE(b));
temp.push_back(ILL_TYPE(c));
this->edge.push_back(temp);
}
this->DoUpdata();
auto cpy = this->d;
this->DoUpdata();
for (i = 0; i < this->d.size(); i++) {
if (this->d[i] != cpy[i]) {
this->d[i] = ILL_TYPE::minus_inf();
}
}
this->DoUpdata();
}
private:
void DoUpdata() {
LL i, j, k;
for (i = 0; i <= this->v; i++) {
bool update = true;
for (j = 0; j < this->e; j++) {
ILL_TYPE c;
LL a, b;
a = this->edge[j][0].getN();
b = this->edge[j][1].getN();
c = this->edge[j][2];
if (this->d[a] < ILL_TYPE::plus_inf()) {
if (this->d[a] + c < this->d[b]) {
update = false;
this->d[b] = this->d[a] + c;
}
}
}
if (update)
break;
}
}
};
//ダイクストラ
class Dijkstra {
public:
Dijkstra(LL v, LL start, VVLL edge_cost_list) {}
};
//ライブラリはここまで
//ここから下を書く
//ここからメイン
int main(void) {
MYCP::DebugFlag = 0;
LL i, j, k, n, m;
char ten = '.', shape = '#';
LL h, w;
cin >> h >> w;
VVLL s(h, VLL(w, 0));
VVLL ans1, ans2;
ans1 = ans2 = s;
for (i = 0; i < h; i++) {
string temp;
cin >> temp;
for (j = 0; j < w; j++) {
if (temp[j] == '#') {
s[i][j] = 1;
}
}
}
VLL ls;
LL count = 0;
for (i = 0; i < h; i++) {
count = 0;
for (j = 0; j < w; j++) {
if (s[i][j] == 0) {
count++;
ans1[i][j] = ls.size();
} else {
ls.push_back(count);
count = 0;
}
}
ls.push_back(count);
}
for (j = 0; j < h; j++) {
count = 0;
for (i = 0; i < w; i++) {
if (s[i][j] == 0) {
count++;
ans2[i][j] = ls.size();
} else {
ls.push_back(count);
count = 0;
}
}
ls.push_back(count);
}
LL mx = -1;
for (i = 0; i < h; i++) {
for (j = 0; j < w; j++) {
LL a, b;
a = ls[ans1[i][j]];
b = ls[ans2[i][j]];
mx = max(mx, a + b);
}
}
cout << mx << endl;
return 0;
}
| #include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<ULL> VULL;
typedef vector<VLL> VVLL;
class MYCP {
public:
static const LL MOD_CONST = (LL)1000 * 1000 * 1000 + 7;
static LL DebugFlag;
//数値を区切って文字列にする
static string MakeString_LongLong(vector<long long> const &numbers,
string const &str) {
if (numbers.size() == 0)
return "";
string result = "" + to_string(numbers[0]);
for (long long i = 1; i < numbers.size(); i++) {
result += str;
result += to_string(numbers[i]);
}
return result;
}
//空白で区切る為のオーバーロード
static string MakeString_LongLong(vector<long long> const &numbers) {
if (numbers.size() == 0)
return "";
string result = "" + to_string(numbers[0]);
for (long long i = 1; i < numbers.size(); i++) {
result += " ";
result += to_string(numbers[i]);
}
return result;
}
//文字列の配列を改行を挟んでまとめる
static string MakeString_VectorString(vector<string> const &str) {
string result = "";
for (long long i = 0; i < str.size(); i++) {
result += str[i] + "\n";
}
return result;
}
//文字列を必要な個数だけ読み取る
static vector<string> MyReadLineSplit(LL n) {
vector<string> str(n);
for (long long i = 0; i < n; i++) {
std::cin >> str[i];
}
return str;
}
//数値を必要な個数だけ読み取る
static vector<long long> ReadInts(long long number) {
vector<long long> a(number);
for (int i = 0; i < number; i++) {
std::cin >> a[i];
}
return a;
}
//渡された自然数が素数ならtureを返す
static bool PrimeCheck_Int(long long number) {
if (number < 2)
return false;
for (ULL i = 2; i * i <= number; i++) {
if (number % i == 0)
return false;
}
return true;
}
//渡された数値以下の素数表を作る
static vector<long long> MakePrimeList(long long n) {
vector<long long> list;
LL i, j, p;
bool flag;
for (i = 2; i <= n; i++) {
flag = true;
for (j = 0; j < list.size(); j++) {
if (!(list[j] * list[j] <= i))
break;
if (i % list[j] == 0) {
flag = false;
break;
}
}
if (flag)
list.push_back(i);
}
return list;
}
//文字列の分割
static vector<string> split(string const &str, char sep) {
vector<std::string> v; // 分割結果を格納するベクター
auto first = str.begin(); // テキストの最初を指すイテレータ
while (first != str.end()) { // テキストが残っている間ループ
auto last = first; // 分割文字列末尾へのイテレータ
while (last != str.end() &&
*last != sep) // 末尾 or セパレータ文字まで進める
last++;
v.push_back(string(first, last)); // 分割文字を出力
if (last != str.end())
last++;
first = last; // 次の処理のためにイテレータを設定
}
return v;
}
//合計を求める
template <typename T> static LL Sum(T const &a) {
LL sum = 0;
auto itr = a.begin();
while (itr != a.end()) {
sum += (*itr);
itr++;
}
return sum;
}
//小文字ならtrueを返す
static bool Komoji(char a) {
if (a >= 'a' && a <= 'z')
return true;
return false;
}
//大文字ならtrueを返す
static bool Oomoji(char a) {
if (a >= 'A' && a <= 'Z')
return true;
return false;
}
//切り上げの整数値割り算
static LL KiriageWarizan(LL a, LL b) {
LL result = a / b;
if (a % b > 0)
result++;
return result;
}
//最大公約数を求める
static LL GreatestCommonFactor(LL a, LL b) {
a = abs(a);
b = abs(b);
LL temp;
if (a < b) {
temp = b;
b = a;
a = temp;
}
while (b > 0) {
temp = a % b;
a = b;
b = temp;
}
return a;
}
//最小公倍数を求める
static LL LeastCommonMultiple(LL a, LL b) {
return (a / GreatestCommonFactor(a, b)) * b;
}
//二次元配列を行列とみなして転置する
static VVLL VVLLturn(VVLL a) {
if (a.size() == 0)
return VVLL(0);
VVLL result(a[0].size(), VLL(a.size()));
LL i, j;
for (i = 0; i < a.size(); i++) {
for (j = 0; j < a[0].size(); j++) {
result[j][i] = a[i][j];
}
}
return result;
}
//素因数分解、素数、指数の順
static vector<VLL> PrimeFactorization(LL n) {
VLL p_list, s_list;
LL i, j, k, count;
for (i = 2; n > 1; i++) {
if (i * i > n) {
p_list.push_back(n);
s_list.push_back(1);
break;
}
if (n % i == 0) {
count = 0;
while (n % i == 0) {
n /= i;
count++;
}
p_list.push_back(i);
s_list.push_back(count);
}
}
vector<VLL> result;
result.push_back(p_list);
result.push_back(s_list);
return MYCP::VVLLturn(result);
}
//整数nの約数の配列を作る
static VLL MakeYakusuList(LL n) {
auto primes = MYCP::PrimeFactorization(n);
VLL ans;
VLL roop(primes.size(), 0);
LL i, j, k, m, size = roop.size();
while (true) {
LL a = 1;
for (i = 0; i < size; i++) {
for (j = 0; j < roop[i]; j++) {
a *= primes[i][0];
}
}
ans.push_back(a);
roop[0]++;
for (i = 0; i < size; i++) {
if (i + 1 < size) {
roop[i + 1] += (roop[i] / (primes[i][1] + 1));
}
roop[i] %= (primes[i][1] + 1);
}
bool flag = true;
for (i = 0; i < size; i++) {
if (roop[i] != 0)
flag = false;
}
if (flag)
break;
}
return MYCP::Sort(ans);
}
//組み合わせ nCr
static LL Combination(LL n, LL r) {
r = min(r, n - r);
VLL p(n + 1, 0);
LL i, j, k, a, b, c;
for (i = 1; i <= r; i++) {
auto temp = MYCP::PrimeFactorization(i);
temp = MYCP::VVLLturn(temp);
if (temp.size() == 0) {
temp = VVLL(2, VLL(0));
}
for (j = 0; j < temp[0].size(); j++) {
p[temp[0][j]] -= temp[1][j];
}
a = i + n - r;
temp = MYCP::PrimeFactorization(a);
temp = MYCP::VVLLturn(temp);
if (temp.size() == 0) {
temp = VVLL(2, VLL(0));
}
for (j = 0; j < temp[0].size(); j++) {
p[temp[0][j]] += temp[1][j];
}
}
LL result = 1;
for (i = 0; i < p.size(); i++) {
if (p[i] > 0) {
for (j = 0; j < p[i]; j++) {
result *= i;
result %= MYCP::MOD_CONST;
}
}
}
return result;
}
//符号
static LL sign(LL const x) {
if (x > 0)
return 1;
if (x < 0)
return -1;
return 0;
}
//円周率
static double PI() { return (double)3.1415926535898; }
//指定した桁でdoubleを出す。改行はしない。
static void CoutDoubleKeta(double a, LL keta) {
cout << setprecision(keta) << a << flush;
}
//コンテナクラスの出力
template <typename T> static T CoutVector(T const &ls) {
LL i, j, k, size = distance(ls.begin(), ls.end());
auto itr = ls.begin();
for (i = 0; i < size - 1; i++) {
cout << *itr << " " << flush;
itr++;
}
cout << *itr << flush;
return ls;
}
//コンテナクラスをソートする
template <typename T> static T Sort(T &ls) {
sort(ls.begin(), ls.end());
return ls;
}
//順序関数付きでコンテナクラスをソートする
template <typename T, typename F> static T Sort(T &ls, F func) {
sort(ls.begin(), ls.end(), func);
return ls;
}
//コンテナクラスを逆順に並び替える
template <typename T> static T Reverse(T &ls) {
reverse(ls.begin(), ls.end());
return ls;
}
//コンテナクラスの条件を満たす要素を数え上げる。bool func(S x)
template <typename T, typename S> static LL Count(T const &ls, S func) {
LL ans = 0;
auto itr = ls.begin();
while (itr != ls.end()) {
if (func(*itr))
ans++;
itr++;
}
return ans;
}
//コンテナクラスの要素をすべて更新する。S func(S x)
template <typename T, typename S> static T AllUpdate(T &ls, S func) {
auto itr = ls.begin();
while (itr != ls.end()) {
*itr = func(*itr);
itr++;
}
return ls;
}
//リストをベクターに変換する
template <typename T> static vector<T> FromListToVector(list<T> a) {
vector<T> ans;
for (auto itr = a.begin(); itr != a.end(); itr++) {
ans.push_back(*itr);
}
return ans;
}
//ベクターをリストに変換する
template <typename T> static list<T> FromVectorToList(vector<T> a) {
list<T> ans;
for (auto itr = a.begin(); itr != a.end(); itr++) {
ans.push_back(*itr);
}
return ans;
}
//デバッグ用出力
template <typename T> static LL DebugPrintf(T output) {
if (MYCP::DebugFlag) {
std::cout << output << endl;
}
return MYCP::DebugFlag;
}
//デバッグ用入力
static LL DebugCin() {
LL a;
if (MYCP::DebugFlag) {
cin >> a;
}
return a;
}
};
LL MYCP::DebugFlag = 0;
//累積和を求めるクラス
class Ruisekiwa {
private:
vector<LL> list;
public:
void MakeArray(vector<LL> data) {
LL i;
list = data;
list.push_back(0);
list[0] = 0;
for (i = 1; i < list.size(); i++) {
list[i] = list[i - 1] + data[i - 1];
}
}
LL Sum(LL start, LL end) {
if (end < start) {
std::cout << "startがendより大きいです";
return 0;
}
if (start < 0 || end >= list.size()) {
std::cout << "範囲が異常";
return 0;
}
return list[end] - list[start];
}
};
// n進数を管理するクラス
class N_Number {
public:
N_Number(LL n, LL keta) {
this->N_Shinsuu = n;
VLL temp(keta, 0);
this->numbers = temp;
}
//数を足す
void plus(LL a) {
if (a < 0) {
a *= (-1);
this->minus(a);
return;
}
this->numbers[0] += a;
LL size = this->numbers.size();
for (LL i = 0; i < size; i++) {
if (i + 1 < size) {
this->numbers[i + 1] += this->numbers[i] / this->N_Shinsuu;
}
this->numbers[i] %= this->N_Shinsuu;
}
}
//全ての桁が同じ数字になっていればその数字を返す。それ以外の場合は -1 を返す
LL check() {
LL a = this->numbers[0];
for (LL i = 0; i < this->numbers.size(); i++) {
if (this->numbers[i] != a)
return -1;
}
return a;
}
LL getNumber(LL keta) { return this->numbers[keta]; }
LL getKeta() { return this->numbers.size(); }
LL getShinsuu() { return this->N_Shinsuu; }
void setNumber(LL keta, LL number) {
if (0 <= number && number < this->getShinsuu()) {
if (0 <= keta && keta < this->getKeta()) {
this->numbers[keta] = number;
return;
}
}
cout << "er" << endl;
}
void setAllNumbers(LL number) {
LL size = this->getKeta(), i;
for (i = 0; i < size; i++) {
this->setNumber(i, number);
}
}
string to_string_KetaSoroe() {
string s = "";
for (LL i = this->getKeta() - 1; i >= 0; i--) {
s += to_string(this->getNumber(i));
}
return s;
}
private:
void minus(LL a) {
LL i, j, k, zettaiti = abs(a);
k = MYCP::KiriageWarizan(zettaiti, this->N_Shinsuu);
j = k * (this->N_Shinsuu - 1);
for (i = 0; i < this->getKeta(); i++) {
this->numbers[i] += j;
}
this->numbers[0] += k - a;
this->plus(0);
}
VLL numbers;
LL N_Shinsuu;
};
// UnionFind
class Union_Find {
private:
VLL tree;
VLL count;
LL root(LL a) {
if (this->tree[a] == a)
return a;
return this->tree[a] = this->root(this->tree[a]);
}
public:
Union_Find(LL n) {
VLL set(n);
this->tree = set;
this->count = set;
for (LL i = 0; i < n; i++) {
this->tree[i] = i;
this->count[i] = 1;
}
}
void unite(LL a, LL b) {
LL x, y;
if (!this->Check(a, b)) {
x = this->getCount(a) + getCount(b);
y = this->root(a);
this->count[y] = x;
y = this->root(b);
this->count[y] = x;
}
x = this->root(a);
y = this->root(b);
this->tree[x] = y;
}
bool Check(LL a, LL b) { return this->root(a) == this->root(b); }
LL getCount(LL index) {
LL temp = this->root(index);
return this->count[temp];
}
VLL getList() {
VLL ans(this->tree.size(), 0);
for (LL i = 0; i < ans.size(); i++) {
ans[i] = this->root(i);
}
return ans;
}
};
//プラスマイナス無限に対応したlong long型
class INF_LONG_LONG {
private:
LL inf, n;
public:
//コンストラクタ
INF_LONG_LONG(LL a) {
this->n = a;
this->inf = 0;
this->Syusei();
}
INF_LONG_LONG() { *this = INF_LONG_LONG(0); }
INF_LONG_LONG(INF_LONG_LONG const &a) {
this->n = a.n;
this->inf = a.inf;
this->Syusei();
}
//ゲッター
LL getN() const { return this->n; }
LL getInf() const { return this->inf; }
//正の無限大生成
static INF_LONG_LONG plus_inf() {
INF_LONG_LONG a;
a.n = 0;
a.inf = 1;
a.Syusei();
return a;
}
//負の無限大生成
static INF_LONG_LONG minus_inf() {
INF_LONG_LONG a;
a.n = 0;
a.inf = -1;
a.Syusei();
return a;
}
//符号を取得
LL sign() const {
if (this->inf != 0) {
return this->inf;
}
return MYCP::sign(this->n);
}
//代入演算子
INF_LONG_LONG operator=(INF_LONG_LONG const &b) {
this->n = b.n;
this->inf = b.inf;
this->Syusei();
return *this;
}
INF_LONG_LONG operator=(LL const &b) {
*this = INF_LONG_LONG(b);
this->Syusei();
return *this;
}
//比較演算子
bool operator==(INF_LONG_LONG const &b) const {
if (this->n == b.n && this->inf == b.inf)
return true;
return false;
}
bool operator!=(INF_LONG_LONG const &b) const { return !(*this == b); }
bool operator<(INF_LONG_LONG const &b) const {
if (this->inf < b.inf)
return true;
if (this->inf > b.inf)
return false;
return this->n < b.n;
}
bool operator>(INF_LONG_LONG const &b) const { return b < *this; }
bool operator<=(INF_LONG_LONG const &b) const { return !(*this > b); }
bool operator>=(INF_LONG_LONG const &b) const { return !(*this < b); }
//算術演算子
INF_LONG_LONG operator+(INF_LONG_LONG const &b) const {
if (max(this->inf, b.inf) > 0)
return INF_LONG_LONG::plus_inf();
if (min(this->inf, b.inf) < 0)
return INF_LONG_LONG::minus_inf();
auto ans = *this;
ans.n += b.n;
ans.Syusei();
return ans;
}
INF_LONG_LONG operator*(INF_LONG_LONG const &b) const {
if (*this == INF_LONG_LONG(0) || b == INF_LONG_LONG(0)) {
return INF_LONG_LONG(0);
}
if (this->inf != 0 || b.inf != 0) {
LL s = this->sign() * b.sign();
INF_LONG_LONG ans(0);
ans.n = 0;
ans.inf = s;
ans.Syusei();
return ans;
}
INF_LONG_LONG ans(0);
ans.n = this->n * b.n;
ans.Syusei();
return ans;
}
INF_LONG_LONG operator-(INF_LONG_LONG const &b) const {
auto ans = (*this + (INF_LONG_LONG(-1) * b));
ans.Syusei();
return ans;
}
INF_LONG_LONG operator/(INF_LONG_LONG const &b) const {
if (b == INF_LONG_LONG(0)) {
LL a = this->n / b.n;
return INF_LONG_LONG(a);
}
if (b.inf != 0) {
return INF_LONG_LONG(0);
}
if (*this == INF_LONG_LONG(0)) {
return INF_LONG_LONG(0);
}
if (this->inf != 0) {
LL s = this->sign() * b.sign();
return INF_LONG_LONG::plus_inf() * INF_LONG_LONG(s);
}
INF_LONG_LONG ans;
ans.n = this->n / b.n;
ans.Syusei();
return ans;
}
INF_LONG_LONG operator%(INF_LONG_LONG const &b) const {
if (this->inf == 0 && b.inf == 0) {
INF_LONG_LONG ans;
ans.n = this->n % b.n;
ans.Syusei();
return ans;
}
auto x = *this / b;
x.Syusei();
auto ans = *this - b * x;
ans.Syusei();
return ans;
}
//複合代入演算子
INF_LONG_LONG operator+=(INF_LONG_LONG const &b) {
auto ans = *this + b;
*this = ans;
return *this;
}
INF_LONG_LONG operator-=(INF_LONG_LONG const &b) {
auto ans = *this - b;
*this = ans;
return *this;
}
INF_LONG_LONG operator*=(INF_LONG_LONG const &b) {
auto ans = *this * b;
*this = ans;
return *this;
}
INF_LONG_LONG operator/=(INF_LONG_LONG const &b) {
auto ans = *this / b;
*this = ans;
return *this;
}
INF_LONG_LONG operator%=(INF_LONG_LONG const &b) {
auto ans = *this % b;
*this = ans;
return *this;
}
//符号演算子
INF_LONG_LONG operator+() const { return *this; }
INF_LONG_LONG operator-() const { return *this * INF_LONG_LONG(-1); }
//前置きインクリメント・デクリメント
INF_LONG_LONG operator++() {
this->n++;
this->Syusei();
return *this;
}
INF_LONG_LONG operator--() {
this->n--;
this->Syusei();
return *this;
}
//後置きインクリメント・デクリメント
INF_LONG_LONG operator++(int) {
auto copy = *this;
++(*this);
return copy;
}
INF_LONG_LONG operator--(int) {
auto copy = *this;
--(*this);
return copy;
}
//文字列への変換
string ToString() const {
if (this->inf == 1) {
return "+INF";
}
if (this->inf == -1) {
return "-INF";
}
return to_string(this->n);
}
private:
void Syusei() {
if (this->inf != 0) {
this->n = 0;
}
}
};
typedef INF_LONG_LONG ILL_TYPE;
typedef vector<ILL_TYPE> VILL_TYPE;
typedef vector<VILL_TYPE> VVILL_TYPE;
//ワーシャルフロイド
class WarshallFloyd {
public:
//最短距離を記録
VVILL_TYPE d;
//頂点数
LL v;
// vは頂点数、edge_cost_listは辺の情報{始点、終点、コスト}の配列。無向グラフの場合、逆矢印の辺に注意。
WarshallFloyd(LL v, VVLL edge_cost_list) {
this->v = v;
this->d = VVILL_TYPE(v, VILL_TYPE(v, ILL_TYPE::plus_inf()));
LL i, j, k, a, b, c;
for (i = 0; i < edge_cost_list.size(); i++) {
a = edge_cost_list[i][0];
b = edge_cost_list[i][1];
c = edge_cost_list[i][2];
this->d[a][b] = ILL_TYPE(c);
}
for (i = 0; i < v; i++) {
this->d[i][i] = ILL_TYPE(0);
}
//ここから計算
for (k = 0; k < v; k++) {
for (i = 0; i < v; i++) {
for (j = 0; j < v; j++) {
d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}
}
}
}
};
//ベルマンフォード
class BellmanFord {
public:
//辺のリスト
VVILL_TYPE edge;
//頂点数、辺数
LL v, e;
//始点
LL s;
//最短距離
VILL_TYPE d;
// vは頂点数、startは始点、edge_cost_listは辺の情報{始点、終点、コスト}の配列。
BellmanFord(LL v, LL start, VVLL edge_cost_list) {
this->v = v;
this->s = start;
this->e = edge_cost_list.size();
this->d = VILL_TYPE(v, ILL_TYPE::plus_inf());
this->d[start] = 0;
LL i, j, k;
for (i = 0; i < this->e; i++) {
VILL_TYPE temp;
LL a, b, c;
a = edge_cost_list[i][0];
b = edge_cost_list[i][1];
c = edge_cost_list[i][2];
temp.push_back(ILL_TYPE(a));
temp.push_back(ILL_TYPE(b));
temp.push_back(ILL_TYPE(c));
this->edge.push_back(temp);
}
this->DoUpdata();
auto cpy = this->d;
this->DoUpdata();
for (i = 0; i < this->d.size(); i++) {
if (this->d[i] != cpy[i]) {
this->d[i] = ILL_TYPE::minus_inf();
}
}
this->DoUpdata();
}
private:
void DoUpdata() {
LL i, j, k;
for (i = 0; i <= this->v; i++) {
bool update = true;
for (j = 0; j < this->e; j++) {
ILL_TYPE c;
LL a, b;
a = this->edge[j][0].getN();
b = this->edge[j][1].getN();
c = this->edge[j][2];
if (this->d[a] < ILL_TYPE::plus_inf()) {
if (this->d[a] + c < this->d[b]) {
update = false;
this->d[b] = this->d[a] + c;
}
}
}
if (update)
break;
}
}
};
//ダイクストラ
class Dijkstra {
public:
Dijkstra(LL v, LL start, VVLL edge_cost_list) {}
};
//ライブラリはここまで
//ここから下を書く
//ここからメイン
int main(void) {
MYCP::DebugFlag = 0;
LL i, j, k, n, m;
char ten = '.', shape = '#';
LL h, w;
cin >> h >> w;
VVLL s(h, VLL(w, 0));
VVLL ans1, ans2;
ans1 = ans2 = s;
for (i = 0; i < h; i++) {
string temp;
cin >> temp;
for (j = 0; j < w; j++) {
if (temp[j] == '#') {
s[i][j] = 1;
}
}
}
VLL ls;
LL count = 0;
for (i = 0; i < h; i++) {
count = 0;
for (j = 0; j < w; j++) {
if (s[i][j] == 0) {
count++;
ans1[i][j] = ls.size();
} else {
ls.push_back(count);
count = 0;
}
}
ls.push_back(count);
}
for (j = 0; j < w; j++) {
count = 0;
for (i = 0; i < h; i++) {
if (s[i][j] == 0) {
count++;
ans2[i][j] = ls.size();
} else {
ls.push_back(count);
count = 0;
}
}
ls.push_back(count);
}
LL mx = -1;
for (i = 0; i < h; i++) {
for (j = 0; j < w; j++) {
LL a, b;
a = ls[ans1[i][j]];
b = ls[ans2[i][j]];
mx = max(mx, a + b);
}
}
cout << mx - 1 << endl;
return 0;
}
| [
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 828,060 | 828,059 | u304318875 | cpp |
p03014 | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
#define debug(...) cout << "[" << #__VA_ARGS__ << ": " << __VA_ARGS__ << "]\n"
#define rd() abs((int)rng())
using namespace std;
using namespace __gnu_pbds;
template <class T>
using ordered_set =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int maxn = 2e3 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int n, m, up[maxn][maxn], down[maxn][maxn], lft[maxn][maxn], rgt[maxn][maxn];
int main() {
ios_base::sync_with_stdio(false), cin.tie(0);
cin >> n >> m;
for (int i = 1; i <= n; i++) {
string s;
cin >> s;
for (int j = 1; j <= m; j++) {
if (s[j - 1] == '.')
up[i][j] = down[i][j] = i, lft[i][j] = rgt[i][j] = j;
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++)
if (lft[i][j - 1] != 0 && lft[i][j] != 0)
lft[i][j] = lft[i][j - 1];
for (int j = n; j >= 1; j--)
if (rgt[i][j + 1] != 0 && rgt[i][j] != 0)
rgt[i][j] = rgt[i][j + 1];
}
for (int j = 1; j <= m; j++) {
for (int i = 1; i <= n; i++)
if (up[i - 1][j] != 0 && up[i][j] != 0)
up[i][j] = up[i - 1][j];
for (int i = n; i >= 1; i--)
if (down[i + 1][j] != 0 && down[i][j] != 0)
down[i][j] = down[i + 1][j];
}
int ans = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (up[i][j] != 0)
ans = max(ans, down[i][j] - up[i][j] + rgt[i][j] - lft[i][j] + 1);
}
}
cout << ans << "\n";
return 0;
} | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
#define debug(...) cout << "[" << #__VA_ARGS__ << ": " << __VA_ARGS__ << "]\n"
#define rd() abs((int)rng())
using namespace std;
using namespace __gnu_pbds;
template <class T>
using ordered_set =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int maxn = 2e3 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int n, m, up[maxn][maxn], down[maxn][maxn], lft[maxn][maxn], rgt[maxn][maxn];
int main() {
ios_base::sync_with_stdio(false), cin.tie(0);
cin >> n >> m;
for (int i = 1; i <= n; i++) {
string s;
cin >> s;
for (int j = 1; j <= m; j++) {
if (s[j - 1] == '.')
up[i][j] = down[i][j] = i, lft[i][j] = rgt[i][j] = j;
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++)
if (lft[i][j - 1] != 0 && lft[i][j] != 0)
lft[i][j] = lft[i][j - 1];
for (int j = m; j >= 1; j--)
if (rgt[i][j + 1] != 0 && rgt[i][j] != 0)
rgt[i][j] = rgt[i][j + 1];
}
for (int j = 1; j <= m; j++) {
for (int i = 1; i <= n; i++)
if (up[i - 1][j] != 0 && up[i][j] != 0)
up[i][j] = up[i - 1][j];
for (int i = n; i >= 1; i--)
if (down[i + 1][j] != 0 && down[i][j] != 0)
down[i][j] = down[i + 1][j];
}
int ans = 1;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (up[i][j] != 0)
ans = max(ans, down[i][j] - up[i][j] + rgt[i][j] - lft[i][j] + 1);
}
}
cout << ans << "\n";
return 0;
} | [
"variable_declaration.value.change",
"identifier.change",
"control_flow.loop.for.initializer.change",
"literal.number.change"
] | 828,064 | 828,065 | u710999236 | cpp |
p03014 | #include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int h, w;
cin >> h >> w;
vector<string> s(h);
for (int i = 0; i < h; i++) {
cin >> s[i];
}
vector<vector<int>> cnt(h, vector<int>(w));
for (int i = 0; i < h; i++) {
vector<int> done(w);
for (int j = 0; j < w; j++) {
if (s[i][j] == '#')
continue;
if (done[j])
continue;
int l = 0;
while (j + 1 < w) {
if (s[i][j + l] == '#')
break;
l++;
}
for (int k = 0; k < l; k++) {
cnt[i][j + k] += l;
done[j + k] = 1;
}
}
}
for (int j = 0; j < w; j++) {
vector<int> done(h);
for (int i = 0; i < h; i++) {
if (s[i][j] == '#')
continue;
if (done[i])
continue;
int l = 0;
while (i + l < h) {
if (s[i + l][j] == '#')
break;
l++;
}
for (int k = 0; k < l; k++) {
cnt[i + k][j] += l;
done[i + k] = 1;
}
}
}
int ans = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
ans = max(ans, cnt[i][j] - 1);
}
}
cout << ans << endl;
return 0;
}
| #include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int h, w;
cin >> h >> w;
vector<string> s(h);
for (int i = 0; i < h; i++) {
cin >> s[i];
}
vector<vector<int>> cnt(h, vector<int>(w));
for (int i = 0; i < h; i++) {
vector<int> done(w);
for (int j = 0; j < w; j++) {
if (s[i][j] == '#')
continue;
if (done[j])
continue;
int l = 0;
while (j + l < w) {
if (s[i][j + l] == '#')
break;
l++;
}
for (int k = 0; k < l; k++) {
cnt[i][j + k] += l;
done[j + k] = 1;
}
}
}
for (int j = 0; j < w; j++) {
vector<int> done(h);
for (int i = 0; i < h; i++) {
if (s[i][j] == '#')
continue;
if (done[i])
continue;
int l = 0;
while (i + l < h) {
if (s[i + l][j] == '#')
break;
l++;
}
for (int k = 0; k < l; k++) {
cnt[i + k][j] += l;
done[i + k] = 1;
}
}
}
int ans = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
ans = max(ans, cnt[i][j] - 1);
}
}
cout << ans << endl;
return 0;
}
| [
"identifier.replace.add",
"literal.replace.remove",
"control_flow.loop.condition.change"
] | 828,088 | 828,089 | u272395350 | cpp |
p03014 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2005;
ll a[maxn][maxn];
ll b[maxn][maxn];
string s[maxn];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n, m;
cin >> n >> m;
for (int i = 0; i < n; ++i) {
cin >> s[i];
}
for (int i = 0; i < n; ++i) {
ll tmp = 0;
for (int j = 0; j < m; ++j) {
if (s[i][j] == '.')
tmp++;
else
tmp = 0;
a[i][j] = tmp;
}
}
for (int j = 0; j < m; ++j) {
ll tmp = 0;
for (int i = 0; i < m; ++i) {
if (s[i][j] == '.')
tmp++;
else
tmp = 0;
b[i][j] = tmp;
}
}
ll mx = -1;
for (int i = n - 1; i >= 0; --i) {
for (int j = m - 1; j >= 0; --j) {
if (j < m - 1 && a[i][j])
a[i][j] = max(a[i][j], a[i][j + 1]);
if (i < n - 1 && b[i][j])
b[i][j] = max(b[i][j], b[i + 1][j]);
mx = max(mx, (a[i][j] + b[i][j] - 1));
}
}
cout << mx << endl;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2005;
ll a[maxn][maxn];
ll b[maxn][maxn];
string s[maxn];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n, m;
cin >> n >> m;
for (int i = 0; i < n; ++i) {
cin >> s[i];
}
for (int i = 0; i < n; ++i) {
ll tmp = 0;
for (int j = 0; j < m; ++j) {
if (s[i][j] == '.')
tmp++;
else
tmp = 0;
a[i][j] = tmp;
}
}
for (int j = 0; j < m; ++j) {
ll tmp = 0;
for (int i = 0; i < n; ++i) {
if (s[i][j] == '.')
tmp++;
else
tmp = 0;
b[i][j] = tmp;
}
}
ll mx = -1;
for (int i = n - 1; i >= 0; --i) {
for (int j = m - 1; j >= 0; --j) {
if (j < m - 1 && a[i][j])
a[i][j] = max(a[i][j], a[i][j + 1]);
if (i < n - 1 && b[i][j])
b[i][j] = max(b[i][j], b[i + 1][j]);
mx = max(mx, (a[i][j] + b[i][j] - 1));
}
}
cout << mx << endl;
}
| [
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 828,101 | 828,102 | u976418120 | cpp |
p03014 | #include <bits/stdc++.h>
using namespace std;
#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename
using ll = long long;
using ull = unsigned long long;
TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;
TPL<TNM T> inline istream &operator>>(istream &is, vector<T> &vec) {
for (T &x : vec)
is >> x;
return is;
}
TPL<TNM V, TNM H> void resize(vector<V> &_v, const H _h) { _v.resize(_h); }
TPL<TNM V, TNM H, TNM... T> void resize(vector<V> &_v, const H &_h,
const T &..._t) {
_v.resize(_h);
for (auto &__v : _v)
resize(__v, _t...);
}
TPL<TNM V, TNM T> TNM enable_if<!is_class<V>::value>::type fill(vector<V> &_v,
const T &_t) {
std::fill(ALL(_v), _t);
}
TPL<TNM V, TNM T> TNM enable_if<is_class<V>::value>::type fill(vector<V> &_v,
const T &_t) {
for (auto &_e : _v)
fill(_e, _t);
}
TPL<TNM T> inline void UNIQUE(vector<T> &_v) {
sort(ALL(_v));
_v.erase(unique(ALL(_v)), _v.end());
}
struct pre_ {
pre_() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << fixed << setprecision(6);
}
} pre__;
const char O = '#';
const char F = '.';
struct UnionFind {
vector<int> data;
UnionFind(){};
UnionFind(int size) : data(size, -1) {}
bool unionSet(int x, int y) {
x = root(x);
y = root(y);
if (x != y) {
if (data[y] < data[x])
swap(x, y);
data[x] += data[y];
data[y] = x;
}
return x != y;
}
bool findSet(int x, int y) { return root(x) == root(y); }
int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
int size(int x) { return -data[root(x)]; }
};
int main(void) {
int H, W;
cin >> H >> W;
vec<string> MAP;
resize(MAP, H);
for (int i = 0; i < H; ++i) {
cin >> MAP[i];
}
vec<UnionFind> uW(H, UnionFind(2000 + 1));
vec<UnionFind> uH(W, UnionFind(2000 + 1));
for (int i = 0; i < H; ++i) {
for (int j = 0; j < W - 1; ++j) {
if (MAP[i][j] == F && MAP[i][j + 1] == F) {
uW[i].unionSet(j, j + 1);
}
}
}
for (int j = 0; j < W; ++j) {
for (int i = 0; i < H - 1; ++i) {
if (MAP[i][j] == F && MAP[i + 1][j] == F) {
uH[j].unionSet(i, i + 1);
}
}
}
int ans = 0;
for (int i = 0; i < H; ++i) {
for (int j = 0; j < W; ++j) {
int sum = uH[j].size(j) + uW[i].size(i);
ans = max(ans, sum);
}
}
cout << ans - 1 << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename
using ll = long long;
using ull = unsigned long long;
TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;
TPL<TNM T> inline istream &operator>>(istream &is, vector<T> &vec) {
for (T &x : vec)
is >> x;
return is;
}
TPL<TNM V, TNM H> void resize(vector<V> &_v, const H _h) { _v.resize(_h); }
TPL<TNM V, TNM H, TNM... T> void resize(vector<V> &_v, const H &_h,
const T &..._t) {
_v.resize(_h);
for (auto &__v : _v)
resize(__v, _t...);
}
TPL<TNM V, TNM T> TNM enable_if<!is_class<V>::value>::type fill(vector<V> &_v,
const T &_t) {
std::fill(ALL(_v), _t);
}
TPL<TNM V, TNM T> TNM enable_if<is_class<V>::value>::type fill(vector<V> &_v,
const T &_t) {
for (auto &_e : _v)
fill(_e, _t);
}
TPL<TNM T> inline void UNIQUE(vector<T> &_v) {
sort(ALL(_v));
_v.erase(unique(ALL(_v)), _v.end());
}
struct pre_ {
pre_() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << fixed << setprecision(6);
}
} pre__;
const char O = '#';
const char F = '.';
struct UnionFind {
vector<int> data;
UnionFind(){};
UnionFind(int size) : data(size, -1) {}
bool unionSet(int x, int y) {
x = root(x);
y = root(y);
if (x != y) {
if (data[y] < data[x])
swap(x, y);
data[x] += data[y];
data[y] = x;
}
return x != y;
}
bool findSet(int x, int y) { return root(x) == root(y); }
int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
int size(int x) { return -data[root(x)]; }
};
int main(void) {
int H, W;
cin >> H >> W;
vec<string> MAP;
resize(MAP, H);
for (int i = 0; i < H; ++i) {
cin >> MAP[i];
}
vec<UnionFind> uW(H, UnionFind(2000 + 1));
vec<UnionFind> uH(W, UnionFind(2000 + 1));
for (int i = 0; i < H; ++i) {
for (int j = 0; j < W - 1; ++j) {
if (MAP[i][j] == F && MAP[i][j + 1] == F) {
uW[i].unionSet(j, j + 1);
}
}
}
for (int j = 0; j < W; ++j) {
for (int i = 0; i < H - 1; ++i) {
if (MAP[i][j] == F && MAP[i + 1][j] == F) {
uH[j].unionSet(i, i + 1);
}
}
}
int ans = 0;
for (int i = 0; i < H; ++i) {
for (int j = 0; j < W; ++j) {
int sum = uH[j].size(i) + uW[i].size(j);
ans = max(ans, sum);
}
}
cout << ans - 1 << endl;
return 0;
} | [
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 828,107 | 828,108 | u582351638 | cpp |
p03014 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long int i = 0; i < n; ++i)
typedef long long int ll;
int main() {
int h, w;
cin >> h >> w;
vector<string> s(h);
rep(i, h) { cin >> s[i]; }
vector<vector<int>> r(h, vector<int>(w, 0)), l(h, vector<int>(w, 0));
vector<vector<int>> u(w, vector<int>(h, 0)), d(w, vector<int>(h, 0));
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if (j == 0 || s[i][j - 1] == '#') {
l[i][j] = 0;
} else {
l[i][j] = l[i][j - 1] + 1;
}
}
}
for (int i = 0; i < h; i++) {
for (int j = w - 1; j >= 0; j--) {
if (j == w - 1 || s[i][j + 1] == '#') {
r[i][j] = 0;
} else {
r[i][j] = r[i][j + 1] + 1;
}
}
}
for (int i = 0; i < w; i++) {
for (int j = 0; j < h; j++) {
if (j == 0 || s[j - 1][i] == '#') {
u[j][i] = 0;
} else {
u[j][i] = u[j - 1][i] + 1;
}
}
}
for (int i = 0; i < w; i++) {
for (int j = h - 1; j >= 0; j--) {
if (j == h - 1 || s[j + 1][i] == '#') {
d[j][i] = 0;
} else {
d[j][i] = d[j + 1][i] + 1;
}
}
}
int ans = 0;
rep(i, h) {
rep(j, w) {
if (s[i][j] != '#') {
int tt;
tt = u[i][j] + d[i][j] + l[i][j] + r[i][j];
tt++;
ans = max(tt, ans);
}
}
}
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long int i = 0; i < n; ++i)
typedef long long int ll;
int main() {
int h, w;
cin >> h >> w;
vector<string> s(h);
rep(i, h) { cin >> s[i]; }
vector<vector<int>> r(h, vector<int>(w, 0)), l(h, vector<int>(w, 0));
vector<vector<int>> u(h, vector<int>(w, 0)), d(h, vector<int>(w, 0));
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if (j == 0 || s[i][j - 1] == '#') {
l[i][j] = 0;
} else {
l[i][j] = l[i][j - 1] + 1;
}
}
}
for (int i = 0; i < h; i++) {
for (int j = w - 1; j >= 0; j--) {
if (j == w - 1 || s[i][j + 1] == '#') {
r[i][j] = 0;
} else {
r[i][j] = r[i][j + 1] + 1;
}
}
}
for (int i = 0; i < w; i++) {
for (int j = 0; j < h; j++) {
if (j == 0 || s[j - 1][i] == '#') {
u[j][i] = 0;
} else {
u[j][i] = u[j - 1][i] + 1;
}
}
}
for (int i = 0; i < w; i++) {
for (int j = h - 1; j >= 0; j--) {
if (j == h - 1 || s[j + 1][i] == '#') {
d[j][i] = 0;
} else {
d[j][i] = d[j + 1][i] + 1;
}
}
}
int ans = 0;
rep(i, h) {
rep(j, w) {
if (s[i][j] != '#') {
int tt;
tt = u[i][j] + d[i][j] + l[i][j] + r[i][j];
tt++;
ans = max(tt, ans);
}
}
}
cout << ans << endl;
return 0;
}
| [
"identifier.change",
"call.arguments.change"
] | 828,109 | 828,110 | u376817785 | cpp |
p03014 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long int i = 0; i < n; ++i)
typedef long long int ll;
int main() {
int h, w;
cin >> h >> w;
vector<string> s(h);
rep(i, h) { cin >> s[i]; }
vector<vector<int>> r(w, vector<int>(w, 0)), l(w, vector<int>(w, 0));
vector<vector<int>> u(h, vector<int>(h, 0)), d(h, vector<int>(h, 0));
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if (j == 0 || s[i][j - 1] == '#') {
l[i][j] = 0;
} else {
l[i][j] = l[i][j - 1] + 1;
}
}
}
for (int i = 0; i < h; i++) {
for (int j = w - 1; j >= 0; j--) {
if (j == w - 1 || s[i][j + 1] == '#') {
r[i][j] = 0;
} else {
r[i][j] = r[i][j + 1] + 1;
}
}
}
for (int i = 0; i < w; i++) {
for (int j = 0; j < h; j++) {
if (j == 0 || s[j - 1][i] == '#') {
u[j][i] = 0;
} else {
u[j][i] = u[j - 1][i] + 1;
}
}
}
for (int i = 0; i < w; i++) {
for (int j = h - 1; j >= 0; j--) {
if (j == h - 1 || s[j + 1][i] == '#') {
d[j][i] = 0;
} else {
d[j][i] = d[j + 1][i] + 1;
}
}
}
int ans = 0;
rep(i, h) {
rep(j, w) {
if (s[i][j] != '#') {
int tt;
tt = u[i][j] + d[i][j] + l[i][j] + r[i][j];
tt++;
ans = max(tt, ans);
}
}
}
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long int i = 0; i < n; ++i)
typedef long long int ll;
int main() {
int h, w;
cin >> h >> w;
vector<string> s(h);
rep(i, h) { cin >> s[i]; }
vector<vector<int>> r(h, vector<int>(w, 0)), l(h, vector<int>(w, 0));
vector<vector<int>> u(h, vector<int>(w, 0)), d(h, vector<int>(w, 0));
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if (j == 0 || s[i][j - 1] == '#') {
l[i][j] = 0;
} else {
l[i][j] = l[i][j - 1] + 1;
}
}
}
for (int i = 0; i < h; i++) {
for (int j = w - 1; j >= 0; j--) {
if (j == w - 1 || s[i][j + 1] == '#') {
r[i][j] = 0;
} else {
r[i][j] = r[i][j + 1] + 1;
}
}
}
for (int i = 0; i < w; i++) {
for (int j = 0; j < h; j++) {
if (j == 0 || s[j - 1][i] == '#') {
u[j][i] = 0;
} else {
u[j][i] = u[j - 1][i] + 1;
}
}
}
for (int i = 0; i < w; i++) {
for (int j = h - 1; j >= 0; j--) {
if (j == h - 1 || s[j + 1][i] == '#') {
d[j][i] = 0;
} else {
d[j][i] = d[j + 1][i] + 1;
}
}
}
int ans = 0;
rep(i, h) {
rep(j, w) {
if (s[i][j] != '#') {
int tt;
tt = u[i][j] + d[i][j] + l[i][j] + r[i][j];
tt++;
ans = max(tt, ans);
}
}
}
cout << ans << endl;
return 0;
}
| [
"identifier.change",
"call.arguments.change"
] | 828,111 | 828,110 | u376817785 | cpp |
p03014 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long int i = 0; i < n; ++i)
typedef long long int ll;
int main() {
int h, w;
cin >> h >> w;
vector<string> s(h);
rep(i, h) { cin >> s[i]; }
vector<vector<int>> x(w), y(h);
rep(i, h) {
rep(j, w) {
if (s[i][j] == '#') {
x[j].push_back(i);
}
}
}
rep(i, w) {
rep(j, h) {
if (s[j][i] == '#') {
y[j].push_back(i);
}
}
}
rep(i, w) { sort(x[i].begin(), x[i].end()); }
rep(i, h) { sort(y[i].begin(), y[i].end()); }
int ans = 0;
rep(i, h) {
rep(j, w) {
if (s[i][j] != '#') {
int tt = 0;
auto xx = lower_bound(x[j].begin(), x[j].end(), i);
auto yy = lower_bound(y[i].begin(), y[i].end(), j);
if (x[j].size() == 0) {
tt += h - 1;
} else if (xx != x[j].begin() && xx != x[j].end()) {
tt += *xx;
xx--;
tt -= *xx;
tt--;
} else if (xx == x[j].begin()) {
tt += (*xx) - 1;
} else if (xx == x[j].end()) {
xx--;
tt += h - (*xx) - 2;
}
if (y[i].size() == 0) {
tt += w - 1;
} else if (yy != y[i].begin() && yy != y[i].end()) {
tt += *yy;
yy--;
tt -= *yy;
tt--;
} else if (yy == y[i].begin()) {
tt += (*yy) - 1;
} else if (yy == y[i].end()) {
yy--;
tt += w - (*yy) - 2;
}
tt++;
/*if(ans<tt){
cout << i <<" " << j << endl;
}*/
ans = max(ans, tt);
}
}
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long int i = 0; i < n; ++i)
typedef long long int ll;
int main() {
int h, w;
cin >> h >> w;
vector<string> s(h);
rep(i, h) { cin >> s[i]; }
vector<vector<int>> x(w), y(h);
rep(i, h) {
rep(j, w) {
if (s[i][j] == '#') {
x[j].push_back(i);
}
}
}
rep(i, w) {
rep(j, h) {
if (s[j][i] == '#') {
y[j].push_back(i);
}
}
}
rep(i, w) { sort(x[i].begin(), x[i].end()); }
rep(i, h) { sort(y[i].begin(), y[i].end()); }
int ans = 0;
rep(i, h) {
rep(j, w) {
if (s[i][j] != '#') {
int tt = 0;
auto xx = lower_bound(x[j].begin(), x[j].end(), i);
auto yy = lower_bound(y[i].begin(), y[i].end(), j);
if (x[j].size() == 0) {
tt += h - 1;
} else if (xx != x[j].begin() && xx != x[j].end()) {
tt += *xx;
xx--;
tt -= *xx + 1;
tt--;
// if(i==3&&j==3)cout << tt << endl;
} else if (xx == x[j].begin()) {
tt += (*xx) - 1;
} else if (xx == x[j].end()) {
xx--;
tt += h - (*xx) - 2;
}
if (y[i].size() == 0) {
tt += w - 1;
} else if (yy != y[i].begin() && yy != y[i].end()) {
tt += *yy;
yy--;
tt -= *yy + 1;
tt--;
} else if (yy == y[i].begin()) {
tt += (*yy) - 1;
} else if (yy == y[i].end()) {
yy--;
tt += w - (*yy) - 2;
}
tt++;
// if(ans<tt){
// cout << i <<" " << j << endl;
//}
ans = max(ans, tt);
}
}
}
cout << ans << endl;
return 0;
} | [
"assignment.change"
] | 828,112 | 828,113 | u376817785 | cpp |
p03014 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
int main() {
int h, w;
cin >> h >> w;
vector<string> s(h);
rep(i, h) cin >> s[i];
vector<vector<int>> cnt(h, vector<int>(w));
rep(i, h) {
vector<int> done(w);
rep(j, w) {
if (s[i][j] == '#')
continue;
if (done[j])
continue;
int l = 0;
while (j + l < w) {
if (s[i][j + l] == '#')
break;
++l;
}
rep(k, l) {
cnt[i][j + k] += l;
done[j + k] = 1;
}
}
}
rep(j, w) {
vector<int> done(h);
rep(i, h) {
if (s[i][j] == '#')
continue;
if (done[i])
continue;
int l = 0;
while (j + l < w) {
if (s[i][j + l] == '#')
break;
++l;
}
rep(k, l) {
cnt[i + k][j] += l;
done[i + k] = 1;
}
}
}
int ans = 0;
rep(i, h) rep(j, w) ans = max(ans, cnt[i][j] - 1);
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
int main() {
int h, w;
cin >> h >> w;
vector<string> s(h);
rep(i, h) cin >> s[i];
vector<vector<int>> cnt(h, vector<int>(w));
rep(i, h) {
vector<int> done(w);
rep(j, w) {
if (s[i][j] == '#')
continue;
if (done[j])
continue;
int l = 0;
while (j + l < w) {
if (s[i][j + l] == '#')
break;
++l;
}
rep(k, l) {
cnt[i][j + k] += l;
done[j + k] = 1;
}
}
}
rep(j, w) {
vector<int> done(h);
rep(i, h) {
if (s[i][j] == '#')
continue;
if (done[i])
continue;
int l = 0;
while (i + l < h) {
if (s[i + l][j] == '#')
break;
++l;
}
rep(k, l) {
cnt[i + k][j] += l;
done[i + k] = 1;
}
}
}
int ans = 0;
rep(i, h) rep(j, w) ans = max(ans, cnt[i][j] - 1);
cout << ans << endl;
return 0;
}
| [
"identifier.change",
"control_flow.loop.condition.change",
"control_flow.branch.if.condition.change",
"expression.operation.binary.remove"
] | 828,131 | 828,132 | u187491596 | cpp |
p03014 | #include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
#define REP(i, n) for (ll i = 0; i < n; i++)
ll h, w;
vector<string> s;
vector<vector<ll>> y_c, x_c;
ll yy, xx;
ll dfs1(ll y, ll x, ll cnt) {
yy = max(yy, y);
if (y >= h || s[y][x] == '#')
return cnt;
return y_c[y][x] = dfs1(y + 1, x, cnt + 1);
}
ll dfs2(ll y, ll x, ll cnt) {
xx = max(xx, x);
if (x >= w || s[y][x] == '#')
return cnt;
return x_c[y][x] = dfs2(y, x + 1, cnt + 1);
}
int main() {
cin >> h >> w;
s.resize(h);
REP(i, h) { cin >> s[i]; }
y_c.resize(h, vector<ll>(w));
x_c.resize(h, vector<ll>(w));
REP(j, w) {
yy = 0;
ll i = 0;
while (i < h) {
dfs1(i, j, 0);
i = yy + 1;
}
}
REP(i, h) {
xx = 0;
ll j = 0;
while (j < h) {
dfs2(i, j, 0);
j = xx + 1;
}
}
ll ans = 0;
REP(i, h) {
REP(j, w) { ans = max(ans, y_c[i][j] + x_c[i][j] - 1); }
}
cout << ans << endl;
} | #include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
#define REP(i, n) for (ll i = 0; i < n; i++)
ll h, w;
vector<string> s;
vector<vector<ll>> y_c, x_c;
ll yy, xx;
ll dfs1(ll y, ll x, ll cnt) {
yy = max(yy, y);
if (y >= h || s[y][x] == '#')
return cnt;
return y_c[y][x] = dfs1(y + 1, x, cnt + 1);
}
ll dfs2(ll y, ll x, ll cnt) {
xx = max(xx, x);
if (x >= w || s[y][x] == '#')
return cnt;
return x_c[y][x] = dfs2(y, x + 1, cnt + 1);
}
int main() {
cin >> h >> w;
s.resize(h);
REP(i, h) { cin >> s[i]; }
y_c.resize(h, vector<ll>(w));
x_c.resize(h, vector<ll>(w));
REP(j, w) {
yy = 0;
ll i = 0;
while (i < h) {
dfs1(i, j, 0);
i = yy + 1;
}
}
REP(i, h) {
xx = 0;
ll j = 0;
while (j < w) {
dfs2(i, j, 0);
j = xx + 1;
}
}
ll ans = 0;
REP(i, h) {
REP(j, w) { ans = max(ans, y_c[i][j] + x_c[i][j] - 1); }
}
cout << ans << endl;
} | [
"identifier.change",
"control_flow.loop.condition.change"
] | 828,143 | 828,144 | u711985352 | cpp |
p03014 | //=template==================================================================//
// include
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <sstream>
#include <string>
#include <vector>
// namespace
using namespace std;
// define
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define REP(i, n) FOR(i, 0, n)
#define MIN_V(v) *min_element(v.begin(), v.end())
#define MAX_V(v) *max_element(v.begin(), v.end())
// typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef long long LL;
typedef unsigned long long ULL;
// conversion
inline int toInt(string s) {
int v;
istringstream sin(s);
sin >> v;
return v;
}
inline int countChar(string s, char c) {
int cnt, i;
cnt = 0;
REP(i, s.size()) {
if (s[i] == c)
cnt++;
}
return cnt;
}
template <class T> inline string toString(T x) {
ostringstream sout;
sout << x;
return sout.str();
}
//===========================================================================//
//=function prototype========================================================//
//===========================================================================//
//=variables=================================================================//
//===========================================================================//
int main(void) {
// Scan begin.
int h, w;
cin >> h >> w;
VS s(h);
REP(i, h) { cin >> s[i]; }
VVI vertical(w, VI(h));
VVI horizontal(h, VI(w));
// Scan done.
// Code begin.
REP(x, w) {
int idx = 0;
REP(y, h) {
if (s[y][x] == '#') {
FOR(i, idx, y) { vertical[x][i] = y - idx; }
idx = y + 1;
continue;
}
if (y == h - 1) {
FOR(i, idx, y) { vertical[x][i] = y - idx + 1; }
}
}
}
REP(y, h) {
int idx = 0;
REP(x, w) {
if (s[y][x] == '#') {
FOR(i, idx, x) { horizontal[y][i] = x - idx; }
idx = x + 1;
continue;
}
if (x == w - 1) {
FOR(i, idx, x) { horizontal[y][i] = x - idx + 1; }
}
}
}
int maxim = 0;
REP(y, h) {
REP(x, w) { maxim = max(maxim, vertical[x][y] + horizontal[y][x] - 1); }
}
cout << maxim << endl;
// Code done.
return 0;
}
//=functions=================================================================//
//===========================================================================// | //=template==================================================================//
// include
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <sstream>
#include <string>
#include <vector>
// namespace
using namespace std;
// define
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define REP(i, n) FOR(i, 0, n)
#define MIN_V(v) *min_element(v.begin(), v.end())
#define MAX_V(v) *max_element(v.begin(), v.end())
// typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef long long LL;
typedef unsigned long long ULL;
// conversion
inline int toInt(string s) {
int v;
istringstream sin(s);
sin >> v;
return v;
}
inline int countChar(string s, char c) {
int cnt, i;
cnt = 0;
REP(i, s.size()) {
if (s[i] == c)
cnt++;
}
return cnt;
}
template <class T> inline string toString(T x) {
ostringstream sout;
sout << x;
return sout.str();
}
//===========================================================================//
//=function prototype========================================================//
//===========================================================================//
//=variables=================================================================//
//===========================================================================//
int main(void) {
// Scan begin.
int h, w;
cin >> h >> w;
VS s(h);
REP(i, h) { cin >> s[i]; }
VVI vertical(w, VI(h));
VVI horizontal(h, VI(w));
// Scan done.
// Code begin.
REP(x, w) {
int idx = 0;
REP(y, h) {
if (s[y][x] == '#') {
FOR(i, idx, y) { vertical[x][i] = y - idx; }
idx = y + 1;
continue;
}
if (y == h - 1) {
FOR(i, idx, h) { vertical[x][i] = y - idx + 1; }
}
}
}
REP(y, h) {
int idx = 0;
REP(x, w) {
if (s[y][x] == '#') {
FOR(i, idx, x) { horizontal[y][i] = x - idx; }
idx = x + 1;
continue;
}
if (x == w - 1) {
FOR(i, idx, w) { horizontal[y][i] = x - idx + 1; }
}
}
}
int maxim = 0;
REP(y, h) {
REP(x, w) { maxim = max(maxim, vertical[x][y] + horizontal[y][x] - 1); }
}
cout << maxim << endl;
// Code done.
return 0;
}
//=functions=================================================================//
//===========================================================================// | [] | 828,145 | 828,146 | u585181206 | cpp |
p03014 | #include <algorithm>
#include <iostream>
#include <queue>
#include <string>
using namespace std;
string grid[2001];
int vert[2001][2001];
int hori[2001][2001];
int main() {
int h, w;
cin >> h >> w;
for (int i = 0; i < h; i++) {
cin >> grid[i];
}
// vertical
for (int x = 0; x < w; x++) {
int range = 0;
int light_begin = 0;
for (int y = 0; y < w; y++) {
if (grid[y][x] == '.') {
range++;
if (y == h - 1) {
for (int i = light_begin; i <= y; i++) {
vert[i][x] = range;
}
}
} else {
vert[y][x] = 0;
for (int i = light_begin; i < y; i++) {
vert[i][x] = range;
}
light_begin = y + 1;
range = 0;
}
}
}
// horizontal
for (int y = 0; y < h; y++) {
int range = 0;
int light_begin = 0;
for (int x = 0; x < w; x++) {
if (grid[y][x] == '.') {
range++;
if (x == w - 1) {
for (int i = light_begin; i <= x; i++) {
hori[y][i] = range;
}
}
} else {
hori[y][x] = 0;
for (int i = light_begin; i < x; i++) {
hori[y][i] = range;
}
light_begin = x + 1;
range = 0;
}
}
}
int ans = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
ans = max(ans, vert[i][j] + hori[i][j] - 1);
}
}
cout << ans << endl;
}
| #include <algorithm>
#include <iostream>
#include <queue>
#include <string>
using namespace std;
string grid[2001];
int vert[2001][2001];
int hori[2001][2001];
int main() {
int h, w;
cin >> h >> w;
for (int i = 0; i < h; i++) {
cin >> grid[i];
}
// vertical
for (int x = 0; x < w; x++) {
int range = 0;
int light_begin = 0;
for (int y = 0; y < h; y++) {
if (grid[y][x] == '.') {
range++;
if (y == h - 1) {
for (int i = light_begin; i <= y; i++) {
vert[i][x] = range;
}
}
} else {
vert[y][x] = 0;
for (int i = light_begin; i < y; i++) {
vert[i][x] = range;
}
light_begin = y + 1;
range = 0;
}
}
}
// horizontal
for (int y = 0; y < h; y++) {
int range = 0;
int light_begin = 0;
for (int x = 0; x < w; x++) {
if (grid[y][x] == '.') {
range++;
if (x == w - 1) {
for (int i = light_begin; i <= x; i++) {
hori[y][i] = range;
}
}
} else {
hori[y][x] = 0;
for (int i = light_begin; i < x; i++) {
hori[y][i] = range;
}
light_begin = x + 1;
range = 0;
}
}
}
int ans = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
ans = max(ans, vert[i][j] + hori[i][j] - 1);
}
}
cout << ans << endl;
}
| [
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 828,147 | 828,148 | u911446944 | cpp |
p03014 | #include <iostream>
using namespace std;
typedef struct pointT {
int *h;
int *v;
int sho;
} point;
int main() {
int h, w;
cin >> h >> w;
point *map = new point[h * w];
int *tmp = new int[2 * h * w];
tmp[0] = 0;
int tmp_cnt = 1;
char c;
for (int i = 0; i < h * w; i++) {
cin >> c;
map[i].h = 0;
map[i].v = 0;
map[i].sho = c == '#' ? 1 : 0;
}
for (int i = 0, k = 0, cnt = 0; i < h; i++, k += w) {
for (int j = 0; j < w; j++) {
if (!map[k + j].sho) {
cnt++;
map[k + j].h = &tmp[tmp_cnt];
} else {
if (cnt > 0) {
tmp[tmp_cnt] = cnt;
tmp_cnt++;
}
map[k + j].h = &tmp[0];
cnt = 0;
}
}
if (cnt > 0) {
tmp[tmp_cnt] = cnt;
tmp_cnt++;
cnt = 0;
}
}
for (int i = 0, cnt = 0; i < w; i++) {
for (int j = 0; j < h; j++) {
if (!map[i + j * w].sho) {
cnt++;
map[i + j * w].v = &tmp[tmp_cnt];
} else {
if (cnt > 0) {
tmp[tmp_cnt] = cnt;
tmp_cnt++;
}
map[i + j * w].v = &tmp[0];
}
}
if (cnt > 0) {
tmp[tmp_cnt] = cnt;
tmp_cnt++;
}
cnt = 0;
}
int max = 0;
for (int i = 0; i < w; i++) {
for (int j = 0; j < h; j++) {
point *m = &map[i + j * w];
// cout << "(" << *m->h << "," << *m->v << ") ";
if (max < *m->h + *m->v) {
max = *m->h + *m->v;
// cout << "(" << i << "," << j << ") : " << max << endl;
}
}
// cout << endl;
}
cout << max - 1 << endl;
} | #include <iostream>
using namespace std;
typedef struct pointT {
int *h;
int *v;
int sho;
} point;
int main() {
int h, w;
cin >> h >> w;
point *map = new point[h * w];
int *tmp = new int[2 * h * w];
tmp[0] = 0;
int tmp_cnt = 1;
char c;
for (int i = 0; i < h * w; i++) {
cin >> c;
map[i].h = 0;
map[i].v = 0;
map[i].sho = c == '#' ? 1 : 0;
}
for (int i = 0, k = 0, cnt = 0; i < h; i++, k += w) {
for (int j = 0; j < w; j++) {
if (!map[k + j].sho) {
cnt++;
map[k + j].h = &tmp[tmp_cnt];
} else {
if (cnt > 0) {
tmp[tmp_cnt] = cnt;
tmp_cnt++;
}
map[k + j].h = &tmp[0];
cnt = 0;
}
}
if (cnt > 0) {
tmp[tmp_cnt] = cnt;
tmp_cnt++;
cnt = 0;
}
}
for (int i = 0, cnt = 0; i < w; i++) {
for (int j = 0; j < h; j++) {
if (!map[i + j * w].sho) {
cnt++;
map[i + j * w].v = &tmp[tmp_cnt];
} else {
if (cnt > 0) {
tmp[tmp_cnt] = cnt;
tmp_cnt++;
}
map[i + j * w].v = &tmp[0];
cnt = 0;
}
}
if (cnt > 0) {
tmp[tmp_cnt] = cnt;
tmp_cnt++;
}
cnt = 0;
}
int max = 0;
for (int i = 0; i < w; i++) {
for (int j = 0; j < h; j++) {
point *m = &map[i + j * w];
// cout << "(" << *m->h << "," << *m->v << ") ";
if (max < *m->h + *m->v) {
max = *m->h + *m->v;
// cout << "(" << i << "," << j << ") : " << max << endl;
}
}
// cout << endl;
}
cout << max - 1 << endl;
} | [
"assignment.add"
] | 828,149 | 828,150 | u199912250 | cpp |
p03014 | #include <bits/stdc++.h>
using namespace std;
#define IOS \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define endl "\n"
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
signed main() {
IOS;
int h, w, ans = 0;
cin >> h >> w;
int hcnt[h + 1][w + 1], wcnt[h + 1][w + 1];
string s[w];
FOR(i, 0, h) {
cin >> s[i];
int prev = -1, cnt = 0;
FOR(j, 0, w) {
if (s[i][j] == '.') {
cnt++;
} else {
FOR(k, prev + 1, j) hcnt[i][k] = cnt;
cnt = 0;
hcnt[i][j] = 0;
prev = j;
}
}
FOR(k, prev + 1, w) hcnt[i][k] = cnt;
// FOR(j,0,w)
// cout << hcnt[i][j] << " ";
// cout << endl;
}
FOR(j, 0, w) {
int prev = -1, cnt = 0;
FOR(i, 0, h) {
if (s[i][j] == '.') {
cnt++;
} else {
FOR(k, prev + 1, i) {
wcnt[k][j] = cnt;
ans = max(ans, hcnt[k][j] + wcnt[k][j] - 1);
}
cnt = 0;
wcnt[i][j] = 0;
prev = i;
}
}
FOR(k, prev + 1, h) {
wcnt[k][j] = cnt;
ans = max(ans, hcnt[k][j] + wcnt[k][j] - 1);
}
}
// cout << endl;
// FOR(i,0,h) {
// FOR(j,0,w)
// cout << wcnt[i][j] << " ";
// cout << endl;
// }
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define IOS \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define endl "\n"
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
signed main() {
IOS;
int h, w, ans = 0;
cin >> h >> w;
int hcnt[h + 1][w + 1], wcnt[h + 1][w + 1];
string s[h];
FOR(i, 0, h) {
cin >> s[i];
int prev = -1, cnt = 0;
FOR(j, 0, w) {
if (s[i][j] == '.') {
cnt++;
} else {
FOR(k, prev + 1, j) hcnt[i][k] = cnt;
cnt = 0;
hcnt[i][j] = 0;
prev = j;
}
}
FOR(k, prev + 1, w) hcnt[i][k] = cnt;
// FOR(j,0,w)
// cout << hcnt[i][j] << " ";
// cout << endl;
}
FOR(j, 0, w) {
int prev = -1, cnt = 0;
FOR(i, 0, h) {
if (s[i][j] == '.') {
cnt++;
} else {
FOR(k, prev + 1, i) {
wcnt[k][j] = cnt;
ans = max(ans, hcnt[k][j] + wcnt[k][j] - 1);
}
cnt = 0;
wcnt[i][j] = 0;
prev = i;
}
}
FOR(k, prev + 1, h) {
wcnt[k][j] = cnt;
ans = max(ans, hcnt[k][j] + wcnt[k][j] - 1);
}
}
// cout << endl;
// FOR(i,0,h) {
// FOR(j,0,w)
// cout << wcnt[i][j] << " ";
// cout << endl;
// }
cout << ans << endl;
return 0;
} | [
"identifier.change",
"variable_declaration.array_dimensions.change"
] | 828,162 | 828,163 | u762703573 | cpp |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.