QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#730060#9564. Hey, Have You Seen My Kangaroo?ucup-team112AC ✓874ms39264kbC++2013.9kb2024-11-09 18:30:312024-11-09 18:30:32

Judging History

你现在查看的是最新测评结果

  • [2024-11-09 18:30:32]
  • 评测
  • 测评结果:AC
  • 用时:874ms
  • 内存:39264kb
  • [2024-11-09 18:30:31]
  • 提交

answer


//#define _GLIBCXX_DEBUG

//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

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


#ifdef LOCAL
#include <debug_print.hpp>
#define OUT(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
#define OUT(...) (static_cast<void>(0))
#endif

#define endl '\n'
#define lfs cout<<fixed<<setprecision(15)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end())
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)

namespace template_tute{
  using ll = long long;
  using ld = long double;
  const ll MOD1 = 1e9+7;
  const ll MOD9 = 998244353;
  const ll INF = 4.1e18;
  using P = pair<ll, ll>;
  template<typename T> using PQ = priority_queue<T>;
  template<typename T> using QP = priority_queue<T,vector<T>,greater<T>>;
  template<typename T1, typename T2>bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
  template<typename T1, typename T2>bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
  ll median(ll a,ll b, ll c){return a+b+c-max<ll>({a,b,c})-min<ll>({a,b,c});}
  void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
  void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
  void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
  template<typename T1,typename T2>void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
  template<typename T1,typename T2,typename T3>void anss(T1 x,T2 y,T3 z){ans(x!=y,x,z);};  
  template<typename T>void debug(const T &v,ll h,ll w,string sv=" "){for(ll i=0;i<h;i++){cout<<v[i][0];for(ll j=1;j<w;j++)cout<<sv<<v[i][j];cout<<endl;}};
  template<typename T>void debug(const T &v,ll n,string sv=" "){if(n!=0)cout<<v[0];for(ll i=1;i<n;i++)cout<<sv<<v[i];cout<<endl;};
  template<typename T>void debug(const vector<T>&v){debug(v,v.size());}
  template<typename T>void debug(const vector<vector<T>>&v){for(auto &vv:v)debug(vv,vv.size());}
  template<typename T>void debug(stack<T> st){while(!st.empty()){cout<<st.top()<<" ";st.pop();}cout<<endl;}
  template<typename T>void debug(queue<T> st){while(!st.empty()){cout<<st.front()<<" ";st.pop();}cout<<endl;}
  template<typename T>void debug(deque<T> st){while(!st.empty()){cout<<st.front()<<" ";st.pop_front();}cout<<endl;}
  template<typename T>void debug(PQ<T> st){while(!st.empty()){cout<<st.top()<<" ";st.pop();}cout<<endl;}
  template<typename T>void debug(QP<T> st){while(!st.empty()){cout<<st.top()<<" ";st.pop();}cout<<endl;}
  template<typename T>void debug(const set<T>&v){for(auto z:v)cout<<z<<" ";cout<<endl;}
  template<typename T>void debug(const multiset<T>&v){for(auto z:v)cout<<z<<" ";cout<<endl;}
  template<typename T,size_t size>void debug(const array<T, size> &a){for(auto z:a)cout<<z<<" ";cout<<endl;}
  template<typename T,typename V>void debug(const map<T,V>&v){for(auto z:v)cout<<"["<<z.first<<"]="<<z.second<<",";cout<<endl;}
  template<typename T>vector<vector<T>>vec(ll x, ll y, T w){vector<vector<T>>v(x,vector<T>(y,w));return v;}
  vector<ll>dx={1,-1,0,0,1,1,-1,-1};vector<ll>dy={0,0,1,-1,1,-1,1,-1};
  template<typename T>vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
  template<typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
  template<typename T1, typename T2>ostream &operator<<(ostream &os, const pair<T1, T2>&p){return os << "(" << p.first << "," << p.second << ")";}
  template<typename T>ostream &operator<<(ostream &os, const vector<T> &v){os<<"[";for(auto &z:v)os << z << ",";os<<"]"; return os;}
  template<typename T>void rearrange(vector<int>&ord, vector<T>&v){
    auto tmp = v;
    for(int i=0;i<tmp.size();i++)v[i] = tmp[ord[i]];
  }
  template<typename Head, typename... Tail>void rearrange(vector<int>&ord,Head&& head, Tail&&... tail){
    rearrange(ord, head);
    rearrange(ord, tail...);
  }
  template<typename T> vector<int> ascend(const vector<T>&v){
    vector<int>ord(v.size());iota(ord.begin(),ord.end(),0);
    sort(ord.begin(),ord.end(),[&](int i,int j){return make_pair(v[i],i)<make_pair(v[j],j);});
    return ord;
  }
  template<typename T> vector<int> descend(const vector<T>&v){
    vector<int>ord(v.size());iota(ord.begin(),ord.end(),0);
    sort(ord.begin(),ord.end(),[&](int i,int j){return make_pair(v[i],-i)>make_pair(v[j],-j);});
    return ord;
  }
  template<typename T> vector<T> inv_perm(const vector<T>&ord){
    vector<T>inv(ord.size());
    for(int i=0;i<ord.size();i++)inv[ord[i]] = i;
    return inv;
  }
  ll FLOOR(ll n,ll div){assert(div>0);return n>=0?n/div:(n-div+1)/div;}
  ll CEIL(ll n,ll div){assert(div>0);return n>=0?(n+div-1)/div:n/div;}
  ll digitsum(ll n){ll ret=0;while(n){ret+=n%10;n/=10;}return ret;}
  ll modulo(ll n,ll d){return (n%d+d)%d;};
  template<typename T>T min(const vector<T>&v){return *min_element(v.begin(),v.end());}
  template<typename T>T max(const vector<T>&v){return *max_element(v.begin(),v.end());}
  template<typename T>T acc(const vector<T>&v){return accumulate(v.begin(),v.end(),T(0));};
  template<typename T>T reverse(const T &v){return T(v.rbegin(),v.rend());};
  //mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
  int popcount(ll x){return __builtin_popcountll(x);};
  int poplow(ll x){return __builtin_ctzll(x);};
  int pophigh(ll x){return 63 - __builtin_clzll(x);};
  template<typename T>T poll(queue<T> &q){auto ret=q.front();q.pop();return ret;};
  template<typename T>T poll(priority_queue<T> &q){auto ret=q.top();q.pop();return ret;};
  template<typename T>T poll(QP<T> &q){auto ret=q.top();q.pop();return ret;};
  template<typename T>T poll(stack<T> &s){auto ret=s.top();s.pop();return ret;};
  ll MULT(ll x,ll y){if(LLONG_MAX/x<=y)return LLONG_MAX;return x*y;}
  ll POW2(ll x, ll k){ll ret=1,mul=x;while(k){if(mul==LLONG_MAX)return LLONG_MAX;if(k&1)ret=MULT(ret,mul);mul=MULT(mul,mul);k>>=1;}return ret;}
  ll POW(ll x, ll k){ll ret=1;for(int i=0;i<k;i++){if(LLONG_MAX/x<=ret)return LLONG_MAX;ret*=x;}return ret;}
  std::ostream &operator<<(std::ostream &dest, __int128_t value) {
    std::ostream::sentry s(dest);
    if (s) {
      __uint128_t tmp = value < 0 ? -value : value;
      char buffer[128];
      char *d = std::end(buffer);
      do {
        --d;
        *d = "0123456789"[tmp % 10];
        tmp /= 10;
      } while (tmp != 0);
      if (value < 0) {
        --d;
        *d = '-';
      }
      int len = std::end(buffer) - d;
      if (dest.rdbuf()->sputn(d, len) != len) {
        dest.setstate(std::ios_base::badbit);
      }
    }
    return dest;
  }
  namespace converter{
    int dict[500];
    const string lower="abcdefghijklmnopqrstuvwxyz";
    const string upper="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    const string digit="0123456789";
    const string digit1="123456789";
    void regi_str(const string &t){
      for(int i=0;i<t.size();i++){
        dict[t[i]]=i;
      }
    }
    void regi_int(const string &t){
      for(int i=0;i<t.size();i++){
        dict[i]=t[i];
      }
    }
    vector<int>to_int(const string &s,const string &t){
      regi_str(t);
      vector<int>ret(s.size());
      for(int i=0;i<s.size();i++){
        ret[i]=dict[s[i]];
      }
      return ret;
    }
    vector<int>to_int(const string &s){
      auto t=s;
      sort(t.begin(),t.end());
      t.erase(unique(t.begin(),t.end()),t.end());
      return to_int(s,t);
    }
    
