Submission #1757280


Source Code Expand

#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>=0;i--)
#define I(n) scanf("%d", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#include <bits/stdc++.h>
using namespace std;


int load[200001][2],n,s,g,x,y,l,r,prex,prey,llimy,rlimy;
double ret,incll,inclr,d_incll,d_inclr;

double len(int ax, int ay, int bx, int by){
    double dx = ax - bx;
    double dy = ay - by;
    return sqrt(dx*dx + dy*dy);
}

int main(){
    I(n);I(s);I(g);
    REP(i,n+1){ I(load[i][0]); I(load[i][1]); }
    load[n][0] = load[n][1] = g;
    prex = s;

    while(1){
        y = llimy = rlimy = prey+1; // dy = 1
        l = load[y][0];
        r = load[y][1];
        incll = l-prex;
        inclr = r-prex;

        for(;y<=n;y++){
            l = load[y][0];
            r = load[y][1];

            d_incll = (double)(l-prex)/(y-prey);
            d_inclr = (double)(r-prex)/(y-prey);

            if (inclr < d_incll){
                x = load[rlimy][1];
                ret += len(prex,prey,x,rlimy);
                prex = x;
                prey = rlimy;
                break;
            }
            if (incll > d_inclr){
                x = load[llimy][0];
                ret += len(prex,prey,x,llimy);
                prex = x;
                prey = llimy;
                break;
            }
            if (incll < d_incll){
                incll = d_incll;
                llimy = y;
            }
            if (inclr > d_inclr){
                inclr = d_inclr;
                rlimy = y;
            }
        }
        if(y==n){
            ret += len(prex,prey,g,n);
            break;
        }
    }
    printf("%.17f\n",ret);
}

Submission Info

Submission Time
Task D - レースゲーム
User omi
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1800 Byte
Status TLE
Exec Time 2103 ms
Memory 1792 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:21:9: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     I(n);I(s);I(g);
         ^
./Main.cpp:21:14: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     I(n);I(s);I(g);
              ^
./Main.cpp:21:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     I(n);I(s);I(g);
                   ^
./Main.cpp:22:30: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     REP(i,n+1){ I(load[i][0]); I(load[i][1]); }
                              ^
./Main.cpp:22:45: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     REP(i,n+1){ I(load[i][0]); I(load[i][1]); }
                     ...

Judge Result

Set Name All
Score / Max Score 0 / 100
Status
AC × 20
TLE × 6
Set Name Test Cases
All 00_sample1.txt, 00_sample2.txt, 01_rnd_large_00.txt, 01_rnd_large_01.txt, 01_rnd_large_02.txt, 01_rnd_small_00.txt, 01_rnd_small_01.txt, 01_rnd_small_02.txt, 02_narrowrnd_large_00.txt, 02_narrowrnd_large_01.txt, 02_narrowrnd_small_00.txt, 02_narrowrnd_small_01.txt, 03_zigzag_large_00.txt, 03_zigzag_small_00.txt, 04_middle_large_00.txt, 04_middle_large_01.txt, 04_middle_large_02.txt, 04_middle_small_00.txt, 04_middle_small_01.txt, 04_middle_small_02.txt, 05_turnleft_large_00.txt, 05_turnleft_small_00.txt, 06_turnright_large_00.txt, 06_turnright_small_00.txt, 07_free_large_00.txt, 07_free_small_00.txt
Case Name Status Exec Time Memory
00_sample1.txt AC 1 ms 256 KB
00_sample2.txt TLE 2103 ms 256 KB
01_rnd_large_00.txt AC 46 ms 1792 KB
01_rnd_large_01.txt TLE 2103 ms 1792 KB
01_rnd_large_02.txt AC 46 ms 1792 KB
01_rnd_small_00.txt TLE 2103 ms 256 KB
01_rnd_small_01.txt AC 1 ms 256 KB
01_rnd_small_02.txt AC 1 ms 256 KB
02_narrowrnd_large_00.txt AC 44 ms 1792 KB
02_narrowrnd_large_01.txt AC 44 ms 1792 KB
02_narrowrnd_small_00.txt AC 1 ms 256 KB
02_narrowrnd_small_01.txt AC 1 ms 256 KB
03_zigzag_large_00.txt AC 41 ms 1792 KB
03_zigzag_small_00.txt AC 1 ms 256 KB
04_middle_large_00.txt AC 45 ms 1792 KB
04_middle_large_01.txt AC 45 ms 1792 KB
04_middle_large_02.txt AC 46 ms 1792 KB
04_middle_small_00.txt AC 1 ms 256 KB
04_middle_small_01.txt AC 1 ms 256 KB
04_middle_small_02.txt AC 1 ms 256 KB
05_turnleft_large_00.txt AC 46 ms 1792 KB
05_turnleft_small_00.txt AC 1 ms 256 KB
06_turnright_large_00.txt AC 575 ms 1792 KB
06_turnright_small_00.txt TLE 2103 ms 256 KB
07_free_large_00.txt TLE 2103 ms 1792 KB
07_free_small_00.txt TLE 2103 ms 256 KB