結果
問題 | No.854 公平なりんご分配 |
ユーザー | Sumitacchan |
提出日時 | 2019-07-26 22:07:05 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,808 bytes |
コンパイル時間 | 1,872 ms |
コンパイル使用メモリ | 177,076 KB |
実行使用メモリ | 243,444 KB |
最終ジャッジ日時 | 2024-07-02 07:25:30 |
合計ジャッジ時間 | 22,178 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
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 | 2 ms
5,376 KB |
testcase_16 | AC | 3 ms
5,376 KB |
testcase_17 | AC | 3 ms
5,376 KB |
testcase_18 | AC | 2 ms
5,376 KB |
testcase_19 | AC | 2 ms
5,376 KB |
testcase_20 | AC | 2 ms
5,376 KB |
testcase_21 | AC | 2 ms
5,376 KB |
testcase_22 | WA | - |
testcase_23 | WA | - |
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 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | WA | - |
testcase_52 | WA | - |
testcase_53 | WA | - |
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 | WA | - |
testcase_75 | WA | - |
testcase_76 | WA | - |
testcase_77 | WA | - |
testcase_78 | WA | - |
testcase_79 | WA | - |
testcase_80 | WA | - |
testcase_81 | WA | - |
testcase_82 | AC | 697 ms
242,432 KB |
testcase_83 | AC | 1,048 ms
242,432 KB |
testcase_84 | AC | 1,035 ms
242,432 KB |
testcase_85 | AC | 1,078 ms
242,304 KB |
testcase_86 | AC | 318 ms
243,444 KB |
testcase_87 | AC | 695 ms
242,304 KB |
testcase_88 | AC | 699 ms
242,304 KB |
testcase_89 | AC | 698 ms
242,304 KB |
testcase_90 | AC | 699 ms
242,432 KB |
testcase_91 | AC | 698 ms
242,304 KB |
testcase_92 | WA | - |
testcase_93 | WA | - |
ソースコード
#include <bits/stdc++.h> using namespace std; struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_; #define FOR(i, begin, end) for(int i=(begin);i<(end);i++) #define REP(i, n) FOR(i,0,n) #define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--) #define IREP(i, n) IFOR(i,0,n) #define Sort(v) sort(v.begin(), v.end()) #define Reverse(v) reverse(v.begin(), v.end()) #define all(v) v.begin(),v.end() #define SZ(v) ((int)v.size()) #define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x)) #define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x)) #define Max(a, b) a = max(a, b) #define Min(a, b) a = min(a, b) #define bit_exist(x, n) ((x >> n) & 1) #define debug(x) cout << #x << "=" << x << endl; #define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; #define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} #define pb push_back #define f first #define s second #define int long long #define INF 1000000000000000000 template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; } template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; } template<typename T> void Out(T x) { cout << x << endl; } template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); } using vec = vector<int>; using mat = vector<vec>; using Pii = pair<int, int>; using PiP = pair<int, Pii>; using PPi = pair<Pii, int>; using bools = vector<bool>; using pairs = vector<Pii>; //int dx[4] = {1,0,-1,0}; //int dy[4] = {0,1,0,-1}; //char d[4] = {'D','R','U','L'}; const int mod = 1000000007; //const int mod = 998244353; #define Add(x, y) x = (x + (y)) % mod #define Mult(x, y) x = (x * (y)) % mod class BIT { public: vector<int> bit; int M; BIT(int M): bit(vector<int>(M+1, 0)), M(M) {} int sum(int i) { if (!i) return 0; return bit[i] + sum(i-(i&-i)); } void add(int i, int x) { if (i > M) return; bit[i] += x; add(i+(i&-i), x); } }; vec prime_list(int MAX_N){ vector<bool> is_prime(MAX_N + 1, true); vec prime(0); is_prime[0] = false; is_prime[1] = false; FOR(i, 2, MAX_N + 1){ if(is_prime[i]){ prime.push_back(i); int tmp = i * 2; while(tmp <= MAX_N){ is_prime[tmp] = false; tmp += i; } } } return prime; } signed main(){ int N; cin >> N; vec A(N); cin >> A; vec p = prime_list(2000); //debug(SZ(p)); int n = SZ(p); vector<BIT> b(n, BIT(N)); vec zero; REP(i, N){ if(A[i] != 0){ REP(j, n){ int c = 0; while(A[i] % p[j] == 0){ c++; A[i] /= p[j]; } if(c) b[j].add(i + 1, c); } }else{ zero.pb(i + 1); } } int Q; cin >> Q; int P, L, R; bools ans(Q); REP(q, Q){ cin >> P >> L >> R; ans[q] = true; int i0 = Lower_bound(zero, L); if(i0 < SZ(zero) && zero[i0] <= R) continue; REP(j, n){ int c = 0; while(P % p[j] == 0){ c++; P /= p[j]; } if(c > 0 && c > b[j].sum(R) - b[j].sum(L - 1)){ ans[q] = false; break; } } } REP(q, Q) Ans(ans[q], "Yes", "NO"); return 0; }