Submission #560069

# Submission time Handle Problem Language Result Execution time Memory
560069 2022-05-11T03:33:33 Z Baytoro Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
284 ms 159116 KB
#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];
int 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++){
			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]=='O')
				pref[i][j]++;
		}
	}
	for(i=n;i>=1;i--){
		for(j=1;j<=m;j++){
			suf[i][j]=suf[i+1][j];
			if(ar[i][j]=='I')
				suf[i][j]++;
		}
	}
	res=0;
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			if(ar[i][j]=='J'){
				res+=pref[i][j]*suf[i][j];
			}
		}
	}
	cout<<res<<endl;
}
main(){
	ios;
	int T=1;
	//cin>>T;
	while(T--){
		solve();
	}
}




Compilation message

joi2019_ho_t1.cpp:61:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   61 | 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);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 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 1 ms 340 KB Output is correct
5 Correct 1 ms 1492 KB Output is correct
6 Correct 1 ms 1492 KB Output is correct
7 Correct 1 ms 1364 KB Output is correct
8 Correct 1 ms 1492 KB Output is correct
9 Correct 1 ms 1492 KB Output is correct
10 Correct 1 ms 1364 KB Output is correct
11 Correct 1 ms 1492 KB Output is correct
12 Correct 1 ms 1492 KB Output is correct
13 Correct 1 ms 1364 KB Output is correct
# 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 1 ms 340 KB Output is correct
5 Correct 1 ms 1492 KB Output is correct
6 Correct 1 ms 1492 KB Output is correct
7 Correct 1 ms 1364 KB Output is correct
8 Correct 1 ms 1492 KB Output is correct
9 Correct 1 ms 1492 KB Output is correct
10 Correct 1 ms 1364 KB Output is correct
11 Correct 1 ms 1492 KB Output is correct
12 Correct 1 ms 1492 KB Output is correct
13 Correct 1 ms 1364 KB Output is correct
14 Correct 11 ms 8788 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 5 ms 5204 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 12 ms 9684 KB Output is correct
19 Correct 9 ms 9556 KB Output is correct
20 Correct 9 ms 9496 KB Output is correct
21 Correct 11 ms 9748 KB Output is correct
22 Correct 11 ms 9556 KB Output is correct
23 Correct 10 ms 9476 KB Output is correct
24 Correct 11 ms 9684 KB Output is correct
25 Correct 9 ms 9524 KB Output is correct
26 Correct 9 ms 9556 KB Output is correct
# 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 1 ms 340 KB Output is correct
5 Correct 1 ms 1492 KB Output is correct
6 Correct 1 ms 1492 KB Output is correct
7 Correct 1 ms 1364 KB Output is correct
8 Correct 1 ms 1492 KB Output is correct
9 Correct 1 ms 1492 KB Output is correct
10 Correct 1 ms 1364 KB Output is correct
11 Correct 1 ms 1492 KB Output is correct
12 Correct 1 ms 1492 KB Output is correct
13 Correct 1 ms 1364 KB Output is correct
14 Correct 11 ms 8788 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 5 ms 5204 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 12 ms 9684 KB Output is correct
19 Correct 9 ms 9556 KB Output is correct
20 Correct 9 ms 9496 KB Output is correct
21 Correct 11 ms 9748 KB Output is correct
22 Correct 11 ms 9556 KB Output is correct
23 Correct 10 ms 9476 KB Output is correct
24 Correct 11 ms 9684 KB Output is correct
25 Correct 9 ms 9524 KB Output is correct
26 Correct 9 ms 9556 KB Output is correct
27 Correct 284 ms 158660 KB Output is correct
28 Correct 12 ms 26300 KB Output is correct
29 Correct 17 ms 13908 KB Output is correct
30 Correct 1 ms 728 KB Output is correct
31 Correct 209 ms 131428 KB Output is correct
32 Correct 239 ms 159116 KB Output is correct
33 Correct 236 ms 158520 KB Output is correct
34 Correct 243 ms 152320 KB Output is correct
35 Correct 234 ms 158916 KB Output is correct
36 Correct 237 ms 158420 KB Output is correct
37 Correct 279 ms 159112 KB Output is correct
38 Correct 176 ms 130720 KB Output is correct
39 Correct 152 ms 130824 KB Output is correct