| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1302396 | nhmktu | JOI 문장 (JOI14_ho_t1) | C++20 | 85 ms | 1420 KiB |
#include <bits/stdc++.h>
#define ll long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define pi pair<int,int>
#define pii pair<int,pi>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(a) (int) a.size()
#define endl '\n'
#define data "data"
using namespace std;
const ll linf = 1e18;
const int inf = 1e9;
const int MOD = 1e9 + 7, N = 1e3;
void add(int &a, int b)
{
a += b;
if(a>=MOD)
a-=MOD;
if(a<0)
a += MOD;
}
int modulo(int x)
{
if(x<=1)
return 1;
return (MOD - MOD/x) * modulo(MOD/x) % MOD;
}
int mul(int a, int b)
{
return (1ll *a%MOD * b%MOD) % MOD;
}
int n, m;
char c[N+3][N+3];
char t[3][3];
void inp(void)
{
cin >> n >> m;
FOR(i, 1, n) FOR(j, 1, m) cin >> c[i][j];
FOR(i, 1, 2) FOR(j, 1, 2) cin >> t[i][j];
}
bool check(int i, int j)
{
if(c[i-1][j-1] != t[1][1]) return 0;
if(c[i-1][j] != t[1][2]) return 0;
if(c[i][j-1] != t[2][1]) return 0;
if(c[i][j] != t[2][2]) return 0;
return 1;
}
int calc(int i, int j, char ch)
{
int ret = 0;
ret -= check(i, j);
ret -= check(i, j + 1);
ret -= check(i + 1, j);
ret -= check(i + 1, j + 1);
char pch = c[i][j];
c[i][j] = ch;
ret += check(i, j);
ret += check(i, j + 1);
ret += check(i + 1, j);
ret += check(i + 1, j + 1);
c[i][j] = pch;
return ret;
}
void solve(void)
{
int ans = 0;
FOR(i, 1, n) FOR(j, 1, m) ans += check(i, j);
int del = 0;
FOR(i, 1, n)
{
FOR(j, 1, m)
{
del = max(del, calc(i, j, 'J'));
del = max(del, calc(i, j, 'O'));
del = max(del, calc(i, j, 'I'));
}
}
cout << ans + del;
}
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
if(fopen(data".inp", "r"))
{
freopen(data".inp","r",stdin);
freopen(data".out","w",stdout);
}
inp();
solve();
return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
