Submission #594256

# Submission time Handle Problem Language Result Execution time Memory
594256 2022-07-12T09:36:17 Z Vanilla Gap (APIO16_gap) C++17
0 / 100
129 ms 10392 KB
#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
typedef long long int64;

int64 findGap(int t, int n){
	vector <int64> v;
	int64 rs = -1;
	if (t == 1) {
		int64 l = 0, r = 1e18, mn = -1, mx = -1;
		set <int64> s;
		vector <int64> p1, p2;
		while (l <= r) {
			MinMax(l, r, &mn, &mx);
			if (mn == -1) break;
			s.insert(mn);
			s.insert(mx);
			l = mn + 1, r = mx - 1;
			if (mn == mx) break;
		}
		for (int64 i: s) v.push_back(i);
	}
	else {
		set <int64> s;
		int64 last = -1, mn = -1, mx = -1;
		for (int i = 0; i < n; i++){
			int64 l = last + 1;
			// cout << "> " << l << "\n";
			auto it = s.lower_bound(l);
			int64 r = (it == s.end() ? 1e18: *it); 
			while (l <= r) {
				int64 mid = (l + r) / 2;
				MinMax(l, mid, &mn, &mx);
				// cout << l << " " << r << " " << mn << " " << mx << "\n";
				if (mn == -1) break;
				s.insert(mn);
				s.insert(mx);
				if (mn == mx) break;
				r = min(mid - 1, mx - 1);
				// l = mn + 1;
			}
			last = *s.lower_bound(last + 1);
		}
		for (int64 i: s) v.push_back(i);
	}
	assert(v.size() == n);
	for (int i = 1; i < n; i++){
		rs = max(rs, v[i] - v[i-1]);
	}
	return rs;
}

Compilation message

In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from gap.cpp:1:
gap.cpp: In function 'int64 findGap(int, int)':
gap.cpp:46:18: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   46 |  assert(v.size() == n);
      |         ~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Output isn't correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Incorrect 0 ms 336 KB Output isn't correct
7 Incorrect 1 ms 208 KB Output isn't correct
8 Incorrect 0 ms 208 KB Output isn't correct
9 Incorrect 0 ms 208 KB Output isn't correct
10 Correct 1 ms 208 KB Output is correct
11 Incorrect 1 ms 336 KB Output isn't correct
12 Incorrect 1 ms 336 KB Output isn't correct
13 Incorrect 1 ms 336 KB Output isn't correct
14 Incorrect 1 ms 336 KB Output isn't correct
15 Incorrect 1 ms 336 KB Output isn't correct
16 Incorrect 15 ms 2000 KB Output isn't correct
17 Incorrect 13 ms 2000 KB Output isn't correct
18 Incorrect 13 ms 2088 KB Output isn't correct
19 Incorrect 14 ms 2000 KB Output isn't correct
20 Correct 13 ms 1996 KB Output is correct
21 Incorrect 69 ms 6900 KB Output isn't correct
22 Incorrect 76 ms 6916 KB Output isn't correct
23 Incorrect 56 ms 6904 KB Output isn't correct
24 Incorrect 56 ms 6936 KB Output isn't correct
25 Incorrect 103 ms 6896 KB Output isn't correct
26 Incorrect 57 ms 6928 KB Output isn't correct
27 Incorrect 76 ms 6948 KB Output isn't correct
28 Incorrect 71 ms 6852 KB Output isn't correct
29 Incorrect 71 ms 6876 KB Output isn't correct
30 Correct 60 ms 6880 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 464 KB Execution killed with signal 6
2 Runtime error 1 ms 464 KB Execution killed with signal 6
3 Runtime error 1 ms 464 KB Execution killed with signal 6
4 Runtime error 1 ms 464 KB Execution killed with signal 6
5 Partially correct 1 ms 208 KB Partially correct
6 Runtime error 1 ms 464 KB Execution killed with signal 6
7 Runtime error 1 ms 464 KB Execution killed with signal 6
8 Runtime error 1 ms 512 KB Execution killed with signal 6
9 Runtime error 1 ms 464 KB Execution killed with signal 6
10 Runtime error 2 ms 464 KB Execution killed with signal 6
11 Runtime error 4 ms 592 KB Execution killed with signal 6
12 Runtime error 2 ms 592 KB Execution killed with signal 6
13 Runtime error 2 ms 592 KB Execution killed with signal 6
14 Runtime error 2 ms 592 KB Execution killed with signal 6
15 Partially correct 3 ms 328 KB Partially correct
16 Runtime error 32 ms 3052 KB Execution killed with signal 6
17 Runtime error 27 ms 3084 KB Execution killed with signal 6
18 Runtime error 27 ms 3024 KB Execution killed with signal 6
19 Runtime error 33 ms 3112 KB Execution killed with signal 6
20 Runtime error 21 ms 2208 KB Execution killed with signal 6
21 Runtime error 124 ms 10372 KB Execution killed with signal 6
22 Runtime error 111 ms 10392 KB Execution killed with signal 6
23 Runtime error 119 ms 10376 KB Execution killed with signal 6
24 Runtime error 124 ms 10376 KB Execution killed with signal 6
25 Partially correct 101 ms 6836 KB Partially correct
26 Runtime error 101 ms 10344 KB Execution killed with signal 6
27 Runtime error 129 ms 10368 KB Execution killed with signal 6
28 Runtime error 99 ms 10364 KB Execution killed with signal 6
29 Runtime error 95 ms 10344 KB Execution killed with signal 6
30 Runtime error 92 ms 6884 KB Execution killed with signal 6
31 Runtime error 1 ms 464 KB Execution killed with signal 6
32 Partially correct 1 ms 208 KB Partially correct