Submission #240127

# Submission time Handle Problem Language Result Execution time Memory
240127 2020-06-18T06:49:27 Z wiwiho Bridges (APIO19_bridges) C++14
13 / 100
3000 ms 8824 KB
//#define NDEBUG

#include <bits/stdc++.h>
#include <bits/extc++.h>

#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define mt make_tuple
#define gt(t, i) get<i>(t)
#define iceil(a, b) ((a + b - 1) / b)
#define tomax(a, b) (a = max(a, b))
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}

//#define TEST

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;
using tiii = tuple<int, int, int>;

const ll MOD = 1000000007;
const ll MAX = 2147483647;

template<typename A, typename B>
ostream& operator<<(ostream& o, pair<A, B> p){
    return o << '(' << p.F << ',' << p.S << ')';
}

vector<int> w;
vector<vector<pii>> g;

vector<bool> vst;
void dfs(int now, int wl){
    vst[now] = true;
    for(pii i : g[now]){
        if(w[i.S] < wl || vst[i.F]) continue;
        dfs(i.F, wl);
    }
}

int main(){
    StarBurstStream

    int n, m;
    cin >> n >> m;
    g.resize(n + 1);
    w.resize(m + 1);
    for(int i = 1; i <= m; i++){
        int u, v;
        cin >> u >> v;
        cin >> w[i];
        g[u].eb(mp(v, i));
        g[v].eb(mp(u, i));
    }

    int q;
    cin >> q;
    while(q--){

        int t;
        cin >> t;

        if(t == 1){
            int b, r;
            cin >> b >> r;
            w[b] = r;
        }
        else{
            int s, wl;
            cin >> s >> wl;
            vst.clear();
            vst.resize(n + 1);
            dfs(s, wl);
            int ans = 0;
            for(bool i : vst) ans += i;
            cout << ans << "\n";
        }

    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 66 ms 632 KB Output is correct
4 Correct 8 ms 512 KB Output is correct
5 Correct 12 ms 512 KB Output is correct
6 Correct 11 ms 512 KB Output is correct
7 Correct 12 ms 512 KB Output is correct
8 Correct 12 ms 512 KB Output is correct
9 Correct 13 ms 384 KB Output is correct
10 Correct 11 ms 512 KB Output is correct
11 Correct 11 ms 512 KB Output is correct
12 Correct 11 ms 512 KB Output is correct
13 Correct 15 ms 512 KB Output is correct
14 Correct 13 ms 512 KB Output is correct
15 Correct 15 ms 512 KB Output is correct
16 Correct 13 ms 384 KB Output is correct
17 Correct 12 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2905 ms 8128 KB Output is correct
2 Correct 2894 ms 8824 KB Output is correct
3 Correct 2897 ms 8696 KB Output is correct
4 Execution timed out 3050 ms 8764 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2808 ms 5308 KB Output is correct
2 Execution timed out 3017 ms 2680 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3094 ms 8696 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2905 ms 8128 KB Output is correct
2 Correct 2894 ms 8824 KB Output is correct
3 Correct 2897 ms 8696 KB Output is correct
4 Execution timed out 3050 ms 8764 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 66 ms 632 KB Output is correct
4 Correct 8 ms 512 KB Output is correct
5 Correct 12 ms 512 KB Output is correct
6 Correct 11 ms 512 KB Output is correct
7 Correct 12 ms 512 KB Output is correct
8 Correct 12 ms 512 KB Output is correct
9 Correct 13 ms 384 KB Output is correct
10 Correct 11 ms 512 KB Output is correct
11 Correct 11 ms 512 KB Output is correct
12 Correct 11 ms 512 KB Output is correct
13 Correct 15 ms 512 KB Output is correct
14 Correct 13 ms 512 KB Output is correct
15 Correct 15 ms 512 KB Output is correct
16 Correct 13 ms 384 KB Output is correct
17 Correct 12 ms 384 KB Output is correct
18 Correct 2905 ms 8128 KB Output is correct
19 Correct 2894 ms 8824 KB Output is correct
20 Correct 2897 ms 8696 KB Output is correct
21 Execution timed out 3050 ms 8764 KB Time limit exceeded
22 Halted 0 ms 0 KB -