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
using namespace std; int main() { int a,b; cin>>a>>b; int mat[a][b]; bool poseten[a][b]; queue
Q; for(int i=0;i
>mat[i][j]; poseten[i][j]=false; } } int kolku=0; int di[] = {-1, 1, 0, 0}; int dj[] = {0, 0, -1, 1}; for(int k=0;k<=a*b;k++) { int najmal=40; int r=0,c=0; for(int i=0;i
mat[i][j] && poseten[i][j]!=true) { najmal=mat[i][j]; r=i; c=j; } } } if(najmal!=40) { poseten[r][c]=true; Q.push(r); Q.push(c); kolku++; while(!Q.empty()) { int ci=Q.front(); Q.pop(); int cj=Q.front(); Q.pop(); for(int o = 0; o < 4; o++) { int ti = ci + di[o]; int tj = cj + dj[o]; if(ti >= 0 and ti < a and tj >= 0 and tj < b and !poseten[ti][tj] and mat[ti][tj] >= mat[ci][cj]) { poseten[ti][tj] = true; Q.push(ti); Q.push(tj); } } } } } cout<
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)