답안 #1092759

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1092759 2024-09-25T01:53:12 Z modwwe Escape Route 2 (JOI24_escape2) C++17
23 / 100
294 ms 46420 KB
#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>
#define int long long
//#define ll long long
#define down cout<<'\n';
#define debug cout<<" cucuucucuuu",down
#define NHP     ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define modwwe  int t;cin>>t; while(t--)
#define bit(i,j) (i>>j&1)
#define sobit(a) __builtin_popcountll(a)
#define task "test"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".out","w",stdout)
#define pb push_back
#define checktime   cerr << (double)clock() / CLOCKS_PER_SEC * 1000  << " ms";
using namespace std;
#define getchar_unlocked getchar

inline int scan()
{
    char c = getchar_unlocked();
    int x = 0;
    while (c < '0' || c > '9')
    {
        c = getchar_unlocked();
    }
    while (c >= '0' && c <= '9')
    {
        x = (x << 1) + (x << 3) + c - '0';
        c = getchar_unlocked();
    }
    return x;
}

void phongbeo();
const int inf = 1e17;
const int mod2 = 1e9 + 9;
const int  mod1 = 998244353;
struct icd
{
    long double a;
    int b;
};
struct ib
{
    int a;
    int b;
};
struct ic
{
    int a, b, c;
};
struct id
{
    int a, b, c, d;
};
struct ie
{
    int a, b, c, d, e;

};

int n, m, s1, s2, s4, s3, sf, k, s5, s6, mx, s7, s8, s9, mx2, res, dem2 = 0, dem = 0, s33, dem3, dem4, l, r, mid, l2, r2, center;
int  i, s10, s12,k1,k2,s11;
int kk;
int el = 19;
main()
{
    //fin(task);
    //fou(task);
    NHP
    /// cin>>s1;
///modwwe
    phongbeo();
    // checktime
}
int s,t;
vector<ib> a[100001];
int b[100001];
vector<int> c[100001];
ib d[100001];
ib st[17][100001];
vector<int> vv;
bool cmp(ib a,ib b)
{
    return a.a<b.a;
}
void phongbeo()
{
    cin>>n>>t;
    for(int i=1; i<n; i++)
    {
        cin>>k;
        b[i]=k;
        a[i].resize(k+1);
        c[i].resize(k+1);
        for(int j=1; j<=k; j++)
            cin>>a[i][j].a>>a[i][j].b,c[i][j]=++dem,d[dem]= {i,j};
        sort(a[i].begin()+1,a[i].end(),cmp);
        for(int j=k-1; j>=1; --j)
            a[i][j].b=min(a[i][j].b,a[i][j+1].b);
    }
    for(int i=1; i<n-1; i++)
    {
        vv.clear();
        for(int j=1; j<=b[i+1]; j++)
            vv.pb(a[i+1][j].a);
        for(int j=1; j<=b[i]; j++)
        {
            if(a[i][j].b>vv.back())
            {
                s3=vv.back()+t-a[i][j].a;
                st[0][c[i][j]]= {c[i+1][1],s3};
            }
            else
            {
                s2=lower_bound(vv.begin(),vv.end(),a[i][j].b)-vv.begin()+1;
                s3=a[i+1][s2].a-a[i][j].a;
                st[0][c[i][j]]= {c[i+1][s2],s3};
            }
        }
    }
    for(int i=1; i<17; i++)
        for(int j=1; j<=n; j++)
            st[i][j].a=st[i-1][st[i-1][j].a].a,
                    st[i][j].b=st[i-1][j].b+st[i-1][st[i-1][j].a].b;
    cin>>m;
    for(int i=1; i<=m; i++)
    {
        cin>>l>>r;
        if(l==r)
        {
            cout<<0,down continue;
        }
        for(int j=1; j<=b[l]; j++)
        {
            s=r-l-1;
            s3=c[l][j];
            s4=0;
            for(int f=0; f<17; f++)
                if(bit(s,f))
                    s4+=st[f][s3].b,s3=st[f][s3].a;
            if(j==1)s5=s4+a[r-1][d[s3].b].b-a[r-1][d[s3].b].a;
            else s5=min(s4+a[r-1][d[s3].b].b-a[r-1][d[s3].b].a,s5);
        }
        cout<<s5,down
    }
}

