//~ #pragma GCC optimize("Ofast,unroll-loops")
//~ #pragma GCC target("avx,avx2,fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define fi first
#define se second
#define space " "
#define endl "\n"
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define md 1000000007
#define inf 1000000000
#define li 3005
#define int long long
using namespace std;
int n,m,vis1[li],vis2[li],flag;
char c[li][li];
vector<int> v1[li],v2[li];
int32_t main(){
scanf("%lld %lld",&n,&m);
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
scanf(" %c",&c[i][j]);
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(c[i][j]=='O') v1[i].pb(j);
}
//~ printf("ABUBU %lld %lld\n",i,sayi);
}
for(int i=1;i<=m;i++){
for(int j=1;j<=n;j++){
if(c[j][i]=='I') v2[i].pb(j);
}
//~ printf("ABUBRERER %lld %lld\n",i,sayi);
}
for(int i=1;i<=min(n,m);i++){
//~ int vl1=vis2[i];
//~ if(vl1==0) continue;
for(int j=1;j<=n;j++){
if(c[j][i]!='J') continue;
if((int)v2[i].size()==0 || (int)v1[j].size()==0) continue;
auto itr1=ub(v2[i].begin(),v2[i].end(),j);
auto itr2=ub(v1[j].begin(),v1[j].end(),i);
if(itr1==v2[i].end() || itr2==v1[j].end()) continue;
int vl1=itr1-v2[i].begin();
int vl2=itr2-v1[j].begin();
vl1=(int)v2[i].size()-vl1;
vl2=(int)v1[j].size()-vl2;
//~ printf("DEBUGGI %lld %lld %lld %lld\n",j,i,v2[i][vl1-1],v1[j][vl2-1]);
flag+=vl1*vl2;
}
}
printf("%lld\n",flag);
return 0;
}
Compilation message
joi2019_ho_t1.cpp: In function 'int32_t main()':
joi2019_ho_t1.cpp:23:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
23 | scanf("%lld %lld",&n,&m);
| ~~~~~^~~~~~~~~~~~~~~~~~~
joi2019_ho_t1.cpp:26:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
26 | scanf(" %c",&c[i][j]);
| ~~~~~^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
724 KB |
Output is correct |
6 |
Correct |
2 ms |
852 KB |
Output is correct |
7 |
Incorrect |
1 ms |
724 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
724 KB |
Output is correct |
6 |
Correct |
2 ms |
852 KB |
Output is correct |
7 |
Incorrect |
1 ms |
724 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
724 KB |
Output is correct |
6 |
Correct |
2 ms |
852 KB |
Output is correct |
7 |
Incorrect |
1 ms |
724 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |