Submission #855504


Source Code Expand

Copy
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

const int N=101000;
int n,x[N],l,q,p[N][22],u,v;
int main() {
	scanf("%d",&n);
	rep(i,0,n) scanf("%d",x+i);
	scanf("%d",&l);
	scanf("%d",&q);
	rep(i,0,n) {
		p[i][0]=upper_bound(x,x+n,x[i]+l)-x-1;
	}
	rep(j,1,20) rep(i,0,n) p[i][j]=p[p[i][j-1]][j-1];
	rep(i,0,q) {
		scanf("%d%d",&u,&v);
		--u; --v; if (u>v) swap(u,v);
		int r=0;
		per(j,0,20) if (p[u][j]<=v) {
			u=p[u][j],r+=(1<<j);
		}
		printf("%d\n",r);
	}
}

Submission Info

Submission Time
Task E - Tak and Hotels
User apiad
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1093 Byte
Status WA
Exec Time 146 ms
Memory 9728 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:29:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
                ^
./Main.cpp:30:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  rep(i,0,n) scanf("%d",x+i);
                            ^
./Main.cpp:31:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&l);
                ^
./Main.cpp:32:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&q);
                ^
./Main.cpp:38:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&u,&v);
                      ^

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 0 / 200 0 / 500
Status
AC × 1
AC × 1
WA × 13
AC × 1
WA × 26
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 2 ms 128 KB
subtask1_01.txt WA 2 ms 128 KB
subtask1_02.txt WA 2 ms 128 KB
subtask1_03.txt WA 3 ms 256 KB
subtask1_04.txt WA 3 ms 256 KB
subtask1_05.txt WA 3 ms 256 KB
subtask1_06.txt WA 3 ms 256 KB
subtask1_07.txt WA 3 ms 256 KB
subtask1_08.txt WA 3 ms 256 KB
subtask1_09.txt WA 3 ms 256 KB
subtask1_10.txt WA 3 ms 256 KB
subtask1_11.txt WA 3 ms 256 KB
subtask1_12.txt WA 3 ms 256 KB
subtask1_13.txt WA 3 ms 256 KB
subtask2_01.txt WA 143 ms 9600 KB
subtask2_02.txt WA 145 ms 9728 KB
subtask2_03.txt WA 130 ms 9472 KB
subtask2_04.txt WA 70 ms 6144 KB
subtask2_05.txt WA 88 ms 6400 KB
subtask2_06.txt WA 106 ms 9344 KB
subtask2_07.txt WA 136 ms 9600 KB
subtask2_08.txt WA 142 ms 9728 KB
subtask2_09.txt WA 142 ms 9728 KB
subtask2_10.txt WA 146 ms 9728 KB
subtask2_11.txt WA 145 ms 8960 KB
subtask2_12.txt WA 110 ms 9728 KB
subtask2_13.txt WA 105 ms 9344 KB