# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
95703 |
2019-02-02T07:50:41 Z |
jeff |
Gap (APIO16_gap) |
C++14 |
|
237 ms |
2288 KB |
#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
inline unsigned long long mde(unsigned long long a, unsigned long long b, unsigned long long c) {
unsigned long long t = 0, y = 0, z = 0, i;
stack<unsigned long long> st;
while (b) st.push(b % 2), b /= 2;
while (!st.empty()) {
z <<= 1;
y <<= 1;
z += a * st.top();
st.pop();
y += z / (1LL << 62);
z %= (1LL << 62);
}
t += y / c;
y %= c;
for (i = 0; i < 62; ++i) {
y <<= 1;
z <<= 1;
t <<= 1;
y += z / (1LL << 62);
z %= (1LL << 62);
t += y / c;
y %= c;
}
return t;
}
vector<long long> v;
long long findGap(int T, int N) {
long long l, r, y, z, ls = -1, rs = 0, a, b = 0, i;
if (T == 1) {
l = 0;
r = 1000000000000000000;
for (i = 0; i < (N + 1) / 2; ++i) {
MinMax(l, r, &a, &b);
if (a < 0 && b < 0) break;
v.push_back(a);
v.push_back(b);
l = a + 1;
r = b - 1;
if (l > r) break;
}
sort(v.begin(), v.end());
for (i = 1; i < v.size(); ++i) if (v[i - 1] > -1) rs = max(rs, v[i] - v[i - 1]);
return rs;
}
MinMax(0, 1000000000000000000, &y, &z);
for (i = 0; i < N - 1; ++i) {
a = y + mde(z - y, i, N - 1);
b = y + mde(z - y, i + 1, N - 1) - 1;
if (a >= b) continue;
MinMax(a, b, &l, &r);
if (l < 0 && r < 0) continue;
if (ls > -1) rs = max(rs, l - ls);
ls = r;
}
return max(rs, z - ls);
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:48:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (i = 1; i < v.size(); ++i) if (v[i - 1] > -1) rs = max(rs, v[i] - v[i - 1]);
~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
380 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
14 ms |
860 KB |
Output is correct |
17 |
Correct |
13 ms |
892 KB |
Output is correct |
18 |
Correct |
14 ms |
888 KB |
Output is correct |
19 |
Correct |
13 ms |
892 KB |
Output is correct |
20 |
Correct |
12 ms |
888 KB |
Output is correct |
21 |
Correct |
52 ms |
2288 KB |
Output is correct |
22 |
Correct |
50 ms |
2280 KB |
Output is correct |
23 |
Correct |
52 ms |
2284 KB |
Output is correct |
24 |
Correct |
51 ms |
2288 KB |
Output is correct |
25 |
Correct |
44 ms |
2288 KB |
Output is correct |
26 |
Correct |
51 ms |
2288 KB |
Output is correct |
27 |
Correct |
50 ms |
2288 KB |
Output is correct |
28 |
Correct |
52 ms |
2288 KB |
Output is correct |
29 |
Correct |
50 ms |
2284 KB |
Output is correct |
30 |
Correct |
39 ms |
2288 KB |
Output is correct |
31 |
Correct |
2 ms |
376 KB |
Output is correct |
32 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
5 ms |
504 KB |
Output is correct |
15 |
Correct |
5 ms |
376 KB |
Output is correct |
16 |
Correct |
58 ms |
504 KB |
Output is correct |
17 |
Correct |
58 ms |
676 KB |
Output is correct |
18 |
Correct |
57 ms |
612 KB |
Output is correct |
19 |
Correct |
57 ms |
612 KB |
Output is correct |
20 |
Correct |
49 ms |
504 KB |
Output is correct |
21 |
Correct |
228 ms |
1272 KB |
Output is correct |
22 |
Correct |
237 ms |
1156 KB |
Output is correct |
23 |
Correct |
232 ms |
1144 KB |
Output is correct |
24 |
Correct |
231 ms |
1144 KB |
Output is correct |
25 |
Correct |
223 ms |
1144 KB |
Output is correct |
26 |
Correct |
230 ms |
1196 KB |
Output is correct |
27 |
Correct |
225 ms |
1144 KB |
Output is correct |
28 |
Correct |
228 ms |
1272 KB |
Output is correct |
29 |
Correct |
228 ms |
1144 KB |
Output is correct |
30 |
Correct |
194 ms |
1276 KB |
Output is correct |
31 |
Correct |
2 ms |
376 KB |
Output is correct |
32 |
Correct |
2 ms |
376 KB |
Output is correct |