Submission #587487

# Submission time Handle Problem Language Result Execution time Memory
587487 2022-07-02T01:37:09 Z NekoRolly I want to be the very best too! (NOI17_pokemonmaster) C++17
Compilation error
0 ms 0 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)) dfs(a-1, b, x);
	if (valid(a+1, b)) dfs(a+1, b, x);
	if (valid(a, b-1)) dfs(a, b-1, x);
	if (valid(a, b+1)) 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;
pokemonmaster.cpp:15:18: error: too few arguments to function 'bool valid(int, int, int)'
   15 |  if (valid(a-1, b)) dfs(a-1, b, x);
      |                  ^
pokemonmaster.cpp:10:6: note: declared here
   10 | bool valid(int a,int b,int x){
      |      ^~~~~
pokemonmaster.cpp:16:18: error: too few arguments to function 'bool valid(int, int, int)'
   16 |  if (valid(a+1, b)) dfs(a+1, b, x);
      |                  ^
pokemonmaster.cpp:10:6: note: declared here
   10 | bool valid(int a,int b,int x){
      |      ^~~~~
pokemonmaster.cpp:17:18: error: too few arguments to function 'bool valid(int, int, int)'
   17 |  if (valid(a, b-1)) dfs(a, b-1, x);
      |                  ^
pokemonmaster.cpp:10:6: note: declared here
   10 | bool valid(int a,int b,int x){
      |      ^~~~~
pokemonmaster.cpp:18:18: error: too few arguments to function 'bool valid(int, int, int)'
   18 |  if (valid(a, b+1)) dfs(a, b+1, x);
      |                  ^
pokemonmaster.cpp:10:6: note: declared here
   10 | bool valid(int a,int b,int x){
      |      ^~~~~