結果
| 問題 | No.332 数列をプレゼントに |
| コンテスト | |
| ユーザー |
FF256grhy
|
| 提出日時 | 2015-12-25 11:52:33 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,080 bytes |
| 記録 | |
| コンパイル時間 | 131 ms |
| コンパイル使用メモリ | 23,680 KB |
| 実行使用メモリ | 25,664 KB |
| 最終ジャッジ日時 | 2024-09-18 23:45:06 |
| 合計ジャッジ時間 | 8,874 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 20 RE * 22 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:13:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
13 | scanf("%d%lld", &n, &x);
| ~~~~~^~~~~~~~~~~~~~~~~~
main.cpp:17:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
17 | scanf("%d", &a[i]);
| ~~~~~^~~~~~~~~~~~~
ソースコード
#include <stdio.h>
#define LIM 57797
#define SUM (LIM + 79)
int n, a[100], s_sum[SUM], s_ans[SUM + 1][100], s_c = 1;
long long int x, l_sum[1<<20], l_c;
int main(void) {
s_sum[0] = s_c;
s_c++;
scanf("%d%lld", &n, &x);
int i, j, k, l_c = 0;
for(i = 0; i < n; i++) {
scanf("%d", &a[i]);
if(a[i] < LIM) {
for(j = SUM - 1; 0 <= j; j--) {
if(s_sum[j] != 0 && s_sum[ j + a[i] ] == 0) {
for(k = 0; k < i; k++) {
s_ans[s_c][k] = s_ans[ s_sum[j] ][k];
}
s_ans[s_c][i] = 1;
s_sum[ j + a[i] ] = s_c;
s_c++;
}
}
} else {
for(j = 0; j < (1 << l_c); j++) {
l_sum[ j + (1 << l_c) ] = l_sum[j] + a[i];
}
l_c++;
}
}
int flag = 0;
for(j = 0; j < (1 << l_c); j++) {
long long int v = x - l_sum[j];
if(0 <= v && v < SUM && s_sum[v] != 0) {
flag = 1;
for(i = 0; i < n; i++) {
if(a[i] < LIM) {
printf("%c", s_ans[ s_sum[v] ][i] ? 'o' : 'x');
} else {
printf("%c", j % 2 ? 'o' : 'x');
j /= 2;
}
}
printf("\n");
break;
}
}
if(! flag) { printf("No\n"); }
return 0;
}
FF256grhy