Submission #494021

#TimeUsernameProblemLanguageResultExecution timeMemory
494021aurimsMonthly railway pass (LMIO18_menesinis_bilietas)C++14
0 / 100
555 ms34240 KiB
#include <bits/stdc++.h> #define MAX 500000 #define pb push_back using namespace std; /* input 6 4 1 2 T 2 3 T 2 4 T 5 6 T */ vector<int> adj[MAX]; bool aplankytas[MAX]; int sk = 0; void dfs(int v) { if(aplankytas[v]) return; aplankytas[v] = true; sk++; for( int kaimynas : adj[v] ) dfs(kaimynas); } bool jungus(int n) { for(int i = 1; i <= n; i++) aplankytas[i] = false; sk = 0; dfs(1); if(sk == n) return n; else return 0; } int main() { int N, M; cin >> N >> M; int ans = 0; for(int i = 0; i < M; i++) { int a, b; char t; cin >> a >> b >> t; adj[a].pb(b); if(a != b) adj[b].pb(a); } cout << jungus(N); return 0; }

Compilation message (stderr)

menesinis_bilietas.cpp: In function 'int main()':
menesinis_bilietas.cpp:43:9: warning: unused variable 'ans' [-Wunused-variable]
   43 |     int ans = 0;
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...