# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1272785 | nthvn | Bitaro the Brave (JOI19_ho_t1) | C++20 | 232 ms | 221168 KiB |
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define pii pair<int,int>
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pb push_back
#define ll long long
const int N = 3005;
int n,m;
string s[N];
int a[3][N][N], ps[3][N][N];
void build_ps(int a[][N], int ps[][N]){
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
ps[i][j] = ps[i-1][j]+ ps[i][j-1]-ps[i-1][j-1]+a[i][j];
}
}
}
int get(int ps[][N], int x, int y, int u, int v){
return ps[u][v] - ps[x-1][v] - ps[u][y-1] + ps[x-1][y-1];
}
signed main(){
ios_base::sync_with_stdio(NULL);
cin.tie(NULL);
if(fopen("TASK.INP", "r")){
freopen("TASK.INP", "r", stdin);
freopen("TASK.OUT", "w", stdout);
}
cin>>n>>m;
for(int i=1;i<=n;i++) cin>>s[i], s[i]=' '+s[i];
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(s[i][j]=='J') a[0][i][j]=1;
if(s[i][j]=='O') a[1][i][j]=1;
if(s[i][j]=='I') a[2][i][j]=1;
}
}
for(int i=0;i<=2;i++) build_ps(a[i],ps[i]);
ll ans =0;
for(int i=1;i<n;i++){
for(int j=1;j<m;j++){
if(!a[0][i][j]) continue;
ll f = get(ps[1], i,j+1,i,m);
ll g = get(ps[2], i+1,j,n,j);
ans+= f*g;
}
}
cout<<ans;
}
컴파일 시 표준 에러 (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... |