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 L, W; cin >> L >> W; int N; cin >> N; int b; cin >> b; vector
> v; bool visited[L + 5][W + 5]; for(int i = 0; i <= L; i++) { for(int j = 0; j <= W; j++) { visited[i][j] = false; } } for(int i = 0; i < b; i++) { int a, c; cin >> a >> c; v.push_back(make_pair(a, c)); visited[a][c] = true; } int di[] = {-1, 1, 0, 0}; int dj[] = {0, 0, -1, 1}; queue
> > q; q.push(v); int barokni = 0; int meseci = 0; while(!q.empty()) { vector
> c = q.front(); q.pop(); barokni += c.size(); if(barokni >= N) { break; } meseci++; vector
> novi_barokni; for(int i = 0; i < c.size(); i++) { for(int j = 0; j < 4; j++) { int ti = c[i].first + di[j]; int tj = c[i].second + dj[j]; if(ti >= 1 and ti <= L and tj >= 1 and tj <= W and !visited[ti][tj]) { visited[ti][tj] = true; novi_barokni.push_back(make_pair(ti, tj)); } } } q.push(novi_barokni); } cout << meseci << 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)