Submission #168524

#TimeUsernameProblemLanguageResultExecution timeMemory
168524achibasadzishviliEvacuation plan (IZhO18_plan)C++14
Compilation error
0 ms0 KiB
nclude <bits/stdc++.h> #define ll int #define f first #define s second #define pb push_back #define mp make_pair using namespace std; ll k,n,m,qq,d[100005],p[100005],c[100005],ans[100005],las,fix[100005]; ll qu[100005],sz[100005]; vector<ll>vec[100005]; vector<pair<ll,ll> >v[100005],q[100005]; set<pair<ll,ll> >st; ll find(ll x){ if(p[x] == x)return x; return p[x] = find(p[x]); } void join(ll x,ll y){ x = find(x); y = find(y); if(x == y)return; if(sz[x] < sz[y])swap(x , y); qu[x] += qu[y]; sz[x] += sz[y]; for(int i=0; i<q[y].size(); i++){ if(find(q[y][i].f) == x) ans[q[y][i].s] = min(ans[q[y][i].s] , las); q[x].pb(q[y][i]); } for(int i=0; i<vec[y].size(); i++){ vec[x].pb(vec[y][i]); } p[y] = x; } int main(){ ios::sync_with_stdio(false); cin >> n >> m; for(int i=1; i<=m; i++){ int x,y,z; cin >> x >> y >> z; v[x].pb(mp(y , z)); v[y].pb(mp(x , z)); } cin >> k; for(int i=1; i<=n; i++){ d[i] = 1000000000; } for(int i=1; i<=k; i++){ cin >> c[i]; st.insert(mp(0LL , c[i])); d[c[i]] = 0; } while(st.size()){ ll x = (*st.begin()).s; st.erase(st.begin()); for(int i=0; i<v[x].size(); i++){ ll to = v[x][i].f; if(d[to] > d[x] + v[x][i].s){ if(st.find(mp(d[to] , to)) != st.end())st.erase(st.find(mp(d[to] , to))); d[to] = d[x] + v[x][i].s; st.insert(mp(d[to] , to)); } } } cin >> qq; for(int i=1; i<=qq; i++){ ans[i] = 1000000000; int x,y; cin >> x >> y; q[x].pb(mp(y , i)); q[y].pb(mp(x , i)); } vector<pair<ll,ll> >g; for(int i=1; i<=n; i++){ g.pb(mp(d[i] , i)); } sort(g.begin() , g.end()); reverse(g.begin() , g.end()); for(int i=1; i<=n; i++){ p[i] = i; qu[i] = (int)q[i].size(); vec[i].pb(i); sz[i] = 1; } for(int i=0; i<g.size(); i++){ las = g[i].f; fix[g[i].s] = 1; for(int j=0; j<v[g[i].s].size(); j++){ ll to = v[g[i].s][j].f; if(fix[to] == 1){ join(g[i].s , to); } } } for(int i=1; i<=qq; i++) cout << ans[i] << '\n'; return 0; } /* 9 12 1 9 4 1 2 5 2 3 7 2 4 3 4 3 6 3 6 4 8 7 10 6 7 5 5 8 1 9 5 7 5 4 12 6 8 2 2 4 7 5 1 6 5 3 4 8 5 8 1 5 */

Compilation message (stderr)

plan.cpp:1:1: error: 'nclude' does not name a type
 nclude <bits/stdc++.h>
 ^~~~~~
plan.cpp:10:1: error: 'vector' does not name a type
 vector<ll>vec[100005];
 ^~~~~~
plan.cpp:11:1: error: 'vector' does not name a type
 vector<pair<ll,ll> >v[100005],q[100005];
 ^~~~~~
plan.cpp:12:1: error: 'set' does not name a type
 set<pair<ll,ll> >st;
 ^~~
plan.cpp: In function 'void join(int, int)':
plan.cpp:21:22: error: 'swap' was not declared in this scope
     if(sz[x] < sz[y])swap(x , y);
                      ^~~~
