Submission #63427

# Submission time Handle Problem Language Result Execution time Memory
63427 2018-08-01T18:49:01 Z qkxwsm Gap (APIO16_gap) C++17
48.541 / 100
111 ms 39824 KB
#include "gap.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

struct chash
{
        int operator()(int x) const
        {
                x ^= (x >> 20) ^ (x >> 12);
                return x ^ (x >> 7) ^ (x >> 4);
        }
        int operator()(long long x) const
        {
                return x ^ (x >> 32);
        }
};

template<typename T> using orderedset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename U> using hashtable = gp_hash_table<T, U, chash>;

template<class T>
void readi(T &x)
{
        T input = 0;
        bool negative = false;
        char c = ' ';
        while (c < '-')
        {
                c = getchar();
        }
        if (c == '-')
        {
                negative = true;
                c = getchar();
        }
        while (c >= '0')
        {
                input = input * 10 + (c - '0');
                c = getchar();
        }
        if (negative)
        {
                input = -input;
        }
        x = input;
}
template<class T>
void printi(T output)
{
        if (output == 0)
        {
                putchar('0');
                return;
        }
        if (output < 0)
        {
                putchar('-');
                output = -output;
        }
        int aout[20];
        int ilen = 0;
        while(output)
        {
                aout[ilen] = ((output % 10));
                output /= 10;
                ilen++;
        }
        for (int i = ilen - 1; i >= 0; i--)
        {
                putchar(aout[i] + '0');
        }
        return;
}
template<class T>
void ckmin(T &a, T b)
{
        a = min(a, b);
}
template<class T>
void ckmax(T &a, T b)
{
        a = max(a, b);
}
template<class T, class U>
T normalize(T x, U mod = 1000000007)
{
	return (((x % mod) + mod) % mod);
}
static long long randomizell(long long mod)
{
        return ((1ll << 45) * rand() + (1ll << 30) * rand() + (1ll << 15) * rand() + rand()) % mod;
}
static int randomize(int mod)
{
        return ((1ll << 15) * rand() + rand()) % mod;
}

#define y0 ___y0
#define y1 ___y1
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define debug(x) cerr << #x << " = " << x << endl;

const long double PI = 4.0 * atan(1.0);
const long double EPS = 1e-10;

#define MAGIC 347
#define SINF 10007
#define CO 1000007
#define INF 1000000007
#define BIG 1000000931
#define LARGE 1696969696967ll
#define GIANT 2564008813937411ll
#define LLINF 2696969696969696969ll

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;

pll bound(ll L, ll R)
{
	pll res;
	MinMax(L, R, &res.fi, &res.se);
	return res;
}
long long findGap(int tc, int n)
{
	//LARGEST value of a_i - a_(i-1)
	vector<ll> nums;
	pll st = bound(0, 1'000'000'000'000'000'000);
	ll lo = st.fi, hi = st.se;
	ll dif = (hi - lo + n - 1) / n;
	for (ll i = 0; i < hi; i += dif)
	{
		pll cur = bound(i, min(hi, i + dif - 1));
		if (cur.fi != -1)
		{
			nums.PB(cur.fi);
			nums.PB(cur.se);
		}
	}
	ll res = 0;
	for (int i = 1; i < nums.size(); i++)
	{
		ckmax(res, nums[i] - nums[i - 1]);
	}
	return res;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:155:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 1; i < nums.size(); i++)
                  ~~^~~~~~~~~~~~~
gap.cpp: At global scope:
gap.cpp:97:12: warning: 'int randomize(int)' defined but not used [-Wunused-function]
 static int randomize(int mod)
            ^~~~~~~~~
gap.cpp:93:18: warning: 'long long int randomizell(long long int)' defined but not used [-Wunused-function]
 static long long randomizell(long long mod)
                  ^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 248 KB Output isn't correct
2 Incorrect 3 ms 488 KB Output isn't correct
3 Incorrect 3 ms 488 KB Output isn't correct
4 Incorrect 2 ms 488 KB Output isn't correct
5 Incorrect 3 ms 488 KB Output isn't correct
6 Incorrect 3 ms 488 KB Output isn't correct
7 Incorrect 3 ms 488 KB Output isn't correct
8 Incorrect 2 ms 528 KB Output isn't correct
9 Incorrect 3 ms 536 KB Output isn't correct
10 Incorrect 2 ms 536 KB Output isn't correct
11 Incorrect 4 ms 580 KB Output isn't correct
12 Incorrect 3 ms 696 KB Output isn't correct
13 Incorrect 3 ms 720 KB Output isn't correct
14 Incorrect 4 ms 892 KB Output isn't correct
15 Incorrect 4 ms 892 KB Output isn't correct
16 Incorrect 29 ms 1896 KB Output isn't correct
17 Incorrect 24 ms 2364 KB Output isn't correct
18 Incorrect 24 ms 2828 KB Output isn't correct
19 Incorrect 24 ms 3348 KB Output isn't correct
20 Incorrect 15 ms 3348 KB Output isn't correct
21 Incorrect 93 ms 6660 KB Output isn't correct
22 Incorrect 81 ms 8508 KB Output isn't correct
23 Incorrect 86 ms 10332 KB Output isn't correct
24 Incorrect 84 ms 12196 KB Output isn't correct
25 Incorrect 79 ms 14544 KB Output isn't correct
26 Incorrect 89 ms 15316 KB Output isn't correct
27 Incorrect 86 ms 17076 KB Output isn't correct
28 Incorrect 93 ms 18992 KB Output isn't correct
29 Incorrect 98 ms 20812 KB Output isn't correct
30 Incorrect 43 ms 20812 KB Output isn't correct
31 Incorrect 2 ms 20812 KB Output isn't correct
32 Incorrect 4 ms 20812 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Partially correct 2 ms 20812 KB Partially correct
2 Partially correct 2 ms 20812 KB Partially correct
3 Partially correct 2 ms 20812 KB Partially correct
4 Partially correct 3 ms 20812 KB Partially correct
5 Partially correct 3 ms 20812 KB Partially correct
6 Partially correct 2 ms 20812 KB Partially correct
7 Partially correct 2 ms 20812 KB Partially correct
8 Partially correct 3 ms 20812 KB Partially correct
9 Partially correct 3 ms 20812 KB Partially correct
10 Partially correct 2 ms 20812 KB Partially correct
11 Partially correct 4 ms 20812 KB Partially correct
12 Partially correct 3 ms 20812 KB Partially correct
13 Partially correct 3 ms 20812 KB Partially correct
14 Partially correct 5 ms 20812 KB Partially correct
15 Partially correct 5 ms 20812 KB Partially correct
16 Partially correct 23 ms 20884 KB Partially correct
17 Partially correct 21 ms 21308 KB Partially correct
18 Partially correct 21 ms 21772 KB Partially correct
19 Partially correct 23 ms 22236 KB Partially correct
20 Correct 12 ms 22236 KB Output is correct
21 Partially correct 80 ms 25608 KB Partially correct
22 Partially correct 86 ms 27432 KB Partially correct
23 Partially correct 82 ms 29224 KB Partially correct
24 Partially correct 87 ms 31108 KB Partially correct
25 Partially correct 83 ms 33440 KB Partially correct
26 Partially correct 89 ms 34264 KB Partially correct
27 Partially correct 86 ms 36028 KB Partially correct
28 Partially correct 80 ms 37864 KB Partially correct
29 Partially correct 111 ms 39824 KB Partially correct
30 Correct 43 ms 39824 KB Output is correct
31 Partially correct 2 ms 39824 KB Partially correct
32 Partially correct 2 ms 39824 KB Partially correct