답안 #913656

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
913656 2024-01-20T08:39:08 Z ashkan_ahmadi_koni Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
377 ms 79360 KB
/*               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

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)
      |  ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 6236 KB Output is correct
2 Correct 4 ms 6388 KB Output is correct
3 Correct 4 ms 6236 KB Output is correct
4 Correct 3 ms 6236 KB Output is correct
5 Correct 3 ms 6236 KB Output is correct
6 Correct 4 ms 6236 KB Output is correct
7 Correct 4 ms 6236 KB Output is correct
8 Correct 4 ms 6236 KB Output is correct
9 Correct 4 ms 6272 KB Output is correct
10 Correct 4 ms 6404 KB Output is correct
11 Correct 4 ms 6232 KB Output is correct
12 Correct 4 ms 6236 KB Output is correct
13 Correct 3 ms 6244 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 6236 KB Output is correct
2 Correct 4 ms 6388 KB Output is correct
3 Correct 4 ms 6236 KB Output is correct
4 Correct 3 ms 6236 KB Output is correct
5 Correct 3 ms 6236 KB Output is correct
6 Correct 4 ms 6236 KB Output is correct
7 Correct 4 ms 6236 KB Output is correct
8 Correct 4 ms 6236 KB Output is correct
9 Correct 4 ms 6272 KB Output is correct
10 Correct 4 ms 6404 KB Output is correct
11 Correct 4 ms 6232 KB Output is correct
12 Correct 4 ms 6236 KB Output is correct
13 Correct 3 ms 6244 KB Output is correct
14 Correct 12 ms 7000 KB Output is correct
15 Correct 4 ms 6236 KB Output is correct
16 Correct 5 ms 6748 KB Output is correct
17 Correct 3 ms 6236 KB Output is correct
18 Correct 13 ms 7308 KB Output is correct
19 Correct 12 ms 7772 KB Output is correct
20 Correct 10 ms 7004 KB Output is correct
21 Correct 17 ms 7304 KB Output is correct
22 Correct 9 ms 7412 KB Output is correct
23 Correct 12 ms 7308 KB Output is correct
24 Correct 15 ms 7240 KB Output is correct
25 Correct 11 ms 7836 KB Output is correct
26 Correct 12 ms 7004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 6236 KB Output is correct
2 Correct 4 ms 6388 KB Output is correct
3 Correct 4 ms 6236 KB Output is correct
4 Correct 3 ms 6236 KB Output is correct
5 Correct 3 ms 6236 KB Output is correct
6 Correct 4 ms 6236 KB Output is correct
7 Correct 4 ms 6236 KB Output is correct
8 Correct 4 ms 6236 KB Output is correct
9 Correct 4 ms 6272 KB Output is correct
10 Correct 4 ms 6404 KB Output is correct
11 Correct 4 ms 6232 KB Output is correct
12 Correct 4 ms 6236 KB Output is correct
13 Correct 3 ms 6244 KB Output is correct
14 Correct 12 ms 7000 KB Output is correct
15 Correct 4 ms 6236 KB Output is correct
16 Correct 5 ms 6748 KB Output is correct
17 Correct 3 ms 6236 KB Output is correct
18 Correct 13 ms 7308 KB Output is correct
19 Correct 12 ms 7772 KB Output is correct
20 Correct 10 ms 7004 KB Output is correct
21 Correct 17 ms 7304 KB Output is correct
22 Correct 9 ms 7412 KB Output is correct
23 Correct 12 ms 7308 KB Output is correct
24 Correct 15 ms 7240 KB Output is correct
25 Correct 11 ms 7836 KB Output is correct
26 Correct 12 ms 7004 KB Output is correct
27 Correct 352 ms 60020 KB Output is correct
28 Correct 6 ms 12420 KB Output is correct
29 Correct 19 ms 9388 KB Output is correct
30 Correct 5 ms 6232 KB Output is correct
31 Correct 247 ms 46736 KB Output is correct
32 Correct 233 ms 79360 KB Output is correct
33 Correct 195 ms 60916 KB Output is correct
34 Correct 321 ms 52844 KB Output is correct
35 Correct 244 ms 62200 KB Output is correct
36 Correct 168 ms 60900 KB Output is correct
37 Correct 377 ms 61524 KB Output is correct
38 Correct 185 ms 60912 KB Output is correct
39 Correct 159 ms 48792 KB Output is correct