結果
問題 | No.332 数列をプレゼントに |
ユーザー | LayCurse |
提出日時 | 2015-12-25 00:41:11 |
言語 | C++11 (gcc 11.4.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 3,894 bytes |
コンパイル時間 | 1,610 ms |
コンパイル使用メモリ | 162,600 KB |
実行使用メモリ | 332,540 KB |
最終ジャッジ日時 | 2024-09-18 23:13:21 |
合計ジャッジ時間 | 5,808 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 21 ms
19,072 KB |
testcase_01 | AC | 17 ms
11,776 KB |
testcase_02 | AC | 7 ms
7,552 KB |
testcase_03 | AC | 8 ms
7,552 KB |
testcase_04 | AC | 45 ms
26,112 KB |
testcase_05 | AC | 254 ms
127,104 KB |
testcase_06 | MLE | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
testcase_43 | -- | - |
testcase_44 | -- | - |
testcase_45 | -- | - |
testcase_46 | -- | - |
コンパイルメッセージ
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 #define M 100 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[100000], md[M]; int dp[M][120][10000]; int res[120]; int solve(int i, int j[]){ int k, ok; ll chk; if(i==-1){ chk = 0; rep(k,N) if(res[k]) chk += A[k]; if(chk==X) return 1; return 0; } if(solve(i-1, j)) return 1; ok = 1; rep(k,M) if(j[k]==A[i]%md[k] || dp[k][i][((j[k]-A[i])%md[k]+md[k])%md[k]]); else {ok = 0; break;} if(ok){ res[i] = 1; rep(k,M) j[k] = ((j[k]-A[i])%md[k]+md[k])%md[k]; if(solve(i-1, j)) return 1; rep(k,M) j[k] = (j[k]+A[i])%md[k]; res[i] = 0; } return 0; } int main(){ int i, j, k, tar[M], loop; ll chk; reader(&N,&X); rep(i,N) reader(A+i); ps = getPrime(6000, p); srand(time(NULL)); rep(loop,M){ md[loop] = p[(ps/2)+rand()%(ps/2)]; tar[loop] = X % md[loop]; rep(i,N+1) rep(j,md[loop]) dp[loop][i][j] = 0; rep(i,N){ dp[loop][i+1][A[i]%md[loop]] = 1; rep(j,md[loop]) dp[loop][i+1][(j+A[i])%md[loop]] |= dp[loop][i][j]; rep(j,md[loop]) dp[loop][i+1][j] |= dp[loop][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(""); } rep(k,M) if(dp[k][N][tar[k]]==0) break; if(k==M){ rep(i,N) res[i] = 0; k = solve(N-1, tar); if(k){ rep(i,N) mypc(res[i]?'o':'x'); mypc('\n'); return 0; } } writerLn("No"); return 0; }