結果
問題 | No.1950 片道きゃっちぼーる |
ユーザー | Mazesoba |
提出日時 | 2022-05-25 06:13:30 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,485 bytes |
コンパイル時間 | 4,735 ms |
コンパイル使用メモリ | 271,764 KB |
実行使用メモリ | 56,588 KB |
最終ジャッジ日時 | 2023-10-20 19:05:22 |
合計ジャッジ時間 | 19,886 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,348 KB |
testcase_01 | AC | 2 ms
4,348 KB |
testcase_02 | AC | 2 ms
4,348 KB |
testcase_03 | AC | 641 ms
56,588 KB |
testcase_04 | AC | 621 ms
56,588 KB |
testcase_05 | AC | 2 ms
4,348 KB |
testcase_06 | AC | 635 ms
56,588 KB |
testcase_07 | AC | 603 ms
37,844 KB |
testcase_08 | WA | - |
testcase_09 | AC | 638 ms
48,140 KB |
testcase_10 | WA | - |
testcase_11 | AC | 589 ms
26,008 KB |
testcase_12 | AC | 579 ms
32,324 KB |
testcase_13 | AC | 637 ms
42,068 KB |
testcase_14 | AC | 659 ms
43,916 KB |
testcase_15 | AC | 1,134 ms
52,364 KB |
testcase_16 | AC | 659 ms
50,252 KB |
testcase_17 | AC | 2 ms
4,348 KB |
testcase_18 | AC | 639 ms
40,748 KB |
testcase_19 | AC | 1,108 ms
48,932 KB |
testcase_20 | WA | - |
testcase_21 | AC | 636 ms
42,860 KB |
testcase_22 | WA | - |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; //#define DISABLE_PRINT #if defined(ENABLE_PRINT) && !defined(DISABLE_PRINT) #define P(...) fprintf(stderr, __VA_ARGS__) #define P2(fmt) fprintf(stderr, fmt) #define LP fprintf(stderr, "L: %d\n", __LINE__) #else #define P(...) ((void)0) #define P2(fmt) ((void)0) #define LP ((void)0) #endif #define rep(i, n) for(int i = 0; i < (int)(n); ++i) #define ALL(x) x.begin(),x.end() using ll = long long; using ull = unsigned long long; int main(int, const char**) { int N; cin >> N; vector<vector<int>> g(N); vector<ll> X(N), A(N); map<ll, int> posToIdx, distToIdx; rep(i, N) { cin >> X[i]; posToIdx[X[i]] = i; } rep(i, N) cin >> A[i]; rep(i, N) { auto d0 = X[i] + A[i]; if(posToIdx.find(d0) != posToIdx.end()) { g[posToIdx[d0]].push_back(i); } distToIdx[d0] = i; auto d1 = X[i] - A[i]; if(posToIdx.find(d1) != posToIdx.end()) { g[posToIdx[d1]].push_back(i); } } vector<ll> ans(N, -1); function<void(int, ll)> f = [&](int x, ll d) { if(ans[x] != -1) return; ans[x] = d; for(auto nx : g[x]) { f(nx, d); } }; for(auto itr = distToIdx.rbegin(); itr != distToIdx.rend(); ++itr) { f(itr->second, itr->first); } rep(i, N) { auto a = ans[i] - X[i]; cout << a << endl; } return 0; }