結果
問題 | No.961 Vibrant Fillumination |
ユーザー | 👑 emthrm |
提出日時 | 2020-02-25 23:58:48 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 379 ms / 5,000 ms |
コード長 | 4,758 bytes |
コンパイル時間 | 2,515 ms |
コンパイル使用メモリ | 221,636 KB |
実行使用メモリ | 10,064 KB |
最終ジャッジ日時 | 2024-10-13 14:40:18 |
合計ジャッジ時間 | 24,323 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 296 ms
9,932 KB |
testcase_03 | AC | 318 ms
9,808 KB |
testcase_04 | AC | 318 ms
9,904 KB |
testcase_05 | AC | 301 ms
9,936 KB |
testcase_06 | AC | 291 ms
9,932 KB |
testcase_07 | AC | 357 ms
9,936 KB |
testcase_08 | AC | 305 ms
9,936 KB |
testcase_09 | AC | 298 ms
9,936 KB |
testcase_10 | AC | 371 ms
9,936 KB |
testcase_11 | AC | 379 ms
9,808 KB |
testcase_12 | AC | 371 ms
10,064 KB |
testcase_13 | AC | 369 ms
9,856 KB |
testcase_14 | AC | 371 ms
9,936 KB |
testcase_15 | AC | 343 ms
9,940 KB |
testcase_16 | AC | 364 ms
9,936 KB |
testcase_17 | AC | 340 ms
9,932 KB |
testcase_18 | AC | 369 ms
9,932 KB |
testcase_19 | AC | 364 ms
9,936 KB |
testcase_20 | AC | 364 ms
9,936 KB |
testcase_21 | AC | 338 ms
10,064 KB |
testcase_22 | AC | 339 ms
9,916 KB |
testcase_23 | AC | 337 ms
9,940 KB |
testcase_24 | AC | 349 ms
9,880 KB |
testcase_25 | AC | 371 ms
9,940 KB |
testcase_26 | AC | 170 ms
9,936 KB |
testcase_27 | AC | 176 ms
9,936 KB |
testcase_28 | AC | 173 ms
9,932 KB |
testcase_29 | AC | 183 ms
9,932 KB |
testcase_30 | AC | 128 ms
9,936 KB |
testcase_31 | AC | 80 ms
9,840 KB |
testcase_32 | AC | 253 ms
9,680 KB |
testcase_33 | AC | 2 ms
5,248 KB |
testcase_34 | AC | 338 ms
9,932 KB |
testcase_35 | AC | 319 ms
9,908 KB |
testcase_36 | AC | 335 ms
9,940 KB |
testcase_37 | AC | 342 ms
9,804 KB |
testcase_38 | AC | 321 ms
9,932 KB |
testcase_39 | AC | 317 ms
9,936 KB |
testcase_40 | AC | 322 ms
9,940 KB |
testcase_41 | AC | 330 ms
9,936 KB |
testcase_42 | AC | 323 ms
9,808 KB |
testcase_43 | AC | 323 ms
9,936 KB |
testcase_44 | AC | 333 ms
9,804 KB |
testcase_45 | AC | 324 ms
9,936 KB |
testcase_46 | AC | 327 ms
9,936 KB |
testcase_47 | AC | 328 ms
9,936 KB |
testcase_48 | AC | 336 ms
9,940 KB |
testcase_49 | AC | 331 ms
9,836 KB |
ソースコード
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; #define FOR(i,m,n) for(int i=(m);i<(n);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() using ll = long long; template <typename T> using posteriority_queue = priority_queue<T, vector<T>, greater<T> >; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fLL; const double EPS = 1e-8; const int MOD = 1000000007; // const int MOD = 998244353; const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1}; const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1}; template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; } template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; } template <typename T> void unique(vector<T> &a) { a.erase(unique(ALL(a)), a.end()); } struct IOSetup { IOSetup() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << fixed << setprecision(20); } } iosetup; int main() { int n; cin >> n; vector<ll> h(n); REP(i, n) cin >> h[i]; vector<int> a(n), b(n), c(n), d(n), e(n); vector<pair<int, int> > xs, ys; REP(i, n) { cin >> a[i] >> b[i] >> c[i] >> d[i] >> e[i]; --e[i]; xs.emplace_back(a[i], i); xs.emplace_back(c[i], n + i); ys.emplace_back(b[i], i); ys.emplace_back(d[i], n + i); } int Q; cin >> Q; vector<int> p(Q), q(Q); REP(i, Q) { cin >> p[i] >> q[i]; xs.emplace_back(p[i], n * 2 + i); ys.emplace_back(q[i], n * 2 + i); } sort(ALL(xs)); int X = 0; for (pair<int, int> pr : xs) { if (pr.second >= n * 2) { p[pr.second - n * 2] = X - 1; } else { if (pr.second < n) { a[pr.second] = X; } else { c[pr.second - n] = X; } ++X; } } ++X; vector<int> in_x(X, -1), out_x(X, -1); REP(i, n) { in_x[a[i]] = i; out_x[c[i]] = i; // cout << 'x' << i << " [" << a[i] << ',' << c[i] << "]\n"; } // REP(i, X) cout << in_x[i] << " \n"[i + 1 == X]; // REP(i, X) cout << out_x[i] << " \n"[i + 1 == X]; sort(ALL(ys)); int Y = 0; for (pair<int, int> pr : ys) { if (pr.second >= n * 2) { q[pr.second - n * 2] = Y - 1; } else { if (pr.second < n) { b[pr.second] = Y; } else { d[pr.second - n] = Y; } ++Y; } } ++Y; vector<int> in_y(Y, -1), out_y(Y, -1); REP(i, n) { in_y[b[i]] = i; out_y[d[i]] = i; // cout << 'y' << i << " [" << b[i] << ',' << d[i] << "]\n"; } int B = sqrt(X), m = (X + B - 1) / B; vector<vector<int> > query(m); REP(i, Q) { if (p[i] != -1 && q[i] != -1) query[p[i] / B].emplace_back(i); // cout << p[i] << ' ' << q[i] << '\n'; } vector<ll> ans(Q, 0); REP(block, m) { sort(ALL(query[block]), [&](int l, int r) { return q[l] < q[r]; }); ll hash = 0; vector<int> cnt(n, 0); int x = block * B, y = 0; for (int idx : query[block]) { for (; y <= q[idx]; ++y) { if (in_y[y] != -1) { int film = in_y[y]; if (a[film] < x && x <= c[film]) { if (cnt[e[film]] == 0) hash ^= h[e[film]]; ++cnt[e[film]]; } } if (out_y[y] != -1) { int film = out_y[y]; if (a[film] < x && x <= c[film]) { --cnt[e[film]]; if (cnt[e[film]] == 0) hash ^= h[e[film]]; } } // cout << '(' << x << ',' << y << ") "; // REP(i, n) cout << cnt[i] << " \n"[i + 1 == n]; } for (; x <= p[idx]; ++x) { if (in_x[x] != -1) { int film = in_x[x]; if (b[film] < y && y <= d[film]) { if (cnt[e[film]] == 0) hash ^= h[e[film]]; ++cnt[e[film]]; } } if (out_x[x] != -1) { int film = out_x[x]; if (b[film] < y && y <= d[film]) { --cnt[e[film]]; if (cnt[e[film]] == 0) hash ^= h[e[film]]; } } // cout << '(' << x << ',' << y << ") "; // REP(i, n) cout << cnt[i] << " \n"[i + 1 == n]; } while (x > p[idx] + 1) { --x; if (in_x[x] != -1) { int film = in_x[x]; if (b[film] < y && y <= d[film]) { --cnt[e[film]]; if (cnt[e[film]] == 0) hash ^= h[e[film]]; } } if (out_x[x] != -1) { int film = out_x[x]; if (b[film] < y && y <= d[film]) { if (cnt[e[film]] == 0) hash ^= h[e[film]]; ++cnt[e[film]]; } } // cout << '(' << x << ',' << y << ") "; // REP(i, n) cout << cnt[i] << " \n"[i + 1 == n]; } ans[idx] = hash; } } REP(i, Q) cout << ans[i] << '\n'; return 0; }