답안 #128367

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
128367 2019-07-10T19:23:19 Z doowey Long Mansion (JOI17_long_mansion) C++14
10 / 100
3000 ms 27008 KB
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ld, ld> pdd;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = (int)5e5 + 9;
int L[N];
int R[N];
int C[N];
vector<int> ls[N];

int las[N];
int lf[N];
int rf[N];


int main(){
    fastIO;
    int n;
    cin >> n;
    for(int i = 1; i < n; i ++ ){
        cin >> C[i];
    }
    int x, k;
    for(int i = 1; i <= n ; i ++ ){
        cin >> k;
        for(int j = 0 ; j < k ; j ++ ){
            cin >> x;
            ls[i].push_back(x);
        }
    }
    for(int j = 1; j <= n; j ++ )
        las[j] = -1;
    for(int i = 1; i < n; i ++ ){
        for(auto p : ls[i])
            las[p] = i;
        lf[i + 1] = las[C[i]];
    }
    for(int j = 1; j <= n; j ++ )
        las[j] = -1;
    for(int i = n; i > 1; i -- ){
        for(auto p : ls[i])
            las[p] = i;
        rf[i - 1] = las[C[i - 1]];
    }
    for(int i = 1; i <= n; i ++ ){
        L[i] = i;
        R[i] = i;
        while(1){
            if(L[i] != 1 && rf[L[i] - 1] <= R[i] && rf[L[i] - 1] != -1){
                L[i] -- ;
            }
            else if(R[i] != n && lf[R[i] + 1] >= L[i] && lf[R[i] + 1] != -1){
                R[i] ++ ;
            }
            else{
                break;
            }
        }
    }
    int Q;
    cin >> Q;
    int p, q;
    for(int i = 0 ; i < Q; i ++ ){
        cin >> p >> q;
        if(q >= L[p] && q <= R[p])
            cout << "YES\n";
        else
            cout << "NO\n";
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 12280 KB Output is correct
2 Correct 24 ms 12536 KB Output is correct
3 Correct 34 ms 12536 KB Output is correct
4 Correct 19 ms 12280 KB Output is correct
5 Correct 22 ms 12408 KB Output is correct
6 Correct 18 ms 12280 KB Output is correct
7 Correct 19 ms 12280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 12280 KB Output is correct
2 Correct 24 ms 12536 KB Output is correct
3 Correct 34 ms 12536 KB Output is correct
4 Correct 19 ms 12280 KB Output is correct
5 Correct 22 ms 12408 KB Output is correct
6 Correct 18 ms 12280 KB Output is correct
7 Correct 19 ms 12280 KB Output is correct
8 Correct 141 ms 18168 KB Output is correct
9 Correct 136 ms 18124 KB Output is correct
10 Correct 144 ms 18552 KB Output is correct
11 Correct 151 ms 18808 KB Output is correct
12 Correct 128 ms 17784 KB Output is correct
13 Correct 134 ms 18424 KB Output is correct
14 Correct 131 ms 18296 KB Output is correct
15 Correct 138 ms 18424 KB Output is correct
16 Correct 134 ms 18168 KB Output is correct
17 Correct 130 ms 18288 KB Output is correct
18 Correct 141 ms 18296 KB Output is correct
19 Correct 135 ms 18424 KB Output is correct
20 Correct 135 ms 18296 KB Output is correct
21 Correct 140 ms 18112 KB Output is correct
22 Correct 136 ms 18380 KB Output is correct
23 Correct 208 ms 18168 KB Output is correct
24 Correct 141 ms 18168 KB Output is correct
25 Correct 137 ms 18168 KB Output is correct
26 Correct 132 ms 18084 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1242 ms 19996 KB Output is correct
2 Correct 2473 ms 27008 KB Output is correct
3 Execution timed out 3021 ms 19416 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 12280 KB Output is correct
2 Correct 24 ms 12536 KB Output is correct
3 Correct 34 ms 12536 KB Output is correct
4 Correct 19 ms 12280 KB Output is correct
5 Correct 22 ms 12408 KB Output is correct
6 Correct 18 ms 12280 KB Output is correct
7 Correct 19 ms 12280 KB Output is correct
8 Correct 141 ms 18168 KB Output is correct
9 Correct 136 ms 18124 KB Output is correct
10 Correct 144 ms 18552 KB Output is correct
11 Correct 151 ms 18808 KB Output is correct
12 Correct 128 ms 17784 KB Output is correct
13 Correct 134 ms 18424 KB Output is correct
14 Correct 131 ms 18296 KB Output is correct
15 Correct 138 ms 18424 KB Output is correct
16 Correct 134 ms 18168 KB Output is correct
17 Correct 130 ms 18288 KB Output is correct
18 Correct 141 ms 18296 KB Output is correct
19 Correct 135 ms 18424 KB Output is correct
20 Correct 135 ms 18296 KB Output is correct
21 Correct 140 ms 18112 KB Output is correct
22 Correct 136 ms 18380 KB Output is correct
23 Correct 208 ms 18168 KB Output is correct
24 Correct 141 ms 18168 KB Output is correct
25 Correct 137 ms 18168 KB Output is correct
26 Correct 132 ms 18084 KB Output is correct
27 Correct 1242 ms 19996 KB Output is correct
28 Correct 2473 ms 27008 KB Output is correct
29 Execution timed out 3021 ms 19416 KB Time limit exceeded
30 Halted 0 ms 0 KB -