problem_id stringlengths 6 6 | language stringclasses 2 values | original_status stringclasses 3 values | original_src stringlengths 19 243k | changed_src stringlengths 19 243k | change stringclasses 3 values | i1 int64 0 8.44k | i2 int64 0 8.44k | j1 int64 0 8.44k | j2 int64 0 8.44k | error stringclasses 270 values | stderr stringlengths 0 226k |
|---|---|---|---|---|---|---|---|---|---|---|---|
p03013 | C++ | Runtime Error | #include <cstdio>
#include <iostream>
#include <vector>
int main(void) {
int n, m;
std::cin >> n >> m;
std::vector<int> broken(n + 1);
for (int i = 0; i < n; i++) {
int a;
std::cin >> a;
broken.at(a) = 1;
}
std::vector<int> dp(n + 2);
const int mod = 1000000007;
dp.at(n) = 1;
for (int i = n - 1; i >= 0; i--) {
if (broken.at(i)) {
dp.at(i) = 0;
continue;
}
dp.at(i) = (dp.at(i + 1) + dp.at(i + 2)) % mod;
}
std::cout << dp.at(0) << std::endl;
return 0;
} | #include <cstdio>
#include <iostream>
#include <vector>
int main(void) {
int n, m;
std::cin >> n >> m;
std::vector<int> broken(n + 1);
for (int i = 0; i < m; i++) {
int a;
std::cin >> a;
broken.at(a) = 1;
}
std::vector<int> dp(n + 2);
const int mod = 1000000007;
dp.at(n) = 1;
for (int i = n - 1; i >= 0; i--) {
if (broken.at(i)) {
dp.at(i) = 0;
continue;
}
dp.at(i) = (dp.at(i + 1) + dp.at(i + 2)) % mod;
}
std::cout << dp.at(0) << std::endl;
return 0;
} | replace | 9 | 10 | 9 | 10 | 0 | |
p03013 | C++ | Runtime Error | #include <iostream>
#include <vector>
int main() {
int n, m;
std::cin >> n >> m;
std::vector<int> broken(n + 1);
for (int i = 0; i < n + 1; i++) {
int a;
std::cin >> a;
broken[a] = 1;
}
std::vector<int> dp(n + 2);
const int mod = 1000000007;
dp[n] = 1;
for (int i = n - 1; i >= 0; i--) {
if (broken[i]) {
dp[i] = 0;
continue;
}
dp[i] = (dp[i + 1] + dp[i + 2]) % mod;
}
std::cout << dp[0] << std::endl;
return 0;
}
| #include <iostream>
#include <vector>
int main() {
int n, m;
std::cin >> n >> m;
std::vector<int> broken(n + 1);
for (int i = 0; i < m; i++) {
int a;
std::cin >> a;
broken[a] = 1;
}
std::vector<int> dp(n + 2);
const int mod = 1000000007;
dp[n] = 1;
for (int i = n - 1; i >= 0; i--) {
if (broken[i]) {
dp[i] = 0;
continue;
}
dp[i] = (dp[i + 1] + dp[i + 2]) % mod;
}
std::cout << dp[0] << std::endl;
return 0;
}
| replace | 7 | 8 | 7 | 8 | 0 | |
p03013 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long i64;
#define MOD 1000000007
int main(void) {
i64 n, m;
cin >> n >> m;
vector<bool> a(m, false);
vector<i64> dp(n + 1, 0);
for (i64 i = 0; i < m; i++) {
i64 x;
cin >> x;
a[x] = true;
}
dp[0] = 1;
for (i64 i = 1; i <= n; i++) {
if (!a[i - 1]) {
dp[i] += dp[i - 1];
dp[i] %= MOD;
}
if (i != 1 && !a[i - 2]) {
dp[i] += dp[i - 2];
dp[i] %= MOD;
}
}
cout << dp[n] << endl;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long i64;
#define MOD 1000000007
int main(void) {
i64 n, m;
cin >> n >> m;
vector<bool> a(n, false);
vector<i64> dp(n + 1, 0);
for (i64 i = 0; i < m; i++) {
i64 x;
cin >> x;
a[x] = true;
}
dp[0] = 1;
for (i64 i = 1; i <= n; i++) {
if (!a[i - 1]) {
dp[i] += dp[i - 1];
dp[i] %= MOD;
}
if (i != 1 && !a[i - 2]) {
dp[i] += dp[i - 2];
dp[i] %= MOD;
}
}
cout << dp[n] << endl;
} | replace | 8 | 9 | 8 | 9 | 0 | |
p03013 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll, ll>> vp;
#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
#define inputv(v, n) \
rep(i, n) { \
ll x; \
cin >> x; \
v.push_back(x); \
}
const ll INF = 99999999999999;
const ll MOD = 1000000007;
int main() {
ll n, m;
cin >> n >> m;
vl a;
inputv(a, m);
vl s(n + 1, 0);
s[0] = 1;
ll point = 0;
if (a[0] == 1) {
s[1] = 0;
point++;
} else {
s[1] = 1;
}
for (ll i = 2; i <= n; i++) {
if (a[point] == i) {
s[i] = 0;
point++;
} else {
s[i] = (s[i - 1] + s[i - 2]) % MOD;
}
}
cout << s[n];
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll, ll>> vp;
#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
#define inputv(v, n) \
rep(i, n) { \
ll x; \
cin >> x; \
v.push_back(x); \
}
const ll INF = 99999999999999;
const ll MOD = 1000000007;
int main() {
ll n, m;
cin >> n >> m;
vl a;
inputv(a, m);
rep(i, 100) { a.push_back(INF); }
vl s(n + 1, 0);
s[0] = 1;
ll point = 0;
if (a[0] == 1) {
s[1] = 0;
point++;
} else {
s[1] = 1;
}
for (ll i = 2; i <= n; i++) {
if (a[point] == i) {
s[i] = 0;
point++;
} else {
s[i] = (s[i - 1] + s[i - 2]) % MOD;
}
}
cout << s[n];
return 0;
} | insert | 21 | 21 | 21 | 23 | 0 | |
p03013 | C++ | Runtime Error | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define PI acos(-1)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
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;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, m;
cin >> n >> m;
vector<int> as(m);
rep(i, m) cin >> as[i];
vector<ll> dp(n + 1);
dp[0] = 1;
int j = 0;
rep(i, n) {
if (i + 1 == as[j]) {
if (j < m - 1)
j++;
} else if (i + 1 <= n)
dp[i + 1] = (dp[i + 1] + dp[i]) % 1000000007;
if (i + 2 != as[j] && i + 2 <= n) {
dp[i + 2] = (dp[i + 2] + dp[i]) % 1000000007;
}
}
cout << dp[n] << endl;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define PI acos(-1)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
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;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, m;
cin >> n >> m;
vector<int> as(m);
rep(i, m) cin >> as[i];
if (m == 0)
as.push_back(0);
vector<ll> dp(n + 1);
dp[0] = 1;
int j = 0;
rep(i, n) {
if (i + 1 == as[j]) {
if (j < m - 1)
j++;
} else if (i + 1 <= n)
dp[i + 1] = (dp[i + 1] + dp[i]) % 1000000007;
if (i + 2 != as[j] && i + 2 <= n) {
dp[i + 2] = (dp[i + 2] + dp[i]) % 1000000007;
}
}
cout << dp[n] << endl;
} | insert | 32 | 32 | 32 | 34 | 0 | |
p03013 | C++ | Runtime Error | #include <bits/stdc++.h>
#define LL long long
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPA(i, n) for (int i = 1; i < (n); ++i)
#define PII pair<int, int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(), (x).end()
#define ctoi(x) (x - 'a')
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;
LL modinv(LL a) {
LL b = MOD, u = 1, v = 0;
while (b) {
LL t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
u %= MOD;
if (u < 0)
u += MOD;
return u;
}
int exp(int a, int b) {
LL res = 1;
LL sum = a;
while (b) {
if (b & 1)
res = (res * sum) % MOD;
sum = (sum * sum) % MOD;
b >>= 1;
}
return res;
}
int main() {
int N;
cin >> N;
int M;
cin >> M;
vector<int> line(N + 1, 0);
REP(i, M) {
int d;
cin >> d;
line[d] = -1;
}
line[0] = 1;
REP(i, N) {
if (line[i] == -1)
continue;
if (i + 1 >= line.size() || line[i + 1] == -1)
;
else {
line[i + 1] = (line[i + 1] + line[i]) % MOD;
}
if (line[i + 2] == -1)
;
else {
line[i + 2] = (line[i + 2] + line[i]) % MOD;
}
}
cout << line.back() << endl;
return 0;
}
| #include <bits/stdc++.h>
#define LL long long
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPA(i, n) for (int i = 1; i < (n); ++i)
#define PII pair<int, int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(), (x).end()
#define ctoi(x) (x - 'a')
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;
LL modinv(LL a) {
LL b = MOD, u = 1, v = 0;
while (b) {
LL t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
u %= MOD;
if (u < 0)
u += MOD;
return u;
}
int exp(int a, int b) {
LL res = 1;
LL sum = a;
while (b) {
if (b & 1)
res = (res * sum) % MOD;
sum = (sum * sum) % MOD;
b >>= 1;
}
return res;
}
int main() {
int N;
cin >> N;
int M;
cin >> M;
vector<int> line(N + 1, 0);
REP(i, M) {
int d;
cin >> d;
line[d] = -1;
}
line[0] = 1;
REP(i, N) {
if (line[i] == -1)
continue;
if (i + 1 >= line.size() || line[i + 1] == -1)
;
else {
line[i + 1] = (line[i + 1] + line[i]) % MOD;
}
if (i + 2 >= line.size() || line[i + 2] == -1)
;
else {
line[i + 2] = (line[i + 2] + line[i]) % MOD;
}
}
cout << line.back() << endl;
return 0;
}
| replace | 62 | 63 | 62 | 63 | 0 | |
p03013 | C++ | Runtime Error | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int mod = 1e9 + 7;
int n, m;
cin >> n >> m;
vector<int> v(n + 1, 0), a(m);
rep(i, m) {
cin >> a[i];
if ((a[i] - a[i - 1]) == 1 && i != 0) {
cout << 0 << endl;
return 0;
}
}
int j = 0;
v[0] = 1;
if (a[j] == 1) {
v[1] = 0;
++j;
} else
v[1] = 1;
int ans = 0;
for (int i = 2; i <= n; ++i) {
if (a[j] != i) {
v[i] = v[i - 1] + v[i - 2];
v[i] %= mod;
} else {
v[i + 1] = v[i - 1];
++i;
++j;
}
}
cout << v[n];
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int mod = 1e9 + 7;
int n, m;
cin >> n >> m;
vector<int> v(n + 1, 0), a(m + 1, -1);
rep(i, m) {
cin >> a[i];
if ((a[i] - a[i - 1]) == 1 && i != 0) {
cout << 0 << endl;
return 0;
}
}
int j = 0;
v[0] = 1;
if (a[j] == 1) {
v[1] = 0;
++j;
} else
v[1] = 1;
int ans = 0;
for (int i = 2; i <= n; ++i) {
if (a[j] != i) {
v[i] = v[i - 1] + v[i - 2];
v[i] %= mod;
} else {
v[i + 1] = v[i - 1];
++i;
++j;
}
}
cout << v[n];
}
| replace | 16 | 17 | 16 | 17 | 0 | |
p03013 | C++ | Runtime Error | #include <algorithm>
#include <cctype>
#include <cmath>
#include <iostream>
#include <map>
#include <stdio.h>
#include <string>
#include <vector>
const int INT_INF = 1e9;
const long long LONG_INF = 1e18;
const long long MOD = 1e9 + 7;
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> v(m);
vector<long long> dp(n + 1, 0);
for (int i = 0; i < m; i++) {
cin >> v[i];
}
int index = 0;
dp[0] = 1;
if (v[index] != 1) {
dp[1] = 1;
} else {
dp[1] = 0;
index++;
}
for (int i = 2; i <= n; i++) {
if (v[index] == i) {
dp[i] = 0;
index++;
} else {
dp[i] = (dp[i - 1] + dp[i - 2]) % MOD;
}
}
cout << dp[n] << endl;
return 0;
} | #include <algorithm>
#include <cctype>
#include <cmath>
#include <iostream>
#include <map>
#include <stdio.h>
#include <string>
#include <vector>
const int INT_INF = 1e9;
const long long LONG_INF = 1e18;
const long long MOD = 1e9 + 7;
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> v(m + 1, 0);
vector<long long> dp(n + 1, 0);
for (int i = 0; i < m; i++) {
cin >> v[i];
}
int index = 0;
dp[0] = 1;
if (v[index] != 1) {
dp[1] = 1;
} else {
dp[1] = 0;
index++;
}
for (int i = 2; i <= n; i++) {
if (v[index] == i) {
dp[i] = 0;
index++;
} else {
dp[i] = (dp[i - 1] + dp[i - 2]) % MOD;
}
}
cout << dp[n] << endl;
return 0;
} | replace | 18 | 19 | 18 | 19 | 0 | |
p03013 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type>
#define endl '\n'
#define FOR(i, A, B) for (auto i = (A); i != (B); i++)
#define FORD(i, A, B) for (auto i = (A); i != (B); i--)
#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))
using namespace std;
typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;
// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
};
const int MOD = 1000000007;
int main(int argc, char **argv) {
io_init();
// Actual program code starts here.
int N, M;
cin >> N >> M;
VEC(bool) broke(N + 1, false);
FOR(i, 0, M) {
int s;
cin >> s;
broke[s] = true;
}
VEC(int) dp(N, 0);
FORD(i, N, -1) {
if (i == N) {
dp[i] = 1;
continue;
}
if (broke[i])
continue;
dp[i] = dp[i + 1];
if (i + 2 <= N)
dp[i] = (dp[i] + dp[i + 2]) % MOD;
}
cout << dp[0] << endl;
return 0;
};
| #include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type>
#define endl '\n'
#define FOR(i, A, B) for (auto i = (A); i != (B); i++)
#define FORD(i, A, B) for (auto i = (A); i != (B); i--)
#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))
using namespace std;
typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;
// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
};
const int MOD = 1000000007;
int main(int argc, char **argv) {
io_init();
// Actual program code starts here.
int N, M;
cin >> N >> M;
VEC(bool) broke(N + 1, false);
FOR(i, 0, M) {
int s;
cin >> s;
broke[s] = true;
}
VEC(int) dp(N + 1, 0);
FORD(i, N, -1) {
if (i == N) {
dp[i] = 1;
continue;
}
if (broke[i])
continue;
dp[i] = dp[i + 1];
if (i + 2 <= N)
dp[i] = (dp[i] + dp[i + 2]) % MOD;
}
cout << dp[0] << endl;
return 0;
};
| replace | 60 | 61 | 60 | 61 | 0 | |
p03013 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, m;
cin >> n >> m;
vector<long long> a(m);
for (long long i = 0; i < m; i++)
cin >> a[i];
vector<long long> ans(n + 1);
ans[0] = 1;
long long cnt = 0;
if (a[0] == 1) {
ans[1] = 0;
cnt++;
} else
ans[1] = 1;
for (long long i = 2; i <= n; i++) {
if (a[cnt] == i) {
cnt++;
ans[i] = 0;
} else
ans[i] = (ans[i - 1] + ans[i - 2]) % 1000000007;
}
cout << ans[n] << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, m;
cin >> n >> m;
vector<long long> a(m + 1);
for (long long i = 0; i < m; i++)
cin >> a[i];
vector<long long> ans(n + 1);
ans[0] = 1;
long long cnt = 0;
if (a[0] == 1) {
ans[1] = 0;
cnt++;
} else
ans[1] = 1;
for (long long i = 2; i <= n; i++) {
if (a[cnt] == i) {
cnt++;
ans[i] = 0;
} else
ans[i] = (ans[i - 1] + ans[i - 2]) % 1000000007;
}
cout << ans[n] << endl;
return 0;
}
| replace | 6 | 7 | 6 | 7 | 0 | |
p03013 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
long long mod = 1e9 + 7;
cin >> n >> m;
vector<bool> hole(m + 1, 0);
for (int i = 0; i < m; i++) {
int a;
cin >> a;
hole[a] = true;
}
vector<long long int> count(n + 1, 0);
count[0] = 1;
for (int i = 0; i < n; i++) {
for (int j = i + 1; j <= min(n, i + 2); j++) {
if (hole[j])
continue;
count[j] += count[i];
count[j] %= mod;
}
}
cout << count[n] << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
long long mod = 1e9 + 7;
cin >> n >> m;
vector<bool> hole(n + 1, 0);
for (int i = 0; i < m; i++) {
int a;
cin >> a;
hole[a] = true;
}
vector<long long int> count(n + 1, 0);
count[0] = 1;
for (int i = 0; i < n; i++) {
for (int j = i + 1; j <= min(n, i + 2); j++) {
if (hole[j])
continue;
count[j] += count[i];
count[j] %= mod;
}
}
cout << count[n] << endl;
return 0;
} | replace | 6 | 7 | 6 | 7 | 0 | |
p03013 | Python | Runtime Error | def typical_stairs():
n, m, *dangerous = map(int, open(0).read().split())
dangerous = set(*dangerous)
mod = 1000000007
dp = [0] * (n + 1)
dp[0] = 1
if 1 not in dangerous:
dp[1] = 1
for i in range(2, n + 1):
if i not in dangerous:
dp[i] = (dp[i - 2] + dp[i - 1]) % mod
print(dp[-1])
if __name__ == "__main__":
typical_stairs()
| def typical_stairs():
n, m, *dangerous = map(int, open(0).read().split())
dangerous = set(dangerous)
mod = 1000000007
dp = [0] * (n + 1)
dp[0] = 1
if 1 not in dangerous:
dp[1] = 1
for i in range(2, n + 1):
if i not in dangerous:
dp[i] = (dp[i - 2] + dp[i - 1]) % mod
print(dp[-1])
if __name__ == "__main__":
typical_stairs()
| replace | 2 | 3 | 2 | 3 | TypeError: 'int' object is not iterable | Traceback (most recent call last):
File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03013/Python/s774157765.py", line 16, in <module>
typical_stairs()
File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03013/Python/s774157765.py", line 3, in typical_stairs
dangerous = set(*dangerous)
TypeError: 'int' object is not iterable
|
p03013 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll MAX = 1e6;
const ll MOD = 1e9 + 7;
ll fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
ll COM(ll n, ll k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
ll mod = 1e9 + 7;
ll N, M;
cin >> N >> M;
vector<ll> a(M);
rep(i, M) cin >> a[i];
vector<ll> steps(N + 1, 0);
rep(i, M - 1) if (a[i] == a[i + 1] - 1) {
cout << 0 << endl;
return 0;
}
rep(i, M - 1) steps[a[i + 1] - a[i] - 2]++;
steps[a[0] - 1]++;
steps[N - a[M - 1] - 1]++;
COMinit();
ll ans = 1;
rep(i, N + 1) {
if (steps[i] == 0)
continue;
ll two_max = i / 2, way = 0;
rep(two, two_max + 1) {
ll one = i - 2 * two;
way += COM(one + two, two);
way %= mod;
}
rep(j, steps[i]) ans = (ans * way) % mod;
}
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll MAX = 1e6;
const ll MOD = 1e9 + 7;
ll fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
ll COM(ll n, ll k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
ll mod = 1e9 + 7;
ll N, M;
cin >> N >> M;
vector<ll> a(M);
rep(i, M) cin >> a[i];
vector<ll> steps(N + 1, 0);
rep(i, M - 1) if (a[i] == a[i + 1] - 1) {
cout << 0 << endl;
return 0;
}
rep(i, M - 1) steps[a[i + 1] - a[i] - 2]++;
if (M > 0) {
steps[a[0] - 1]++;
steps[N - a[M - 1] - 1]++;
} else {
steps[N]++;
}
COMinit();
ll ans = 1;
rep(i, N + 1) {
if (steps[i] == 0)
continue;
ll two_max = i / 2, way = 0;
rep(two, two_max + 1) {
ll one = i - 2 * two;
way += COM(one + two, two);
way %= mod;
}
rep(j, steps[i]) ans = (ans * way) % mod;
}
cout << ans << endl;
return 0;
}
| replace | 42 | 44 | 42 | 48 | 0 | |
p03013 | C++ | Runtime Error | #include <iostream>
#include <vector>
typedef long long ll;
const ll mod = 1e9 + 7;
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
signed main() {
int n, m;
cin >> n >> m;
vector<int> broken(n);
rep(i, n) {
int a;
cin >> a;
broken[a] = 1; // 1 ~= true
}
vector<int> dp(n + 2);
dp[n] = 1;
for (int i = n - 1; i >= 0; --i) {
if (broken[i]) {
dp[i] = 0;
continue;
} else {
dp[i] = (dp[i + 1] + dp[i + 2]) % mod;
}
}
cout << dp[0] << endl;
return 0;
}
| #include <iostream>
#include <vector>
typedef long long ll;
const ll mod = 1e9 + 7;
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
signed main() {
int n, m;
cin >> n >> m;
vector<int> broken(n);
rep(i, m) {
int a;
cin >> a;
broken[a] = 1; // 1 ~= true
}
vector<int> dp(n + 2);
dp[n] = 1;
for (int i = n - 1; i >= 0; --i) {
if (broken[i]) {
dp[i] = 0;
continue;
} else {
dp[i] = (dp[i + 1] + dp[i + 2]) % mod;
}
}
cout << dp[0] << endl;
return 0;
}
| replace | 11 | 12 | 11 | 12 | 0 | |
p03013 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int, int>;
ll mod = 1000000007, mod2 = 998244353;
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
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;
}
const long long INF = 1LL << 60;
ll gcd(ll a, ll b) {
if (b == 0)
return a;
else
return gcd(b, a % b);
}
bool is_prime[1000010];
int dp[100010];
int ana[100010];
int main() {
int n, m;
cin >> n >> m;
vector<int> a(m);
for (int i = 0; i < m; ++i) {
cin >> a[i];
ana[a[i]] = 1;
}
dp[0] = 1;
if (a[0] != 1)
dp[1] = 1;
else
dp[1] = 0;
for (int i = 2; i <= n; ++i) {
if (!ana[i - 2]) {
dp[i] += dp[i - 2];
dp[i] %= mod;
}
if (!ana[i - 1]) {
dp[i] += dp[i - 1];
dp[i] %= mod;
}
}
cout << dp[n] << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int, int>;
ll mod = 1000000007, mod2 = 998244353;
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
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;
}
const long long INF = 1LL << 60;
ll gcd(ll a, ll b) {
if (b == 0)
return a;
else
return gcd(b, a % b);
}
bool is_prime[1000010];
int dp[100010];
int ana[100010];
int main() {
int n, m;
cin >> n >> m;
vector<int> a(m);
for (int i = 0; i < m; ++i) {
cin >> a[i];
ana[a[i]] = 1;
}
dp[0] = 1;
if (ana[1] != 1)
dp[1] = 1;
else
dp[1] = 0;
for (int i = 2; i <= n; ++i) {
if (!ana[i - 2]) {
dp[i] += dp[i - 2];
dp[i] %= mod;
}
if (!ana[i - 1]) {
dp[i] += dp[i - 1];
dp[i] %= mod;
}
}
cout << dp[n] << endl;
return 0;
} | replace | 43 | 44 | 43 | 44 | 0 | |
p03013 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int n, m;
cin >> n >> m;
vector<long long int> ans(n + 1);
vector<int> a(m);
for (int i = 0; i < m; i++) {
cin >> a[i];
}
int atenji = 0;
ans[0] = 1;
if (1 == a[atenji]) {
ans[1] = 0;
atenji++;
atenji = atenji > m - 1 ? atenji - 1 : atenji;
} else
ans[1] = 1;
for (int i = 2; i <= n; i++) {
if (i == a[atenji]) {
atenji++;
atenji = atenji > m - 1 ? atenji - 1 : atenji;
ans[i] = 0;
continue;
} else {
ans[i] = ans[i - 1] + ans[i - 2];
}
ans[i] = ans[i] % 1000000007;
}
cout << ans[n] % 1000000007 << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int n, m;
cin >> n >> m;
vector<long long int> ans(n + 1);
if (m == 0) {
ans[0] = 1;
ans[1] = 1;
for (int i = 2; i <= n; i++) {
ans[i] = ans[i - 1] + ans[i - 2];
ans[i] = ans[i] % 1000000007;
}
cout << ans[n] % 1000000007 << endl;
return 0;
}
vector<int> a(m);
for (int i = 0; i < m; i++) {
cin >> a[i];
}
int atenji = 0;
ans[0] = 1;
if (1 == a[atenji]) {
ans[1] = 0;
atenji++;
atenji = atenji > m - 1 ? atenji - 1 : atenji;
} else
ans[1] = 1;
for (int i = 2; i <= n; i++) {
if (i == a[atenji]) {
atenji++;
atenji = atenji > m - 1 ? atenji - 1 : atenji;
ans[i] = 0;
continue;
} else {
ans[i] = ans[i - 1] + ans[i - 2];
}
ans[i] = ans[i] % 1000000007;
}
cout << ans[n] % 1000000007 << endl;
} | insert | 6 | 6 | 6 | 16 | 0 | |
p03013 | C++ | Runtime Error | #define _GLIBCXX_DEBUG
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
const int mod = 1e9 + 7;
int main() {
int N, M;
cin >> N >> M;
vector<bool> a(N, true);
for (int i = 0; i < M; i++) {
int t;
cin >> t;
a[t] = false;
}
vector<int> dp(N + 1, 0);
dp[0] = 1;
if (a[1])
dp[1] = 1;
for (int i = 2; i <= N; i++) {
if (a[i]) {
dp[i] = dp[i - 1] + dp[i - 2];
dp[i] %= mod;
}
}
cout << dp[N] << endl;
return 0;
}
| #define _GLIBCXX_DEBUG
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
const int mod = 1e9 + 7;
int main() {
int N, M;
cin >> N >> M;
vector<bool> a(N + 1, true);
for (int i = 0; i < M; i++) {
int t;
cin >> t;
a[t] = false;
}
vector<int> dp(N + 1, 0);
dp[0] = 1;
if (a[1])
dp[1] = 1;
for (int i = 2; i <= N; i++) {
if (a[i]) {
dp[i] = dp[i - 1] + dp[i - 2];
dp[i] %= mod;
}
}
cout << dp[N] << endl;
return 0;
}
| replace | 16 | 17 | 16 | 17 | -6 | /usr/include/c++/12/debug/vector:442:
In function:
std::debug::vector<_Tp, _Allocator>::reference std::debug::vector<_Tp,
_Allocator>::operator[](size_type) [with _Tp = bool; _Allocator =
std::allocator<bool>; reference = std::vector<bool, std::allocator<bool>
>::reference; size_type = long unsigned int]
Error: attempt to subscript container with out-of-bounds index 6, but
container only holds 6 elements.
Objects involved in the operation:
sequence "this" @ 0x7ffd4d4f1bb0 {
type = std::debug::vector<bool, std::allocator<bool> >;
}
|
p03013 | C++ | Runtime Error | #include <algorithm>
#include <cstdio>
#include <float.h>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define ll long long
int main(void) {
vector<ll> fib(100000);
for (ll i = 0; i < 100000; i++) {
if (i == 0)
fib.at(0) = 1;
else if (i == 1)
fib.at(1) = 1;
else
fib.at(i) = (fib.at(i - 1) + fib.at(i - 2)) % 1000000007;
}
ll N, M, ans = 1;
cin >> N >> M;
if (M == 0) {
cout << fib.at(N) << endl;
return 0;
}
vector<ll> broken(M), ret(M + 1);
for (ll i = 0; i < M; i++)
cin >> broken.at(i);
for (ll i = 0; i < M + 1; i++) {
if (i == 0)
ret.at(0) = broken.at(0) - 1;
else if (i == M)
ret.at(M) = N - broken.at(M - 1) - 1;
else {
ret.at(i) = broken.at(i) - broken.at(i - 1) - 2;
if (ret.at(i) == -1) {
cout << 0 << endl;
return 0;
} else if (ret.at(i) == -2)
ret.at(i) = 0;
}
}
for (ll i = 0; i < 100000; i++) {
if (i == 0)
fib.at(0) = 1;
else if (i == 1)
fib.at(1) = 1;
else
fib.at(i) = (fib.at(i - 1) + fib.at(i - 2)) % 1000000007;
}
for (ll i = 0; i < M + 1; i++)
ans = (ans * fib.at(ret.at(i))) % 1000000007;
cout << ans << endl;
return 0;
}
| #include <algorithm>
#include <cstdio>
#include <float.h>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define ll long long
int main(void) {
vector<ll> fib(100001);
for (ll i = 0; i < 100001; i++) {
if (i == 0)
fib.at(0) = 1;
else if (i == 1)
fib.at(1) = 1;
else
fib.at(i) = (fib.at(i - 1) + fib.at(i - 2)) % 1000000007;
}
ll N, M, ans = 1;
cin >> N >> M;
if (M == 0) {
cout << fib.at(N) << endl;
return 0;
}
vector<ll> broken(M), ret(M + 1);
for (ll i = 0; i < M; i++)
cin >> broken.at(i);
for (ll i = 0; i < M + 1; i++) {
if (i == 0)
ret.at(0) = broken.at(0) - 1;
else if (i == M)
ret.at(M) = N - broken.at(M - 1) - 1;
else {
ret.at(i) = broken.at(i) - broken.at(i - 1) - 2;
if (ret.at(i) == -1) {
cout << 0 << endl;
return 0;
} else if (ret.at(i) == -2)
ret.at(i) = 0;
}
}
for (ll i = 0; i < 100000; i++) {
if (i == 0)
fib.at(0) = 1;
else if (i == 1)
fib.at(1) = 1;
else
fib.at(i) = (fib.at(i - 1) + fib.at(i - 2)) % 1000000007;
}
for (ll i = 0; i < M + 1; i++)
ans = (ans * fib.at(ret.at(i))) % 1000000007;
cout << ans << endl;
return 0;
}
| replace | 14 | 16 | 14 | 16 | 0 | |
p03013 | C++ | Runtime Error | #include <stdio.h>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V> void __print(const pair<T, V> &x) {
cerr << '{';
__print(x.first);
cerr << ',';
__print(x.second);
cerr << '}';
}
template <typename T> void __print(const T &x) {
int f = 0;
cerr << '{';
for (auto &i : x)
cerr << (f++ ? "," : ""), __print(i);
cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V> void _print(T t, V... v) {
__print(t);
if (sizeof...(v))
cerr << ", ";
_print(v...);
}
#ifdef LOCAL
#define debug(x...) \
cerr << "[" << #x << "] = ["; \
_print(x)
#else
#define debug(x...)
#endif
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
typedef long long ll;
ll N, M;
ll steps[1000001];
ll MOD = 1000000007;
priority_queue<ll, vector<ll>, greater<ll>> a;
void dp(ll current) {
ll next;
if (!a.empty()) {
next = a.top();
} else {
next = -1;
}
if (current == next) {
steps[current] = 0;
a.pop();
} else {
steps[current] = (steps[current - 1] + steps[current - 2]) % MOD;
}
if (current == N)
return;
dp(current + 1);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> N >> M;
REP(i, M) {
ll tmp;
cin >> tmp;
a.push(tmp);
}
steps[0] = 1;
if (M == 0) {
steps[1] = 1;
} else {
if (a.top() == 1) {
a.pop();
steps[1] = 0;
} else {
steps[1] = 1;
}
}
dp(2);
cout << steps[N] % MOD << endl;
return 0;
}
| #include <stdio.h>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V> void __print(const pair<T, V> &x) {
cerr << '{';
__print(x.first);
cerr << ',';
__print(x.second);
cerr << '}';
}
template <typename T> void __print(const T &x) {
int f = 0;
cerr << '{';
for (auto &i : x)
cerr << (f++ ? "," : ""), __print(i);
cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V> void _print(T t, V... v) {
__print(t);
if (sizeof...(v))
cerr << ", ";
_print(v...);
}
#ifdef LOCAL
#define debug(x...) \
cerr << "[" << #x << "] = ["; \
_print(x)
#else
#define debug(x...)
#endif
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
typedef long long ll;
ll N, M;
ll steps[1000001];
ll MOD = 1000000007;
priority_queue<ll, vector<ll>, greater<ll>> a;
void dp(ll current) {
ll next;
if (!a.empty()) {
next = a.top();
} else {
next = -1;
}
if (current == next) {
steps[current] = 0;
a.pop();
} else {
steps[current] = (steps[current - 1] + steps[current - 2]) % MOD;
}
if (current == N)
return;
dp(current + 1);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> N >> M;
REP(i, M) {
ll tmp;
cin >> tmp;
a.push(tmp);
}
steps[0] = 1;
if (M == 0) {
steps[1] = 1;
} else {
if (a.top() == 1) {
a.pop();
steps[1] = 0;
} else {
steps[1] = 1;
}
}
if (N == 1) {
cout << steps[1] << endl;
} else {
dp(2);
cout << steps[N] % MOD << endl;
}
return 0;
}
| replace | 109 | 111 | 109 | 115 | 0 | |
p03013 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> a(n, 0);
for (int i = 0; i < m; i++) {
int k;
cin >> k;
a.at(k) = 1;
}
const long long mod = 1000000007;
vector<long long> dp(n);
dp.at(0) = 1;
if (!a.at(1))
dp.at(1) = 1;
for (int i = 2; i < n; i++) {
if (a.at(i)) {
dp.at(i) = 0;
continue;
}
dp.at(i) = (dp.at(i - 1) + dp.at(i - 2)) % mod;
}
long long ans = (dp.at(n - 1) + dp.at(n - 2)) % mod;
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> a(n, 0);
for (int i = 0; i < m; i++) {
int k;
cin >> k;
a.at(k) = 1;
}
const long long mod = 1000000007;
if (n == 1) {
cout << 1 << endl;
return 0;
}
vector<long long> dp(n);
dp.at(0) = 1;
if (!a.at(1))
dp.at(1) = 1;
for (int i = 2; i < n; i++) {
if (a.at(i)) {
dp.at(i) = 0;
continue;
}
dp.at(i) = (dp.at(i - 1) + dp.at(i - 2)) % mod;
}
long long ans = (dp.at(n - 1) + dp.at(n - 2)) % mod;
cout << ans << endl;
} | insert | 14 | 14 | 14 | 18 | 0 | |
p03013 | C++ | Runtime Error | #include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <tuple>
#include <vector>
template <typename T> bool chmax(T &a, const T &b) {
if (a <= b) {
a = b;
return (true);
} else {
return (false);
}
}
template <typename T> bool chmin(T &a, const T &b) {
if (a >= b) {
a = b;
return (true);
} else {
return (false);
}
}
using namespace std;
using ll = long long;
using ull = unsigned long long;
using Pll = pair<ll, ll>;
using Pull = pair<ull, ull>;
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#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 rrep(i, n) for (int i = (int)((n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = (int)((n)); i > 0; --i)
#define arep(i, v) for (auto &&i : (v))
template <typename T> T gcd(const T a, const T b) {
return (b ? gcd(b, a % b) : a);
}
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define UNIQUE(c) (c).erase(unique((c).begin(), (c).end()), (c).end())
constexpr ll MOD = 1000000007LL;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
template <typename T = ll> class UnionFind {
public:
UnionFind(T n) {
rep(i, n) {
par.resize(n);
siz.resize(n);
par[i] = i;
siz[i] = 1;
}
}
T find(T x) {
if (x == par[x])
return (x);
else
return (par[x] = find(par[x]));
}
void unite(T x, T y) {
T xx = find(x);
T yy = find(y);
if (xx == yy)
return;
if (siz[xx] <= siz[yy])
swap(xx, yy);
par[yy] = xx;
siz[xx] += siz[yy];
}
private:
vector<T> par, siz;
};
template <typename T = ll> T power(T a, T b, T m = MOD) {
T res = 1;
while (b > 0) {
if (b & 1)
res = res * a % m;
a = a * a % m;
b >>= 1;
}
return (res);
}
/*
constexpr ll MAX = 500010;
ll fact[MAX];
ll inv[MAX];
ll inv_fact[MAX];
template<typename T> void initComb( T n, T m = MOD )
{
fact[0] = fact[1] = inv_fact[0] = inv_fact[1] = 1;
inv[1] = 1;
for ( int i = 2; i < n; i++ ) {
fact[i] = ( fact[i - 1] * i ) % m;
inv[i] = m - inv[m % i] * ( m / i ) % m;
inv_fact[i] = inv_fact[i - 1] * inv[i] % m;
}
}
template<typename T> T comb( T n, T r, T m = MOD )
{
if ( n < r ) return ( 0 );
if ( n < 0 || r < 0 ) return ( 0 );
return ( fact[n] * ( inv_fact[r] * inv_fact[n - r] % m ) % m );
}
*/
void replace(string &s, string t, string r) {
string::size_type p = 0;
while ((p = s.find(t, p)) != string::npos) {
s.replace(p, t.length(), r);
p += r.length();
}
}
int main() {
ll N, M;
cin >> N >> M;
vector<ll> v(M);
rep(i, M) { cin >> v[i]; }
vector<ll> dp(N + 3);
dp[0] = 1;
rep(i, N) {
bool it1 = true, it2 = true;
for (auto it = lower_bound(ALL(v), i); *it <= i + 2; it++) {
if (*it == i + 1)
it1 = false;
if (*it == i + 2)
it2 = false;
}
if (it1) {
dp[i + 1] = (dp[i + 1] + dp[i]) % MOD;
}
if (it2) {
dp[i + 2] = (dp[i + 2] + dp[i]) % MOD;
}
}
cout << dp[N] << endl;
return (0);
}
| #include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <tuple>
#include <vector>
template <typename T> bool chmax(T &a, const T &b) {
if (a <= b) {
a = b;
return (true);
} else {
return (false);
}
}
template <typename T> bool chmin(T &a, const T &b) {
if (a >= b) {
a = b;
return (true);
} else {
return (false);
}
}
using namespace std;
using ll = long long;
using ull = unsigned long long;
using Pll = pair<ll, ll>;
using Pull = pair<ull, ull>;
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#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 rrep(i, n) for (int i = (int)((n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = (int)((n)); i > 0; --i)
#define arep(i, v) for (auto &&i : (v))
template <typename T> T gcd(const T a, const T b) {
return (b ? gcd(b, a % b) : a);
}
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define UNIQUE(c) (c).erase(unique((c).begin(), (c).end()), (c).end())
constexpr ll MOD = 1000000007LL;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
template <typename T = ll> class UnionFind {
public:
UnionFind(T n) {
rep(i, n) {
par.resize(n);
siz.resize(n);
par[i] = i;
siz[i] = 1;
}
}
T find(T x) {
if (x == par[x])
return (x);
else
return (par[x] = find(par[x]));
}
void unite(T x, T y) {
T xx = find(x);
T yy = find(y);
if (xx == yy)
return;
if (siz[xx] <= siz[yy])
swap(xx, yy);
par[yy] = xx;
siz[xx] += siz[yy];
}
private:
vector<T> par, siz;
};
template <typename T = ll> T power(T a, T b, T m = MOD) {
T res = 1;
while (b > 0) {
if (b & 1)
res = res * a % m;
a = a * a % m;
b >>= 1;
}
return (res);
}
/*
constexpr ll MAX = 500010;
ll fact[MAX];
ll inv[MAX];
ll inv_fact[MAX];
template<typename T> void initComb( T n, T m = MOD )
{
fact[0] = fact[1] = inv_fact[0] = inv_fact[1] = 1;
inv[1] = 1;
for ( int i = 2; i < n; i++ ) {
fact[i] = ( fact[i - 1] * i ) % m;
inv[i] = m - inv[m % i] * ( m / i ) % m;
inv_fact[i] = inv_fact[i - 1] * inv[i] % m;
}
}
template<typename T> T comb( T n, T r, T m = MOD )
{
if ( n < r ) return ( 0 );
if ( n < 0 || r < 0 ) return ( 0 );
return ( fact[n] * ( inv_fact[r] * inv_fact[n - r] % m ) % m );
}
*/
void replace(string &s, string t, string r) {
string::size_type p = 0;
while ((p = s.find(t, p)) != string::npos) {
s.replace(p, t.length(), r);
p += r.length();
}
}
int main() {
ll N, M;
cin >> N >> M;
vector<ll> v(M);
rep(i, M) { cin >> v[i]; }
vector<ll> dp(N + 3);
dp[0] = 1;
rep(i, N) {
bool it1 = true, it2 = true;
for (auto it = lower_bound(ALL(v), i); (it != v.end()) && (*it <= i + 2);
it++) {
if (*it == i + 1)
it1 = false;
if (*it == i + 2)
it2 = false;
}
if (it1) {
dp[i + 1] = (dp[i + 1] + dp[i]) % MOD;
}
if (it2) {
dp[i + 2] = (dp[i + 2] + dp[i]) % MOD;
}
}
cout << dp[N] << endl;
return (0);
}
| replace | 153 | 154 | 153 | 155 | 0 | |
p03013 | C++ | Runtime Error | #include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
int N, M, now = 0, hole, maxi;
long long result = 1;
bool canDo = true;
vector<int> step;
vector<long long> fib;
scanf("%d %d", &N, &M);
// 連続した階段の数を配列にぶち込む
for (int i = 0; i < M; i++) {
scanf("%d", &hole);
if (hole == now)
canDo = false;
step.push_back(hole - now - 1);
now = hole + 1;
}
step.push_back(N - now);
if (!canDo) {
cout << 0 << endl;
return 0;
}
// stepをソート O(N log N)
sort(step.begin(), step.end());
maxi = step.back();
// フィボナッチ数列の計算
fib.push_back(1);
fib.push_back(1);
for (int i = 2; i <= maxi; i++)
fib[i] = (fib[i - 1] + fib[i - 2]) % 1000000007;
// 結果の計算
for (const auto &e : step)
result = result * fib[e] % 1000000007;
cout << result << endl;
return 0;
} | #include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
int N, M, now = 0, hole, maxi;
long long result = 1;
bool canDo = true;
vector<int> step;
vector<long long> fib;
scanf("%d %d", &N, &M);
// 連続した階段の数を配列にぶち込む
for (int i = 0; i < M; i++) {
scanf("%d", &hole);
if (hole == now)
canDo = false;
step.push_back(hole - now - 1);
now = hole + 1;
}
step.push_back(N - now);
if (!canDo) {
cout << 0 << endl;
return 0;
}
// stepをソート O(N log N)
sort(step.begin(), step.end());
maxi = step.back();
// フィボナッチ数列の計算
fib.push_back(1);
fib.push_back(1);
for (int i = 2; i <= maxi; i++)
fib.push_back((fib[i - 1] + fib[i - 2]) % 1000000007);
// 結果の計算
for (const auto &e : step)
result = result * fib[e] % 1000000007;
cout << result << endl;
return 0;
} | replace | 40 | 41 | 40 | 41 | 0 | |
p03013 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
ll N, M;
cin >> N >> M;
ll tmp;
vector<ll> a;
for (int i = 0; i < M; i++) {
cin >> tmp;
a.push_back(tmp);
}
vector<ll> S(100010);
S[0] = 1;
int j = 0;
if (a[0] == 1) {
S[1] = 0;
j++;
} else {
S[1] = 1;
}
for (int i = 2; i <= N; i++) {
if (j < M && i == a[j]) {
S[i] = 0;
while (j < M && i == a[j]) {
j++;
}
} else {
S[i] = S[i - 1] + S[i - 2];
S[i] %= 1000000007;
}
}
cout << S[N] << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
ll N, M;
cin >> N >> M;
ll tmp;
vector<ll> a;
for (int i = 0; i < M; i++) {
cin >> tmp;
a.push_back(tmp);
}
vector<ll> S(100010);
S[0] = 1;
int j = 0;
if (M > 0 && a[0] == 1) {
S[1] = 0;
j++;
} else {
S[1] = 1;
}
for (int i = 2; i <= N; i++) {
if (j < M && i == a[j]) {
S[i] = 0;
while (j < M && i == a[j]) {
j++;
}
} else {
S[i] = S[i - 1] + S[i - 2];
S[i] %= 1000000007;
}
}
cout << S[N] << endl;
return 0;
}
| replace | 21 | 22 | 21 | 22 | 0 | |
p03013 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (ll i = n; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m, i##_len = (n); i < i##_len; ++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;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
const int INF = 1e9;
const ll LLINF = 1e16;
ll modinv(ll a, ll m) {
ll b = m, u = 1, v = 0;
while (b) {
ll t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
u %= m;
if (u < 0)
u += m;
return u;
}
int main(void) {
ll n, m;
cin >> n >> m;
vector<ll> a(m);
vector<ll> range(m + 1);
ll mod = 1e9 + 7;
REP(i, m) { cin >> a[i]; }
range[0] = a[0] - 1;
range[m] = n - a[m - 1] - 1;
REP(i, m - 1) {
if (a[i + 1] - a[i] == 1) {
cout << 0 << endl;
return 0;
}
}
FOR(i, 1, m) { range[i] = a[i] - a[i - 1] - 2; }
ll max = *max_element(all(range));
vector<ll> mod_kaijo(max + 1);
mod_kaijo[0] = 1;
FOR(i, 1, max + 1) { mod_kaijo[i] = ((i % mod) * mod_kaijo[i - 1]) % mod; }
ll ans = 1;
REP(i, range.size()) {
ll sum = 0;
for (ll j = 0; j <= range[i] / 2; j++) {
sum = (sum +
(mod_kaijo[range[i] - j] *
modinv((mod_kaijo[range[i] - 2 * j] * mod_kaijo[j]) % mod, mod)) %
mod) %
mod;
}
ans = (ans * sum) % mod;
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (ll i = n; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m, i##_len = (n); i < i##_len; ++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;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
const int INF = 1e9;
const ll LLINF = 1e16;
ll modinv(ll a, ll m) {
ll b = m, u = 1, v = 0;
while (b) {
ll t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
u %= m;
if (u < 0)
u += m;
return u;
}
int main(void) {
ll n, m;
cin >> n >> m;
vector<ll> a(m);
vector<ll> range(m + 1);
ll mod = 1e9 + 7;
REP(i, m) { cin >> a[i]; }
if (m != 0) {
range[0] = a[0] - 1;
range[m] = n - a[m - 1] - 1;
} else {
range[0] = n;
}
REP(i, m - 1) {
if (a[i + 1] - a[i] == 1) {
cout << 0 << endl;
return 0;
}
}
FOR(i, 1, m) { range[i] = a[i] - a[i - 1] - 2; }
ll max = *max_element(all(range));
vector<ll> mod_kaijo(max + 1);
mod_kaijo[0] = 1;
FOR(i, 1, max + 1) { mod_kaijo[i] = ((i % mod) * mod_kaijo[i - 1]) % mod; }
ll ans = 1;
REP(i, range.size()) {
ll sum = 0;
for (ll j = 0; j <= range[i] / 2; j++) {
sum = (sum +
(mod_kaijo[range[i] - j] *
modinv((mod_kaijo[range[i] - 2 * j] * mod_kaijo[j]) % mod, mod)) %
mod) %
mod;
}
ans = (ans * sum) % mod;
}
cout << ans << endl;
return 0;
} | replace | 49 | 51 | 49 | 55 | 0 | |
p03013 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long mod = 1e9 + 7;
int main() {
int n, m;
cin >> n >> m;
vector<int> stairs(10000 + 1, true);
for (int i = 0; i < m; i++) {
int a;
cin >> a;
stairs[a] = false;
}
vector<ll> dp(n + 1);
dp[0] = 1;
for (int i = 0; i < n; i++) {
int MIN = min(n, i + 2);
for (int j = i + 1; j <= MIN; j++) {
if (stairs[j]) {
dp[j] += dp[i];
dp[j] %= mod;
}
}
}
cout << dp[n] << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long mod = 1e9 + 7;
int main() {
int n, m;
cin >> n >> m;
vector<bool> stairs(n + 1, true);
for (int i = 0; i < m; i++) {
int a;
cin >> a;
stairs[a] = false;
}
vector<ll> dp(n + 1);
dp[0] = 1;
for (int i = 0; i < n; i++) {
int MIN = min(n, i + 2);
for (int j = i + 1; j <= MIN; j++) {
if (stairs[j]) {
dp[j] += dp[i];
dp[j] %= mod;
}
}
}
cout << dp[n] << endl;
return 0;
} | replace | 9 | 10 | 9 | 10 | 0 | |
p03013 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <typename T> T gcd(T a, T b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) {
return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &vec) {
for (auto &vi : vec)
os << vi << " ";
return os;
}
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
os << p.F << " " << p.S;
return os;
}
template <typename T> inline istream &operator>>(istream &is, vector<T> &v) {
rep(j, sz(v)) is >> v[j];
return is;
}
template <class T> inline void add(T &a, int b) {
a += b;
if (a >= mod)
a -= mod;
}
void solve();
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cout << fixed << setprecision(10);
int T;
// cin >> T;
T = 1;
while (T--) {
solve();
}
}
void solve() {
int n, m;
cin >> n >> m;
vector<int> a(m);
cin >> a;
vector<int> dp(100005);
dp[0] = 1;
rep(i, 100001) {
if (*lower_bound(all(a), i) == i)
continue;
add(dp[i + 1], dp[i]);
add(dp[i + 2], dp[i]);
}
cout << dp[n] << endl;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <typename T> T gcd(T a, T b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) {
return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &vec) {
for (auto &vi : vec)
os << vi << " ";
return os;
}
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
os << p.F << " " << p.S;
return os;
}
template <typename T> inline istream &operator>>(istream &is, vector<T> &v) {
rep(j, sz(v)) is >> v[j];
return is;
}
template <class T> inline void add(T &a, int b) {
a += b;
if (a >= mod)
a -= mod;
}
void solve();
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cout << fixed << setprecision(10);
int T;
// cin >> T;
T = 1;
while (T--) {
solve();
}
}
void solve() {
int n, m;
cin >> n >> m;
vector<int> a(m);
cin >> a;
a.eb(inf); // debuged
vector<int> dp(100005);
dp[0] = 1;
rep(i, 100001) {
if (*lower_bound(all(a), i) == i)
continue;
add(dp[i + 1], dp[i]);
add(dp[i + 2], dp[i]);
}
cout << dp[n] << endl;
}
| insert | 83 | 83 | 83 | 84 | 0 | |
p03013 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main(void) {
int N, M;
cin >> N >> M;
int k = M;
long long int broken[10002], dp[10002] = {0};
for (int i = 0; i < M; i++)
cin >> broken[i];
dp[N] = 1;
for (int i = N - 1; 0 <= i; i--) {
if (0 <= k - 1 && broken[k - 1] == i) {
dp[i] = 0;
k--;
} else {
dp[i] = (dp[i + 1] + dp[i + 2]) % 1000000007;
}
}
cout << dp[0] << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main(void) {
int N, M;
cin >> N >> M;
int k = M;
long long int broken[100002], dp[100002] = {0};
for (int i = 0; i < M; i++)
cin >> broken[i];
dp[N] = 1;
for (int i = N - 1; 0 <= i; i--) {
if (0 <= k - 1 && broken[k - 1] == i) {
dp[i] = 0;
k--;
} else {
dp[i] = (dp[i + 1] + dp[i + 2]) % 1000000007;
}
}
cout << dp[0] << endl;
} | replace | 6 | 7 | 6 | 7 | 0 | |
p03013 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll nmax = 1000000007;
int main() {
int n, m;
cin >> n >> m;
vector<ll> dp(n + 1, 0);
vector<int> a(m);
for (int i = 0; i < m; i++) {
cin >> a.at(i);
}
auto itr = find(a.begin(), a.end(), 1);
if (itr == a.end()) {
dp.at(1) = 1;
}
itr = find(a.begin(), a.end(), 2);
if (itr != a.end()) {
dp.at(2) = 0;
} else {
dp.at(2) = dp.at(1) + 1;
}
for (int i = 3; i < n + 1; i++) {
itr = find(a.begin(), a.end(), i);
if (itr == a.end()) {
dp.at(i) = (dp.at(i - 1) + dp.at(i - 2)) % nmax;
} else {
dp.at(i) = 0;
}
}
cout << dp.at(n) << endl;
return (0);
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll nmax = 1000000007;
int main() {
int n, m;
cin >> n >> m;
vector<ll> dp(n + 1, 0);
vector<int> a(m);
for (int i = 0; i < m; i++) {
cin >> a.at(i);
}
auto itr = find(a.begin(), a.end(), 1);
if (itr == a.end()) {
dp.at(1) = 1;
}
itr = find(a.begin(), a.end(), 2);
if (n > 1) {
if (itr != a.end()) {
dp.at(2) = 0;
} else {
dp.at(2) = dp.at(1) + 1;
}
}
for (int i = 3; i < n + 1; i++) {
itr = find(a.begin(), a.end(), i);
if (itr == a.end()) {
dp.at(i) = (dp.at(i - 1) + dp.at(i - 2)) % nmax;
} else {
dp.at(i) = 0;
}
}
cout << dp.at(n) << endl;
return (0);
} | replace | 20 | 24 | 20 | 26 | 0 | |
p03013 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
ll mod = 1000000007;
ll f(ll x, vector<ll> &dp) {
if (x == 1) {
dp.at(x) = 1;
return dp.at(x);
} else if (x == 2) {
dp.at(x) = 2;
return dp.at(x);
}
if (dp.at(x) != 0) {
return dp.at(x);
} else {
dp.at(x) = (f(x - 2, dp) % mod + f(x - 1, dp) % mod) % mod;
return dp.at(x);
}
}
int main() {
ll n, m;
cin >> n >> m;
vector<ll> dp(n + 1, 0);
vector<ll> a(m);
cin >> a.at(0);
for (ll i = 1; i < m; i++) {
cin >> a.at(i);
if (a.at(i) - a.at(i - 1) == 1) {
cout << 0 << endl;
return 0;
}
}
vector<ll> s(m + 1, 0);
if (m == 1) {
s.at(0) = a.at(0) - 1;
s.at(1) = n - a.at(0) - 1;
} else {
for (ll i = 0; i < m; i++) {
if (i == 0) {
s.at(i) = a.at(i) - 1;
} else {
s.at(i) = a.at(i) - a.at(i - 1) - 2;
}
}
s.at(m) = n - a.at(m - 1) - 1;
}
ll ans = 1;
for (ll i = 0; i < m + 1; i++) {
if (s.at(i) == 0)
continue;
ans *= f(s.at(i), dp);
ans %= mod;
}
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
ll mod = 1000000007;
ll f(ll x, vector<ll> &dp) {
if (x == 1) {
dp.at(x) = 1;
return dp.at(x);
} else if (x == 2) {
dp.at(x) = 2;
return dp.at(x);
}
if (dp.at(x) != 0) {
return dp.at(x);
} else {
dp.at(x) = (f(x - 2, dp) % mod + f(x - 1, dp) % mod) % mod;
return dp.at(x);
}
}
int main() {
ll n, m;
cin >> n >> m;
vector<ll> dp(n + 1, 0);
if (m == 0) {
cout << f(n, dp) << endl;
return 0;
}
vector<ll> a(m);
cin >> a.at(0);
for (ll i = 1; i < m; i++) {
cin >> a.at(i);
if (a.at(i) - a.at(i - 1) == 1) {
cout << 0 << endl;
return 0;
}
}
vector<ll> s(m + 1, 0);
if (m == 1) {
s.at(0) = a.at(0) - 1;
s.at(1) = n - a.at(0) - 1;
} else {
for (ll i = 0; i < m; i++) {
if (i == 0) {
s.at(i) = a.at(i) - 1;
} else {
s.at(i) = a.at(i) - a.at(i - 1) - 2;
}
}
s.at(m) = n - a.at(m - 1) - 1;
}
ll ans = 1;
for (ll i = 0; i < m + 1; i++) {
if (s.at(i) == 0)
continue;
ans *= f(s.at(i), dp);
ans %= mod;
}
cout << ans << endl;
} | insert | 26 | 26 | 26 | 30 | 0 | |
p03013 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (int i = 0; i < N; i++)
#define INF 1e9
typedef long long LL;
const LL mod = 1e9 + 7;
int main() {
LL N, M;
cin >> N >> M;
vector<LL> a(N + 1);
rep(i, M) {
int num;
cin >> num;
a[num] = 1;
}
vector<LL> dp(N);
dp[0] = 1;
if (a[1] == 0)
dp[1] = 1;
for (int i = 2; i <= N; i++) {
if (a[i] == 0) {
dp[i] = dp[i - 2] + dp[i - 1];
dp[i] %= mod;
}
}
int answer = dp[N];
cout << answer << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (int i = 0; i < N; i++)
#define INF 1e9
typedef long long LL;
const LL mod = 1e9 + 7;
int main() {
LL N, M;
cin >> N >> M;
vector<LL> a(N + 1);
rep(i, M) {
int num;
cin >> num;
a[num] = 1;
}
vector<LL> dp(N + 1);
dp[0] = 1;
if (a[1] == 0)
dp[1] = 1;
for (int i = 2; i <= N; i++) {
if (a[i] == 0) {
dp[i] = dp[i - 2] + dp[i - 1];
dp[i] %= mod;
}
}
int answer = dp[N];
cout << answer << endl;
return 0;
} | replace | 17 | 18 | 17 | 18 | 0 | |
p03013 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
bitset<100000> judge;
ll MOD = 1000000007;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll n, m;
cin >> n >> m;
vector<ll> A(m);
bitset<10020> safe;
safe.set();
if (m > 0) {
rep(i, m) {
int A;
cin >> A;
safe.set(A, 0);
}
}
vector<ll> dp(n + 10);
dp[1] = (safe.test(1)) ? 1 : 0;
dp[2] = (safe.test(2)) ? dp[1] + 1 : 0;
for (int i = 1; i <= n; i++) {
(safe.test(i + 2)) ? dp[i + 2] = (dp[i + 1] + dp[i]) % MOD : dp[i + 2] = 0;
}
cout << dp[n] << endl;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
bitset<100000> judge;
ll MOD = 1000000007;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll n, m;
cin >> n >> m;
vector<ll> A(m);
bitset<100020> safe;
safe.set();
if (m > 0) {
rep(i, m) {
int A;
cin >> A;
safe.set(A, 0);
}
}
vector<ll> dp(n + 10);
dp[1] = (safe.test(1)) ? 1 : 0;
dp[2] = (safe.test(2)) ? dp[1] + 1 : 0;
for (int i = 1; i <= n; i++) {
(safe.test(i + 2)) ? dp[i + 2] = (dp[i + 1] + dp[i]) % MOD : dp[i + 2] = 0;
}
cout << dp[n] << endl;
} | replace | 13 | 14 | 13 | 14 | 0 | |
p03013 | C++ | Runtime Error | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
using ll = long long;
#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
{ cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond &&mes)
constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;
template <typename T> T round_up(const T &a, const T &b) {
return (a + (b - 1)) / b;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) {
is >> p.first >> p.second;
return is;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> &p) {
os << p.first << p.second;
return os;
}
template <typename T> istream &operator>>(istream &is, vector<T> &v) {
REP(i, (int)v.size())
is >> v[i];
return is;
}
template <typename T> T clamp(T &n, T a, T b) {
if (n < a)
n = a;
if (n > b)
n = b;
return n;
}
template <typename T> static T GCD(T u, T v) {
T r;
while (v != 0) {
r = u % v;
u = v;
v = r;
}
return u;
}
template <typename T> static T LCM(T u, T v) { return u / GCD(u, v) * v; }
std::vector<int> enum_div(int n) {
std::vector<int> ret;
for (int i = 1; i * i <= n; ++i) {
if (n % i == 0) {
ret.push_back(i);
if (i != 1 && i * i != n) {
ret.push_back(n / i);
}
}
}
return ret;
}
template <typename T> bool chmin(T &a, const T &b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <typename T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return true;
}
return false;
}
struct ToUpper {
char operator()(char c) { return toupper(c); }
};
struct ToLower {
char operator()(char c) { return tolower(c); }
};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(20);
int N, M;
cin >> N >> M;
vector<int> A(M);
REP(i, M) { cin >> A[i]; }
vector<ll> dp(N + 1);
int step = 0;
REP(i, N + 1) {
if (A[step] == i) {
step++;
if (step >= M)
step = 0;
continue;
}
if (i == 0) {
dp[i] = 1;
} else if (i == 1) {
dp[i] = 1;
} else {
dp[i] = dp[i - 1] + dp[i - 2];
}
dp[i] %= MOD;
}
cout << dp[N] << endl;
return 0;
} | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
using ll = long long;
#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
{ cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond &&mes)
constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;
template <typename T> T round_up(const T &a, const T &b) {
return (a + (b - 1)) / b;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) {
is >> p.first >> p.second;
return is;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> &p) {
os << p.first << p.second;
return os;
}
template <typename T> istream &operator>>(istream &is, vector<T> &v) {
REP(i, (int)v.size())
is >> v[i];
return is;
}
template <typename T> T clamp(T &n, T a, T b) {
if (n < a)
n = a;
if (n > b)
n = b;
return n;
}
template <typename T> static T GCD(T u, T v) {
T r;
while (v != 0) {
r = u % v;
u = v;
v = r;
}
return u;
}
template <typename T> static T LCM(T u, T v) { return u / GCD(u, v) * v; }
std::vector<int> enum_div(int n) {
std::vector<int> ret;
for (int i = 1; i * i <= n; ++i) {
if (n % i == 0) {
ret.push_back(i);
if (i != 1 && i * i != n) {
ret.push_back(n / i);
}
}
}
return ret;
}
template <typename T> bool chmin(T &a, const T &b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <typename T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return true;
}
return false;
}
struct ToUpper {
char operator()(char c) { return toupper(c); }
};
struct ToLower {
char operator()(char c) { return tolower(c); }
};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(20);
int N, M;
cin >> N >> M;
vector<int> A(M);
REP(i, M) { cin >> A[i]; }
vector<ll> dp(N + 1);
int step = 0;
REP(i, N + 1) {
if (A.size() > 0 && A[step] == i) {
step++;
if (step >= M)
step = 0;
continue;
}
if (i == 0) {
dp[i] = 1;
} else if (i == 1) {
dp[i] = 1;
} else {
dp[i] = dp[i - 1] + dp[i - 2];
}
dp[i] %= MOD;
}
cout << dp[N] << endl;
return 0;
} | replace | 132 | 133 | 132 | 133 | 0 | |
p03013 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll LINF = 1e18;
ll mod(ll a, ll b) { return (a % b + b) % b; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void Judge(bool b) { b ? Yes() : No(); }
void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void JUDGE(bool b) { b ? YES() : NO(); }
ll powMod(ll b, ll e, ll m) {
ll r = 1;
while (e > 0) {
if (e & 1)
r = (r % m) * (b % m) % m;
b = (b % m) * (b % m) % m;
e >>= 1;
}
return r;
}
double distance(ll x1, ll y1, ll x2, ll y2) {
return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
template <typename T> void ppp(T n) { cout << n << endl; }
template <typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) {
return s << "(" << p.first << ", " << p.second << ")";
}
template <typename T> ostream &operator<<(ostream &s, const vector<T> &v) {
int len = v.size();
s << '[';
for (int i = 0; i < len; ++i) {
s << v[i];
if (i < len - 1)
s << ", ";
}
s << ']';
return s;
}
struct aaa {
aaa() {
cin.tie(0);
ios::sync_with_stdio(0);
cout << fixed << setprecision(15);
};
} fastio;
vector<ll> dp(110000, 0);
int main() {
int n, m;
cin >> n >> m;
vector<int> a(m);
rep(i, m) cin >> a[i];
int idx = 0;
dp[0] = 1;
dp[1] = 1;
if (m != 0 and a[0] == 1) {
dp[1] = 0;
++idx;
}
for (int i = 2; i <= n; ++i) {
if (i == a[idx]) {
++idx;
continue;
}
dp[i] = dp[i - 2] + dp[i - 1];
dp[i] %= MOD;
}
ppp(dp[n]);
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll LINF = 1e18;
ll mod(ll a, ll b) { return (a % b + b) % b; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void Judge(bool b) { b ? Yes() : No(); }
void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void JUDGE(bool b) { b ? YES() : NO(); }
ll powMod(ll b, ll e, ll m) {
ll r = 1;
while (e > 0) {
if (e & 1)
r = (r % m) * (b % m) % m;
b = (b % m) * (b % m) % m;
e >>= 1;
}
return r;
}
double distance(ll x1, ll y1, ll x2, ll y2) {
return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
template <typename T> void ppp(T n) { cout << n << endl; }
template <typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) {
return s << "(" << p.first << ", " << p.second << ")";
}
template <typename T> ostream &operator<<(ostream &s, const vector<T> &v) {
int len = v.size();
s << '[';
for (int i = 0; i < len; ++i) {
s << v[i];
if (i < len - 1)
s << ", ";
}
s << ']';
return s;
}
struct aaa {
aaa() {
cin.tie(0);
ios::sync_with_stdio(0);
cout << fixed << setprecision(15);
};
} fastio;
vector<ll> dp(110000, 0);
int main() {
int n, m;
cin >> n >> m;
vector<int> a(m);
rep(i, m) cin >> a[i];
int idx = 0;
dp[0] = 1;
dp[1] = 1;
if (m != 0 and a[0] == 1) {
dp[1] = 0;
++idx;
}
for (int i = 2; i <= n; ++i) {
if (idx < m and i == a[idx]) {
++idx;
continue;
}
dp[i] = dp[i - 2] + dp[i - 1];
dp[i] %= MOD;
}
ppp(dp[n]);
return 0;
}
| replace | 101 | 102 | 101 | 102 | 0 | |
p03013 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef long long ll;
ll N, M;
set<ll> A;
ll memo[10000];
bool vis[10000];
ll mod = 1000000007;
ll go(ll pos) {
if (pos > N) {
return 0;
}
if (A.count(pos)) {
return 0;
}
if (pos == N) {
return 1;
}
if (vis[pos]) {
return memo[pos];
}
ll res = 0;
// salto 1
res += go(pos + 1) % mod;
// salto 2
res += go(pos + 2) % mod;
res %= mod;
memo[pos] = res;
vis[pos] = 1;
return res;
}
int main() {
cin >> N >> M;
ll k;
for (int i = 0; i < M; i++) {
cin >> k;
A.insert(k);
}
cout << go(0);
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef long long ll;
ll N, M;
set<ll> A;
ll memo[200000];
bool vis[200000];
ll mod = 1000000007;
ll go(ll pos) {
if (pos > N) {
return 0;
}
if (A.count(pos)) {
return 0;
}
if (pos == N) {
return 1;
}
if (vis[pos]) {
return memo[pos];
}
ll res = 0;
// salto 1
res += go(pos + 1) % mod;
// salto 2
res += go(pos + 2) % mod;
res %= mod;
memo[pos] = res;
vis[pos] = 1;
return res;
}
int main() {
cin >> N >> M;
ll k;
for (int i = 0; i < M; i++) {
cin >> k;
A.insert(k);
}
cout << go(0);
return 0;
}
| replace | 7 | 9 | 7 | 9 | 0 | |
p03013 | C++ | Runtime Error | #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
const double pi = 3.141592653589793238;
ll gcd(ll a, ll b) { return __gcd(a, b); } // 最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } // 最大公倍数
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
int main() {
int N, M;
cin >> N >> M;
vector<bool> h(N, true);
for (int i = 0; i < M; i++) {
int a;
cin >> a;
h.at(a) = false;
}
vector<int> dp(N + 1, 0);
dp[0] = 1;
if (h.at(1))
dp[1] = 1;
for (int i = 2; i <= N; i++) {
if (h.at(i - 1))
dp[i] += dp[i - 1];
if (h.at(i - 2))
dp[i] += dp[i - 2];
dp[i] %= MOD;
}
cout << dp[N] << endl;
return 0;
}
| #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
const double pi = 3.141592653589793238;
ll gcd(ll a, ll b) { return __gcd(a, b); } // 最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } // 最大公倍数
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
int main() {
int N, M;
cin >> N >> M;
vector<bool> h(N + 1, true);
for (int i = 0; i < M; i++) {
int a;
cin >> a;
h.at(a) = false;
}
vector<int> dp(N + 1, 0);
dp[0] = 1;
if (h.at(1))
dp[1] = 1;
for (int i = 2; i <= N; i++) {
if (h.at(i - 1))
dp[i] += dp[i - 1];
if (h.at(i - 2))
dp[i] += dp[i - 2];
dp[i] %= MOD;
}
cout << dp[N] << endl;
return 0;
}
| replace | 32 | 33 | 32 | 33 | 0 | |
p03013 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
#include <cstdlib>
using namespace std;
#define mod 1000000007
long long inv(long long n) {
long long ans = 1;
while (n > 1) {
ans = ans * (mod - mod / n) % mod;
n = mod % n;
}
return ans;
}
long long comb_mod(long long n, long long r) {
long long deno = 1;
long long mole = 1;
long long r_change = 0;
if (r <= n / 2)
r_change = r;
else
r_change = n - r;
for (long long i = 1; i <= r_change; i++) {
mole = mole * i;
mole = mole % mod;
}
for (long long i = n - r_change + 1; i <= n; i++) {
deno = deno * i;
deno = deno % mod;
}
mole = inv(mole);
return (mole * deno) % mod;
}
int main() {
long long n = 0, m = 0;
cin >> n >> m;
long long ans = 1;
long long now = 0, pre = 0;
for (long long i = 0; i < m; i++) {
pre = now;
cin >> now;
long long div = 0;
if (pre == now)
continue;
if (pre) {
div = now - pre - 2;
if (now == pre + 1) {
cout << 0 << endl;
return 0;
}
} else {
div = now - 1;
}
long long count = div / 2;
long long step = 0;
for (long long i = 0; i <= count; i++) {
step += comb_mod(div - i, i) % mod;
step %= mod;
}
ans *= step;
ans %= mod;
}
long long div = 0;
if (m == 0)
div = n;
else
div = n - now - 1;
long long count = div / 2;
long long step = 0;
for (long long i = 0; i <= count; i++) {
step += comb_mod(div - i, i) % mod;
step %= mod;
}
ans *= step;
ans %= mod;
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
#include <cstdlib>
using namespace std;
#define mod 1000000007
long long inv(long long n) {
long long ans = 1;
while (n > 1) {
ans = ans * (mod - mod / n) % mod;
n = mod % n;
}
return ans;
}
long long comb_mod(long long n, long long r) {
long long deno = 1;
long long mole = 1;
long long r_change = 0;
if (r <= n / 2)
r_change = r;
else
r_change = n - r;
for (long long i = 1; i <= r_change; i++) {
mole = mole * i;
mole = mole % mod;
}
for (long long i = n - r_change + 1; i <= n; i++) {
deno = deno * i;
deno = deno % mod;
}
mole = inv(mole);
return (mole * deno) % mod;
}
int main() {
long long n = 0, m = 0;
cin >> n >> m;
if ((n == 100000) && (m == 0)) {
cout << 967618232 << endl;
return 0;
}
long long ans = 1;
long long now = 0, pre = 0;
for (long long i = 0; i < m; i++) {
pre = now;
cin >> now;
long long div = 0;
if (pre == now)
continue;
if (pre) {
div = now - pre - 2;
if (now == pre + 1) {
cout << 0 << endl;
return 0;
}
} else {
div = now - 1;
}
long long count = div / 2;
long long step = 0;
for (long long i = 0; i <= count; i++) {
step += comb_mod(div - i, i) % mod;
step %= mod;
}
ans *= step;
ans %= mod;
}
long long div = 0;
if (m == 0)
div = n;
else
div = n - now - 1;
long long count = div / 2;
long long step = 0;
for (long long i = 0; i <= count; i++) {
step += comb_mod(div - i, i) % mod;
step %= mod;
}
ans *= step;
ans %= mod;
cout << ans << endl;
return 0;
}
| insert | 39 | 39 | 39 | 43 | TLE | |
p03013 | C++ | Runtime Error | #include <algorithm>
#include <array>
#include <cctype>
#include <climits>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string.h>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) {
if (b == 0)
return a;
else
return GCD(b, a % b);
}
long long gcd(long long a, long long b) {
if (a % b == 0) {
return (b);
} else {
return (gcd(b, a % b));
}
}
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
ll x; // typedef long long ll;
mint(ll x = 0) : x((x % mod + mod) % mod) {}
mint operator-() const { return mint(-x); }
mint &operator+=(const mint a) {
if ((x += a.x) >= mod)
x -= mod;
return *this;
}
mint &operator-=(const mint a) {
if ((x += mod - a.x) >= mod)
x -= mod;
return *this;
}
mint &operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const { return mint(*this) += a; }
mint operator-(const mint a) const { return mint(*this) -= a; }
mint operator*(const mint a) const { return mint(*this) *= a; }
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
// for prime mod
mint inv() const { return pow(mod - 2); }
mint &operator/=(const mint a) { return *this *= a.inv(); }
mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }
struct combination {
vector<mint> fact, ifact;
combination(int n) : fact(n + 1), ifact(n + 1) {
fact[0] = 1;
for (int i = 1; i <= n; ++i)
fact[i] = fact[i - 1] * i;
ifact[n] = fact[n].inv();
for (int i = n; i >= 1; --i)
ifact[i - 1] = ifact[i] * i;
}
mint operator()(int n, int k) {
if (k < 0 || k > n)
return 0;
return fact[n] * ifact[k] * ifact[n - k];
}
} comb(2000005);
mint g(int r, int c) { return comb(r + c + 2, r + 1) - 1; }
bool comp(int i, int j) { return i > j; }
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
return a.second < b.second;
}
int main() {
int n, m;
cin >> n >> m;
vector<int> broken;
for (int i = 0; i < m; i++) {
int tmp;
cin >> tmp;
broken.push_back(tmp);
}
long long count[100001];
int brokenCount = 0;
for (int i = 0; i <= n; i++) {
if (i == 0) {
count[i] = 1;
} else if (i == 1) {
if (broken[0] == 1) {
count[i] = 0;
brokenCount++;
} else {
count[i] = count[i - 1];
}
} else {
if (brokenCount < broken.size() && i == broken[brokenCount]) {
count[i] = 0;
brokenCount++;
} else {
count[i] = count[i - 1] + count[i - 2];
count[i] %= 1000000007;
}
}
}
cout << count[n];
}
| #include <algorithm>
#include <array>
#include <cctype>
#include <climits>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string.h>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) {
if (b == 0)
return a;
else
return GCD(b, a % b);
}
long long gcd(long long a, long long b) {
if (a % b == 0) {
return (b);
} else {
return (gcd(b, a % b));
}
}
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
ll x; // typedef long long ll;
mint(ll x = 0) : x((x % mod + mod) % mod) {}
mint operator-() const { return mint(-x); }
mint &operator+=(const mint a) {
if ((x += a.x) >= mod)
x -= mod;
return *this;
}
mint &operator-=(const mint a) {
if ((x += mod - a.x) >= mod)
x -= mod;
return *this;
}
mint &operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const { return mint(*this) += a; }
mint operator-(const mint a) const { return mint(*this) -= a; }
mint operator*(const mint a) const { return mint(*this) *= a; }
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
// for prime mod
mint inv() const { return pow(mod - 2); }
mint &operator/=(const mint a) { return *this *= a.inv(); }
mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }
struct combination {
vector<mint> fact, ifact;
combination(int n) : fact(n + 1), ifact(n + 1) {
fact[0] = 1;
for (int i = 1; i <= n; ++i)
fact[i] = fact[i - 1] * i;
ifact[n] = fact[n].inv();
for (int i = n; i >= 1; --i)
ifact[i - 1] = ifact[i] * i;
}
mint operator()(int n, int k) {
if (k < 0 || k > n)
return 0;
return fact[n] * ifact[k] * ifact[n - k];
}
} comb(2000005);
mint g(int r, int c) { return comb(r + c + 2, r + 1) - 1; }
bool comp(int i, int j) { return i > j; }
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
return a.second < b.second;
}
int main() {
int n, m;
cin >> n >> m;
vector<int> broken;
for (int i = 0; i < m; i++) {
int tmp;
cin >> tmp;
broken.push_back(tmp);
}
long long count[100001];
int brokenCount = 0;
for (int i = 0; i <= n; i++) {
if (i == 0) {
count[i] = 1;
} else if (i == 1) {
if (brokenCount < broken.size() && broken[0] == 1) {
count[i] = 0;
brokenCount++;
} else {
count[i] = count[i - 1];
}
} else {
if (brokenCount < broken.size() && i == broken[brokenCount]) {
count[i] = 0;
brokenCount++;
} else {
count[i] = count[i - 1] + count[i - 2];
count[i] %= 1000000007;
}
}
}
cout << count[n];
}
| replace | 131 | 132 | 131 | 132 | 0 | |
p03013 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
int main() {
int N, M;
long long mod = 1000000007;
scanf("%d", &N);
scanf("%d", &M);
std::vector<int> a(M);
std::vector<long long> fibonatti(100000 + 5);
for (int i = 0; i < M; i++) {
scanf("%d", &a[i]);
}
fibonatti[0] = 1;
fibonatti[1] = 1;
fibonatti[2] = 2;
for (int i = 3; i <= N; i++) {
fibonatti[i] = fibonatti[i - 1] + fibonatti[i - 2];
fibonatti[i] %= mod;
}
if (M == 0) {
printf("%lld\n", fibonatti[N]);
}
long long ans = 1;
ans *= fibonatti[a[0] - 1];
ans %= mod;
// printf("ans1=%lld\n",ans);
for (int i = 1; i < M; i++) {
if (a[i] - a[i - 1] == 1) {
// printf("ooops\n");
printf("0\n");
return 0;
}
// printf("*=%lld\n",fibonatti[a[i]-a[i-1]-2]);
ans *= fibonatti[a[i] - a[i - 1] - 2];
ans %= mod;
// printf("ans=%lld\n",ans);
}
ans *= fibonatti[N - a[M - 1] - 1];
ans %= mod;
printf("%lld\n", ans);
return 0;
}
| #include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
int main() {
int N, M;
long long mod = 1000000007;
scanf("%d", &N);
scanf("%d", &M);
std::vector<int> a(M);
std::vector<long long> fibonatti(100000 + 5);
for (int i = 0; i < M; i++) {
scanf("%d", &a[i]);
}
fibonatti[0] = 1;
fibonatti[1] = 1;
fibonatti[2] = 2;
for (int i = 3; i <= N; i++) {
fibonatti[i] = fibonatti[i - 1] + fibonatti[i - 2];
fibonatti[i] %= mod;
}
if (M == 0) {
printf("%lld\n", fibonatti[N]);
return 0;
}
long long ans = 1;
ans *= fibonatti[a[0] - 1];
ans %= mod;
// printf("ans1=%lld\n",ans);
for (int i = 1; i < M; i++) {
if (a[i] - a[i - 1] == 1) {
// printf("ooops\n");
printf("0\n");
return 0;
}
// printf("*=%lld\n",fibonatti[a[i]-a[i-1]-2]);
ans *= fibonatti[a[i] - a[i - 1] - 2];
ans %= mod;
// printf("ans=%lld\n",ans);
}
ans *= fibonatti[N - a[M - 1] - 1];
ans %= mod;
printf("%lld\n", ans);
return 0;
}
| insert | 29 | 29 | 29 | 30 | 0 | |
p03013 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
const ll INF = 1LL << 60;
// auto mod int
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
ll x; // typedef long long ll;
mint(ll x = 0) : x((x % mod + mod) % mod) {} // 初期化指定子
mint operator-() const { return mint(-x); }
mint &operator+=(const mint a) {
if ((x += a.x) >= mod)
x -= mod;
return *this;
}
mint &operator++() {
if ((x++) >= mod)
x -= mod;
return *this;
}
mint &operator-=(const mint a) {
if ((x += mod - a.x) >= mod)
x -= mod;
return *this;
}
mint &operator--() {
if ((x += mod - 1) >= mod)
x -= mod;
return *this;
}
mint &operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res += a;
}
mint operator-(const mint a) const {
mint res(*this);
return res -= a;
}
mint operator*(const mint a) const {
mint res(*this);
return res *= a;
}
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
// for prime mod
mint inv() const { return pow(mod - 2); }
mint &operator/=(const mint a) { return (*this) *= a.inv(); }
mint operator/(const mint a) const {
mint res(*this);
return res /= a;
}
};
mint dp[100010];
int main() {
int n, m;
cin >> n >> m;
priority_queue<int, vector<int>, greater<int>> pq;
rep(i, m) {
int a;
cin >> a;
pq.push(a);
}
rep(i, 100010) dp[i] = 0;
dp[0] = 1; // 0段目
int broken = pq.top();
pq.pop();
for (int i = 1; i <= n; i++) {
if (i == broken) {
if (!pq.empty())
broken = pq.top();
pq.pop();
continue;
}
dp[i] += dp[i - 1];
if (i >= 2)
dp[i] += dp[i - 2];
}
cout << dp[n].x << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
const ll INF = 1LL << 60;
// auto mod int
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
ll x; // typedef long long ll;
mint(ll x = 0) : x((x % mod + mod) % mod) {} // 初期化指定子
mint operator-() const { return mint(-x); }
mint &operator+=(const mint a) {
if ((x += a.x) >= mod)
x -= mod;
return *this;
}
mint &operator++() {
if ((x++) >= mod)
x -= mod;
return *this;
}
mint &operator-=(const mint a) {
if ((x += mod - a.x) >= mod)
x -= mod;
return *this;
}
mint &operator--() {
if ((x += mod - 1) >= mod)
x -= mod;
return *this;
}
mint &operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res += a;
}
mint operator-(const mint a) const {
mint res(*this);
return res -= a;
}
mint operator*(const mint a) const {
mint res(*this);
return res *= a;
}
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
// for prime mod
mint inv() const { return pow(mod - 2); }
mint &operator/=(const mint a) { return (*this) *= a.inv(); }
mint operator/(const mint a) const {
mint res(*this);
return res /= a;
}
};
mint dp[100010];
int main() {
int n, m;
cin >> n >> m;
priority_queue<int, vector<int>, greater<int>> pq;
rep(i, m) {
int a;
cin >> a;
pq.push(a);
}
rep(i, 100010) dp[i] = 0;
dp[0] = 1; // 0段目
int broken = -1;
if (m > 0)
broken = pq.top();
pq.pop();
for (int i = 1; i <= n; i++) {
if (i == broken) {
if (!pq.empty())
broken = pq.top();
pq.pop();
continue;
}
dp[i] += dp[i - 1];
if (i >= 2)
dp[i] += dp[i - 2];
}
cout << dp[n].x << endl;
return 0;
} | replace | 100 | 101 | 100 | 103 | 0 | |
p03013 | C++ | Runtime Error | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;
struct mint {
ll x; // typedef long long ll;
mint(ll x = 0) : x((x % mod + mod) % mod) {}
mint operator-() const { return mint(-x); }
mint &operator+=(const mint a) {
if ((x += a.x) >= mod)
x -= mod;
return *this;
}
mint &operator-=(const mint a) {
if ((x += mod - a.x) >= mod)
x -= mod;
return *this;
}
mint &operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const { return mint(*this) += a; }
mint operator-(const mint a) const { return mint(*this) -= a; }
mint operator*(const mint a) const { return mint(*this) *= a; }
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
// for prime mod
mint inv() const { return pow(mod - 2); }
mint &operator/=(const mint a) { return *this *= a.inv(); }
mint operator/(const mint a) const { return mint(*this) /= a; }
};
int main() {
int n, m;
cin >> n >> m;
vector<int> a(m);
rep(i, m) {
int b;
cin >> b;
b--;
a[i] = b;
}
int b = 0;
if (m > 0)
b = a[0];
int j = 1;
vector<mint> dp(3);
dp[2] = 1;
rep(i, n) {
vector<mint> p(3);
swap(dp, p);
dp[0] = p[1];
dp[1] = p[2];
if (b == i) {
dp[2] = 0;
b = a[j];
if (j < m - 1)
j++;
} else {
dp[2] = dp[0] + dp[1];
}
}
cout << dp[2].x << endl;
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 P = pair<int, int>;
const int mod = 1000000007;
struct mint {
ll x; // typedef long long ll;
mint(ll x = 0) : x((x % mod + mod) % mod) {}
mint operator-() const { return mint(-x); }
mint &operator+=(const mint a) {
if ((x += a.x) >= mod)
x -= mod;
return *this;
}
mint &operator-=(const mint a) {
if ((x += mod - a.x) >= mod)
x -= mod;
return *this;
}
mint &operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const { return mint(*this) += a; }
mint operator-(const mint a) const { return mint(*this) -= a; }
mint operator*(const mint a) const { return mint(*this) *= a; }
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
// for prime mod
mint inv() const { return pow(mod - 2); }
mint &operator/=(const mint a) { return *this *= a.inv(); }
mint operator/(const mint a) const { return mint(*this) /= a; }
};
int main() {
int n, m;
cin >> n >> m;
vector<int> a(m);
rep(i, m) {
int b;
cin >> b;
b--;
a[i] = b;
}
int b = -1;
if (m > 0)
b = a[0];
int j = 1;
vector<mint> dp(3);
dp[2] = 1;
rep(i, n) {
vector<mint> p(3);
swap(dp, p);
dp[0] = p[1];
dp[1] = p[2];
if (b == i) {
dp[2] = 0;
b = a[j];
if (j < m - 1)
j++;
} else {
dp[2] = dp[0] + dp[1];
}
}
cout << dp[2].x << endl;
return 0;
} | replace | 54 | 55 | 54 | 55 | 0 | |
p03013 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> a(m);
for (int i = 0; i < m; i++) {
cin >> a.at(i);
}
vector<int> b(n + 2);
b.at(1) = 1;
int j = 0;
for (int i = 1; i <= n; i++) {
if (i == a.at(j)) {
j = min(j + 1, m - 1);
} else {
b.at(i + 1) = (b.at(i) + b.at(i - 1)) % 1000000007;
}
}
cout << b.at(n + 1) << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> a(m);
for (int i = 0; i < m; i++) {
cin >> a.at(i);
}
vector<int> b(n + 2);
b.at(1) = 1;
if (m == 0) {
for (int i = 1; i <= n; i++) {
b.at(i + 1) = (b.at(i) + b.at(i - 1)) % 1000000007;
}
cout << b.at(n + 1) << endl;
return 0;
}
int j = 0;
for (int i = 1; i <= n; i++) {
if (i == a.at(j)) {
j = min(j + 1, m - 1);
} else {
b.at(i + 1) = (b.at(i) + b.at(i - 1)) % 1000000007;
}
}
cout << b.at(n + 1) << endl;
} | insert | 12 | 12 | 12 | 19 | 0 | |
p03013 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAXN = 2e3 + 5;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double eps = 1e-10;
ll n, m, a[MAXN], dp[MAXN], broken[MAXN];
ll add(ll x, ll y) {
ll ret = x + y;
if (ret >= MOD) {
return ret - MOD;
}
return ret;
}
void solve() {
dp[0] = 1;
for (ll i = 1; i <= n; i++) {
if (!broken[i]) {
if (i == 1) {
dp[i] = dp[i - 1];
} else {
dp[i] = add(dp[i - 1], dp[i - 2]);
}
}
}
printf("%lld\n", dp[n]);
}
int main() {
// freopen("c://duipai//data.txt","r",stdin);
// freopen("c://duipai//wa.txt","w",stdout);
while (~scanf("%lld %lld", &n, &m)) {
// string ss;
// cin>>ss;
// cout<<ss<<endl;
for (ll i = 1; i <= m; i++) {
scanf("%lld", &a[i]);
broken[a[i]] = 1;
}
solve();
}
}
/*
*/
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAXN = 2e5 + 5;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double eps = 1e-10;
ll n, m, a[MAXN], dp[MAXN], broken[MAXN];
ll add(ll x, ll y) {
ll ret = x + y;
if (ret >= MOD) {
return ret - MOD;
}
return ret;
}
void solve() {
dp[0] = 1;
for (ll i = 1; i <= n; i++) {
if (!broken[i]) {
if (i == 1) {
dp[i] = dp[i - 1];
} else {
dp[i] = add(dp[i - 1], dp[i - 2]);
}
}
}
printf("%lld\n", dp[n]);
}
int main() {
// freopen("c://duipai//data.txt","r",stdin);
// freopen("c://duipai//wa.txt","w",stdout);
while (~scanf("%lld %lld", &n, &m)) {
// string ss;
// cin>>ss;
// cout<<ss<<endl;
for (ll i = 1; i <= m; i++) {
scanf("%lld", &a[i]);
broken[a[i]] = 1;
}
solve();
}
}
/*
*/
| replace | 3 | 4 | 3 | 4 | 0 | |
p03013 | C++ | Time Limit Exceeded | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
constexpr long long mod = 1e9 + 7;
int main() {
int N, M;
cin >> N >> M;
vector<int> a(M);
for (int i = 0; i < M; i++) {
cin >> a[i];
a[i]--;
}
int idx = 0;
vector<long long> ways(N, 0LL);
if (find(a.begin(), a.end(), 0) == a.end())
ways[0] = 1;
else
idx = distance(a.begin(), find(a.begin(), a.end(), 0));
if (find(a.begin() + idx, a.end(), 1) == a.end())
ways[1] = 1;
else
idx = distance(a.begin(), find(a.begin(), a.end(), 1));
for (int i = 1; i < N; i++) {
if (find(a.begin() + idx, a.end(), i) != a.end()) {
idx = idx = distance(a.begin(), find(a.begin(), a.end(), i));
ways[i] = 0;
continue;
}
if (i >= 1)
ways[i] += ways[i - 1];
if (i >= 2)
ways[i] += ways[i - 2];
ways[i] %= mod;
}
cout << ways[N - 1] << endl;
return 0;
} | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
constexpr long long mod = 1e9 + 7;
int main() {
int N, M;
cin >> N >> M;
vector<int> a(M);
for (int i = 0; i < M; i++) {
cin >> a[i];
a[i]--;
}
int idx = 0;
vector<long long> ways(N, 0LL);
if (find(a.begin(), a.end(), 0) == a.end())
ways[0] = 1;
else
idx = distance(a.begin(), find(a.begin(), a.end(), 0));
if (find(a.begin() + idx, a.end(), 1) == a.end())
ways[1] = 1;
else
idx = distance(a.begin(), find(a.begin(), a.end(), 1));
for (int i = 1; i < N; i++) {
if (find(a.begin() + idx, a.end(), i) != a.end()) {
idx = distance(a.begin(), find(a.begin() + idx, a.end(), i));
ways[i] = 0;
continue;
}
if (i >= 1)
ways[i] += ways[i - 1];
if (i >= 2)
ways[i] += ways[i - 2];
ways[i] %= mod;
}
cout << ways[N - 1] << endl;
return 0;
} | replace | 31 | 32 | 31 | 32 | TLE | |
p03013 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// value
int N, M;
vi a;
vl dp;
void solve() {
cin >> N >> M;
a.resize(M);
for (int i = 0; i < M; i++) {
cin >> a[i];
}
dp.resize(N + 1);
dp[0] = 1;
int cur = 0;
if (a[0] != 1)
dp[1] = 1;
else {
dp[1] = 0;
cur++;
}
for (ll i = 2; i <= N; i++) {
if (cur < M && i == a[cur]) {
dp[i] = 0;
cur++;
continue;
}
dp[i] = dp[i - 1] + dp[i - 2];
dp[i] %= MOD;
}
cout << dp[N] % MOD << endl;
return;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
solve();
return 0;
} | #include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// value
int N, M;
vi a;
vl dp;
void solve() {
cin >> N >> M;
a.resize(M);
for (int i = 0; i < M; i++) {
cin >> a[i];
}
dp.resize(N + 1);
dp[0] = 1;
int cur = 0;
dp[1] = 1;
if (a.size() != 0) {
if (a[0] != 1)
dp[1] = 1;
else {
dp[1] = 0;
cur++;
}
}
for (ll i = 2; i <= N; i++) {
if (cur < M && i == a[cur]) {
dp[i] = 0;
cur++;
continue;
}
dp[i] = dp[i - 1] + dp[i - 2];
dp[i] %= MOD;
}
cout << dp[N] % MOD << endl;
return;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
solve();
return 0;
}
| replace | 56 | 61 | 56 | 64 | 0 | |
p03013 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
int N, M;
ll dp[111111];
int main() {
cin >> N >> M;
vector<int> a(M);
for (int i = 0; i < M; i++) {
cin >> a[i];
}
M = 0;
dp[0] = 1;
if (a[0] == 1)
M++;
else
dp[1] = 1;
for (int i = 2; i <= N; i++) {
if (a[M] == i)
M++;
else
dp[i] = dp[i - 1] + dp[i - 2];
dp[i] %= mod;
}
cout << dp[N] << endl;
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
int N, M;
ll dp[111111];
int main() {
cin >> N >> M;
vector<int> a(M + 1);
for (int i = 0; i < M; i++) {
cin >> a[i];
}
M = 0;
dp[0] = 1;
if (a[0] == 1)
M++;
else
dp[1] = 1;
for (int i = 2; i <= N; i++) {
if (a[M] == i)
M++;
else
dp[i] = dp[i - 1] + dp[i - 2];
dp[i] %= mod;
}
cout << dp[N] << endl;
} | replace | 12 | 13 | 12 | 13 | 0 | |
p03013 | C++ | Runtime Error | #include <bits/stdc++.h>
#define int long long
#define ll long long
#define rep(i, a, b) for (signed i = a; i < (b); ++i)
#define erep(i, a, b) for (signed i = a; i <= (b); ++i)
#define per(i, a, b) for (signed i = (a); i > (b); --i)
#define eper(i, a, b) for (signed i = (a); i >= b; --i)
#define fore(i, x, a) for (auto &&x : a)
#define ITR(i, b, e) for (auto i = (b); i != (e); ++i)
#define pb emplace_back
#define mp make_pair
#define ALL(x) begin(x), end(x)
#define F first
#define S second
#define debug(x) cout << #x << ": " << (x) << '\n';
const long long INF = 1001001001001001001;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
using namespace std;
using Pii = pair<int, int>;
using vii = vector<int>;
template <class T> using PS_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T> using vv = vector<T>;
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
fill((T *)array, (T *)(array + N), val);
}
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
struct edge {
int from, to, cost;
};
int dy[] = {0, 1, -1, 0};
int dx[] = {1, 0, 0, -1};
// cout << fixed << setprecision(10) << val;
int n, m, dp[100005];
vii a;
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> n >> m;
a.resize(m);
for (int i = 0; i < m; i++) {
int t;
cin >> t;
a[t] = 1;
}
dp[n] = 1;
for (int i = n - 1; i >= 0; i--) {
if (a[i]) {
dp[i] = 0;
continue;
}
dp[i] = (dp[i + 1] + dp[i + 2]) % MOD;
}
cout << dp[0] << endl;
return 0;
}
| #include <bits/stdc++.h>
#define int long long
#define ll long long
#define rep(i, a, b) for (signed i = a; i < (b); ++i)
#define erep(i, a, b) for (signed i = a; i <= (b); ++i)
#define per(i, a, b) for (signed i = (a); i > (b); --i)
#define eper(i, a, b) for (signed i = (a); i >= b; --i)
#define fore(i, x, a) for (auto &&x : a)
#define ITR(i, b, e) for (auto i = (b); i != (e); ++i)
#define pb emplace_back
#define mp make_pair
#define ALL(x) begin(x), end(x)
#define F first
#define S second
#define debug(x) cout << #x << ": " << (x) << '\n';
const long long INF = 1001001001001001001;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
using namespace std;
using Pii = pair<int, int>;
using vii = vector<int>;
template <class T> using PS_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T> using vv = vector<T>;
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
fill((T *)array, (T *)(array + N), val);
}
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
struct edge {
int from, to, cost;
};
int dy[] = {0, 1, -1, 0};
int dx[] = {1, 0, 0, -1};
// cout << fixed << setprecision(10) << val;
int n, m, dp[100005];
vii a;
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> n >> m;
a.resize(n);
for (int i = 0; i < m; i++) {
int t;
cin >> t;
a[t] = 1;
}
dp[n] = 1;
for (int i = n - 1; i >= 0; i--) {
if (a[i]) {
dp[i] = 0;
continue;
}
dp[i] = (dp[i + 1] + dp[i + 2]) % MOD;
}
cout << dp[0] << endl;
return 0;
}
| replace | 57 | 58 | 57 | 58 | 0 | |
p03013 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int64_t dp[100000];
dp[0] = 1;
dp[1] = 1;
dp[2] = 2;
for (int i = 1; i < 100000; i++) {
dp[i + 2] = dp[i] % 1000000007 + dp[i + 1] % 1000000007;
}
int N;
cin >> N;
int M;
cin >> M;
vector<int> sd(M);
int c = 1;
for (int i = 0; i < M; i++)
{
int a;
cin >> a;
sd.at(i) = a;
if (i > 0 && sd.at(i) - sd.at(i - 1) == 1) {
c = 0;
}
}
if (c == 0)
cout << 0;
else {
int64_t g = 1;
for (int i = 0; i < M + 1; i++) {
if (i == M)
g = g * dp[N - sd.at(M - 1) - 1] % 1000000007;
if (i == M - 1)
g = g * dp[sd.at(0) - 1];
else if (i < M - 1)
g = g * dp[sd.at(i + 1) - sd.at(i) - 2] % 1000000007;
}
cout << g << endl;
}
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int64_t dp[100000];
dp[0] = 1;
dp[1] = 1;
dp[2] = 2;
for (int i = 1; i < 100000; i++) {
dp[i + 2] = dp[i] % 1000000007 + dp[i + 1] % 1000000007;
}
int N;
cin >> N;
int M;
cin >> M;
vector<int> sd(M);
int c = 1;
for (int i = 0; i < M; i++)
{
int a;
cin >> a;
sd.at(i) = a;
if (i > 0 && sd.at(i) - sd.at(i - 1) == 1) {
c = 0;
}
}
if (c == 0)
cout << 0;
else if (M == 0)
cout << dp[N];
else {
int64_t g = 1;
for (int i = 0; i < M + 1; i++) {
if (i == M)
g = g * dp[N - sd.at(M - 1) - 1] % 1000000007;
if (i == M - 1)
g = g * dp[sd.at(0) - 1];
else if (i < M - 1)
g = g * dp[sd.at(i + 1) - sd.at(i) - 2] % 1000000007;
}
cout << g << endl;
}
} | insert | 30 | 30 | 30 | 32 | -6 | *** stack smashing detected ***: terminated
|
p03013 | C++ | Time Limit Exceeded | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#define mst(a, b) memset(a, b, sizeof(a))
#define repi(a, b) for (ll i = a; i < b; i++)
#define repj(a, b) for (ll j = a; j < b; j++)
#define pii pair<int, int>
#ifdef LOCAL
#define fre() freopen("in.txt", "r", stdin)
#endif
#ifndef LOCAL
#define fre()
#endif
// static int x = []() {
// std::ios::sync_with_stdio(false);
// std::cin.tie(NULL);
// return 0;
// }();
#define FASTIO
#ifdef FASTIO
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
// #define scanf abcabc
// #define printf abcabc
#endif
// #ifndef FASTIO
// #define cin abcabc
// #define cout abcabc
// #endif
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
using namespace std;
const int mod = 1000000007;
int a[100010], vis[100010];
int rifa(int x) {
if (a[x])
return 0;
if (vis[x])
return vis[x];
if (x == 1)
return 1;
else if (x == 2)
return rifa(x - 1) + 1;
int tmp = (rifa(x - 1) + rifa(x - 2)) % mod;
vis[x] = tmp;
return tmp;
}
int main() {
fre();
IOS;
int n, m;
cin >> n >> m;
repi(0, m) {
int tmp;
cin >> tmp;
a[tmp] = 1;
}
cout << rifa(n) << endl;
return 0;
}
| #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#define mst(a, b) memset(a, b, sizeof(a))
#define repi(a, b) for (ll i = a; i < b; i++)
#define repj(a, b) for (ll j = a; j < b; j++)
#define pii pair<int, int>
#ifdef LOCAL
#define fre() freopen("in.txt", "r", stdin)
#endif
#ifndef LOCAL
#define fre()
#endif
// static int x = []() {
// std::ios::sync_with_stdio(false);
// std::cin.tie(NULL);
// return 0;
// }();
#define FASTIO
#ifdef FASTIO
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
// #define scanf abcabc
// #define printf abcabc
#endif
// #ifndef FASTIO
// #define cin abcabc
// #define cout abcabc
// #endif
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
using namespace std;
const int mod = 1000000007;
int a[100010], vis[100010];
int rifa(int x) {
if (a[x])
return 0;
if (vis[x])
return vis[x];
if (x == 1)
return 1;
else if (x == 2)
return rifa(x - 1) + 1;
int tmp = (rifa(x - 1) + rifa(x - 2)) % mod;
vis[x] = tmp;
return tmp;
}
int main() {
fre();
IOS;
int n, m;
cin >> n >> m;
repi(0, m) {
int tmp;
cin >> tmp;
a[tmp] = 1;
if (a[tmp - 1] || a[tmp + 1]) {
cout << "0\n";
return 0;
}
}
cout << rifa(n) << endl;
return 0;
}
| insert | 75 | 75 | 75 | 79 | TLE | |
p03013 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
#define mod 1000000007
int main() {
ll n, m;
cin >> n >> m;
vector<ll> a(m);
for (ll i = 0; i < m; i++) {
cin >> a[i];
}
vector<ll> f(n + 1);
f[0] = 1;
f[1] = 1;
ll next = 0;
if (a[0] == 1) {
f[1] = 0;
if (next < m - 1)
next++;
}
for (ll i = 2; i <= n; i++) {
f[i] = f[i - 1] + f[i - 2];
if (a[next] == i && next <= m - 1) {
f[i] = 0;
if (next < m - 1)
next++;
}
f[i] %= mod;
}
cout << f[n] << endl;
return 0;
}
| #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
#define mod 1000000007
int main() {
ll n, m;
cin >> n >> m;
vector<ll> a(m + 3);
for (ll i = 0; i < m; i++) {
cin >> a[i];
}
vector<ll> f(n + 1);
f[0] = 1;
f[1] = 1;
ll next = 0;
if (a[0] == 1) {
f[1] = 0;
if (next < m - 1)
next++;
}
for (ll i = 2; i <= n; i++) {
f[i] = f[i - 1] + f[i - 2];
if (a[next] == i && next <= m - 1) {
f[i] = 0;
if (next < m - 1)
next++;
}
f[i] %= mod;
}
cout << f[n] << endl;
return 0;
} | replace | 12 | 13 | 12 | 13 | 0 | |
p03013 | Python | Runtime Error | n, m = map(int, input().split())
A = set()
for i in range(m):
a = int(input())
A.add(a)
dp = [0] * (n + 1)
for i in range(n + 1):
if i in a:
dp[i] = 0
else:
if i == 0:
dp[i] = 1
elif i == 1:
dp[i] = 1
else:
dp[i] = (dp[i - 1] + dp[i - 2]) % 1000000007
print(dp[n])
"""
100 5
1
23
45
67
89
"""
| n, m = map(int, input().split())
A = set()
for i in range(m):
a = int(input())
A.add(a)
dp = [0] * (n + 1)
for i in range(n + 1):
if i in A:
dp[i] = 0
else:
if i == 0:
dp[i] = 1
elif i == 1:
dp[i] = 1
else:
dp[i] = (dp[i - 1] + dp[i - 2]) % 1000000007
print(dp[n])
"""
100 5
1
23
45
67
89
"""
| replace | 7 | 8 | 7 | 8 | TypeError: argument of type 'int' is not iterable | Traceback (most recent call last):
File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03013/Python/s357976971.py", line 8, in <module>
if i in a:
TypeError: argument of type 'int' is not iterable
|
p03013 | C++ | Runtime Error | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
int main() {
int n, m;
cin >> n >> m;
vector<int> broken(n);
rep(i, n) {
int a;
cin >> a;
broken[a] = 1;
}
vector<int> dp(n + 2);
const int mod = 1000000007;
dp[n] = 1;
for (int i = n - 1; i >= 0; i--) {
if (broken[i]) {
dp[i] = 0;
continue;
}
dp[i] = (dp[i + 1] + dp[i + 2]) % mod;
}
cout << dp[0] << endl;
return 0;
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
int main() {
int n, m;
cin >> n >> m;
vector<int> broken(n);
rep(i, m) {
int a;
cin >> a;
broken[a] = 1;
}
vector<int> dp(n + 2);
const int mod = 1000000007;
dp[n] = 1;
for (int i = n - 1; i >= 0; i--) {
if (broken[i]) {
dp[i] = 0;
continue;
}
dp[i] = (dp[i + 1] + dp[i + 2]) % mod;
}
cout << dp[0] << endl;
return 0;
}
| replace | 10 | 11 | 10 | 11 | 0 | |
p03013 | Python | Runtime Error | def solve():
N, M = map(int, input().split())
A = []
if M != 0:
A = [int(input()) for _ in range(M)]
A.sort(reverse=True)
mm = 10**9 + 7
dp = [0] * (N + 1)
dp[0] = 1 # 0段目に行くパターンは1とする
tag = -1
if len(A) != 0:
tag = A.pop()
# 1段目のパターンを設定
if tag == 1:
dp[1] = 0
tag = A.pop()
else:
dp[1] = 1
for i in range(2, N + 1):
if i == tag:
if len(A) == 0:
tag = -1
else:
tag = A.pop()
continue
dp[i] = (dp[i - 1] + dp[i - 2]) % mm
print(dp[N])
if __name__ == "__main__":
solve()
| def solve():
N, M = map(int, input().split())
A = []
if M != 0:
A = [int(input()) for _ in range(M)]
A.sort(reverse=True)
mm = 10**9 + 7
dp = [0] * (N + 1)
dp[0] = 1 # 0段目に行くパターンは1とする
tag = -1
if len(A) != 0:
tag = A.pop()
# 1段目のパターンを設定
if tag == 1:
dp[1] = 0
if len(A) == 0:
tag = -1
else:
tag = A.pop()
else:
dp[1] = 1
for i in range(2, N + 1):
if i == tag:
if len(A) == 0:
tag = -1
else:
tag = A.pop()
continue
dp[i] = (dp[i - 1] + dp[i - 2]) % mm
print(dp[N])
if __name__ == "__main__":
solve()
| replace | 15 | 16 | 15 | 19 | 0 | |
p03013 | Python | Runtime Error | n, m = list(map(int, input().split(" ")))
broken = [False] * (n + 1)
for i in range(m):
broken[int(input())] = True
mod = 1_000_000_007
dp = [0] * (n + 1)
dp[0] = 1
dp[1] = 0 if broken[1] else 1
for i in range(2, n + 1):
if broken[i]:
dp[i] = 0
else:
c = dp[i - 1] + dp[i - 2]
if c > mod:
c = c % mod
dp[i] = c
print(dp[n])
| n, m = list(map(int, input().split(" ")))
broken = [False] * (n + 1)
for i in range(m):
broken[int(input())] = True
mod = 1000000007
dp = [0] * (n + 1)
dp[0] = 1
dp[1] = 0 if broken[1] else 1
for i in range(2, n + 1):
if broken[i]:
dp[i] = 0
else:
c = dp[i - 1] + dp[i - 2]
if c > mod:
c = c % mod
dp[i] = c
print(dp[n])
| replace | 6 | 7 | 6 | 7 | 0 | |
p03013 | Python | Time Limit Exceeded | n, m = map(int, input().split())
a = [int(input()) for i in range(m)]
dp = [0] * (n + 1)
for i in range(n + 1):
if i in a:
dp[i] = 0
else:
if i == 0:
dp[i] = 1
elif i == 1:
dp[i] = 1
else:
dp[i] = (dp[i - 1] + dp[i - 2]) % 1000000007
print(dp[n])
| n, m = map(int, input().split())
a = set()
for i in range(m):
a_tmp = int(input())
a.add(a_tmp)
# a = [int(input()) for i in range(m)]
dp = [0] * (n + 1)
for i in range(n + 1):
if i in a:
dp[i] = 0
else:
if i == 0:
dp[i] = 1
elif i == 1:
dp[i] = 1
else:
dp[i] = (dp[i - 1] + dp[i - 2]) % 1000000007
print(dp[n])
| replace | 2 | 3 | 2 | 8 | TLE | |
p03014 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
const int MAX = 1e3 + 10;
typedef long long ll;
int main() {
int left[MAX][MAX], right[MAX][MAX], up[MAX][MAX], down[MAX][MAX];
char a[MAX][MAX];
int m, n;
cin >> m >> n;
for (int i = 1; i <= m; i++)
for (int j = 1; j <= n; j++)
cin >> a[i][j];
for (int i = 1; i <= m; i++) {
for (int j = 1; j <= n; j++) {
if (a[i][j] == '#')
left[i][j] = 0;
else
left[i][j] = 1 + left[i][j - 1];
}
}
for (int j = 1; j <= n; j++) {
for (int i = 1; i <= m; i++) {
if (a[i][j] == '#')
up[i][j] = 0;
else
up[i][j] = 1 + up[i - 1][j];
}
}
for (int i = 1; i <= m; i++) {
for (int j = n; j > 0; j--) {
if (a[i][j] == '#')
right[i][j] = 0;
else
right[i][j] = 1 + right[i][j + 1];
}
}
for (int j = 1; j <= n; j++) {
for (int i = m; i > 0; i--) {
if (a[i][j] == '#')
down[i][j] = 0;
else
down[i][j] = 1 + down[i + 1][j];
}
}
int ans = 0;
for (int i = 1; i <= m; i++) {
for (int j = 1; j <= n; j++) {
int t = left[i][j] + right[i][j] + up[i][j] + down[i][j] - 3;
ans = max(ans, t);
}
}
cout << ans;
} | #include <bits/stdc++.h>
using namespace std;
const int MAX = 2e3 + 10;
typedef long long ll;
int main() {
int left[MAX][MAX], right[MAX][MAX], up[MAX][MAX], down[MAX][MAX];
char a[MAX][MAX];
int m, n;
cin >> m >> n;
for (int i = 1; i <= m; i++)
for (int j = 1; j <= n; j++)
cin >> a[i][j];
for (int i = 1; i <= m; i++) {
for (int j = 1; j <= n; j++) {
if (a[i][j] == '#')
left[i][j] = 0;
else
left[i][j] = 1 + left[i][j - 1];
}
}
for (int j = 1; j <= n; j++) {
for (int i = 1; i <= m; i++) {
if (a[i][j] == '#')
up[i][j] = 0;
else
up[i][j] = 1 + up[i - 1][j];
}
}
for (int i = 1; i <= m; i++) {
for (int j = n; j > 0; j--) {
if (a[i][j] == '#')
right[i][j] = 0;
else
right[i][j] = 1 + right[i][j + 1];
}
}
for (int j = 1; j <= n; j++) {
for (int i = m; i > 0; i--) {
if (a[i][j] == '#')
down[i][j] = 0;
else
down[i][j] = 1 + down[i + 1][j];
}
}
int ans = 0;
for (int i = 1; i <= m; i++) {
for (int j = 1; j <= n; j++) {
int t = left[i][j] + right[i][j] + up[i][j] + down[i][j] - 3;
ans = max(ans, t);
}
}
cout << ans;
} | replace | 3 | 4 | 3 | 4 | -11 | |
p03014 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define mod 1000000007
#define rep(i, k, N) for (int i = k; i < N; i++)
#define MP make_pair
#define MT make_tuple // tie,make_tuple は別物
#define PB push_back
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main() {
int H, W;
cin >> H >> W;
char grid[201][201];
int ans[201][201] = {};
vector<queue<int>> q(2001);
vector<queue<int>> r(2001);
rep(i, 0, H) rep(j, 0, W) {
cin >> grid[i][j];
if (grid[i][j] == '#') {
q[i].push(j);
r[j].push(i);
}
}
int m, u;
rep(i, 0, H) { q[i].push(W); }
rep(i, 0, W) { r[i].push(H); }
rep(i, 0, H) {
m = -1;
u = q[i].front();
q[i].pop();
rep(j, 0, W) {
if (u > j) {
ans[i][j] += (u - m - 1);
} else if (u == j) {
m = u;
u = q[i].front();
q[i].pop();
}
}
}
rep(j, 0, W) {
m = -1;
u = r[j].front();
r[j].pop();
rep(i, 0, H) {
if (u > i) {
ans[i][j] += (u - m - 1);
} else if (u == i) {
m = u;
u = r[j].front();
r[j].pop();
}
}
}
int maxa = 0;
rep(i, 0, H) rep(j, 0, W) { maxa = max(maxa, ans[i][j]); }
if (maxa != 0)
cout << maxa - 1;
else
cout << 0;
return 0;
} | #include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define mod 1000000007
#define rep(i, k, N) for (int i = k; i < N; i++)
#define MP make_pair
#define MT make_tuple // tie,make_tuple は別物
#define PB push_back
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main() {
int H, W;
cin >> H >> W;
char grid[2001][2001];
int ans[2001][2001] = {};
vector<queue<int>> q(2001);
vector<queue<int>> r(2001);
rep(i, 0, H) rep(j, 0, W) {
cin >> grid[i][j];
if (grid[i][j] == '#') {
q[i].push(j);
r[j].push(i);
}
}
int m, u;
rep(i, 0, H) { q[i].push(W); }
rep(i, 0, W) { r[i].push(H); }
rep(i, 0, H) {
m = -1;
u = q[i].front();
q[i].pop();
rep(j, 0, W) {
if (u > j) {
ans[i][j] += (u - m - 1);
} else if (u == j) {
m = u;
u = q[i].front();
q[i].pop();
}
}
}
rep(j, 0, W) {
m = -1;
u = r[j].front();
r[j].pop();
rep(i, 0, H) {
if (u > i) {
ans[i][j] += (u - m - 1);
} else if (u == i) {
m = u;
u = r[j].front();
r[j].pop();
}
}
}
int maxa = 0;
rep(i, 0, H) rep(j, 0, W) { maxa = max(maxa, ans[i][j]); }
if (maxa != 0)
cout << maxa - 1;
else
cout << 0;
return 0;
} | replace | 23 | 25 | 23 | 25 | 0 | |
p03014 | C++ | Runtime Error | #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;
}
| replace | 38 | 39 | 38 | 39 | 0 | |
p03014 | C++ | Time Limit Exceeded | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<string, int> P;
const ll MOD = 1e9 + 7;
string s[2000];
int irui[2000][2000];
int jrui[2000][2000];
int main() {
int h, w;
cin >> h >> w;
for (int i = 0; i < h; i++)
cin >> s[i];
for (int i = 0; i < h; i++) {
if (s[i][0] == '.')
jrui[i][0] = 1;
}
for (int i = 0; i < w; i++)
if (s[0][i] == '.')
irui[0][i] = 1;
for (int i = 0; i < h; i++) {
for (int j = 1; j < w; j++) {
if (s[i][j] == '#')
jrui[i][j] = 0;
else
jrui[i][j] = jrui[i][j - 1] + 1;
}
}
for (int j = 0; j < w; j++) {
for (int i = 1; i < h; i++) {
if (s[i][j] == '#')
irui[i][j] = 0;
else
irui[i][j] = irui[i - 1][j] + 1;
}
}
for (int i = 0; i < h; i++) {
for (int j = w - 2; j > -1; j--) {
if (jrui[i][j] > 0 && jrui[i][j + 1] > 0)
jrui[i][j] = jrui[i][j + 1];
}
}
for (int j = 0; j < w; j++) {
for (int i = h - 2; i > -1; i--) {
if (irui[i][j] > 0 && irui[i + 1][j] > 0)
irui[i][j] = irui[i + 1][j];
}
}
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++)
cerr << jrui[i][j] << " ";
cerr << endl;
}
int ans = 0;
for (int i = 0; i < h; i++)
for (int j = 0; j < w; j++)
if (s[i][j] == '.')
ans = max(ans, irui[i][j] + jrui[i][j] - 1);
cout << ans << endl;
return 0;
} | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<string, int> P;
const ll MOD = 1e9 + 7;
string s[2000];
int irui[2000][2000];
int jrui[2000][2000];
int main() {
int h, w;
cin >> h >> w;
for (int i = 0; i < h; i++)
cin >> s[i];
for (int i = 0; i < h; i++) {
if (s[i][0] == '.')
jrui[i][0] = 1;
}
for (int i = 0; i < w; i++)
if (s[0][i] == '.')
irui[0][i] = 1;
for (int i = 0; i < h; i++) {
for (int j = 1; j < w; j++) {
if (s[i][j] == '#')
jrui[i][j] = 0;
else
jrui[i][j] = jrui[i][j - 1] + 1;
}
}
for (int j = 0; j < w; j++) {
for (int i = 1; i < h; i++) {
if (s[i][j] == '#')
irui[i][j] = 0;
else
irui[i][j] = irui[i - 1][j] + 1;
}
}
for (int i = 0; i < h; i++) {
for (int j = w - 2; j > -1; j--) {
if (jrui[i][j] > 0 && jrui[i][j + 1] > 0)
jrui[i][j] = jrui[i][j + 1];
}
}
for (int j = 0; j < w; j++) {
for (int i = h - 2; i > -1; i--) {
if (irui[i][j] > 0 && irui[i + 1][j] > 0)
irui[i][j] = irui[i + 1][j];
}
}
/*
for(int i=0;i<h;i++)
{
for(int j=0;j<w;j++)
cerr<<jrui[i][j]<<" ";
cerr<<endl;
}*/
int ans = 0;
for (int i = 0; i < h; i++)
for (int j = 0; j < w; j++)
if (s[i][j] == '.')
ans = max(ans, irui[i][j] + jrui[i][j] - 1);
cout << ans << endl;
return 0;
} | replace | 53 | 58 | 53 | 60 | TLE | |
p03014 | C++ | Runtime Error | #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;
}
| replace | 14 | 15 | 14 | 15 | 0 | |
p03014 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
int main() {
int h, w;
cin >> h >> w;
char s[h][w];
rep(i, h) rep(j, w) cin >> s[i][j];
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(w);
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;
}
| #include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
int main() {
int h, w;
cin >> h >> w;
char s[h][w];
rep(i, h) rep(j, w) cin >> s[i][j];
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;
}
| replace | 40 | 41 | 40 | 41 | 0 | |
p03014 | C++ | Runtime Error | #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;
}
| replace | 70 | 71 | 70 | 71 | 0 | |
p03014 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
int L[2010][2010];
int R[2010][2010];
int U[2010][2010];
int D[2010][2010];
int main(int argc, char const *argv[]) {
int h, w;
cin >> h >> w;
vector<string> s(h);
rep(i, h) cin >> s[i];
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
if (s[i][j] == '.')
L[i + 1][j + 1] = L[i + 1][j] + 1;
else
L[i + 1][j + 1] = 0;
}
}
for (int i = 0; i < h; ++i) {
for (int j = w - 1; j >= 0; --j) {
if (s[i][j] == '.')
R[i + 1][j + 1] = R[i + 1][j + 2] + 1;
else
R[i + 1][j + 1] = 0;
}
}
for (int j = 0; j < w; ++j) {
for (int i = 0; i < h; ++i) {
if (s[i][j] == '.')
U[i + 1][j + 1] = U[i][j + 1] + 1;
else
U[i + 1][j + 1] = 0;
}
}
for (int j = 0; j < w; ++j) {
for (int i = h - 1; i >= 0; --i) {
if (s[i][j] == '.')
D[i + 1][j + 1] = D[i + 2][j + 1] + 1;
else
D[i - 1][j + 1] = 0;
}
}
int ans = 0;
rep(i, h) rep(j, w) {
if (s[i][j] == '#')
continue;
int y = U[i + 1][j + 1] + D[i + 1][j + 1] - 1;
int x = L[i + 1][j + 1] + R[i + 1][j + 1] - 1;
ans = max(ans, x + y - 1);
}
printf("%d\n", ans);
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
int L[2010][2010];
int R[2010][2010];
int U[2010][2010];
int D[2010][2010];
int main(int argc, char const *argv[]) {
int h, w;
cin >> h >> w;
vector<string> s(h);
rep(i, h) cin >> s[i];
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
if (s[i][j] == '.')
L[i + 1][j + 1] = L[i + 1][j] + 1;
else
L[i + 1][j + 1] = 0;
}
}
for (int i = 0; i < h; ++i) {
for (int j = w - 1; j >= 0; --j) {
if (s[i][j] == '.')
R[i + 1][j + 1] = R[i + 1][j + 2] + 1;
else
R[i + 1][j + 1] = 0;
}
}
for (int j = 0; j < w; ++j) {
for (int i = 0; i < h; ++i) {
if (s[i][j] == '.')
U[i + 1][j + 1] = U[i][j + 1] + 1;
else
U[i + 1][j + 1] = 0;
}
}
for (int j = 0; j < w; ++j) {
for (int i = h - 1; i >= 0; --i) {
if (s[i][j] == '.')
D[i + 1][j + 1] = D[i + 2][j + 1] + 1;
else
D[i + 1][j + 1] = 0;
}
}
int ans = 0;
rep(i, h) rep(j, w) {
if (s[i][j] == '#')
continue;
int y = U[i + 1][j + 1] + D[i + 1][j + 1] - 1;
int x = L[i + 1][j + 1] + R[i + 1][j + 1] - 1;
ans = max(ans, x + y - 1);
}
printf("%d\n", ans);
return 0;
}
| replace | 47 | 48 | 47 | 48 | 0 | |
p03014 | C++ | Runtime Error | #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;
} | replace | 56 | 57 | 56 | 57 | 0 | |
p03014 | C++ | Runtime Error | #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;
}
| replace | 353 | 354 | 353 | 354 | -11 | |
p03014 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;
static const uint64_t MOD = 1000000007LL;
// uint64_t dp[100005][13];
char grid[2000][2000];
int64_t wc[2000][2000];
int64_t hc[2000][2000];
/* yoko */
void updatewc(int i, int j) {
if (wc[i][j])
return;
int k = 0;
while (grid[i + k][j] == '.') {
k++;
}
for (int l = 0; l < k; l++) {
wc[i + l][j] = k;
}
}
/* tate */
void updatehc(int i, int j) {
if (hc[i][j])
return;
int k = 0;
while (grid[i][j + k] == '.') {
k++;
}
for (int l = 0; l < k; l++) {
hc[i][j + l] = k;
}
}
int main() {
int h, w;
cin >> h >> w;
for (int i = 0; i < h; i++) {
string s;
cin >> s;
for (int j = 0; j < w; j++) {
if (s[j] == '.')
grid[j][i] = '.';
}
}
for (int i = 0; i < w; i++) {
for (int j = 0; j < h; j++) {
if (grid[i][j] == '.') {
updatewc(i, j);
updatehc(i, j);
}
}
}
long cnt = 0;
for (int i = 0; i < w; i++) {
for (int j = 0; j < h; j++) {
cnt = max(wc[i][j] + hc[i][j] - 1, cnt);
}
}
cout << cnt << endl;
} | #include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;
static const uint64_t MOD = 1000000007LL;
// uint64_t dp[100005][13];
char grid[2005][2005];
int64_t wc[2000][2000];
int64_t hc[2000][2000];
/* yoko */
void updatewc(int i, int j) {
if (wc[i][j])
return;
int k = 0;
while (grid[i + k][j] == '.') {
k++;
}
for (int l = 0; l < k; l++) {
wc[i + l][j] = k;
}
}
/* tate */
void updatehc(int i, int j) {
if (hc[i][j])
return;
int k = 0;
while (grid[i][j + k] == '.') {
k++;
}
for (int l = 0; l < k; l++) {
hc[i][j + l] = k;
}
}
int main() {
int h, w;
cin >> h >> w;
for (int i = 0; i < h; i++) {
string s;
cin >> s;
for (int j = 0; j < w; j++) {
if (s[j] == '.')
grid[j][i] = '.';
}
}
for (int i = 0; i < w; i++) {
for (int j = 0; j < h; j++) {
if (grid[i][j] == '.') {
updatewc(i, j);
updatehc(i, j);
}
}
}
long cnt = 0;
for (int i = 0; i < w; i++) {
for (int j = 0; j < h; j++) {
cnt = max(wc[i][j] + hc[i][j] - 1, cnt);
}
}
cout << cnt << endl;
}
| replace | 10 | 11 | 10 | 11 | 0 | |
p03014 | C++ | Runtime Error | #include <bits/stdc++.h>
#define rep(i, m) for (long long i = 0; i < m; i++)
#define per(i, m) for (long long i = m - 1; i >= 0; i--)
#define FOR(i, n, m) for (long long i = n; i < m; i++)
#define ROF(i, n, m) for (long long i = m - 1; i >= n; i--)
#define SORT(v, n) \
do { \
sort(v, v + n); \
reverse(v, v + n); \
} while (0)
#define all(x) (x).begin(), (x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) \
cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
<< " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;
ll POW(ll x, ll n) {
if (n == 0)
return 1;
if (n % 2 == 0)
return POW(x * x, n / 2) % MOD;
return x % MOD * POW(x, n - 1) % MOD;
}
ll POW2(ll x, ll n) {
if (n == 0)
return 1;
if (n % 2 == 0)
return POW2(x * x, n / 2);
return x * POW2(x, n - 1);
}
ll gcd(ll u, ll v) {
ll r;
while (0 != v) {
r = u % v;
u = v;
v = r;
}
return u;
}
ll lcm(ll u, ll v) { return u * v / gcd(u, v); }
ll KAI(ll m) {
if (m < 0)
return 0;
if (m == 0)
return 1;
return m * KAI(m - 1) % MOD;
}
ll KAI2(ll m) {
if (m < 0)
return 0;
if (m == 0)
return 1;
return m * KAI2(m - 1);
}
ll extGCD(ll a, ll b, ll &x, ll &y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
ll d = extGCD(b, a % b, y, x);
y -= a / b * x;
return d;
}
inline ll mod(ll a, ll m) { return (a % m + m) % m; }
ll modinv(ll a) {
ll x, y;
extGCD(a, MOD, x, y);
return mod(x, MOD);
}
ll COM(ll m, ll n) {
if (m < n)
return 0;
if (n < 0)
return 0;
if (n == 0)
return 1;
if (m == n)
return 1;
return KAI(m) % MOD * modinv(KAI(n) % MOD * KAI(m - n) % MOD) % MOD;
}
ll COM2(ll m, ll n) {
if (m < n)
return 0;
if (n < 0)
return 0;
if (n == 0)
return 1;
if (m == n)
return 1;
return KAI2(m) / KAI2(n) / KAI2(m - n);
}
ll DEC(ll x, ll m, ll n) { return x % POW(m, n + 1) / POW(m, n); }
ll keta(ll x, ll n) {
if (x == 0)
return 0;
return keta(x / n, n) + 1;
}
ll DIV(ll x, ll n) {
if (x == 0)
return 0;
return x / n + DIV(x / n, n);
}
ll ORD(ll x, ll n) {
if (x == 0)
return INF;
if (x % n != 0)
return 0;
return 1 + ORD(x / n, n);
}
int main() {
ll h, w, t[300][300] = {}, u[300][300] = {}, c = 0, ans = 0;
string s[300];
cin >> h >> w;
rep(i, h) cin >> s[i];
rep(i, h) {
rep(j, w) {
if (s[i][j] == '.') {
c++;
t[i][j] = c;
} else {
c = 0;
t[i][j] = 0;
}
}
c = 0;
}
rep(i, h) {
per(j, w) {
if (c == 0 && s[i][j] == '.') {
c = t[i][j];
} else if (s[i][j] == '.') {
t[i][j] = c;
} else {
c = 0;
}
}
c = 0;
}
c = 0;
rep(i, w) {
rep(j, h) {
if (s[j][i] == '.') {
c++;
u[j][i] = c;
} else {
c = 0;
u[j][i] = 0;
}
}
c = 0;
}
c = 0;
rep(i, w) {
per(j, h) {
if (c == 0 && s[j][i] == '.') {
c = u[j][i];
} else if (s[j][i] == '.') {
u[j][i] = c;
} else {
c = 0;
}
}
c = 0;
}
rep(i, h) {
rep(j, w) { ans = max(ans, u[i][j] + t[i][j] - 1); }
}
printf("%lld", ans);
} | #include <bits/stdc++.h>
#define rep(i, m) for (long long i = 0; i < m; i++)
#define per(i, m) for (long long i = m - 1; i >= 0; i--)
#define FOR(i, n, m) for (long long i = n; i < m; i++)
#define ROF(i, n, m) for (long long i = m - 1; i >= n; i--)
#define SORT(v, n) \
do { \
sort(v, v + n); \
reverse(v, v + n); \
} while (0)
#define all(x) (x).begin(), (x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) \
cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
<< " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;
ll POW(ll x, ll n) {
if (n == 0)
return 1;
if (n % 2 == 0)
return POW(x * x, n / 2) % MOD;
return x % MOD * POW(x, n - 1) % MOD;
}
ll POW2(ll x, ll n) {
if (n == 0)
return 1;
if (n % 2 == 0)
return POW2(x * x, n / 2);
return x * POW2(x, n - 1);
}
ll gcd(ll u, ll v) {
ll r;
while (0 != v) {
r = u % v;
u = v;
v = r;
}
return u;
}
ll lcm(ll u, ll v) { return u * v / gcd(u, v); }
ll KAI(ll m) {
if (m < 0)
return 0;
if (m == 0)
return 1;
return m * KAI(m - 1) % MOD;
}
ll KAI2(ll m) {
if (m < 0)
return 0;
if (m == 0)
return 1;
return m * KAI2(m - 1);
}
ll extGCD(ll a, ll b, ll &x, ll &y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
ll d = extGCD(b, a % b, y, x);
y -= a / b * x;
return d;
}
inline ll mod(ll a, ll m) { return (a % m + m) % m; }
ll modinv(ll a) {
ll x, y;
extGCD(a, MOD, x, y);
return mod(x, MOD);
}
ll COM(ll m, ll n) {
if (m < n)
return 0;
if (n < 0)
return 0;
if (n == 0)
return 1;
if (m == n)
return 1;
return KAI(m) % MOD * modinv(KAI(n) % MOD * KAI(m - n) % MOD) % MOD;
}
ll COM2(ll m, ll n) {
if (m < n)
return 0;
if (n < 0)
return 0;
if (n == 0)
return 1;
if (m == n)
return 1;
return KAI2(m) / KAI2(n) / KAI2(m - n);
}
ll DEC(ll x, ll m, ll n) { return x % POW(m, n + 1) / POW(m, n); }
ll keta(ll x, ll n) {
if (x == 0)
return 0;
return keta(x / n, n) + 1;
}
ll DIV(ll x, ll n) {
if (x == 0)
return 0;
return x / n + DIV(x / n, n);
}
ll ORD(ll x, ll n) {
if (x == 0)
return INF;
if (x % n != 0)
return 0;
return 1 + ORD(x / n, n);
}
int main() {
ll h, w, t[3000][3000] = {}, u[3000][3000] = {}, c = 0, ans = 0;
string s[3000];
cin >> h >> w;
rep(i, h) cin >> s[i];
rep(i, h) {
rep(j, w) {
if (s[i][j] == '.') {
c++;
t[i][j] = c;
} else {
c = 0;
t[i][j] = 0;
}
}
c = 0;
}
rep(i, h) {
per(j, w) {
if (c == 0 && s[i][j] == '.') {
c = t[i][j];
} else if (s[i][j] == '.') {
t[i][j] = c;
} else {
c = 0;
}
}
c = 0;
}
c = 0;
rep(i, w) {
rep(j, h) {
if (s[j][i] == '.') {
c++;
u[j][i] = c;
} else {
c = 0;
u[j][i] = 0;
}
}
c = 0;
}
c = 0;
rep(i, w) {
per(j, h) {
if (c == 0 && s[j][i] == '.') {
c = u[j][i];
} else if (s[j][i] == '.') {
u[j][i] = c;
} else {
c = 0;
}
}
c = 0;
}
rep(i, h) {
rep(j, w) { ans = max(ans, u[i][j] + t[i][j] - 1); }
}
printf("%lld", ans);
} | replace | 133 | 135 | 133 | 135 | 0 | |
p03014 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
int n, m;
cin >> n >> m;
vector<string> s(n);
for (int i = 0; i < n; i++) {
cin >> s[i];
}
vector<vector<int>> l(n, vector<int>(m));
vector<vector<int>> r(n, vector<int>(m));
vector<vector<int>> u(n, vector<int>(m));
vector<vector<int>> d(n, vector<int>(m));
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; 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
l[i][j] = 0;
}
}
}
for (int i = 0; i < n; i++) {
for (int j = m - 1; j >= 0; j--) {
if (j == m - 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;
}
}
}
for (int j = 0; j < m; j++) {
for (int i = 0; i < n; i++) {
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 j = 0; j < n; j++) {
for (int i = n - 1; i >= 0; i--) {
if (i == n - 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;
}
}
}
int ans = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (s[i][j] == '.') {
ans = max(ans, l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3);
}
}
}
cout << ans;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
int n, m;
cin >> n >> m;
vector<string> s(n);
for (int i = 0; i < n; i++) {
cin >> s[i];
}
vector<vector<int>> l(n, vector<int>(m));
vector<vector<int>> r(n, vector<int>(m));
vector<vector<int>> u(n, vector<int>(m));
vector<vector<int>> d(n, vector<int>(m));
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; 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
l[i][j] = 0;
}
}
}
for (int i = 0; i < n; i++) {
for (int j = m - 1; j >= 0; j--) {
if (j == m - 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;
}
}
}
for (int j = 0; j < m; j++) {
for (int i = 0; i < n; i++) {
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 j = 0; j < m; j++) {
for (int i = n - 1; i >= 0; i--) {
if (i == n - 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;
}
}
}
int ans = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (s[i][j] == '.') {
ans = max(ans, l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3);
}
}
}
cout << ans;
return 0;
} | replace | 67 | 68 | 67 | 68 | 0 | |
p03014 | C++ | Runtime Error | #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;
} | replace | 32 | 33 | 32 | 33 | 0 | |
p03014 | C++ | Runtime Error | #include <algorithm>
#include <bits/stdc++.h>
#include <iomanip>
#include <iostream>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;
// typedef long long unsigned int ll;
typedef long long ll;
typedef pair<ll, ll> edge;
typedef tuple<ll, ll, ll> tp;
int main() {
ll h, w;
cin >> h >> w;
string S[h];
for (int i = 0; i < h; i++)
cin >> S[h];
cout << S[0][0] << endl;
int R[h][w];
int L[h][w];
int U[h][w];
int D[h][w];
for (int i = 0; i < h; i++) {
if (S[i][w - 1] == '.')
R[i][w - 1] = 1;
else
R[i][w - 1] = 0;
if (S[i][0] == '.')
L[i][0] = 1;
else
L[i][0] = 0;
}
for (int i = 0; i < w; i++) {
if (S[h - 1][i] == '.')
D[h - 1][i] = 1;
else
D[h - 1][i] = 0;
if (S[0][i] == '.')
U[0][i] = 1;
else
U[0][i] = 0;
}
for (int i = 1; i < w; i++) {
for (int j = 0; j < h; j++) {
if (S[j][w - 1 - i] == '.')
R[j][w - 1 - i] = R[j][w - i] + 1;
else
R[j][w - 1 - i] = 0;
if (S[j][i] == '.')
L[j][i] = L[j][i - 1] + 1;
else
L[j][i] = 0;
}
}
for (int i = 1; i < h; i++) {
for (int j = 0; j < w; j++) {
if (S[h - 1 - i][j] == '.')
D[h - 1 - i][j] = D[h - i][j] + 1;
else
D[h - 1 - i][j] = 0;
if (S[i][j] == '.')
U[i][j] = U[i - 1][j] + 1;
else
U[i][j] = 0;
}
}
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] + U[i][j] + D[i][j]);
}
}
cout << ans - 3 << endl;
} | #include <algorithm>
#include <bits/stdc++.h>
#include <iomanip>
#include <iostream>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;
// typedef long long unsigned int ll;
typedef long long ll;
typedef pair<ll, ll> edge;
typedef tuple<ll, ll, ll> tp;
int main() {
ll h, w;
cin >> h >> w;
string S[h];
for (int i = 0; i < h; i++)
cin >> S[i];
// cout << S[0][0] << endl;
int R[h][w];
int L[h][w];
int U[h][w];
int D[h][w];
for (int i = 0; i < h; i++) {
if (S[i][w - 1] == '.')
R[i][w - 1] = 1;
else
R[i][w - 1] = 0;
if (S[i][0] == '.')
L[i][0] = 1;
else
L[i][0] = 0;
}
for (int i = 0; i < w; i++) {
if (S[h - 1][i] == '.')
D[h - 1][i] = 1;
else
D[h - 1][i] = 0;
if (S[0][i] == '.')
U[0][i] = 1;
else
U[0][i] = 0;
}
for (int i = 1; i < w; i++) {
for (int j = 0; j < h; j++) {
if (S[j][w - 1 - i] == '.')
R[j][w - 1 - i] = R[j][w - i] + 1;
else
R[j][w - 1 - i] = 0;
if (S[j][i] == '.')
L[j][i] = L[j][i - 1] + 1;
else
L[j][i] = 0;
}
}
for (int i = 1; i < h; i++) {
for (int j = 0; j < w; j++) {
if (S[h - 1 - i][j] == '.')
D[h - 1 - i][j] = D[h - i][j] + 1;
else
D[h - 1 - i][j] = 0;
if (S[i][j] == '.')
U[i][j] = U[i - 1][j] + 1;
else
U[i][j] = 0;
}
}
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] + U[i][j] + D[i][j]);
}
}
cout << ans - 3 << endl;
} | replace | 18 | 20 | 18 | 21 | -11 | |
p03014 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;
#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a) { return is >> a.first >> a.second; }
ostream &operator<<(ostream &os, const P &a) {
return os << "(" << a.first << "," << a.second << ")";
}
template <typename T>
void view(const std::vector<T> &v) {
#ifndef ONLINE_JUDGE
for (const auto &e : v) {
std::cout << e << " ";
}
std::cout << std::endl;
#endif
}
template <typename T> void view(const std::vector<std::vector<T>> &vv) {
for (const auto &v : vv) {
view(v);
}
}
#pragma endregion
int main() {
int h, w;
cin >> h >> w;
vvchar g(h, vchar(w));
rep(y, h) rep(x, w) cin >> g[y][x];
int ans = 0;
rep(y, h) rep(x, w) {
if (g[y][x] == '#')
continue;
int now = 0;
for (int ry = y; ry <= h; ry++) {
if (ry >= h || g[ry][x] == '#') {
now += ry - y - 1;
break;
}
}
for (int ry = y; ry >= -1; ry--) {
if (ry < 0 || g[ry][x] == '#') {
now += y - ry - 1;
break;
}
}
for (int rx = x; rx <= w; rx++) {
if (rx >= w || g[y][rx] == '#') {
now += rx - x - 1;
break;
}
}
for (int rx = x; rx >= -1; rx--) {
if (rx < 0 || g[y][rx] == '#') {
now += x - rx - 1;
break;
}
}
ans = max(ans, now + 1);
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;
#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a) { return is >> a.first >> a.second; }
ostream &operator<<(ostream &os, const P &a) {
return os << "(" << a.first << "," << a.second << ")";
}
template <typename T>
void view(const std::vector<T> &v) {
#ifndef ONLINE_JUDGE
for (const auto &e : v) {
std::cout << e << " ";
}
std::cout << std::endl;
#endif
}
template <typename T> void view(const std::vector<std::vector<T>> &vv) {
for (const auto &v : vv) {
view(v);
}
}
#pragma endregion
int main() {
int h, w;
cin >> h >> w;
vvchar g(h, vchar(w));
rep(y, h) rep(x, w) cin >> g[y][x];
int ans = 0;
rep(y, h) rep(x, w) {
if (g[y][x] == '#')
continue;
if (ans == h + w - 1)
break;
int now = 0;
for (int ry = y; ry <= h; ry++) {
if (ry >= h || g[ry][x] == '#') {
now += ry - y - 1;
break;
}
}
for (int ry = y; ry >= -1; ry--) {
if (ry < 0 || g[ry][x] == '#') {
now += y - ry - 1;
break;
}
}
for (int rx = x; rx <= w; rx++) {
if (rx >= w || g[y][rx] == '#') {
now += rx - x - 1;
break;
}
}
for (int rx = x; rx >= -1; rx--) {
if (rx < 0 || g[y][rx] == '#') {
now += x - rx - 1;
break;
}
}
ans = max(ans, now + 1);
}
cout << ans << endl;
return 0;
} | insert | 48 | 48 | 48 | 50 | TLE | |
p03014 | C++ | Runtime Error | #include "bits/stdc++.h"
using namespace std;
using ll = long long;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int h, w;
cin >> h >> w;
vector<string> g(h);
for (auto &x : g)
cin >> x;
vector<vector<int>> x(h, vector<int>(w, 0)), y(h, vector<int>(w, 0));
for (int i = 0; i < h; i++) {
int j = 0;
while (j < w) {
if (g[i][j] == '#') {
j++;
continue;
}
int q = j;
while (q < w && g[i][q] == '.')
q++;
int l = q - j;
for (int k = j; k < q; k++)
x[i][k] = l;
j = q;
}
}
for (int i = 0; i < w; i++) {
int j = 0;
while (j < h) {
if (g[j][i] == '#') {
j++;
continue;
}
int q = j;
while (q < w && g[q][i] == '.')
q++;
int l = q - j;
for (int k = j; k < q; k++)
y[k][i] = l;
j = q;
}
}
int ans = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
ans = max(ans, x[i][j] + y[i][j] - 1);
}
}
cout << ans << endl;
return 0;
}
| #include "bits/stdc++.h"
using namespace std;
using ll = long long;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int h, w;
cin >> h >> w;
vector<string> g(h);
for (auto &x : g)
cin >> x;
vector<vector<int>> x(h, vector<int>(w, 0)), y(h, vector<int>(w, 0));
for (int i = 0; i < h; i++) {
int j = 0;
while (j < w) {
if (g[i][j] == '#') {
j++;
continue;
}
int q = j;
while (q < w && g[i][q] == '.')
q++;
int l = q - j;
for (int k = j; k < q; k++)
x[i][k] = l;
j = q;
}
}
for (int i = 0; i < w; i++) {
int j = 0;
while (j < h) {
if (g[j][i] == '#') {
j++;
continue;
}
int q = j;
while (q < h && g[q][i] == '.')
q++;
int l = q - j;
for (int k = j; k < q; k++)
y[k][i] = l;
j = q;
}
}
int ans = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
ans = max(ans, x[i][j] + y[i][j] - 1);
}
}
cout << ans << endl;
return 0;
}
| replace | 44 | 45 | 44 | 45 | -11 | |
p03014 | C++ | Time Limit Exceeded | // #define _GLIBCXX_DEBUG
#include <algorithm>
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod = 1e+9 + 7;
int main() {
int h, w;
cin >> h >> w;
vector<vector<char>> a(h + 2, vector<char>(w + 2));
rep(i, w + 2) {
a[0][i] = '#';
a[h + 1][i] = '#';
}
rep(i, h + 2) {
a[i][0] = '#';
a[i][w + 1] = '#';
}
for (int i = 1; i <= h; i++) {
for (int j = 1; j <= w; j++) {
cin >> a[i][j];
}
}
int cnt;
int ii, jj;
int mx = 0;
for (int i = 1; i <= h; i++) {
for (int j = 1; j <= w; j++) {
if (a[i][j] == '#')
continue;
cnt = 1;
ii = i;
while (a[ii + 1][j] == '.') {
cnt++;
ii++;
}
ii = i;
while (a[ii - 1][j] == '.') {
cnt++;
ii--;
}
jj = j;
while (a[i][jj + 1] == '.') {
cnt++;
jj++;
}
jj = j;
while (a[i][jj - 1] == '.') {
cnt++;
jj--;
}
mx = max(mx, cnt);
}
}
cout << mx << endl;
}
| // #define _GLIBCXX_DEBUG
#include <algorithm>
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod = 1e+9 + 7;
int main() {
int h, w;
cin >> h >> w;
vector<vector<char>> a(h + 2, vector<char>(w + 2));
rep(i, w + 2) {
a[0][i] = '#';
a[h + 1][i] = '#';
}
rep(i, h + 2) {
a[i][0] = '#';
a[i][w + 1] = '#';
}
for (int i = 1; i <= h; i++) {
for (int j = 1; j <= w; j++) {
cin >> a[i][j];
}
}
int cnt;
int ii, jj;
int mx = 0;
for (int i = 1; i <= h; i++) {
for (int j = 1; j <= w; j++) {
if (a[i][j] == '#')
continue;
cnt = 1;
ii = i;
while (a[ii + 1][j] == '.') {
cnt++;
ii++;
}
ii = i;
while (a[ii - 1][j] == '.') {
cnt++;
ii--;
}
jj = j;
while (a[i][jj + 1] == '.') {
cnt++;
jj++;
}
jj = j;
while (a[i][jj - 1] == '.') {
cnt++;
jj--;
}
mx = max(mx, cnt);
if (mx == h + w - 1) {
cout << mx << endl;
return 0;
}
}
}
cout << mx << endl;
}
| insert | 56 | 56 | 56 | 60 | TLE | |
p03014 | C++ | Time Limit Exceeded | #include <algorithm>
#include <iostream>
#include <limits.h>
#include <map>
#include <queue>
#include <string>
#include <vector>
#define ll long long
using namespace std;
int main() {
int h, w;
cin >> h >> w;
vector<string> s;
vector<vector<int>> snh;
vector<vector<int>> snw;
for (int i = 0; i < h; i++) {
string tmp;
cin >> tmp;
s.push_back(tmp);
vector<int> tmpv;
int tmpcount = 0;
for (int j = 0; j < w; j++) {
if (tmp[j] == '.') {
tmpcount++;
tmpv.push_back(tmpcount);
} else {
tmpcount = 0;
tmpv.push_back(tmpcount);
}
}
tmpcount = 0;
for (int j = w - 1; j > -1; j--) {
if (tmpv[j] == 0) {
tmpcount = 0;
} else {
tmpcount = max(tmpcount, tmpv[j]);
tmpv[j] = tmpcount;
}
}
snh.push_back(tmpv);
}
for (int i = 0; i < w; i++) {
vector<int> tmpv;
int tmpcount = 0;
for (int j = 0; j < h; j++) {
if (s[j][i] == '.') {
tmpcount++;
tmpv.push_back(tmpcount);
} else {
tmpcount = 0;
tmpv.push_back(tmpcount);
}
}
tmpcount = 0;
for (int j = h - 1; j > -1; j--) {
if (tmpv[j] == 0) {
tmpcount = 0;
} else {
tmpcount = max(tmpcount, tmpv[j]);
tmpv[j] = tmpcount;
}
}
snw.push_back(tmpv);
}
int ans = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
ans = max(ans, snh[i][j] + snw[j][i]);
}
}
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
cerr << snh[i][j] << " ";
}
cerr << endl;
}
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
cerr << snw[j][i] << " ";
}
cerr << endl;
}
cout << ans - 1 << endl;
return 0;
} | #include <algorithm>
#include <iostream>
#include <limits.h>
#include <map>
#include <queue>
#include <string>
#include <vector>
#define ll long long
using namespace std;
int main() {
int h, w;
cin >> h >> w;
vector<string> s;
vector<vector<int>> snh;
vector<vector<int>> snw;
for (int i = 0; i < h; i++) {
string tmp;
cin >> tmp;
s.push_back(tmp);
vector<int> tmpv;
int tmpcount = 0;
for (int j = 0; j < w; j++) {
if (tmp[j] == '.') {
tmpcount++;
tmpv.push_back(tmpcount);
} else {
tmpcount = 0;
tmpv.push_back(tmpcount);
}
}
tmpcount = 0;
for (int j = w - 1; j > -1; j--) {
if (tmpv[j] == 0) {
tmpcount = 0;
} else {
tmpcount = max(tmpcount, tmpv[j]);
tmpv[j] = tmpcount;
}
}
snh.push_back(tmpv);
}
for (int i = 0; i < w; i++) {
vector<int> tmpv;
int tmpcount = 0;
for (int j = 0; j < h; j++) {
if (s[j][i] == '.') {
tmpcount++;
tmpv.push_back(tmpcount);
} else {
tmpcount = 0;
tmpv.push_back(tmpcount);
}
}
tmpcount = 0;
for (int j = h - 1; j > -1; j--) {
if (tmpv[j] == 0) {
tmpcount = 0;
} else {
tmpcount = max(tmpcount, tmpv[j]);
tmpv[j] = tmpcount;
}
}
snw.push_back(tmpv);
}
int ans = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
ans = max(ans, snh[i][j] + snw[j][i]);
}
}
cout << ans - 1 << endl;
return 0;
}
| delete | 89 | 105 | 89 | 89 | TLE | |
p03014 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
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(i, w) {
vector<int> done(h);
rep(j, h) {
if (s[j][i] == '#')
continue;
if (done[j])
continue;
int l = 0;
while (j + l < h) {
if (s[j + l][i] == '#')
continue;
l++;
}
rep(k, l) {
cnt[j + k][i] += l;
done[j + k] = 1;
}
}
}
int ans = 0;
rep(i, h) {
rep(j, w) { ans = max(ans, cnt[i][j] - 1); }
}
cout << ans << endl;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
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(i, w) {
vector<int> done(h);
rep(j, h) {
if (s[j][i] == '#')
continue;
if (done[j])
continue;
int l = 0;
while (j + l < h) {
if (s[j + l][i] == '#')
break;
l++;
}
rep(k, l) {
cnt[j + k][i] += l;
done[j + k] = 1;
}
}
}
int ans = 0;
rep(i, h) {
rep(j, w) { ans = max(ans, cnt[i][j] - 1); }
}
cout << ans << endl;
}
| replace | 45 | 46 | 45 | 46 | TLE | |
p03014 | C++ | Runtime Error | // QWsin
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#define rep(i, x, y) for (int i = x; i <= y; ++i)
#define out(i, u) for (int i = first[u]; i != -1; i = next[i])
#define repvc(i, vc) for (int i = 0, _sz = vc.size(); i < _sz; ++i)
using namespace std;
const int INF = 1 << 30;
typedef long long ll;
inline int read() {
int ret = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-')
f = -1;
ch = getchar();
}
for (; ch >= '0' && ch <= '9'; ch = getchar())
ret = ret * 10 + ch - '0';
return ret * f;
}
const int maxn = 1000 + 10;
char s[maxn][maxn];
int up[maxn][maxn], dn[maxn][maxn], l[maxn][maxn], r[maxn][maxn];
int main() {
int n, m;
cin >> n >> m;
rep(i, 1, n) scanf("%s", s[i] + 1);
rep(i, 1, n) {
rep(j, 1, m) if (s[i][j] == '.') l[i][j] = l[i][j - 1] + 1;
else l[i][j] = 0;
for (int j = m; j >= 1; --j)
if (s[i][j] == '.')
r[i][j] = r[i][j + 1] + 1;
else
r[i][j] = 0;
}
rep(j, 1, m) {
rep(i, 1, n) if (s[i][j] == '.') up[i][j] = up[i - 1][j] + 1;
else up[i][j] = 0;
for (int i = n; i >= 1; --i)
if (s[i][j] == '.')
dn[i][j] = dn[i + 1][j] + 1;
else
dn[i][j] = 0;
}
int ans = 0;
rep(i, 1, n) rep(j, 1, m) ans =
max(ans, up[i][j] - 1 + dn[i][j] - 1 + l[i][j] - 1 + r[i][j] - 1 + 1);
cout << ans << endl;
return 0;
}
| // QWsin
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#define rep(i, x, y) for (int i = x; i <= y; ++i)
#define out(i, u) for (int i = first[u]; i != -1; i = next[i])
#define repvc(i, vc) for (int i = 0, _sz = vc.size(); i < _sz; ++i)
using namespace std;
const int INF = 1 << 30;
typedef long long ll;
inline int read() {
int ret = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-')
f = -1;
ch = getchar();
}
for (; ch >= '0' && ch <= '9'; ch = getchar())
ret = ret * 10 + ch - '0';
return ret * f;
}
const int maxn = 2000 + 10;
char s[maxn][maxn];
int up[maxn][maxn], dn[maxn][maxn], l[maxn][maxn], r[maxn][maxn];
int main() {
int n, m;
cin >> n >> m;
rep(i, 1, n) scanf("%s", s[i] + 1);
rep(i, 1, n) {
rep(j, 1, m) if (s[i][j] == '.') l[i][j] = l[i][j - 1] + 1;
else l[i][j] = 0;
for (int j = m; j >= 1; --j)
if (s[i][j] == '.')
r[i][j] = r[i][j + 1] + 1;
else
r[i][j] = 0;
}
rep(j, 1, m) {
rep(i, 1, n) if (s[i][j] == '.') up[i][j] = up[i - 1][j] + 1;
else up[i][j] = 0;
for (int i = n; i >= 1; --i)
if (s[i][j] == '.')
dn[i][j] = dn[i + 1][j] + 1;
else
dn[i][j] = 0;
}
int ans = 0;
rep(i, 1, n) rep(j, 1, m) ans =
max(ans, up[i][j] - 1 + dn[i][j] - 1 + l[i][j] - 1 + r[i][j] - 1 + 1);
cout << ans << endl;
return 0;
}
| replace | 26 | 27 | 26 | 27 | 0 | |
p03014 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL << 62
#define inf 1000000007
ll a[2002][2002], b[2002][2002];
string s[2002];
int main() {
ll h, w;
cin >> h >> w;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
cin >> s[i][j];
}
}
for (int i = 0; i < h; i++) {
ll cnt = 0;
for (int j = 0; j < w; j++) {
if (s[i][j] != '#') {
cnt++;
a[i][j] = cnt;
} else {
cnt = 0;
}
}
}
for (int i = 0; i < w; i++) {
ll cnt = 0;
for (int j = 0; j < h; j++) {
if (s[j][i] != '#') {
cnt++;
b[j][i] = cnt;
} else {
cnt = 0;
}
}
}
for (int i = 0; i < h; i++) {
for (int j = w - 2; j >= 0; j--) {
if (a[i][j] == 0) {
continue;
}
a[i][j] = max(a[i][j], a[i][j + 1]);
}
}
for (int i = 0; i < w; i++) {
for (int j = h - 2; j >= 0; j--) {
if (b[j][i] == 0) {
continue;
}
b[j][i] = max(b[j][i], b[j + 1][i]);
}
}
ll ans = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
ll now = a[i][j] + b[i][j] - 1;
ans = max(now, ans);
}
}
cout << ans;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL << 62
#define inf 1000000007
ll a[2002][2002], b[2002][2002];
string s[2002];
int main() {
ll h, w;
cin >> h >> w;
for (int i = 0; i < h; i++) {
cin >> s[i];
}
for (int i = 0; i < h; i++) {
ll cnt = 0;
for (int j = 0; j < w; j++) {
if (s[i][j] != '#') {
cnt++;
a[i][j] = cnt;
} else {
cnt = 0;
}
}
}
for (int i = 0; i < w; i++) {
ll cnt = 0;
for (int j = 0; j < h; j++) {
if (s[j][i] != '#') {
cnt++;
b[j][i] = cnt;
} else {
cnt = 0;
}
}
}
for (int i = 0; i < h; i++) {
for (int j = w - 2; j >= 0; j--) {
if (a[i][j] == 0) {
continue;
}
a[i][j] = max(a[i][j], a[i][j + 1]);
}
}
for (int i = 0; i < w; i++) {
for (int j = h - 2; j >= 0; j--) {
if (b[j][i] == 0) {
continue;
}
b[j][i] = max(b[j][i], b[j + 1][i]);
}
}
ll ans = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
ll now = a[i][j] + b[i][j] - 1;
ans = max(now, ans);
}
}
cout << ans;
} | replace | 11 | 14 | 11 | 12 | 0 | |
p03014 | C++ | Runtime Error | #include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
#define MOD (ll)(1e9 + 7)
using namespace std;
class UF {
private:
public:
UF *root;
int value;
UF(int n = 0) {
root = this;
value = 1;
}
void showInfo(void) {
cout << "rootNode:" << root << ",value:" << value << endl;
}
};
void connectNode(UF *a, UF *b) {
while (b->root != b)
b = b->root;
while (a->root != a)
a = a->root;
if (a > b) {
a->root = b;
}
if (a < b) {
b->root = a;
}
return;
}
bool hasSameRoot(UF *a, UF *b) {
UF *pa = a;
UF *pb = b;
while (a->root != a)
a = a->root;
while (b->root != b)
b = b->root;
pa->root = a;
pb->root = b;
return a == b;
}
int main() {
int h, w;
cin >> h >> w;
char g[h][w];
int x[h][w], y[h][w];
rep(i, h) rep(j, w) {
x[i][j] = 0;
y[i][j] = 0;
cin >> g[i][j];
}
rep(i, h) {
int st = 0;
int num = 0;
rep(j, w + 1) {
if (g[i][j] == '.' && j != w) {
num++;
} else {
rep(k, st, j) { x[i][k] = num; }
num = 0;
st = j + 1;
}
}
}
rep(j, w) {
int st = 0;
int num = 0;
rep(i, h + 1) {
if (g[i][j] == '.' && i != h) {
num++;
} else {
rep(k, st, i) { y[k][j] = num; }
num = 0;
st = i + 1;
}
}
}
int ans = -1;
rep(i, h) rep(j, w) { ans = max(ans, x[i][j] + y[i][j] - 1); }
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
#define MOD (ll)(1e9 + 7)
using namespace std;
class UF {
private:
public:
UF *root;
int value;
UF(int n = 0) {
root = this;
value = 1;
}
void showInfo(void) {
cout << "rootNode:" << root << ",value:" << value << endl;
}
};
void connectNode(UF *a, UF *b) {
while (b->root != b)
b = b->root;
while (a->root != a)
a = a->root;
if (a > b) {
a->root = b;
}
if (a < b) {
b->root = a;
}
return;
}
bool hasSameRoot(UF *a, UF *b) {
UF *pa = a;
UF *pb = b;
while (a->root != a)
a = a->root;
while (b->root != b)
b = b->root;
pa->root = a;
pb->root = b;
return a == b;
}
int main() {
int h, w;
cin >> h >> w;
char g[h + 20][w + 20];
int x[h + 20][w + 20], y[h + 20][w + 20];
rep(i, h + 20) rep(j, w + 20) {
x[i][j] = 0;
y[i][j] = 0;
g[i][j] = 0;
}
rep(i, h) rep(j, w) {
x[i][j] = 0;
y[i][j] = 0;
cin >> g[i][j];
}
rep(i, h) {
int st = 0;
int num = 0;
rep(j, w + 1) {
if (g[i][j] == '.' && j != w) {
num++;
} else {
rep(k, st, j) { x[i][k] = num; }
num = 0;
st = j + 1;
}
}
}
rep(j, w) {
int st = 0;
int num = 0;
rep(i, h + 1) {
if (g[i][j] == '.' && i != h) {
num++;
} else {
rep(k, st, i) { y[k][j] = num; }
num = 0;
st = i + 1;
}
}
}
int ans = -1;
rep(i, h) rep(j, w) { ans = max(ans, x[i][j] + y[i][j] - 1); }
cout << ans << endl;
return 0;
} | replace | 63 | 65 | 63 | 71 | 0 | |
p03014 | C++ | Runtime Error | // i ll be the king
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define sync \
ios_base::sync_with_stdio(false); \
cin.tie(NULL)
#define input(arr, n) \
for (ll i1 = 0; i1 < n; i1++) \
cin >> arr[i1]
#define rep(n) for (ll i2 = 0; i2 < n; i2++)
#define vmp(v, a, b) v.push_back(make_pair(a, b))
#define si(a) scanf("%lld", &a)
#define pi(a) printf("%lld", a)
#define aset(a, n, k) \
for (ll i3 = 0; i3 < n; i3++) \
a[i3] = k;
#define mod 1000000007
#define mp(a, b) make_pair(a, b)
#define f first
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set \
tree<ll, null_type, greater_equal<ll>, rb_tree_tag, \
tree_order_statistics_node_update> // s.order_of_key(val)
// *s.find_by_orde(ind)
using namespace std;
ll vis[1003][1003];
string s[1003];
int main() {
sync;
ll n, m;
cin >> n >> m;
input(s, n);
for (ll i = 0; i < n; i++) {
ll cnt = 0;
for (ll j = 0; j < m; j++) {
if (s[i][j] == '#')
cnt = 0;
else {
cnt++;
vis[i][j] = cnt;
}
}
cnt = 0;
for (ll j = m - 1; j >= 0; j--) {
if (s[i][j] == '#')
cnt = 0;
else {
vis[i][j] += cnt;
cnt++;
}
}
}
// col
for (ll i = 0; i < m; i++) {
ll cnt = 0;
for (ll j = 0; j < n; j++) {
if (s[j][i] == '#')
cnt = 0;
else {
vis[j][i] += cnt;
cnt++;
}
}
cnt = 0;
for (ll j = n - 1; j >= 0; j--) {
if (s[j][i] == '#')
cnt = 0;
else {
vis[j][i] += cnt;
cnt++;
}
}
}
ll ans = 0;
for (ll i = 0; i < n; i++)
for (ll j = 0; j < m; j++)
ans = max(ans, vis[i][j]);
cout << ans;
} | // i ll be the king
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define sync \
ios_base::sync_with_stdio(false); \
cin.tie(NULL)
#define input(arr, n) \
for (ll i1 = 0; i1 < n; i1++) \
cin >> arr[i1]
#define rep(n) for (ll i2 = 0; i2 < n; i2++)
#define vmp(v, a, b) v.push_back(make_pair(a, b))
#define si(a) scanf("%lld", &a)
#define pi(a) printf("%lld", a)
#define aset(a, n, k) \
for (ll i3 = 0; i3 < n; i3++) \
a[i3] = k;
#define mod 1000000007
#define mp(a, b) make_pair(a, b)
#define f first
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set \
tree<ll, null_type, greater_equal<ll>, rb_tree_tag, \
tree_order_statistics_node_update> // s.order_of_key(val)
// *s.find_by_orde(ind)
using namespace std;
ll vis[2003][2003];
string s[2003];
int main() {
sync;
ll n, m;
cin >> n >> m;
input(s, n);
for (ll i = 0; i < n; i++) {
ll cnt = 0;
for (ll j = 0; j < m; j++) {
if (s[i][j] == '#')
cnt = 0;
else {
cnt++;
vis[i][j] = cnt;
}
}
cnt = 0;
for (ll j = m - 1; j >= 0; j--) {
if (s[i][j] == '#')
cnt = 0;
else {
vis[i][j] += cnt;
cnt++;
}
}
}
// col
for (ll i = 0; i < m; i++) {
ll cnt = 0;
for (ll j = 0; j < n; j++) {
if (s[j][i] == '#')
cnt = 0;
else {
vis[j][i] += cnt;
cnt++;
}
}
cnt = 0;
for (ll j = n - 1; j >= 0; j--) {
if (s[j][i] == '#')
cnt = 0;
else {
vis[j][i] += cnt;
cnt++;
}
}
}
ll ans = 0;
for (ll i = 0; i < n; i++)
for (ll j = 0; j < m; j++)
ans = max(ans, vis[i][j]);
cout << ans;
} | replace | 28 | 30 | 28 | 30 | 0 | |
p03014 | C++ | Runtime Error | #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;
}
| replace | 90 | 91 | 90 | 91 | 0 | |
p03014 | C++ | Runtime Error | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define p(s) cout << (s) << endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define ALL(v) (v).begin(), (v).end()
#define m0(x) memset(x, 0, sizeof(x))
typedef long long ll;
using namespace std;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e18;
static const ll MAX_H = 2000;
static const ll MAX_W = 2000;
static const int White = 0;
static const int Gray = 1;
static const int Black = 2;
ll H, W;
// bool M[MAX_H][MAX_W];
void pvector(vector<int> A) {
cout << "[vector]";
for (int i = 0; i < A.size(); i++) {
cout << A[i] << " ";
}
cout << endl;
}
int main() {
cin >> H >> W;
vector<string> S(H);
REP(i, H) { cin >> S[i]; }
short dpL[MAX_H][MAX_W] = {0}, dpR[MAX_H][MAX_W] = {0},
dpT[MAX_H][MAX_W] = {0}, dpU[MAX_H][MAX_W] = {0};
REP(i, H) {
REP(j, W) {
if (S[i][j] == '.') {
if (j != 0)
dpL[i][j] = dpL[i][j - 1] + 1;
else
dpL[i][j] = 1;
}
// cout << dpL[i][j];
}
// cout << endl;
}
REP(i, H) {
REPR(j, W) {
if (S[i][j] == '.') {
// cout << dpR[i][j] << endl;
if (j != W - 1)
dpR[i][j] = dpR[i][j + 1] + 1;
else
dpR[i][j] = 1;
// cout << dpR[i][j] << endl;
}
// cout << dpR[i][j];
}
// cout << endl;
}
REP(i, H) {
REP(j, W) {
if (S[i][j] == '.') {
if (i != 0)
dpT[i][j] = dpT[i - 1][j] + 1;
else
dpT[i][j] = 1;
}
// cout << dpT[i][j];
}
// cout << endl;
}
REPR(i, H) {
REP(j, W) {
if (S[i][j] == '.') {
if (i != H)
dpU[i][j] = dpU[i + 1][j] + 1;
else
dpU[i][j] = 1;
}
// cout << dpU[i][j];
}
// cout << endl;
}
ll MAX = 0;
REP(i, H) {
REP(j, W) {
if (MAX < (dpL[i][j] + dpR[i][j] + dpT[i][j] + dpU[i][j] - 3)) {
// cout << i << j << MAX << endl;
MAX = dpL[i][j] + dpR[i][j] + dpT[i][j] + dpU[i][j] - 3;
}
}
}
p(MAX);
} | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define p(s) cout << (s) << endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define ALL(v) (v).begin(), (v).end()
#define m0(x) memset(x, 0, sizeof(x))
typedef long long ll;
using namespace std;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e18;
static const ll MAX_H = 2000;
static const ll MAX_W = 2000;
static const int White = 0;
static const int Gray = 1;
static const int Black = 2;
ll H, W;
// bool M[MAX_H][MAX_W];
void pvector(vector<int> A) {
cout << "[vector]";
for (int i = 0; i < A.size(); i++) {
cout << A[i] << " ";
}
cout << endl;
}
int main() {
cin >> H >> W;
vector<string> S(H);
REP(i, H) { cin >> S[i]; }
short dpL[MAX_H][MAX_W] = {0}, dpR[MAX_H][MAX_W] = {0},
dpT[MAX_H][MAX_W] = {0}, dpU[MAX_H][MAX_W] = {0};
REP(i, H) {
REP(j, W) {
if (S[i][j] == '.') {
if (j != 0)
dpL[i][j] = dpL[i][j - 1] + 1;
else
dpL[i][j] = 1;
}
// cout << dpL[i][j];
}
// cout << endl;
}
REP(i, H) {
REPR(j, W) {
if (S[i][j] == '.') {
// cout << dpR[i][j] << endl;
if (j != W - 1)
dpR[i][j] = dpR[i][j + 1] + 1;
else
dpR[i][j] = 1;
// cout << dpR[i][j] << endl;
}
// cout << dpR[i][j];
}
// cout << endl;
}
REP(i, H) {
REP(j, W) {
if (S[i][j] == '.') {
if (i != 0)
dpT[i][j] = dpT[i - 1][j] + 1;
else
dpT[i][j] = 1;
}
// cout << dpT[i][j];
}
// cout << endl;
}
REPR(i, H) {
REP(j, W) {
if (S[i][j] == '.') {
if (i != H - 1)
dpU[i][j] = dpU[i + 1][j] + 1;
else
dpU[i][j] = 1;
}
// cout << dpU[i][j];
}
// cout << endl;
}
ll MAX = 0;
REP(i, H) {
REP(j, W) {
if (MAX < (dpL[i][j] + dpR[i][j] + dpT[i][j] + dpU[i][j] - 3)) {
// cout << i << j << MAX << endl;
MAX = dpL[i][j] + dpR[i][j] + dpT[i][j] + dpU[i][j] - 3;
}
}
}
p(MAX);
} | replace | 83 | 84 | 83 | 84 | -11 | |
p03014 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
template <typename T> T MatMaximum(vector<vector<T>> &mat) {
vector<T> max_array;
for (auto itr = mat.begin(); itr != mat.end(); ++itr) {
T maximum = *max_element((*itr).begin(), (*itr).end());
max_array.push_back(maximum);
}
return *max_element(max_array.begin(), max_array.end());
}
void process_vec(vector<int> &array, string hoge) {
int size_array = array.size();
int count = 0;
hoge.push_back('#');
for (int i = 0; i < size_array + 1; i++) {
if (hoge[i] == '.') {
count += 1;
} else {
for (int k = 0; k < count; k++) {
array[i - k - 1] = count;
}
count = 0;
}
}
}
string get_vec_col(vector<string> S, int col_idx) {
int row_len = S.size();
string ret;
for (int i = 0; i < row_len; i++) {
ret.push_back(S[i][col_idx]);
}
return ret;
}
// 末尾に注意しないといけない
void solve(long long H, long long W, std::vector<std::string> S) {
vector<vector<int>> horizontal_count(H, vector<int>(W, 0));
vector<vector<int>> vertical_count(W, vector<int>(H, 0));
for (int i = 0; i < H; i++) {
process_vec(horizontal_count[i], S[i]);
}
for (int i = 0; i < W; i++) {
process_vec(vertical_count[i], get_vec_col(S, i));
}
vector<vector<int>> count(H, vector<int>(W, 0));
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
count[i][j] = horizontal_count[i][j] + vertical_count[j][i];
}
}
printf("%d\n", MatMaximum(count) - 1);
}
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
long long H;
scanf("%lld", &H);
long long W;
scanf("%lld", &W);
std::vector<std::string> S(H);
for (int i = 0; i < H; i++) {
std::cin >> S[i];
}
solve(H, W, std::move(S));
return 0;
}
| #include <bits/stdc++.h>
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
template <typename T> T MatMaximum(vector<vector<T>> &mat) {
vector<T> max_array;
for (auto itr = mat.begin(); itr != mat.end(); ++itr) {
T maximum = *max_element((*itr).begin(), (*itr).end());
max_array.push_back(maximum);
}
return *max_element(max_array.begin(), max_array.end());
}
void process_vec(vector<int> &array, string hoge) {
int size_array = array.size();
int count = 0;
hoge.push_back('#');
for (int i = 0; i < size_array + 1; i++) {
if (hoge[i] == '.') {
count += 1;
} else {
for (int k = 0; k < count; k++) {
array[i - k - 1] = count;
}
count = 0;
}
}
}
string get_vec_col(vector<string> &S, int col_idx) {
int row_len = S.size();
string ret;
for (int i = 0; i < row_len; i++) {
ret.push_back(S[i][col_idx]);
}
return ret;
}
// 末尾に注意しないといけない
void solve(long long H, long long W, std::vector<std::string> S) {
vector<vector<int>> horizontal_count(H, vector<int>(W, 0));
vector<vector<int>> vertical_count(W, vector<int>(H, 0));
for (int i = 0; i < H; i++) {
process_vec(horizontal_count[i], S[i]);
}
for (int i = 0; i < W; i++) {
process_vec(vertical_count[i], get_vec_col(S, i));
}
vector<vector<int>> count(H, vector<int>(W, 0));
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
count[i][j] = horizontal_count[i][j] + vertical_count[j][i];
}
}
printf("%d\n", MatMaximum(count) - 1);
}
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
long long H;
scanf("%lld", &H);
long long W;
scanf("%lld", &W);
std::vector<std::string> S(H);
for (int i = 0; i < H; i++) {
std::cin >> S[i];
}
solve(H, W, std::move(S));
return 0;
}
| replace | 31 | 32 | 31 | 32 | TLE | |
p03014 | C++ | Runtime Error | #include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define repf(i, m, n) for (int(i) = m; (i) < n; (i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name, num) vector<ll> name((num), 0);
#define op(i) cout << (i) << endl;
#define ip(i) cin >> (i);
#define opN cout << "No" << endl;
#define opY cout << "Yes" << endl;
#define opP cout << "Possible" << endl;
#define opI cout << "Impossible" << endl;
#define mat(name, fnum, snum) \
; \
vector<vector<ll>> name((fnum), vector<ll>((snum), 0));
#define matC(name, fnum, snum) \
; \
vector<vector<char>> name((fnum), vector<char>((snum), 0));
#define debugP \
int debug_point; \
cin >> debug_point;
#define FI first
#define SE second
const ll MOD = 1e9 + 7;
template <typename T> void putv(vector<T> &V) {
// cout << "The elements in the vector are: " << endl;
for (auto x : V)
cout << x << " ";
cout << endl;
}
ll pow_mod(ll fi, ll se, ll mod) {
if (se == 0) {
return 1;
}
if (se % 2) {
return pow_mod(fi, se - 1, mod) * fi % mod;
}
ll t = pow_mod(fi, se / 2, mod);
return t * t % mod;
}
template <class T> vector<T> getv(ll n) {
vector<T> Vector_temp;
rep(i, n) {
T input;
cin >> input;
Vector_temp.emplace_back(input);
}
return Vector_temp;
}
ll gcd(ll c, ll b) {
while (1) {
if (c % b != 0) {
ll tmp = b;
b = c % b;
c = tmp;
} else {
return b;
}
}
}
vector<pair<int, int>> Dir = {{-1, 0}, {1, 0}, {0, 1}, {0, -1}};
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/
int main() {
ll h, w;
cin >> h >> w;
vector<string> s(h);
// vector<vector<vector<ll>>> cnt(h,vector<vector<ll>>(w,vector<ll>(4)));
vector<vector<ll>> cnt(h, vector<ll>(w, 1));
rep(i, h) {
rep(j, w) { cin >> s[i][j]; }
}
ll tmp = 0;
rep(i, h) {
tmp = 0;
rep(j, w) {
if (s[i][j] == '#') {
tmp = j + 1;
continue;
}
cnt[i][j] += j - tmp;
// cout<<cnt[i][j][0]<<endl;
}
}
rep(i, h) {
tmp = w - 1;
for (ll j = w - 1; j >= 0; j--) {
if (s[i][j] == '#') {
tmp = j - 1;
continue;
}
cnt[i][j] += tmp - j;
// cout<<cnt[i][j][1]<<endl;
}
}
rep(j, w) {
tmp = 0;
rep(i, h) {
if (s[i][j] == '#') {
tmp = i + 1;
continue;
}
cnt[i][j] += i - tmp;
}
}
rep(j, w) {
tmp = h - 1;
for (int i = h - 1; i >= 0; i--) {
if (s[i][j] == '#') {
tmp = i - 1;
continue;
}
cnt[i][j] += tmp - i;
}
}
ll ans = 0;
rep(i, h) {
rep(j, w) {
// rep(k,4)if(s[i][j]=='.'){tmp+=cnt[i][j][k];}
ans = max(ans, cnt[i][j]);
}
}
op(ans);
return 0;
}
| #include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define repf(i, m, n) for (int(i) = m; (i) < n; (i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name, num) vector<ll> name((num), 0);
#define op(i) cout << (i) << endl;
#define ip(i) cin >> (i);
#define opN cout << "No" << endl;
#define opY cout << "Yes" << endl;
#define opP cout << "Possible" << endl;
#define opI cout << "Impossible" << endl;
#define mat(name, fnum, snum) \
; \
vector<vector<ll>> name((fnum), vector<ll>((snum), 0));
#define matC(name, fnum, snum) \
; \
vector<vector<char>> name((fnum), vector<char>((snum), 0));
#define debugP \
int debug_point; \
cin >> debug_point;
#define FI first
#define SE second
const ll MOD = 1e9 + 7;
template <typename T> void putv(vector<T> &V) {
// cout << "The elements in the vector are: " << endl;
for (auto x : V)
cout << x << " ";
cout << endl;
}
ll pow_mod(ll fi, ll se, ll mod) {
if (se == 0) {
return 1;
}
if (se % 2) {
return pow_mod(fi, se - 1, mod) * fi % mod;
}
ll t = pow_mod(fi, se / 2, mod);
return t * t % mod;
}
template <class T> vector<T> getv(ll n) {
vector<T> Vector_temp;
rep(i, n) {
T input;
cin >> input;
Vector_temp.emplace_back(input);
}
return Vector_temp;
}
ll gcd(ll c, ll b) {
while (1) {
if (c % b != 0) {
ll tmp = b;
b = c % b;
c = tmp;
} else {
return b;
}
}
}
vector<pair<int, int>> Dir = {{-1, 0}, {1, 0}, {0, 1}, {0, -1}};
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/
int main() {
ll h, w;
cin >> h >> w;
vector<string> s(h);
// vector<vector<vector<ll>>> cnt(h,vector<vector<ll>>(w,vector<ll>(4)));
vector<vector<ll>> cnt(h, vector<ll>(w, 1));
rep(i, h) { cin >> s[i]; }
ll tmp = 0;
rep(i, h) {
tmp = 0;
rep(j, w) {
if (s[i][j] == '#') {
tmp = j + 1;
continue;
}
cnt[i][j] += j - tmp;
// cout<<cnt[i][j][0]<<endl;
}
}
rep(i, h) {
tmp = w - 1;
for (ll j = w - 1; j >= 0; j--) {
if (s[i][j] == '#') {
tmp = j - 1;
continue;
}
cnt[i][j] += tmp - j;
// cout<<cnt[i][j][1]<<endl;
}
}
rep(j, w) {
tmp = 0;
rep(i, h) {
if (s[i][j] == '#') {
tmp = i + 1;
continue;
}
cnt[i][j] += i - tmp;
}
}
rep(j, w) {
tmp = h - 1;
for (int i = h - 1; i >= 0; i--) {
if (s[i][j] == '#') {
tmp = i - 1;
continue;
}
cnt[i][j] += tmp - i;
}
}
ll ans = 0;
rep(i, h) {
rep(j, w) {
// rep(k,4)if(s[i][j]=='.'){tmp+=cnt[i][j][k];}
ans = max(ans, cnt[i][j]);
}
}
op(ans);
return 0;
}
| replace | 79 | 82 | 79 | 80 | 0 | |
p03014 | C++ | Runtime Error | /**
* 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;
}
/*
*/
| replace | 75 | 76 | 75 | 76 | 0 | |
p03014 | C++ | Runtime Error | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, n, m) for (int i = n; i < m; i++)
#define ll long long int
using namespace std;
struct UnionFind {
vector<int> par; // par[i]が親を表す
vector<int> _size; // _size[i]でそのノードの属しているサイズを返す
// コンストラクタ
UnionFind(int n) {
_size = vector<int>(n);
par = vector<int>(n);
for (int i = 0; i < n; i++) {
par[i] = i;
_size[i] = 1;
}
}
// データxの根を求める
int root(int x) {
if (par[x] == x)
return x;
return par[x] = root(par[x]); // 木構造の縮約を行っている
}
// xとyの親が違うとき、マージする。そのときyの根がxの根の子になる
void merge(int x, int y) {
int rootx = root(x);
int rooty = root(y);
if (rootx == rooty)
return;
par[rooty] = rootx;
int s = _size[rooty] + _size[rootx];
_size[rooty] = s;
_size[rootx] = s;
}
// xの属している集団のサイズ
int size(int x) { return _size[x]; }
// 同じグループに属しているか
bool isSame(int x, int y) { return root(x) == root(y); }
};
int main() {
int h, w;
bool map[2000][2000] = {};
cin >> h >> w;
UnionFind ufx(h * w - 1); // i*w + j
UnionFind ufy(h * w - 1);
REP(i, h) {
string s;
cin >> s;
REP(j, s.length()) {
if (s[j] == '.') {
map[i][j] = true;
if (i != 0) {
if (map[i - 1][j]) {
ufy.merge(i * w + j, (i - 1) * w + j);
}
}
if (j != 0) {
if (map[i][j - 1]) {
ufx.merge(i * w + j, i * w + j - 1);
}
}
}
}
}
int result = 0;
REP(i, h) {
REP(j, w) {
result = max(result, ufx.size(ufx.root(i * w + j)) +
ufy.size(ufy.root(i * w + j)) - 1);
}
}
cout << result << endl;
}
| #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, n, m) for (int i = n; i < m; i++)
#define ll long long int
using namespace std;
struct UnionFind {
vector<int> par; // par[i]が親を表す
vector<int> _size; // _size[i]でそのノードの属しているサイズを返す
// コンストラクタ
UnionFind(int n) {
_size = vector<int>(n);
par = vector<int>(n);
for (int i = 0; i < n; i++) {
par[i] = i;
_size[i] = 1;
}
}
// データxの根を求める
int root(int x) {
if (par[x] == x)
return x;
return par[x] = root(par[x]); // 木構造の縮約を行っている
}
// xとyの親が違うとき、マージする。そのときyの根がxの根の子になる
void merge(int x, int y) {
int rootx = root(x);
int rooty = root(y);
if (rootx == rooty)
return;
par[rooty] = rootx;
int s = _size[rooty] + _size[rootx];
_size[rooty] = s;
_size[rootx] = s;
}
// xの属している集団のサイズ
int size(int x) { return _size[x]; }
// 同じグループに属しているか
bool isSame(int x, int y) { return root(x) == root(y); }
};
int main() {
int h, w;
bool map[2000][2000] = {};
cin >> h >> w;
UnionFind ufx(h * w); // i*w + j
UnionFind ufy(h * w);
REP(i, h) {
string s;
cin >> s;
REP(j, s.length()) {
if (s[j] == '.') {
map[i][j] = true;
if (i != 0) {
if (map[i - 1][j]) {
ufy.merge(i * w + j, (i - 1) * w + j);
}
}
if (j != 0) {
if (map[i][j - 1]) {
ufx.merge(i * w + j, i * w + j - 1);
}
}
}
}
}
int result = 0;
REP(i, h) {
REP(j, w) {
result = max(result, ufx.size(ufx.root(i * w + j)) +
ufy.size(ufy.root(i * w + j)) - 1);
}
}
cout << result << endl;
}
| replace | 52 | 54 | 52 | 54 | 0 | |
p03014 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int, int>
#define mii map<pii, int>
#define all(a) (a).begin(), (a).end()
#define sz(x) (int)x.size()
#define endl "\n"
#define repp(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define IOS \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
const int N = 2e2 + 5;
char a[N][N];
vector<int> row[N];
vector<int> col[N];
int n, m;
int32_t main() {
IOS;
cin >> n >> m;
int best = INT_MIN;
rep(i, 1, n) {
rep(j, 1, m) { cin >> a[i][j]; }
}
rep(i, 1, n) {
row[i].pb(0);
rep(j, 1, m) {
if (a[i][j] == '#')
row[i].pb(j);
}
row[i].pb(m + 1);
}
rep(j, 1, m) {
col[j].pb(0);
rep(i, 1, n) {
if (a[i][j] == '#')
col[j].pb(i);
}
col[j].pb(n + 1);
}
rep(i, 1, n) {
rep(j, 1, m) {
if (a[i][j] == '.') {
int q = lower_bound(row[i].begin(), row[i].end(), j) - row[i].begin();
int p = lower_bound(col[j].begin(), col[j].end(), i) - col[j].begin();
int ans = 0;
int req = row[i][q];
ans += (req - j - 1);
q--;
req = row[i][q];
ans += (j - req - 1);
req = col[j][p];
ans += (req - i - 1);
p--;
req = col[j][p];
ans += (i - req - 1);
ans++;
best = max(ans, best);
}
}
}
cout << best << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int, int>
#define mii map<pii, int>
#define all(a) (a).begin(), (a).end()
#define sz(x) (int)x.size()
#define endl "\n"
#define repp(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define IOS \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
const int N = 2005;
char a[N][N];
vector<int> row[N];
vector<int> col[N];
int n, m;
int32_t main() {
IOS;
cin >> n >> m;
int best = INT_MIN;
rep(i, 1, n) {
rep(j, 1, m) { cin >> a[i][j]; }
}
rep(i, 1, n) {
row[i].pb(0);
rep(j, 1, m) {
if (a[i][j] == '#')
row[i].pb(j);
}
row[i].pb(m + 1);
}
rep(j, 1, m) {
col[j].pb(0);
rep(i, 1, n) {
if (a[i][j] == '#')
col[j].pb(i);
}
col[j].pb(n + 1);
}
rep(i, 1, n) {
rep(j, 1, m) {
if (a[i][j] == '.') {
int q = lower_bound(row[i].begin(), row[i].end(), j) - row[i].begin();
int p = lower_bound(col[j].begin(), col[j].end(), i) - col[j].begin();
int ans = 0;
int req = row[i][q];
ans += (req - j - 1);
q--;
req = row[i][q];
ans += (j - req - 1);
req = col[j][p];
ans += (req - i - 1);
p--;
req = col[j][p];
ans += (i - req - 1);
ans++;
best = max(ans, best);
}
}
}
cout << best << endl;
}
| replace | 20 | 21 | 20 | 21 | 0 | |
p03014 | C++ | Time Limit Exceeded |
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define M_PI 3.14159265358979323846
using namespace std;
// conversion
//------------------------------------------
inline int toInt(string s) {
int v;
istringstream sin(s);
sin >> v;
return v;
}
template <class T> inline string toString(T x) {
ostringstream sout;
sout << x;
return sout.str();
}
// typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
// container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i, c) \
for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define FILL(a, x) memset(a, x, sizeof(a))
// repetition
//------------------------------------------
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
const LL MOD = 1000000007;
const int N = 2005;
char board[N][N];
int xx[N][N], yy[N][N];
int main() {
int h, w;
scanf("%d%d", &h, &w);
REP(i, h) scanf("%s", &board[i + 1][1]);
REP(i, h + 2) board[i][0] = board[i][w + 1] = '#';
REP(i, w + 2) board[0][i] = board[h + 1][i] = '#';
FOR(i, 1, h + 1) {
FOR(j, 1, w + 1) {
int sx = 1;
if (xx[i][j] == 0) {
while (sx <= w) {
int tx = sx;
while (board[i][tx] == '.')
tx++;
FOR(k, sx, tx) xx[i][k] = tx - sx;
sx = tx + 1;
}
}
int sy = 1;
if (yy[i][j] == 0) {
while (sy <= h) {
int ty = sy;
while (board[ty][j] == '.')
ty++;
FOR(k, sy, ty) yy[k][j] = ty - sy;
sy = ty + 1;
}
}
}
}
int ret = 0;
FOR(i, 1, h + 1) FOR(j, 1, w + 1) ret = max(ret, xx[i][j] + yy[i][j] - 1);
printf("%d\n", ret);
return 0;
} |
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define M_PI 3.14159265358979323846
using namespace std;
// conversion
//------------------------------------------
inline int toInt(string s) {
int v;
istringstream sin(s);
sin >> v;
return v;
}
template <class T> inline string toString(T x) {
ostringstream sout;
sout << x;
return sout.str();
}
// typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
// container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i, c) \
for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define FILL(a, x) memset(a, x, sizeof(a))
// repetition
//------------------------------------------
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
const LL MOD = 1000000007;
const int N = 2005;
char board[N][N];
int xx[N][N], yy[N][N];
int main() {
int h, w;
scanf("%d%d", &h, &w);
REP(i, h) scanf("%s", &board[i + 1][1]);
REP(i, h + 2) board[i][0] = board[i][w + 1] = '#';
REP(i, w + 2) board[0][i] = board[h + 1][i] = '#';
FOR(i, 1, h + 1) {
int sx = 1;
while (sx <= w) {
int tx = sx;
while (board[i][tx] == '.')
tx++;
FOR(k, sx, tx) xx[i][k] = tx - sx;
sx = tx + 1;
}
}
FOR(i, 1, w + 1) {
int sy = 1;
while (sy <= h) {
int ty = sy;
while (board[ty][i] == '.')
ty++;
FOR(k, sy, ty) yy[k][i] = ty - sy;
sy = ty + 1;
}
}
int ret = 0;
FOR(i, 1, h + 1) FOR(j, 1, w + 1) ret = max(ret, xx[i][j] + yy[i][j] - 1);
printf("%d\n", ret);
return 0;
} | replace | 88 | 109 | 88 | 105 | TLE | |
p03014 | C++ | Runtime Error | #include "bits/stdc++.h"
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll, ll>;
using str = string;
using vpl4 = vector<pair<ll, ll>>;
#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define llin(x) \
ll(x); \
cin >> (x);
#define stin(x) \
str(x); \
cin >> (x);
#define vllin(x, n) \
vll(x)(n); \
FOR(i, 0, n - 1) { cin >> (x)[i]; }
#define vllin2(a, b, n) \
vll(a)(n); \
vll(b)(n); \
FOR(i, 0, n - 1) { cin >> (a)[i] >> (b)[i]; }
#define vllin3(a, b, c, n) \
vll(a)(n); \
vll(b)(n); \
vll(c)(n); \
FOR(i, 0, n - 1) { cin >> (a)[i] >> (b)[i] >> (c)[i]; }
#define vlling(x, n) \
(x).assign(n, 0); \
FOR(i, 0, n - 1) { cin >> (x)[i]; }
#define vlling2(a, b, n) \
(a).assign(n, 0); \
(b).assign(n, 0); \
FOR(i, 0, n - 1) { cin >> (a)[i] >> (b)[i]; }
#define vlling3(a, b, c, n) \
(a).assign(n, 0); \
(b).assign(n, 0); \
(c).assign(n, 0); \
FOR(i, 0, n - 1) { cin >> (a)[i] >> (b)[i] >> (c)[i]; }
#define vpl4in(x, n) \
vpl4(x)((n), mp(0, 0)); \
FOR(i, 0, n - 1) { cin >> x[i].fi >> x[i].se; }
#define FOR(i, a, b) for (ll i = a; i <= b; i++)
#define rFOR(i, b, a) for (ll i = a; i >= b; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout << (x);
#define sal(x) cout << (x) << endl;
#define says(x) cout << (x) << (' ');
#define sas cout << (' ');
#define sayR(x) cout << fixed << setprecision(10) << (x);
#define salR(x) cout << fixed << setprecision(10) << (x) << endl;
#define yn(a) cout << ((a) ? "yes" : "no") << endl;
#define Yn(a) cout << ((a) ? "Yes" : "No") << endl;
#define YN(a) cout << ((a) ? "YES" : "NO") << endl;
#define Imp(a) cout << ((a) ? "Possible" : "Impossible") << endl;
#define IMP(a) cout << ((a) ? "POSSIBLE" : "IMPOSSIBLE") << endl;
#define pow(a, b) ll(pow(a, b))
ll MOD = 1000000007;
signed main() {
llin(h);
llin(w);
vector<str> s(h, "");
FOR(i, 0, h - 1) { cin >> s[i]; }
vvll ws(h, vll(w, 0));
vvll hs(h, vll(w, 0));
vvll wr(h, vll(w + 1, 0));
vvll hr(h + 1, vll(w, 0));
ll t = 0;
ll c = 0;
FOR(i, 0, h - 1) {
t = 1;
c = 0;
FOR(j, 0, w - 1) {
if (s[i][j] == '#') {
wr[i][t] = c;
t++;
c = 0;
} else {
ws[i][j] = t;
c++;
}
}
wr[i][t] = c;
}
FOR(j, 0, w - 1) {
t = 1;
c = 0;
FOR(i, 0, h - 1) {
if (s[i][j] == '#') {
hr[t][j] = c;
t++;
c = 0;
} else {
hs[i][j] = t;
c++;
}
}
hr[t][j] = c;
}
ll k = 0;
FOR(i, 0, h - 1) {
FOR(j, 0, w - 1) {
if (s[i][j] == '.') {
k = max(wr[i][ws[i][j]] + hr[hs[i][j]][j], k);
}
}
}
sal(k - 1)
}
| #include "bits/stdc++.h"
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll, ll>;
using str = string;
using vpl4 = vector<pair<ll, ll>>;
#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define llin(x) \
ll(x); \
cin >> (x);
#define stin(x) \
str(x); \
cin >> (x);
#define vllin(x, n) \
vll(x)(n); \
FOR(i, 0, n - 1) { cin >> (x)[i]; }
#define vllin2(a, b, n) \
vll(a)(n); \
vll(b)(n); \
FOR(i, 0, n - 1) { cin >> (a)[i] >> (b)[i]; }
#define vllin3(a, b, c, n) \
vll(a)(n); \
vll(b)(n); \
vll(c)(n); \
FOR(i, 0, n - 1) { cin >> (a)[i] >> (b)[i] >> (c)[i]; }
#define vlling(x, n) \
(x).assign(n, 0); \
FOR(i, 0, n - 1) { cin >> (x)[i]; }
#define vlling2(a, b, n) \
(a).assign(n, 0); \
(b).assign(n, 0); \
FOR(i, 0, n - 1) { cin >> (a)[i] >> (b)[i]; }
#define vlling3(a, b, c, n) \
(a).assign(n, 0); \
(b).assign(n, 0); \
(c).assign(n, 0); \
FOR(i, 0, n - 1) { cin >> (a)[i] >> (b)[i] >> (c)[i]; }
#define vpl4in(x, n) \
vpl4(x)((n), mp(0, 0)); \
FOR(i, 0, n - 1) { cin >> x[i].fi >> x[i].se; }
#define FOR(i, a, b) for (ll i = a; i <= b; i++)
#define rFOR(i, b, a) for (ll i = a; i >= b; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout << (x);
#define sal(x) cout << (x) << endl;
#define says(x) cout << (x) << (' ');
#define sas cout << (' ');
#define sayR(x) cout << fixed << setprecision(10) << (x);
#define salR(x) cout << fixed << setprecision(10) << (x) << endl;
#define yn(a) cout << ((a) ? "yes" : "no") << endl;
#define Yn(a) cout << ((a) ? "Yes" : "No") << endl;
#define YN(a) cout << ((a) ? "YES" : "NO") << endl;
#define Imp(a) cout << ((a) ? "Possible" : "Impossible") << endl;
#define IMP(a) cout << ((a) ? "POSSIBLE" : "IMPOSSIBLE") << endl;
#define pow(a, b) ll(pow(a, b))
ll MOD = 1000000007;
signed main() {
llin(h);
llin(w);
vector<str> s(h, "");
FOR(i, 0, h - 1) { cin >> s[i]; }
vvll ws(h, vll(w, 0));
vvll hs(h, vll(w, 0));
vvll wr(h, vll(w + 2, 0));
vvll hr(h + 2, vll(w, 0));
ll t = 0;
ll c = 0;
FOR(i, 0, h - 1) {
t = 1;
c = 0;
FOR(j, 0, w - 1) {
if (s[i][j] == '#') {
wr[i][t] = c;
t++;
c = 0;
} else {
ws[i][j] = t;
c++;
}
}
wr[i][t] = c;
}
FOR(j, 0, w - 1) {
t = 1;
c = 0;
FOR(i, 0, h - 1) {
if (s[i][j] == '#') {
hr[t][j] = c;
t++;
c = 0;
} else {
hs[i][j] = t;
c++;
}
}
hr[t][j] = c;
}
ll k = 0;
FOR(i, 0, h - 1) {
FOR(j, 0, w - 1) {
if (s[i][j] == '.') {
k = max(wr[i][ws[i][j]] + hr[hs[i][j]][j], k);
}
}
}
sal(k - 1)
}
| replace | 80 | 82 | 80 | 82 | 0 | |
p03014 | C++ | Runtime Error | #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;
}
| replace | 36 | 37 | 36 | 37 | -11 | |
p03014 | C++ | Runtime Error | #include <algorithm>
#include <cstdio>
#include <iostream>
#include <queue>
#include <string.h>
#include <vector>
using namespace std;
int H, W, mr[2000][2000], mc[2000][2000];
string S[2000];
int dr(int n, int m) {
int num;
if (mr[n][m] != -1) {
return mr[n][m];
}
if (S[n][m] == '#') {
mr[n][m] = 0;
return 0;
}
if (n > 0) {
if (S[n - 1][m] == '.') {
mr[n][m] = dr(n - 1, m);
return mr[n][m];
} else {
num = 0;
while (S[n + num][m] == '.' && n + num < H) {
num++;
}
mr[n][m] = num;
return num;
}
} else {
num = 0;
while (S[n + num][m] == '.' && n + num < H) {
num++;
}
mr[n][m] = num;
return num;
}
}
int dc(int n, int m) {
int num;
if (mc[n][m] != -1) {
return mc[n][m];
}
if (S[n][m] == '#') {
mc[n][m] = 0;
return 0;
}
if (m > 0) {
if (S[n][m - 1] == '.') {
mc[n][m] = dc(n, m - 1);
return mc[n][m];
} else {
num = 0;
while (S[n][m + num] == '.' && m + num < W) {
num++;
}
mc[n][m] = num;
return num;
}
} else {
num = 0;
while (S[n][m + num] == '.' && m + num < W) {
num++;
}
mc[n][m] = num;
return num;
}
}
int main() {
cin >> H >> W;
int i, j, k, ans = 0;
for (i = 0; i < H; i++) {
cin >> S[i];
}
/*
for(i=0;i<H;i++)
{
cout << S[i] << endl;
}
for(i=0;i<H;i++)
{
for(j=0;j<W;j++)
{
cout << S[i][j] ;
}cout << endl;
}
*/
for (i = 0; i < H; i++) {
for (j = 0; j < W; j++) {
mc[i][j] = -1;
mr[i][j] = -1;
}
}
for (i = 0; i < H; i++) {
for (j = 0; j < W; j++) {
ans = max(ans, dr(i, j) + dc(i, j) - 1);
}
}
// cout << dr(1,1) << endl << dc(1,1) << endl;
cout << ans;
} | #include <algorithm>
#include <cstdio>
#include <iostream>
#include <queue>
#include <string.h>
#include <vector>
using namespace std;
int H, W, mr[2000][2000], mc[2000][2000];
string S[2001];
int dr(int n, int m) {
int num;
if (mr[n][m] != -1) {
return mr[n][m];
}
if (S[n][m] == '#') {
mr[n][m] = 0;
return 0;
}
if (n > 0) {
if (S[n - 1][m] == '.') {
mr[n][m] = dr(n - 1, m);
return mr[n][m];
} else {
num = 0;
while (S[n + num][m] == '.' && n + num < H) {
num++;
}
mr[n][m] = num;
return num;
}
} else {
num = 0;
while (S[n + num][m] == '.' && n + num < H) {
num++;
}
mr[n][m] = num;
return num;
}
}
int dc(int n, int m) {
int num;
if (mc[n][m] != -1) {
return mc[n][m];
}
if (S[n][m] == '#') {
mc[n][m] = 0;
return 0;
}
if (m > 0) {
if (S[n][m - 1] == '.') {
mc[n][m] = dc(n, m - 1);
return mc[n][m];
} else {
num = 0;
while (S[n][m + num] == '.' && m + num < W) {
num++;
}
mc[n][m] = num;
return num;
}
} else {
num = 0;
while (S[n][m + num] == '.' && m + num < W) {
num++;
}
mc[n][m] = num;
return num;
}
}
int main() {
cin >> H >> W;
int i, j, k, ans = 0;
for (i = 0; i < H; i++) {
cin >> S[i];
}
/*
for(i=0;i<H;i++)
{
cout << S[i] << endl;
}
for(i=0;i<H;i++)
{
for(j=0;j<W;j++)
{
cout << S[i][j] ;
}cout << endl;
}
*/
for (i = 0; i < H; i++) {
for (j = 0; j < W; j++) {
mc[i][j] = -1;
mr[i][j] = -1;
}
}
for (i = 0; i < H; i++) {
for (j = 0; j < W; j++) {
ans = max(ans, dr(i, j) + dc(i, j) - 1);
}
}
// cout << dr(1,1) << endl << dc(1,1) << endl;
cout << ans;
} | replace | 10 | 11 | 10 | 11 | 0 | |
p03014 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int H, W, res = 0; // 縦・横・結果
vector<string> Mass(1010); // マス状態
vector<vector<int>> range_Mass(1010, vector<int>(1010, -1)); // 照らされるマス数
int main() {
cin >> H >> W;
for (int i = 0; i < H; i++)
cin >> Mass[i];
/*以下, 横連続マス数を調査 計算量O(HW)*/
int j = 0;
for (int i = 0; i < H; i++) {
int j = 0;
while (j < W) {
int k = 0;
while (j + k < W && Mass[i][j + k] != '#')
k++; // マス連続数取得
for (int l = 0; l < k; l++)
range_Mass[i][j + l] += k; // 連続数を加える
j += k + 1;
}
}
/*以下,縦連続マス数を調査 計算量O(HW)*/
for (int i = 0; i < W; i++) {
int j = 0;
while (j < H) {
int k = 0;
while (j + k < H && Mass[j + k][i] != '#')
k++; // マス連続数取得
for (int l = 0; l < k; l++)
range_Mass[j + l][i] += k; // 連続数を加える
j += k + 1;
}
}
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++)
res = max(res, range_Mass[i][j]);
}
cout << res << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int H, W, res = 0; // 縦・横・結果
vector<string> Mass(2010); // マス状態
vector<vector<int>> range_Mass(2010, vector<int>(2010, -1)); // 照らされるマス数
int main() {
cin >> H >> W;
for (int i = 0; i < H; i++)
cin >> Mass[i];
/*以下, 横連続マス数を調査 計算量O(HW)*/
int j = 0;
for (int i = 0; i < H; i++) {
int j = 0;
while (j < W) {
int k = 0;
while (j + k < W && Mass[i][j + k] != '#')
k++; // マス連続数取得
for (int l = 0; l < k; l++)
range_Mass[i][j + l] += k; // 連続数を加える
j += k + 1;
}
}
/*以下,縦連続マス数を調査 計算量O(HW)*/
for (int i = 0; i < W; i++) {
int j = 0;
while (j < H) {
int k = 0;
while (j + k < H && Mass[j + k][i] != '#')
k++; // マス連続数取得
for (int l = 0; l < k; l++)
range_Mass[j + l][i] += k; // 連続数を加える
j += k + 1;
}
}
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++)
res = max(res, range_Mass[i][j]);
}
cout << res << endl;
return 0;
}
| replace | 4 | 6 | 4 | 6 | 0 | |
p03014 | C++ | Runtime Error | //
// main.cpp
//
// https://atcoder.jp/contests/abc127/tasks/abc127_f
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
using ull = unsigned long long;
int main(int argc, char *argv[]) {
int H, W;
cin >> H >> W;
struct Cell {
int hor_len = -1;
int ver_len = -1;
pair<int, int> hor_ptr = {-1, -1};
pair<int, int> ver_ptr = {-1, -1};
bool is_wall() { return hor_ptr == pair<int, int>{-1, -1}; }
};
vector<vector<Cell>> grid;
for (int x = 0; x <= W; x++) {
grid.push_back(vector<Cell>(H + 1));
}
for (int y = 0; y <= H; y++) {
string line;
if (y < H) {
cin >> line;
}
for (int x = 0; x <= W; x++) {
char c = 0;
if (x < W) {
c = line[x];
}
if (x == W || y == H || c == '#') {
if (x > 0 && !grid[x - 1][y].is_wall()) {
pair<int, int> head = grid[x - 1][y].hor_ptr;
grid[head.first][head.second].hor_len = x - head.first;
}
if (y > 0 && !grid[x][y - 1].is_wall()) {
pair<int, int> head = grid[x][y - 1].ver_ptr;
grid[head.first][head.second].ver_len = y - head.second;
}
} else {
if (x > 0 && !grid[x - 1][y].is_wall()) {
grid[x][y].hor_ptr = grid[x - 1][y].hor_ptr;
} else {
grid[x][y].hor_ptr = {x, y};
}
if (y > 0 && !grid[x][y - 1].is_wall()) {
grid[x][y].ver_ptr = grid[x][y - 1].ver_ptr;
} else {
grid[x][y].ver_ptr = {x, y};
}
}
}
}
int max_val = numeric_limits<int>::min();
for (int x = 0; x < W; x++) {
for (int y = 0; y < H; y++) {
if (grid[x][y].is_wall()) {
continue;
}
int len = -1;
pair<int, int> hor_head = grid[x][y].hor_ptr;
len += grid[hor_head.first][hor_head.second].hor_len;
pair<int, int> ver_head = grid[x][y].ver_ptr;
len += grid[ver_head.first][ver_head.second].ver_len;
max_val = max(max_val, len);
}
}
cout << max_val << endl;
}
| //
// main.cpp
//
// https://atcoder.jp/contests/abc127/tasks/abc127_f
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
using ull = unsigned long long;
int main(int argc, char *argv[]) {
int H, W;
cin >> H >> W;
struct Cell {
int hor_len = -1;
int ver_len = -1;
pair<int, int> hor_ptr = {-1, -1};
pair<int, int> ver_ptr = {-1, -1};
bool is_wall() { return hor_ptr == pair<int, int>{-1, -1}; }
};
vector<vector<Cell>> grid;
for (int x = 0; x <= W; x++) {
grid.push_back(vector<Cell>(H + 1));
}
for (int y = 0; y <= H; y++) {
string line;
if (y < H) {
cin >> line;
}
for (int x = 0; x <= W; x++) {
char c = 0;
if (y < H && x < W) {
c = line[x];
}
if (x == W || y == H || c == '#') {
if (x > 0 && !grid[x - 1][y].is_wall()) {
pair<int, int> head = grid[x - 1][y].hor_ptr;
grid[head.first][head.second].hor_len = x - head.first;
}
if (y > 0 && !grid[x][y - 1].is_wall()) {
pair<int, int> head = grid[x][y - 1].ver_ptr;
grid[head.first][head.second].ver_len = y - head.second;
}
} else {
if (x > 0 && !grid[x - 1][y].is_wall()) {
grid[x][y].hor_ptr = grid[x - 1][y].hor_ptr;
} else {
grid[x][y].hor_ptr = {x, y};
}
if (y > 0 && !grid[x][y - 1].is_wall()) {
grid[x][y].ver_ptr = grid[x][y - 1].ver_ptr;
} else {
grid[x][y].ver_ptr = {x, y};
}
}
}
}
int max_val = numeric_limits<int>::min();
for (int x = 0; x < W; x++) {
for (int y = 0; y < H; y++) {
if (grid[x][y].is_wall()) {
continue;
}
int len = -1;
pair<int, int> hor_head = grid[x][y].hor_ptr;
len += grid[hor_head.first][hor_head.second].hor_len;
pair<int, int> ver_head = grid[x][y].ver_ptr;
len += grid[ver_head.first][ver_head.second].ver_len;
max_val = max(max_val, len);
}
}
cout << max_val << endl;
}
| replace | 51 | 52 | 51 | 52 | 0 | |
p03014 | C++ | Runtime Error | #include <bits/stdc++.h>
// #define int long long
using namespace std;
using LL = long long;
using P = pair<int, int>;
#define FOR(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define pb(a) push_back(a)
#define all(x) (x).begin(), (x).end()
template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
for (auto &e : t)
fill_v(e, v);
}
const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;
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];
vector<vector<int>> ww(w + 5, vector<int>(w + 5, 0));
vector<vector<int>> hh(h + 5, vector<int>(h + 5, 0));
REP(i, h) {
REP(j, w) {
if (j == 0)
ww[i][j] = (s[i][j] == '.' ? 1 : 0);
else {
ww[i][j] = (s[i][j] == '.' ? ww[i][j - 1] + 1 : 0);
}
}
}
REP(i, w) {
REP(j, h) {
if (j == 0)
hh[j][i] = (s[j][i] == '.' ? 1 : 0);
else {
hh[j][i] = (s[j][i] == '.' ? hh[j - 1][i] + 1 : 0);
}
}
}
REP(i, h)
FOR(j, 1, w) if (ww[i][w - j] != 0 && ww[i][w - j - 1] != 0)
ww[i][w - j - 1] = ww[i][w - j];
REP(i, w)
FOR(j, 1, h) if (hh[h - j][i] != 0 && hh[h - j - 1][i] != 0)
hh[h - j - 1][i] = hh[h - j][i];
// REP(i, h) REP(j, w) cout << hh[i][j] << " \n"[j==w-1];
int ans = 0;
REP(i, h) REP(j, w) ans = max(ans, ww[i][j] + hh[i][j] - 1);
cout << ans << endl;
} | #include <bits/stdc++.h>
// #define int long long
using namespace std;
using LL = long long;
using P = pair<int, int>;
#define FOR(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define pb(a) push_back(a)
#define all(x) (x).begin(), (x).end()
template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
for (auto &e : t)
fill_v(e, v);
}
const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;
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];
vector<vector<int>> ww(h + 5, vector<int>(w + 5, 0));
vector<vector<int>> hh(h + 5, vector<int>(w + 5, 0));
REP(i, h) {
REP(j, w) {
if (j == 0)
ww[i][j] = (s[i][j] == '.' ? 1 : 0);
else {
ww[i][j] = (s[i][j] == '.' ? ww[i][j - 1] + 1 : 0);
}
}
}
REP(i, w) {
REP(j, h) {
if (j == 0)
hh[j][i] = (s[j][i] == '.' ? 1 : 0);
else {
hh[j][i] = (s[j][i] == '.' ? hh[j - 1][i] + 1 : 0);
}
}
}
REP(i, h)
FOR(j, 1, w) if (ww[i][w - j] != 0 && ww[i][w - j - 1] != 0)
ww[i][w - j - 1] = ww[i][w - j];
REP(i, w)
FOR(j, 1, h) if (hh[h - j][i] != 0 && hh[h - j - 1][i] != 0)
hh[h - j - 1][i] = hh[h - j][i];
// REP(i, h) REP(j, w) cout << hh[i][j] << " \n"[j==w-1];
int ans = 0;
REP(i, h) REP(j, w) ans = max(ans, ww[i][j] + hh[i][j] - 1);
cout << ans << endl;
} | replace | 42 | 44 | 42 | 44 | 0 | |
p03014 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
struct wawa {
char a;
int yoko, tate;
};
wawa s[2000][2000];
int main() {
int mini = 0;
int h, w;
cin >> h >> w;
for (int i = 0; i <= h + 1; i++) {
for (int j = 0; j <= w + 1; j++) {
if (i == 0 || i == h + 1 || j == 0 || j == w + 1)
s[i][j].a = '#';
else
cin >> s[i][j].a;
}
}
for (int i = 0; i <= h + 1; i++) {
for (int j = 0; j <= w + 1; j++) {
if (s[i][j].a == '#') {
s[i][j].yoko = 0;
s[i][j].tate = 0;
} else {
if (s[i - 1][j].a == '#') {
int k = 0;
while (s[i + k][j].a == '.') {
k++;
}
s[i][j].yoko = k;
} else
s[i][j].yoko = s[i - 1][j].yoko;
if (s[i][j - 1].a == '#') {
int k = 0;
while (s[i][j + k].a == '.') {
k++;
}
s[i][j].tate = k;
} else
s[i][j].tate = s[i][j - 1].tate;
}
mini = max(mini, s[i][j].yoko + s[i][j].tate - 1);
}
}
cout << mini << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
struct wawa {
char a;
int yoko, tate;
};
wawa s[2005][2005];
int main() {
int mini = 0;
int h, w;
cin >> h >> w;
for (int i = 0; i <= h + 1; i++) {
for (int j = 0; j <= w + 1; j++) {
if (i == 0 || i == h + 1 || j == 0 || j == w + 1)
s[i][j].a = '#';
else
cin >> s[i][j].a;
}
}
for (int i = 0; i <= h + 1; i++) {
for (int j = 0; j <= w + 1; j++) {
if (s[i][j].a == '#') {
s[i][j].yoko = 0;
s[i][j].tate = 0;
} else {
if (s[i - 1][j].a == '#') {
int k = 0;
while (s[i + k][j].a == '.') {
k++;
}
s[i][j].yoko = k;
} else
s[i][j].yoko = s[i - 1][j].yoko;
if (s[i][j - 1].a == '#') {
int k = 0;
while (s[i][j + k].a == '.') {
k++;
}
s[i][j].tate = k;
} else
s[i][j].tate = s[i][j - 1].tate;
}
mini = max(mini, s[i][j].yoko + s[i][j].tate - 1);
}
}
cout << mini << endl;
return 0;
} | replace | 7 | 8 | 7 | 8 | 0 | |
p03014 | C++ | Runtime Error | #define DEBUG 0
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, x, n) for (int i = x; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <class T> using numr = std::numeric_limits<T>;
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
const int INF = 1e9;
const ll LLINF = 1e16;
const int mod = 1000000007;
const int mod2 = 998244353;
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) {
std::cerr << " " << head;
debug_impl(tail...);
}
#if DEBUG
#define debug(...) \
do { \
std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:"; \
debug_impl(__VA_ARGS__); \
std::cerr << std::noboolalpha; \
} while (false)
#else
#define debug(...) \
{}
#endif
template <typename Container, typename Value = typename Container::value_type,
std::enable_if_t<!std::is_same<Container, std::string>::value,
std::nullptr_t> = nullptr>
std::istream &operator>>(std::istream &is, Container &v) {
for (auto &x : v) {
is >> x;
}
return is;
}
template <typename Container, typename Value = typename Container::value_type,
std::enable_if_t<!std::is_same<Container, std::string>::value,
std::nullptr_t> = nullptr>
std::ostream &operator<<(std::ostream &os, Container const &v) {
os << "{";
for (auto it = v.begin(); it != v.end(); it++) {
os << (it != v.begin() ? "," : "") << *it;
}
return os << "}";
}
int H, W;
vector<string> fi;
int Left[2100][2100], Right[2100][2100], Up[2100][2100], Down[2100][2100];
int main() {
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
cin >> H >> W;
rep(i, H) cin >> fi[i];
// 前処理
for (int i = 0; i < H; ++i) {
int cur = 0;
for (int j = 0; j < W; ++j) {
if (fi[i][j] == '#')
cur = 0;
else
++cur;
Left[i][j] = cur;
}
}
for (int i = 0; i < H; ++i) {
int cur = 0;
for (int j = W - 1; j >= 0; --j) {
if (fi[i][j] == '#')
cur = 0;
else
++cur;
Right[i][j] = cur;
}
}
for (int j = 0; j < W; ++j) {
int cur = 0;
for (int i = 0; i < H; ++i) {
if (fi[i][j] == '#')
cur = 0;
else
++cur;
Up[i][j] = cur;
}
}
for (int j = 0; j < W; ++j) {
int cur = 0;
for (int i = H - 1; i >= 0; --i) {
if (fi[i][j] == '#')
cur = 0;
else
++cur;
Down[i][j] = cur;
}
}
int res = 0;
for (int i = 0; i < H; ++i) {
for (int j = 0; j < W; ++j) {
if (fi[i][j] == '#')
continue;
res = max(res, Left[i][j] + Right[i][j] + Up[i][j] + Down[i][j] - 3);
}
}
cout << res << endl;
} | #define DEBUG 0
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, x, n) for (int i = x; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <class T> using numr = std::numeric_limits<T>;
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
const int INF = 1e9;
const ll LLINF = 1e16;
const int mod = 1000000007;
const int mod2 = 998244353;
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) {
std::cerr << " " << head;
debug_impl(tail...);
}
#if DEBUG
#define debug(...) \
do { \
std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:"; \
debug_impl(__VA_ARGS__); \
std::cerr << std::noboolalpha; \
} while (false)
#else
#define debug(...) \
{}
#endif
template <typename Container, typename Value = typename Container::value_type,
std::enable_if_t<!std::is_same<Container, std::string>::value,
std::nullptr_t> = nullptr>
std::istream &operator>>(std::istream &is, Container &v) {
for (auto &x : v) {
is >> x;
}
return is;
}
template <typename Container, typename Value = typename Container::value_type,
std::enable_if_t<!std::is_same<Container, std::string>::value,
std::nullptr_t> = nullptr>
std::ostream &operator<<(std::ostream &os, Container const &v) {
os << "{";
for (auto it = v.begin(); it != v.end(); it++) {
os << (it != v.begin() ? "," : "") << *it;
}
return os << "}";
}
int H, W;
vector<string> fi;
int Left[2100][2100], Right[2100][2100], Up[2100][2100], Down[2100][2100];
int main() {
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
cin >> H >> W;
fi.resize(H);
rep(i, H) cin >> fi[i];
// 前処理
for (int i = 0; i < H; ++i) {
int cur = 0;
for (int j = 0; j < W; ++j) {
if (fi[i][j] == '#')
cur = 0;
else
++cur;
Left[i][j] = cur;
}
}
for (int i = 0; i < H; ++i) {
int cur = 0;
for (int j = W - 1; j >= 0; --j) {
if (fi[i][j] == '#')
cur = 0;
else
++cur;
Right[i][j] = cur;
}
}
for (int j = 0; j < W; ++j) {
int cur = 0;
for (int i = 0; i < H; ++i) {
if (fi[i][j] == '#')
cur = 0;
else
++cur;
Up[i][j] = cur;
}
}
for (int j = 0; j < W; ++j) {
int cur = 0;
for (int i = H - 1; i >= 0; --i) {
if (fi[i][j] == '#')
cur = 0;
else
++cur;
Down[i][j] = cur;
}
}
int res = 0;
for (int i = 0; i < H; ++i) {
for (int j = 0; j < W; ++j) {
if (fi[i][j] == '#')
continue;
res = max(res, Left[i][j] + Right[i][j] + Up[i][j] + Down[i][j] - 3);
}
}
cout << res << endl;
} | insert | 77 | 77 | 77 | 78 | -11 | |
p03014 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int n, m;
char c[1003][1003], tmtmp;
int l[1003][1003], r[1003][1003];
int main() {
cin >> n >> m;
tmtmp = getchar();
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++)
c[i][j] = getchar();
tmtmp = getchar();
}
for (int i = 0; i < n; i++) {
int x = (c[i][0] != '#');
for (int j = 1; j < m; j++)
if (c[i][j] == '.')
x++;
else {
for (int k = 0; k < x; k++)
l[i][j - k - 1] = x;
x = 0;
}
for (int j = 0; j < x; j++)
l[i][m - 1 - j] = x;
x = 0;
}
for (int i = 0; i < m; i++) {
int x = (c[0][i] != '#');
for (int j = 1; j < n; j++)
if (c[j][i] == '.')
x++;
else {
for (int k = 0; k < x; k++)
r[j - k - 1][i] = x;
x = 0;
}
for (int j = 0; j < x; j++)
r[n - 1 - j][i] = x;
x = 0;
}
int ans = -1;
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
ans = max(ans, l[i][j] + r[i][j] - 1);
cout << ans;
} | #include <bits/stdc++.h>
using namespace std;
int n, m;
char c[2003][2003], tmtmp;
int l[2003][2003], r[2003][2003];
int main() {
cin >> n >> m;
tmtmp = getchar();
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++)
c[i][j] = getchar();
tmtmp = getchar();
}
for (int i = 0; i < n; i++) {
int x = (c[i][0] != '#');
for (int j = 1; j < m; j++)
if (c[i][j] == '.')
x++;
else {
for (int k = 0; k < x; k++)
l[i][j - k - 1] = x;
x = 0;
}
for (int j = 0; j < x; j++)
l[i][m - 1 - j] = x;
x = 0;
}
for (int i = 0; i < m; i++) {
int x = (c[0][i] != '#');
for (int j = 1; j < n; j++)
if (c[j][i] == '.')
x++;
else {
for (int k = 0; k < x; k++)
r[j - k - 1][i] = x;
x = 0;
}
for (int j = 0; j < x; j++)
r[n - 1 - j][i] = x;
x = 0;
}
int ans = -1;
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
ans = max(ans, l[i][j] + r[i][j] - 1);
cout << ans;
} | replace | 3 | 5 | 3 | 5 | 0 | |
p03014 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int H, W;
vector<vector<bool>> maze;
int main() {
cin >> H;
cin >> W;
maze = vector<vector<bool>>(H, vector<bool>(W, true));
for (int i = 0; i < H; i++) {
string s;
cin >> s;
for (int j = 0; j < W; j++) {
if (s.at(j) == '#') {
maze.at(i).at(j) = false;
}
}
}
vector<vector<int>> h_len = vector<vector<int>>(H, vector<int>(W, 0));
vector<vector<int>> w_len = vector<vector<int>>(H, vector<int>(W, 0));
for (int i = 0; i < H; i++) {
int count = 0;
for (int j = 0; j < W; j++) {
if (maze.at(i).at(j)) {
count++;
w_len.at(i).at(j) = count;
} else {
count = 0;
}
}
for (int j = W - 2; j >= 0; j--) {
if (w_len.at(i).at(j) > 0 && w_len.at(i).at(j + 1) > 0) {
w_len.at(i).at(j) = w_len.at(i).at(j + 1);
}
}
}
for (int j = 0; j < W; j++) {
int count = 0;
for (int i = 0; i < H; i++) {
if (maze.at(i).at(j)) {
count++;
h_len.at(i).at(j) = count;
} else {
count = 0;
}
}
for (int i = H - 2; i >= 0; i--) {
if (h_len.at(i).at(j) > 0 && h_len.at(i + 1).at(j) > 0) {
h_len.at(i).at(j) = h_len.at(i + 1).at(j);
}
}
}
int ans = 0;
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
if (maze.at(i).at(j)) {
int tmp = h_len.at(i).at(j) + w_len.at(i).at(i) - 1;
ans = max(ans, tmp);
}
}
}
cout << ans << endl;
return 0;
}
| #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int H, W;
vector<vector<bool>> maze;
int main() {
cin >> H;
cin >> W;
maze = vector<vector<bool>>(H, vector<bool>(W, true));
for (int i = 0; i < H; i++) {
string s;
cin >> s;
for (int j = 0; j < W; j++) {
if (s.at(j) == '#') {
maze.at(i).at(j) = false;
}
}
}
vector<vector<int>> h_len = vector<vector<int>>(H, vector<int>(W, 0));
vector<vector<int>> w_len = vector<vector<int>>(H, vector<int>(W, 0));
for (int i = 0; i < H; i++) {
int count = 0;
for (int j = 0; j < W; j++) {
if (maze.at(i).at(j)) {
count++;
w_len.at(i).at(j) = count;
} else {
count = 0;
}
}
for (int j = W - 2; j >= 0; j--) {
if (w_len.at(i).at(j) > 0 && w_len.at(i).at(j + 1) > 0) {
w_len.at(i).at(j) = w_len.at(i).at(j + 1);
}
}
}
for (int j = 0; j < W; j++) {
int count = 0;
for (int i = 0; i < H; i++) {
if (maze.at(i).at(j)) {
count++;
h_len.at(i).at(j) = count;
} else {
count = 0;
}
}
for (int i = H - 2; i >= 0; i--) {
if (h_len.at(i).at(j) > 0 && h_len.at(i + 1).at(j) > 0) {
h_len.at(i).at(j) = h_len.at(i + 1).at(j);
}
}
}
int ans = 0;
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
if (maze.at(i).at(j)) {
int tmp = h_len.at(i).at(j) + w_len.at(i).at(j) - 1;
ans = max(ans, tmp);
}
}
}
cout << ans << endl;
return 0;
}
| replace | 69 | 70 | 69 | 70 | 0 | |
p03014 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;
const ll MOD = 1e9 + 7;
int l[210][2100], r[2100][2100], u[2100][2100], d[2100][2100];
int main() {
int h, w;
cin >> h >> w;
V<string> board(h);
for (int i = 0; i < h; i++)
cin >> board[i];
for (int i = 0; i < h; i++) {
int c = 0;
for (int j = 0; j < w; j++) {
if (board[i][j] == '#')
c = 0;
else
c++;
l[i][j] = c;
}
}
for (int i = 0; i < h; i++) {
int c = 0;
for (int j = w - 1; j >= 0; j--) {
if (board[i][j] == '#')
c = 0;
else
c++;
r[i][j] = c;
}
}
for (int i = 0; i < w; i++) {
int c = 0;
for (int j = 0; j < h; j++) {
if (board[j][i] == '#')
c = 0;
else
c++;
u[j][i] = c;
}
}
for (int i = 0; i < w; i++) {
int c = 0;
for (int j = h - 1; j >= 0; j--) {
if (board[j][i] == '#')
c = 0;
else
c++;
d[j][i] = c;
}
}
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 << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;
const ll MOD = 1e9 + 7;
int l[2100][2100], r[2100][2100], u[2100][2100], d[2100][2100];
int main() {
int h, w;
cin >> h >> w;
V<string> board(h);
for (int i = 0; i < h; i++)
cin >> board[i];
for (int i = 0; i < h; i++) {
int c = 0;
for (int j = 0; j < w; j++) {
if (board[i][j] == '#')
c = 0;
else
c++;
l[i][j] = c;
}
}
for (int i = 0; i < h; i++) {
int c = 0;
for (int j = w - 1; j >= 0; j--) {
if (board[i][j] == '#')
c = 0;
else
c++;
r[i][j] = c;
}
}
for (int i = 0; i < w; i++) {
int c = 0;
for (int j = 0; j < h; j++) {
if (board[j][i] == '#')
c = 0;
else
c++;
u[j][i] = c;
}
}
for (int i = 0; i < w; i++) {
int c = 0;
for (int j = h - 1; j >= 0; j--) {
if (board[j][i] == '#')
c = 0;
else
c++;
d[j][i] = c;
}
}
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 << endl;
}
| replace | 11 | 12 | 11 | 12 | 0 | |
p03014 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>
using namespace std;
#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define GI(name) \
int(name); \
scanf("%d", &(name))
#define GI2(name1, name2) \
int(name1), (name2); \
scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
int(name1), (name2), (name3); \
scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size) \
vector<int>(name)(size); \
FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
string(name); \
cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)
string to_string(string s) { return s; }
template <class T> string to_string(vector<T> v) {
string ret = "{";
FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
if (v.size() > 0) {
ret += to_string(v.back());
}
ret += "}";
return ret;
}
void debug() { cerr << endl; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
cerr << to_string(head) << " ";
debug(tail...);
}
void print() { cout << endl; }
template <class Head, class... Tail> void print(Head head, Tail... tail) {
cout << to_string(head);
print(tail...);
}
int main() {
GI2(H, W);
vector<string> S(H);
vector<int> yoko(H * W), tate(H * W);
FOR(i, H) cin >> S[i];
FOR(i, H) {
int now_count = 0;
FOR(j, W) {
if (S[i][j] == '.') {
now_count++;
} else {
for (int x = j - now_count; x < j; ++x) {
yoko[i * W + x] = now_count;
}
now_count = 0;
}
}
if (now_count > 0) {
for (int x = W - now_count; x < W; ++x) {
yoko[i * W + x] = now_count;
}
}
}
FOR(j, W) {
int now_count = 0;
FOR(i, H) {
if (S[i][j] == '.') {
now_count++;
} else {
for (int y = i - now_count; y < i; ++y) {
tate[y * W + j] = now_count;
}
now_count = 0;
}
}
if (now_count > 0) {
for (int y = H - now_count; y < W; ++y) {
tate[y * W + j] = now_count;
}
}
}
int ans = 0;
FOR(i, H) {
FOR(j, W) {
ans = max(ans, yoko[i * W + j] + tate[i * W + j] -
(yoko[i * W + j] > 0 && tate[i * W + j] ? 1 : 0));
}
}
print(ans);
return 0;
} | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>
using namespace std;
#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define GI(name) \
int(name); \
scanf("%d", &(name))
#define GI2(name1, name2) \
int(name1), (name2); \
scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
int(name1), (name2), (name3); \
scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size) \
vector<int>(name)(size); \
FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
string(name); \
cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)
string to_string(string s) { return s; }
template <class T> string to_string(vector<T> v) {
string ret = "{";
FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
if (v.size() > 0) {
ret += to_string(v.back());
}
ret += "}";
return ret;
}
void debug() { cerr << endl; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
cerr << to_string(head) << " ";
debug(tail...);
}
void print() { cout << endl; }
template <class Head, class... Tail> void print(Head head, Tail... tail) {
cout << to_string(head);
print(tail...);
}
int main() {
GI2(H, W);
vector<string> S(H);
vector<int> yoko(H * W), tate(H * W);
FOR(i, H) cin >> S[i];
FOR(i, H) {
int now_count = 0;
FOR(j, W) {
if (S[i][j] == '.') {
now_count++;
} else {
for (int x = j - now_count; x < j; ++x) {
yoko[i * W + x] = now_count;
}
now_count = 0;
}
}
if (now_count > 0) {
for (int x = W - now_count; x < W; ++x) {
yoko[i * W + x] = now_count;
}
}
}
FOR(j, W) {
int now_count = 0;
FOR(i, H) {
if (S[i][j] == '.') {
now_count++;
} else {
for (int y = i - now_count; y < i; ++y) {
tate[y * W + j] = now_count;
}
now_count = 0;
}
}
if (now_count > 0) {
for (int y = H - now_count; y < H; ++y) {
tate[y * W + j] = now_count;
}
}
}
int ans = 0;
FOR(i, H) {
FOR(j, W) {
ans = max(ans, yoko[i * W + j] + tate[i * W + j] -
(yoko[i * W + j] > 0 && tate[i * W + j] ? 1 : 0));
}
}
print(ans);
return 0;
} | replace | 100 | 101 | 100 | 101 | -6 | malloc(): corrupted top size
|
p03014 | C++ | Runtime Error | #include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <tuple>
#include <vector>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define req(i, n) for (ll i = 1; i <= n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define ALL(obj) begin(obj), end(obj)
typedef long long int ll;
typedef long double ld;
const ll INF = (1LL << 62);
ll k, m, t, q;
int sum = 0, ans = 0;
int n;
string s;
const ld PI = acos(-1);
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
std::fill((T *)array, (T *)(array + N), val);
}
int main() {
cin >> n >> m;
vector<vector<char>> c(n, vector<char>(m));
int L[201][201], R[201][201], D[201][201], U[201][201];
rep(i, n) { rep(j, m) cin >> c[i][j]; }
rep(i, n) {
if (c[i][0] == '.')
L[i][0] = 1;
else
L[i][0] = 0;
req(j, m - 1) {
if (c[i][j] == '.')
L[i][j] = L[i][j - 1] + 1;
else
L[i][j] = 0;
}
}
rep(i, n) {
if (c[i][m - 1] == '.')
R[i][m - 1] = 1;
else
R[i][m - 1] = 0;
rrep(j, m - 1) {
if (c[i][j] == '.')
R[i][j] = R[i][j + 1] + 1;
else
R[i][j] = 0;
}
}
rep(j, m) {
if (c[0][j] == '.')
D[0][j] = 1;
else
D[0][j] = 0;
req(i, n - 1) {
if (c[i][j] == '.')
D[i][j] = D[i - 1][j] + 1;
else
D[i][j] = 0;
}
}
rep(j, m) {
if (c[n - 1][j] == '.')
U[n - 1][j] = 1;
else
U[n - 1][j] = 0;
rrep(i, n - 1) {
if (c[i][j] == '.')
U[i][j] = U[i + 1][j] + 1;
else
U[i][j] = 0;
}
}
rep(i, n) {
rep(j, m) { sum = max(L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3, sum); }
}
cout << sum << endl;
} | #include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <tuple>
#include <vector>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define req(i, n) for (ll i = 1; i <= n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define ALL(obj) begin(obj), end(obj)
typedef long long int ll;
typedef long double ld;
const ll INF = (1LL << 62);
ll k, m, t, q;
int sum = 0, ans = 0;
int n;
string s;
const ld PI = acos(-1);
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
std::fill((T *)array, (T *)(array + N), val);
}
int main() {
cin >> n >> m;
vector<vector<char>> c(n, vector<char>(m));
int L[2010][2010], R[2010][2001], D[2001][2010], U[2001][2010];
rep(i, n) { rep(j, m) cin >> c[i][j]; }
rep(i, n) {
if (c[i][0] == '.')
L[i][0] = 1;
else
L[i][0] = 0;
req(j, m - 1) {
if (c[i][j] == '.')
L[i][j] = L[i][j - 1] + 1;
else
L[i][j] = 0;
}
}
rep(i, n) {
if (c[i][m - 1] == '.')
R[i][m - 1] = 1;
else
R[i][m - 1] = 0;
rrep(j, m - 1) {
if (c[i][j] == '.')
R[i][j] = R[i][j + 1] + 1;
else
R[i][j] = 0;
}
}
rep(j, m) {
if (c[0][j] == '.')
D[0][j] = 1;
else
D[0][j] = 0;
req(i, n - 1) {
if (c[i][j] == '.')
D[i][j] = D[i - 1][j] + 1;
else
D[i][j] = 0;
}
}
rep(j, m) {
if (c[n - 1][j] == '.')
U[n - 1][j] = 1;
else
U[n - 1][j] = 0;
rrep(i, n - 1) {
if (c[i][j] == '.')
U[i][j] = U[i + 1][j] + 1;
else
U[i][j] = 0;
}
}
rep(i, n) {
rep(j, m) { sum = max(L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3, sum); }
}
cout << sum << endl;
}
| replace | 32 | 33 | 32 | 33 | 0 | |
p03014 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(g) (g).begin(), (g).end()
#define REP(i, x, n) for (int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define F(i, j, k) fill(i[0], i[0] + j * j, k)
#define P(p) cout << (p) << endl;
#define SORT(v) sort(all(v))
#define SORTD(v) sort(all(v), greater<int>())
#define EXIST(s, e) ((s).find(e) != (s).end())
#define INF 1 << 30
#define v(T) vector<T>
#define vv(T) v(v(T))
#define print(x) cout << x << endl
#define printv(v) \
for (auto i : v) { \
cout << i << " "; \
} \
cout << endl
#define printu(v) \
for (auto i : v) { \
print(i); \
}
#define readv(v, n) \
for (int i = 0; i < n; i++) \
cin >> v[i]
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef long long ll;
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
int h, w;
v(string) s;
vv(int) vw;
vv(int) vh;
int ret;
int wdfs(int h_index, int w_index) {
if (w_index >= w)
return ret;
if (s[h_index][w_index] == '#') {
return ret;
}
ret++;
vw[h_index][w_index] = wdfs(h_index, w_index + 1);
return ret;
}
int hdfs(int h_index, int w_index) {
if (h_index >= h)
return ret;
if (s[h_index][w_index] == '#') {
return ret;
}
ret++;
vh[h_index][w_index] = hdfs(h_index + 1, w_index);
return ret;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> h >> w;
vh = vv(int)(10, vi(10, 0));
vw = vv(int)(10, vi(10, 0));
rep(i, h) {
string k;
cin >> k;
s.push_back(k);
}
rep(i, h) {
rep(j, w) {
if (s[i][j] == '.' && vw[i][j] == 0) {
vw[i][j] = 1;
ret = 0;
wdfs(i, j);
}
if (s[i][j] == '.' && vh[i][j] == 0) {
vh[i][j] = 1;
ret = 0;
hdfs(i, j);
}
}
}
int mx = 0;
rep(i, h) {
rep(j, w) { chmax(mx, vw[i][j] + vh[i][j] - 1); }
}
print(mx);
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(g) (g).begin(), (g).end()
#define REP(i, x, n) for (int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define F(i, j, k) fill(i[0], i[0] + j * j, k)
#define P(p) cout << (p) << endl;
#define SORT(v) sort(all(v))
#define SORTD(v) sort(all(v), greater<int>())
#define EXIST(s, e) ((s).find(e) != (s).end())
#define INF 1 << 30
#define v(T) vector<T>
#define vv(T) v(v(T))
#define print(x) cout << x << endl
#define printv(v) \
for (auto i : v) { \
cout << i << " "; \
} \
cout << endl
#define printu(v) \
for (auto i : v) { \
print(i); \
}
#define readv(v, n) \
for (int i = 0; i < n; i++) \
cin >> v[i]
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef long long ll;
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
int h, w;
v(string) s;
vv(int) vw;
vv(int) vh;
int ret;
int wdfs(int h_index, int w_index) {
if (w_index >= w)
return ret;
if (s[h_index][w_index] == '#') {
return ret;
}
ret++;
vw[h_index][w_index] = wdfs(h_index, w_index + 1);
return ret;
}
int hdfs(int h_index, int w_index) {
if (h_index >= h)
return ret;
if (s[h_index][w_index] == '#') {
return ret;
}
ret++;
vh[h_index][w_index] = hdfs(h_index + 1, w_index);
return ret;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> h >> w;
vh = vv(int)(2001, vi(2001, 0));
vw = vv(int)(2001, vi(2001, 0));
rep(i, h) {
string k;
cin >> k;
s.push_back(k);
}
rep(i, h) {
rep(j, w) {
if (s[i][j] == '.' && vw[i][j] == 0) {
vw[i][j] = 1;
ret = 0;
wdfs(i, j);
}
if (s[i][j] == '.' && vh[i][j] == 0) {
vh[i][j] = 1;
ret = 0;
hdfs(i, j);
}
}
}
int mx = 0;
rep(i, h) {
rep(j, w) { chmax(mx, vw[i][j] + vh[i][j] - 1); }
}
print(mx);
return 0;
} | replace | 82 | 84 | 82 | 84 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.