結果
問題 |
No.871 かえるのうた
|
ユーザー |
![]() |
提出日時 | 2019-08-30 22:01:42 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,054 bytes |
コンパイル時間 | 2,046 ms |
コンパイル使用メモリ | 175,756 KB |
実行使用メモリ | 20,224 KB |
最終ジャッジ日時 | 2024-11-21 23:25:55 |
合計ジャッジ時間 | 6,063 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 39 WA * 2 RE * 8 |
ソースコード
#include <bits/stdc++.h> using namespace std; using lint = long long; template<class T = int> using V = vector<T>; template<class T = int> using VV = V< V<T> >; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n, k; cin >> n >> k, --k; V<lint> x(n); for (auto&& e : x) cin >> e; V<lint> a(n); for (auto&& e : a) cin >> e; VV<> g(2 * n); for (int i = 0; i < n; ++i) { int l = lower_bound(begin(x), end(x), x[i] - a[i]) - begin(x); int r = upper_bound(begin(x), end(x), x[i] + a[i]) - begin(x); l += n, r += n; while (l < r) { if (l & 1) { g[n + i].push_back(l++); } if (r & 1) { g[n + i].push_back(--r); } l >>= 1, r >>= 1; } } for (int i = 1; i < n; ++i) { g[i].push_back(2 * i); g[i].push_back(2 * i + 1); } int res = 0; bitset<100000> vis; auto dfs = [&](const auto& dfs, int v) -> void { vis[v] = true; res += v >= n; for (int w : g[v]) if (!vis[w]) { dfs(dfs, w); } }; dfs(dfs, n + k); cout << res << '\n'; }