이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define F first
#define S second
#define INF 2e14
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define MAXN 3005
ll hor[MAXN][MAXN];
ll ver[MAXN][MAXN];
int main()
{
mset(hor,0); mset(ver,0);
ios_base::sync_with_stdio(0); cin.tie(0);
int n,m; cin>>n>>m;
string arr[MAXN];
forn(i,0,n) cin>>arr[i];
for(int i=0;i<n;i++){
for(int j=m-1;j>=0;j--){
if(j<m-1) hor[i][j]+=hor[i][j+1];
if(arr[i][j]=='O') hor[i][j]++;
}
}
for(int j=0;j<m;j++){
for(int i=n-1;i>=0;i--){
if(i<n-1) ver[i][j]+=ver[i+1][j];
if(arr[i][j]=='I') ver[i][j]++;
}
}
ll ans=0;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(arr[i][j]!='J') continue;
ans+=hor[i][j+1]*ver[i+1][j];
}
}
cout<<ans<<'\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |