Submission #537350

#TimeUsernameProblemLanguageResultExecution timeMemory
5373508e7Treatment Project (JOI20_treatment)C++17
0 / 100
23 ms4904 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]; struct rect{ int x1, y1, x2, y2; int cost; bool ins(int x, int y){ return x >= x1 - 1 && x <= x2 + 1 && y >= y1 - 1 && y <= y2 + 1; } bool inter(rect r) { return ins(r.x1, r.y1) || ins(r.x1, r.y2) || ins(r.x2, r.y1) || ins(r.x2, r.y2) || r.ins(x1, y1) || r.ins(x1, y2) || r.ins(x2, y1) || r.ins(x2, y2); } } a[maxn]; ll dis[maxn]; int main() { io int L, n; cin >> L >> n; for (int i = 1;i <= n;i++) { int t, l, r, c; cin >> t >> l >> r >> c; a[i].x1 = t - r, a[i].x2 = t - l, a[i].y1 = t + l, a[i].y2 = t + r; a[i].cost = c; if (r == L) { adj[0][i] = 1; } if (l == 1) { adj[i][n+1] = 1; } } for (int i = 1;i <= n;i++) { dis[i] = inf; for (int j = i + 1;j <= n;j++) { adj[i][j] = adj[j][i] = a[i].inter(a[j]); } } 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"; }

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:58:3: note: in expansion of macro 'pary'
   58 |   pary(adj[i], adj[i] + n + 2);
      |   ^~~~
treatment.cpp:12:20: warning: statement has no effect [-Wunused-value]
   12 | #define debug(...) 0
      |                    ^
treatment.cpp:68:3: note: in expansion of macro 'debug'
   68 |   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...