Submission #296263

#TimeUsernameProblemLanguageResultExecution timeMemory
296263BTheroLong Mansion (JOI17_long_mansion)C++17
5 / 100
3100 ms8944 KiB
// chrono::system_clock::now().time_since_epoch().count() #include<bits/stdc++.h> #define pb push_back #define eb emplace_back #define mp make_pair #define fi first #define se second #define all(x) (x).begin(), (x).end() #define debug(x) cerr << #x << " = " << x << endl; using namespace std; typedef long long ll; typedef pair<int, int> pii; const int MAXN = (int)5e3 + 5; vector<int> keys[MAXN]; int betw[MAXN]; int A[MAXN], B[MAXN]; int n, q; void solve() { scanf("%d", &n); for (int i = 1; i < n; ++i) { scanf("%d", &betw[i]); } for (int i = 1; i <= n; ++i) { int sz; scanf("%d", &sz); keys[i].resize(sz); for (int j = 0; j < sz; ++j) { scanf("%d", &keys[i][j]); } } for (int i = 1; i < n; ++i) { int p = i + 1; while (p <= n && find(all(keys[p]), betw[i]) == keys[p].end()) { ++p; } B[i] = p; } for (int i = 2; i <= n; ++i) { int p = i - 1; while (p > 0 && find(all(keys[p]), betw[i - 1]) == keys[p].end()) { --p; } A[i] = p; } B[0] = n + 1; A[n + 1] = 0; vector<pii> bad; for (int l = 1; l <= n; ++l) { for (int r = l; r <= n; ++r) { if (B[l - 1] > r && A[r + 1] < l) { bad.eb(l, r); } } } scanf("%d", &q); for (int i = 1; i <= q; ++i) { int a, b; scanf("%d %d", &a, &b); // a -> b bool ans = 1; if (a < b) { for (auto it : bad) { if (it.fi <= a && it.se >= a && it.se < b) { ans = 0; break; } } } else { for (auto it : bad) { if (b < it.fi && it.fi <= a && it.se >= a) { ans = 0; break; } } } if (ans) { printf("YES\n"); } else { printf("NO\n"); } } } int main() { int tt = 1; while (tt--) { solve(); } return 0; }

Compilation message (stderr)

long_mansion.cpp: In function 'void solve()':
long_mansion.cpp:25:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   25 |   scanf("%d", &n);
      |   ~~~~~^~~~~~~~~~
long_mansion.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   28 |     scanf("%d", &betw[i]);
      |     ~~~~~^~~~~~~~~~~~~~~~
long_mansion.cpp:33:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   33 |     scanf("%d", &sz);
      |     ~~~~~^~~~~~~~~~~
long_mansion.cpp:37:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   37 |       scanf("%d", &keys[i][j]);
      |       ~~~~~^~~~~~~~~~~~~~~~~~~
long_mansion.cpp:73:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   73 |   scanf("%d", &q);
      |   ~~~~~^~~~~~~~~~
long_mansion.cpp:77:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   77 |     scanf("%d %d", &a, &b);
      |     ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...