Submission #5546611


Source Code Expand

#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define rep(i,a,b) for(register int i=(a);i<=(b);i++)
#define dep(i,a,b) for(register int i=(a);i>=(b);i--)
using namespace std;
const int maxn=2e5+5;
//const double pi=acos(-1.0);
//const double eps=1e-9;
//const ll mo=1e9+7;
int n,m,k,l,q;
int a[maxn],c[maxn];
int f[maxn][25];
int ans,tmp,cnt;
int flag;
char s[maxn];
bool ok[maxn];
int main()
{
    int T,cas=1;
    //scanf("%d",&T);
    while(scanf("%d",&n)!=EOF)
    {
        rep(i,0,n) c[i]=1;
        int j=1;
        rep(i,1,n) scanf("%d",&a[i]);
        scanf("%d",&l);
        rep(i,0,20)
        for(int j=0;j<=n;j++)
        f[j][i]=inf;
        rep(i,1,n){
            while(a[i]>a[j]+l) {f[j][0]=i-1;j++;}
        }
        rep(i,1,20)
        {
            c[i]=c[i-1]<<1;
            for(int j=1;j<=n;j++)
            if(f[j][i-1]!=inf){
                //cout<<f[j][i-1]<<endl;
                f[j][i]=f[f[j][i-1]][i-1];
            }
        }
        ans=0;
        scanf("%d",&q);
        rep(t,1,q)
        {
            int x,y,ans=0;
            scanf("%d%d",&x,&y);
            if(x>y) swap(x,y);
            dep(i,20,0)
            {
                if(f[x][i]<y)
                {
                    x=f[x][i];
                    ans+=c[i];
                }
            }
            printf("%d\n",ans+1);
        }
    }
    return 0;
}

Submission Info

Submission Time
Task E - Tak and Hotels
User IGVA
Language C++14 (GCC 5.4.1)
Score 700
Code Size 1449 Byte
Status AC
Exec Time 76 ms
Memory 13184 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:26:37: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         rep(i,1,n) scanf("%d",&a[i]);
                                     ^
./Main.cpp:27:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&l);
                       ^
./Main.cpp:44:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&q);
                       ^
./Main.cpp:48:32: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d%d",&x,&y);
                                ^

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 1 ms 2304 KB
subtask1_01.txt AC 2 ms 2304 KB
subtask1_02.txt AC 2 ms 2304 KB
subtask1_03.txt AC 2 ms 2432 KB
subtask1_04.txt AC 2 ms 2432 KB
subtask1_05.txt AC 2 ms 2432 KB
subtask1_06.txt AC 2 ms 2304 KB
subtask1_07.txt AC 2 ms 2304 KB
subtask1_08.txt AC 2 ms 2432 KB
subtask1_09.txt AC 2 ms 2432 KB
subtask1_10.txt AC 2 ms 2432 KB
subtask1_11.txt AC 2 ms 2432 KB
subtask1_12.txt AC 2 ms 2432 KB
subtask1_13.txt AC 2 ms 2432 KB
subtask2_01.txt AC 69 ms 12928 KB
subtask2_02.txt AC 76 ms 13056 KB
subtask2_03.txt AC 68 ms 12928 KB
subtask2_04.txt AC 37 ms 10496 KB
subtask2_05.txt AC 46 ms 10624 KB
subtask2_06.txt AC 55 ms 12672 KB
subtask2_07.txt AC 71 ms 13056 KB
subtask2_08.txt AC 75 ms 13056 KB
subtask2_09.txt AC 75 ms 13056 KB
subtask2_10.txt AC 75 ms 13056 KB
subtask2_11.txt AC 73 ms 13056 KB
subtask2_12.txt AC 57 ms 13184 KB
subtask2_13.txt AC 55 ms 12672 KB