제출 #1292073

#제출 시각아이디문제언어결과실행 시간메모리
1292073qmdz1908Long Mansion (JOI17_long_mansion)C++17
0 / 100
3095 ms17640 KiB
#include <bits/stdc++.h> using namespace std; #define pii pair <int, int> #define fi first #define se second const int maxn = 5e5 + 5, oo = 1e18, mod = 1e9 + 7; int n, c[maxn], L[maxn], R[maxn]; vector <int> a[maxn]; bool has (int l, int r, int x) { return *lower_bound (a[x].begin(), a[x].end(), l) <= r; } void solve () { cin >> n; for (int i = 1; i < n; i++) cin >> c[i]; for (int i = 1, m; i <= n; i++) { cin >> m; for (int j = 1, x; j <= m; j++) { cin >> x; a[x].push_back (i); } } for (int i = 1; i <= n; i++) a[i].push_back (oo); for (int i = 1; i <= n; i++) { L[i] = R[i] = i; bool loop = true; while (loop) { loop = false; if (L[i] > 1 && has (L[i], R[i], c[L[i] - 1])) { L[i] = min (L[i], L[L[i - 1]]); R[i] = max (R[i], R[R[i - 1]]); loop = true; } if (R[i] < n && has (L[i], R[i], c[R[i]])) { R[i]++; loop = true; } } } int q; cin >> q; while (q--) { int x, y; cin >> x >> y; if (y >= L[x] && y <= R[x]) cout << "YES\n"; else cout << "NO\n"; } } signed main () { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen ("code.inp", "r")) { freopen ("code.inp", "r", stdin); freopen ("code.out", "w", stdout); } int tc = 1; // cin >> tc; while (tc--) solve (); }

컴파일 시 표준 에러 (stderr) 메시지

long_mansion.cpp:6:32: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
    6 | const int maxn = 5e5 + 5, oo = 1e18, mod = 1e9 + 7;
      |                                ^~~~
long_mansion.cpp: In function 'int main()':
long_mansion.cpp:54:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |         freopen ("code.inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
long_mansion.cpp:55:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   55 |         freopen ("code.out", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...