Submission #203857

#TimeUsernameProblemLanguageResultExecution timeMemory
203857staniewzkiOlympic Bus (JOI20_ho_t4)C++17
Compilation error
0 ms0 KiB
FG"+ using namespace std; ostream& operator<<(ostream &out, string str) { for(char c : str) out << c; return out; } template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) { return out << "(" << p.first << ", " << p.second << ")"; } template<class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) { out << "{"; for(auto it = a.begin(); it != a.end(); it = next(it)) out << (it != a.begin() ? ", " : "") << *it; return out << "}"; } void dump() { cerr << "\n"; } template<class T, class... Ts> void dump(T a, Ts... x) { cerr << a << ", "; dump(x...); } #ifdef DEBUG # define debug(...) cerr << "[" #__VA_ARGS__ "]: ", dump(__VA_ARGS__) #else # define debug(...) false #endif #define REP(i, n) for(int i = 0; i < n; i++) #define FOR(i, a, b) for(int i = a; i <= b; i++) #define ST first #define ND second template<class T> int size(T && a) { return a.size(); } using LL = long long; using PII = pair<int, int>; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; vector<int> a(m), b(m), c(m), d(m); vector<vector<PII>> g(n), r(n); REP(i, m) { cin >> a[i] >> b[i] >> c[i] >> d[i]; a[i]--, b[i]--; g[a[i]].emplace_back(b[i], i); r[b[i]].emplace_back(a[i], i); } vector<bool> on_path(m); auto dijkstra = [&](vector<vector<PII>> &adj, int source, int banned, bool mark) { vector<int> dst(n, 1e9), last(n, -1); priority_queue<PII> Q; dst[source] = 0; Q.emplace(0, source); while(!Q.empty()) { int d, v; tie(d, v) = Q.top(); Q.pop(); if(-d != dst[v]) continue; for(auto &[u, e] : adj[v]) { if(banned == e) continue; if(dst[u] > dst[v] + c[e]) { if(mark) last[u] = e; dst[u] = dst[v] + c[e]; Q.emplace(-dst[u], u); } } } REP(i, n) if(last[i] != -1) on_path[last[i]] = true; return dst; }; auto norm_source = dijkstra(g, 0, -1, true); auto norm_sink = dijkstra(g, n - 1, -1, true); auto rev_source = dijkstra(r, 0, -1, false); auto rev_sink = dijkstra(r, n - 1, -1, false); auto add_edge = [&](int i) { g[b[i]].emplace_back(a[i], size(a)); r[a[i]].emplace_back(b[i], size(b)); a.emplace_back(b[i]); b.emplace_back(a[i]); c.emplace_back(c[i]); }; auto pop_edge = [&](int i) { g[b[i]].pop_back(); r[a[i]].pop_back(); a.pop_back(); b.pop_back(); c.pop_back(); }; LL ans = norm_source[n - 1] + norm_sink[0]; REP(i, m) { if(on_path[i]) { add_edge(i); auto source = dijkstra(g, 0, i, false); auto sink = dijkstra(g, n - 1, i, false); ans = min(ans, (LL) source[n - 1] + sink[0] + d[i]); pop_edge(i); } else { int source = min(norm_source[n - 1], norm_source[b[i]] + c[i] + rev_sink[a[i]]); int sink = min(norm_sink[0], norm_sink[b[i]] + c[i] + rev_source[a[i]]); ans = min(ans, (LL) source + sink + d[i]); } } if(ans >= 1e9) ans = -1; cout << ans << "\n"; }

Compilation message (stderr)

ho_t4.cpp:1:3: warning: missing terminating " character
 FG"+
   ^
ho_t4.cpp:1:3: error: missing terminating " character
 FG"+
   ^~
ho_t4.cpp:1:1: error: 'FG' does not name a type
 FG"+
 ^~
