답안 #241666

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
241666 2020-06-25T07:16:56 Z osaaateiasavtnl Long Mansion (JOI17_long_mansion) C++17
10 / 100
3000 ms 11512 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif


    int n;
    cin >> n;

    vector <int> c(n-1);
    for (int i = 0; i < n - 1; ++i)
        cin >> c[i];

    vector <vector <int> > a(n);
    for (int i = 0; i < n; ++i) {
        int k;
        cin >> k;
        a[i].resize(k);
        for (int j = 0; j < k; ++j)
            cin >> a[i][j];
    }   

    vector <int> l(n), r(n);
    for (int i = 0; i < n; ++i) {
        l[i] = r[i] = i;

        set <int> cur;
        for (auto e : a[i])
            cur.insert(e);

        while (1) {
            if (l[i] && cur.find(c[l[i]-1]) != cur.end()) {
                --l[i];
                for (auto e : a[l[i]])
                    cur.insert(e);
            }   
            else if (r[i] < n - 1 && cur.find(c[r[i]]) != cur.end()) {
                ++r[i];
                for (auto e : a[r[i]])
                    cur.insert(e);
            }   
            else {
                break;
            }   
        }   
    }   

    int q;
    cin >> q;
    while (q--) {
        int i, j;
        cin >> i >> j;
        --i; --j;
        if (l[i] <= j && j <= r[i]) {
            cout << "YES" << endl;
        }   
        else {
            cout << "NO" << endl;
        }   
    }   
}
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 640 KB Output is correct
2 Correct 135 ms 640 KB Output is correct
3 Correct 309 ms 760 KB Output is correct
4 Correct 27 ms 628 KB Output is correct
5 Correct 472 ms 604 KB Output is correct
6 Correct 165 ms 760 KB Output is correct
7 Correct 113 ms 760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 640 KB Output is correct
2 Correct 135 ms 640 KB Output is correct
3 Correct 309 ms 760 KB Output is correct
4 Correct 27 ms 628 KB Output is correct
5 Correct 472 ms 604 KB Output is correct
6 Correct 165 ms 760 KB Output is correct
7 Correct 113 ms 760 KB Output is correct
8 Correct 174 ms 6392 KB Output is correct
9 Correct 138 ms 6408 KB Output is correct
10 Correct 268 ms 6776 KB Output is correct
11 Correct 446 ms 7288 KB Output is correct
12 Correct 183 ms 6164 KB Output is correct
13 Correct 130 ms 6648 KB Output is correct
14 Correct 142 ms 6648 KB Output is correct
15 Correct 377 ms 6648 KB Output is correct
16 Correct 603 ms 6552 KB Output is correct
17 Correct 133 ms 6648 KB Output is correct
18 Correct 150 ms 6648 KB Output is correct
19 Correct 197 ms 6652 KB Output is correct
20 Correct 597 ms 6540 KB Output is correct
21 Correct 591 ms 6392 KB Output is correct
22 Correct 508 ms 6580 KB Output is correct
23 Correct 292 ms 6392 KB Output is correct
24 Correct 265 ms 6520 KB Output is correct
25 Correct 226 ms 6392 KB Output is correct
26 Correct 159 ms 6448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3096 ms 11512 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 640 KB Output is correct
2 Correct 135 ms 640 KB Output is correct
3 Correct 309 ms 760 KB Output is correct
4 Correct 27 ms 628 KB Output is correct
5 Correct 472 ms 604 KB Output is correct
6 Correct 165 ms 760 KB Output is correct
7 Correct 113 ms 760 KB Output is correct
8 Correct 174 ms 6392 KB Output is correct
9 Correct 138 ms 6408 KB Output is correct
10 Correct 268 ms 6776 KB Output is correct
11 Correct 446 ms 7288 KB Output is correct
12 Correct 183 ms 6164 KB Output is correct
13 Correct 130 ms 6648 KB Output is correct
14 Correct 142 ms 6648 KB Output is correct
15 Correct 377 ms 6648 KB Output is correct
16 Correct 603 ms 6552 KB Output is correct
17 Correct 133 ms 6648 KB Output is correct
18 Correct 150 ms 6648 KB Output is correct
19 Correct 197 ms 6652 KB Output is correct
20 Correct 597 ms 6540 KB Output is correct
21 Correct 591 ms 6392 KB Output is correct
22 Correct 508 ms 6580 KB Output is correct
23 Correct 292 ms 6392 KB Output is correct
24 Correct 265 ms 6520 KB Output is correct
25 Correct 226 ms 6392 KB Output is correct
26 Correct 159 ms 6448 KB Output is correct
27 Execution timed out 3096 ms 11512 KB Time limit exceeded
28 Halted 0 ms 0 KB -