#include <bits/stdc++.h>
using namespace std;
#define Baytoro_Mayrambekov void solve()
#define ios ios::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fr first
#define sc second
#define int long long
#define endl '\n'
const int INF=1e18;
void fopn(string name){
freopen((name+".in").c_str(),"r",stdin);
freopen((name+".out").c_str(),"w",stdout);
}
int binpow(int a,int n){
if(n==0)
return 1;
if(n%2==1)
return binpow(a, n-1)*a;
else{
int b=binpow(a, n/2);
return b*b;
}
}
char ar[3005][3005];
struct joi{
int j,o,i;
};
joi pref[3005][3005],suf[3005][3005];
int a,b,c,n,m,i,j,k,x,y,cnt=0,sum=0,res=0;
Baytoro_Mayrambekov{
cin>>n>>m;
for(i=1;i<=n;i++){
for(j=1;j<=m;j++){
char ch;
cin>>ar[i][j];
}
}
for(i=1;i<=n;i++){
for(j=m;j>=1;j--){
pref[i][j]=pref[i][j+1];
if(ar[i][j]=='J')
pref[i][j].j++;
else if(ar[i][j]=='O')
pref[i][j].o++;
else
pref[i][j].i++;
}
}
for(i=n;i>=1;i--){
for(j=1;j<=m;j++){
suf[i][j]=suf[i+1][j];
if(ar[i][j]=='J')
suf[i][j].j++;
else if(ar[i][j]=='O')
suf[i][j].o++;
else
suf[i][j].i++;
}
}
res=0;
for(i=1;i<=n;i++){
for(j=1;j<=m;j++){
if(ar[i][j]=='J'){
res+=pref[i][j].o*suf[i][j].i;
}
}
}
cout<<res<<endl;
}
main(){
ios;
int T=1;
//cin>>T;
while(T--){
solve();
}
}
Compilation message
joi2019_ho_t1.cpp: In function 'void solve()':
joi2019_ho_t1.cpp:37:9: warning: unused variable 'ch' [-Wunused-variable]
37 | char ch;
| ^~
joi2019_ho_t1.cpp: At global scope:
joi2019_ho_t1.cpp:73:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
73 | main(){
| ^~~~
joi2019_ho_t1.cpp: In function 'void fopn(std::string)':
joi2019_ho_t1.cpp:14:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
14 | freopen((name+".in").c_str(),"r",stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t1.cpp:15:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
15 | freopen((name+".out").c_str(),"w",stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1876 KB |
Output is correct |
6 |
Correct |
1 ms |
1748 KB |
Output is correct |
7 |
Correct |
1 ms |
1748 KB |
Output is correct |
8 |
Correct |
2 ms |
1876 KB |
Output is correct |
9 |
Correct |
1 ms |
1748 KB |
Output is correct |
10 |
Correct |
1 ms |
1744 KB |
Output is correct |
11 |
Correct |
2 ms |
1876 KB |
Output is correct |
12 |
Correct |
1 ms |
1748 KB |
Output is correct |
13 |
Correct |
1 ms |
1748 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1876 KB |
Output is correct |
6 |
Correct |
1 ms |
1748 KB |
Output is correct |
7 |
Correct |
1 ms |
1748 KB |
Output is correct |
8 |
Correct |
2 ms |
1876 KB |
Output is correct |
9 |
Correct |
1 ms |
1748 KB |
Output is correct |
10 |
Correct |
1 ms |
1744 KB |
Output is correct |
11 |
Correct |
2 ms |
1876 KB |
Output is correct |
12 |
Correct |
1 ms |
1748 KB |
Output is correct |
13 |
Correct |
1 ms |
1748 KB |
Output is correct |
14 |
Correct |
13 ms |
15024 KB |
Output is correct |
15 |
Correct |
3 ms |
5204 KB |
Output is correct |
16 |
Correct |
8 ms |
9432 KB |
Output is correct |
17 |
Correct |
1 ms |
596 KB |
Output is correct |
18 |
Correct |
16 ms |
17872 KB |
Output is correct |
19 |
Correct |
14 ms |
17364 KB |
Output is correct |
20 |
Correct |
14 ms |
17620 KB |
Output is correct |
21 |
Correct |
16 ms |
17912 KB |
Output is correct |
22 |
Correct |
14 ms |
17308 KB |
Output is correct |
23 |
Correct |
13 ms |
17488 KB |
Output is correct |
24 |
Correct |
16 ms |
17784 KB |
Output is correct |
25 |
Correct |
15 ms |
17360 KB |
Output is correct |
26 |
Correct |
15 ms |
17620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1876 KB |
Output is correct |
6 |
Correct |
1 ms |
1748 KB |
Output is correct |
7 |
Correct |
1 ms |
1748 KB |
Output is correct |
8 |
Correct |
2 ms |
1876 KB |
Output is correct |
9 |
Correct |
1 ms |
1748 KB |
Output is correct |
10 |
Correct |
1 ms |
1744 KB |
Output is correct |
11 |
Correct |
2 ms |
1876 KB |
Output is correct |
12 |
Correct |
1 ms |
1748 KB |
Output is correct |
13 |
Correct |
1 ms |
1748 KB |
Output is correct |
14 |
Correct |
13 ms |
15024 KB |
Output is correct |
15 |
Correct |
3 ms |
5204 KB |
Output is correct |
16 |
Correct |
8 ms |
9432 KB |
Output is correct |
17 |
Correct |
1 ms |
596 KB |
Output is correct |
18 |
Correct |
16 ms |
17872 KB |
Output is correct |
19 |
Correct |
14 ms |
17364 KB |
Output is correct |
20 |
Correct |
14 ms |
17620 KB |
Output is correct |
21 |
Correct |
16 ms |
17912 KB |
Output is correct |
22 |
Correct |
14 ms |
17308 KB |
Output is correct |
23 |
Correct |
13 ms |
17488 KB |
Output is correct |
24 |
Correct |
16 ms |
17784 KB |
Output is correct |
25 |
Correct |
15 ms |
17360 KB |
Output is correct |
26 |
Correct |
15 ms |
17620 KB |
Output is correct |
27 |
Runtime error |
301 ms |
274432 KB |
Execution killed with signal 9 |
28 |
Halted |
0 ms |
0 KB |
- |