# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1086317 | kiethm07 | Bitaro the Brave (JOI19_ho_t1) | C++11 | 213 ms | 88512 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define pii pair<int,int>
#define iii pair<int,pii>
#define fi first
#define se second
#define vi vector<int>
#define all(x) x.begin(),x.end()
#define TEXT "a"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int inf = 1e9 + 7;
const ld eps = 1e-8;
const double pi = acos(-1);
const int N = 3005;
int n,m;
char a[N][N];
int row[N][N], col[N][N];
int main(){
cin.tie(0) -> sync_with_stdio(0);
if (fopen(TEXT".inp","r")){
freopen(TEXT".inp","r",stdin);
freopen(TEXT".out","w",stdout);
}
cin >> n >> m;
for (int i = 1; i <= n; i++){
for (int j = 1; j <= m; j++) cin >> a[i][j];
}
for (int i = 1; i <= n; i++){
for (int j = 1; j <= m; j++){
col[i][j] = col[i][j - 1] + (a[i][j] == 'O');
}
}
for (int j = 1; j <= m; j++){
for (int i = 1; i <= n; i++){
row[i][j] = row[i - 1][j] + (a[i][j] == 'I');
}
}
ll res = 0;
for (int i = 1; i <= n; i++){
for (int j = 1; j <= m; j++){
if (a[i][j] != 'J') continue;
ll x = row[n][j] - row[i][j];
ll y = col[i][m] - col[i][j];
res += x * y;
}
}
cout << res << "\n";
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |