結果
問題 | No.2490 Escalator |
ユーザー | square1001 |
提出日時 | 2023-09-29 21:31:37 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,724 bytes |
コンパイル時間 | 2,731 ms |
コンパイル使用メモリ | 211,164 KB |
実行使用メモリ | 36,448 KB |
最終ジャッジ日時 | 2024-07-22 15:33:07 |
合計ジャッジ時間 | 12,493 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 3 ms
5,376 KB |
testcase_13 | AC | 2 ms
5,376 KB |
testcase_14 | AC | 2 ms
5,376 KB |
testcase_15 | AC | 3 ms
5,376 KB |
testcase_16 | AC | 2 ms
5,376 KB |
testcase_17 | AC | 2 ms
5,376 KB |
testcase_18 | AC | 2 ms
5,376 KB |
testcase_19 | AC | 3 ms
5,376 KB |
testcase_20 | AC | 2 ms
5,376 KB |
testcase_21 | AC | 2 ms
5,376 KB |
testcase_22 | AC | 2 ms
5,376 KB |
testcase_23 | AC | 2 ms
5,376 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | AC | 170 ms
36,224 KB |
testcase_45 | AC | 166 ms
36,096 KB |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | AC | 165 ms
36,224 KB |
testcase_49 | AC | 166 ms
36,096 KB |
testcase_50 | AC | 172 ms
36,096 KB |
testcase_51 | AC | 165 ms
36,224 KB |
testcase_52 | AC | 168 ms
36,208 KB |
testcase_53 | AC | 167 ms
36,200 KB |
testcase_54 | WA | - |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | WA | - |
testcase_59 | WA | - |
testcase_60 | WA | - |
testcase_61 | WA | - |
testcase_62 | WA | - |
testcase_63 | WA | - |
testcase_64 | WA | - |
testcase_65 | WA | - |
testcase_66 | WA | - |
testcase_67 | WA | - |
testcase_68 | WA | - |
testcase_69 | WA | - |
testcase_70 | WA | - |
testcase_71 | WA | - |
testcase_72 | WA | - |
testcase_73 | WA | - |
testcase_74 | AC | 162 ms
35,968 KB |
testcase_75 | AC | 162 ms
36,224 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; const long double pi = acos(-1.0); alignas(64) complex<long double> pw[263168]; void fft(int d, vector<complex<long double> > &v) { // d = dimensions (i.e. size(v) = 2^d) if(d == 0) return; int n = (1 << d); for(int i = 0, j = 1; j < n - 1; ++j) { for(int k = n >> 1; k > (i ^= k); k >>= 1); if(i < j) swap(v[i], v[j]); } complex<long double> t; for(int i = 0; i < d; ++i) { for(int j = 0; j < n; j += 2 << i) { for(int k = j; k < (j | (1 << i)); ++k) { t = v[k | (1 << i)] * pw[(k - j) | (1 << i)]; v[k | (1 << i)] = v[k] - t; v[k] += t; } } } } void fft_inverse(int d, vector<complex<long double> > &v) { // d = dimensions (i.e. size(v) = 2^d) if(d == 0) return; int n = (1 << d); for(int i = 0, j = 1; j < n - 1; ++j) { for(int k = n >> 1; k > (i ^= k); k >>= 1); if(i < j) swap(v[i], v[j]); } complex<long double> t; for(int i = 0; i < d; ++i) { for(int j = 0; j < n; j += 2 << i) { t = v[j | (1 << i)]; v[j | (1 << i)] = v[j] - t; v[j] += t; for(int k = j + 1; k < (j | (1 << i)); ++k) { t = v[k | (1 << i)] * pw[(2 << i) - (k - j)]; v[k | (1 << i)] = v[k] + t; v[k] -= t; } } } for(int i = 0; i < n; ++i) { v[i] /= n; } } vector<long double> convolve(int n, const vector<long double>& va, const vector<long double>& vb) { int d = 0; while((1 << d) < 2 * n) ++d; for(int i = 0; i < d; ++i) { complex<long double> r = polar(1.0L, pi / (1 << i)); pw[1 << i] = 1.0; for(int j = (1 << i) + 1; j < 2 << i; ++j) { pw[j] = pw[j - 1] * r; } } vector<complex<long double> > a(1 << d), b(1 << d); for(int i = 0; i < n; ++i) { a[i] = va[i]; b[i] = vb[i]; } fft(d, a); fft(d, b); for(int i = 0; i < 1 << d; ++i) { a[i] *= b[i]; } fft_inverse(d, a); vector<long double> res(2 * n - 1); for (int i = 0; i <= 2 * n - 2; i++) { res[i] = a[i].real(); } return res; } int main() { cin.tie(0); ios_base::sync_with_stdio(false); int N; cin >> N; vector<int> A(2 * N); for (int i = 0; i < 2 * N; i++) { cin >> A[i]; if (A[i] != -1) { A[i] -= 1; } } mt19937_64 mt(1); uniform_real_distribution<long double> p(1.0, 2.0); vector<long double> g(2 * N); for (int i = 0; i < 2 * N; i++) { g[i] = p(mt); } vector<long double> sa(2 * N), sb(2 * N); for (int i = 0; i < 2 * N; i++) { if (A[i] != -1) { sa[i] = g[A[i]]; sb[i] = 1.0L / g[A[i]]; } } vector<long double> res = convolve(2 * N, sa, sb); res.resize(4 * N); bool ans = false; for (int i = 0; i < 2 * N; i++) { long double z = res[i] + res[i + 2 * N]; long double f = round(z); if (abs(z - f) < 1.0e-8L) { ans = true; } } cout << (ans ? "Yes" : "No") << endl; return 0; }