Submission #510605

#TimeUsernameProblemLanguageResultExecution timeMemory
510605amukkalir다리 (APIO19_bridges)C++17
Compilation error
0 ms0 KiB
f#include <bits/stdc++.h>
using namespace std; 
typedef long long ll; 
#define pii pair<int,int> 
#define fi first 
#define se second 
#define pb push_back 
#define mp make_pair

const int INF = 1e9+1000; 
const int nax = 1000; 
int n, m; 
int p[nax+5]; 
vector<pair<int,pii>> b; 

int par(int a) {
    return p[a] == a ? a : p[a] = par(p[a]); 
}

void  join(int a, int b) {
    p[par(a)] = par(b); 
}

signed main () {
    scanf("%d %d", &n, &m); 

    b.pb(mp(0,mp(0,0))); 
    for(int i=1; i<=m; i++) {
        int u, v, d; 
        scanf("%d %d %d", &u,&v,&d); 
        b.pb(mp(d,mp(u,v))); 
    }

    int q; scanf("%d", &q); 
    while(q--) {
        int tp; scanf("%d", &tp); 
        int x, w; scanf("%d%d", &x, &w); 

        if(tp==1) {
            b[x].fi = w; 
        } else {    
            for(int i=1; i<=n; i++) p[i] = i; 
            for(auto br : b) {
                int d = br.fi; 
                if(d < w) continue; 
                int u = br.se.fi; int v = br.se.se; 
                join(u, v); 
            }
            int c = 0; 
            for(int i=1; i<=n; i++) {
                if(par(i) == par(x)) c++; 
            }
            printf("%d\n", c); 
        }
    }
}

Compilation message (stderr)

bridges.cpp:1:2: error: stray '#' in program
    1 | f#include <bits/stdc++.h>
      |  ^
bridges.cpp:1:1: error: 'f' does not name a type; did you mean 'fi'?
    1 | f#include <bits/stdc++.h>
      | ^
      | fi
bridges.cpp:14:1: error: 'vector' does not name a type
   14 | vector<pair<int,pii>> b;
      | ^~~~~~
bridges.cpp: In function 'int main()':
bridges.cpp:25:5: error: 'scanf' was not declared in this scope
   25 |     scanf("%d %d", &n, &m);
      |     ^~~~~
bridges.cpp:27:5: error: 'b' was not declared in this scope
   27 |     b.pb(mp(0,mp(0,0)));
      |     ^
bridges.cpp:8:12: error: 'make_pair' was not declared in this scope
    8 | #define mp make_pair
      |            ^~~~~~~~~
bridges.cpp:27:15: note: in expansion of macro 'mp'
   27 |     b.pb(mp(0,mp(0,0)));
      |               ^~
bridges.cpp:8:12: error: 'make_pair' was not declared in this scope
    8 | #define mp make_pair
      |            ^~~~~~~~~
bridges.cpp:27:10: note: in expansion of macro 'mp'
   27 |     b.pb(mp(0,mp(0,0)));
      |          ^~
bridges.cpp:53:13: error: 'printf' was not declared in this scope
   53 |             printf("%d\n", c);
      |             ^~~~~~
bridges.cpp:1:1: note: 'printf' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'?
  +++ |+#include <cstdio>
    1 | f#include <bits/stdc++.h>