# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
581731 | 2022-06-23T05:17:08 Z | 반딧불(#8365) | Long Mansion (JOI17_long_mansion) | C++17 | 3000 ms | 18848 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n, q; int arr[500002]; /// arr[i]: i�� i+1 ���� vector<int> vec[500002]; int l[500002], r[500002]; int main(){ scanf("%d", &n); for(int i=1; i<n; i++) scanf("%d", &arr[i]); for(int i=1; i<=n; i++){ int x; scanf("%d", &x); vec[i].resize(x); for(int j=0; j<x; j++){ scanf("%d", &vec[i][j]); } } for(int i=1; i<=n; i++){ l[i] = r[i] = i; vector<bool> possess (n+2); for(auto x: vec[i]) possess[x] = 1; while(1){ int newRoom = 0; if(l[i] > 1 && possess[arr[l[i]-1]]) newRoom = l[i]-1; else if(r[i] < n && possess[arr[r[i]]]) newRoom = r[i]+1; else break; l[i] = min(newRoom, l[i]), r[i] = max(newRoom, r[i]); for(auto x: vec[newRoom]) possess[x] = 1; } } scanf("%d", &q); while(q--){ int s, e; scanf("%d %d", &s, &e); printf("%s\n", (l[s] <= e && e <= r[s]) ? "YES" : "NO"); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 12116 KB | Output is correct |
2 | Correct | 31 ms | 12232 KB | Output is correct |
3 | Correct | 78 ms | 12316 KB | Output is correct |
4 | Correct | 9 ms | 12244 KB | Output is correct |
5 | Correct | 42 ms | 12204 KB | Output is correct |
6 | Correct | 16 ms | 12244 KB | Output is correct |
7 | Correct | 14 ms | 12244 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 12116 KB | Output is correct |
2 | Correct | 31 ms | 12232 KB | Output is correct |
3 | Correct | 78 ms | 12316 KB | Output is correct |
4 | Correct | 9 ms | 12244 KB | Output is correct |
5 | Correct | 42 ms | 12204 KB | Output is correct |
6 | Correct | 16 ms | 12244 KB | Output is correct |
7 | Correct | 14 ms | 12244 KB | Output is correct |
8 | Correct | 166 ms | 17984 KB | Output is correct |
9 | Correct | 177 ms | 17996 KB | Output is correct |
10 | Correct | 195 ms | 18308 KB | Output is correct |
11 | Correct | 221 ms | 18848 KB | Output is correct |
12 | Correct | 159 ms | 17688 KB | Output is correct |
13 | Correct | 156 ms | 18172 KB | Output is correct |
14 | Correct | 143 ms | 18220 KB | Output is correct |
15 | Correct | 156 ms | 18252 KB | Output is correct |
16 | Correct | 173 ms | 18008 KB | Output is correct |
17 | Correct | 148 ms | 18204 KB | Output is correct |
18 | Correct | 146 ms | 18232 KB | Output is correct |
19 | Correct | 158 ms | 18388 KB | Output is correct |
20 | Correct | 164 ms | 18208 KB | Output is correct |
21 | Correct | 174 ms | 18036 KB | Output is correct |
22 | Correct | 155 ms | 18128 KB | Output is correct |
23 | Correct | 169 ms | 18020 KB | Output is correct |
24 | Correct | 151 ms | 18032 KB | Output is correct |
25 | Correct | 170 ms | 17924 KB | Output is correct |
26 | Correct | 156 ms | 17908 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3038 ms | 17864 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 12116 KB | Output is correct |
2 | Correct | 31 ms | 12232 KB | Output is correct |
3 | Correct | 78 ms | 12316 KB | Output is correct |
4 | Correct | 9 ms | 12244 KB | Output is correct |
5 | Correct | 42 ms | 12204 KB | Output is correct |
6 | Correct | 16 ms | 12244 KB | Output is correct |
7 | Correct | 14 ms | 12244 KB | Output is correct |
8 | Correct | 166 ms | 17984 KB | Output is correct |
9 | Correct | 177 ms | 17996 KB | Output is correct |
10 | Correct | 195 ms | 18308 KB | Output is correct |
11 | Correct | 221 ms | 18848 KB | Output is correct |
12 | Correct | 159 ms | 17688 KB | Output is correct |
13 | Correct | 156 ms | 18172 KB | Output is correct |
14 | Correct | 143 ms | 18220 KB | Output is correct |
15 | Correct | 156 ms | 18252 KB | Output is correct |
16 | Correct | 173 ms | 18008 KB | Output is correct |
17 | Correct | 148 ms | 18204 KB | Output is correct |
18 | Correct | 146 ms | 18232 KB | Output is correct |
19 | Correct | 158 ms | 18388 KB | Output is correct |
20 | Correct | 164 ms | 18208 KB | Output is correct |
21 | Correct | 174 ms | 18036 KB | Output is correct |
22 | Correct | 155 ms | 18128 KB | Output is correct |
23 | Correct | 169 ms | 18020 KB | Output is correct |
24 | Correct | 151 ms | 18032 KB | Output is correct |
25 | Correct | 170 ms | 17924 KB | Output is correct |
26 | Correct | 156 ms | 17908 KB | Output is correct |
27 | Execution timed out | 3038 ms | 17864 KB | Time limit exceeded |
28 | Halted | 0 ms | 0 KB | - |