답안 #40154

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
40154 2018-01-28T16:33:31 Z SpaimaCarpatilor Gap (APIO16_gap) C++14
30 / 100
124 ms 9152 KB
#include "gap.h"
#include<bits/stdc++.h>

using namespace std;

long long x[100009];
const long long xmax = 1e18;

long long rand15 () {return rand () & 32767;}
long long rand30 () {return (rand15 () << 15LL) | rand15 ();}
long long rand60 () {return (rand30 () << 30LL) | rand30 ();}

vector < long long > divide (long long a, long long b)
{
    if (a > b) return {};
    long long mid = a + rand60 () % (b - a);
    long long x, y, z, t;
    MinMax (a, mid, &x, &y);
    MinMax (mid + 1, b, &z, &t);
    vector < long long > ans;
    if (x == -1) ;
    else
    {
        ans.push_back (x);
        if (x != y)
        {
            vector < long long > curr;
            curr = divide (x + 1, y - 1);
            for (auto it : curr)
                ans.push_back (it);
            ans.push_back (y);
        }
    }
    if (z == -1) ;
    else
    {
        ans.push_back (z);
        if (z != t)
        {
            vector < long long > curr;
            curr = divide (z + 1, t - 1);
            for (auto it : curr)
                ans.push_back (it);
            ans.push_back (t);
        }
    }
    return ans;
}

long long findGap(int T, int N)
{
    srand (time (0));
    if (T == 1)
    {
        long long a = 0, b = xmax;
        for (int i = 1, j = N; i<=j; i ++, j --)
            MinMax (a, b, &x[i], &x[j]), a = x[i] + 1, b = x[j] - 1;
        long long ans = x[2] - x[1];
        for (int i=1; i<N; i++)
            if (x[i + 1] - x[i] > ans)
                ans = x[i + 1] - x[i];
        return ans;
    }
    vector < long long > v = divide (0, xmax);
    long long ans = v[1] - v[0];
    for (int i=0; i<v.size () - 1; i++)
        ans = max (ans, v[i + 1] - v[i]);
	return ans;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:66:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0; i<v.size () - 1; i++)
                    ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 5928 KB Output is correct
2 Correct 0 ms 5928 KB Output is correct
3 Correct 0 ms 5928 KB Output is correct
4 Correct 0 ms 5928 KB Output is correct
5 Correct 0 ms 5928 KB Output is correct
6 Correct 0 ms 5928 KB Output is correct
7 Correct 0 ms 5928 KB Output is correct
8 Correct 0 ms 5928 KB Output is correct
9 Correct 0 ms 5928 KB Output is correct
10 Correct 0 ms 5928 KB Output is correct
11 Correct 1 ms 5928 KB Output is correct
12 Correct 1 ms 5928 KB Output is correct
13 Correct 0 ms 5928 KB Output is correct
14 Correct 2 ms 5928 KB Output is correct
15 Correct 1 ms 5928 KB Output is correct
16 Correct 13 ms 5928 KB Output is correct
17 Correct 13 ms 5928 KB Output is correct
18 Correct 16 ms 5928 KB Output is correct
19 Correct 14 ms 5928 KB Output is correct
20 Correct 15 ms 5928 KB Output is correct
21 Correct 59 ms 5928 KB Output is correct
22 Correct 55 ms 5928 KB Output is correct
23 Correct 47 ms 5928 KB Output is correct
24 Correct 50 ms 5928 KB Output is correct
25 Correct 43 ms 5928 KB Output is correct
26 Correct 57 ms 5928 KB Output is correct
27 Correct 53 ms 5928 KB Output is correct
28 Correct 46 ms 5928 KB Output is correct
29 Correct 53 ms 5928 KB Output is correct
30 Correct 39 ms 5928 KB Output is correct
31 Correct 0 ms 5928 KB Output is correct
32 Correct 0 ms 5928 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 5928 KB Output is correct
2 Partially correct 0 ms 5928 KB Partially correct
3 Partially correct 0 ms 5928 KB Partially correct
4 Partially correct 0 ms 5928 KB Partially correct
5 Partially correct 0 ms 5928 KB Partially correct
6 Partially correct 0 ms 5928 KB Partially correct
7 Partially correct 0 ms 5928 KB Partially correct
8 Partially correct 0 ms 5928 KB Partially correct
9 Partially correct 0 ms 5928 KB Partially correct
10 Runtime error 0 ms 5928 KB Execution killed with signal 8 (could be triggered by violating memory limits)
11 Partially correct 0 ms 6064 KB Partially correct
12 Partially correct 2 ms 6060 KB Partially correct
13 Partially correct 0 ms 5928 KB Partially correct
14 Partially correct 0 ms 5928 KB Partially correct
15 Partially correct 1 ms 6064 KB Partially correct
16 Partially correct 16 ms 6784 KB Partially correct
17 Partially correct 32 ms 6780 KB Partially correct
18 Partially correct 25 ms 6784 KB Partially correct
19 Partially correct 23 ms 6780 KB Partially correct
20 Runtime error 4 ms 5928 KB Execution killed with signal 8 (could be triggered by violating memory limits)
21 Partially correct 96 ms 9088 KB Partially correct
22 Partially correct 98 ms 9084 KB Partially correct
23 Partially correct 94 ms 9088 KB Partially correct
24 Partially correct 124 ms 9084 KB Partially correct
25 Partially correct 92 ms 9088 KB Partially correct
26 Partially correct 104 ms 9152 KB Partially correct
27 Partially correct 97 ms 9088 KB Partially correct
28 Partially correct 107 ms 9084 KB Partially correct
29 Partially correct 95 ms 9088 KB Partially correct
30 Runtime error 17 ms 5928 KB Execution killed with signal 8 (could be triggered by violating memory limits)
31 Runtime error 0 ms 5928 KB Execution killed with signal 8 (could be triggered by violating memory limits)
32 Runtime error 0 ms 5928 KB Execution killed with signal 8 (could be triggered by violating memory limits)