이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (stderr) 메시지
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;
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |