Submission #805667

# Submission time Handle Problem Language Result Execution time Memory
805667 2023-08-03T19:48:24 Z HD1 Monthly railway pass (LMIO18_menesinis_bilietas) C++14
30 / 100
3000 ms 54792 KB
// we all are lost trying to be someone.
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_studio(0); cin.tie(0);
#define sz(x) int(x.size())
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pb push_back
#define ss second
#define ff first
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
const int MAX=1e6;
const int inf=1e9;
const int mod=1e9+7;
vector<ii>gfo[MAX];
ll dist[MAX];
void dikstra(ll ini){
    set<ii> q;
    q.insert({0,ini});
    dist[ini]=0;
    while(sz(q)){
        ii x=*q.begin();
        q.erase(q.begin());
        ll u=x.ss;
        ll dist_u=x.ff;
        if(dist[u]!=dist_u) continue;
        for(auto y:gfo[u]){
            ll v=y.ff;
            ll w=y.ss;
            if(dist[v]>dist[u]+w){
                dist[v]=dist[u]+w;
                q.insert({dist[v],v});
            }
        }
    }
}
void coso(ll n){
    for(int i=0; i<=n; i++){
        dist[i]=inf;
    }
    return;
}
void solve(){
    ll n, m, u, v;
    char x;
    cin>>n>>m;
    for(ll i=0; i<m; i++){
        cin>>u>>v>>x;
        if(x=='A'){
            gfo[u].pb({v,1});
            gfo[v].pb({u,1});
        }
        else{
            gfo[u].pb({v,0});
            gfo[v].pb({u,0});
        }
    }
    ll ans=0;
    for(ll i=1; i<=n; i++){
        coso(n);
        dikstra(i);
        ll cont=0;
        for(ll j=1; j<=n; j++){
            if(dist[j]<=1)cont++;
        }
        if(cont==n)ans++;
    }
    cout<<ans<<endl;
    return;
}
int main(){
    solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 3084 ms 54792 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3074 ms 27348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23804 KB Output is correct
2 Correct 12 ms 23776 KB Output is correct
3 Correct 15 ms 23928 KB Output is correct
4 Correct 32 ms 24020 KB Output is correct
5 Correct 56 ms 24324 KB Output is correct
6 Correct 32 ms 24064 KB Output is correct
7 Correct 15 ms 23764 KB Output is correct
8 Correct 14 ms 23796 KB Output is correct
9 Correct 123 ms 24512 KB Output is correct
10 Correct 12 ms 23764 KB Output is correct
11 Correct 16 ms 23892 KB Output is correct
12 Correct 12 ms 23764 KB Output is correct
13 Correct 14 ms 23892 KB Output is correct
14 Correct 17 ms 23820 KB Output is correct
15 Correct 149 ms 23988 KB Output is correct
16 Correct 12 ms 23764 KB Output is correct
17 Correct 13 ms 23764 KB Output is correct
18 Correct 12 ms 23800 KB Output is correct
19 Correct 13 ms 23764 KB Output is correct
20 Correct 157 ms 24256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23804 KB Output is correct
2 Correct 12 ms 23776 KB Output is correct
3 Correct 15 ms 23928 KB Output is correct
4 Correct 32 ms 24020 KB Output is correct
5 Correct 56 ms 24324 KB Output is correct
6 Correct 32 ms 24064 KB Output is correct
7 Correct 15 ms 23764 KB Output is correct
8 Correct 14 ms 23796 KB Output is correct
9 Correct 123 ms 24512 KB Output is correct
10 Correct 12 ms 23764 KB Output is correct
11 Correct 16 ms 23892 KB Output is correct
12 Correct 12 ms 23764 KB Output is correct
13 Correct 14 ms 23892 KB Output is correct
14 Correct 17 ms 23820 KB Output is correct
15 Correct 149 ms 23988 KB Output is correct
16 Correct 12 ms 23764 KB Output is correct
17 Correct 13 ms 23764 KB Output is correct
18 Correct 12 ms 23800 KB Output is correct
19 Correct 13 ms 23764 KB Output is correct
20 Correct 157 ms 24256 KB Output is correct
21 Correct 167 ms 25852 KB Output is correct
22 Execution timed out 3082 ms 47532 KB Time limit exceeded
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23804 KB Output is correct
2 Correct 12 ms 23776 KB Output is correct
3 Correct 15 ms 23928 KB Output is correct
4 Correct 32 ms 24020 KB Output is correct
5 Correct 56 ms 24324 KB Output is correct
6 Correct 32 ms 24064 KB Output is correct
7 Correct 15 ms 23764 KB Output is correct
8 Correct 14 ms 23796 KB Output is correct
9 Correct 123 ms 24512 KB Output is correct
10 Correct 12 ms 23764 KB Output is correct
11 Correct 16 ms 23892 KB Output is correct
12 Correct 12 ms 23764 KB Output is correct
13 Correct 14 ms 23892 KB Output is correct
14 Correct 17 ms 23820 KB Output is correct
15 Correct 149 ms 23988 KB Output is correct
16 Correct 167 ms 25852 KB Output is correct
17 Execution timed out 3082 ms 47532 KB Time limit exceeded
18 Halted 0 ms 0 KB -