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
#include
#include
#include
using namespace std; typedef long long ll; const int maxn = 3005; vector
graph[maxn]; bool visited[maxn][maxn]; int main() { ios_base::sync_with_stdio(false); int n, m; cin >> n >> m; for(int i = 0; i < m; i++) { int a, b; cin >> a >> b; graph[a].push_back(b); graph[b].push_back(a); } int k; cin >> k; map
, bool> triplets; for(int i = 0; i < k; i++) { int a, b, c; cin >> a >> b >> c; triplets[{a, b, c}] = true; } queue
q; q.push(0); q.push(-1); q.push(0); while(!q.empty()) { int current_node = q.front(); q.pop(); int prev_node = q.front(); q.pop(); int cekor = q.front(); q.pop(); if(current_node == n - 1) { cout << cekor << endl; return 0; } for(int i = 0; i < (int) graph[current_node].size(); i++) { int neighbour = graph[current_node][i]; if(!triplets[{prev_node, current_node, neighbour}] and !visited[current_node][neighbour]) { visited[current_node][neighbour] = true; q.push(neighbour); q.push(current_node); q.push(cekor + 1); } } } cout << "GRESHKA" << 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)