Submission #623208

#TimeUsernameProblemLanguageResultExecution timeMemory
623208thanh913Ferries (NOI13_ferries)C++14
Compilation error
0 ms0 KiB
using namespace std; //types #define ll long long #define ld long double #define pll pair<ll, ll> #define pld pair<ld, ld> #define pii pair<int, int> #define fi first #define se second #define inf 0x3f3f3f3f #define pw2(x) (1LL << x) #define getBit(x, y) (x & (1LL << y)) template <class X, class Y> bool cmax(X &a, const Y &b) { return a < b ? a = b, 1 : 0; } template <class X, class Y> bool cmin(X &a, const Y &b) { return a > b ? a = b, 1 : 0; } //lowercase 31, all 53 //(P/Q) % M = (P % M) * (Q^(M-2) % M) //------------------------------------------------------- const ld PI = 3.14159265359; const ll mx = 3e5+5, mod = 1e9+7; bool vs[mx]; ll n, m, f[mx]; vector<pll> adj[mx]; void dfs(int u) { vs[u] = true; vector<ll> ed; for (auto e : adj[u]) { ll v, w; tie(w, v) = e; if (vs[v]) { ed.push_back(f[v]); continue; } dfs(v); ed.push_back(f[v]); } sort(ed.begin(), ed.end(), greater<ll>()); for (int i = 0; i < ed.size(); i++) { cmin(f[u], adj[u][i].fi + ed[i]); } } /* f[i] : kcnn tu dinh i den n dfs den u trong cac canh di tu u -> v */ main() { ios::sync_with_stdio(0); cin.tie(0), cout.tie(0); // freopen("Ferry.Inp", "r", stdin); // freopen("Ferry.Out", "w", stdout); cin >> n >> m; for (int i = 1; i <= m; i++) { int u, v, w; cin >> u >> v >> w; adj[u].push_back({w, v}); } for (int i = 1; i <= n; i++) sort(adj[i].begin(), adj[i].end()); memset(f, inf, sizeof(f)); f[n] = 0; dfs(1); cout << f[1]; }

Compilation message (stderr)

ferries.cpp:35:1: error: 'vector' does not name a type
   35 | vector<pll> adj[mx];
      | ^~~~~~
ferries.cpp: In function 'void dfs(int)':
ferries.cpp:40:2: error: 'vector' was not declared in this scope
   40 |  vector<ll> ed;
      |  ^~~~~~
ferries.cpp:1:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
  +++ |+#include <vector>
    1 | using namespace std;
ferries.cpp:4:12: error: expected primary-expression before 'long'
    4 | #define ll long long
      |            ^~~~
ferries.cpp:40:9: note: in expansion of macro 'll'
   40 |  vector<ll> ed;
      |         ^~
ferries.cpp:41:16: error: 'adj' was not declared in this scope
   41 |  for (auto e : adj[u]) {
      |                ^~~
ferries.cpp:43:3: error: 'tie' was not declared in this scope
   43 |   tie(w, v) = e;
      |   ^~~
ferries.cpp:1:1: note: 'std::tie' is defined in header '<tuple>'; did you forget to '#include <tuple>'?
  +++ |+#include <tuple>
    1 | using namespace std;
ferries.cpp:45:4: error: 'ed' was not declared in this scope; did you mean 'ld'?
   45 |    ed.push_back(f[v]);
      |    ^~
      |    ld
ferries.cpp:49:3: error: 'ed' was not declared in this scope; did you mean 'ld'?
   49 |   ed.push_back(f[v]);
      |   ^~
      |   ld
ferries.cpp:52:7: error: 'ed' was not declared in this scope; did you mean 'ld'?
   52 |  sort(ed.begin(), ed.end(), greater<ll>());
      |       ^~
      |       ld
ferries.cpp:52:29: error: 'greater' was not declared in this scope
   52 |  sort(ed.begin(), ed.end(), greater<ll>());
      |                             ^~~~~~~
ferries.cpp:4:12: error: expected primary-expression before 'long'
    4 | #define ll long long
      |            ^~~~
ferries.cpp:52:37: note: in expansion of macro 'll'
   52 |  sort(ed.begin(), ed.end(), greater<ll>());
      |                                     ^~
ferries.cpp:52:2: error: 'sort' was not declared in this scope; did you mean 'short'?
   52 |  sort(ed.begin(), ed.end(), greater<ll>());
      |  ^~~~
      |  short
ferries.cpp:54:14: error: 'adj' was not declared in this scope
   54 |   cmin(f[u], adj[u][i].fi + ed[i]);
      |              ^~~
ferries.cpp: At global scope:
ferries.cpp:65:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   65 | main() {
      | ^~~~
ferries.cpp: In function 'int main()':
ferries.cpp:66:5: error: 'ios' has not been declared
   66 |     ios::sync_with_stdio(0);
      |     ^~~
ferries.cpp:67:5: error: 'cin' was not declared in this scope
   67 |     cin.tie(0), cout.tie(0);
      |     ^~~
ferries.cpp:1:1: note: 'std::cin' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
  +++ |+#include <iostream>
    1 | using namespace std;
ferries.cpp:67:17: error: 'cout' was not declared in this scope
   67 |     cin.tie(0), cout.tie(0);
      |                 ^~~~
ferries.cpp:67:17: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
ferries.cpp:75:6: error: 'adj' was not declared in this scope
   75 |      adj[u].push_back({w, v});
      |      ^~~
ferries.cpp:77:39: error: 'adj' was not declared in this scope
   77 |     for (int i = 1; i <= n; i++) sort(adj[i].begin(), adj[i].end());
      |                                       ^~~
ferries.cpp:77:34: error: 'sort' was not declared in this scope; did you mean 'short'?
   77 |     for (int i = 1; i <= n; i++) sort(adj[i].begin(), adj[i].end());
      |                                  ^~~~
      |                                  short
ferries.cpp:79:5: error: 'memset' was not declared in this scope
   79 |     memset(f, inf, sizeof(f));
      |     ^~~~~~
ferries.cpp:1:1: note: 'memset' is defined in header '<cstring>'; did you forget to '#include <cstring>'?
  +++ |+#include <cstring>
    1 | using namespace std;