제출 #381360

#제출 시각아이디문제언어결과실행 시간메모리
381360NONAMEPaint (COI20_paint)C++17
0 / 100
16 ms2540 KiB
#include <bits/stdc++.h> using namespace std; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); template <typename T> inline bool chmin(T& a, const T b) {a = min(a, b); return (a == b);} template <typename T> inline bool chmax(T& a, const T b) {a = max(a, b); return (a == b);} const int steps[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}; const int man = (int)(2e5 + 500); int n, m; int a[man]; bool was[man]; int to(int x, int y) { return (x * m) + y; } int btool(int x, int y, int c) { for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { was[to(i, j)] = false; } } queue <array <int, 2> > q; q.push({x, y}); was[to(x, y)] = true; while (!q.empty()) { auto cur = q.front(); q.pop(); for (int i = 0; i < 4; ++i) { int cx = cur[0] + steps[i][0]; int cy = cur[1] + steps[i][1]; if ((cx >= 0) && (cx < n) && (cy >= 0) && (cy < m) && !was[to(cx, cy)] && (a[to(cx, cy)] == a[to(x, y)])) { was[to(cx, cy)] = true; q.push({cx, cy}); } } } for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { a[to(i, j)] = (was[to(i, j)] ? c : a[to(i, j)]); } } } void solve() { cin >> n >> m; for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { cin >> a[to(i, j)]; } } int q; cin >> q; while (q--) { int x, y, c; cin >> x >> y >> c; --x, --y; btool(x, y, c); } for (int i = 0; i < n; ++i, cout << "\n") { for (int j = 0; j < m; ++j) { cout << a[to(i, j)] << " "; } } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifdef _LOCAL system("color a"); freopen("in.txt", "r", stdin); #endif solve(); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

paint.cpp: In function 'int btool(int, int, int)':
paint.cpp:48:1: warning: no return statement in function returning non-void [-Wreturn-type]
   48 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...