Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
#include
#include
#include
#include
using namespace std; int main() { int n, m; cin >> n >> m; int W; cin >> W; char mat[n][m]; vector
> flower_positions; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { cin >> mat[i][j]; if(mat[i][j] == 'C') { flower_positions.push_back(make_pair(i, j)); } } } int count_flowers[n][m]; bool visited[n][m]; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { count_flowers[i][j] = 0; } } int di[] = {-1, 1, 0, 0}; int dj[] = {0, 0, -1, 1}; int answer = -1; for(int it = 0; it < flower_positions.size(); it++) { queue
q; q.push(flower_positions[it].first); q.push(flower_positions[it].second); q.push(0); // distanec memset(visited, false, sizeof visited); // site vrednosti na visited da bidat false while(!q.empty()) { int ci = q.front(); q.pop(); int cj = q.front(); q.pop(); int dist = q.front(); q.pop(); if(mat[ci][cj] == '.') { count_flowers[ci][cj]++; answer = max(answer, count_flowers[ci][cj]); } for(int k = 0; k < 4; k++) { int ti = ci + di[k]; int tj = cj + dj[k]; if(ti >= 0 and ti < n and tj >= 0 and tj < m and !visited[ti][tj] and dist + 1 <= W and mat[ti][tj] != '#') { visited[ti][tj] = true; q.push(ti); q.push(tj); q.push(dist + 1); } } } } for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { if(count_flowers[i][j] == answer) { cout << i + 1 << " " << j + 1 << endl; return 0; } } } return 0; } /* C.3C 02 30 #321 0332 #21C 0220 .321 0111 */
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)