Submission #855607


Source Code Expand

Copy
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <deque>
#include <queue>
#include <cstring>
#include <set>
#include <list>
#include <map>
#include <random>
#include <unordered_map>
#include <stdio.h>

using namespace std;

typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<bool> vb;
typedef std::vector<string> vs;
typedef std::vector<double> vd;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<int> > vvi;
typedef vector<vvi> vvvi;
typedef vector<vll> vvll;
typedef std::vector<std::pair<int, int> > vpi;
typedef vector<vpi> vvpi;
typedef std::pair<int, int> pi;
typedef std::pair<ll, ll> pll;
typedef std::vector<pll> vpll;

const long long mod = 1000000007;

#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define forn(i, a, b) for(int i = a; i < b; i++)

#define pb push_back
#define mp make_pair

int main()
{


    int n;
    scanf("%d", &n);
    vi x(n);
    forn(i,0,n) scanf("%d", &x[i]);
    int l;
    scanf("%d", &l);
    int q;
    scanf("%d", &q);
    vvi d(20, vi(n));
    forn(i,0,n) {
        d[0][i] = (upper_bound(all(x), x[i] + l) - x.begin()) - 1;
    }
    forn(k,1,20) {
        forn(i,0,n) {
            d[k][i] = d[k-1][d[k-1][i]];
        }
    }
    vi d2(1,1);
    forn(i,0,20) d2.pb(d2.back()*2);
    forn(i,0,q) {
        int a,b;
        scanf("%d %d", &a, &b);
        if(a>b) swap(a,b);
        a--;
        b--;
        int ans = 0;
        int cur = 19;
        while(a<b) {
            if(d[cur][a] <= b) {
                a= d[cur][a];
                ans += d2[cur];
            }
            cur--;
        }
        printf("%d\n", ans);
    }
    
    
}

Submission Info

Submission Time
Task E - Tak and Hotels
User Vercingetorix
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1799 Byte
Status WA
Exec Time 649 ms
Memory 9080 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:47:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
                    ^
./Main.cpp:49:35: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     forn(i,0,n) scanf("%d", &x[i]);
                                   ^
./Main.cpp:51:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &l);
                    ^
./Main.cpp:53:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &q);
                    ^
./Main.cpp:67:31: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &a, &b);
                      ...

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 0 / 200 0 / 500
Status
AC × 1
AC × 1
WA × 3
RE × 10
AC × 1
WA × 4
RE × 22
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 4 ms 256 KB
subtask1_01.txt RE 649 ms 256 KB
subtask1_02.txt WA 4 ms 256 KB
subtask1_03.txt RE 193 ms 256 KB
subtask1_04.txt WA 5 ms 384 KB
subtask1_05.txt RE 188 ms 256 KB
subtask1_06.txt WA 4 ms 256 KB
subtask1_07.txt RE 192 ms 256 KB
subtask1_08.txt RE 192 ms 256 KB
subtask1_09.txt RE 192 ms 256 KB
subtask1_10.txt RE 189 ms 384 KB
subtask1_11.txt RE 193 ms 384 KB
subtask1_12.txt RE 193 ms 256 KB
subtask1_13.txt RE 193 ms 256 KB
subtask2_01.txt RE 227 ms 8832 KB
subtask2_02.txt WA 152 ms 9080 KB
subtask2_03.txt RE 234 ms 8832 KB
subtask2_04.txt RE 219 ms 6016 KB
subtask2_05.txt RE 215 ms 5888 KB
subtask2_06.txt RE 226 ms 8832 KB
subtask2_07.txt RE 229 ms 8832 KB
subtask2_08.txt RE 229 ms 8832 KB
subtask2_09.txt RE 229 ms 8832 KB
subtask2_10.txt RE 229 ms 8832 KB
subtask2_11.txt RE 225 ms 8192 KB
subtask2_12.txt RE 231 ms 8832 KB
subtask2_13.txt RE 230 ms 8832 KB