Submission #153353

#TimeUsernameProblemLanguageResultExecution timeMemory
153353junodeveloperBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
311 ms53368 KiB
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int h,w;
int tmp[3010][3010];
char s[3010][3010];
int main() {
	scanf("%d%d",&h,&w);
	int i,j;
	for(i=0;i<h;i++) scanf("%s",s[i]);
	for(i=0;i<h;i++) {
		int c=0;
		for(j=w-1;j>=0;j--) {
			if(s[i][j]=='O') c++;
			else if(s[i][j]=='J') tmp[i][j]=c;
		}
	}
	ll ans=0;
	for(j=0;j<w;j++) {
		int c=0;
		for(i=h-1;i>=0;i--) {
			if(s[i][j]=='I') c++;
			else if(s[i][j]=='J') ans+=tmp[i][j]*c;
		}
	}
	printf("%lld",ans);
	return 0;
}

Compilation message (stderr)

joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&h,&w);
  ~~~~~^~~~~~~~~~~~~~
joi2019_ho_t1.cpp:17:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(i=0;i<h;i++) scanf("%s",s[i]);
                   ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...