Submission #334797

#TimeUsernameProblemLanguageResultExecution timeMemory
334797beksultan04Evacuation plan (IZhO18_plan)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define OK puts("OK");
#define fr first
#define sc second
#define ret return
#define scan1(a) scanf("%lld",&a);
#define scan2(a,b) scanf("%lld %lld",&a, &b);
#define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define pb push_back
#define endi puts("");
const int N = 1e5+12,INF=1e9+7;
int dist[N],n,yy,ans,batya[N],;
vector <pii> g[N];
bool is[N];
set <pii> s;
void fun(){
    int i,j,k;
    while (!s.empty()){

        pii x = *s.begin();
        s.erase(s.begin());
        for (i=0;i<g[x.sc].size();++i){
            if (dist[g[x.sc][i].fr] > dist[x.sc]+g[x.sc][i].sc){
                s.erase({dist[g[x.sc][i].fr],g[x.sc][i].fr});
                dist[g[x.sc][i].fr] = dist[x.sc]+g[x.sc][i].sc;
                s.insert({dist[g[x.sc][i].fr],g[x.sc][i].fr});
            }
        }
    }
}

int find_baty(int a){
    if (a == batya[a])ret a;
    ret batya[a] = find_baty(batya[a]);
}

void unite(int a,int b){
    batya[a] = b;
    
    
}




main(){
    int m,i,j;
    scan2(n,m)
    for (i=1;i<=n;++i)dist[i]=INF;
    while (m--){
        int x,y,z;
        scan3(x,y,z)
        g[x].pb({y,z});
        g[y].pb({x,z});
    }
    scan1(m)
    while (m--){
        int x;
        scan1(x)
        dist[x] = 0;
        s.insert({0,x});
    }
    fun();
    for(i = 1; i <= n; i++){
        v.pb({dis[i],i});
    }
    sort(all(v));
    reverse(all(v));
    
    scan1(m)
    for (i=1;i<=m;++i){
        int x,y;
        scan2(x,y)
        s[x].insert(i);
        s[y].insert(i);
        p[i]={x,y};
    }
    
    for (i=0;i<v.size();++i){
        int x = v[i];
        for (j=0;j<g[x].size();++j){
            int to = g[x][j];
            if (is[to]){
                unite(x,find_baty(to));
            }
        }
    }
    
}

Compilation message (stderr)

plan.cpp:16:31: error: expected unqualified-id before ';' token
   16 | int dist[N],n,yy,ans,batya[N],;
      |                               ^
plan.cpp: In function 'void fun()':
plan.cpp:26:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         for (i=0;i<g[x.sc].size();++i){
      |                  ~^~~~~~~~~~~~~~~
plan.cpp:21:11: warning: unused variable 'j' [-Wunused-variable]
   21 |     int i,j,k;
      |           ^
plan.cpp:21:13: warning: unused variable 'k' [-Wunused-variable]
   21 |     int i,j,k;
      |             ^
plan.cpp: At global scope:
plan.cpp:50:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   50 | main(){
      |      ^
plan.cpp: In function 'int main()':
plan.cpp:69:9: error: 'v' was not declared in this scope
   69 |         v.pb({dis[i],i});
      |         ^
plan.cpp:69:15: error: 'dis' was not declared in this scope; did you mean 'is'?
   69 |         v.pb({dis[i],i});
      |               ^~~
      |               is
plan.cpp:71:14: error: 'v' was not declared in this scope
   71 |     sort(all(v));
      |              ^
plan.cpp:12:16: note: in definition of macro 'all'
   12 | #define all(s) s.begin(),s.end()
      |                ^
plan.cpp:78:10: error: no match for 'operator[]' (operand types are 'std::set<std::pair<long long int, long long int> >' and 'long long int')
   78 |         s[x].insert(i);
      |          ^
plan.cpp:79:10: error: no match for 'operator[]' (operand types are 'std::set<std::pair<long long int, long long int> >' and 'long long int')
   79 |         s[y].insert(i);
      |          ^
plan.cpp:80:9: error: 'p' was not declared in this scope
   80 |         p[i]={x,y};
      |         ^
plan.cpp:85:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   85 |         for (j=0;j<g[x].size();++j){
      |                  ~^~~~~~~~~~~~
plan.cpp:86:28: error: cannot convert '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} to 'long long int' in initialization
   86 |             int to = g[x][j];
      |                            ^
plan.cpp:10:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 | #define scan2(a,b) scanf("%lld %lld",&a, &b);
      |                    ~~~~~^~~~~~~~~~~~~~~~~~~~
plan.cpp:52:5: note: in expansion of macro 'scan2'
   52 |     scan2(n,m)
      |     ^~~~~
plan.cpp:11:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   11 | #define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
      |                      ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
plan.cpp:56:9: note: in expansion of macro 'scan3'
   56 |         scan3(x,y,z)
      |         ^~~~~
plan.cpp:9:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 | #define scan1(a) scanf("%lld",&a);
      |                  ~~~~~^~~~~~~~~~~
plan.cpp:60:5: note: in expansion of macro 'scan1'
   60 |     scan1(m)
      |     ^~~~~
plan.cpp:9:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 | #define scan1(a) scanf("%lld",&a);
      |                  ~~~~~^~~~~~~~~~~
plan.cpp:63:9: note: in expansion of macro 'scan1'
   63 |         scan1(x)
      |         ^~~~~
plan.cpp:9:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 | #define scan1(a) scanf("%lld",&a);
      |                  ~~~~~^~~~~~~~~~~
plan.cpp:74:5: note: in expansion of macro 'scan1'
   74 |     scan1(m)
      |     ^~~~~
plan.cpp:10:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 | #define scan2(a,b) scanf("%lld %lld",&a, &b);
      |                    ~~~~~^~~~~~~~~~~~~~~~~~~~
plan.cpp:77:9: note: in expansion of macro 'scan2'
   77 |         scan2(x,y)
      |         ^~~~~