Submission #125305

# Submission time Handle Problem Language Result Execution time Memory
125305 2019-07-05T05:17:30 Z 송준혁(#3062) Long Mansion (JOI17_long_mansion) C++14
10 / 100
716 ms 22520 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int N, Q;
int C[5050];
int A[5050][5050], cnt[5050];
int S[5050], E[5050];
bool chk[5050];

int main(){
    scanf("%d", &N);
    for (int i=1; i<N; i++) scanf("%d", &C[i]);
    for (int i=1; i<=N; i++){
        scanf("%d", &cnt[i]);
        for (int j=1; j<=cnt[i]; j++) scanf("%d", &A[i][j]);
    }
    for (int i=1; i<=N; i++){
        memset(chk, false, sizeof chk);
        S[i] = E[i] = i;
        for (int j=1; j<=cnt[i]; j++) chk[A[i][j]] = true;
        while (1){
            if (S[i]>1 && chk[C[S[i]-1]]){
                S[i]--;
                for (int j=1; j<=cnt[S[i]]; j++) chk[A[S[i]][j]] = true;
                continue;
            }
            if (E[i]<N && chk[C[E[i]]]){
                E[i]++;
                for (int j=1; j<=cnt[E[i]]; j++) chk[A[E[i]][j]] = true;
                continue;
            }
            break;
        }
    }
    scanf("%d", &Q);
    int x, y;
    while (Q--){
        scanf("%d %d", &x, &y);
        if (S[x] <= y && y <= E[x]) puts("YES");
        else puts("NO");
    }
    return 0;
}

Compilation message

long_mansion.cpp: In function 'int main()':
long_mansion.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
     ~~~~~^~~~~~~~~~
long_mansion.cpp:13:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (int i=1; i<N; i++) scanf("%d", &C[i]);
                             ~~~~~^~~~~~~~~~~~~
long_mansion.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &cnt[i]);
         ~~~~~^~~~~~~~~~~~~~~
long_mansion.cpp:16:44: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         for (int j=1; j<=cnt[i]; j++) scanf("%d", &A[i][j]);
                                       ~~~~~^~~~~~~~~~~~~~~~
long_mansion.cpp:36:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &Q);
     ~~~~~^~~~~~~~~~
long_mansion.cpp:39:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &x, &y);
         ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 13 ms 8440 KB Output is correct
2 Correct 118 ms 12536 KB Output is correct
3 Correct 571 ms 20728 KB Output is correct
4 Correct 11 ms 8440 KB Output is correct
5 Correct 101 ms 8568 KB Output is correct
6 Correct 18 ms 8568 KB Output is correct
7 Correct 27 ms 8568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 8440 KB Output is correct
2 Correct 118 ms 12536 KB Output is correct
3 Correct 571 ms 20728 KB Output is correct
4 Correct 11 ms 8440 KB Output is correct
5 Correct 101 ms 8568 KB Output is correct
6 Correct 18 ms 8568 KB Output is correct
7 Correct 27 ms 8568 KB Output is correct
8 Correct 160 ms 10224 KB Output is correct
9 Correct 147 ms 10252 KB Output is correct
10 Correct 258 ms 14440 KB Output is correct
11 Correct 716 ms 22520 KB Output is correct
12 Correct 135 ms 6324 KB Output is correct
13 Correct 136 ms 10360 KB Output is correct
14 Correct 137 ms 10488 KB Output is correct
15 Correct 171 ms 10436 KB Output is correct
16 Correct 217 ms 10744 KB Output is correct
17 Correct 136 ms 10488 KB Output is correct
18 Correct 136 ms 10356 KB Output is correct
19 Correct 137 ms 10360 KB Output is correct
20 Correct 201 ms 10488 KB Output is correct
21 Correct 218 ms 10616 KB Output is correct
22 Correct 145 ms 10488 KB Output is correct
23 Correct 152 ms 10268 KB Output is correct
24 Correct 153 ms 10232 KB Output is correct
25 Correct 153 ms 10284 KB Output is correct
26 Correct 148 ms 10132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 8440 KB Output is correct
2 Correct 118 ms 12536 KB Output is correct
3 Correct 571 ms 20728 KB Output is correct
4 Correct 11 ms 8440 KB Output is correct
5 Correct 101 ms 8568 KB Output is correct
6 Correct 18 ms 8568 KB Output is correct
7 Correct 27 ms 8568 KB Output is correct
8 Correct 160 ms 10224 KB Output is correct
9 Correct 147 ms 10252 KB Output is correct
10 Correct 258 ms 14440 KB Output is correct
11 Correct 716 ms 22520 KB Output is correct
12 Correct 135 ms 6324 KB Output is correct
13 Correct 136 ms 10360 KB Output is correct
14 Correct 137 ms 10488 KB Output is correct
15 Correct 171 ms 10436 KB Output is correct
16 Correct 217 ms 10744 KB Output is correct
17 Correct 136 ms 10488 KB Output is correct
18 Correct 136 ms 10356 KB Output is correct
19 Correct 137 ms 10360 KB Output is correct
20 Correct 201 ms 10488 KB Output is correct
21 Correct 218 ms 10616 KB Output is correct
22 Correct 145 ms 10488 KB Output is correct
23 Correct 152 ms 10268 KB Output is correct
24 Correct 153 ms 10232 KB Output is correct
25 Correct 153 ms 10284 KB Output is correct
26 Correct 148 ms 10132 KB Output is correct
27 Incorrect 3 ms 376 KB Output isn't correct
28 Halted 0 ms 0 KB -