이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ve vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define si(v) (int)v.size()
#define en '\n'
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 2e5 + 228;
const int big = 1e9;
int n, m, b[N], curCol, col;
map<pi, bool> mrk;
map<pi, int> re;
queue<int> X, Y;
void put(int x, int y){
if (x < 1 || x > n || y < 1 || y > m) return;
if (mrk[mp(x, y)]) return;
if (re[mp(x, y)] != curCol) return;
re[mp(x, y)] = col;
mrk[mp(x, y)] = 1;
X.push(x); Y.push(y);
}
void go(int x, int y){
int st[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
for (int i = 0; i < 4; i++) {
put(x + st[i][0], y + st[i][1]);
}
}
int main(){
iostream::sync_with_stdio(false); cin.tie(0); ios_base::sync_with_stdio(false); cout.tie(0);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
cin >> n >> m;
int kol = 0;
for (int i = 1; i <= n; i++){
for (int j = 1; j <= m; j++){
int x; cin >> x;
re[mp(i, j)] = x;
}
}
int q;
cin >> q;
while(q--){
int x, y;
cin >> x >> y >> col;
curCol = re[mp(x, y)];
put(x, y);
while(!X.empty()){
int x = X.front(); X.pop();
int y = Y.front(); Y.pop();
go(x, y);
}
for (int i = 1; i <= n; i++){
for (int j = 1; j <= m; j++){
mrk[mp(i, j)] = 0;
}
}
}
for (int i = 1; i <= n; i++){
for (int j = 1; j <= m; j++){
cout << re[mp(i, j)] << ' ';
}
cout << en;
}
return 0;
}
/*
12 11
1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 0 0 0 1 1 1 1
1 1 1 0 0 0 0 0 1 1 1
1 1 0 0 0 0 0 0 0 1 1
1 0 0 0 2 2 2 0 0 0 1
1 0 0 0 2 2 2 0 0 0 1
1 0 0 0 2 2 2 0 0 0 1
1 0 0 0 0 0 0 0 0 0 1
1 1 0 0 0 9 0 0 0 1 1
0 1 1 0 0 9 0 0 1 1 0
0 0 1 1 0 0 0 1 1 0 0
0 0 0 1 1 1 1 1 0 0 0
4
12 11 1
5 11 2
4 4 2
6 6 4
*/
컴파일 시 표준 에러 (stderr) 메시지
paint.cpp: In function 'int main()':
paint.cpp:43:9: warning: unused variable 'kol' [-Wunused-variable]
43 | int kol = 0;
| ^~~
# | 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... |