    vector<vector<int>>to_int(const vector<string>&s,const string &t){
      regi_str(t);
      vector<vector<int>>ret(s.size(),vector<int>(s[0].size()));
      for(int i=0;i<s.size();i++){
        for(int j=0;j<s[0].size();j++){
          ret[i][j]=dict[s[i][j]];
        }
      }
      return ret;
    }
    vector<vector<int>>to_int(const vector<string>&s){
      string t;
      for(int i=0;i<s.size();i++){
        t+=s[i];
      }
      sort(t.begin(),t.end());t.erase(unique(t.begin(),t.end()),t.end());
      return to_int(s,t);
    }
    string to_str(const vector<int>&s,const string &t){
      regi_int(t);
      string ret;
      for(auto z:s)ret+=dict[z];
      return ret;
    }
    vector<string> to_str(const vector<vector<int>>&s,const string &t){
      regi_int(t);
      vector<string>ret(s.size());
      for(int i=0;i<s.size();i++){
        for(auto z:s[i])ret[i]+=dict[z];
      }
      return ret;
    }
  }
  template< typename T = int >
  struct edge {
    int to;
    T cost;
    int id;
    edge():to(-1),id(-1){};
    edge(int to, T cost = 1, int id = -1):to(to), cost(cost), id(id){}
    operator int() const { return to; }
  };

  template<typename T>
  using Graph = vector<vector<edge<T>>>;
  template<typename T>
  Graph<T>revgraph(const Graph<T> &g){
    Graph<T>ret(g.size());
    for(int i=0;i<g.size();i++){
      for(auto e:g[i]){
        int to = e.to;
        e.to = i;
        ret[to].push_back(e);
      }
    }
    return ret;
  }
  template<typename T>
  Graph<T> readGraph(int n,int m,int indexed=1,bool directed=false,bool weighted=false){
    Graph<T> ret(n);
    for(int es = 0; es < m; es++){
      int u,v;
      T w=1;
      cin>>u>>v;u-=indexed,v-=indexed;
      if(weighted)cin>>w;
      ret[u].emplace_back(v,w,es);
      if(!directed)ret[v].emplace_back(u,w,es);
    }
    return ret;
  }
  template<typename T>
  Graph<T> readParent(int n,int indexed=1,bool directed=true){
    Graph<T>ret(n);
    for(int i=1;i<n;i++){
      int p;cin>>p;
      p-=indexed;
      ret[p].emplace_back(i);
      if(!directed)ret[i].emplace_back(p);
    }
    return ret;
  }
}
using namespace template_tute;

template<typename T>
struct SCC{
  int n;
  const Graph<T>&G;
  vector<int>index;//各ノードが属する強連結成分の番号
  vector<int>start,visited,low,ord;
  int now_ord,group_num;
  SCC(const Graph<T> &g):G(g),n(g.size()){
    index.assign(n,-1);
    build();
  }
  void build(){
    low.assign(n,0);ord.assign(n,-1);index.assign(n,0);
    visited.reserve(n);
    now_ord=0,group_num=0;
    for(int i=0;i<n;i++){
      if(ord[i]==-1)dfs(i);
    }
    for(auto& x:index)x=group_num-1-x;
  }
  void dfs(int v){
    low[v]=ord[v]=now_ord++;
    visited.push_back(v);
    for(auto to:G[v]){
      if(ord[to]==-1){
        dfs(to);
        low[v]=min(low[v],low[to]);
      }
      else{
        low[v]=min(low[v],ord[to]);
      }
    }
    if(low[v]==ord[v]){
      while(1){
        int u=visited.back();
        visited.pop_back();
        ord[u]=n;
        index[u]=group_num;
        if(u==v)break;
      }
      group_num++;
    }

  }
  Graph<T>scc_graph;
  void build_edges(){
    scc_graph.resize(*max_element(index.begin(),index.end())+1);
    for(int i=0;i<n;i++){
      for(int j=0;j<G[i].size();j++){
        if(index[i]!=index[G[i][j]]){
          scc_graph[index[i]].emplace_back(index[G[i][j]], G[i][j].cost, G[i][j].id);
        }
      }
    }
  }
  vector<int>compsize(){
    vector<int>ret(*max_element(index.begin(),index.end())+1);
    for(int i=0;i<n;i++)ret[index[i]]++;
    return ret;
  }
  vector<int>output(){return index;};
};
bitset<200003>bit[203];
void solve(){
	ll res=0,buf=0;
  bool judge = true;

  int n,m,k;cin>>n>>m>>k;
  string s;cin>>s;
  vector<string>a(n);
  rep(i,0,n)cin>>a[i];
  vector<int>mg;
  Graph<int>g(n*m);
  string dir="UDLR";
  vector<int>dx={-1,1,0,0},dy={0,0,-1,1};
  ll cnt=0;
  auto ope=[&](int x,int y,int set=-1,int pre=-1){
    rep(i,0,k){
      rep(j,0,4){
        if(s[i]!=dir[j])continue;
        int nx=x+dx[j],ny=y+dy[j];
        //OUT(x,dx[j],y,dy[j],nx,ny);
        if(nx<0||nx>=n||ny<0||ny>=m);
        else if(a[nx][ny]=='0');
        else x=nx,y=ny;
        //OUT(x,y,nx,ny,j,dir[j],dx[j],dy[j]);
        if(set==1){
          if(!bit[i][x*m+y]){
            bit[i][x*m+y]=1;
          }
          else{
            mg.PB(pre+i+1);
            return MP(-1,-1);
          }
        }
        if(set==0){
          bit[i][x*m+y]=0;
        }
        break;
      }
    }
    return MP(x,y);
  };
  auto calc=[&](vector<pair<int,int>>p,int pre){
    //OUT(p,pre);
    for(auto z:p)ope(z.fi,z.se,1,pre);
    for(auto z:p)ope(z.fi,z.se,0,-999999);
  };
  vector<bool>loop(n*m);
  rep(i,0,n)rep(j,0,m){
    if(a[i][j]=='0')continue;
    cnt++;
    auto [nx,ny]=ope(i,j);
    g[nx*m+ny].EB(i*m+j);
    //OUT(i,j,nx,ny);
    if(nx==i&&ny==j)loop[i*m+j]=true;
  }

  SCC<int> scc(g);
  {
    auto sz=scc.compsize();
    rep(i,0,n*m){
      if(sz[scc.index[i]]>1){
        loop[i]=true;
      }
    }
  }
  //OUT(g);
  rep(src,0,n*m){
    if(!loop[src])continue;
    auto dfs=[&](auto &&f,int v)->int {
      int dep=0;
      vector<pair<int,int>>ps;
      for(auto to:g[v]){
        if(loop[to]){
          ps.EB(1e9,to);
        }
        else{
          auto d=f(f,to);
          chmax(dep,d);
          ps.EB(d,to);
        }
      }
      sort(ALLR(ps));
      //OUT(ps);
      if(ps.size()>=2){
        rep(i,1,ps[1].fi+1){
          vector<pair<int,int>>qs;
          rep(j,0,ps.size()){
            if(i>ps[j].fi)break;
            qs.EB(ps[j].se/m,ps[j].se%m);
          }
          int pre=k*(i-1);
          calc(qs,pre);
        }
      }
      return dep+1;
    };
    auto dep=dfs(dfs,src);
  }
  //OUT(mg);
  sort(ALL(mg));
  vector<ll>ret(n*m,-1);
  rep(i,cnt-1,ret.size()){
    ret[i]=0;
  }
  rep(i,0,mg.size()){
    ret[cnt-i-2]=mg[i];
  }
  rep(i,0,ret.size()){
    cout<<ret[i]<<endl;
  }
}

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  int T = 1;
  //cin>>T;
  while(T--){
    solve();
  }
  return 0;
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3908kb

input:

3 3 6
ULDDRR
010
111
010

output:

-1
4
2
1
0
0
0
0
0

result:

ok 9 numbers

Test #2:

score: 0
Accepted
time: 0ms
memory: 3560kb

input:

3 3 6
ULDDRR
010
111
011

output:

7
4
2
1
1
0
0
0
0

result:

ok 9 numbers

Test #3:

score: 0
Accepted
time: 0ms
memory: 3856kb

input:

1 5 1
R
11111

output:

4
3
2
1
0

result:

ok 5 number(s): "4 3 2 1 0"

Test #4:

score: 0
Accepted
time: 463ms
memory: 26736kb

input:

1 200000 200
RDRLDRULURDLDRULLRULLRRULRULRDLLDLRUDDLRURLURLULDRUUURDLUDUDLLLLLURRDURLUDDRRLRRURUUDDLLDDUUUDUULRLRUDULRRUURUDDDDLULULLLLLLLLLLLUDURLURLRLLRRRURUURLUDULDUULRRLULLRUDRDRUUDDRUDRDLLDLURDDDURLUULDRRDLDD
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

3999923
3999865
3999864
3999740
3999729
3999728
3999727
3999726
3999725
3999724
3999723
3999665
3999664
3999540
3999529
3999528
3999527
3999526
3999525
3999524
3999523
3999465
3999464
3999340
3999329
3999328
3999327
3999326
3999325
3999324
3999323
3999265
3999264
3999140
3999129
3999128
3999127
3999...

result:

ok 200000 numbers

Test #5:

score: 0
Accepted
time: 700ms
memory: 20944kb

input:

2 100000 200
UULDRDLURDLDDRDRDUULDLUUULLRURLUUDDDRURURLLRRUDLDDDUDDRRUUURDDULURURLRULLUDLULURUUDURLDRRRDULRDLRRLDUUUDDUUDUDRDRUDLDRRUDRDLDRDLDRRDLRRDRDLRRLUDUDRULLRRLDDLUDDULDRLLLDLURRDDULDDUDULLRRRUURLRRRLURDLRLU
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
384513
384490
384313
384290
384113
384090
383913
383890
383713
383690
383513
383490
383313
383290
383113
383090
382913
382890
382713
382690
382513
382490
382313
382290
382113
382090
381913
381890
381713
381690
381513
381490
381313
381290
381113
381090
380...

result:

ok 200000 numbers

Test #6:

score: 0
Accepted
time: 662ms
memory: 22596kb

input:

