Contest Duration: - (local time) (100 minutes) Back to Home

Submission #1407819

Source Code Expand

Copy
```#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>>
#include <functional>
#include <string>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <nmmintrin.h>
#include <chrono>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
if (b == 0) return a;
return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
std::fill((T*)array, (T*)(array + N), val);
}

ll func(ll b, ll n) {
if (n < b)
return n;
return func(b, n/b) + n%b;
}

signed main() {
int n,l,q;
scnaf("%d", &n);
vector<int> h(n);
REP(i, n) {
scnaf("%d", &h[i]);
}

scanf("%d %d", &l, &q);

int db[100001][31] = {};

REP(i, n) {
db[i][0] = upper_bound(ALL(h), h[i] + l) - h.begin() - 1;
}

rep(j, 1, 31) {
REP(i, n) {
db[i][j] = db[db[i][j-1]][j - 1];
}
}

REP(i, q) {
int a, b;
scanf("%d %d", &a, &b);
a--, b--;
if (b < a)
swap(a, b);

int ans = 0;

int now = a;

while (now != b) {
auto buf = upper_bound(begin(db[now]), end(db[now]), b);
buf--;
ans += 1 << (buf - begin(db[now]));
now = *buf;
}

printf("%d\n", ans);
}

return 0;
}```

#### Submission Info

Submission Time 2017-07-09 16:03:22+0900 E - Tak and Hotels Gear C++14 (GCC 5.4.1) 0 2274 Byte WA 3159 ms 13312 KB

#### Compile Error

```./Main.cpp:9:20: warning: extra tokens at end of #include directive
#include <stdlib.h>>
^
./Main.cpp: In function ‘int main()’:
./Main.cpp:64:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scnaf("%d", &n);
^
./Main.cpp:67:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scnaf("%d", &h[i]);
^
./Main.cpp:70:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d", &l, &q);
^
./Main.cpp:86:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d", &a, &b);
^
```

#### Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 0 / 200 0 / 500
Status
 AC × 1
 AC × 1 WA × 3 TLE × 10
 AC × 1 WA × 4 TLE × 22
Set Name Test Cases
Sample example_01.txt
Subtask1 example_01.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt
All example_01.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt, subtask2_13.txt
Case Name Status Exec Time Memory
example_01.txt AC 5 ms 12416 KB
subtask1_01.txt TLE 3155 ms 12288 KB
subtask1_02.txt WA 4 ms 12288 KB
subtask1_03.txt TLE 3155 ms 12288 KB
subtask1_04.txt WA 5 ms 12416 KB
subtask1_05.txt TLE 3155 ms 12288 KB
subtask1_06.txt WA 5 ms 12416 KB
subtask1_07.txt TLE 3155 ms 12288 KB
subtask1_08.txt TLE 3155 ms 12288 KB
subtask1_09.txt TLE 3155 ms 12288 KB
subtask1_10.txt TLE 3155 ms 12288 KB
subtask1_11.txt TLE 3155 ms 12416 KB
subtask1_12.txt TLE 3155 ms 12288 KB
subtask1_13.txt TLE 3155 ms 12416 KB
subtask2_01.txt TLE 3155 ms 12672 KB
subtask2_02.txt WA 82 ms 13312 KB
subtask2_03.txt TLE 3155 ms 12672 KB
subtask2_04.txt TLE 3155 ms 12544 KB
subtask2_05.txt TLE 3155 ms 12544 KB
subtask2_06.txt TLE 3155 ms 12800 KB
subtask2_07.txt TLE 3159 ms 12800 KB
subtask2_08.txt TLE 3155 ms 12800 KB
subtask2_09.txt TLE 3159 ms 12800 KB
subtask2_10.txt TLE 3155 ms 12800 KB
subtask2_11.txt TLE 3155 ms 12672 KB
subtask2_12.txt TLE 3155 ms 12672 KB
subtask2_13.txt TLE 3155 ms 12672 KB