Submission #954737

# Submission time Handle Problem Language Result Execution time Memory
954737 2024-03-28T13:05:22 Z Itamar Gap (APIO16_gap) C++14
0 / 100
13 ms 3028 KB
#include "gap.h"
using namespace std;
#define ll long long
#include <vector>
#define vll vector<ll>
#include <algorithm>
long long findGap(int T, int N)
{
	if (T == 1) {
		ll a = -1, b = 1e18+1;
		vll v;
		for (int it = 0; it < (N + 1) / 2; it++) {
			ll *at, *bt;
			MinMax(a+1, b-1, at, bt);
			a = *at, b = *bt;
			v.push_back(a); v.push_back(b);
		}
		sort(v.begin(), v.end());
		ll ans = 0;
		for (int i = 0; i < v.size()-1; i++)ans = max(ans, v[i + 1] - v[i]);
		return ans;
	}
	else {
		ll* a, * b;
		MinMax(0, 1e18, a, b);
		vll v;
		ll d = (b - a+N-2) / (N - 1);
		for (int i = *a; i < *b; i += d + 1) {
			ll* c, * k;
			MinMax(i, i + d, c, k);
			v.push_back(*c); v.push_back(*k);
		}
		sort(v.begin(), v.end());
		ll ans = d;
		for (int i = 0; i < v.size()-1; i++) {
			if (v[i] > -1) {
				ans = max(ans, v[i + 1] - v[i]);
			}
		}
		return ans;
	}
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:20:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   for (int i = 0; i < v.size()-1; i++)ans = max(ans, v[i + 1] - v[i]);
      |                   ~~^~~~~~~~~~~~
gap.cpp:35:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |   for (int i = 0; i < v.size()-1; i++) {
      |                   ~~^~~~~~~~~~~~
gap.cpp:14:10: warning: 'at' may be used uninitialized in this function [-Wmaybe-uninitialized]
   14 |    MinMax(a+1, b-1, at, bt);
      |    ~~~~~~^~~~~~~~~~~~~~~~~~
gap.cpp:14:10: warning: 'bt' may be used uninitialized in this function [-Wmaybe-uninitialized]
gap.cpp:25:9: warning: 'a' may be used uninitialized in this function [-Wmaybe-uninitialized]
   25 |   MinMax(0, 1e18, a, b);
      |   ~~~~~~^~~~~~~~~~~~~~~
gap.cpp:25:9: warning: 'b' may be used uninitialized in this function [-Wmaybe-uninitialized]
gap.cpp:30:10: warning: 'c' may be used uninitialized in this function [-Wmaybe-uninitialized]
   30 |    MinMax(i, i + d, c, k);
      |    ~~~~~~^~~~~~~~~~~~~~~~
gap.cpp:30:10: warning: 'k' may be used uninitialized in this function [-Wmaybe-uninitialized]
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 344 KB Execution failed because the return code was nonzero
2 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
3 Runtime error 0 ms 2392 KB Execution failed because the return code was nonzero
4 Runtime error 0 ms 2392 KB Execution failed because the return code was nonzero
5 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
6 Runtime error 1 ms 2396 KB Execution failed because the return code was nonzero
7 Runtime error 0 ms 2392 KB Execution failed because the return code was nonzero
8 Runtime error 0 ms 2392 KB Execution failed because the return code was nonzero
9 Runtime error 1 ms 2388 KB Execution failed because the return code was nonzero
10 Runtime error 0 ms 2392 KB Execution failed because the return code was nonzero
11 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
12 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
13 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
14 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
15 Runtime error 0 ms 2392 KB Execution failed because the return code was nonzero
16 Runtime error 4 ms 2740 KB Execution failed because the return code was nonzero
17 Runtime error 3 ms 2712 KB Execution failed because the return code was nonzero
18 Runtime error 4 ms 2820 KB Execution failed because the return code was nonzero
19 Runtime error 3 ms 2572 KB Execution failed because the return code was nonzero
20 Runtime error 2 ms 2564 KB Execution failed because the return code was nonzero
21 Runtime error 12 ms 2792 KB Execution failed because the return code was nonzero
22 Runtime error 12 ms 2852 KB Execution failed because the return code was nonzero
23 Runtime error 13 ms 2740 KB Execution failed because the return code was nonzero
24 Runtime error 12 ms 2860 KB Execution failed because the return code was nonzero
25 Runtime error 9 ms 3028 KB Execution failed because the return code was nonzero
26 Runtime error 12 ms 2856 KB Execution failed because the return code was nonzero
27 Runtime error 13 ms 2856 KB Execution failed because the return code was nonzero
28 Runtime error 12 ms 2840 KB Execution failed because the return code was nonzero
29 Runtime error 13 ms 2872 KB Execution failed because the return code was nonzero
30 Runtime error 7 ms 2844 KB Execution failed because the return code was nonzero
31 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
32 Runtime error 0 ms 2640 KB Execution failed because the return code was nonzero
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
2 Runtime error 0 ms 2392 KB Execution failed because the return code was nonzero
3 Runtime error 0 ms 2392 KB Execution failed because the return code was nonzero
4 Runtime error 0 ms 2392 KB Execution failed because the return code was nonzero
5 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
6 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
7 Runtime error 0 ms 2392 KB Execution failed because the return code was nonzero
8 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
9 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
10 Runtime error 1 ms 2476 KB Execution failed because the return code was nonzero
11 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
12 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
13 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
14 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
15 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
16 Runtime error 4 ms 2572 KB Execution failed because the return code was nonzero
17 Runtime error 4 ms 2580 KB Execution failed because the return code was nonzero
18 Runtime error 4 ms 2572 KB Execution failed because the return code was nonzero
19 Runtime error 3 ms 2672 KB Execution failed because the return code was nonzero
20 Runtime error 2 ms 2560 KB Execution failed because the return code was nonzero
21 Runtime error 12 ms 2860 KB Execution failed because the return code was nonzero
22 Runtime error 12 ms 2848 KB Execution failed because the return code was nonzero
23 Runtime error 12 ms 2852 KB Execution failed because the return code was nonzero
24 Runtime error 13 ms 2952 KB Execution failed because the return code was nonzero
25 Runtime error 9 ms 2868 KB Execution failed because the return code was nonzero
26 Runtime error 12 ms 2856 KB Execution failed because the return code was nonzero
27 Runtime error 13 ms 2856 KB Execution failed because the return code was nonzero
28 Runtime error 13 ms 2868 KB Execution failed because the return code was nonzero
29 Runtime error 13 ms 2856 KB Execution failed because the return code was nonzero
30 Runtime error 7 ms 2852 KB Execution failed because the return code was nonzero
31 Runtime error 1 ms 2392 KB Execution failed because the return code was nonzero
32 Runtime error 0 ms 2392 KB Execution failed because the return code was nonzero