Submission #969588

#TimeUsernameProblemLanguageResultExecution timeMemory
969588AmaarsaaBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
539 ms134232 KiB
#include<bits/stdc++.h>

using namespace std;
using ll = long long ;
vector < ll > O[3002], I[3002];
vector < pair < ll, ll > > J;
ll A[3003][3003];
int main() {
//	freopen("moocast.in", "r", stdin);
//	freopen("moocast.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll t, n, m, ans, s, sum, x, y, r, p, i, j;

	cin >> n >> m;
	

	
	for (i = 1; i <= n; i ++) {
		string str;
		cin >> str;
		for (j = 1; j <= m; j ++) {
			if ( str[j - 1] == 'O') {
				O[i].push_back(j);
			}
			if ( str[j - 1] == 'I') {
				I[j].push_back(i);
			}
			if ( str[j - 1] == 'J') {
				J.push_back({i, j});
			}
		}
	}
	ans = 0;
	for ( pair < ll, ll>&P : J) {
		x = P.first;
		y = P.second;
		r = (upper_bound(I[y].begin(), I[y].end(), x) - I[y].begin());
		r = I[y].size() - r;
		s = upper_bound(O[x].begin(), O[x].end(), y) - O[x].begin();
		s = O[x].size() - s;
		ans = ans + (r * s);
	}
	cout << ans << endl;
}

Compilation message (stderr)

joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:13:5: warning: unused variable 't' [-Wunused-variable]
   13 |  ll t, n, m, ans, s, sum, x, y, r, p, i, j;
      |     ^
joi2019_ho_t1.cpp:13:22: warning: unused variable 'sum' [-Wunused-variable]
   13 |  ll t, n, m, ans, s, sum, x, y, r, p, i, j;
      |                      ^~~
joi2019_ho_t1.cpp:13:36: warning: unused variable 'p' [-Wunused-variable]
   13 |  ll t, n, m, ans, s, sum, x, y, r, p, i, j;
      |                                    ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...