Submission #250149

# Submission time Handle Problem Language Result Execution time Memory
250149 2020-07-17T04:47:50 Z jeqcho Bridges (APIO19_bridges) C++17
13 / 100
146 ms 48376 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpi;

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

#define pb push_back
#define rsz resize
#define sz(x) int(x.size())
#define all(x) begin(x), end(x)
#define f first
#define s second

int n,m;
int const N=1e3;
vi adj[N];
int const M=1e5;
tuple<int,int,int> bridge[M];
vi matrix[N][N];
bitset<N> vis;

int dfs(int now, int weight)
{
    if(vis[now])return 0;
    int ans=1;
    vis[now]=1;
    trav(chi,adj[now])
    {
        trav(wlimit, matrix[now][chi])
        {
            if(weight>wlimit)continue;
            ans += dfs(chi,weight);
        }
    }
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n>>m;
    int u,v,d;
    F0R(i,m)
    {
        cin>>u>>v>>d;
        --u; --v;
        adj[u].pb(v);
        adj[v].pb(u);
        matrix[u][v].pb(d);
        matrix[v][u].pb(d);
        bridge[i] = {u,v,sz(matrix[u][v])-1};
    }
    int q;
    cin>>q;
    int typ, bj, rj, sj, wj;
    int id;
    while(q--)
    {
        cin>>typ;
        if(typ==1)
        {
            cin>>bj>>rj;
            --bj;
            tie(u,v,id) = bridge[bj];
            matrix[u][v][id] = rj;
            matrix[v][u][id] = rj;
        }
        else
        {
            cin>>sj>>wj;
            vis.reset();
            --sj;
            cout<<dfs(sj,wj)<<'\n';
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 13 ms 23808 KB Output is correct
2 Correct 14 ms 23808 KB Output is correct
3 Correct 146 ms 24312 KB Output is correct
4 Correct 18 ms 24056 KB Output is correct
5 Correct 24 ms 24064 KB Output is correct
6 Correct 23 ms 24064 KB Output is correct
7 Correct 21 ms 23936 KB Output is correct
8 Correct 21 ms 24064 KB Output is correct
9 Correct 28 ms 23936 KB Output is correct
10 Correct 19 ms 24064 KB Output is correct
11 Correct 18 ms 24064 KB Output is correct
12 Correct 20 ms 24064 KB Output is correct
13 Correct 22 ms 24064 KB Output is correct
14 Correct 21 ms 24056 KB Output is correct
15 Correct 24 ms 24064 KB Output is correct
16 Correct 21 ms 23936 KB Output is correct
17 Correct 20 ms 23936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 44 ms 48376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 45 ms 48376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 37 ms 48120 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 44 ms 48376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 23808 KB Output is correct
2 Correct 14 ms 23808 KB Output is correct
3 Correct 146 ms 24312 KB Output is correct
4 Correct 18 ms 24056 KB Output is correct
5 Correct 24 ms 24064 KB Output is correct
6 Correct 23 ms 24064 KB Output is correct
7 Correct 21 ms 23936 KB Output is correct
8 Correct 21 ms 24064 KB Output is correct
9 Correct 28 ms 23936 KB Output is correct
10 Correct 19 ms 24064 KB Output is correct
11 Correct 18 ms 24064 KB Output is correct
12 Correct 20 ms 24064 KB Output is correct
13 Correct 22 ms 24064 KB Output is correct
14 Correct 21 ms 24056 KB Output is correct
15 Correct 24 ms 24064 KB Output is correct
16 Correct 21 ms 23936 KB Output is correct
17 Correct 20 ms 23936 KB Output is correct
18 Runtime error 44 ms 48376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Halted 0 ms 0 KB -