# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
381349 |
2021-03-25T06:48:43 Z |
Slavita |
Paint (COI20_paint) |
C++14 |
|
3000 ms |
71828 KB |
#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;
map<pi, int> a;
map<pi, int> re;
map<pi, bool> mrk;
queue<int> X, Y;
void create(int i, int j, int &kol){
kol++;
a[mp(i, j)] = kol;
b[kol] = re[mp(i, j)];
}
void update(int i0, int j0, int i, int j){
a[mp(i, j)] = a[mp(i0, j0)];
}
void check(int i, int j, int i2, int j2){
if (j2 >= 1 && j2 <= m && i2 >= 1 && i2 <= n && b[a[mp(i2, j2)]] == re[mp(i, j)])
update(i2, j2, i, j);
}
void first(int x, int y, int &kol){
X.push(x); Y.push(y);
create(x, y, kol);
}
void put(int x, int y, int kol){
if (x < 1 || x > n || y < 1 || y > m) return;
if (mrk[mp(x, y)]) return;
if (re[mp(x, y)] != curCol) return;
a[mp(x, y)] = kol;
X.push(x); Y.push(y);
mrk[mp(x, y)] = 1;
}
void go(int x, int y, int kol){
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], kol);
}
}
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;
}
}
//first(1, 1, kol);
for (int i = 1; i <= n; i++){
for (int j = 1; j <= m; j++){
if (mrk[mp(i, j)]) continue;
first(i, j, kol);
curCol = b[a[mp(i, j)]];
while(!X.empty()){
int x = X.front(); X.pop();
int y = Y.front(); Y.pop();
go(x, y, kol);
}
}
}
/*for (int i = 1; i <= kol; i++){
cout << b[i] << en;
}*/
int q;
cin >> q;
while(q--){
int x, y, col;
cin >> x >> y >> col;
b[a[mp(x, y)]] = col;
cout << en << en;
for (int i = 1; i <= n; i++){
for (int j = 1; j <= m; j++){
cout << b[a[mp(i, j)]] << ' ';
}
cout << en;
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
620 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3068 ms |
41236 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3038 ms |
71828 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3080 ms |
63468 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |