結果
問題 | No.1349 Subset Product Queries |
ユーザー | LayCurse |
提出日時 | 2021-01-16 14:11:03 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 4,987 bytes |
コンパイル時間 | 2,929 ms |
コンパイル使用メモリ | 221,344 KB |
実行使用メモリ | 30,096 KB |
最終ジャッジ日時 | 2024-11-27 15:18:05 |
合計ジャッジ時間 | 49,568 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
14,576 KB |
testcase_01 | AC | 3 ms
22,516 KB |
testcase_02 | AC | 2 ms
14,576 KB |
testcase_03 | AC | 3 ms
16,632 KB |
testcase_04 | AC | 3 ms
14,580 KB |
testcase_05 | AC | 3 ms
22,032 KB |
testcase_06 | AC | 3 ms
16,364 KB |
testcase_07 | AC | 3 ms
22,580 KB |
testcase_08 | AC | 3 ms
16,500 KB |
testcase_09 | AC | 3 ms
21,624 KB |
testcase_10 | AC | 3 ms
14,444 KB |
testcase_11 | AC | 1,783 ms
26,508 KB |
testcase_12 | AC | 1,315 ms
22,004 KB |
testcase_13 | AC | 1,942 ms
27,540 KB |
testcase_14 | TLE | - |
testcase_15 | AC | 1,336 ms
26,448 KB |
testcase_16 | AC | 1,655 ms
21,392 KB |
testcase_17 | TLE | - |
testcase_18 | AC | 230 ms
19,632 KB |
testcase_19 | AC | 209 ms
28,020 KB |
testcase_20 | AC | 998 ms
21,228 KB |
testcase_21 | TLE | - |
testcase_22 | TLE | - |
testcase_23 | TLE | - |
testcase_24 | TLE | - |
testcase_25 | TLE | - |
testcase_26 | TLE | - |
testcase_27 | TLE | - |
testcase_28 | TLE | - |
testcase_29 | TLE | - |
testcase_30 | TLE | - |
ソースコード
#pragma GCC optimize ("Ofast") #include<bits/stdc++.h> using namespace std; void*wmem; char memarr[96000000]; template<class T> inline void walloc1d(T **arr, int x, void **mem = &wmem){ static int skip[16] = {0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}; (*mem) = (void*)( ((char*)(*mem)) + skip[((unsigned long long)(*mem)) & 15] ); (*arr)=(T*)(*mem); (*mem)=((*arr)+x); } template<class T> inline void walloc1d(T **arr, int x1, int x2, void **mem = &wmem){ walloc1d(arr, x2-x1, mem); (*arr) -= x1; } template<class T1, class T2, class T3> void sortA_L(int N, T1 a[], T2 b[], T3 c[], void *mem = wmem){ int i; pair<T1, pair<T2, T3> >*arr; walloc1d(&arr, N, &mem); for(i=(0);i<(N);i++){ arr[i].first = a[i]; arr[i].second.first = b[i]; arr[i].second.second = c[i]; } sort(arr, arr+N); for(i=(0);i<(N);i++){ a[i] = arr[i].first; b[i] = arr[i].second.first; c[i] = arr[i].second.second; } } template<class T1, class T2, class T3, class T4> void sortA_L(int N, T1 a[], T2 b[], T3 c[], T4 d[], void *mem = wmem){ int i; pair<pair<T1, T2>, pair<T3, T4> >*arr; walloc1d(&arr, N, &mem); for(i=(0);i<(N);i++){ arr[i].first.first = a[i]; arr[i].first.second = b[i]; arr[i].second.first = c[i]; arr[i].second.second = d[i]; } sort(arr, arr+N); for(i=(0);i<(N);i++){ a[i] = arr[i].first.first; b[i] = arr[i].first.second; c[i] = arr[i].second.first; d[i] = arr[i].second.second; } } inline int my_getchar_unlocked(){ static char buf[1048576]; static int s = 1048576; static int e = 1048576; if(s == e && e == 1048576){ e = fread_unlocked(buf, 1, 1048576, stdin); s = 0; } if(s == e){ return EOF; } return buf[s++]; } inline void rd(int &x){ int k; int m=0; x=0; for(;;){ k = my_getchar_unlocked(); if(k=='-'){ m=1; break; } if('0'<=k&&k<='9'){ x=k-'0'; break; } } for(;;){ k = my_getchar_unlocked(); if(k<'0'||k>'9'){ break; } x=x*10+k-'0'; } if(m){ x=-x; } } struct MY_WRITER{ char buf[1048576]; int s; int e; MY_WRITER(){ s = 0; e = 1048576; } ~MY_WRITER(){ if(s){ fwrite_unlocked(buf, 1, s, stdout); } } } ; MY_WRITER MY_WRITER_VAR; void my_putchar_unlocked(int a){ if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){ fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout); MY_WRITER_VAR.s = 0; } MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a; } inline void wt_L(char a){ my_putchar_unlocked(a); } inline void wt_L(const char c[]){ int i=0; for(i=0;c[i]!='\0';i++){ my_putchar_unlocked(c[i]); } } int N; int Q; int P; int A[5000]; int L[200000]; int R[200000]; int K[200000]; int ind[200000]; int res[200000]; int ds; int d[5000]; int ok[5000]; int main(){ wmem = memarr; int i; int j; int k; int q = 0; int x; rd(N); rd(Q); rd(P); { int Lj4PdHRW; for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){ rd(A[Lj4PdHRW]); } } { int e98WHCEY; for(e98WHCEY=(0);e98WHCEY<(Q);e98WHCEY++){ rd(L[e98WHCEY]);L[e98WHCEY] += (-1); rd(R[e98WHCEY]);R[e98WHCEY] += (-1); rd(K[e98WHCEY]); } } for(i=(0);i<(Q);i++){ ind[i] = i; } sortA_L(Q, L, R, K, ind); for(k=(0);k<(N);k++){ if(q == Q || L[q] != k){ continue; } ds = 0; for(i=(0);i<(P);i++){ ok[i] = 0; } for(i=(k);i<(N);i++){ int hCmBdyQB = ds; for(j=(0);j<(hCmBdyQB);j++){ x = d[j] * A[i] % P; if(ok[x]==0){ d[ds++] = x; ok[x] = 1; } } if(!ok[A[i]]){ d[ds++] = A[i]; ok[A[i]] = 1; } while(q < Q && L[q] == k){ if(ok[K[q]]){ res[ind[q]] = 1; q++; continue; } if(R[q] == i){ q++; continue; } break; } if(q == Q || L[q] != k){ break; } } } for(i=(0);i<(Q);i++){ if(res[i]){ wt_L("Yes"); wt_L('\n'); } else{ wt_L("No"); wt_L('\n'); } } return 0; } // cLay version 20210103-1 [bug fixed 1] // --- original code --- // int N, Q, P, A[5000], L[2d5], R[2d5], K[2d5], ind[2d5], res[2d5]; // int ds, d[5000], ok[5000]; // { // int i, j, k, q = 0, x; // rd(N,Q,P,A(N),(L--,R--,K)(Q)); // rep(i,Q) ind[i] = i; // sortA(Q, L, R, K, ind); // // rep(k,N){ // if(q == Q || L[q] != k) continue; // // ds = 0; // rep(i,P) ok[i] = 0; // // rep(i,k,N){ // REP(j,ds){ // x = d[j] * A[i] % P; // if(ok[x]==0) d[ds++] = x, ok[x] = 1; // } // if(!ok[A[i]]) d[ds++] = A[i], ok[A[i]] = 1; // // while(q < Q && L[q] == k){ // if(ok[K[q]]) res[ind[q]] = 1, q++, continue; // if(R[q] == i) q++, continue; // break; // } // // if(q == Q || L[q] != k) break; // } // } // // rep(i,Q) wt(if[res[i], "Yes", "No"]); // }