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; struct node{ int idx; node(){ } node(int _idx){ idx=_idx; } bool operator <(const node &tmp) const{ return idx > tmp.idx; } }; int main() { int n; int m; cin>>n>>m; vector
graph[n+5]; for(int i=0; i
>a>>b; graph[a].push_back(b); graph[b].push_back(a); } int s=1; bool niza[n+5]; for(int i=0; i<=n; i++){ niza[i]=false; } niza[s]=true; priority_queue
pq; pq.push(node(s)); while(!pq.empty()){ node c=pq.top(); cout << c.idx << " "; pq.pop(); niza[c.idx]=true; for(int i=0; i < graph[c.idx].size(); i++){ int sosed=graph[c.idx][i]; if(niza[sosed]==false){ pq.push(node(sosed)); niza[sosed]=true; } } } 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)