Submission #51645719


Source Code Expand

// LUOGU_RID: 152544326
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll MOD=998244353;
// head

int main() 
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    bitset<3600001> dp[2001];
    char op[4]={'L','U','D','R'};
    int d[2000];
    int m[2];

    int n,x,y;cin>>n>>x>>y;
    int sum=0;
    for(int i=0;i<n;i++) {cin>>d[i];sum+=d[i];}
    m[0]=x+y,m[1]=x-y;
    bool flag=true;
    for(int i=0;i<2;i++) if(abs(m[i])>sum) flag=false;
    for(int i=0;i<2;i++) if((m[i]+sum)%2!=0) flag=false;
    if(!flag) {cout<<"No"<<endl;return 0;}
    for(int i=0;i<2;i++) m[i]=(m[i]+sum)/2;
    dp[0][0]=1;
    for(int i=0;i<2000;i++) dp[i+1]=dp[i]|(dp[i]<<d[i]);
    if((!dp[n][m[0]])||(!dp[n][m[1]])) {cout<<"No"<<endl;return 0;}
    string ans;
    for(int i=n-1;i>=0;i--){
        sum=0;
        for(int j=0;j<2;j++){
            if(!dp[i][m[j]]){
                m[j]-=d[i];
                sum+=(1<<j);
            }
        }
        ans=op[sum]+ans;
    }
    cout<<"Yes"<<endl;
    cout<<ans<<endl;
}

Submission Info

Submission Time
Task G - Jumping sequence
User gangbengr
Language C++ 17 (gcc 12.2)
Score 600
Code Size 1318 Byte
Status AC
Exec Time 723 ms
Memory 883936 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 3
AC × 72
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 628 ms 883708 KiB
example_01.txt AC 635 ms 883896 KiB
example_02.txt AC 650 ms 883668 KiB
hand_00.txt AC 690 ms 883860 KiB
hand_01.txt AC 682 ms 883924 KiB
hand_02.txt AC 695 ms 883836 KiB
hand_03.txt AC 700 ms 883744 KiB
hand_04.txt AC 703 ms 883932 KiB
hand_05.txt AC 703 ms 883696 KiB
hand_06.txt AC 717 ms 883700 KiB
hand_07.txt AC 716 ms 883856 KiB
hand_08.txt AC 424 ms 883780 KiB
hand_09.txt AC 690 ms 883936 KiB
hand_10.txt AC 390 ms 883672 KiB
hand_11.txt AC 390 ms 883656 KiB
hand_12.txt AC 389 ms 883668 KiB
hand_13.txt AC 392 ms 883856 KiB
hand_14.txt AC 390 ms 883712 KiB
hand_15.txt AC 395 ms 883708 KiB
hand_16.txt AC 395 ms 883784 KiB
hand_17.txt AC 391 ms 883708 KiB
hand_18.txt AC 411 ms 883756 KiB
hand_19.txt AC 406 ms 883748 KiB
hand_20.txt AC 408 ms 883780 KiB
hand_21.txt AC 413 ms 883708 KiB
hand_22.txt AC 410 ms 883668 KiB
hand_23.txt AC 416 ms 883756 KiB
periodic_00.txt AC 698 ms 883792 KiB
periodic_01.txt AC 696 ms 883852 KiB
periodic_02.txt AC 695 ms 883768 KiB
periodic_03.txt AC 710 ms 883932 KiB
periodic_04.txt AC 722 ms 883780 KiB
periodic_05.txt AC 645 ms 883744 KiB
periodic_06.txt AC 618 ms 883848 KiB
periodic_07.txt AC 624 ms 883784 KiB
periodic_08.txt AC 623 ms 883744 KiB
periodic_09.txt AC 661 ms 883784 KiB
periodic_10.txt AC 634 ms 883904 KiB
periodic_11.txt AC 629 ms 883712 KiB
periodic_12.txt AC 638 ms 883712 KiB
periodic_13.txt AC 632 ms 883780 KiB
periodic_14.txt AC 634 ms 883908 KiB
random_00.txt AC 646 ms 883648 KiB
random_01.txt AC 710 ms 883920 KiB
random_02.txt AC 417 ms 883708 KiB
random_03.txt AC 675 ms 883792 KiB
random_04.txt AC 682 ms 883860 KiB
random_05.txt AC 598 ms 883784 KiB
random_06.txt AC 689 ms 883932 KiB
random_07.txt AC 707 ms 883788 KiB
random_08.txt AC 712 ms 883768 KiB
random_09.txt AC 708 ms 883860 KiB
random_10.txt AC 628 ms 883904 KiB
random_11.txt AC 715 ms 883936 KiB
random_12.txt AC 714 ms 883776 KiB
random_13.txt AC 697 ms 883784 KiB
random_14.txt AC 397 ms 883900 KiB
random_15.txt AC 595 ms 883704 KiB
random_16.txt AC 668 ms 883668 KiB
random_17.txt AC 672 ms 883936 KiB
random_18.txt AC 676 ms 883676 KiB
random_19.txt AC 683 ms 883776 KiB
random_20.txt AC 636 ms 883700 KiB
random_21.txt AC 712 ms 883860 KiB
random_22.txt AC 712 ms 883760 KiB
random_23.txt AC 711 ms 883744 KiB
random_24.txt AC 708 ms 883724 KiB
random_25.txt AC 641 ms 883776 KiB
random_26.txt AC 708 ms 883780 KiB
random_27.txt AC 709 ms 883744 KiB
random_28.txt AC 723 ms 883904 KiB
random_29.txt AC 692 ms 883860 KiB