Submission #913619


Source Code Expand

Copy
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int n, m, l, a, b, d[100010], dt[100010][20];

int main()
{
    scanf("%d", &n);
    for(int i = 0 ; i < n ; i++ ) scanf("%d", d+i);
    scanf("%d%d", &l, &m);
    for(int i = 0 ; i < n ; i++ )
        dt[i][0] = (int)(upper_bound(d+i, d+n, d[i]+l) - d) - 1;
    for(int k = 1 ; k < 20 ; k++ ) for(int i = 0 ; i < n ; i++ )
        dt[i][k] = dt[dt[i][k-1]][k-1];
    while( m-- )
    {
        int ans = 1;
        scanf("%d%d", &a, &b), a--, b--;
        if( a < b ) swap(a, b);
        for(int i = 19 ; i >= 0 ; i-- )
            if( dt[b][i] < a ) b = dt[b][i], ans+=(1<<i);
        printf("%d\n", ans);
    }
    return 0;
}

Submission Info

Submission Time
Task E - Tak and Hotels
User JKJeong
Language C++14 (GCC 5.4.1)
Score 700
Code Size 759 Byte
Status AC
Exec Time 81 ms
Memory 9088 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:12:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
                    ^
./Main.cpp:13:51: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 0 ; i < n ; i++ ) scanf("%d", d+i);
                                                   ^
./Main.cpp:14:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &l, &m);
                          ^
./Main.cpp:22:40: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &a, &b), a--, b--;
                                        ^

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 200 / 200 500 / 500
Status
AC × 1
AC × 14
AC × 27
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 3 ms 256 KB
subtask1_01.txt AC 3 ms 256 KB
subtask1_02.txt AC 3 ms 256 KB
subtask1_03.txt AC 3 ms 384 KB
subtask1_04.txt AC 3 ms 384 KB
subtask1_05.txt AC 3 ms 384 KB
subtask1_06.txt AC 3 ms 256 KB
subtask1_07.txt AC 3 ms 256 KB
subtask1_08.txt AC 3 ms 384 KB
subtask1_09.txt AC 3 ms 384 KB
subtask1_10.txt AC 3 ms 384 KB
subtask1_11.txt AC 3 ms 384 KB
subtask1_12.txt AC 3 ms 384 KB
subtask1_13.txt AC 3 ms 384 KB
subtask2_01.txt AC 74 ms 8832 KB
subtask2_02.txt AC 81 ms 8960 KB
subtask2_03.txt AC 74 ms 8832 KB
subtask2_04.txt AC 40 ms 5760 KB
subtask2_05.txt AC 50 ms 5888 KB
subtask2_06.txt AC 60 ms 8576 KB
subtask2_07.txt AC 77 ms 8960 KB
subtask2_08.txt AC 80 ms 8960 KB
subtask2_09.txt AC 80 ms 8960 KB
subtask2_10.txt AC 81 ms 8960 KB
subtask2_11.txt AC 78 ms 8320 KB
subtask2_12.txt AC 59 ms 9088 KB
subtask2_13.txt AC 60 ms 8576 KB