結果
問題 | No.332 数列をプレゼントに |
ユーザー | LayCurse |
提出日時 | 2015-12-25 00:17:19 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,562 bytes |
コンパイル時間 | 1,445 ms |
コンパイル使用メモリ | 161,676 KB |
実行使用メモリ | 23,160 KB |
最終ジャッジ日時 | 2024-09-18 23:08:28 |
合計ジャッジ時間 | 20,876 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 20 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 8 ms
6,940 KB |
testcase_04 | AC | 3 ms
7,740 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 602 ms
20,772 KB |
testcase_08 | WA | - |
testcase_09 | AC | 85 ms
8,340 KB |
testcase_10 | AC | 156 ms
10,536 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 6 ms
17,916 KB |
testcase_16 | AC | 7 ms
18,096 KB |
testcase_17 | AC | 21 ms
20,728 KB |
testcase_18 | AC | 6 ms
18,216 KB |
testcase_19 | AC | 19 ms
20,444 KB |
testcase_20 | AC | 7 ms
18,076 KB |
testcase_21 | AC | 7 ms
19,996 KB |
testcase_22 | AC | 6 ms
18,124 KB |
testcase_23 | WA | - |
testcase_24 | AC | 693 ms
22,676 KB |
testcase_25 | AC | 584 ms
21,144 KB |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | AC | 635 ms
20,932 KB |
testcase_29 | AC | 627 ms
22,440 KB |
testcase_30 | WA | - |
testcase_31 | AC | 587 ms
21,232 KB |
testcase_32 | AC | 636 ms
21,068 KB |
testcase_33 | AC | 629 ms
22,056 KB |
testcase_34 | AC | 660 ms
21,980 KB |
testcase_35 | AC | 552 ms
21,416 KB |
testcase_36 | AC | 3 ms
6,944 KB |
testcase_37 | AC | 13 ms
20,408 KB |
testcase_38 | AC | 554 ms
21,428 KB |
testcase_39 | AC | 18 ms
20,740 KB |
testcase_40 | AC | 618 ms
22,340 KB |
testcase_41 | AC | 601 ms
23,160 KB |
testcase_42 | AC | 596 ms
21,068 KB |
testcase_43 | AC | 590 ms
20,920 KB |
testcase_44 | AC | 19 ms
22,336 KB |
testcase_45 | AC | 588 ms
22,596 KB |
testcase_46 | AC | 270 ms
12,716 KB |
コンパイルメッセージ
main.cpp: In function ‘void reader(double*)’: main.cpp:15:29: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | void reader(double *x){scanf("%lf",x);} | ~~~~~^~~~~~~~~
ソースコード
#include<bits/stdc++.h> using namespace std; #define REP(i,a,b) for(i=a;i<b;i++) #define rep(i,n) REP(i,0,n) #define mygc(c) (c)=getchar_unlocked() #define mypc(c) putchar_unlocked(c) #define ll long long #define ull unsigned ll void reader(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);} void reader(ll *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);} void reader(double *x){scanf("%lf",x);} int reader(char c[]){int i,s=0;for(;;){mygc(i);if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF) break;}c[s++]=i;for(;;){mygc(i);if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF) break;c[s++]=i;}c[s]='\0';return s;} template <class T, class S> void reader(T *x, S *y){reader(x);reader(y);} template <class T, class S, class U> void reader(T *x, S *y, U *z){reader(x);reader(y);reader(z);} template <class T, class S, class U, class V> void reader(T *x, S *y, U *z, V *w){reader(x);reader(y);reader(z);reader(w);} void writer(int x, char c){int s=0,m=0;char f[10];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);} void writer(ll x, char c){int s=0,m=0;char f[20];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);} void writer(double x, char c){printf("%.15f",x);mypc(c);} void writer(const char c[]){int i;for(i=0;c[i]!='\0';i++)mypc(c[i]);} void writer(const char x[], char c){int i;for(i=0;x[i]!='\0';i++)mypc(x[i]);mypc(c);} template<class T> void writerLn(T x){writer(x,'\n');} template<class T, class S> void writerLn(T x, S y){writer(x,' ');writer(y,'\n');} template<class T, class S, class U> void writerLn(T x, S y, U z){writer(x,' ');writer(y,' ');writer(z,'\n');} template<class T> void writerArr(T x[], int n){int i;if(!n){mypc('\n');return;}rep(i,n-1)writer(x[i],' ');writer(x[n-1],'\n');} char memarr[17000000]; void *mem = memarr; #define MD 1000000007 int getPrime(int N, int res[]){int i,a,b,s=1,f[4780],S=1;const int r=23000;bool B[r],*p=B;N/=2;res[0]=2;b=min(r,N);REP(i,1,b)p[i]=1;REP(i,1,b)if(p[i]){res[s++]=2*i+1;f[S]=2*i*(i+1);if(f[S]<N){for(;f[S]<r;f[S]+=res[S])p[f[S]]=0;S++;}}for(a=r;a<N;a+=r){b=min(a+r,N);p-=r;REP(i,a,b)p[i]=1;REP(i,1,S)for(;f[i]<b;f[i]+=res[i])p[f[i]]=0;REP(i,a,b)if(p[i])res[s++]=2*i+1;}return s;} int N, A[120]; ll X; int ps, p[30000], md; int dp[120][40000]; int res[120]; int main(){ int i, j, k, tar, loop; ll chk; reader(&N,&X); rep(i,N) reader(A+i); ps = getPrime(30000, p); srand(time(NULL)); rep(loop,60){ md = p[rand()%ps]; tar = X % md; rep(i,N+1) rep(j,md) dp[i][j] = 0; rep(i,N){ dp[i+1][A[i]%md] = 1; rep(j,md) dp[i+1][(j+A[i])%md] |= dp[i][j]; rep(j,md) dp[i+1][j] |= dp[i][j]; } // writerLn(tar); // rep(i,N+1) rep(j,md) if(dp[i][j]) printf("%d %d %d\n",i,j,dp[i][j]); // puts(""); if(dp[N][tar]){ rep(i,N) res[i] = 0; i = N-1; j = tar; for(;;){ if(j==A[i]%md){ res[i]=1; break; } if(dp[i][((j-A[i])%md+md)%md]){ res[i]=1; j=((j-A[i])%md+md)%md; i--; continue; } i--; } chk = 0; rep(i,N) if(res[i]) chk += A[i]; // writerLn(chk); // writerArr(res,N); if(chk==X){ rep(i,N) mypc(res[i]?'o':'x'); mypc('\n'); return 0; } } } writerLn("No"); return 0; }