Compilation message

Main.cpp:67:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   67 | main()
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5208 KB Output is correct
2 Correct 51 ms 8272 KB Output is correct
3 Correct 52 ms 8548 KB Output is correct
4 Correct 69 ms 9808 KB Output is correct
5 Correct 58 ms 8788 KB Output is correct
6 Correct 74 ms 10064 KB Output is correct
7 Correct 73 ms 9808 KB Output is correct
8 Correct 59 ms 8784 KB Output is correct
9 Correct 72 ms 9828 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5208 KB Output is correct
2 Correct 51 ms 8272 KB Output is correct
3 Correct 52 ms 8548 KB Output is correct
4 Correct 69 ms 9808 KB Output is correct
5 Correct 58 ms 8788 KB Output is correct
6 Correct 74 ms 10064 KB Output is correct
7 Correct 73 ms 9808 KB Output is correct
8 Correct 59 ms 8784 KB Output is correct
9 Correct 72 ms 9828 KB Output is correct
10 Correct 2 ms 5212 KB Output is correct
11 Incorrect 69 ms 7676 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5208 KB Output is correct
2 Correct 51 ms 8272 KB Output is correct
3 Correct 52 ms 8548 KB Output is correct
4 Correct 69 ms 9808 KB Output is correct
5 Correct 58 ms 8788 KB Output is correct
6 Correct 74 ms 10064 KB Output is correct
7 Correct 73 ms 9808 KB Output is correct
8 Correct 59 ms 8784 KB Output is correct
9 Correct 72 ms 9828 KB Output is correct
10 Correct 156 ms 37340 KB Output is correct
11 Correct 294 ms 46420 KB Output is correct
12 Correct 267 ms 46272 KB Output is correct
13 Correct 217 ms 45140 KB Output is correct
14 Correct 287 ms 46196 KB Output is correct
15 Correct 282 ms 46160 KB Output is correct
16 Correct 176 ms 37204 KB Output is correct
17 Correct 293 ms 46164 KB Output is correct
18 Correct 105 ms 39508 KB Output is correct
19 Correct 86 ms 39312 KB Output is correct
20 Correct 97 ms 39548 KB Output is correct
21 Correct 146 ms 39516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5208 KB Output is correct
2 Correct 51 ms 8272 KB Output is correct
3 Correct 52 ms 8548 KB Output is correct
4 Correct 69 ms 9808 KB Output is correct
5 Correct 58 ms 8788 KB Output is correct
6 Correct 74 ms 10064 KB Output is correct
7 Correct 73 ms 9808 KB Output is correct
8 Correct 59 ms 8784 KB Output is correct
9 Correct 72 ms 9828 KB Output is correct
10 Correct 2 ms 5212 KB Output is correct
11 Incorrect 69 ms 7676 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5208 KB Output is correct
2 Correct 2 ms 5292 KB Output is correct
3 Incorrect 273 ms 10704 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5208 KB Output is correct
2 Correct 51 ms 8272 KB Output is correct
3 Correct 52 ms 8548 KB Output is correct
4 Correct 69 ms 9808 KB Output is correct
5 Correct 58 ms 8788 KB Output is correct
6 Correct 74 ms 10064 KB Output is correct
7 Correct 73 ms 9808 KB Output is correct
8 Correct 59 ms 8784 KB Output is correct
9 Correct 72 ms 9828 KB Output is correct
10 Correct 2 ms 5212 KB Output is correct
11 Incorrect 69 ms 7676 KB Output isn't correct
12 Halted 0 ms 0 KB -