5 40000 200
URDDRRUDURLDLUUDUUDDLRRRURULURDRRURRURULUULRRLDLLDUURRDRUULRULULUDRURRRURDDLLDDRLLLUDUDLLDDULUUUULDLDUDLULLDRURRDRDULURLLLUDLRRRDRLUDDUURULURRRDLDRUDLURUUULDLURDDDRRLLLDLRRDLDLDRRURRRRDLRRLLULRRLDUULD
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

1000036
999836
999636
999436
999236
999036
998836
998636
998436
998236
998036
997836
997636
997436
997236
997036
996836
996636
996436
996236
996036
995836
995636
995436
995236
995036
994836
994636
994436
994236
994036
993836
993636
993436
993236
993036
992836
992636
992436
992236
992036
991836
99163...

result:

ok 200000 numbers

Test #7:

score: 0
Accepted
time: 621ms
memory: 22256kb

input:

10 20000 200
UULRURURUDRUULRRRDDDULUURRDUURDLDLLURRDUDDRDULRDURLDDLRRRRRRURLLUUURURDDUDDLLRDRLDDDDRULDRLLDUDLLLUDRURLDDLRRULDRRLLRRRDLRUDDDRRLDLRUDRUUDDDLUDULLDLUDUDUUUDLLRUURRLRLLDLLLLRLLRRDRRLLUDDURDRRDDULLDDULR
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

571658
571458
571258
571058
570858
570658
570458
570258
570058
569858
569658
569458
569258
569058
568858
568658
568458
568258
568058
567858
567658
567458
567258
567058
566858
566658
566458
566258
566058
565858
565658
565458
565258
565058
564858
564658
564458
564258
564058
563858
563658
563458
563258...

result:

ok 200000 numbers

Test #8:

score: 0
Accepted
time: 653ms
memory: 22220kb

input:

20 10000 200
UUDUUDRDLLLURLULDRULUDLRURRUUDLDLUURUDURDRUULULULUURRDDDLUDLLRDDLDULLDURLRRUULLRDULUUDDLRDLDRDLDULULRLLLLUDUUUDDLDLLRLUUDLURLULLURDDDLLLUDDDLRDULLUUDRLDLRDLRLURRUUDLRULURRLLLURRUDLDUDRLUDDRDUUULLDDUDL
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

83411
83305
83211
83105
83011
82905
82811
82705
82611
82505
82411
82305
82211
82105
82011
81905
81811
81705
81611
81505
81411
81305
81211
81105
81011
80905
80811
80705
80611
80505
80411
80305
80211
80105
80011
79905
79811
79705
79611
79505
79411
79305
79211
79105
79011
78905
78811
78705
78611
78505
...

result:

ok 200000 numbers

Test #9:

score: 0
Accepted
time: 764ms
memory: 24156kb

input:

50 4000 200
LUDLUULUUUDUDDUDRULLDDRDRDLDUDRUUDUUUDULDUURDUUDLRUDDDURURRRUDDRUDDRURURURUDLLLDRURLLRRURRLULDDLLURULRDURDDLURURDDURDDRURRDDDULUURLUDRRUULRLURUDULLRURUUDLRDDLULUDRULDRRLRRLURDLUDDRDRLRRDDULRULDLURRRUL
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

53472
53272
53072
52872
52672
52472
52272
52072
51872
51672
51472
51272
51072
50872
50672
50472
50272
50072
49872
49672
49472
49272
49072
48872
48672
48472
48272
48072
47872
47672
47472
47272
47072
46872
46672
46472
46272
46072
45872
45672
45472
45272
45072
44872
44672
44472
44272
44072
43872
43672
...

result:

ok 200000 numbers

Test #10:

score: 0
Accepted
time: 777ms
memory: 22980kb

input:

100 2000 200
UDULUDLDUUDDUDLURDRDLDDLLDRLLDUURUDLLUURLRLLRDLUUUURLLUDRRUDUDDLRLLLDDUUDDULRUUULLRRUUUUUDRLLUUUURDUDLUUDLUDDRRULRLRLUDLRLRRRLRULULLRLLURRUUUDRLRRRRLUURULURUUUUDURRDDDRLLLLULDUDRLDURUUDDRRRULULRLRDULD
10111111111111111111111111111111111111111111111111111111111111111110111111111100111111...

output:

-1
-1
47281
47081
46881
46681
46481
46281
46081
45881
45681
45481
45281
45081
44881
44681
44481
44281
44081
43881
43681
43481
43281
43081
42881
42681
42481
42281
42081
41881
41681
41481
41281
41081
40881
40681
40481
40281
40081
39881
39681
39481
39281
39081
38881
38681
38481
38281
38081
37881
37681
...

result:

ok 200000 numbers

Test #11:

score: 0
Accepted
time: 873ms
memory: 22960kb

input:

200 1000 200
RLRDLDRDUDLRDULDLLURDULDLLDUDLULLLUUUDLRRRUDLUUUDDRLULRRLDLDLLDRLLLURDLDRRRLULUDDLUDUULULUULDRRURDDLUUULURULRUUDRRLRDULDUDRLDLRUDRLULLLLRLLDRDLDLRDUUUUUULUDLDRUDDUUDRLDRUDUUDLULLDDURLRULLRULDRLLRDLURR
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

-1
10432
10232
10062
10032
9994
9887
9862
9832
9794
9687
9662
9632
9594
9487
9462
9432
9394
9287
9262
9232
9194
9087
9062
9032
8994
8887
8862
8832
8794
8687
8662
8632
8594
8487
8462
8432
8394
8287
8262
8232
8194
8135
8087
8062
8032
7994
7935
7887
7862
7832
7794
7736
7735
7687
7662
7632
7594
7553
753...

result:

ok 200000 numbers

Test #12:

score: 0
Accepted
time: 874ms
memory: 22924kb

input:

400 500 200
RULLRRRDLUDDRLDDRDLRLDLDLUUDRUDDULRDDLDULULLRUDULRLRLRUDURDRDDDLDRUDRLRDRLRDLULLLLRURRLRRULULDLDRDDULDDUULURLRLLDUUUUDDUDURLULRLDRLDDRULUDDLLRRDDULLDLURDLDRLLULRLRUULRLLLRULRUDLRRRLURUULLLDDDUDRDLRURD
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

9541
9370
9369
9341
9244
9243
9170
9169
9141
9103
9044
9043
9039
9039
9022
8987
8970
8969
8960
8941
8903
8876
8865
8844
8843
8839
8839
8824
8822
8787
8770
8769
8760
8750
8741
8703
8676
8676
8665
8644
8643
8639
8639
8624
8622
8588
8587
8570
8569
8560
8550
8541
8503
8503
8476
8476
8465
8444
8443
8439
...