ho_t4.cpp:4:1: error: 'ostream' does not name a type
 ostream& operator<<(ostream &out, string str) {
 ^~~~~~~
ho_t4.cpp:9:28: error: 'ostream' does not name a type
 template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) {
                            ^~~~~~~
ho_t4.cpp:13:35: error: declaration of 'operator<<' as non-function
 template<class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
                                   ^~~~~~~
ho_t4.cpp:13:35: error: 'ostream' was not declared in this scope
ho_t4.cpp:13:44: error: 'out' was not declared in this scope
 template<class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
                                            ^~~
ho_t4.cpp:13:44: note: suggested alternative: 'auto'
 template<class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
                                            ^~~
                                            auto
ho_t4.cpp:13:51: error: expected primary-expression before 'a'
 template<class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
                                                   ^
ho_t4.cpp: In function 'void dump()':
ho_t4.cpp:20:15: error: 'cerr' was not declared in this scope
 void dump() { cerr << "\n"; }
               ^~~~
ho_t4.cpp:20:15: note: suggested alternative: 'char'
 void dump() { cerr << "\n"; }
               ^~~~
               char
ho_t4.cpp: In function 'void dump(T, Ts ...)':
ho_t4.cpp:22:2: error: 'cerr' was not declared in this scope
  cerr << a << ", ";
  ^~~~
ho_t4.cpp:22:2: note: suggested alternative: 'char'
  cerr << a << ", ";
  ^~~~
  char
ho_t4.cpp: At global scope:
ho_t4.cpp:40:13: error: 'pair' does not name a type
 using PII = pair<int, int>;
             ^~~~
ho_t4.cpp: In function 'int main()':
ho_t4.cpp:43:2: error: 'ios_base' has not been declared
  ios_base::sync_with_stdio(0);
  ^~~~~~~~
ho_t4.cpp:44:2: error: 'cin' was not declared in this scope
  cin.tie(0);
  ^~~
ho_t4.cpp:44:2: note: suggested alternative: 'main'
  cin.tie(0);
  ^~~
  main
ho_t4.cpp:49:2: error: 'vector' was not declared in this scope
  vector<int> a(m), b(m), c(m), d(m);
  ^~~~~~
ho_t4.cpp:49:9: error: expected primary-expression before 'int'
  vector<int> a(m), b(m), c(m), d(m);
         ^~~
ho_t4.cpp:50:16: error: 'PII' was not declared in this scope
  vector<vector<PII>> g(n), r(n);
                ^~~
ho_t4.cpp:50:22: error: 'g' was not declared in this scope
  vector<vector<PII>> g(n), r(n);
                      ^
ho_t4.cpp:50:28: error: 'r' was not declared in this scope
  vector<vector<PII>> g(n), r(n);
                            ^
ho_t4.cpp:52:10: error: 'a' was not declared in this scope
   cin >> a[i] >> b[i] >> c[i] >> d[i];
          ^
ho_t4.cpp:52:18: error: 'b' was not declared in this scope
   cin >> a[i] >> b[i] >> c[i] >> d[i];
                  ^
ho_t4.cpp:52:26: error: 'c' was not declared in this scope
   cin >> a[i] >> b[i] >> c[i] >> d[i];
                          ^
ho_t4.cpp:52:34: error: 'd' was not declared in this scope
   cin >> a[i] >> b[i] >> c[i] >> d[i];
                                  ^
ho_t4.cpp:58:9: error: expected primary-expression before 'bool'
  vector<bool> on_path(m);
         ^~~~
ho_t4.cpp:59:22: error: 'vector' is not a type
  auto dijkstra = [&](vector<vector<PII>> &adj, int source, int banned, bool mark) {
                      ^~~~~~
ho_t4.cpp:59:28: error: expected ',' or '...' before '<' token
  auto dijkstra = [&](vector<vector<PII>> &adj, int source, int banned, bool mark) {
                            ^
ho_t4.cpp: In lambda function:
ho_t4.cpp:60:10: error: expected primary-expression before 'int'
   vector<int> dst(n, 1e9), last(n, -1);
          ^~~
ho_t4.cpp:61:3: error: 'priority_queue' was not declared in this scope
   priority_queue<PII> Q;
   ^~~~~~~~~~~~~~
ho_t4.cpp:61:23: error: 'Q' was not declared in this scope
   priority_queue<PII> Q;
                       ^
ho_t4.cpp:62:3: error: 'dst' was not declared in this scope
   dst[source] = 0;
   ^~~
ho_t4.cpp:62:7: error: 'source' was not declared in this scope
   dst[source] = 0;
       ^~~~~~
ho_t4.cpp:62:7: note: suggested alternative: 'double'
   dst[source] = 0;
       ^~~~~~
       double
ho_t4.cpp:66:4: error: 'tie' was not declared in this scope
    tie(d, v) = Q.top();
    ^~~
ho_t4.cpp:66:4: note: suggested alternative: 'size'
    tie(d, v) = Q.top();
    ^~~
    size
ho_t4.cpp:69:23: error: 'adj' was not declared in this scope
    for(auto &[u, e] : adj[v]) {
                       ^~~
ho_t4.cpp:70:8: error: 'banned' was not declared in this scope
     if(banned == e) continue;
        ^~~~~~
ho_t4.cpp:70:8: note: suggested alternative: 'signed'
     if(banned == e) continue;
        ^~~~~~
        signed
ho_t4.cpp:71:26: error: 'c' was not declared in this scope
     if(dst[u] > dst[v] + c[e]) {
                          ^
ho_t4.cpp:72:9: error: 'mark' was not declared in this scope
      if(mark) last[u] = e;
         ^~~~
ho_t4.cpp:72:9: note: suggested alternative: 'main'
      if(mark) last[u] = e;
         ^~~~
         main
ho_t4.cpp:72:15: error: 'last' was not declared in this scope
      if(mark) last[u] = e;
               ^~~~
ho_t4.cpp:72:15: note: suggested alternative: 'class'
      if(mark) last[u] = e;
               ^~~~
               class
ho_t4.cpp:78:16: error: 'last' was not declared in this scope
   REP(i, n) if(last[i] != -1)
                ^~~~
ho_t4.cpp:78:16: note: suggested alternative: 'class'
   REP(i, n) if(last[i] != -1)
                ^~~~
                class
ho_t4.cpp:79:4: error: 'on_path' was not declared in this scope
    on_path[last[i]] = true;
    ^~~~~~~
ho_t4.cpp:80:10: error: unable to deduce lambda return type from 'dst'
   return dst;
          ^~~
ho_t4.cpp: In lambda function:
ho_t4.cpp:89:5: error: 'b' was not declared in this scope
   g[b[i]].emplace_back(a[i], size(a));
     ^
ho_t4.cpp:89:24: error: 'a' was not declared in this scope
   g[b[i]].emplace_back(a[i], size(a));
                        ^
ho_t4.cpp:93:3: error: 'c' was not declared in this scope
   c.emplace_back(c[i]);
   ^
ho_t4.cpp: In lambda function:
ho_t4.cpp:97:5: error: 'b' was not declared in this scope
   g[b[i]].pop_back();
     ^
ho_t4.cpp:98:5: error: 'a' was not declared in this scope
   r[a[i]].pop_back();
     ^
ho_t4.cpp:101:3: error: 'c' was not declared in this scope
   c.pop_back();
   ^
ho_t4.cpp: In function 'int main()':
ho_t4.cpp:107:6: error: 'on_path' was not declared in this scope
   if(on_path[i]) {
      ^~~~~~~
ho_t4.cpp:111:50: error: 'd' was not declared in this scope
    ans = min(ans, (LL) source[n - 1] + sink[0] + d[i]);
                                                  ^
ho_t4.cpp:111:10: error: 'min' was not declared in this scope
    ans = min(ans, (LL) source[n - 1] + sink[0] + d[i]);
          ^~~
ho_t4.cpp:111:10: note: suggested alternative: 'main'
    ans = min(ans, (LL) source[n - 1] + sink[0] + d[i]);
          ^~~
          main
ho_t4.cpp:115:53: error: 'b' was not declared in this scope
    int source = min(norm_source[n - 1], norm_source[b[i]] + c[i] + rev_sink[a[i]]);
                                                     ^
ho_t4.cpp:115:61: error: 'c' was not declared in this scope
    int source = min(norm_source[n - 1], norm_source[b[i]] + c[i] + rev_sink[a[i]]);
                                                             ^
ho_t4.cpp:115:77: error: 'a' was not declared in this scope
    int source = min(norm_source[n - 1], norm_source[b[i]] + c[i] + rev_sink[a[i]]);
                                                                             ^
ho_t4.cpp:115:17: error: 'min' was not declared in this scope
    int source = min(norm_source[n - 1], norm_source[b[i]] + c[i] + rev_sink[a[i]]);
                 ^~~
ho_t4.cpp:115:17: note: suggested alternative: 'main'
    int source = min(norm_source[n - 1], norm_source[b[i]] + c[i] + rev_sink[a[i]]);
                 ^~~
                 main
ho_t4.cpp:117:40: error: 'd' was not declared in this scope
    ans = min(ans, (LL) source + sink + d[i]);
                                        ^
ho_t4.cpp:122:2: error: 'cout' was not declared in this scope
  cout << ans << "\n";
  ^~~~