답안 #801932

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
801932 2023-08-02T08:29:43 Z vjudge1 Long Mansion (JOI17_long_mansion) C++17
10 / 100
161 ms 26604 KB
#ifdef Home
#define _GLIBCXX_DEBUG
#endif // Home

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;


const int N = 5555;

bool can[N][N];

int corr[N], have[N], T;

vector < int > V[N];

main() {
#ifdef Home
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // Home
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n, q, a, b;
    cin >> n;
    for(int i = 1; i < n; ++ i) {
        cin >> corr[i];
    }
    for(int k, i = 1; i <= n; ++ i) {
        cin >> k;
        V[i].resize(k);
        for(auto &j : V[i]) {
            cin >> j;
        }
    }
    for(int i = 1; i <= n; ++ i) {
        ++ T;
        int l = i - 1, r = i;
        for(auto &j : V[i]) {
            have[j] = T;
        }
        bool L = true, R = true;
        for(; L|R;) {
            L = R = false;
            for(; l && have[corr[l]] == T; -- l, L = true) {
                can[i][l] = true;
                for(auto &j : V[l]) {
                    have[j] = T;
                }
            }
            for(; r < n && have[corr[r]] == T; R = true) {
                ++ r;
                can[i][r] = true;
                for(auto &j : V[r]) {
                    have[j] = T;
                }
            }
        }
    }
    for(cin >> q; q --> 0;) {
        cin >> a >> b;
        cout << (can[a][b] ? "YES" : "NO") << '\n';
    }
}

Compilation message

long_mansion.cpp:21:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   21 | main() {
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2900 KB Output is correct
2 Correct 11 ms 9376 KB Output is correct
3 Correct 32 ms 22632 KB Output is correct
4 Correct 5 ms 8660 KB Output is correct
5 Correct 13 ms 11392 KB Output is correct
6 Correct 6 ms 9300 KB Output is correct
7 Correct 5 ms 2764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2900 KB Output is correct
2 Correct 11 ms 9376 KB Output is correct
3 Correct 32 ms 22632 KB Output is correct
4 Correct 5 ms 8660 KB Output is correct
5 Correct 13 ms 11392 KB Output is correct
6 Correct 6 ms 9300 KB Output is correct
7 Correct 5 ms 2764 KB Output is correct
8 Correct 87 ms 7808 KB Output is correct
9 Correct 81 ms 6708 KB Output is correct
10 Correct 106 ms 13400 KB Output is correct
11 Correct 161 ms 26604 KB Output is correct
12 Correct 74 ms 7528 KB Output is correct
13 Correct 91 ms 12628 KB Output is correct
14 Correct 81 ms 12680 KB Output is correct
15 Correct 87 ms 13944 KB Output is correct
16 Correct 96 ms 15700 KB Output is correct
17 Correct 80 ms 12344 KB Output is correct
18 Correct 86 ms 12752 KB Output is correct
19 Correct 81 ms 12912 KB Output is correct
20 Correct 95 ms 14912 KB Output is correct
21 Correct 96 ms 15600 KB Output is correct
22 Correct 85 ms 13992 KB Output is correct
23 Correct 82 ms 6596 KB Output is correct
24 Correct 81 ms 6540 KB Output is correct
25 Correct 83 ms 6520 KB Output is correct
26 Correct 83 ms 5392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 9 ms 2388 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2900 KB Output is correct
2 Correct 11 ms 9376 KB Output is correct
3 Correct 32 ms 22632 KB Output is correct
4 Correct 5 ms 8660 KB Output is correct
5 Correct 13 ms 11392 KB Output is correct
6 Correct 6 ms 9300 KB Output is correct
7 Correct 5 ms 2764 KB Output is correct
8 Correct 87 ms 7808 KB Output is correct
9 Correct 81 ms 6708 KB Output is correct
10 Correct 106 ms 13400 KB Output is correct
11 Correct 161 ms 26604 KB Output is correct
12 Correct 74 ms 7528 KB Output is correct
13 Correct 91 ms 12628 KB Output is correct
14 Correct 81 ms 12680 KB Output is correct
15 Correct 87 ms 13944 KB Output is correct
16 Correct 96 ms 15700 KB Output is correct
17 Correct 80 ms 12344 KB Output is correct
18 Correct 86 ms 12752 KB Output is correct
19 Correct 81 ms 12912 KB Output is correct
20 Correct 95 ms 14912 KB Output is correct
21 Correct 96 ms 15600 KB Output is correct
22 Correct 85 ms 13992 KB Output is correct
23 Correct 82 ms 6596 KB Output is correct
24 Correct 81 ms 6540 KB Output is correct
25 Correct 83 ms 6520 KB Output is correct
26 Correct 83 ms 5392 KB Output is correct
27 Runtime error 9 ms 2388 KB Execution killed with signal 11
28 Halted 0 ms 0 KB -