result:

ok 200000 numbers

Test #13:

score: 0
Accepted
time: 870ms
memory: 23120kb

input:

447 447 200
LULRUURRDLDUDDRDRLDDUDLRLURUDLLDDLRLRDLURURRDRDDDRRDDLLDRDDDUDULLRLURLLURULLLLRUUULDRDRRDDULULRLURDDUDURDULUURRLDURURDDUDDDDURRLRLLDLULDRURDUUURLRULURUULURURUDDRDDDDLLRRLLLDRLRDDRRLDDRULLLLRURDRUULRUU
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
22650
22450
22250
22050
21850
21650
21450
21250
21050
20850
20650
20450
20250
...

result:

ok 199809 numbers

Test #14:

score: 0
Accepted
time: 867ms
memory: 23412kb

input:

500 400 200
DUUDRULRRRULLDUDDULULLRRDUDRULDRUURUDLDLDDDDRDLDUDRLDLDDURUDDLDLLLRLURDRULDLRLDRRUDRRULURDLDDDLULRLLRRDLUDLLULUULLRLLUURLDDULLRRDDRULUDRRLRRDURLLLDRDRRRLUDUUDUDDLRUDUDLRLDRLURULUULDUDLLDURDLLDDLRLULLU
111111111111111111111111111111111111111111111111011111111111111111111111111111111111111...

output:

11256
11056
10856
10656
10456
10256
10056
9856
9656
9456
9256
9065
9056
8865
8856
8665
8656
8469
8465
8456
8269
8265
8256
8069
8065
8056
7918
7879
7869
7865
7856
7718
7679
7669
7665
7656
7518
7511
7479
7469
7465
7456
7434
7318
7311
7311
7279
7269
7265
7256
7234
7118
7111
7111
7094
7079
7069
7065
705...

result:

ok 200000 numbers

Test #15:

score: 0
Accepted
time: 829ms
memory: 23056kb

input:

1000 200 200
LRUURLUDLDRURRLRLDRDLURDRUDUULDRLULLLRURRURDLULDULDDUDUULRLRDRLRLUDURULRDLDDLUURULDURDLLRUUDURDLURDDDUDRURRDRUUUUDLRUULRDDRLULDURLRDURDLDRRULRURLRUDLRRUUDRRDDLLUULDDDRDLRURLDLRDDULDDDUUDDRURURDDLRRRDR
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
20999
20799
20599
20399
20199
19999
19799
19599
19399
19199
18999
18799
18599
18399
18199
17999
17799
17799
17599
...

result:

ok 200000 numbers

Test #16:

score: 0
Accepted
time: 873ms
memory: 23380kb

input:

2000 100 200
LRLUUDDLLUURLDRUUDUDRRULRDRDURURLRLLLRDLULLDRRRULDUDRDDRRRDUUDDDRLLULDRULRDDLDUULRDUDLRUUUDRDLRLDDUDLLDLLUDDLDRLRLURURLRRRLUULLLDLRLULDRRRLURDRDLRUDDLLLLRUDRLRLLRUDRDLUDLDRDDDLDUDLRDUURDRDUDDDUUDURUUU
11111111111111111111111111111111111111111111111111111111111111111111101111111111111111...

output:

-1
-1
-1
-1
-1
41180
40980
40780
40580
40380
40180
39980
39780
39580
39380
39180
38980
38780
38580
38380
38180
37980
37780
37580
37380
37180
36980
36780
36580
36380
36180
35980
35780
35580
35380
35180
34980
34780
34580
34380
34180
33980
33780
33580
33380
33180
32980
32780
32580
32380
32180
31980
317...

result:

ok 200000 numbers

Test #17:

score: 0
Accepted
time: 753ms
memory: 24180kb

input:

4000 50 200
DRUDDUDULRURRULUUDLLUUURUURLLDUDRRUULULDLRRLUDURLRUDDLRRDLUDURUULRDRURUDUDRDLDUDLDURULURRLRRRDRDRRRDRDUDLUDRDUDLRLDDULLLLLUDRDLLUDRRRLUURDUULLRRLLRLDDLDRDDDUDLRRRURDRLLUDUUURLLDDLLRRLLDRUDRUULUULRURDR
11111111111111111111111111111111111111111111111111
111111111111111111111111111111111111...

output:

-1
112736
112536
112336
112136
111936
111736
111536
111336
111136
110936
110736
110536
110336
110136
109936
109736
109536
109336
109136
108936
108736
108536
108336
108136
107936
107736
107536
107336
107136
106936
106736
106536
106336
106136
105936
105736
105536
105336
105136
104936
104736
104536
104...

result:

ok 200000 numbers

Test #18:

score: 0
Accepted
time: 848ms
memory: 23660kb

input:

10000 20 200
UDLLURURULUUUDDLDRDRLDLRUULDLUUULUULLRRDUUDDLRDRRLUDUDLRRLUURLURRLULRRURLRRLLDLULUDRRDUUUDURRURLDDRRDRRDLDURDRLLURDDDDDURULRULULLUURLUDUUUUDDLURULRUDLUDDRLLUDRLDRRULUDRDUDRUDDDLLRRURULULDLLUDLLRUDRDRL
11111111111111111111
11111111111111111111
11111111111111111111
11111111111111111111
11...

output:

182271
182071
181871
181671
181471
181271
181071
180871
180671
180471
180271
180071
179871
179671
179471
179271
179071
178871
178671
178471
178271
178071
177871
177671
177471
177271
177071
176871
176671
176471
176271
176071
175871
175671
175471
175271
175071
174871
174671
174471
174271
174071
173871...

result:

ok 200000 numbers

Test #19:

score: 0
Accepted
time: 552ms
memory: 23124kb

input:

20000 10 200
RULRLRLLLRUUDLLDDUDUURUUUUDUUDDRDDUULRRLDRDDRRLUURRLUDUDURUDRUDLDLDDURLRDRRRRUDRDLRRRULLLDLRURRDUUURURUDUUUDLLLRDLDDDLRULUDDURRUUDDDLURLDURRRRDLLLDRUDDDULRRLRDURRDURDDUDDUDLDRLLLULLULRULULLRLUUDRLDLDL
1111111111
1111111111
1111111111
1111111111
1111111111
1111111111
1111111111
111111111...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 200000 numbers

