답안 #500004

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
500004 2021-12-30T09:12:39 Z kappa Paint (COI20_paint) C++14
0 / 100
34 ms 5660 KB
#include <bits/stdc++.h>
#define st first
#define nd second

using namespace std;

long long a, b, q;

void solve(vector<vector<int> > &v){
    long long x, y, col, vis[a + 1][b + 1];
    memset(vis, 0, sizeof(vis));
    
    pair<int, int> dir[4] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

    cin >> x >> y >> col;

    queue<pair<int, int> > q;

    q.push({x, y});

    while(!q.empty()){
        pair<int, int> curr = q.front();
        q.pop();

        long long cx = curr.st, cy = curr.nd, currColor = v[cx][cy];

        if(vis[cx][cy]) continue;

        vis[cx][cy] = 1;

        v[cx][cy] = col; 

        for (int i = 0; i < 4; i++)
        {
            if(!vis[cx + dir[i].first][cy + dir[i].second] && v[cx + dir[i].first][cy + dir[i].second] == currColor){
                q.push({cx + dir[i].first, cy + dir[i].second});
            }
        }
    }
}

int main(){
    cin >> a >> b;

    vector<vector<int> > d(a + 1, vector<int>(b + 1, 0));

    for (int i = 1; i <= a; i++)
    {
        for (int j = 1; j <= b; j++)
        {
            cin >> d[i][j];
        }
    }

    cin >> q;

    while(q--){
        solve(d);
    }

    for (int i = 1; i <= a; i++)
    {
        for (int j = 1; j <= b; j++)
        {
            cout << d[i][j] << " ";
        }
        cout << "\n";
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 288 KB Output is correct
3 Runtime error 3 ms 684 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 12 ms 2964 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 34 ms 5660 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 25 ms 4384 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -