Submission #537973

#TimeUsernameProblemLanguageResultExecution timeMemory
5379738e7Treatment Project (JOI20_treatment)C++17
35 / 100
217 ms25292 KiB
//Challenge: Accepted #include <bits/stdc++.h> using namespace std; #ifdef zisk void debug(){cout << endl;} template<class T, class ... U> void debug(T a, U ... b){cout << a << " ", debug(b...);} template<class T> void pary(T l, T r) { while (l != r) cout << *l << " ", l++; cout << endl; } #else #define debug(...) 0 #define pary(...) 0 #endif #define ll long long #define maxn 5005 #define pii pair<ll, ll> #define ff first #define ss second #define io ios_base::sync_with_stdio(0);cin.tie(0); const ll inf = 1LL<<60; bool adj[maxn][maxn], mark[maxn]; bool vis[maxn]; void dfs(int n, int tot) { vis[n] = 1; for (int v = 1;v <= tot;v++) { if (adj[n][v] && mark[v] && !vis[v]) { dfs(v, tot); } } } struct rect{ int t, l, r; int cost; rect(){t = l = r = cost = 0;} } a[maxn]; ll dis[maxn]; int main() { io int L, n; cin >> L >> n; for (int i = 1;i <= n;i++) { cin >> a[i].t >> a[i].l >> a[i].r >> a[i].cost; if (a[i].l == 1) adj[0][i] = 1; if (a[i].r == L) adj[i][n+1] = 1; } for (int i = 1;i <= n;i++) { dis[i] = inf; for (int j = 1;j <= n;j++) { if (i == j) continue; if (a[j].l <= a[i].r - abs(a[i].t - a[j].t) + 1) adj[i][j] = 1; } } for (int i = 0;i <= n + 1;i++) { pary(adj[i], adj[i] + n + 2); } dis[n+1] = inf; priority_queue<pii, vector<pii>, greater<pii> > pq; pq.push({0, 0}); while (pq.size()) { auto [d, cur] = pq.top(); pq.pop(); if (d != dis[cur]) continue; debug(cur, d); for (int i = 1;i <= n + 1;i++) { if (adj[cur][i] && d + a[i].cost < dis[i]) { dis[i] = d + a[i].cost; pq.push({dis[i], i}); } } } cout << (dis[n+1] == inf ? -1 : dis[n+1]) << "\n"; } /* 1000000000 16 6 2 2 1 4 999999997 999999999 4 2 999999997 1000000000 2 3 1 4 3 3 999999997 1000000000 3 5 999999998 999999999 3 6 999999999 999999999 1 2 1 4 2 6 3 999999998 1 999999987 1 1000000000 10 999999986 1 1000000000 10 999999985 1 1000000000 10 4 2 4 4 5 2 3 3 1 999999997 1000000000 1 1 1 4 1 */

Compilation message (stderr)

treatment.cpp: In function 'int main()':
treatment.cpp:13:19: warning: statement has no effect [-Wunused-value]
   13 | #define pary(...) 0
      |                   ^
treatment.cpp:55:3: note: in expansion of macro 'pary'
   55 |   pary(adj[i], adj[i] + n + 2);
      |   ^~~~
treatment.cpp:12:20: warning: statement has no effect [-Wunused-value]
   12 | #define debug(...) 0
      |                    ^
treatment.cpp:65:3: note: in expansion of macro 'debug'
   65 |   debug(cur, d);
      |   ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...