답안 #1003924

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1003924 2024-06-20T20:11:17 Z vjudge1 Paint (COI20_paint) C++17
0 / 100
22 ms 2020 KB
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
const int MAXN = 5e5+5;
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pb push_back
#define fr first
#define sc second

int n, m, q, c, aux[4] = {0,0,1,-1};
vector<vector<bool>> vis;
vector<vector<int>> v;
vector<pii> V;

void dfs(int x, int y) {
    V.pb({x,y});
    vis[x][y] = 1;

    for(int i = 0; i < 4; i++) {
        int a = x+aux[i], b = y+aux[3-i];
        if(a >= 0 and b >= 0 and a < n and b < m and v[a][b] == v[x][y] and !vis[a][b])
            dfs(a,b);
    }
    
    v[x][y] = c;
}
int main() {

    cin >> n >> m;
    v.resize(n);
    vis.resize(n);
    
    for(int i = 0; i < n; i++) {
        v[i].resize(m);
        vis[i].resize(m);
        for(int j = 0; j < m; j++)
            cin >> v[i][j];
    }

    cin >> q;
    while(q--) {
        int a, b;
        cin >> a >> b >> c;

        dfs(a,b);

        for(auto [x,y] : V) vis[x][y] = 0;
        V.clear();
    }

    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
            cout << v[i][j] << " \n"[j==m-1];
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 860 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 22 ms 2020 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 14 ms 1624 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -