Submission #920865

#TimeUsernameProblemLanguageResultExecution timeMemory
920865gelastropodMonthly railway pass (LMIO18_menesinis_bilietas)C++14
0 / 100
794 ms36312 KiB
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { int N, M, a, b, ans = 0; cin >> N >> M; char t; bool is1 = true, is2 = true; vector<vector<int>> adjlist(N, vector<int>()); for (int i = 0; i < M; i++) { cin >> a >> b >> t; a--, b--; adjlist[a].push_back(b); adjlist[b].push_back(a); if (t == 'A') is1 = false; if (t == 'T') is2 = false; } queue<int> bfs; set<int> visited; bfs.push(1); visited.insert(1); while (!bfs.empty()) { int i = bfs.front(); bfs.pop(); for (int j : adjlist[i]) if (visited.lower_bound(j) == visited.end() || *visited.lower_bound(j) != j) visited.insert(j), bfs.push(j); } if (is2) { cout << (bfs.size() == N ? N : 0) << '\n'; return 0; } else if (is1) { for (int i = 0; i < N; i++) { if ((int)adjlist[i].size() >= N - 1) ans++; } cout << ans << '\n'; return 0; } }

Compilation message (stderr)

menesinis_bilietas.cpp: In function 'int main()':
menesinis_bilietas.cpp:35:29: warning: comparison of integer expressions of different signedness: 'std::queue<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   35 |         cout << (bfs.size() == N ? N : 0) << '\n';
      |                  ~~~~~~~~~~~^~~~
#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...