Language: C++

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;

typedef pair<int,int> PII;
typedef long long LL;
#define CLR(a,b) memset(a,b,sizeof(a))
#define MP make_pair
#define FI first
#define SE second

const int N = 1000;
PII a[2][N][2];
bool in[N];
int n,l;
int last[2];
int time[2];
int t = 0;

void update(int p, int who,int t)
{
    if(p == 0){
        last[0] = who;
        time[0] = t;
        in[who] = 0;
    }
    if(p == l){
        last[1] = who;
        time[1] = t;
        in[who] = 0;
    }
}
void solve()
{
    CLR(last,0);
    CLR(time,0);
    for(int i = 1; i <= n ; i++)in[i] = 1;
    for(int i = 1; i <= t ;i ++){
        CLR(a[i & 1] , 0);
        for (int j = 1; j < l ; j++){
            for(int k = 0; k <= 1; k++){
                PII cur = a[!(i&1)][j][k];
                if(cur.FI != 0 && in[cur.FI]){
                    if(a[i&1][j+cur.SE][0].FI == 0){
                        a[i&1][j+cur.SE][0] = MP(cur.FI, cur.SE);
                    }else{
                        a[i&1][j+cur.SE][1] = MP(cur.FI, -cur.SE);
                        a[i&1][j+cur.SE][0].SE = -a[i&1][j+cur.SE][0].SE;
                    }
                    update(j+cur.SE,cur.FI,i);
                }
            }
        }
    }
    int ans = time[0] >= time[1] ? last[0] : last[1];
    printf("%d %d\n",t,ans);
}
int main()
{
   // freopen("input.txt","r",stdin);
    while(~scanf("%d%d",&n,&l) && (n||l)){
        t = 0;
        CLR(a, 0);
        CLR(in,0);
        for(int i = 1 ; i <= n ; i++){
            int p;
            char s;
            scanf(" %c%d",&s,&p);
            int d = (s == 'L')? -1 : 1 ;
            if(d == -1) t = max(t , p);
            else t = max(t, l-p);
            a[0][p][0] = MP( i , d );
        }
        solve();
    }
    return 0;
}

Compiler output:
a.cc:21:11: error: 'int time [2]' redeclared as different kind of entity
   21 | int time[2];
      |           ^
In file included from /usr/include/pthread.h:23,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
                 from /usr/include/c++/14/ext/atomicity.h:35,
                 from /usr/include/c++/14/bits/ios_base.h:39,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
   76 | extern time_t time (time_t *__timer) __THROW;
      |               ^~~~
a.cc: In function 'void update(int, int, int)':
a.cc:28:15: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   28 |         time[0] = t;
      |               ^
a.cc:28:17: error: assignment of read-only location '* time'
   28 |         time[0] = t;
      |         ~~~~~~~~^~~
a.cc:33:15: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   33 |         time[1] = t;
      |               ^
a.cc:33:17: error: assignment of read-only location '*(time + 1)'
   33 |         time[1] = t;
      |         ~~~~~~~~^~~
a.cc: In function 'void solve()':
a.cc:40:9: error: ISO C++ forbids applying 'sizeof' to an expression of function type [-fpermissive]
   40 |     CLR(time,0);
      |         ^
a.cc:11:36: note: in definition of macro 'CLR'
   11 | #define CLR(a,b) memset(a,b,sizeof(a))
      |                                    ^
a.cc:40:9: error: invalid conversion from 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} to 'void*' [-fpermissive]
   40 |     CLR(time,0);
      |         ^~~~
      |         |
      |         time_t (*)(time_t*) noexcept {aka long int (*)(long int*) noexcept}
a.cc:11:25: note: in definition of macro 'CLR'
   11 | #define CLR(a,b) memset(a,b,sizeof(a))
      |                         ^
In file included from /usr/include/c++/14/cstring:43,
                 from a.cc:5:
/usr/include/string.h:61:28: note:   initializing argument 1 of 'void* memset(void*, int, size_t)'
   61 | extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
      |                      ~~~~~~^~~
a.cc:59:21: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   59 |     int ans = time[0] >= time[1] ? last[0] : last[1];
      |                     ^
a.cc:59:32: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   59 |     int ans = time[0] >= time[1] ? last[0] : last[1];
      |                                ^