답안 #973566

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
973566 2024-05-02T07:22:25 Z vjudge1 Passport (JOI23_passport) C++17
0 / 100
2000 ms 11280 KB
#include <time.h>
#include <cstdlib>
#include <stack>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <map>
#include <set>
#include <iterator>
#include <deque>
#include <queue>
#include <sstream>
#include <array>
#include <string>
#include <tuple>
#include <chrono>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <list>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <bitset>

using namespace std;

int tt = 1, n;
int a[200005], lf[200005], rg[200005];
int mn[4 * 200005], mx[4 * 200005];
void up(int l, int r, int pos, int num, int num1, int vv){
    if(l > pos || r < pos) return;
    if(l == r){
        mn[vv] = num;
        mx[vv] = num1;
        return; 
    }
    int mid = (l + r) / 2;
    up(l, mid, pos, num, num1, vv * 2);
    up(mid + 1, r, pos, num, num1, vv * 2 + 1);
    mn[vv] = min(mn[vv * 2], mn[vv * 2 + 1]);
    mx[vv] = max(mx[vv * 2], mx[vv * 2 + 1]);
}
int sbor(int l, int r, int l1, int r1, int vv){
    if(l > r1 || l1 > r) return 1e9;
    if(l >= l1 && r1 >= r) return mn[vv];
    int mid = (l + r) / 2;
    return min(sbor(l, mid, l1, r1, vv * 2), sbor(mid + 1, r, l1, r1, vv * 2 + 1));
}
int sbor1(int l, int r, int l1, int r1, int vv){
    if(l > r1 || l1 > r) return 0;
    if(l >= l1 && r1 >= r) return mx[vv];
    int mid = (l + r) / 2;
    return max(sbor1(l, mid, l1, r1, vv * 2), sbor1(mid + 1, r, l1, r1, vv * 2 + 1));
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> lf[i] >> rg[i];
        up(1, n, i, lf[i], rg[i], 1);
    }
    cin >> tt;
    while(tt--){
        int x;
        cin >> x;
        int l = x, r = x, l1 = x, r1 = x, k = 0;
        bool ok = 0;
        while(l != 1 || r != n){
            int mn1 = sbor(1, n, l, r, 1);
            int mx1 = sbor1(1, n, l, r, 1);
            l = mn1, r = mx1;
            k++;
            if(l == l1 && r == r1){
                ok = 1;
                break;
            }
        }
        if(ok) cout << -1 << "\n";
        else cout << k << "\n";
    }
}

# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 2 ms 6744 KB Output is correct
4 Correct 90 ms 11280 KB Output is correct
5 Correct 57 ms 11088 KB Output is correct
6 Correct 95 ms 11108 KB Output is correct
7 Correct 47 ms 10328 KB Output is correct
8 Execution timed out 2050 ms 10320 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6748 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6488 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Incorrect 1 ms 6492 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6748 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6488 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Incorrect 1 ms 6492 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6748 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6488 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Incorrect 1 ms 6492 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 2 ms 6744 KB Output is correct
4 Correct 90 ms 11280 KB Output is correct
5 Correct 57 ms 11088 KB Output is correct
6 Correct 95 ms 11108 KB Output is correct
7 Correct 47 ms 10328 KB Output is correct
8 Execution timed out 2050 ms 10320 KB Time limit exceeded
9 Halted 0 ms 0 KB -