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
using namespace std; int n, m; int w; char mat[1005][1005]; int cnt[1005][1005]; int main() { cin >> n >> m; cin >> w; vector
> v; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { cin >> mat[i][j]; cnt[i][j] = 0; if(mat[i][j] == 'C') { v.push_back(make_pair(i, j)); } } } int di[] = {-1, 1, 0, 0}; int dj[] = {0, 0, -1, 1}; for(int i = 0; i < v.size(); i++) { int si = v[i].first, sj = v[i].second; queue
q; q.push(si); q.push(sj); q.push(0); vector
> visited(n, vector
(m, 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] == '.') { cnt[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 mat[ti][tj] != '#' and dist + 1 <= w) { q.push(ti); q.push(tj); q.push(dist + 1); visited[ti][tj] = true; } } } } int res = 0, ri, rj; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { if(res < cnt[i][j] and mat[i][j] == '.') { res = cnt[i][j]; ri = i; rj = j; } } } cout << ri + 1 << " " << rj + 1 << endl; return 0; }
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)