Submission #831942

# Submission time Handle Problem Language Result Execution time Memory
831942 2023-08-20T18:18:49 Z DarkMatter Lightning Rod (NOI18_lightningrod) C++14
19 / 100
2000 ms 262144 KB
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int>pi;
typedef pair<ll, ll>pl;
typedef vector<pi>vpi;
typedef vector<pl>vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
const long double PI = acos(-1);
const ll oo = 1e18;
const int MOD = 1e9 + 7;
const int N = 2e5 + 7;
#define endl '\n'
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define read(v) for (auto& it : v) scanf("%d", &it);
#define readL(v) for (auto& it : v) scanf("%lld", &it);
#define print(v) for (auto it : v) printf("%d ", it); puts("");
#define printL(v) for (auto it : v) printf("%lld ", it); puts("");
ll n;
vpl v;
ll ans = oo;
void calc(ll idx, vpl cur) {
	if (idx == n) {
		vb vis(n, false);
		for (int i = 0; i < cur.size(); i++) {
			for (int j = 0; j < n; j++) {
				if (vis[j])
					continue;
				if (abs(cur[i].first - v[j].first) <= (cur[i].second - v[j].second))
					vis[j] = true;
			}
		}
		sort(all(vis));
		if (vis[0])
			ans = min(ans, (ll)cur.size());
		return;
	}
	calc(idx + 1, cur);
	cur.push_back(v[idx]);
	calc(idx + 1, cur);
}
void solve() {
	scanf("%lld", &n);
	v.resize(n);
	ans = oo;
	for (auto& it : v)
		scanf("%lld %lld", &it.first, &it.second);
	vpl cur;
	calc(0, cur);
	printf("%lld\n", ans);
}
int t = 1;
int main() {
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt", "r", stdin);
	//#endif
		//scanf("%d", &t);
	while (t--) solve();
}

Compilation message

lightningrod.cpp: In function 'void calc(ll, vpl)':
lightningrod.cpp:34:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |   for (int i = 0; i < cur.size(); i++) {
      |                   ~~^~~~~~~~~~~~
lightningrod.cpp: In function 'void solve()':
lightningrod.cpp:52:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |  scanf("%lld", &n);
      |  ~~~~~^~~~~~~~~~~~
lightningrod.cpp:56:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   56 |   scanf("%lld %lld", &it.first, &it.second);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1378 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 379 ms 296 KB Output is correct
9 Correct 849 ms 312 KB Output is correct
10 Correct 859 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 379 ms 296 KB Output is correct
9 Correct 849 ms 312 KB Output is correct
10 Correct 859 ms 308 KB Output is correct
11 Execution timed out 2057 ms 744 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 379 ms 296 KB Output is correct
9 Correct 849 ms 312 KB Output is correct
10 Correct 859 ms 308 KB Output is correct
11 Execution timed out 2057 ms 744 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1359 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1378 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -