Submission #117083

# Submission time Handle Problem Language Result Execution time Memory
117083 2019-06-14T16:36:57 Z arman_ferdous Pinball (JOI14_pinball) C++14
0 / 100
2 ms 384 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
const int N = 1e5+100;

int n, m, a[N], b[N], c[N], Del[N];
ll d[N];
vector< pair<ll,int> > v;

int dfs(int u, int lev) {
	if(lev == n + 2) return u;
	if(Del[lev]) return dfs(u, lev + 1);
	if(a[lev] <= u && u <= b[lev]) return dfs(c[lev], lev + 1);
	return dfs(u, lev + 1);
}

bool ok() {
	return dfs(1, 1) == dfs(m, 1);	
}

int main() {
	scanf("%d %d", &n, &m);
	for(int i = 2; i < n + 2; i++) {
		scanf("%d %d %d %lld", &a[i], &b[i], &c[i], &d[i]);
		v.push_back({-d[i], i});
	} sort(v.begin(), v.end());

	ll ans = 0;
	for(int i = 0; i < n; i++) {
		Del[v[i].second] = 1;
		if(!ok()) ans -= v[i].first, Del[v[i].second] = 0;
	} printf("%lld\n", ans);
	return 0;
}

Compilation message

pinball.cpp: In function 'int main()':
pinball.cpp:23:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~~
pinball.cpp:25:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d %lld", &a[i], &b[i], &c[i], &d[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -