Submission #50480

#TimeUsernameProblemLanguageResultExecution timeMemory
50480ayhcbagnopWiring (IOI17_wiring)C++14
Compilation error
0 ms0 KiB
#ifdef atom #include "grader.cpp" #endif #include "wiring.h" #include <bits/stdc++.h> #define X first #define Y second #define pb push_back #define mp make_pair typedef long long ll; typedef pair<int, int> ii; vector<int> x; vector<int> pong; vector<int> prv; vector< vector< ll > > pref; vector< vector< ll > > dp; vector< vector<int> > buck; long long min_total_length(std::vector<int> r, std::vector<int> b) { int ir, ib; ir = ib = 0; while(ir< r.size() && ib< b.size()) { if(r[ir]< b[ib]) { x.pb(r[ir]); pong.pb(0); ir++; } else { x.pb(b[ib]); pong.pb(1); ib++; } } while(ir< r.size()) x.pb(r[ir++]), pong.pb(0); while(ib< b.size()) x.pb(b[ib++]), pong.pb(1); ll last = -1e18; int n = pong.size(); for(int i = 0; i< n; i++) { if(i && pong[i] != pong[i-1]) last = x[i-1]; prv.pb(last); } pref.pb(vector<ll>()); buck.pb(vector<int>()); for(int i = 0; i< n; i++) { if(i && pong[i] != pong[i-1]) { pref.pb(vector<ll>()); buck.pb(vector<int>()); } pref.back().pb(pref.back().empty()?x[i]:(pref.back().back()+x[i]) ); buck.back().pb(x[i]); } dp.resize(pref.size()); int comps = pref.size(); for(int i = 0; i< (int) dp.size(); i++) { dp[i].resize(pref[i].size()+1); } for(int i = comps-1; i>= 0; i--) { if(i == comps-1) dp[i][pref[i].size()] = 0; else dp[i][pref[i].size()] = dp[i+1][0]; //printf("%d\n", i); for(int j = pref[i].size()-1; j>= 0; j--) { //printf("dp[%d][%d]\n", i, j); int numleft = pref[i].size()-j; //printf("numleft = %d ((%d))->(%d)\n", numleft, pref[i].size()-numleft-1, pref[i][pref[i].size()-1]); ll sumhere = pref[i][pref[i].size()-1]-(((int)pref[i].size()-numleft-1>= 0)?pref[i][pref[i].size()-numleft-1]:0ll); ll sumnext; if(i+1< comps) { if(numleft-1< pref[i+1].size()) sumnext = pref[i+1][numleft-1]; else sumnext = pref[i+1].back() + pref[i+1][0]*(numleft-pref[i+1].size()); } else sumnext = 1e18; //printf("sumnext %lld sumhere %lld\n", sumnext, sumhere); ll prev; if(i) prev = buck[i-1].back(); else prev = -1e18; dp[i][j] = min(i+1< comps?dp[i+1][min(numleft, (int)pref[i+1].size())]+sumnext-sumhere:(ll)1e18, dp[i][j+1]+buck[i][j]-prev); //printf("dp[%d][%d] = %lld\n", i, j, dp[i][j]); } } return dp[0][0]; }

Compilation message (stderr)

wiring.cpp:11:9: error: 'pair' does not name a type; did you mean 'wait'?
 typedef pair<int, int> ii;
         ^~~~
         wait
wiring.cpp:12:1: error: 'vector' does not name a type; did you mean 'wctob'?
 vector<int> x;
 ^~~~~~
 wctob
wiring.cpp:13:1: error: 'vector' does not name a type; did you mean 'wctob'?
 vector<int> pong;
 ^~~~~~
 wctob
wiring.cpp:14:1: error: 'vector' does not name a type; did you mean 'wctob'?
 vector<int> prv;
 ^~~~~~
 wctob
wiring.cpp:15:1: error: 'vector' does not name a type; did you mean 'wctob'?
 vector< vector< ll > > pref;
 ^~~~~~
 wctob
wiring.cpp:16:1: error: 'vector' does not name a type; did you mean 'wctob'?
 vector< vector< ll > > dp;
 ^~~~~~
 wctob
wiring.cpp:17:1: error: 'vector' does not name a type; did you mean 'wctob'?
 vector< vector<int> > buck;
 ^~~~~~
 wctob
wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:21:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(ir< r.size() && ib< b.size())
           ~~^~~~~~~~~~
wiring.cpp:21:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(ir< r.size() && ib< b.size())
                           ~~^~~~~~~~~~
wiring.cpp:25:13: error: 'x' was not declared in this scope
             x.pb(r[ir]); pong.pb(0);
             ^
wiring.cpp:25:26: error: 'pong' was not declared in this scope
             x.pb(r[ir]); pong.pb(0);
                          ^~~~
wiring.cpp:25:26: note: suggested alternative: 'long'
             x.pb(r[ir]); pong.pb(0);
                          ^~~~
                          long
wiring.cpp:30:13: error: 'x' was not declared in this scope
             x.pb(b[ib]); pong.pb(1);
             ^
wiring.cpp:30:26: error: 'pong' was not declared in this scope
             x.pb(b[ib]); pong.pb(1);
                          ^~~~
wiring.cpp:30:26: note: suggested alternative: 'long'
             x.pb(b[ib]); pong.pb(1);
                          ^~~~
                          long
wiring.cpp:34:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(ir< r.size()) x.pb(r[ir++]), pong.pb(0);
           ~~^~~~~~~~~~
wiring.cpp:34:25: error: 'x' was not declared in this scope
     while(ir< r.size()) x.pb(r[ir++]), pong.pb(0);
                         ^
wiring.cpp:34:40: error: 'pong' was not declared in this scope
     while(ir< r.size()) x.pb(r[ir++]), pong.pb(0);
                                        ^~~~
wiring.cpp:34:40: note: suggested alternative: 'long'
     while(ir< r.size()) x.pb(r[ir++]), pong.pb(0);
                                        ^~~~
                                        long
wiring.cpp:35:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(ib< b.size()) x.pb(b[ib++]), pong.pb(1);
           ~~^~~~~~~~~~
wiring.cpp:35:25: error: 'x' was not declared in this scope
     while(ib< b.size()) x.pb(b[ib++]), pong.pb(1);
                         ^
wiring.cpp:35:40: error: 'pong' was not declared in this scope
     while(ib< b.size()) x.pb(b[ib++]), pong.pb(1);
                                        ^~~~
wiring.cpp:35:40: note: suggested alternative: 'long'
     while(ib< b.size()) x.pb(b[ib++]), pong.pb(1);
                                        ^~~~
                                        long
wiring.cpp:37:13: error: 'pong' was not declared in this scope
     int n = pong.size();
             ^~~~
wiring.cpp:37:13: note: suggested alternative: 'long'
     int n = pong.size();
             ^~~~
             long
wiring.cpp:40:46: error: 'x' was not declared in this scope
         if(i && pong[i] != pong[i-1]) last = x[i-1];
                                              ^
wiring.cpp:41:9: error: 'prv' was not declared in this scope
         prv.pb(last);
         ^~~
wiring.cpp:43:5: error: 'pref' was not declared in this scope
     pref.pb(vector<ll>());
     ^~~~
wiring.cpp:43:5: note: suggested alternative: 'dremf'
     pref.pb(vector<ll>());
     ^~~~
     dremf
wiring.cpp:43:13: error: 'vector' was not declared in this scope
     pref.pb(vector<ll>());
             ^~~~~~
wiring.cpp:43:13: note: suggested alternative:
In file included from /usr/include/c++/7/vector:64:0,
                 from wiring.h:1,
                 from wiring.cpp:4:
/usr/include/c++/7/bits/stl_vector.h:216:11: note:   'std::vector'
     class vector : protected _Vector_base<_Tp, _Alloc>
           ^~~~~~
wiring.cpp:43:22: error: expected primary-expression before '>' token
     pref.pb(vector<ll>());
                      ^
wiring.cpp:43:24: error: expected primary-expression before ')' token
     pref.pb(vector<ll>());
                        ^
wiring.cpp:44:5: error: 'buck' was not declared in this scope
     buck.pb(vector<int>());
     ^~~~
wiring.cpp:44:20: error: expected primary-expression before 'int'
     buck.pb(vector<int>());
                    ^~~
wiring.cpp:49:30: error: expected primary-expression before '>' token
             pref.pb(vector<ll>());
                              ^
wiring.cpp:49:32: error: expected primary-expression before ')' token
             pref.pb(vector<ll>());
                                ^
wiring.cpp:50:28: error: expected primary-expression before 'int'
             buck.pb(vector<int>());
                            ^~~
wiring.cpp:52:44: error: 'x' was not declared in this scope
         pref.back().pb(pref.back().empty()?x[i]:(pref.back().back()+x[i])   );
                                            ^
wiring.cpp:55:5: error: 'dp' was not declared in this scope
     dp.resize(pref.size());
     ^~
wiring.cpp:55:5: note: suggested alternative: 'mp'
     dp.resize(pref.size());
     ^~
     mp
wiring.cpp:83:47: error: 'min' was not declared in this scope
             dp[i][j] = min(i+1< comps?dp[i+1][min(numleft, (int)pref[i+1].size())]+sumnext-sumhere:(ll)1e18, dp[i][j+1]+buck[i][j]-prev);
                                               ^~~
wiring.cpp:83:47: note: suggested alternative:
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from wiring.cpp:5:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   'std::min'
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
wiring.cpp:83:24: error: 'min' was not declared in this scope
             dp[i][j] = min(i+1< comps?dp[i+1][min(numleft, (int)pref[i+1].size())]+sumnext-sumhere:(ll)1e18, dp[i][j+1]+buck[i][j]-prev);
                        ^~~
wiring.cpp:83:24: note: suggested alternative:
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from wiring.cpp:5:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   'std::min'
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~