Test #20:

score: 0
Accepted
time: 681ms
memory: 24836kb

input:

40000 5 200
LDULRUULURUDRDLRUDUDURUUUDDRLUDDRUDUUUUDURUDUURDRLURLDURDUDRUULURUURRRRURRRLRLUUUULLLLDLDLRUUDDLDRLDURRRRUULDDLRRLRUUUDDRDRDRLLLLRDURLLLLDRRUULLDRLRULRURUDDURLDDRRRULUDULDULRDLDLRLRUUUDRLRRUUDLRULURRD
11111
11111
11111
11111
11111
11111
11111
11111
11111
11111
11111
11111
11111
11111
111...

output:

444424
444224
444024
443824
443624
443424
443224
443024
442824
442624
442424
442224
442024
441824
441624
441424
441224
441024
440824
440624
440424
440224
440024
439824
439624
439424
439224
439024
438824
438624
438424
438224
438024
437824
437624
437424
437224
437024
436824
436624
436424
436224
436024...

result:

ok 200000 numbers

Test #21:

score: 0
Accepted
time: 746ms
memory: 26004kb

input:

100000 2 200
RRULURDRDDUULLLURURULUDRRDLULURRULUURDURDRRLDDRLRDLRLURRDDDRRDRLDDLUDRLUDDLLUDRLDRURLLDDLRURRRLLLLUULRULUDRRLLLLRLLUUULURDDDRRDRDULLLUULLRDDRUDUURRRLURURDLULURLURLDLRULUDDDRULRUDRLUDLDLLLUURDDLRLLULUU
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11...

output:

-1
-1
-1
-1
-1
-1
-1
829117
828917
828717
828517
828317
828117
827917
827717
827517
827317
827117
826917
826717
826517
826317
826117
825917
825717
825517
825317
825117
824917
824717
824517
824317
824117
823917
823717
823517
823317
823117
822917
822717
822517
822317
822117
821917
821717
821517
821317...

result:

ok 200000 numbers

Test #22:

score: 0
Accepted
time: 467ms
memory: 33388kb

input:

200000 1 200
RUDRUUULRUDURLULRLLLRLDLLUURRLURRDDRLRLLDDUULDRURDLRRRLLLRRURURLDRUURLLRRRRLULLURLDULDLUURLLRUDLRRRRURLDRLLDDUUURDRUUULRLDRDLULRRUDRRDDDRLRDLUDLDUUULDDRUUDLULRDULLURUULLRULLUDDRDDLLRRUUUDULDLDRDLLDDDU
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

output:

4444289
4444280
4444277
4444231
4444174
4444171
4444118
4444117
4444094
4444089
4444080
4444077
4444031
4443974
4443971
4443918
4443917
4443894
4443889
4443880
4443877
4443831
4443774
4443771
4443718
4443717
4443694
4443689
4443680
4443677
4443631
4443574
4443571
4443518
4443517
4443494
4443489
4443...

result:

ok 200000 numbers

Test #23:

score: 0
Accepted
time: 859ms
memory: 24532kb

input:

447 447 200
DRUDULRLDRLUUUDRRDULUDRUURRRLDRDUDULDRLRLUDLDRURDRDUULRRUDRRLDULLRRLDDRRDRLRDRLRLDDRRULDLRDRUDRUDDRRLRRULDDDLRLRURLLULLDLDDRDDULRULURDULDULULRURDLLLRUDUUUURUDRDRLRLDRURRLLLURDUDDDDULLRDRDUDLDULLRULLLD
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

12700
12500
12485
12478
12474
12316
12300
12285
12278
12277
12274
12144
12116
12100
12085
12078
12077
12074
11944
11916
11900
11885
11878
11877
11874
11744
11716
11700
11685
11678
11677
11674
11544
11516
11500
11485
11478
11477
11474
11344
11316
11300
11285
11278
11277
11274
11144
11116
11100
11085
...

result:

ok 199809 numbers

Test #24:

score: 0
Accepted
time: 647ms
memory: 22056kb

input:

447 447 200
RRUULDLLULUUDLDUUDDRLDUDLLDLUURDLDURLUDUDLRRDDDDUUULRDDRDURDDDLDRDDLRDDLULUDLURDDRUUDUUDUDLRRDRUDDUUDLRRUDLRDDLUUUDDURDLDDLULUURUURDDLLUDRDRDLLLRDRLUDLLRDUDRRRDURUDLLLUUUDULLRRUDRLLLDDLURUUDRLDDRUUURL
110111111111111111111111111111111111011111111111111111111111111111101111111101111111111...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
12867
12667
12667
12467
12467
12267
12267
12067
12067
11867
118...

result:

ok 199809 numbers

Test #25:

score: 0
Accepted
time: 547ms
memory: 21812kb

input:

447 447 200
LULULUDRURRURLDRLUUDDLDUDRLLUDRLLLLDDUULLLLRLUDLRRLDRRRLURRULULURRRUULUUDRLUDDLRRDDRLLURLDDULLDURDULRRURULLRUURLUUUULULLDLRLDLULULDDRDUDRULUUDUUDRRRDRURUUDLDDRRLDLRLLULLRLURDDULRLUDLRLUDUDUDLLRRUULDDU
111101111111111101111111111110011111101101111111111111111111111111111111111001011101111...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
9719
9519
9433
9319
9233
9119
9033
8919
8833
8719
8633
8519
8433
8319
8233
8130
8119
8033
7930
7919
7833
773...

result:

ok 199809 numbers

Test #26:

score: 0
Accepted
time: 285ms
memory: 19576kb

input:

447 447 200
UDUDDURLLULURDRLLDLLRDDRDRUDRRRURLRDRDDURURDUUDRUUDURDRLULLRLDDLRURUDDRDULDUDDRLLDDRRULURRUUDDURRURDRRLUDLRLLDLUUDDLUDUULLLLUULDURRDDRDDLULLULDRLRLLUURLDUDRUDDLUUULUDUUUDUUDLUDDRLDDDRRDUURUUDDDRDLRLRL
001100011110110011011100101110111101101001000011011010011001100100000111110101010100100...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 199809 numbers

Test #27:

score: 0
Accepted
time: 46ms
memory: 17460kb

input:

