답안 #1090723

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1090723 2024-09-18T15:57:46 Z Taxiradio Zoo (COCI19_zoo) C++14
110 / 110
51 ms 5220 KB
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;

int g[1004][1004];
queue<array<int , 2>> t , b;
int c = 0;
vector<array<int , 2>> l = {{1 , 0},{-1 , 0},{0 , -1},{0 , 1}};
void T(){
	while(!t.empty()){
		auto [h , j] = t.front();
		t.pop();
		for(auto[x , y] : l){
			if(g[h-x][j-y] == 1){
				t.push({h-x , j-y});
				g[h-x][j-y] = 0;
			}
			if(g[h-x][j-y] == 2){
				b.push({h-x , j-y});
				g[h-x][j-y] = 0;
			}
		}
	}
} 

void B(){
	while(!b.empty()){
		auto [h , j] = b.front();
		b.pop();
		for(auto[x , y] : l){
			if(g[h-x][j-y] == 1){
				t.push({h-x , j-y});
				g[h-x][j-y] = 0;
			}
			if(g[h-x][j-y] == 2){
				b.push({h-x , j-y});
				g[h-x][j-y] = 0;
			}
		}
	}
} 

int main() {
	int n, m; cin >> n >> m;
	for(int i = 1; i <= n; i++){
		for(int i2 = 1; i2 <=m; i2++){
			char y; cin >> y;
			if(y == 'T'){
				g[i][i2] = 1;
				c++;
			}
			if(y == 'B'){
				g[i][i2] = 2;
				c++;
			}
		}	
	}
	int ans = 0;
	if(g[1][1] == 1){
		t.push({1,  1});
		g[1][1] = 0;
	}else if(g[1][1] == 2){
		b.push({1 , 1});
		g[1][1] = 0;
		ans++;
		B();
	}

	while(1){
		if(t.empty() && b.empty()){
			cout << ans << endl;
			return 0;
		}
		ans++;
		T();
		if(t.empty() && b.empty()){
			cout << ans << endl;
			return 0;
		}
		ans++;
		B();
	}
}

Compilation message

zoo.cpp: In function 'void T()':
zoo.cpp:12:8: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   12 |   auto [h , j] = t.front();
      |        ^
zoo.cpp:14:11: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   14 |   for(auto[x , y] : l){
      |           ^
zoo.cpp: In function 'void B()':
zoo.cpp:29:8: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   29 |   auto [h , j] = b.front();
      |        ^
zoo.cpp:31:11: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   31 |   for(auto[x , y] : l){
      |           ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2504 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 1 ms 2652 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2652 KB Output is correct
13 Correct 1 ms 2652 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2504 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 1 ms 2652 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2652 KB Output is correct
13 Correct 1 ms 2652 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 30 ms 5208 KB Output is correct
17 Correct 32 ms 5220 KB Output is correct
18 Correct 32 ms 5200 KB Output is correct
19 Correct 31 ms 5068 KB Output is correct
20 Correct 31 ms 5016 KB Output is correct
21 Correct 51 ms 4944 KB Output is correct
22 Correct 49 ms 4852 KB Output is correct
23 Correct 49 ms 4944 KB Output is correct
24 Correct 50 ms 5200 KB Output is correct
25 Correct 50 ms 5200 KB Output is correct
26 Correct 51 ms 5076 KB Output is correct
27 Correct 49 ms 4944 KB Output is correct
28 Correct 51 ms 4956 KB Output is correct
29 Correct 49 ms 5212 KB Output is correct
30 Correct 51 ms 5136 KB Output is correct