結果
問題 | No.332 数列をプレゼントに |
ユーザー | LayCurse |
提出日時 | 2015-12-25 00:16:40 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,562 bytes |
コンパイル時間 | 1,633 ms |
コンパイル使用メモリ | 161,784 KB |
実行使用メモリ | 22,984 KB |
最終ジャッジ日時 | 2024-09-18 23:07:54 |
合計ジャッジ時間 | 10,609 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
6,816 KB |
testcase_01 | AC | 7 ms
6,940 KB |
testcase_02 | AC | 3 ms
6,944 KB |
testcase_03 | AC | 4 ms
6,948 KB |
testcase_04 | AC | 4 ms
7,876 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 226 ms
20,524 KB |
testcase_08 | WA | - |
testcase_09 | AC | 31 ms
8,496 KB |
testcase_10 | AC | 54 ms
9,848 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 12 ms
18,304 KB |
testcase_16 | AC | 12 ms
20,120 KB |
testcase_17 | AC | 13 ms
20,404 KB |
testcase_18 | AC | 12 ms
20,128 KB |
testcase_19 | AC | 12 ms
20,088 KB |
testcase_20 | AC | 12 ms
18,228 KB |
testcase_21 | AC | 12 ms
20,256 KB |
testcase_22 | AC | 11 ms
18,308 KB |
testcase_23 | WA | - |
testcase_24 | AC | 194 ms
22,140 KB |
testcase_25 | AC | 192 ms
22,128 KB |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | AC | 223 ms
22,488 KB |
testcase_29 | AC | 223 ms
22,356 KB |
testcase_30 | WA | - |
testcase_31 | AC | 226 ms
21,432 KB |
testcase_32 | AC | 245 ms
21,392 KB |
testcase_33 | AC | 246 ms
21,888 KB |
testcase_34 | AC | 247 ms
21,876 KB |
testcase_35 | AC | 232 ms
22,264 KB |
testcase_36 | AC | 3 ms
6,944 KB |
testcase_37 | AC | 26 ms
21,344 KB |
testcase_38 | AC | 233 ms
21,208 KB |
testcase_39 | AC | 26 ms
21,100 KB |
testcase_40 | AC | 230 ms
22,636 KB |
testcase_41 | AC | 203 ms
21,336 KB |
testcase_42 | AC | 202 ms
22,568 KB |
testcase_43 | AC | 202 ms
21,384 KB |
testcase_44 | AC | 11 ms
20,264 KB |
testcase_45 | AC | 202 ms
22,572 KB |
testcase_46 | AC | 97 ms
12,784 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,20){ 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; }