Submission #856467


Source Code Expand

Copy
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
#define mod 1000000000
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define Lson L, mid, rt<<1
#define Rson mid+1, R, rt<<1|1
const int maxn=1e5+10;
using namespace std;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}
int n,m,k,t,l[maxn],r[maxn],ans[maxn];
ll a[maxn],p;
vi go[maxn],to[maxn],all;
void init()
{
    for(int i=0;i<=n-1;i++)
    {
        r[i]=lower_bound(a,a+n,a[i]+p)-a;
        if(r[i]==n||a[r[i]]>a[i]+p)r[i]--;
        l[i]=lower_bound(a,a+n,a[i]-p)-a;
    }
}
int main()
{
    int i,j;
    scanf("%d",&n);
    rep(i,0,n-1)scanf("%lld",&a[i]);
    scanf("%lld",&p);
    init();
    int q;
    scanf("%d",&q);
    rep(i,0,q-1)
    {
        int c,d;
        scanf("%d%d",&c,&d);
        c--,d--;
        all.pb(d);
        if(c<d)go[c].pb(i);
        if(c>d)to[c].pb(i);
    }
    rep(i,0,n-1)
    {
        for(int x:go[i])
        {
            ans[x]++;
            if(r[i]<all[x])go[r[i]].pb(x);
        }
    }
    for(i=n-1;i>=0;i--)
    {
        for(int x:to[i])
        {
            ans[x]++;
            if(l[i]>all[x])to[l[i]].pb(x);
        }
    }
    rep(i,0,q-1)printf("%d\n",ans[i]);
    //system("Pause");
    return 0;
}

Submission Info

Submission Time
Task E - Tak and Hotels
User mxzf0213
Language C++14 (GCC 5.4.1)
Score 200
Code Size 1814 Byte
Status MLE
Exec Time 3242 ms
Memory 924664 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:48:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
                   ^
./Main.cpp:49:36: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     rep(i,0,n-1)scanf("%lld",&a[i]);
                                    ^
./Main.cpp:50:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&p);
                     ^
./Main.cpp:53:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&q);
                   ^
./Main.cpp:57:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&c,&d);
                         ...

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 200 / 200 0 / 500
Status
AC × 1
AC × 14
AC × 17
TLE × 8
MLE × 2
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 10 ms 4992 KB
subtask1_01.txt AC 12 ms 4992 KB
subtask1_02.txt AC 10 ms 4992 KB
subtask1_03.txt AC 12 ms 5120 KB
subtask1_04.txt AC 20 ms 6656 KB
subtask1_05.txt AC 12 ms 4992 KB
subtask1_06.txt AC 13 ms 5376 KB
subtask1_07.txt AC 13 ms 4992 KB
subtask1_08.txt AC 11 ms 4992 KB
subtask1_09.txt AC 13 ms 5376 KB
subtask1_10.txt AC 18 ms 6016 KB
subtask1_11.txt AC 17 ms 6272 KB
subtask1_12.txt AC 18 ms 6144 KB
subtask1_13.txt AC 16 ms 6016 KB
subtask2_01.txt TLE 3242 ms 924664 KB
subtask2_02.txt TLE 3231 ms 826360 KB
subtask2_03.txt MLE 1206 ms 257784 KB
subtask2_04.txt AC 74 ms 8060 KB
subtask2_05.txt MLE 2127 ms 521084 KB
subtask2_06.txt AC 107 ms 9720 KB
subtask2_07.txt TLE 3239 ms 857080 KB
subtask2_08.txt TLE 3231 ms 823544 KB
subtask2_09.txt TLE 3235 ms 823160 KB
subtask2_10.txt TLE 3238 ms 846712 KB
subtask2_11.txt TLE 3237 ms 844792 KB
subtask2_12.txt TLE 3238 ms 857080 KB
subtask2_13.txt AC 110 ms 10232 KB