Submission #1003947

# Submission time Handle Problem Language Result Execution time Memory
1003947 2024-06-20T20:43:18 Z vjudge1 Paint (COI20_paint) C++17
8 / 100
3000 ms 14884 KB
#include <bits/stdc++.h>
using namespace std;

vector<vector<int>> adj;
int r,s;

int vx[4] = {0,0,1,-1}, vy[4] = {1,-1,0,0};

void dfs(int x, int y, int cor){
    int atual = adj[x][y];

    adj[x][y] = cor;

    for(int i=0 ;i<4; i++){
        int xx = x + vx[i]; int yy = y+vy[i];
        if(xx < 0 or xx >= r or yy < 0 or yy >= s) continue;
        if(adj[xx][yy] == atual) dfs(xx,yy,cor);
    }
    return;
}

int main(){

    cin >> r >> s;
    adj.assign(r, vector<int> (s, 0));

    for(int i=0; i<r; i++){
        for(int j=0; j<s; j++){
            int x; cin >> x;
            adj[i][j] = x;
        }
    }

    int q; cin >> q;
    for(int i=0; i<q; i++){
        int x,y,cor; cin >> x >> y >> cor;
        x--; y--;
        if(cor == adj[x][y]) continue;

        dfs(x,y,cor);
    }

    for(int i=0; i<r; i++){
        for(int j=0; j< s; j++){
            if(j) cout << ' ';
            cout << adj[i][j];
        }
        cout << endl;
    }

}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 4 ms 468 KB Output is correct
5 Correct 191 ms 668 KB Output is correct
6 Correct 279 ms 1200 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 40 ms 636 KB Output is correct
2 Correct 123 ms 1992 KB Output is correct
3 Execution timed out 3078 ms 8440 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1250 ms 13428 KB Output is correct
2 Correct 220 ms 10836 KB Output is correct
3 Correct 270 ms 13908 KB Output is correct
4 Execution timed out 3075 ms 14884 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 78 ms 3152 KB Output is correct
2 Execution timed out 3055 ms 4548 KB Time limit exceeded
3 Halted 0 ms 0 KB -