답안 #587488

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
587488 2022-07-02T01:38:29 Z NekoRolly I want to be the very best too! (NOI17_pokemonmaster) C++17
16 / 100
24 ms 8292 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 5e4+4;

int n,m,q;
vector<vector<int>> level,poke,vis;
bool use[N];

bool valid(int a,int b,int x){
	return 0 < a && a <= n && 0 < b && b <= m && !vis[a][b] && level[a][b] <= x;
}

void dfs(int a,int b,int x){ use[poke[a][b]] = vis[a][b] = 1;
	if (valid(a-1, b, x)) dfs(a-1, b, x);
	if (valid(a+1, b, x)) dfs(a+1, b, x);
	if (valid(a, b-1, x)) dfs(a, b-1, x);
	if (valid(a, b+1, x)) dfs(a, b+1, x);
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	cin >> n >> m >> q;
	level.resize(n+1, vector<int> (m+1));
	poke.resize(n+1, vector<int> (m+1));
	vis.resize(n+1, vector<int> (m+1));

	for (int i=1; i<=n; i++) for (int j=1; j<=m; j++) cin >> level[i][j];
	for (int i=1; i<=n; i++) for (int j=1; j<=m; j++) cin >> poke[i][j];

	if (q <= 10){
		for (int t,a,b,x,ans; q; q--){ cin >> t >> b >> a >> x;
			if (t == 1) poke[a][b] = x;
			if (t == 2){ ans = 0;
				for (int i=1; i<N; i++) use[i] = 0;
				for (int i=1; i<=n; i++) for (int j=1; j<=m; j++) vis[i][j] = 0;
				if (level[a][b] <= x) dfs(a, b, x);
				for (int i=1; i<N; i++) ans += use[i], use[i] = 0;
				cout << ans << "\n";
			}
		}
	}
	else if (n == 1){

	}

    return 0;
}

Compilation message

pokemonmaster.cpp: In function 'void dfs(int, int, int)':
pokemonmaster.cpp:14:58: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   14 | void dfs(int a,int b,int x){ use[poke[a][b]] = vis[a][b] = 1;
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 2188 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 5740 KB Output is correct
2 Correct 12 ms 5128 KB Output is correct
3 Correct 15 ms 5264 KB Output is correct
4 Correct 15 ms 7252 KB Output is correct
5 Correct 21 ms 8264 KB Output is correct
6 Correct 24 ms 8292 KB Output is correct
7 Correct 16 ms 4180 KB Output is correct
8 Correct 15 ms 3728 KB Output is correct
9 Correct 14 ms 3668 KB Output is correct
10 Correct 15 ms 4104 KB Output is correct
11 Correct 16 ms 3796 KB Output is correct
12 Correct 15 ms 3472 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 2448 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 2188 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 2188 KB Output isn't correct
2 Halted 0 ms 0 KB -