Submission #920868

# Submission time Handle Problem Language Result Execution time Memory
920868 2024-02-03T06:47:03 Z gelastropod Monthly railway pass (LMIO18_menesinis_bilietas) C++14
6 / 100
825 ms 48176 KB
#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 (is1)
    {
        cout << ((int)bfs.size() == N ? N : 0) << '\n';
        return 0;
    }
    else if (is2)
    {
        for (int i = 0; i < N; i++)
        {
            if ((int)adjlist[i].size() >= N - 1)
                ans++;
        }
        cout << ans << '\n';
        return 0;
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 825 ms 36304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 11356 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 6 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 273 ms 10508 KB Output is correct
7 Correct 599 ms 48176 KB Output is correct
8 Correct 12 ms 2136 KB Output is correct
9 Correct 25 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 6 ms 604 KB Output is correct
4 Incorrect 0 ms 344 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -