# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
402134 | 2021-05-11T11:17:45 Z | AriaH | Long Mansion (JOI17_long_mansion) | C++11 | 3000 ms | 19144 KB |
/** I can do this all day **/ #pragma GCC optimize("O2") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int,int> pii; typedef pair<ll,ll> pll; #define all(x) (x).begin(),(x).end() #define F first #define S second #define Mp make_pair #define SZ(x) (int)x.size() #define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define file_io freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout); const int N = 5e5 + 10; const ll mod = 1e9 + 7; const ll mod2 = 998244353; const ll inf = 1e9; const int LOG = 22; ll pw(ll a , ll b, ll M) { return (!b ? 1 : (b & 1 ? (a * pw(a * a % M, b / 2, M)) % M : pw(a * a % M, b / 2, M))); } int n, q, X[N], Y[N], C[N], Z[N], mark[N]; vector < int > keys[N]; 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", &Z[i]); for(int j = 1; j <= Z[i]; j ++) { int x; scanf("%d", &x); keys[i].push_back(x); } } scanf("%d", &q); for(int i = 1; i <= q; i ++) { scanf("%d%d", &X[i], &Y[i]); memset(mark, 0, sizeof mark); int l = X[i], r = X[i]; for(auto x : keys[X[i]]) mark[x] = 1; while(1) { if(!mark[C[l - 1]] && !mark[C[r]]) break; if(mark[C[l - 1]]) { l --; for(auto x : keys[l]) mark[x] = 1; } else { r ++; for(auto x : keys[r]) mark[x] = 1; } } if(l <= Y[i] && Y[i] <= r) { printf("YES\n"); } else { printf("NO\n"); } } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 354 ms | 14124 KB | Output is correct |
2 | Correct | 389 ms | 14320 KB | Output is correct |
3 | Correct | 446 ms | 14324 KB | Output is correct |
4 | Correct | 354 ms | 14212 KB | Output is correct |
5 | Correct | 437 ms | 14156 KB | Output is correct |
6 | Correct | 365 ms | 14176 KB | Output is correct |
7 | Correct | 375 ms | 14192 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 354 ms | 14124 KB | Output is correct |
2 | Correct | 389 ms | 14320 KB | Output is correct |
3 | Correct | 446 ms | 14324 KB | Output is correct |
4 | Correct | 354 ms | 14212 KB | Output is correct |
5 | Correct | 437 ms | 14156 KB | Output is correct |
6 | Correct | 365 ms | 14176 KB | Output is correct |
7 | Correct | 375 ms | 14192 KB | Output is correct |
8 | Execution timed out | 3062 ms | 15380 KB | Time limit exceeded |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3061 ms | 19144 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 354 ms | 14124 KB | Output is correct |
2 | Correct | 389 ms | 14320 KB | Output is correct |
3 | Correct | 446 ms | 14324 KB | Output is correct |
4 | Correct | 354 ms | 14212 KB | Output is correct |
5 | Correct | 437 ms | 14156 KB | Output is correct |
6 | Correct | 365 ms | 14176 KB | Output is correct |
7 | Correct | 375 ms | 14192 KB | Output is correct |
8 | Execution timed out | 3062 ms | 15380 KB | Time limit exceeded |
9 | Halted | 0 ms | 0 KB | - |