plan.cpp:24:20: error: 'q' was not declared in this scope
     for(int i=0; i<q[y].size(); i++){
                    ^
plan.cpp:26:30: error: 'min' was not declared in this scope
             ans[q[y][i].s] = min(ans[q[y][i].s] , las);
                              ^~~
plan.cpp:26:30: note: suggested alternative: 'join'
             ans[q[y][i].s] = min(ans[q[y][i].s] , las);
                              ^~~
                              join
plan.cpp:29:20: error: 'vec' was not declared in this scope
     for(int i=0; i<vec[y].size(); i++){
                    ^~~
plan.cpp: In function 'int main()':
plan.cpp:35:5: error: 'ios' has not been declared
     ios::sync_with_stdio(false);
     ^~~
plan.cpp:36:5: error: 'cin' was not declared in this scope
     cin >> n >> m;
     ^~~
plan.cpp:36:5: note: suggested alternative: 'main'
     cin >> n >> m;
     ^~~
     main
plan.cpp:41:9: error: 'v' was not declared in this scope
         v[x].pb(mp(y , z));
         ^
plan.cpp:6:12: error: 'make_pair' was not declared in this scope
 #define mp make_pair
            ^
plan.cpp:41:17: note: in expansion of macro 'mp'
         v[x].pb(mp(y , z));
                 ^~
plan.cpp:53:9: error: 'st' was not declared in this scope
         st.insert(mp(0LL , c[i]));
         ^~
plan.cpp:53:9: note: suggested alternative: 'sz'
         st.insert(mp(0LL , c[i]));
         ^~
         sz
plan.cpp:6:12: error: 'make_pair' was not declared in this scope
 #define mp make_pair
            ^
plan.cpp:53:19: note: in expansion of macro 'mp'
         st.insert(mp(0LL , c[i]));
                   ^~
plan.cpp:57:11: error: 'st' was not declared in this scope
     while(st.size()){
           ^~
plan.cpp:57:11: note: suggested alternative: 'sz'
     while(st.size()){
           ^~
           sz
plan.cpp:60:24: error: 'v' was not declared in this scope
         for(int i=0; i<v[x].size(); i++){
                        ^
plan.cpp:6:12: error: 'make_pair' was not declared in this scope
 #define mp make_pair
            ^
plan.cpp:63:28: note: in expansion of macro 'mp'
                 if(st.find(mp(d[to] , to)) != st.end())st.erase(st.find(mp(d[to] , to)));
                            ^~
plan.cpp:6:12: error: 'make_pair' was not declared in this scope
 #define mp make_pair
            ^
plan.cpp:65:27: note: in expansion of macro 'mp'
                 st.insert(mp(d[to] , to));
                           ^~
plan.cpp:76:9: error: 'q' was not declared in this scope
         q[x].pb(mp(y , i));
         ^
plan.cpp:6:12: error: 'make_pair' was not declared in this scope
 #define mp make_pair
            ^
plan.cpp:76:17: note: in expansion of macro 'mp'
         q[x].pb(mp(y , i));
                 ^~
plan.cpp:80:5: error: 'vector' was not declared in this scope
     vector<pair<ll,ll> >g;
     ^~~~~~
plan.cpp:80:12: error: 'pair' was not declared in this scope
     vector<pair<ll,ll> >g;
            ^~~~
plan.cpp:80:12: note: suggested alternative: 'main'
     vector<pair<ll,ll> >g;
            ^~~~
            main
plan.cpp:2:12: error: expected primary-expression before 'int'
 #define ll int
            ^
plan.cpp:80:17: note: in expansion of macro 'll'
     vector<pair<ll,ll> >g;
                 ^~
plan.cpp:83:9: error: 'g' was not declared in this scope
         g.pb(mp(d[i] , i));
         ^
plan.cpp:6:12: error: 'make_pair' was not declared in this scope
 #define mp make_pair
            ^
plan.cpp:83:14: note: in expansion of macro 'mp'
         g.pb(mp(d[i] , i));
              ^~
plan.cpp:87:10: error: 'g' was not declared in this scope
     sort(g.begin() , g.end());
          ^
plan.cpp:87:5: error: 'sort' was not declared in this scope
     sort(g.begin() , g.end());
     ^~~~
plan.cpp:87:5: note: suggested alternative: 'short'
     sort(g.begin() , g.end());
     ^~~~
     short
plan.cpp:88:5: error: 'reverse' was not declared in this scope
     reverse(g.begin() , g.end());
     ^~~~~~~
plan.cpp:92:22: error: 'q' was not declared in this scope
         qu[i] = (int)q[i].size();
                      ^
plan.cpp:93:9: error: 'vec' was not declared in this scope
         vec[i].pb(i);
         ^~~
plan.cpp:100:24: error: 'v' was not declared in this scope
         for(int j=0; j<v[g[i].s].size(); j++){
                        ^
plan.cpp:110:9: error: 'cout' was not declared in this scope
         cout << ans[i] << '\n';
         ^~~~