Submission #913656

#TimeUsernameProblemLanguageResultExecution timeMemory
913656ashkan_ahmadi_koniBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
377 ms79360 KiB
/*               In The Name Of God               */
#include                              <bits/stdc++.h>
using                                  namespace std;
#define int                                 long long
#define sw                            sync_with_stdio
// #pragma GCC       optimize("Ofast, unroll-loops, O3")
#define fast       ios::sw(0),cin.tie(0),cout.tie(0);
const int   N = 3e3 + 3, M = 1e9 + 7, inf = 1e18 + 8; 

int h, w, ans; char a[N][N];
deque <int> ii[N], oo[N];

signed main() {
    fast; cin >> h >> w;
    
     for (int i = 1; i <= h; ++i)
    	for (int j = 1; j <= w; ++j) {
    		cin >> a[i][j];
    		
    		if (a[i][j] == 'O')
    			oo[i].push_back(j);
    		else if (a[i][j] == 'I')
    			ii[j].push_back(i);
    	}
    	
	for (int i = 1; i <= h; ++i)
		for (int j = 1; j <= w; ++j) 
			if (a[i][j] == 'J') {
				while (oo[i].size() && oo[i].front() <= j)
					oo[i].pop_front();
					
				while (ii[j].size() && ii[j].front() <= i)
					ii[j].pop_front();
					
				ans += oo[i].size() * ii[j].size();
			}
		
	cout << ans << '\n';
    
}

/* 

    .---.    .    .--.         
    |        |    |   ) o      
    |--- .--.|--. |--:  .  ---.
    |    `--.|  | |   ) |   .' 
    '---'`--''  `-'--'-' `-'--- 

*/

Compilation message (stderr)

joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:16:6: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   16 |      for (int i = 1; i <= h; ++i)
      |      ^~~
joi2019_ho_t1.cpp:26:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   26 |  for (int i = 1; i <= h; ++i)
      |  ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...