Submission #973854

# Submission time Handle Problem Language Result Execution time Memory
973854 2024-05-02T11:55:28 Z AtabayRajabli Monthly railway pass (LMIO18_menesinis_bilietas) C++17
10 / 100
219 ms 39036 KB
#include <bits/stdc++.h>
#define int ll
#define all(v) v.begin(), v.end()
 
// author : a1abay
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
const int sz = 5e5 + 5;
const int inf = 1e9 + 7;
 
int n, m, u, v;
int used[sz];
char c;
vector<int> g[sz];

void dfs(int v)
{
    used[v] = 1;
    for(int i : g[v])
    {
        if(used[i]) continue;
        dfs(i);
    }
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    cin >> n >> m;
    for(int i = 1; i <= m; i++)
    {
        cin >> u >> v >> c;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    dfs(1);

    bool ok = 1;
    for(int i = 1; i <= n; i++) ok &= used[i];

    cout << (ok ? n : 0) << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 219 ms 39036 KB Output is correct
2 Correct 3 ms 12892 KB Output is correct
3 Correct 3 ms 12892 KB Output is correct
4 Correct 3 ms 12892 KB Output is correct
5 Correct 3 ms 12892 KB Output is correct
6 Correct 46 ms 20020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 12892 KB Output is correct
2 Correct 3 ms 12892 KB Output is correct
3 Incorrect 3 ms 12888 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 12892 KB Output is correct
2 Correct 3 ms 12892 KB Output is correct
3 Incorrect 3 ms 12888 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 12892 KB Output is correct
2 Correct 3 ms 12892 KB Output is correct
3 Incorrect 3 ms 12888 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 219 ms 39036 KB Output is correct
2 Correct 3 ms 12892 KB Output is correct
3 Correct 3 ms 12892 KB Output is correct
4 Correct 3 ms 12892 KB Output is correct
5 Incorrect 3 ms 12888 KB Output isn't correct
6 Halted 0 ms 0 KB -