Submission #537351

# Submission time Handle Problem Language Result Execution time Memory
537351 2022-03-15T03:05:47 Z 8e7 Treatment Project (JOI20_treatment) C++17
0 / 100
22 ms 2728 KB
//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;	
	rect(){x1 = y1 = x2 = y2 = cost = 0;}
	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

treatment.cpp: In function 'int main()':
treatment.cpp:13:19: warning: statement has no effect [-Wunused-value]
   13 | #define pary(...) 0
      |                   ^
treatment.cpp:59:3: note: in expansion of macro 'pary'
   59 |   pary(adj[i], adj[i] + n + 2);
      |   ^~~~
treatment.cpp:12:20: warning: statement has no effect [-Wunused-value]
   12 | #define debug(...) 0
      |                    ^
treatment.cpp:69:3: note: in expansion of macro 'debug'
   69 |   debug(cur, d);
      |   ^~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 22 ms 2728 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Incorrect 1 ms 468 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Incorrect 1 ms 468 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 22 ms 2728 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -