Submission #99660

#TimeUsernameProblemLanguageResultExecution timeMemory
99660cki86201Bitaro the Brave (JOI19_ho_t1)C++11
100 / 100
228 ms84936 KiB
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_set>
#include <bitset>
#include <time.h>
#include <limits.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
typedef tuple<int, int, int> t3;

int N, M;
char X[3030][3030];
ll ans;
int cnt[3030][3030][2];

int main() {
	scanf("%d%d", &N, &M);
	for(int i=1;i<=N;i++) scanf("%s", X[i] + 1);
	for(int i=1;i<=N;i++) for(int j=1;j<=M;j++) {
		if(X[i][j] == 'O') cnt[i][j][0]++;
		if(X[i][j] == 'I') cnt[i][j][1]++;
	}
	for(int i=N;i;i--) for(int j=M;j;j--) {
		cnt[i][j][0] += cnt[i][j+1][0];
		cnt[i][j][1] += cnt[i+1][j][1];
	}
	for(int i=1;i<=N;i++) for(int j=1;j<=M;j++) if(X[i][j] == 'J') {
		ans += (ll)cnt[i][j][0] * cnt[i][j][1];
	}
	printf("%lld\n", ans);
	return 0;
}

Compilation message (stderr)

joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:38:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &N, &M);
  ~~~~~^~~~~~~~~~~~~~~~
joi2019_ho_t1.cpp:39:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=N;i++) scanf("%s", X[i] + 1);
                        ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...