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

Submission #863299

Source Code Expand

Copy
```#define _CRT_SECURE_NO_WARNINGS
#include<sstream>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())

int ans[100000];

vector<pair<int,int>> query[100000];
vector<int> child[100000];
vector<int> par;

int N;
int x[100000];
int L, Q;

void dfs(int u) {
for (auto p : query[u]) {
ans[p.second] = par.end() - upper_bound(all(par), p.first, greater<int>()) + 1;
}

par.push_back(u);
for (int v : child[u]) {
dfs(v);
}
par.pop_back();
}

int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> N;
rep(i, N)cin >> x[i];
cin >> L >> Q;
rep(i, Q) {
int a, b;
cin >> a >> b;
a--; b--;
if (a > b) {
a = N - a - 1;
b = N - b - 1;
}
query[a].emplace_back(b, i);
}
rep(i,N-1) {
if (query[i].empty() && child[i].empty())continue;
int nxt = upper_bound(x, x + N, x[i] + L) - 1 - x;
child[nxt].push_back(i);
}
dfs(N - 1);
rep(i, Q)cout << ans[i] << endl;

return 0;
}```

#### Submission Info

Submission Time 2016-09-03 21:14:53+0900 E - Tak and Hotels hirokazu1020 C++14 (GCC 5.4.1) 0 1417 Byte WA 819 ms 18168 KB

#### Judge Result

Score / Max Score 0 / 0 0 / 200 0 / 500
Status
 AC × 1
 AC × 8 WA × 6
 AC × 15 WA × 12
Set Name Test Cases
Sample example_01.txt
Case Name Status Exec Time Memory
example_01.txt AC 13 ms 4992 KB
subtask1_01.txt WA 13 ms 4992 KB
subtask1_02.txt AC 13 ms 4992 KB
subtask1_03.txt AC 20 ms 4992 KB
subtask1_04.txt AC 18 ms 5120 KB
subtask1_05.txt AC 20 ms 4992 KB
subtask1_06.txt AC 15 ms 4992 KB
subtask1_07.txt AC 17 ms 4992 KB
subtask1_08.txt AC 20 ms 4992 KB
subtask1_09.txt WA 18 ms 4992 KB
subtask1_10.txt WA 18 ms 4992 KB
subtask1_11.txt WA 18 ms 4992 KB
subtask1_12.txt WA 18 ms 4992 KB
subtask1_13.txt WA 20 ms 4992 KB
subtask2_01.txt AC 687 ms 11648 KB
subtask2_02.txt AC 696 ms 18168 KB
subtask2_03.txt AC 688 ms 11264 KB
subtask2_04.txt AC 423 ms 7164 KB
subtask2_05.txt WA 515 ms 8320 KB
subtask2_06.txt AC 784 ms 8316 KB
subtask2_07.txt WA 819 ms 10240 KB
subtask2_08.txt WA 803 ms 14972 KB
subtask2_09.txt WA 696 ms 14972 KB
subtask2_10.txt WA 806 ms 14972 KB
subtask2_11.txt WA 732 ms 14460 KB
subtask2_12.txt AC 686 ms 17404 KB
subtask2_13.txt AC 642 ms 8316 KB