447 447 200
DRLLUUDDULDRRDDDLLRRLUDLUURULDLRUDULDLLLRLDLLUDUDDULRUULRDDLDLUDRDRUDRRLLDDUDLDLULLUULRDRDRUUURDRRRDRRUULLDUUDDDUDRUDLRLRRLRUDDURULUUULULDDRRRLRURDLRDLDRUUDRUUDRRLDLUULLRLURURRURLLDDLRRLRURLRURULUULLR
000010000000000000101000000000100000000000000000000000000000001000000000000000000000000...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 199809 numbers

Test #28:

score: 0
Accepted
time: 660ms
memory: 22280kb

input:

100 2000 200
DURRLLDURUUDULRRUDRRUDLURRDUURLUURLUDLRURLRLRRRURDDRULRRULLUUDUDRDLUDDRRDRRDULUDUDULDRDLRUUULLRLULURRRRDDRUULDLLDUDDRLDURLULURUDRLRDLULRDLLLDRLDULLRRDLDURDUURLDLLRLLDDURUDRDDLUURDURRULRRRDDLLRRDURRDDU
11110111111111111011111111111111111011111111111111110111111111111111111111111011111111...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
32875
32675
32475
32275
32075
31875
31675
31475
31275
31075
30875
30675
30475
30275
30075
29875
29675
29475
29275
29075
28875
28675
28475
28275
28075
27875
27675
27475
27275
27075
26875
26675
26475
26275
26075
25875
25675
25475
25275
25075
24875
24675
24475
242...

result:

ok 200000 numbers

Test #29:

score: 0
Accepted
time: 661ms
memory: 22080kb

input:

200 1000 200
UDDLRLLURDDRDLRURLUURDRRRUULUULLRDDLRRDUUDDULDDUULULLLRDRUUDRRULRDLLUUDURDLDUURLRDDUDRURDRLRUDRLURUULDRLURUURLRULUUULLLRUDDDLRULLLRRDULUDDURURUURDUUULDRURDDDULULRRULRLLULULLURDDLDRRULLLULDLUDLLRDDUDRL
11111111111111111111111111011111111111111111110111111111111111110111111111111111111111...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
4972
4792
4772
4718
4592
4572
4518
4399
4392
4372
4359
4318
4207
4199...

result:

ok 200000 numbers

Test #30:

score: 0
Accepted
time: 617ms
memory: 21880kb

input:

400 500 200
URDRUUDRDUUDRRRUUDLDDLRRRLRULLRDDDULRURUURLLRDLULURRURRRLLRRLDUDLDRRRLLUUUDULLDRRDDRULULDUUDDRLRUURRRLDDRRUDRDDDDDLLURDLDUDDLRURLDRUUDUDRURURLDURRULDRLDDRLRLDLLUURUULRRRULLUDDLDRRDLDRRDRRURLURLDULDDLU
111111101111111111111111111111110111111101111011111111111111111111111111111111111111111...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
8513
8434
8353
8313
8234
8153
8113
8034
7953
7953
7913
7900
7834
7753
7753
7713
7700
7634
7553
7553
7553
7513
7500
7434
7398
7358
7353
7353
7353
7352
7313
7300
7234
7198
7158
7153
7153
7153...

result:

ok 200000 numbers

Test #31:

score: 0
Accepted
time: 659ms
memory: 22120kb

input:

500 400 200
LRLLDDDLLRRLLRDURRLLDLUDLLRDRULRURULUDURRUDDRLRDRLURRDURLLLDLRUDRDLUURUDDUUDUUDUURRLDRURLDULDRLLLDDUUUULRDLUDURLLRDRRLUDLLRLURUULUURDRULLDDDLRDLRUURDUUDRDLDRURDDURUDUDRUUUDURUUDURDUUDURLDDRUDDDRLRLRDR
111111111111101101111111011111111111111111111111111111111111111111111111111111111111111...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 200000 numbers

Test #32:

score: 0
Accepted
time: 680ms
memory: 22096kb

input:

1000 200 200
RLRDURLUDDLRRURLUDRLUUURULRLLULRRRRUDLRRDLUULDRDURLDLURLUDULLRDLRLDLRUDLLRRULLUUDDRRDUUULUDLRLDUDLUURDUUURRUULRLRLUUDLLLULUDLRLDUUUURDUDRRDLRDLRRLRULDDRULURDUULULLUDDLLUDRURURRUDRUDLDRLRLDLUULLRUUUUDD
11111111110111111101111111110111111111111111011111111111111110101111111110111111011111...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
11932
11732
11725
11596
11532
11525
11520
11396
11393
11332
11325
11320
11196
11193
11132
11125
11120
10996
10993
10932
10925
10920
10829
10796
10793
10732
10725
10720
10629
10596
10593
10532
10525
10520
10429
10396
10393
10332
10325
10320
10229
10196
10193
...

result:

ok 200000 numbers

Test #33:

score: 0
Accepted
time: 640ms
memory: 21944kb

input:

2000 100 200
RLDDDLUDDURRDLURDUULDRDUURDULDDRLLRUDDULDDRURDUULLDDDUULDDRUUDRUUDLLLULRRDRULRUDURRRRDULRRLUUDRULRRUURURDUDULULDLLLUDDLLLURRDRRRDDDDRUULDLULUULURLLDDUUDRUDDRDDLLDUDRDDDLUUURRLLUUUDLLURURURRLUUUDUUDDUL
01111111111101111111110111111111111111011111111111111111111111111111111111111111101111...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 200000 numbers

Test #34:

score: 0
Accepted
time: 556ms
memory: 21760kb

input:

100 2000 200
UDDRLDUDRDRLLLRDLRLDLDULLULUUULDUUULULLDDDLLULRDLURLUUULRDRRLURURLULLLDULRUULURUDRDLRUDUDURUUUDDRLUDDRUDUUUUDURUDUURDRLURLDURDUDRUULURUURRRRURRRLRLUUUULLLLDLDLRUUDDLDRLDURRRRUULDDLRRLRUUUDDRDRDRLLLLRD
11111111111111111111111111111011011111111011111110111111111111100111111110111111110111...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 200000 numbers

Test #35:

score: 0
Accepted
time: 595ms
memory: 22044kb

input:

200 1000 200
ULRLUUDDRLUURDRRDULLDDULLLDLRULRRRRULRULLDRDRUUDLDLLLRUULRDUDLRDRLRUDDUDULUULDLUURLRRUUURRDURLDLRUURUDULRDUDLDULLURRURURULDLDDRDRRUURRULRLDURRLLDRUDDUURLLLRRLDLRDDRLRUULLDLRLDDRUUDRUULRDRDLDULULLULLDU
11111111111111111111111111111111111111111111111111111111101111101111111111111110111111...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 200000 numbers

