Submission #3296247

Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }


void solveS(int N,vi& x,vi& y) {

    vi _cnt(2, 0);
    int lmax = 0;
    vi ls(N), rs(N);
    rep(i,N){
        int l = abs(x[i]) + abs(y[i]);
        ls[i] = l;
        lmax = max(lmax, l);
        _cnt[l % 2]++;
    }
    if (_cnt[0] && _cnt[1]) {
        cout << -1 << endl;
        return;
    }

    int m = lmax; // (_cnt[1]) ? 19 : 20;
    if (m > 40) {
      cout << -1 << endl;
      return;
    }
    printf("%d\n", m);
    printf("1");
    rep(i, m-1) printf(" 1");
    printf("\n");
    rep(i,N){
        int rem = m;
        if (x[i] > 0) { // right
            rep(j, x[i]) putchar('R');
            rem -= x[i];
        } else if (x[i] < 0) { // left
          rep(j, -x[i]) putchar('L');
          rem += x[i];
        } else {
          //
        }
        if (y[i] > 0) { // up
          rep(j, y[i]) putchar('U');
          rem -= y[i];
        } else if (y[i] < 0) {  // down
          rep(j, -y[i]) putchar('D');
          rem += y[i];
        } else {
          //
        }
        assert(rem >= 0 && rem%2 == 0);
        for (int j=0; j<rem; j+=2) {
          putchar('R');
          putchar('L');
        }
        putchar('\n');
    }
}


int main() {
  int N;
  cin >> N;
  vi x(N), y(N);
  rep(i, N) cin >> x[i] >> y[i];
  solveS(N, x, y);
  return 0;
}

Submission Info

Submission Time
Task D - Robot Arms
User naoya_t
Language C++14 (GCC 5.4.1)
Score 300
Code Size 2627 Byte
Status
Exec Time 2 ms
Memory 256 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample1.txt, sample2.txt, sample3.txt, sample4.txt
subtask 300 / 300 sample1.txt, sample2.txt, sample3.txt, sample4.txt, sub1.txt, sub10.txt, sub11.txt, sub12.txt, sub13.txt, sub14.txt, sub15.txt, sub16.txt, sub2.txt, sub3.txt, sub4.txt, sub5.txt, sub6.txt, sub7.txt, sub8.txt, sub9.txt
All 0 / 300 sample1.txt, sample2.txt, sample3.txt, sample4.txt, 1.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 2.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 3.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 4.txt, 5.txt, 6.txt, 7.txt, 8.txt, 9.txt, sample1.txt, sample2.txt, sample3.txt, sample4.txt, sub1.txt, sub10.txt, sub11.txt, sub12.txt, sub13.txt, sub14.txt, sub15.txt, sub16.txt, sub2.txt, sub3.txt, sub4.txt, sub5.txt, sub6.txt, sub7.txt, sub8.txt, sub9.txt
Case Name Status Exec Time Memory
1.txt 1 ms 256 KB
10.txt 2 ms 256 KB
11.txt 2 ms 256 KB
12.txt 2 ms 256 KB
13.txt 2 ms 256 KB
14.txt 2 ms 256 KB
15.txt 2 ms 256 KB
16.txt 2 ms 256 KB
17.txt 2 ms 256 KB
18.txt 2 ms 256 KB
19.txt 2 ms 256 KB
2.txt 1 ms 256 KB
20.txt 2 ms 256 KB
21.txt 2 ms 256 KB
22.txt 2 ms 256 KB
23.txt 2 ms 256 KB
24.txt 2 ms 256 KB
25.txt 2 ms 256 KB
26.txt 2 ms 256 KB
27.txt 2 ms 256 KB
28.txt 2 ms 256 KB
29.txt 2 ms 256 KB
3.txt 2 ms 256 KB
30.txt 2 ms 256 KB
31.txt 2 ms 256 KB
32.txt 2 ms 256 KB
33.txt 2 ms 256 KB
34.txt 2 ms 256 KB
4.txt 2 ms 256 KB
5.txt 2 ms 256 KB
6.txt 2 ms 256 KB
7.txt 2 ms 256 KB
8.txt 2 ms 256 KB
9.txt 2 ms 256 KB
sample1.txt 1 ms 256 KB
sample2.txt 1 ms 256 KB
sample3.txt 1 ms 256 KB
sample4.txt 1 ms 256 KB
sub1.txt 1 ms 256 KB
sub10.txt 2 ms 256 KB
sub11.txt 2 ms 256 KB
sub12.txt 2 ms 256 KB
sub13.txt 2 ms 256 KB
sub14.txt 2 ms 256 KB
sub15.txt 2 ms 256 KB
sub16.txt 2 ms 256 KB
sub2.txt 1 ms 256 KB
sub3.txt 2 ms 256 KB
sub4.txt 2 ms 256 KB
sub5.txt 2 ms 256 KB
sub6.txt 2 ms 256 KB
sub7.txt 2 ms 256 KB
sub8.txt 2 ms 256 KB
sub9.txt 2 ms 256 KB