Submission #33849395
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,n) for (ll i=a;i<(ll)n;i++)
#define per(i,a,n) for (ll i=n;i-->(ll)a;)
#define pb push_back
ll read(){ll r;scanf("%lld",&r);return r;} // read
bitset<3600001> dp[2001]; // bitset 压空间, dp[前i个][值] = 是否可达
int d[2000];
// 旋转矩阵: 逆时针 45度 * 根号2
// (x y) ( 1 1) => (x-y, x+y)
// (-1 1)
// x y y x
// L: (-1 0) => (-1 -1) => +1)/2 => (0,0) 0 + 0 = 0
// D: (0 -1) => ( 1 -1) => +1)/2 => (1,0) 0 + 1 = 1
// U: (0 1) => (-1 1) => +1)/2 => (0,1) 10 + 0 = 10
// R: (1 0) => ( 1 1) => +1)/2 => (1,1) 10 + 1 = 11
const char c[] = { 'L','D','U','R'};
char ans[2010];
bool w(){
int n = read();
int x = read();
int y = read();
int m[2] = {x-y,x+y};
int s = 0;
rep(i,0, n) {
d[i] = read(); // [1,1800]
s += d[i];
}
rep(i,0,2) if(abs(m[i]) > s) return false; // 过远
rep(i,0,2) if((m[i] + s) % 2 != 0) return false; // (m[i] + s )/2 = 选部分di
rep(i,0,2) m[i] = (m[i] + s) / 2;
dp[0][0] = true;
rep(i,0, 2000) dp[i + 1] = dp[i] | (dp[i] << d[i]); // 哇
rep(j,0,2) if(!dp[n][m[j]]) return false; // 有值无法构成
per(i,0,n){ // 倒着找哪些用了哪些没用
int bit = 0;
rep(j,0,2) if (!dp[i][m[j]]) { // 表示可达, 直接贪心选取, 两个中必有一个可行,一个不可行另一个一定可行
m[j] -= d[i];
bit += (1 << j);
}
ans[i] = c[bit];
}
return true;
}
int main() {
if(!w()) printf("No\n");
else {
printf("Yes\n");
printf("%s\n",ans);
}
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | G - Jumping sequence |
| User | cromarmot |
| Language | C++ (GCC 9.2.1) |
| Score | 600 |
| Code Size | 1637 Byte |
| Status | AC |
| Exec Time | 834 ms |
| Memory | 883576 KiB |
Compile Error
./Main.cpp: In function ‘ll read()’:
./Main.cpp:9:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
9 | ll read(){ll r;scanf("%lld",&r);return r;} // read
| ~~~~~^~~~~~~~~~~
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 600 / 600 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | example_00.txt, example_01.txt, example_02.txt |
| All | example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, hand_10.txt, hand_11.txt, hand_12.txt, hand_13.txt, hand_14.txt, hand_15.txt, hand_16.txt, hand_17.txt, hand_18.txt, hand_19.txt, hand_20.txt, hand_21.txt, hand_22.txt, hand_23.txt, periodic_00.txt, periodic_01.txt, periodic_02.txt, periodic_03.txt, periodic_04.txt, periodic_05.txt, periodic_06.txt, periodic_07.txt, periodic_08.txt, periodic_09.txt, periodic_10.txt, periodic_11.txt, periodic_12.txt, periodic_13.txt, periodic_14.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| example_00.txt | AC | 834 ms | 883564 KiB |
| example_01.txt | AC | 648 ms | 883464 KiB |
| example_02.txt | AC | 652 ms | 883448 KiB |
| hand_00.txt | AC | 749 ms | 883348 KiB |
| hand_01.txt | AC | 753 ms | 883448 KiB |
| hand_02.txt | AC | 760 ms | 883312 KiB |
| hand_03.txt | AC | 755 ms | 883444 KiB |
| hand_04.txt | AC | 755 ms | 883576 KiB |
| hand_05.txt | AC | 755 ms | 883440 KiB |
| hand_06.txt | AC | 754 ms | 883464 KiB |
| hand_07.txt | AC | 749 ms | 883464 KiB |
| hand_08.txt | AC | 2 ms | 3512 KiB |
| hand_09.txt | AC | 758 ms | 883492 KiB |
| hand_10.txt | AC | 7 ms | 3516 KiB |
| hand_11.txt | AC | 2 ms | 3516 KiB |
| hand_12.txt | AC | 2 ms | 3696 KiB |
| hand_13.txt | AC | 4 ms | 3652 KiB |
| hand_14.txt | AC | 3 ms | 3672 KiB |
| hand_15.txt | AC | 2 ms | 3632 KiB |
| hand_16.txt | AC | 2 ms | 3552 KiB |
| hand_17.txt | AC | 2 ms | 3632 KiB |
| hand_18.txt | AC | 2 ms | 3652 KiB |
| hand_19.txt | AC | 2 ms | 3648 KiB |
| hand_20.txt | AC | 1 ms | 3512 KiB |
| hand_21.txt | AC | 2 ms | 3668 KiB |
| hand_22.txt | AC | 2 ms | 3700 KiB |
| hand_23.txt | AC | 2 ms | 3672 KiB |
| periodic_00.txt | AC | 744 ms | 883448 KiB |
| periodic_01.txt | AC | 754 ms | 883448 KiB |
| periodic_02.txt | AC | 756 ms | 883444 KiB |
| periodic_03.txt | AC | 757 ms | 883464 KiB |
| periodic_04.txt | AC | 753 ms | 883352 KiB |
| periodic_05.txt | AC | 688 ms | 883312 KiB |
| periodic_06.txt | AC | 681 ms | 883464 KiB |
| periodic_07.txt | AC | 681 ms | 883464 KiB |
| periodic_08.txt | AC | 678 ms | 883456 KiB |
| periodic_09.txt | AC | 682 ms | 883460 KiB |
| periodic_10.txt | AC | 644 ms | 883424 KiB |
| periodic_11.txt | AC | 647 ms | 883344 KiB |
| periodic_12.txt | AC | 648 ms | 883464 KiB |
| periodic_13.txt | AC | 645 ms | 883472 KiB |
| periodic_14.txt | AC | 652 ms | 883308 KiB |
| random_00.txt | AC | 652 ms | 883460 KiB |
| random_01.txt | AC | 752 ms | 883452 KiB |
| random_02.txt | AC | 2 ms | 3640 KiB |
| random_03.txt | AC | 752 ms | 883312 KiB |
| random_04.txt | AC | 755 ms | 883452 KiB |
| random_05.txt | AC | 646 ms | 883452 KiB |
| random_06.txt | AC | 752 ms | 883304 KiB |
| random_07.txt | AC | 755 ms | 883424 KiB |
| random_08.txt | AC | 752 ms | 883464 KiB |
| random_09.txt | AC | 751 ms | 883308 KiB |
| random_10.txt | AC | 653 ms | 883496 KiB |
| random_11.txt | AC | 749 ms | 883468 KiB |
| random_12.txt | AC | 749 ms | 883304 KiB |
| random_13.txt | AC | 749 ms | 883492 KiB |
| random_14.txt | AC | 2 ms | 3656 KiB |
| random_15.txt | AC | 659 ms | 883448 KiB |
| random_16.txt | AC | 751 ms | 883444 KiB |
| random_17.txt | AC | 749 ms | 883444 KiB |
| random_18.txt | AC | 748 ms | 883444 KiB |
| random_19.txt | AC | 755 ms | 883440 KiB |
| random_20.txt | AC | 654 ms | 883564 KiB |
| random_21.txt | AC | 749 ms | 883448 KiB |
| random_22.txt | AC | 755 ms | 883428 KiB |
| random_23.txt | AC | 754 ms | 883456 KiB |
| random_24.txt | AC | 748 ms | 883440 KiB |
| random_25.txt | AC | 649 ms | 883572 KiB |
| random_26.txt | AC | 757 ms | 883440 KiB |
| random_27.txt | AC | 752 ms | 883440 KiB |
| random_28.txt | AC | 753 ms | 883468 KiB |
| random_29.txt | AC | 755 ms | 883452 KiB |