Test #36:

score: 0
Accepted
time: 552ms
memory: 21656kb

input:

400 500 200
RURRDRUULDRLDRRLLRURRLUDLRURLLRLDRLURURLDLDLUULDURDLDUULDDULRDUULRDLURDDUURRDRULDRLRLUURUURLUUURRURDDRDDRUUDLULRDDDULULLLUDLDDRRLRUDDULLUDUDLDRLUUURLLULRLRDURLUDLDRDLDDDRRLDURLLDLRDDDRRDUURRRRRRDDRLUD
111111100111111111111111111111111111111111101110111101111011111110101111111111111110101...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 200000 numbers

Test #37:

score: 0
Accepted
time: 573ms
memory: 21824kb

input:

500 400 200
DUULDRURLULRULDLULUURLLUDRUDRULUDULUUDUUURUDUDRLLDLLRRDDDDLRRLRURLULDURRLULULLULLDUDLUUUUDRRRDUDDDDLLUDLRRLUURUULRULDRLDLLRURDRURDDULDLRRLLLDLRUULUURRRLUURLDLLURRULLURDLRDDDLLURLRRUURDDULLRDDDRLRLUURD
011110111111111111101111101111111111111111110111111011111111111111111111111111111010011...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
11623
114...

result:

ok 200000 numbers

Test #38:

score: 0
Accepted
time: 524ms
memory: 21856kb

input:

1000 200 200
RRDDDLLDLLDUDURDLRDURUDDRUULLDLURUDDULLDLLRDRURLLLUULLUURDUDURUURURUUUURRUDRDRRLRRULRDULUUURLRRRULULDDDURDRURDRURLRRRRRDDLDRUDDDDLDDDURRURLRLUUDURRDRRRRLLLDRLUULURRLDUULUDUDLDRLRRLULRRRURDLDRLRDDRRDLR
01111111111111111111101111111011111111111111111111111101111111111011111111111110111111...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 200000 numbers

Test #39:

score: 0
Accepted
time: 529ms
memory: 21692kb

input:

2000 100 200
LRRDLURLLDLUULULRRRURURRRULRLLDURRDLUDUURUDUUURDUURULLDUUDURLDRLULUDRDUUULDRDURRDUURURUUDRDDRLDRDRRLLRDRDDDUDLRRRRDRRLRDRURDUDRRLLLLDRLULRDRRRRLURLLLRRDURLRDRDUUUDRUDURURLUULULLLURLLLULUURRRUULUDRULDU
11111111111111101111110100111111011111111111110110111111111111111111110011111110111111...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
26086
25886
25686
25486
25286
25086
24886
24686
24486
24286
24086
23886
23686
23486
23286
23086
22886
22686
22486
22286
22086
21886
21686
21486
21286
21086
20886
20686
20486
20286
20086
19886
19686
19486
19286
19086
188...

result:

ok 200000 numbers

Test #40:

score: 0
Accepted
time: 367ms
memory: 26220kb

input:

66663 3 200
RUDLLUDRLUDRLDURRDULRDULLDDRUDLLDURLDURLUDRLUDRLDURRUDLRDULRUDLRDULLUDRRUDLRDULRDULRDULLUDRLDURLDURRUDLLUDRRUDLLDURRDULLUDRLUDRRDULRDULUDRUDLLUDRRDULLUDRRDULRDULLDURLUDRRUDLLDURRUULDURRDULLUDRLUDRRUDL
011
010
011
010
011
010
011
010
011
010
011
010
011
010
011
010
011
010
011
010
011
010...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 199989 numbers

Test #41:

score: 0
Accepted
time: 494ms
memory: 39264kb

input:

66666 3 200
RURRLUUUULDLDRRRURURRLRULDLLRRRULURURULDUUDDDUURDRDLDRUUDLLUUULDDULULLLLLDLURUDURLDDDULRLDURRLURULRLDDURUDUDRDDLDDLLULDDLLLLDUDRDRLLRUDUULDLLRLLDDLRURRLURUDLUDUDDDUURDLRLDURRDRLRRDRDRLDDLLUDRRRRURRLUU
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101
101...

output:

-1
-1
-1
-1
13320869
13320681
13320669
13320481
13320469
13320281
13320269
13320081
13320069
13319881
13319869
13319681
13319669
13319481
13319469
13319281
13319269
13319081
13319069
13318881
13318869
13318681
13318669
13318481
13318469
13318281
13318269
13318081
13318069
13317881
13317869
13317681
...

result:

ok 199998 numbers

Test #42:

score: 0
Accepted
time: 177ms
memory: 24140kb

input:

200000 1 200
LRLLRRLLRLRRLRLLRRLRLLRRLLLLRLLRRRRRLRRLLRRLLLLLRLLRRRRRLRLLRLRLLRRRRLRLLRRLRLRLRRRRLLLLRRRRLRRLLRLRLLLLRLLRLLRLRRRLRLLLLRLLLLLLLLLLLRRRLRLRRRLRRRRLLRLLRLRLRRRLLRLRLLRLLRRLLLRLLLRRRRLRRRRLLLRRRRRRRRLR
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 200000 numbers

Test #43:

score: 0
Accepted
time: 255ms
memory: 25164kb

input:

200000 1 200
DUDDUUUDDUUDUUUUDDDDUDDUDUDUUDDDUUDUUDUUUUUDDUDUDUUDDDUUUUDUUDDDDUDDUDDUDDDDUUUUUDUUUUUDUDUDDDDUUDUDDDDUDDUUUDUUDDDUDUUDUDUDDDUDDDDDUDUDUUDUUUDUUDDDUUDUDUDUUDDUUDDUUDDUUUUDUUUDDDDDDUUDUUDDUUDUUDUDDUDD
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 200000 numbers

Test #44:

score: 0
Accepted
time: 307ms
memory: 24528kb

input:

4 49999 200
RRRUUUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDULLDD
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 199996 numbers

Test #45:

score: 0
Accepted
time: 520ms
memory: 29072kb

input:

4 49999 200
RRRUUUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDUDULLDD
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 199996 numbers

Extra Test:

score: 0
Extra Test Passed