답안 #252147

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
252147 2020-07-24T10:24:20 Z Erkhemkhuu 다리 (APIO19_bridges) C++17
0 / 100
39 ms 48764 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
const ll N = 1005;
bool vis[N];
tuple <ll, ll, ll> brid[N];
vector <vector <ll> > adj(N);
vector <ll> wp[N][N];
ll dfs(ll v, ll w) {
    ll ans = 1;
    vis[v] = true;
    for(auto &u: adj[v]) {
        if(vis[u]) continue;
        for(auto &x: wp[v][u])
            if(w <= x) ans += dfs(u, w);
    }
    return ans;
}
int main() {
    ll n, m, i, v, u, w, q, t, l, r;
    cin >> n >> m;
    for(i = 0; i < m; i++) {
        cin >> v >> u >> w;
        v--; u--;
        adj[v].pb(u);
        adj[u].pb(v);
        wp[v][u].pb(w);
        wp[u][v].pb(w);
        brid[i] = {v, u, wp[v][u].size() - 1};
    }
    cin >> q;
    while(q--) {
        cin >> t >> l >> r;
        l--;
        if(t == 1) {
            auto temp = brid[l];
            ll x = get <0> (temp);
            ll y = get <1> (temp);
            ll z = get <2> (temp);
            wp[x][y][z] = wp[y][x][z] = r;
        }
        else {
            memset(vis, false, sizeof(vis));
            cout << dfs(l, r) << "\n";
        }
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 24064 KB Output is correct
2 Incorrect 13 ms 24064 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 39 ms 48760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 38 ms 48764 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 38 ms 48504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 39 ms 48760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 24064 KB Output is correct
2 Incorrect 13 ms 24064 KB Output isn't correct
3 Halted 0 ms 0 KB -