답안 #950077

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
950077 2024-03-20T04:59:15 Z Abito Tourism (JOI23_tourism) C++17
7 / 100
67 ms 40068 KB
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define ppb pop_back
#define ep insert
#define endl '\n'
#define elif else if
#define pow pwr
#define sqrt sqrtt
#define int long long
#define ll long long
typedef unsigned long long ull;
using namespace std;
const int N=1e5+5;
int n,m,q,b[N],stmn[20][N],stmx[20][N],lg[N];
vector<int> adj[N];
void build(){
    for (int i=1;i<=m;i++) stmn[0][i]=stmx[0][i]=b[i];
    for (int i=1;i<20;i++){
        for (int j=1;j+(1<<i)<=m+1;j++){
            stmx[i][j]=max(stmx[i-1][j],stmx[i-1][j+(1<<(i-1))]);
            stmn[i][j]=min(stmn[i-1][j],stmn[i-1][j+(1<<(i-1))]);
        }
    }
    return;
}
int query(int l,int r){
    int i=lg[r-l+1];
    return max(stmx[i][l],stmx[i][r-(1<<i)+1])-min(stmn[i][l],stmn[i][r-(1<<i)+1])+1;
}
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    for (int i=2;i<N;i++) lg[i]=lg[i/2]+1;
    cin>>n>>m>>q;
    for (int i=1;i<n;i++){
        int x,y;
        cin>>x>>y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    for (int i=1;i<=m;i++) cin>>b[i];
    build();
    while (q--){
        int l,r;
        cin>>l>>r;
        cout<<query(l,r)<<endl;
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 10840 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 10840 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 12888 KB Output is correct
2 Correct 3 ms 21084 KB Output is correct
3 Correct 4 ms 23132 KB Output is correct
4 Correct 40 ms 37464 KB Output is correct
5 Correct 37 ms 36184 KB Output is correct
6 Correct 40 ms 38656 KB Output is correct
7 Correct 53 ms 40016 KB Output is correct
8 Correct 52 ms 40016 KB Output is correct
9 Correct 57 ms 40016 KB Output is correct
10 Correct 52 ms 40020 KB Output is correct
11 Correct 51 ms 40068 KB Output is correct
12 Correct 67 ms 39896 KB Output is correct
13 Correct 46 ms 39960 KB Output is correct
14 Correct 45 ms 40016 KB Output is correct
15 Correct 32 ms 13660 KB Output is correct
16 Correct 48 ms 39692 KB Output is correct
17 Correct 31 ms 35164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 10844 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 10844 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 10840 KB Output isn't correct
2 Halted 0 ms 0 KB -