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 main() { int n, m; cin >> n >> m; char mat[n][m]; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { cin >> mat[i][j]; } } int di[] = {-1, 1, 0, 0}; int dj[] = {0, 0, -1, 1}; int res_ovci = 0, res_volci = 0; vector
> visited(n, vector
(m, false)); for(int i = 0 ; i < n; i++) { for(int j = 0; j < m; j++) { if(mat[i][j] != '#' and !visited[i][j]) { queue
q; q.push(i); q.push(j); int ovci = 0, volci = 0; visited[i][j] = true; while(!q.empty()) { int ci = q.front(); q.pop(); int cj = q.front(); q.pop(); if(mat[ci][cj] == 'o') { ovci++; } if(mat[ci][cj] == 'v') { volci++; } 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] != '#') { q.push(ti); q.push(tj); visited[ti][tj] = true; } } } if(ovci > volci) { res_ovci += ovci; } else { res_volci += volci; } } } } cout << res_ovci << " " << res_volci << 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)